blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
3
616
content_id
stringlengths
40
40
detected_licenses
sequencelengths
0
112
license_type
stringclasses
2 values
repo_name
stringlengths
5
115
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
777 values
visit_date
timestamp[us]date
2015-08-06 10:31:46
2023-09-06 10:44:38
revision_date
timestamp[us]date
1970-01-01 02:38:32
2037-05-03 13:00:00
committer_date
timestamp[us]date
1970-01-01 02:38:32
2023-09-06 01:08:06
github_id
int64
4.92k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
22 values
gha_event_created_at
timestamp[us]date
2012-06-04 01:52:49
2023-09-14 21:59:50
gha_created_at
timestamp[us]date
2008-05-22 07:58:19
2023-08-21 12:35:19
gha_language
stringclasses
149 values
src_encoding
stringclasses
26 values
language
stringclasses
1 value
is_vendor
bool
2 classes
is_generated
bool
2 classes
length_bytes
int64
3
10.2M
extension
stringclasses
188 values
content
stringlengths
3
10.2M
authors
sequencelengths
1
1
author_id
stringlengths
1
132
879f7c7ab47377aff0eec96c063e67a82596dc98
bf8d344b17e2ff9b7e38ad9597d5ce0e3d4da062
/ppdet/modeling/reid/fairmot_embedding_head.py
98ca257fd55db020d0e2d483684b5391c28bce49
[ "Apache-2.0" ]
permissive
PaddlePaddle/PaddleDetection
e7e0f40bef75a4e0b6dcbacfafa7eb1969e44961
bd83b98342b0a6bc8d8dcd5936233aeda1e32167
refs/heads/release/2.6
2023-08-31T07:04:15.357051
2023-08-18T02:24:45
2023-08-18T02:24:45
217,475,193
12,523
3,096
Apache-2.0
2023-09-10T10:05:56
2019-10-25T07:21:14
Python
UTF-8
Python
false
false
9,076
py
# Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import numpy as np import math import paddle import paddle.nn as nn import paddle.nn.functional as F from paddle.nn.initializer import KaimingUniform, Uniform from ppdet.core.workspace import register from ppdet.modeling.heads.centernet_head import ConvLayer __all__ = ['FairMOTEmbeddingHead'] @register class FairMOTEmbeddingHead(nn.Layer): __shared__ = ['num_classes'] """ Args: in_channels (int): the channel number of input to FairMOTEmbeddingHead. ch_head (int): the channel of features before fed into embedding, 256 by default. ch_emb (int): the channel of the embedding feature, 128 by default. num_identities_dict (dict): the number of identities of each category, support single class and multi-calss, {0: 14455} as default. """ def __init__(self, in_channels, ch_head=256, ch_emb=128, num_classes=1, num_identities_dict={0: 14455}): super(FairMOTEmbeddingHead, self).__init__() assert num_classes >= 1 self.num_classes = num_classes self.ch_emb = ch_emb self.num_identities_dict = num_identities_dict self.reid = nn.Sequential( ConvLayer( in_channels, ch_head, kernel_size=3, padding=1, bias=True), nn.ReLU(), ConvLayer( ch_head, ch_emb, kernel_size=1, stride=1, padding=0, bias=True)) param_attr = paddle.ParamAttr(initializer=KaimingUniform()) bound = 1 / math.sqrt(ch_emb) bias_attr = paddle.ParamAttr(initializer=Uniform(-bound, bound)) self.reid_loss = nn.CrossEntropyLoss(ignore_index=-1, reduction='sum') if num_classes == 1: nID = self.num_identities_dict[0] # single class self.classifier = nn.Linear( ch_emb, nID, weight_attr=param_attr, bias_attr=bias_attr) # When num_identities(nID) is 1, emb_scale is set as 1 self.emb_scale = math.sqrt(2) * math.log(nID - 1) if nID > 1 else 1 else: self.classifiers = dict() self.emb_scale_dict = dict() for cls_id, nID in self.num_identities_dict.items(): self.classifiers[str(cls_id)] = nn.Linear( ch_emb, nID, weight_attr=param_attr, bias_attr=bias_attr) # When num_identities(nID) is 1, emb_scale is set as 1 self.emb_scale_dict[str(cls_id)] = math.sqrt(2) * math.log( nID - 1) if nID > 1 else 1 @classmethod def from_config(cls, cfg, input_shape): if isinstance(input_shape, (list, tuple)): input_shape = input_shape[0] return {'in_channels': input_shape.channels} def process_by_class(self, bboxes, embedding, bbox_inds, topk_clses): pred_dets, pred_embs = [], [] for cls_id in range(self.num_classes): inds_masks = topk_clses == cls_id inds_masks = paddle.cast(inds_masks, 'float32') pos_num = inds_masks.sum().numpy() if pos_num == 0: continue cls_inds_mask = inds_masks > 0 bbox_mask = paddle.nonzero(cls_inds_mask) cls_bboxes = paddle.gather_nd(bboxes, bbox_mask) pred_dets.append(cls_bboxes) cls_inds = paddle.masked_select(bbox_inds, cls_inds_mask) cls_inds = cls_inds.unsqueeze(-1) cls_embedding = paddle.gather_nd(embedding, cls_inds) pred_embs.append(cls_embedding) return paddle.concat(pred_dets), paddle.concat(pred_embs) def forward(self, neck_feat, inputs, bboxes=None, bbox_inds=None, topk_clses=None): reid_feat = self.reid(neck_feat) if self.training: if self.num_classes == 1: loss = self.get_loss(reid_feat, inputs) else: loss = self.get_mc_loss(reid_feat, inputs) return loss else: assert bboxes is not None and bbox_inds is not None reid_feat = F.normalize(reid_feat) embedding = paddle.transpose(reid_feat, [0, 2, 3, 1]) embedding = paddle.reshape(embedding, [-1, self.ch_emb]) # embedding shape: [bs * h * w, ch_emb] if self.num_classes == 1: pred_dets = bboxes pred_embs = paddle.gather(embedding, bbox_inds) else: pred_dets, pred_embs = self.process_by_class( bboxes, embedding, bbox_inds, topk_clses) return pred_dets, pred_embs def get_loss(self, feat, inputs): index = inputs['index'] mask = inputs['index_mask'] target = inputs['reid'] target = paddle.masked_select(target, mask > 0) target = paddle.unsqueeze(target, 1) feat = paddle.transpose(feat, perm=[0, 2, 3, 1]) feat_n, feat_h, feat_w, feat_c = feat.shape feat = paddle.reshape(feat, shape=[feat_n, -1, feat_c]) index = paddle.unsqueeze(index, 2) batch_inds = list() for i in range(feat_n): batch_ind = paddle.full( shape=[1, index.shape[1], 1], fill_value=i, dtype='int64') batch_inds.append(batch_ind) batch_inds = paddle.concat(batch_inds, axis=0) index = paddle.concat(x=[batch_inds, index], axis=2) feat = paddle.gather_nd(feat, index=index) mask = paddle.unsqueeze(mask, axis=2) mask = paddle.expand_as(mask, feat) mask.stop_gradient = True feat = paddle.masked_select(feat, mask > 0) feat = paddle.reshape(feat, shape=[-1, feat_c]) feat = F.normalize(feat) feat = self.emb_scale * feat logit = self.classifier(feat) target.stop_gradient = True loss = self.reid_loss(logit, target) valid = (target != self.reid_loss.ignore_index) valid.stop_gradient = True count = paddle.sum((paddle.cast(valid, dtype=np.int32))) count.stop_gradient = True if count > 0: loss = loss / count return loss def get_mc_loss(self, feat, inputs): # feat.shape = [bs, ch_emb, h, w] assert 'cls_id_map' in inputs and 'cls_tr_ids' in inputs index = inputs['index'] mask = inputs['index_mask'] cls_id_map = inputs['cls_id_map'] # [bs, h, w] cls_tr_ids = inputs['cls_tr_ids'] # [bs, num_classes, h, w] feat = paddle.transpose(feat, perm=[0, 2, 3, 1]) feat_n, feat_h, feat_w, feat_c = feat.shape feat = paddle.reshape(feat, shape=[feat_n, -1, feat_c]) index = paddle.unsqueeze(index, 2) batch_inds = list() for i in range(feat_n): batch_ind = paddle.full( shape=[1, index.shape[1], 1], fill_value=i, dtype='int64') batch_inds.append(batch_ind) batch_inds = paddle.concat(batch_inds, axis=0) index = paddle.concat(x=[batch_inds, index], axis=2) feat = paddle.gather_nd(feat, index=index) mask = paddle.unsqueeze(mask, axis=2) mask = paddle.expand_as(mask, feat) mask.stop_gradient = True feat = paddle.masked_select(feat, mask > 0) feat = paddle.reshape(feat, shape=[-1, feat_c]) reid_losses = 0 for cls_id, id_num in self.num_identities_dict.items(): # target cur_cls_tr_ids = paddle.reshape( cls_tr_ids[:, cls_id, :, :], shape=[feat_n, -1]) # [bs, h*w] cls_id_target = paddle.gather_nd(cur_cls_tr_ids, index=index) mask = inputs['index_mask'] cls_id_target = paddle.masked_select(cls_id_target, mask > 0) cls_id_target.stop_gradient = True # feat cls_id_feat = self.emb_scale_dict[str(cls_id)] * F.normalize(feat) cls_id_pred = self.classifiers[str(cls_id)](cls_id_feat) loss = self.reid_loss(cls_id_pred, cls_id_target) valid = (cls_id_target != self.reid_loss.ignore_index) valid.stop_gradient = True count = paddle.sum((paddle.cast(valid, dtype=np.int32))) count.stop_gradient = True if count > 0: loss = loss / count reid_losses += loss return reid_losses
98084a7476472c8403acef49cb2182be1e15d07c
e1867a1c31a4b8c61ab04e2e9b20750fe4481137
/test/test_ibnode.py
512d3bd9751bd59b55cf26fdef4f4860bab67d84
[ "MIT" ]
permissive
tmsincomb/pyontutils
4c0235178818adae9b971d0ffa85726dacba7f79
4444ec1e8d903fdf61465b19c4157d52376e866a
refs/heads/master
2023-03-20T00:51:47.392754
2023-03-06T16:58:03
2023-03-06T16:58:03
97,636,258
0
0
null
2017-07-18T19:32:22
2017-07-18T19:32:22
null
UTF-8
Python
false
false
7,689
py
import unittest from pathlib import Path import rdflib from pyontutils.core import yield_recursive from pyontutils.identity_bnode import bnodes, IdentityBNode from .common import temp_path class TestIBNode(unittest.TestCase): def setUp(self): self.graph1 = rdflib.Graph() file = Path('ttlser/test/nasty.ttl') with open(file.as_posix(), 'rb') as f: self.ser1 = f.read() self.graph1.parse(data=self.ser1, format='turtle') g2format = 'nt' # broken serialization :/ with full lenght prefixes self.ser2 = self.graph1.serialize(format=g2format, encoding='utf-8') with open('test_ser2.ttl', 'wb') as f: f.write(self.ser2) self.graph2 = rdflib.Graph() self.graph2.parse(data=self.ser2, format=g2format) # FIXME this doesn't account for changes in identity # under normalization for example by ttlser # IBNode should not do the normalization itself # because we do want normalized forms to have a # different identity, the question does arrise however # about where symmetric predicates fit ... I think those # are not a normalization of representation case I think # they are clearly an ordering cases and thus in scope for # IBNode, in the say way reordering lists is in scope def test_bytes(self): test = b'hello' ident = IdentityBNode(test).identity m = IdentityBNode.cypher() m.update(test) h = m.digest() assert ident == h, ident def test_string(self): test = 'hello' ident = IdentityBNode(test).identity m = IdentityBNode.cypher() m.update(test.encode(IdentityBNode.encoding)) h = m.digest() assert ident == h, ident def test_pair(self): test = 'hello', 'world' ibn = IdentityBNode(test) ident = ibn.identity m = IdentityBNode.cypher() for i, t in enumerate(test): m.update(t.encode(IdentityBNode.encoding)) if not i % 2: m.update(ibn.cypher_field_separator_hash) h = m.digest() assert ident == h, ident def test_ser(self): assert IdentityBNode(self.ser1) != IdentityBNode(self.ser2), 'serialization matches!' def test_nodes(self): assert IdentityBNode('hello there') == IdentityBNode('hello there') assert IdentityBNode(b'hello there') == IdentityBNode(b'hello there') try: assert IdentityBNode(rdflib.BNode()) != IdentityBNode(rdflib.BNode()) # TODO consider returning the bnode itself? raise AssertionError('identity bnode returned identity for bnode') except ValueError as e: pass try: bnode = rdflib.BNode() assert IdentityBNode(bnode) == IdentityBNode(bnode) raise AssertionError('identity bnode returned identity for bnode') except ValueError as e: pass lit1 = rdflib.Literal('hello there') lit2 = rdflib.Literal('hello there', datatype=rdflib.XSD.string) lit3 = rdflib.Literal('hello there', lang='klingon') assert IdentityBNode(lit1) == IdentityBNode(lit1) assert IdentityBNode(lit2) == IdentityBNode(lit2) assert IdentityBNode(lit3) == IdentityBNode(lit3) assert IdentityBNode(lit1) != IdentityBNode(lit2) assert IdentityBNode(lit1) != IdentityBNode(lit3) assert IdentityBNode(lit2) != IdentityBNode(lit3) uri1 = rdflib.URIRef('http://example.org/1') uri2 = rdflib.URIRef('http://example.org/2') assert IdentityBNode(uri1) == IdentityBNode(uri1) assert IdentityBNode(uri2) == IdentityBNode(uri2) assert IdentityBNode(uri1) != IdentityBNode(uri2) def test_bnodes(self): assert sorted(bnodes(self.graph1)) != sorted(bnodes(self.graph2)), 'bnodes match!' def test_nifttl(self): fmt = 'nifttl' s1 = self.graph1.serialize(format=fmt) g2 = rdflib.Graph() [g2.add(t) for t in self.graph1] [g2.namespace_manager.bind(k, str(v)) for k, v in self.graph1.namespaces()] s2 = g2.serialize(format=fmt) try: assert s1 == s2 except AssertionError as e: with open(temp_path / 'f1.ttl', 'wb') as f1, open(temp_path / 'f2.ttl', 'wb') as f2: f1.write(s1) f2.write(s2) raise e def test_ibnode(self): def sbs(l1, l2): for a, b in zip(l1, l2): print('', a[:5], a[-5:], '\n', b[:5], b[-5:], '\n\n') def ds(d1, d2): for (k1, v1), (k2, v2) in sorted(zip(sorted(d1.items()), sorted(d2.items()))): if k1 != k2: # TODO len t1 != len t2 for t1, t2 in sorted(zip(sorted(v1), sorted(v2))): print(tuple(e[:5] if type(e) == bytes else e for e in t1)) print(tuple(e[:5] if type(e) == bytes else e for e in t2)) print() id1 = IdentityBNode(self.graph1, debug=True) id2 = IdentityBNode(self.graph2, debug=True) idni1 = sorted(id1.named_identities) idni2 = sorted(id2.named_identities) assert idni1 == idni2, 'named identities do not match' idli1 = sorted(id1.connected_identities) idli2 = sorted(id2.connected_identities) assert idli1 == idli2, 'linked identities do not match' idfi1 = sorted(id1.free_identities) idfi2 = sorted(id2.free_identities) try: assert idfi1 == idfi2, 'free identities do not match' except AssertionError as e: _ = [[print(e[:10]) for e in t] and print() for t in zip(idfi1, idfi2)] lu1 = {v:k for k, v in id1.unnamed_subgraph_identities.items()} lu2 = {v:k for k, v in id2.unnamed_subgraph_identities.items()} s1 = set(id1.unnamed_subgraph_identities.values()) s2 = set(id2.unnamed_subgraph_identities.values()) diff = (s1 | s2) - (s1 & s2) for d in diff: if d in lu1: s = lu1[d] p, o = next(id1._thing[s]) print('id1 extra') [print(t) for t in sorted(yield_recursive(s, p, o, id1._thing), key=lambda t:t[::-1])] else: s = lu2[d] p, o = next(id2._thing[s]) print('id2 extra') [print(t) for t in sorted(yield_recursive(s, p, o, id2._thing), key=lambda t:t[::-1])] assert len(set(idfi1)) == len(idfi1), 'HRM 1' assert len(set(idfi2)) == len(idfi2), 'HRM 2' print(len(idfi1), len(idfi2)) # wow... terrifying that these don't match print(e) embed() raise e assert id1.identity == id2.identity, 'identities do not match' def test_symmetric(self): msp = 'my-sym-pred' forward = 'a', msp, 'b' backward = tuple(reversed(forward)) f = IdentityBNode([forward], symmetric_predicates=[msp]) b = IdentityBNode([backward], symmetric_predicates=[msp]) assert f == b def test_check(self): id1 = IdentityBNode(self.graph1) assert id1.check(self.graph2), 'check failed!' def test_dropout(self): # TODO # test dropout of all but one subgraphs that share an identity pass
753998dd45ddabf269b8d6490c60b19f915a0d0d
74230f68a1bb947c88b3448e537fe41ce2c820b9
/2018/xman/rmd5.py
b8eb76b7ee8e429b6d3f7a489f189d28b76eecaa
[]
no_license
virink/ctflog
98934a3d6af470ed9eb338beefc7487dbdaf3b3f
e5ed8f7fdf7945f9aa781824184131b00529d073
refs/heads/master
2020-05-02T13:15:08.256096
2020-03-09T03:48:05
2020-03-09T03:48:05
177,979,168
49
10
null
null
null
null
UTF-8
Python
false
false
3,267
py
import multiprocessing from concurrent import futures import sys import os import md5 BASENUM = 1000000 global encoded global stop global result stop = False def md5x(str): m1 = md5.new() m1.update(str) return m1.hexdigest() class Multicpu(): def __init__(self, cpu_num, thread_num): self.cpu_num = cpu_num self.thread_num = thread_num def _multi_cpu(self, func, job_queue, timeout): if getLen(job_queue) == 0: return [] index = get_index(job_queue, self.cpu_num) cpu_pool = multiprocessing.Pool(processes=self.cpu_num) mgr = multiprocessing.Manager() process_bar = mgr.list() for i in range(self.cpu_num): process_bar.append(0) result_queue = cpu_pool.map(_multi_thread, [[func, self.cpu_num, self.thread_num, job_queue[ index[i][0]: index[i][1] + 1], timeout, process_bar, i] for i in range(len(index))]) result = [] for rl in result_queue: for r in rl: result.append(r) return result def _func(argv): argv[2][argv[3]] = round((argv[4] * 100.0 / argv[5]), 2) sys.stdout.write(str(argv[2]) + ' ||' + '->' + "\r") sys.stdout.flush() return argv[0](argv[1]) def _multi_thread(argv): thread_num = argv[2] if getLen(argv[3]) < thread_num: thread_num = argv[3] func_argvs = [[argv[0], argv[3][i], argv[5], argv[6], i, len(argv[3])] for i in range(len(argv[3]))] result = [] if thread_num == 1: for func_argv in func_argvs: result.append(_func(func_argv)) return result # else thread_pool = futures.ThreadPoolExecutor(max_workers=thread_num) result = thread_pool.map(_func, func_argvs, timeout=argv[4]) return [r for r in result] def get_index(job_queue, split_num): job_num = getLen(job_queue) if job_num < split_num: split_num = job_num each_num = job_num / split_num index = [[i * each_num, i * each_num + each_num - 1] for i in range(split_num)] residual_num = job_num % split_num for i in range(residual_num): index[split_num - residual_num + i][0] += i index[split_num - residual_num + i][1] += i + 1 return index def getLen(_list): if _list == None: return 0 return len(_list) def multi_cpu(func, job_queue, cpu_num=1, thread_num=1, timeout=None): multicpu_instance = Multicpu(cpu_num, thread_num) return multicpu_instance._multi_cpu(func, job_queue, timeout) def runmd5(num): global encoded global stop start = BASENUM * (int(num)) i = start while i <= start * 10: if os.getenv('runmd5') or stop: break if md5x(str(i))[0:6] == encoded: print('DeCode : %d\n' % i) os.setenv('runmd5', '1') stop = True return i i += 1 return False if __name__ == '__main__': global encoded encoded = raw_input('code : ') while encoded: os.setenv('runmd5', '0') print('Runing... %s' % encoded) m = multi_cpu(runmd5, [i for i in range(1, 100)], 5, 10) print(m) encoded = raw_input('code : ')
3f87bea7d7804e1c019ab879e8ee5c1cbb99215c
c359314f459e613e2d7ff20efe3998f3b5267f0c
/put_repo_requests_in_db.py
15a68523ac47d991ad008f8ccdf19b10cb241b28
[ "MIT" ]
permissive
curiousleo/oadoi
30a247796982dd467f5536735c1be7ebbc447331
bd63cb3840cc08cc1846b1baf121bea0a84af079
refs/heads/master
2020-04-17T12:47:27.959453
2019-01-18T21:09:50
2019-01-18T21:09:50
null
0
0
null
null
null
null
UTF-8
Python
false
false
3,844
py
import csv import os import json import gspread import datetime import unicodecsv as csv from oauth2client.service_account import ServiceAccountCredentials from app import db from util import safe_commit from repository import Endpoint from repository import Repository from repository import RepoRequest # this file inspired by https://www.twilio.com/blog/2017/02/an-easy-way-to-read-and-write-to-a-google-spreadsheet-in-python.html # use creds to create a client to interact with the Google Drive API scopes = ['https://spreadsheets.google.com/feeds'] json_creds = os.getenv("GOOGLE_SHEETS_CREDS_JSON") creds_dict = json.loads(json_creds) # hack to get around ugly new line escaping issues # this works for me, but later found links to what might be cleaner solutions: # use ast.literal_eval? https://github.com/googleapis/google-api-go-client/issues/185#issuecomment-422732250 # or maybe dumping like this might fix it? https://coreyward.svbtle.com/how-to-send-a-multiline-file-to-heroku-config creds_dict["private_key"] = creds_dict["private_key"].replace("\\\\n", "\n") # now continue creds = ServiceAccountCredentials.from_json_keyfile_dict(creds_dict, scopes) client = gspread.authorize(creds) # Find a workbook by url spreadsheet = client.open_by_url("https://docs.google.com/spreadsheets/d/1RcQuetbKVYRRf0GhGZQi38okY8gT1cPUs6l3RM94yQo/edit#gid=704459328") sheet = spreadsheet.sheet1 # Extract and print all of the values rows = sheet.get_all_values() print(rows[0:1]) with open('out.csv','wb') as f: w = csv.DictWriter(f, fieldnames=RepoRequest.list_fieldnames(), encoding='utf-8-sig') for row in rows[1:]: # skip header row my_repo_request = RepoRequest() my_repo_request.set_id_seed(row[0]) column_num = 0 for fieldname in RepoRequest.list_fieldnames(): if fieldname != "id": setattr(my_repo_request, fieldname, row[column_num]) column_num += 1 w.writerow(my_repo_request.to_dict()) db.session.merge(my_repo_request) safe_commit(db) # # my_requests = RepoRequest.query.all() # for my_request in my_requests: # matching_repo = None # matching_endpoint = None # # endpoint_matches = my_request.matching_endpoints() # print u"\n" # if endpoint_matches: # matching_endpoint = endpoint_matches[0] # matching_repo = matching_endpoint.meta # else: # print u"no matching endpoint for {}".format(my_request.pmh_url) # matching_endpoint = Endpoint() # matching_endpoint.pmh_url = my_request.pmh_url # # db.session.add(matching_endpoint) # # if matching_repo: # print u"yay! for {} matches {}".format(my_request.pmh_url, matching_endpoint.pmh_url) # print u"has repository '{}'".format(matching_repo) # else: # repo_matches = my_request.matching_repositories() # if repo_matches: # matching_repo = repo_matches[0] # print u"yay! for {} {} matches repository {}".format( # my_request.institution_name, my_request.repo_name, matching_repo) # else: # print u"no matching repository for {}: {}".format( # my_request.institution_name, my_request.repo_name) # matching_repo = Repository() # # db.session.add(matching_repo) # # # overwrite stuff with request # matching_repo.institution_name = my_request.institution_name # matching_repo.repository_name = my_request.repo_name # matching_repo.home_page = my_request.repo_home_page # matching_endpoint.repo_unique_id = matching_repo.id # matching_endpoint.email = my_request.email # matching_endpoint.repo_request_id = my_request.id # # db.session.merge(matching_endpoint) # db.session.merge(matching_repo) # # safe_commit(db)
6d2e13a3dc13e31fe80281f8964313acebd61442
78e60a7d8a67ed76244004e8a3ed573fbf396e41
/samples/get_sq_state.py
64970c14e689bd3ca55171246f996d154cc4c310
[ "MIT" ]
permissive
Crivez/apiclient-python
837a9f7cc0453ccd3121311adc7920b5fe6b3e33
860fc054f546152a101e29b1af388c381075ac47
refs/heads/master
2023-06-08T13:24:09.249704
2021-06-17T12:16:35
2021-06-17T12:16:35
null
0
0
null
null
null
null
UTF-8
Python
false
false
475
py
from voximplant.apiclient import VoximplantAPI, VoximplantException if __name__ == "__main__": voxapi = VoximplantAPI("credentials.json") # Gets the current state of the smart queue with id = 1. APPLICATION_ID = 1 SQ_QUEUE_ID = 1 try: res = voxapi.get_sq_state(application_id=APPLICATION_ID, sq_queue_id=SQ_QUEUE_ID) print(res) except VoximplantException as e: print("Error: {}".format(e.message))
4a54783d2c394f8ba238fbd5d64ef46f8dbfddc5
09b8638b41ada6d8341920f88642d829fa45fe34
/blog/migrations/0001_initial.py
517d17b4e456a459c9352af883d1d8e30761c004
[]
no_license
HanHyunsoo/Django_Blog
31bf85616ed4956c894f0f6830428a29e9926be4
ef6b1eb3f8f03fddce1a08f2b10353ee3b529e47
refs/heads/master
2022-12-14T22:56:26.761304
2019-09-08T12:16:31
2019-09-08T12:16:31
157,580,624
0
1
null
2022-12-08T01:40:54
2018-11-14T16:47:45
Python
UTF-8
Python
false
false
614
py
# Generated by Django 2.1.3 on 2019-03-06 15:11 from django.db import migrations, models class Migration(migrations.Migration): initial = True dependencies = [ ] operations = [ migrations.CreateModel( name='Blog', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('title', models.CharField(max_length=200)), ('pub_date', models.DateTimeField(verbose_name='date published')), ('body', models.TextField()), ], ), ]
312e1f6dd256c6c4a88ec83350791c8e36bf048d
21e64f9410323a11d4550b889fd0bb0d68543fab
/apps/rss_feeds/migrations/0036_drop_stories.py
9baa1c02e27bce7c60e5596f4444f79c8a7e652a
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
quanganhdo/NewsBlur
a7eaa3c5bdb2e57998651d736db861f88fcd1e75
cef29f01658c845564a5044b48b4cf19efcaa4d6
refs/heads/master
2021-03-05T23:56:27.976498
2020-02-27T15:23:23
2020-02-27T15:23:23
246,164,347
1
0
MIT
2020-03-09T23:34:18
2020-03-09T23:34:17
null
UTF-8
Python
false
false
11,191
py
# encoding: utf-8 import datetime from south.db import db from south.v2 import SchemaMigration from django.db import models class Migration(SchemaMigration): def forwards(self, orm): # Removing unique constraint on 'Story', fields ['story_feed', 'story_guid_hash'] db.delete_unique('stories', ['story_feed_id', 'story_guid_hash']) # Deleting model 'Story' db.delete_table('stories') # Deleting model 'FeedFetchHistory' db.delete_table('rss_feeds_feedfetchhistory') # Deleting model 'PageFetchHistory' db.delete_table('rss_feeds_pagefetchhistory') # Changing field 'FeedData.feed' db.alter_column('rss_feeds_feeddata', 'feed_id', self.gf('utils.fields.AutoOneToOneField')(unique=True, to=orm['rss_feeds.Feed'])) def backwards(self, orm): # Adding model 'Story' db.create_table('stories', ( ('story_original_content', self.gf('utils.compressed_textfield.StoryField')(null=True, blank=True)), ('story_date', self.gf('django.db.models.fields.DateTimeField')()), ('story_guid_hash', self.gf('django.db.models.fields.CharField')(max_length=40)), ('story_feed', self.gf('django.db.models.fields.related.ForeignKey')(related_name='stories', to=orm['rss_feeds.Feed'])), ('story_title', self.gf('django.db.models.fields.CharField')(max_length=255)), ('story_permalink', self.gf('django.db.models.fields.CharField')(max_length=1000)), ('story_guid', self.gf('django.db.models.fields.CharField')(max_length=1000)), ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), ('story_author', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['rss_feeds.StoryAuthor'])), ('story_author_name', self.gf('django.db.models.fields.CharField')(max_length=500, null=True, blank=True)), ('story_past_trim_date', self.gf('django.db.models.fields.BooleanField')(default=False)), ('story_content_type', self.gf('django.db.models.fields.CharField')(max_length=255, null=True, blank=True)), ('story_tags', self.gf('django.db.models.fields.CharField')(max_length=2000, null=True, blank=True)), ('story_content', self.gf('utils.compressed_textfield.StoryField')(null=True, blank=True)), )) db.send_create_signal('rss_feeds', ['Story']) # Adding unique constraint on 'Story', fields ['story_feed', 'story_guid_hash'] db.create_unique('stories', ['story_feed_id', 'story_guid_hash']) # Adding model 'FeedFetchHistory' db.create_table('rss_feeds_feedfetchhistory', ( ('feed', self.gf('django.db.models.fields.related.ForeignKey')(related_name='feed_fetch_history', to=orm['rss_feeds.Feed'])), ('exception', self.gf('django.db.models.fields.TextField')(null=True, blank=True)), ('status_code', self.gf('django.db.models.fields.CharField')(max_length=10, null=True, blank=True)), ('fetch_date', self.gf('django.db.models.fields.DateTimeField')(auto_now=True, blank=True)), ('message', self.gf('django.db.models.fields.CharField')(max_length=255, null=True, blank=True)), ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), )) db.send_create_signal('rss_feeds', ['FeedFetchHistory']) # Adding model 'PageFetchHistory' db.create_table('rss_feeds_pagefetchhistory', ( ('feed', self.gf('django.db.models.fields.related.ForeignKey')(related_name='page_fetch_history', to=orm['rss_feeds.Feed'])), ('exception', self.gf('django.db.models.fields.TextField')(null=True, blank=True)), ('status_code', self.gf('django.db.models.fields.CharField')(max_length=10, null=True, blank=True)), ('fetch_date', self.gf('django.db.models.fields.DateTimeField')(auto_now=True, blank=True)), ('message', self.gf('django.db.models.fields.CharField')(max_length=255, null=True, blank=True)), ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), )) db.send_create_signal('rss_feeds', ['PageFetchHistory']) # Changing field 'FeedData.feed' db.alter_column('rss_feeds_feeddata', 'feed_id', self.gf('django.db.models.fields.related.OneToOneField')(unique=True, to=orm['rss_feeds.Feed'])) models = { 'rss_feeds.duplicatefeed': { 'Meta': {'object_name': 'DuplicateFeed'}, 'duplicate_address': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}), 'duplicate_feed_id': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True'}), 'feed': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'duplicate_addresses'", 'to': "orm['rss_feeds.Feed']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) }, 'rss_feeds.feed': { 'Meta': {'ordering': "['feed_title']", 'object_name': 'Feed', 'db_table': "'feeds'"}, 'active': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'db_index': 'True'}), 'active_subscribers': ('django.db.models.fields.IntegerField', [], {'default': '-1', 'db_index': 'True'}), 'average_stories_per_month': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'creation': ('django.db.models.fields.DateField', [], {'auto_now_add': 'True', 'blank': 'True'}), 'days_to_trim': ('django.db.models.fields.IntegerField', [], {'default': '90'}), 'etag': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), 'exception_code': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'feed_address': ('django.db.models.fields.URLField', [], {'unique': 'True', 'max_length': '255'}), 'feed_link': ('django.db.models.fields.URLField', [], {'default': "''", 'max_length': '1000', 'null': 'True', 'blank': 'True'}), 'feed_title': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255', 'null': 'True', 'blank': 'True'}), 'fetched_once': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'has_feed_exception': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}), 'has_page_exception': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'last_load_time': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'last_modified': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), 'last_update': ('django.db.models.fields.DateTimeField', [], {'db_index': 'True'}), 'min_to_decay': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'next_scheduled_update': ('django.db.models.fields.DateTimeField', [], {'db_index': 'True'}), 'num_subscribers': ('django.db.models.fields.IntegerField', [], {'default': '-1'}), 'premium_subscribers': ('django.db.models.fields.IntegerField', [], {'default': '-1'}), 'queued_date': ('django.db.models.fields.DateTimeField', [], {'db_index': 'True'}), 'stories_last_month': ('django.db.models.fields.IntegerField', [], {'default': '0'}) }, 'rss_feeds.feeddata': { 'Meta': {'object_name': 'FeedData'}, 'feed': ('utils.fields.AutoOneToOneField', [], {'related_name': "'data'", 'unique': 'True', 'to': "orm['rss_feeds.Feed']"}), 'feed_tagline': ('django.db.models.fields.CharField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'popular_authors': ('django.db.models.fields.CharField', [], {'max_length': '2048', 'null': 'True', 'blank': 'True'}), 'popular_tags': ('django.db.models.fields.CharField', [], {'max_length': '1024', 'null': 'True', 'blank': 'True'}), 'story_count_history': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}) }, 'rss_feeds.feedloadtime': { 'Meta': {'object_name': 'FeedLoadtime'}, 'date_accessed': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'feed': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['rss_feeds.Feed']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'loadtime': ('django.db.models.fields.FloatField', [], {}) }, 'rss_feeds.feedpage': { 'Meta': {'object_name': 'FeedPage'}, 'feed': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'feed_page'", 'unique': 'True', 'to': "orm['rss_feeds.Feed']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'page_data': ('utils.compressed_textfield.StoryField', [], {'null': 'True', 'blank': 'True'}) }, 'rss_feeds.feedupdatehistory': { 'Meta': {'object_name': 'FeedUpdateHistory'}, 'average_per_feed': ('django.db.models.fields.DecimalField', [], {'max_digits': '4', 'decimal_places': '1'}), 'fetch_date': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'number_of_feeds': ('django.db.models.fields.IntegerField', [], {}), 'seconds_taken': ('django.db.models.fields.IntegerField', [], {}) }, 'rss_feeds.feedxml': { 'Meta': {'object_name': 'FeedXML'}, 'feed': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'feed_xml'", 'unique': 'True', 'to': "orm['rss_feeds.Feed']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'rss_xml': ('utils.compressed_textfield.StoryField', [], {'null': 'True', 'blank': 'True'}) }, 'rss_feeds.storyauthor': { 'Meta': {'object_name': 'StoryAuthor'}, 'author_name': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), 'feed': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['rss_feeds.Feed']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) }, 'rss_feeds.tag': { 'Meta': {'object_name': 'Tag'}, 'feed': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['rss_feeds.Feed']"}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}) } } complete_apps = ['rss_feeds']
4e5c72caa25fd48fe9c962c1cc3b9048f5ac051c
cb2a40b70bc21d0057c96ddb2c86edceffe19707
/studioadmin/views/waiting_list.py
9382d6b048ddc7a4a35e7e40495f5bebbbae5b0f
[]
no_license
rebkwok/pipsevents
ceed9f420b08cd1a3fa418800c0870f5a95a4067
c997349a1b4f3995ca4bb3a897be6a73001c9810
refs/heads/main
2023-08-09T14:11:52.227086
2023-07-27T20:21:01
2023-07-27T20:21:01
29,796,344
1
1
null
2023-09-13T14:32:16
2015-01-24T23:53:34
Python
UTF-8
Python
false
false
2,813
py
import logging from django.contrib.auth.decorators import login_required from django.contrib.auth.models import User from django.contrib import messages from django.template.response import TemplateResponse from django.shortcuts import get_object_or_404 from django.shortcuts import HttpResponseRedirect from django.urls import reverse from booking.models import Event, WaitingListUser from studioadmin.views.helpers import is_instructor_or_staff from studioadmin.views.helpers import url_with_querystring from activitylog.models import ActivityLog logger = logging.getLogger(__name__) @login_required @is_instructor_or_staff def event_waiting_list_view(request, event_id): event = get_object_or_404(Event, id=event_id) waiting_list_users = WaitingListUser.objects.filter( event__id=event_id).order_by('user__username') ev_type = 'lessons' if event.event_type.event_type == 'CL' else 'events' template = 'studioadmin/event_waiting_list.html' if request.method == 'POST' and 'remove_user' in request.POST: remove_wluser_id = request.POST.getlist('remove_user')[0] wl_user_to_remove = WaitingListUser.objects.get(id=remove_wluser_id) waiting_list_users.exclude(id=remove_wluser_id) user_to_remove = User.objects.get(id=wl_user_to_remove.user.id) wl_user_to_remove.delete() messages.success( request, "{} {} ({}) has been removed from the waiting list".format( user_to_remove.first_name, user_to_remove.last_name, user_to_remove.username ) ) ActivityLog.objects.create( log="{} {} ({}) removed from the waiting list " "by admin user {}".format( user_to_remove.first_name, user_to_remove.last_name, user_to_remove.username, request.user.username ) ) return TemplateResponse( request, template, { 'waiting_list_users': waiting_list_users, 'event': event, 'sidenav_selection': '{}_register'.format(ev_type) } ) @login_required @is_instructor_or_staff def email_waiting_list(request, event_id): event = get_object_or_404(Event, id=event_id) waiting_list_users = WaitingListUser.objects.filter( event__id=event_id).values_list("user_id", flat=True) request.session['users_to_email'] = list(waiting_list_users) if event.event_type.event_type == "CL": lesson_ids = [event.id] event_ids = [] else: event_ids = [event.id] lesson_ids = [] return HttpResponseRedirect( url_with_querystring( reverse('studioadmin:email_users_view'), events=event_ids, lessons=lesson_ids) )
8af051b8ebbdbb0c18dadaa9850c01bee070223c
d3cbf02ebab6a3748cceaf56757b0ec7390921ce
/investment/migrations/0025_auto_20201123_1602.py
ffd8700b5acf84e40c35d8f91796581b223201ac
[]
no_license
rexcorp01/inv
69d6ec96c1f9206b3ae14b6b13bd3123e13ed3a6
99462cea1f8b027bc9e38d79a99e9194d1e72548
refs/heads/master
2023-09-05T11:46:48.804587
2021-11-04T06:34:16
2021-11-04T06:34:16
426,082,304
1
0
null
null
null
null
UTF-8
Python
false
false
1,587
py
# Generated by Django 3.1.2 on 2020-11-23 16:02 from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): dependencies = [ ('investment', '0024_fundpurchasefee_operate'), ] operations = [ migrations.AlterModelOptions( name='fundpurchasefee', options={'verbose_name': '基金申购赎回费率(天天基金网)', 'verbose_name_plural': '基金申购赎回费率(天天基金网)'}, ), migrations.AlterField( model_name='fundpurchasefee', name='operate', field=models.CharField(choices=[('buy', '买'), ('sell', '卖')], max_length=4, verbose_name='交易方向'), ), migrations.CreateModel( name='StockRealtimePrice', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('price', models.DecimalField(decimal_places=4, max_digits=10, null=True, verbose_name='实时价格')), ('date', models.DateField(verbose_name='日期')), ('time', models.TimeField(verbose_name='时间')), ('secucode', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='investment.stock', verbose_name='股票代码')), ], options={ 'verbose_name': '股票实时价格', 'verbose_name_plural': '股票实时价格', 'db_table': 'sma_stocks_realtime_price', }, ), ]
f9443639ce00b0a98da0f52644922ed377be0588
37262efcd1c12ffd3a62121eb718d6a98e225e56
/venv/Lib/site-packages/matplotlib/mathtext.py
f9f40dfab32729d1f4562cba7eaa28984cf219cd
[]
no_license
durid-ah/Machine_Learning_Basics
23d2d32d2556b1a2be9547a890cbb3d4dd131cd1
944c06b1ef7b48a47922270cdc7137500795c733
refs/heads/master
2020-08-16T00:47:06.608049
2019-12-11T21:52:56
2019-12-11T21:52:56
215,432,308
0
0
null
null
null
null
UTF-8
Python
false
false
124,885
py
r""" :mod:`~matplotlib.mathtext` is a module for parsing a subset of the TeX math syntax and drawing them to a matplotlib backend. For a tutorial of its usage see :doc:`/tutorials/text/mathtext`. This document is primarily concerned with implementation details. The module uses pyparsing_ to parse the TeX expression. .. _pyparsing: http://pyparsing.wikispaces.com/ The Bakoma distribution of the TeX Computer Modern fonts, and STIX fonts are supported. There is experimental support for using arbitrary fonts, but results may vary without proper tweaking and metrics for those fonts. """ from collections import namedtuple import functools from io import StringIO import logging import os import types import unicodedata import numpy as np from pyparsing import ( Combine, Empty, FollowedBy, Forward, Group, Literal, oneOf, OneOrMore, Optional, ParseBaseException, ParseFatalException, ParserElement, QuotedString, Regex, StringEnd, Suppress, ZeroOrMore) ParserElement.enablePackrat() from matplotlib import cbook, colors as mcolors, get_data_path, rcParams from matplotlib.afm import AFM from matplotlib.cbook import get_realpath_and_stat from matplotlib.ft2font import FT2Image, KERNING_DEFAULT, LOAD_NO_HINTING from matplotlib.font_manager import findfont, FontProperties, get_font from matplotlib._mathtext_data import (latex_to_bakoma, latex_to_standard, tex2uni, latex_to_cmex, stix_virtual_fonts) _log = logging.getLogger(__name__) ############################################################################## # FONTS def get_unicode_index(symbol, math=True): r""" Return the integer index (from the Unicode table) of *symbol*. Parameters ---------- symbol : str A single unicode character, a TeX command (e.g. r'\pi') or a Type1 symbol name (e.g. 'phi'). math : bool, default is True If False, always treat as a single unicode character. """ # for a non-math symbol, simply return its unicode index if not math: return ord(symbol) # From UTF #25: U+2212 minus sign is the preferred # representation of the unary and binary minus sign rather than # the ASCII-derived U+002D hyphen-minus, because minus sign is # unambiguous and because it is rendered with a more desirable # length, usually longer than a hyphen. if symbol == '-': return 0x2212 try: # This will succeed if symbol is a single unicode char return ord(symbol) except TypeError: pass try: # Is symbol a TeX symbol (i.e. \alpha) return tex2uni[symbol.strip("\\")] except KeyError: raise ValueError( "'{}' is not a valid Unicode character or TeX/Type1 symbol" .format(symbol)) unichr_safe = cbook.deprecated("3.0")(chr) class MathtextBackend(object): """ The base class for the mathtext backend-specific code. The purpose of :class:`MathtextBackend` subclasses is to interface between mathtext and a specific matplotlib graphics backend. Subclasses need to override the following: - :meth:`render_glyph` - :meth:`render_rect_filled` - :meth:`get_results` And optionally, if you need to use a FreeType hinting style: - :meth:`get_hinting_type` """ def __init__(self): self.width = 0 self.height = 0 self.depth = 0 def set_canvas_size(self, w, h, d): 'Dimension the drawing canvas' self.width = w self.height = h self.depth = d def render_glyph(self, ox, oy, info): """ Draw a glyph described by *info* to the reference point (*ox*, *oy*). """ raise NotImplementedError() def render_rect_filled(self, x1, y1, x2, y2): """ Draw a filled black rectangle from (*x1*, *y1*) to (*x2*, *y2*). """ raise NotImplementedError() def get_results(self, box): """ Return a backend-specific tuple to return to the backend after all processing is done. """ raise NotImplementedError() def get_hinting_type(self): """ Get the FreeType hinting type to use with this particular backend. """ return LOAD_NO_HINTING class MathtextBackendAgg(MathtextBackend): """ Render glyphs and rectangles to an FTImage buffer, which is later transferred to the Agg image by the Agg backend. """ def __init__(self): self.ox = 0 self.oy = 0 self.image = None self.mode = 'bbox' self.bbox = [0, 0, 0, 0] MathtextBackend.__init__(self) def _update_bbox(self, x1, y1, x2, y2): self.bbox = [min(self.bbox[0], x1), min(self.bbox[1], y1), max(self.bbox[2], x2), max(self.bbox[3], y2)] def set_canvas_size(self, w, h, d): MathtextBackend.set_canvas_size(self, w, h, d) if self.mode != 'bbox': self.image = FT2Image(np.ceil(w), np.ceil(h + max(d, 0))) def render_glyph(self, ox, oy, info): if self.mode == 'bbox': self._update_bbox(ox + info.metrics.xmin, oy - info.metrics.ymax, ox + info.metrics.xmax, oy - info.metrics.ymin) else: info.font.draw_glyph_to_bitmap( self.image, ox, oy - info.metrics.iceberg, info.glyph, antialiased=rcParams['text.antialiased']) def render_rect_filled(self, x1, y1, x2, y2): if self.mode == 'bbox': self._update_bbox(x1, y1, x2, y2) else: height = max(int(y2 - y1) - 1, 0) if height == 0: center = (y2 + y1) / 2.0 y = int(center - (height + 1) / 2.0) else: y = int(y1) self.image.draw_rect_filled(int(x1), y, np.ceil(x2), y + height) def get_results(self, box, used_characters): self.mode = 'bbox' orig_height = box.height orig_depth = box.depth ship(0, 0, box) bbox = self.bbox bbox = [bbox[0] - 1, bbox[1] - 1, bbox[2] + 1, bbox[3] + 1] self.mode = 'render' self.set_canvas_size( bbox[2] - bbox[0], (bbox[3] - bbox[1]) - orig_depth, (bbox[3] - bbox[1]) - orig_height) ship(-bbox[0], -bbox[1], box) result = (self.ox, self.oy, self.width, self.height + self.depth, self.depth, self.image, used_characters) self.image = None return result def get_hinting_type(self): from matplotlib.backends import backend_agg return backend_agg.get_hinting_flag() class MathtextBackendBitmap(MathtextBackendAgg): def get_results(self, box, used_characters): ox, oy, width, height, depth, image, characters = \ MathtextBackendAgg.get_results(self, box, used_characters) return image, depth class MathtextBackendPs(MathtextBackend): """ Store information to write a mathtext rendering to the PostScript backend. """ _PSResult = namedtuple( "_PSResult", "width height depth pswriter used_characters") def __init__(self): self.pswriter = StringIO() self.lastfont = None def render_glyph(self, ox, oy, info): oy = self.height - oy + info.offset postscript_name = info.postscript_name fontsize = info.fontsize symbol_name = info.symbol_name if (postscript_name, fontsize) != self.lastfont: ps = """/%(postscript_name)s findfont %(fontsize)s scalefont setfont """ % locals() self.lastfont = postscript_name, fontsize self.pswriter.write(ps) ps = """%(ox)f %(oy)f moveto /%(symbol_name)s glyphshow\n """ % locals() self.pswriter.write(ps) def render_rect_filled(self, x1, y1, x2, y2): ps = "%f %f %f %f rectfill\n" % ( x1, self.height - y2, x2 - x1, y2 - y1) self.pswriter.write(ps) def get_results(self, box, used_characters): ship(0, 0, box) return self._PSResult(self.width, self.height + self.depth, self.depth, self.pswriter, used_characters) class MathtextBackendPdf(MathtextBackend): """Store information to write a mathtext rendering to the PDF backend.""" _PDFResult = namedtuple( "_PDFResult", "width height depth glyphs rects used_characters") def __init__(self): self.glyphs = [] self.rects = [] def render_glyph(self, ox, oy, info): filename = info.font.fname oy = self.height - oy + info.offset self.glyphs.append( (ox, oy, filename, info.fontsize, info.num, info.symbol_name)) def render_rect_filled(self, x1, y1, x2, y2): self.rects.append((x1, self.height - y2, x2 - x1, y2 - y1)) def get_results(self, box, used_characters): ship(0, 0, box) return self._PDFResult(self.width, self.height + self.depth, self.depth, self.glyphs, self.rects, used_characters) class MathtextBackendSvg(MathtextBackend): """ Store information to write a mathtext rendering to the SVG backend. """ def __init__(self): self.svg_glyphs = [] self.svg_rects = [] def render_glyph(self, ox, oy, info): oy = self.height - oy + info.offset self.svg_glyphs.append( (info.font, info.fontsize, info.num, ox, oy, info.metrics)) def render_rect_filled(self, x1, y1, x2, y2): self.svg_rects.append( (x1, self.height - y1 + 1, x2 - x1, y2 - y1)) def get_results(self, box, used_characters): ship(0, 0, box) svg_elements = types.SimpleNamespace(svg_glyphs=self.svg_glyphs, svg_rects=self.svg_rects) return (self.width, self.height + self.depth, self.depth, svg_elements, used_characters) class MathtextBackendPath(MathtextBackend): """ Store information to write a mathtext rendering to the text path machinery. """ def __init__(self): self.glyphs = [] self.rects = [] def render_glyph(self, ox, oy, info): oy = self.height - oy + info.offset thetext = info.num self.glyphs.append( (info.font, info.fontsize, thetext, ox, oy)) def render_rect_filled(self, x1, y1, x2, y2): self.rects.append((x1, self.height - y2, x2 - x1, y2 - y1)) def get_results(self, box, used_characters): ship(0, 0, box) return (self.width, self.height + self.depth, self.depth, self.glyphs, self.rects) class MathtextBackendCairo(MathtextBackend): """ Store information to write a mathtext rendering to the Cairo backend. """ def __init__(self): self.glyphs = [] self.rects = [] def render_glyph(self, ox, oy, info): oy = oy - info.offset - self.height thetext = chr(info.num) self.glyphs.append( (info.font, info.fontsize, thetext, ox, oy)) def render_rect_filled(self, x1, y1, x2, y2): self.rects.append( (x1, y1 - self.height, x2 - x1, y2 - y1)) def get_results(self, box, used_characters): ship(0, 0, box) return (self.width, self.height + self.depth, self.depth, self.glyphs, self.rects) class Fonts(object): """ An abstract base class for a system of fonts to use for mathtext. The class must be able to take symbol keys and font file names and return the character metrics. It also delegates to a backend class to do the actual drawing. """ def __init__(self, default_font_prop, mathtext_backend): """ *default_font_prop*: A :class:`~matplotlib.font_manager.FontProperties` object to use for the default non-math font, or the base font for Unicode (generic) font rendering. *mathtext_backend*: A subclass of :class:`MathTextBackend` used to delegate the actual rendering. """ self.default_font_prop = default_font_prop self.mathtext_backend = mathtext_backend self.used_characters = {} def destroy(self): """ Fix any cyclical references before the object is about to be destroyed. """ self.used_characters = None def get_kern(self, font1, fontclass1, sym1, fontsize1, font2, fontclass2, sym2, fontsize2, dpi): """ Get the kerning distance for font between *sym1* and *sym2*. *fontX*: one of the TeX font names:: tt, it, rm, cal, sf, bf or default/regular (non-math) *fontclassX*: TODO *symX*: a symbol in raw TeX form. e.g., '1', 'x' or '\\sigma' *fontsizeX*: the fontsize in points *dpi*: the current dots-per-inch """ return 0. def get_metrics(self, font, font_class, sym, fontsize, dpi, math=True): """ *font*: one of the TeX font names:: tt, it, rm, cal, sf, bf or default/regular (non-math) *font_class*: TODO *sym*: a symbol in raw TeX form. e.g., '1', 'x' or '\\sigma' *fontsize*: font size in points *dpi*: current dots-per-inch *math*: whether sym is a math character Returns an object with the following attributes: - *advance*: The advance distance (in points) of the glyph. - *height*: The height of the glyph in points. - *width*: The width of the glyph in points. - *xmin*, *xmax*, *ymin*, *ymax* - the ink rectangle of the glyph - *iceberg* - the distance from the baseline to the top of the glyph. This corresponds to TeX's definition of "height". """ info = self._get_info(font, font_class, sym, fontsize, dpi, math) return info.metrics def set_canvas_size(self, w, h, d): """ Set the size of the buffer used to render the math expression. Only really necessary for the bitmap backends. """ self.width, self.height, self.depth = np.ceil([w, h, d]) self.mathtext_backend.set_canvas_size( self.width, self.height, self.depth) def render_glyph(self, ox, oy, facename, font_class, sym, fontsize, dpi): """ Draw a glyph at - *ox*, *oy*: position - *facename*: One of the TeX face names - *font_class*: - *sym*: TeX symbol name or single character - *fontsize*: fontsize in points - *dpi*: The dpi to draw at. """ info = self._get_info(facename, font_class, sym, fontsize, dpi) realpath, stat_key = get_realpath_and_stat(info.font.fname) used_characters = self.used_characters.setdefault( stat_key, (realpath, set())) used_characters[1].add(info.num) self.mathtext_backend.render_glyph(ox, oy, info) def render_rect_filled(self, x1, y1, x2, y2): """ Draw a filled rectangle from (*x1*, *y1*) to (*x2*, *y2*). """ self.mathtext_backend.render_rect_filled(x1, y1, x2, y2) def get_xheight(self, font, fontsize, dpi): """ Get the xheight for the given *font* and *fontsize*. """ raise NotImplementedError() def get_underline_thickness(self, font, fontsize, dpi): """ Get the line thickness that matches the given font. Used as a base unit for drawing lines such as in a fraction or radical. """ raise NotImplementedError() def get_used_characters(self): """ Get the set of characters that were used in the math expression. Used by backends that need to subset fonts so they know which glyphs to include. """ return self.used_characters def get_results(self, box): """ Get the data needed by the backend to render the math expression. The return value is backend-specific. """ result = self.mathtext_backend.get_results( box, self.get_used_characters()) self.destroy() return result def get_sized_alternatives_for_symbol(self, fontname, sym): """ Override if your font provides multiple sizes of the same symbol. Should return a list of symbols matching *sym* in various sizes. The expression renderer will select the most appropriate size for a given situation from this list. """ return [(fontname, sym)] class TruetypeFonts(Fonts): """ A generic base class for all font setups that use Truetype fonts (through FT2Font). """ def __init__(self, default_font_prop, mathtext_backend): Fonts.__init__(self, default_font_prop, mathtext_backend) self.glyphd = {} self._fonts = {} filename = findfont(default_font_prop) default_font = get_font(filename) self._fonts['default'] = default_font self._fonts['regular'] = default_font def destroy(self): self.glyphd = None Fonts.destroy(self) def _get_font(self, font): if font in self.fontmap: basename = self.fontmap[font] else: basename = font cached_font = self._fonts.get(basename) if cached_font is None and os.path.exists(basename): cached_font = get_font(basename) self._fonts[basename] = cached_font self._fonts[cached_font.postscript_name] = cached_font self._fonts[cached_font.postscript_name.lower()] = cached_font return cached_font def _get_offset(self, font, glyph, fontsize, dpi): if font.postscript_name == 'Cmex10': return ((glyph.height/64.0/2.0) + (fontsize/3.0 * dpi/72.0)) return 0. def _get_info(self, fontname, font_class, sym, fontsize, dpi, math=True): key = fontname, font_class, sym, fontsize, dpi bunch = self.glyphd.get(key) if bunch is not None: return bunch font, num, symbol_name, fontsize, slanted = \ self._get_glyph(fontname, font_class, sym, fontsize, math) font.set_size(fontsize, dpi) glyph = font.load_char( num, flags=self.mathtext_backend.get_hinting_type()) xmin, ymin, xmax, ymax = [val/64.0 for val in glyph.bbox] offset = self._get_offset(font, glyph, fontsize, dpi) metrics = types.SimpleNamespace( advance = glyph.linearHoriAdvance/65536.0, height = glyph.height/64.0, width = glyph.width/64.0, xmin = xmin, xmax = xmax, ymin = ymin+offset, ymax = ymax+offset, # iceberg is the equivalent of TeX's "height" iceberg = glyph.horiBearingY/64.0 + offset, slanted = slanted ) result = self.glyphd[key] = types.SimpleNamespace( font = font, fontsize = fontsize, postscript_name = font.postscript_name, metrics = metrics, symbol_name = symbol_name, num = num, glyph = glyph, offset = offset ) return result def get_xheight(self, fontname, fontsize, dpi): font = self._get_font(fontname) font.set_size(fontsize, dpi) pclt = font.get_sfnt_table('pclt') if pclt is None: # Some fonts don't store the xHeight, so we do a poor man's xHeight metrics = self.get_metrics( fontname, rcParams['mathtext.default'], 'x', fontsize, dpi) return metrics.iceberg xHeight = (pclt['xHeight'] / 64.0) * (fontsize / 12.0) * (dpi / 100.0) return xHeight def get_underline_thickness(self, font, fontsize, dpi): # This function used to grab underline thickness from the font # metrics, but that information is just too un-reliable, so it # is now hardcoded. return ((0.75 / 12.0) * fontsize * dpi) / 72.0 def get_kern(self, font1, fontclass1, sym1, fontsize1, font2, fontclass2, sym2, fontsize2, dpi): if font1 == font2 and fontsize1 == fontsize2: info1 = self._get_info(font1, fontclass1, sym1, fontsize1, dpi) info2 = self._get_info(font2, fontclass2, sym2, fontsize2, dpi) font = info1.font return font.get_kerning(info1.num, info2.num, KERNING_DEFAULT) / 64 return Fonts.get_kern(self, font1, fontclass1, sym1, fontsize1, font2, fontclass2, sym2, fontsize2, dpi) class BakomaFonts(TruetypeFonts): """ Use the Bakoma TrueType fonts for rendering. Symbols are strewn about a number of font files, each of which has its own proprietary 8-bit encoding. """ _fontmap = { 'cal' : 'cmsy10', 'rm' : 'cmr10', 'tt' : 'cmtt10', 'it' : 'cmmi10', 'bf' : 'cmb10', 'sf' : 'cmss10', 'ex' : 'cmex10' } def __init__(self, *args, **kwargs): self._stix_fallback = StixFonts(*args, **kwargs) TruetypeFonts.__init__(self, *args, **kwargs) self.fontmap = {} for key, val in self._fontmap.items(): fullpath = findfont(val) self.fontmap[key] = fullpath self.fontmap[val] = fullpath _slanted_symbols = set(r"\int \oint".split()) def _get_glyph(self, fontname, font_class, sym, fontsize, math=True): symbol_name = None font = None if fontname in self.fontmap and sym in latex_to_bakoma: basename, num = latex_to_bakoma[sym] slanted = (basename == "cmmi10") or sym in self._slanted_symbols font = self._get_font(basename) elif len(sym) == 1: slanted = (fontname == "it") font = self._get_font(fontname) if font is not None: num = ord(sym) if font is not None: gid = font.get_char_index(num) if gid != 0: symbol_name = font.get_glyph_name(gid) if symbol_name is None: return self._stix_fallback._get_glyph( fontname, font_class, sym, fontsize, math) return font, num, symbol_name, fontsize, slanted # The Bakoma fonts contain many pre-sized alternatives for the # delimiters. The AutoSizedChar class will use these alternatives # and select the best (closest sized) glyph. _size_alternatives = { '(' : [('rm', '('), ('ex', '\xa1'), ('ex', '\xb3'), ('ex', '\xb5'), ('ex', '\xc3')], ')' : [('rm', ')'), ('ex', '\xa2'), ('ex', '\xb4'), ('ex', '\xb6'), ('ex', '\x21')], '{' : [('cal', '{'), ('ex', '\xa9'), ('ex', '\x6e'), ('ex', '\xbd'), ('ex', '\x28')], '}' : [('cal', '}'), ('ex', '\xaa'), ('ex', '\x6f'), ('ex', '\xbe'), ('ex', '\x29')], # The fourth size of '[' is mysteriously missing from the BaKoMa # font, so I've omitted it for both '[' and ']' '[' : [('rm', '['), ('ex', '\xa3'), ('ex', '\x68'), ('ex', '\x22')], ']' : [('rm', ']'), ('ex', '\xa4'), ('ex', '\x69'), ('ex', '\x23')], r'\lfloor' : [('ex', '\xa5'), ('ex', '\x6a'), ('ex', '\xb9'), ('ex', '\x24')], r'\rfloor' : [('ex', '\xa6'), ('ex', '\x6b'), ('ex', '\xba'), ('ex', '\x25')], r'\lceil' : [('ex', '\xa7'), ('ex', '\x6c'), ('ex', '\xbb'), ('ex', '\x26')], r'\rceil' : [('ex', '\xa8'), ('ex', '\x6d'), ('ex', '\xbc'), ('ex', '\x27')], r'\langle' : [('ex', '\xad'), ('ex', '\x44'), ('ex', '\xbf'), ('ex', '\x2a')], r'\rangle' : [('ex', '\xae'), ('ex', '\x45'), ('ex', '\xc0'), ('ex', '\x2b')], r'\__sqrt__' : [('ex', '\x70'), ('ex', '\x71'), ('ex', '\x72'), ('ex', '\x73')], r'\backslash': [('ex', '\xb2'), ('ex', '\x2f'), ('ex', '\xc2'), ('ex', '\x2d')], r'/' : [('rm', '/'), ('ex', '\xb1'), ('ex', '\x2e'), ('ex', '\xcb'), ('ex', '\x2c')], r'\widehat' : [('rm', '\x5e'), ('ex', '\x62'), ('ex', '\x63'), ('ex', '\x64')], r'\widetilde': [('rm', '\x7e'), ('ex', '\x65'), ('ex', '\x66'), ('ex', '\x67')], r'<' : [('cal', 'h'), ('ex', 'D')], r'>' : [('cal', 'i'), ('ex', 'E')] } for alias, target in [(r'\leftparen', '('), (r'\rightparent', ')'), (r'\leftbrace', '{'), (r'\rightbrace', '}'), (r'\leftbracket', '['), (r'\rightbracket', ']'), (r'\{', '{'), (r'\}', '}'), (r'\[', '['), (r'\]', ']')]: _size_alternatives[alias] = _size_alternatives[target] def get_sized_alternatives_for_symbol(self, fontname, sym): return self._size_alternatives.get(sym, [(fontname, sym)]) class UnicodeFonts(TruetypeFonts): """ An abstract base class for handling Unicode fonts. While some reasonably complete Unicode fonts (such as DejaVu) may work in some situations, the only Unicode font I'm aware of with a complete set of math symbols is STIX. This class will "fallback" on the Bakoma fonts when a required symbol can not be found in the font. """ use_cmex = True def __init__(self, *args, **kwargs): # This must come first so the backend's owner is set correctly if rcParams['mathtext.fallback_to_cm']: self.cm_fallback = BakomaFonts(*args, **kwargs) else: self.cm_fallback = None TruetypeFonts.__init__(self, *args, **kwargs) self.fontmap = {} for texfont in "cal rm tt it bf sf".split(): prop = rcParams['mathtext.' + texfont] font = findfont(prop) self.fontmap[texfont] = font prop = FontProperties('cmex10') font = findfont(prop) self.fontmap['ex'] = font _slanted_symbols = set(r"\int \oint".split()) def _map_virtual_font(self, fontname, font_class, uniindex): return fontname, uniindex def _get_glyph(self, fontname, font_class, sym, fontsize, math=True): found_symbol = False if self.use_cmex: uniindex = latex_to_cmex.get(sym) if uniindex is not None: fontname = 'ex' found_symbol = True if not found_symbol: try: uniindex = get_unicode_index(sym, math) found_symbol = True except ValueError: uniindex = ord('?') _log.warning( "No TeX to unicode mapping for {!a}.".format(sym)) fontname, uniindex = self._map_virtual_font( fontname, font_class, uniindex) new_fontname = fontname # Only characters in the "Letter" class should be italicized in 'it' # mode. Greek capital letters should be Roman. if found_symbol: if fontname == 'it' and uniindex < 0x10000: char = chr(uniindex) if (not unicodedata.category(char)[0] == "L" or unicodedata.name(char).startswith("GREEK CAPITAL")): new_fontname = 'rm' slanted = (new_fontname == 'it') or sym in self._slanted_symbols found_symbol = False font = self._get_font(new_fontname) if font is not None: glyphindex = font.get_char_index(uniindex) if glyphindex != 0: found_symbol = True if not found_symbol: if self.cm_fallback: if isinstance(self.cm_fallback, BakomaFonts): _log.warning( "Substituting with a symbol from Computer Modern.") if (fontname in ('it', 'regular') and isinstance(self.cm_fallback, StixFonts)): return self.cm_fallback._get_glyph( 'rm', font_class, sym, fontsize) else: return self.cm_fallback._get_glyph( fontname, font_class, sym, fontsize) else: if (fontname in ('it', 'regular') and isinstance(self, StixFonts)): return self._get_glyph('rm', font_class, sym, fontsize) _log.warning("Font {!r} does not have a glyph for {!a} " "[U+{:x}], substituting with a dummy " "symbol.".format(new_fontname, sym, uniindex)) fontname = 'rm' font = self._get_font(fontname) uniindex = 0xA4 # currency char, for lack of anything better glyphindex = font.get_char_index(uniindex) slanted = False symbol_name = font.get_glyph_name(glyphindex) return font, uniindex, symbol_name, fontsize, slanted def get_sized_alternatives_for_symbol(self, fontname, sym): if self.cm_fallback: return self.cm_fallback.get_sized_alternatives_for_symbol( fontname, sym) return [(fontname, sym)] class DejaVuFonts(UnicodeFonts): use_cmex = False def __init__(self, *args, **kwargs): # This must come first so the backend's owner is set correctly if isinstance(self, DejaVuSerifFonts): self.cm_fallback = StixFonts(*args, **kwargs) else: self.cm_fallback = StixSansFonts(*args, **kwargs) self.bakoma = BakomaFonts(*args, **kwargs) TruetypeFonts.__init__(self, *args, **kwargs) self.fontmap = {} # Include Stix sized alternatives for glyphs self._fontmap.update({ 1 : 'STIXSizeOneSym', 2 : 'STIXSizeTwoSym', 3 : 'STIXSizeThreeSym', 4 : 'STIXSizeFourSym', 5 : 'STIXSizeFiveSym'}) for key, name in self._fontmap.items(): fullpath = findfont(name) self.fontmap[key] = fullpath self.fontmap[name] = fullpath def _get_glyph(self, fontname, font_class, sym, fontsize, math=True): # Override prime symbol to use Bakoma. if sym == r'\prime': return self.bakoma._get_glyph( fontname, font_class, sym, fontsize, math) else: # check whether the glyph is available in the display font uniindex = get_unicode_index(sym) font = self._get_font('ex') if font is not None: glyphindex = font.get_char_index(uniindex) if glyphindex != 0: return super()._get_glyph( 'ex', font_class, sym, fontsize, math) # otherwise return regular glyph return super()._get_glyph( fontname, font_class, sym, fontsize, math) class DejaVuSerifFonts(DejaVuFonts): """ A font handling class for the DejaVu Serif fonts If a glyph is not found it will fallback to Stix Serif """ _fontmap = { 'rm' : 'DejaVu Serif', 'it' : 'DejaVu Serif:italic', 'bf' : 'DejaVu Serif:weight=bold', 'sf' : 'DejaVu Sans', 'tt' : 'DejaVu Sans Mono', 'ex' : 'DejaVu Serif Display', 0 : 'DejaVu Serif', } class DejaVuSansFonts(DejaVuFonts): """ A font handling class for the DejaVu Sans fonts If a glyph is not found it will fallback to Stix Sans """ _fontmap = { 'rm' : 'DejaVu Sans', 'it' : 'DejaVu Sans:italic', 'bf' : 'DejaVu Sans:weight=bold', 'sf' : 'DejaVu Sans', 'tt' : 'DejaVu Sans Mono', 'ex' : 'DejaVu Sans Display', 0 : 'DejaVu Sans', } class StixFonts(UnicodeFonts): """ A font handling class for the STIX fonts. In addition to what UnicodeFonts provides, this class: - supports "virtual fonts" which are complete alpha numeric character sets with different font styles at special Unicode code points, such as "Blackboard". - handles sized alternative characters for the STIXSizeX fonts. """ _fontmap = { 'rm' : 'STIXGeneral', 'it' : 'STIXGeneral:italic', 'bf' : 'STIXGeneral:weight=bold', 'nonunirm' : 'STIXNonUnicode', 'nonuniit' : 'STIXNonUnicode:italic', 'nonunibf' : 'STIXNonUnicode:weight=bold', 0 : 'STIXGeneral', 1 : 'STIXSizeOneSym', 2 : 'STIXSizeTwoSym', 3 : 'STIXSizeThreeSym', 4 : 'STIXSizeFourSym', 5 : 'STIXSizeFiveSym' } use_cmex = False cm_fallback = False _sans = False def __init__(self, *args, **kwargs): TruetypeFonts.__init__(self, *args, **kwargs) self.fontmap = {} for key, name in self._fontmap.items(): fullpath = findfont(name) self.fontmap[key] = fullpath self.fontmap[name] = fullpath def _map_virtual_font(self, fontname, font_class, uniindex): # Handle these "fonts" that are actually embedded in # other fonts. mapping = stix_virtual_fonts.get(fontname) if (self._sans and mapping is None and fontname not in ('regular', 'default')): mapping = stix_virtual_fonts['sf'] doing_sans_conversion = True else: doing_sans_conversion = False if mapping is not None: if isinstance(mapping, dict): try: mapping = mapping[font_class] except KeyError: mapping = mapping['rm'] # Binary search for the source glyph lo = 0 hi = len(mapping) while lo < hi: mid = (lo+hi)//2 range = mapping[mid] if uniindex < range[0]: hi = mid elif uniindex <= range[1]: break else: lo = mid + 1 if range[0] <= uniindex <= range[1]: uniindex = uniindex - range[0] + range[3] fontname = range[2] elif not doing_sans_conversion: # This will generate a dummy character uniindex = 0x1 fontname = rcParams['mathtext.default'] # Handle private use area glyphs if fontname in ('it', 'rm', 'bf') and 0xe000 <= uniindex <= 0xf8ff: fontname = 'nonuni' + fontname return fontname, uniindex _size_alternatives = {} def get_sized_alternatives_for_symbol(self, fontname, sym): fixes = {'\\{': '{', '\\}': '}', '\\[': '[', '\\]': ']'} sym = fixes.get(sym, sym) alternatives = self._size_alternatives.get(sym) if alternatives: return alternatives alternatives = [] try: uniindex = get_unicode_index(sym) except ValueError: return [(fontname, sym)] fix_ups = { ord('<'): 0x27e8, ord('>'): 0x27e9 } uniindex = fix_ups.get(uniindex, uniindex) for i in range(6): font = self._get_font(i) glyphindex = font.get_char_index(uniindex) if glyphindex != 0: alternatives.append((i, chr(uniindex))) # The largest size of the radical symbol in STIX has incorrect # metrics that cause it to be disconnected from the stem. if sym == r'\__sqrt__': alternatives = alternatives[:-1] self._size_alternatives[sym] = alternatives return alternatives class StixSansFonts(StixFonts): """ A font handling class for the STIX fonts (that uses sans-serif characters by default). """ _sans = True class StandardPsFonts(Fonts): """ Use the standard postscript fonts for rendering to backend_ps Unlike the other font classes, BakomaFont and UnicodeFont, this one requires the Ps backend. """ basepath = os.path.join(get_data_path(), 'fonts', 'afm') fontmap = { 'cal' : 'pzcmi8a', # Zapf Chancery 'rm' : 'pncr8a', # New Century Schoolbook 'tt' : 'pcrr8a', # Courier 'it' : 'pncri8a', # New Century Schoolbook Italic 'sf' : 'phvr8a', # Helvetica 'bf' : 'pncb8a', # New Century Schoolbook Bold None : 'psyr' # Symbol } def __init__(self, default_font_prop): Fonts.__init__(self, default_font_prop, MathtextBackendPs()) self.glyphd = {} self.fonts = {} filename = findfont(default_font_prop, fontext='afm', directory=self.basepath) if filename is None: filename = findfont('Helvetica', fontext='afm', directory=self.basepath) with open(filename, 'rb') as fd: default_font = AFM(fd) default_font.fname = filename self.fonts['default'] = default_font self.fonts['regular'] = default_font self.pswriter = StringIO() def _get_font(self, font): if font in self.fontmap: basename = self.fontmap[font] else: basename = font cached_font = self.fonts.get(basename) if cached_font is None: fname = os.path.join(self.basepath, basename + ".afm") with open(fname, 'rb') as fd: cached_font = AFM(fd) cached_font.fname = fname self.fonts[basename] = cached_font self.fonts[cached_font.get_fontname()] = cached_font return cached_font def _get_info(self, fontname, font_class, sym, fontsize, dpi, math=True): 'load the cmfont, metrics and glyph with caching' key = fontname, sym, fontsize, dpi tup = self.glyphd.get(key) if tup is not None: return tup # Only characters in the "Letter" class should really be italicized. # This class includes greek letters, so we're ok if (fontname == 'it' and (len(sym) > 1 or not unicodedata.category(sym).startswith("L"))): fontname = 'rm' found_symbol = False if sym in latex_to_standard: fontname, num = latex_to_standard[sym] glyph = chr(num) found_symbol = True elif len(sym) == 1: glyph = sym num = ord(glyph) found_symbol = True else: _log.warning( "No TeX to built-in Postscript mapping for {!r}".format(sym)) slanted = (fontname == 'it') font = self._get_font(fontname) if found_symbol: try: symbol_name = font.get_name_char(glyph) except KeyError: _log.warning( "No glyph in standard Postscript font {!r} for {!r}" .format(font.get_fontname(), sym)) found_symbol = False if not found_symbol: glyph = '?' num = ord(glyph) symbol_name = font.get_name_char(glyph) offset = 0 scale = 0.001 * fontsize xmin, ymin, xmax, ymax = [val * scale for val in font.get_bbox_char(glyph)] metrics = types.SimpleNamespace( advance = font.get_width_char(glyph) * scale, width = font.get_width_char(glyph) * scale, height = font.get_height_char(glyph) * scale, xmin = xmin, xmax = xmax, ymin = ymin+offset, ymax = ymax+offset, # iceberg is the equivalent of TeX's "height" iceberg = ymax + offset, slanted = slanted ) self.glyphd[key] = types.SimpleNamespace( font = font, fontsize = fontsize, postscript_name = font.get_fontname(), metrics = metrics, symbol_name = symbol_name, num = num, glyph = glyph, offset = offset ) return self.glyphd[key] def get_kern(self, font1, fontclass1, sym1, fontsize1, font2, fontclass2, sym2, fontsize2, dpi): if font1 == font2 and fontsize1 == fontsize2: info1 = self._get_info(font1, fontclass1, sym1, fontsize1, dpi) info2 = self._get_info(font2, fontclass2, sym2, fontsize2, dpi) font = info1.font return (font.get_kern_dist(info1.glyph, info2.glyph) * 0.001 * fontsize1) return Fonts.get_kern(self, font1, fontclass1, sym1, fontsize1, font2, fontclass2, sym2, fontsize2, dpi) def get_xheight(self, font, fontsize, dpi): font = self._get_font(font) return font.get_xheight() * 0.001 * fontsize def get_underline_thickness(self, font, fontsize, dpi): font = self._get_font(font) return font.get_underline_thickness() * 0.001 * fontsize ############################################################################## # TeX-LIKE BOX MODEL # The following is based directly on the document 'woven' from the # TeX82 source code. This information is also available in printed # form: # # Knuth, Donald E.. 1986. Computers and Typesetting, Volume B: # TeX: The Program. Addison-Wesley Professional. # # The most relevant "chapters" are: # Data structures for boxes and their friends # Shipping pages out (Ship class) # Packaging (hpack and vpack) # Data structures for math mode # Subroutines for math mode # Typesetting math formulas # # Many of the docstrings below refer to a numbered "node" in that # book, e.g., node123 # # Note that (as TeX) y increases downward, unlike many other parts of # matplotlib. # How much text shrinks when going to the next-smallest level. GROW_FACTOR # must be the inverse of SHRINK_FACTOR. SHRINK_FACTOR = 0.7 GROW_FACTOR = 1.0 / SHRINK_FACTOR # The number of different sizes of chars to use, beyond which they will not # get any smaller NUM_SIZE_LEVELS = 6 class FontConstantsBase(object): """ A set of constants that controls how certain things, such as sub- and superscripts are laid out. These are all metrics that can't be reliably retrieved from the font metrics in the font itself. """ # Percentage of x-height of additional horiz. space after sub/superscripts script_space = 0.05 # Percentage of x-height that sub/superscripts drop below the baseline subdrop = 0.4 # Percentage of x-height that superscripts are raised from the baseline sup1 = 0.7 # Percentage of x-height that subscripts drop below the baseline sub1 = 0.3 # Percentage of x-height that subscripts drop below the baseline when a # superscript is present sub2 = 0.5 # Percentage of x-height that sub/supercripts are offset relative to the # nucleus edge for non-slanted nuclei delta = 0.025 # Additional percentage of last character height above 2/3 of the # x-height that supercripts are offset relative to the subscript # for slanted nuclei delta_slanted = 0.2 # Percentage of x-height that supercripts and subscripts are offset for # integrals delta_integral = 0.1 class ComputerModernFontConstants(FontConstantsBase): script_space = 0.075 subdrop = 0.2 sup1 = 0.45 sub1 = 0.2 sub2 = 0.3 delta = 0.075 delta_slanted = 0.3 delta_integral = 0.3 class STIXFontConstants(FontConstantsBase): script_space = 0.1 sup1 = 0.8 sub2 = 0.6 delta = 0.05 delta_slanted = 0.3 delta_integral = 0.3 class STIXSansFontConstants(FontConstantsBase): script_space = 0.05 sup1 = 0.8 delta_slanted = 0.6 delta_integral = 0.3 class DejaVuSerifFontConstants(FontConstantsBase): pass class DejaVuSansFontConstants(FontConstantsBase): pass # Maps font family names to the FontConstantBase subclass to use _font_constant_mapping = { 'DejaVu Sans': DejaVuSansFontConstants, 'DejaVu Sans Mono': DejaVuSansFontConstants, 'DejaVu Serif': DejaVuSerifFontConstants, 'cmb10': ComputerModernFontConstants, 'cmex10': ComputerModernFontConstants, 'cmmi10': ComputerModernFontConstants, 'cmr10': ComputerModernFontConstants, 'cmss10': ComputerModernFontConstants, 'cmsy10': ComputerModernFontConstants, 'cmtt10': ComputerModernFontConstants, 'STIXGeneral': STIXFontConstants, 'STIXNonUnicode': STIXFontConstants, 'STIXSizeFiveSym': STIXFontConstants, 'STIXSizeFourSym': STIXFontConstants, 'STIXSizeThreeSym': STIXFontConstants, 'STIXSizeTwoSym': STIXFontConstants, 'STIXSizeOneSym': STIXFontConstants, # Map the fonts we used to ship, just for good measure 'Bitstream Vera Sans': DejaVuSansFontConstants, 'Bitstream Vera': DejaVuSansFontConstants, } def _get_font_constant_set(state): constants = _font_constant_mapping.get( state.font_output._get_font(state.font).family_name, FontConstantsBase) # STIX sans isn't really its own fonts, just different code points # in the STIX fonts, so we have to detect this one separately. if (constants is STIXFontConstants and isinstance(state.font_output, StixSansFonts)): return STIXSansFontConstants return constants class MathTextWarning(Warning): pass class Node(object): """ A node in the TeX box model """ def __init__(self): self.size = 0 def __repr__(self): return self.__class__.__name__ def get_kerning(self, next): return 0.0 def shrink(self): """ Shrinks one level smaller. There are only three levels of sizes, after which things will no longer get smaller. """ self.size += 1 def grow(self): """ Grows one level larger. There is no limit to how big something can get. """ self.size -= 1 def render(self, x, y): pass class Box(Node): """ Represents any node with a physical location. """ def __init__(self, width, height, depth): Node.__init__(self) self.width = width self.height = height self.depth = depth def shrink(self): Node.shrink(self) if self.size < NUM_SIZE_LEVELS: self.width *= SHRINK_FACTOR self.height *= SHRINK_FACTOR self.depth *= SHRINK_FACTOR def grow(self): Node.grow(self) self.width *= GROW_FACTOR self.height *= GROW_FACTOR self.depth *= GROW_FACTOR def render(self, x1, y1, x2, y2): pass class Vbox(Box): """ A box with only height (zero width). """ def __init__(self, height, depth): Box.__init__(self, 0., height, depth) class Hbox(Box): """ A box with only width (zero height and depth). """ def __init__(self, width): Box.__init__(self, width, 0., 0.) class Char(Node): """ Represents a single character. Unlike TeX, the font information and metrics are stored with each :class:`Char` to make it easier to lookup the font metrics when needed. Note that TeX boxes have a width, height, and depth, unlike Type1 and Truetype which use a full bounding box and an advance in the x-direction. The metrics must be converted to the TeX way, and the advance (if different from width) must be converted into a :class:`Kern` node when the :class:`Char` is added to its parent :class:`Hlist`. """ def __init__(self, c, state, math=True): Node.__init__(self) self.c = c self.font_output = state.font_output self.font = state.font self.font_class = state.font_class self.fontsize = state.fontsize self.dpi = state.dpi self.math = math # The real width, height and depth will be set during the # pack phase, after we know the real fontsize self._update_metrics() def __repr__(self): return '`%s`' % self.c def _update_metrics(self): metrics = self._metrics = self.font_output.get_metrics( self.font, self.font_class, self.c, self.fontsize, self.dpi, self.math) if self.c == ' ': self.width = metrics.advance else: self.width = metrics.width self.height = metrics.iceberg self.depth = -(metrics.iceberg - metrics.height) def is_slanted(self): return self._metrics.slanted def get_kerning(self, next): """ Return the amount of kerning between this and the given character. Called when characters are strung together into :class:`Hlist` to create :class:`Kern` nodes. """ advance = self._metrics.advance - self.width kern = 0. if isinstance(next, Char): kern = self.font_output.get_kern( self.font, self.font_class, self.c, self.fontsize, next.font, next.font_class, next.c, next.fontsize, self.dpi) return advance + kern def render(self, x, y): """ Render the character to the canvas """ self.font_output.render_glyph( x, y, self.font, self.font_class, self.c, self.fontsize, self.dpi) def shrink(self): Node.shrink(self) if self.size < NUM_SIZE_LEVELS: self.fontsize *= SHRINK_FACTOR self.width *= SHRINK_FACTOR self.height *= SHRINK_FACTOR self.depth *= SHRINK_FACTOR def grow(self): Node.grow(self) self.fontsize *= GROW_FACTOR self.width *= GROW_FACTOR self.height *= GROW_FACTOR self.depth *= GROW_FACTOR class Accent(Char): """ The font metrics need to be dealt with differently for accents, since they are already offset correctly from the baseline in TrueType fonts. """ def _update_metrics(self): metrics = self._metrics = self.font_output.get_metrics( self.font, self.font_class, self.c, self.fontsize, self.dpi) self.width = metrics.xmax - metrics.xmin self.height = metrics.ymax - metrics.ymin self.depth = 0 def shrink(self): Char.shrink(self) self._update_metrics() def grow(self): Char.grow(self) self._update_metrics() def render(self, x, y): """ Render the character to the canvas. """ self.font_output.render_glyph( x - self._metrics.xmin, y + self._metrics.ymin, self.font, self.font_class, self.c, self.fontsize, self.dpi) class List(Box): """ A list of nodes (either horizontal or vertical). """ def __init__(self, elements): Box.__init__(self, 0., 0., 0.) self.shift_amount = 0. # An arbitrary offset self.children = elements # The child nodes of this list # The following parameters are set in the vpack and hpack functions self.glue_set = 0. # The glue setting of this list self.glue_sign = 0 # 0: normal, -1: shrinking, 1: stretching self.glue_order = 0 # The order of infinity (0 - 3) for the glue def __repr__(self): return '[%s <%.02f %.02f %.02f %.02f> %s]' % ( super().__repr__(), self.width, self.height, self.depth, self.shift_amount, ' '.join([repr(x) for x in self.children])) @staticmethod def _determine_order(totals): """ Determine the highest order of glue used by the members of this list. Helper function used by vpack and hpack. """ for i in range(len(totals))[::-1]: if totals[i] != 0: return i return 0 def _set_glue(self, x, sign, totals, error_type): o = self._determine_order(totals) self.glue_order = o self.glue_sign = sign if totals[o] != 0.: self.glue_set = x / totals[o] else: self.glue_sign = 0 self.glue_ratio = 0. if o == 0: if len(self.children): _log.warning("%s %s: %r", error_type, self.__class__.__name__, self) def shrink(self): for child in self.children: child.shrink() Box.shrink(self) if self.size < NUM_SIZE_LEVELS: self.shift_amount *= SHRINK_FACTOR self.glue_set *= SHRINK_FACTOR def grow(self): for child in self.children: child.grow() Box.grow(self) self.shift_amount *= GROW_FACTOR self.glue_set *= GROW_FACTOR class Hlist(List): """ A horizontal list of boxes. """ def __init__(self, elements, w=0., m='additional', do_kern=True): List.__init__(self, elements) if do_kern: self.kern() self.hpack() def kern(self): """ Insert :class:`Kern` nodes between :class:`Char` nodes to set kerning. The :class:`Char` nodes themselves determine the amount of kerning they need (in :meth:`~Char.get_kerning`), and this function just creates the linked list in the correct way. """ new_children = [] num_children = len(self.children) if num_children: for i in range(num_children): elem = self.children[i] if i < num_children - 1: next = self.children[i + 1] else: next = None new_children.append(elem) kerning_distance = elem.get_kerning(next) if kerning_distance != 0.: kern = Kern(kerning_distance) new_children.append(kern) self.children = new_children # This is a failed experiment to fake cross-font kerning. # def get_kerning(self, next): # if len(self.children) >= 2 and isinstance(self.children[-2], Char): # if isinstance(next, Char): # print "CASE A" # return self.children[-2].get_kerning(next) # elif (isinstance(next, Hlist) and len(next.children) # and isinstance(next.children[0], Char)): # print "CASE B" # result = self.children[-2].get_kerning(next.children[0]) # print result # return result # return 0.0 def hpack(self, w=0., m='additional'): """ The main duty of :meth:`hpack` is to compute the dimensions of the resulting boxes, and to adjust the glue if one of those dimensions is pre-specified. The computed sizes normally enclose all of the material inside the new box; but some items may stick out if negative glue is used, if the box is overfull, or if a ``\\vbox`` includes other boxes that have been shifted left. - *w*: specifies a width - *m*: is either 'exactly' or 'additional'. Thus, ``hpack(w, 'exactly')`` produces a box whose width is exactly *w*, while ``hpack(w, 'additional')`` yields a box whose width is the natural width plus *w*. The default values produce a box with the natural width. """ # I don't know why these get reset in TeX. Shift_amount is pretty # much useless if we do. # self.shift_amount = 0. h = 0. d = 0. x = 0. total_stretch = [0.] * 4 total_shrink = [0.] * 4 for p in self.children: if isinstance(p, Char): x += p.width h = max(h, p.height) d = max(d, p.depth) elif isinstance(p, Box): x += p.width if not np.isinf(p.height) and not np.isinf(p.depth): s = getattr(p, 'shift_amount', 0.) h = max(h, p.height - s) d = max(d, p.depth + s) elif isinstance(p, Glue): glue_spec = p.glue_spec x += glue_spec.width total_stretch[glue_spec.stretch_order] += glue_spec.stretch total_shrink[glue_spec.shrink_order] += glue_spec.shrink elif isinstance(p, Kern): x += p.width self.height = h self.depth = d if m == 'additional': w += x self.width = w x = w - x if x == 0.: self.glue_sign = 0 self.glue_order = 0 self.glue_ratio = 0. return if x > 0.: self._set_glue(x, 1, total_stretch, "Overfull") else: self._set_glue(x, -1, total_shrink, "Underfull") class Vlist(List): """ A vertical list of boxes. """ def __init__(self, elements, h=0., m='additional'): List.__init__(self, elements) self.vpack() def vpack(self, h=0., m='additional', l=np.inf): """ The main duty of :meth:`vpack` is to compute the dimensions of the resulting boxes, and to adjust the glue if one of those dimensions is pre-specified. - *h*: specifies a height - *m*: is either 'exactly' or 'additional'. - *l*: a maximum height Thus, ``vpack(h, 'exactly')`` produces a box whose height is exactly *h*, while ``vpack(h, 'additional')`` yields a box whose height is the natural height plus *h*. The default values produce a box with the natural width. """ # I don't know why these get reset in TeX. Shift_amount is pretty # much useless if we do. # self.shift_amount = 0. w = 0. d = 0. x = 0. total_stretch = [0.] * 4 total_shrink = [0.] * 4 for p in self.children: if isinstance(p, Box): x += d + p.height d = p.depth if not np.isinf(p.width): s = getattr(p, 'shift_amount', 0.) w = max(w, p.width + s) elif isinstance(p, Glue): x += d d = 0. glue_spec = p.glue_spec x += glue_spec.width total_stretch[glue_spec.stretch_order] += glue_spec.stretch total_shrink[glue_spec.shrink_order] += glue_spec.shrink elif isinstance(p, Kern): x += d + p.width d = 0. elif isinstance(p, Char): raise RuntimeError( "Internal mathtext error: Char node found in Vlist") self.width = w if d > l: x += d - l self.depth = l else: self.depth = d if m == 'additional': h += x self.height = h x = h - x if x == 0: self.glue_sign = 0 self.glue_order = 0 self.glue_ratio = 0. return if x > 0.: self._set_glue(x, 1, total_stretch, "Overfull") else: self._set_glue(x, -1, total_shrink, "Underfull") class Rule(Box): """ A :class:`Rule` node stands for a solid black rectangle; it has *width*, *depth*, and *height* fields just as in an :class:`Hlist`. However, if any of these dimensions is inf, the actual value will be determined by running the rule up to the boundary of the innermost enclosing box. This is called a "running dimension." The width is never running in an :class:`Hlist`; the height and depth are never running in a :class:`Vlist`. """ def __init__(self, width, height, depth, state): Box.__init__(self, width, height, depth) self.font_output = state.font_output def render(self, x, y, w, h): self.font_output.render_rect_filled(x, y, x + w, y + h) class Hrule(Rule): """ Convenience class to create a horizontal rule. """ def __init__(self, state, thickness=None): if thickness is None: thickness = state.font_output.get_underline_thickness( state.font, state.fontsize, state.dpi) height = depth = thickness * 0.5 Rule.__init__(self, np.inf, height, depth, state) class Vrule(Rule): """ Convenience class to create a vertical rule. """ def __init__(self, state): thickness = state.font_output.get_underline_thickness( state.font, state.fontsize, state.dpi) Rule.__init__(self, thickness, np.inf, np.inf, state) class Glue(Node): """ Most of the information in this object is stored in the underlying :class:`GlueSpec` class, which is shared between multiple glue objects. (This is a memory optimization which probably doesn't matter anymore, but it's easier to stick to what TeX does.) """ def __init__(self, glue_type, copy=False): Node.__init__(self) self.glue_subtype = 'normal' if isinstance(glue_type, str): glue_spec = GlueSpec.factory(glue_type) elif isinstance(glue_type, GlueSpec): glue_spec = glue_type else: raise ValueError("glue_type must be a glue spec name or instance") if copy: glue_spec = glue_spec.copy() self.glue_spec = glue_spec def shrink(self): Node.shrink(self) if self.size < NUM_SIZE_LEVELS: if self.glue_spec.width != 0.: self.glue_spec = self.glue_spec.copy() self.glue_spec.width *= SHRINK_FACTOR def grow(self): Node.grow(self) if self.glue_spec.width != 0.: self.glue_spec = self.glue_spec.copy() self.glue_spec.width *= GROW_FACTOR class GlueSpec(object): """ See :class:`Glue`. """ def __init__(self, width=0., stretch=0., stretch_order=0, shrink=0., shrink_order=0): self.width = width self.stretch = stretch self.stretch_order = stretch_order self.shrink = shrink self.shrink_order = shrink_order def copy(self): return GlueSpec( self.width, self.stretch, self.stretch_order, self.shrink, self.shrink_order) def factory(cls, glue_type): return cls._types[glue_type] factory = classmethod(factory) GlueSpec._types = { 'fil': GlueSpec(0., 1., 1, 0., 0), 'fill': GlueSpec(0., 1., 2, 0., 0), 'filll': GlueSpec(0., 1., 3, 0., 0), 'neg_fil': GlueSpec(0., 0., 0, 1., 1), 'neg_fill': GlueSpec(0., 0., 0, 1., 2), 'neg_filll': GlueSpec(0., 0., 0, 1., 3), 'empty': GlueSpec(0., 0., 0, 0., 0), 'ss': GlueSpec(0., 1., 1, -1., 1) } # Some convenient ways to get common kinds of glue class Fil(Glue): def __init__(self): Glue.__init__(self, 'fil') class Fill(Glue): def __init__(self): Glue.__init__(self, 'fill') class Filll(Glue): def __init__(self): Glue.__init__(self, 'filll') class NegFil(Glue): def __init__(self): Glue.__init__(self, 'neg_fil') class NegFill(Glue): def __init__(self): Glue.__init__(self, 'neg_fill') class NegFilll(Glue): def __init__(self): Glue.__init__(self, 'neg_filll') class SsGlue(Glue): def __init__(self): Glue.__init__(self, 'ss') class HCentered(Hlist): """ A convenience class to create an :class:`Hlist` whose contents are centered within its enclosing box. """ def __init__(self, elements): Hlist.__init__(self, [SsGlue()] + elements + [SsGlue()], do_kern=False) class VCentered(Hlist): """ A convenience class to create a :class:`Vlist` whose contents are centered within its enclosing box. """ def __init__(self, elements): Vlist.__init__(self, [SsGlue()] + elements + [SsGlue()]) class Kern(Node): """ A :class:`Kern` node has a width field to specify a (normally negative) amount of spacing. This spacing correction appears in horizontal lists between letters like A and V when the font designer said that it looks better to move them closer together or further apart. A kern node can also appear in a vertical list, when its *width* denotes additional spacing in the vertical direction. """ height = 0 depth = 0 def __init__(self, width): Node.__init__(self) self.width = width def __repr__(self): return "k%.02f" % self.width def shrink(self): Node.shrink(self) if self.size < NUM_SIZE_LEVELS: self.width *= SHRINK_FACTOR def grow(self): Node.grow(self) self.width *= GROW_FACTOR class SubSuperCluster(Hlist): """ :class:`SubSuperCluster` is a sort of hack to get around that fact that this code do a two-pass parse like TeX. This lets us store enough information in the hlist itself, namely the nucleus, sub- and super-script, such that if another script follows that needs to be attached, it can be reconfigured on the fly. """ def __init__(self): self.nucleus = None self.sub = None self.super = None Hlist.__init__(self, []) class AutoHeightChar(Hlist): """ :class:`AutoHeightChar` will create a character as close to the given height and depth as possible. When using a font with multiple height versions of some characters (such as the BaKoMa fonts), the correct glyph will be selected, otherwise this will always just return a scaled version of the glyph. """ def __init__(self, c, height, depth, state, always=False, factor=None): alternatives = state.font_output.get_sized_alternatives_for_symbol( state.font, c) xHeight = state.font_output.get_xheight( state.font, state.fontsize, state.dpi) state = state.copy() target_total = height + depth for fontname, sym in alternatives: state.font = fontname char = Char(sym, state) # Ensure that size 0 is chosen when the text is regular sized but # with descender glyphs by subtracting 0.2 * xHeight if char.height + char.depth >= target_total - 0.2 * xHeight: break shift = 0 if state.font != 0: if factor is None: factor = (target_total) / (char.height + char.depth) state.fontsize *= factor char = Char(sym, state) shift = (depth - char.depth) Hlist.__init__(self, [char]) self.shift_amount = shift class AutoWidthChar(Hlist): """ :class:`AutoWidthChar` will create a character as close to the given width as possible. When using a font with multiple width versions of some characters (such as the BaKoMa fonts), the correct glyph will be selected, otherwise this will always just return a scaled version of the glyph. """ def __init__(self, c, width, state, always=False, char_class=Char): alternatives = state.font_output.get_sized_alternatives_for_symbol( state.font, c) state = state.copy() for fontname, sym in alternatives: state.font = fontname char = char_class(sym, state) if char.width >= width: break factor = width / char.width state.fontsize *= factor char = char_class(sym, state) Hlist.__init__(self, [char]) self.width = char.width class Ship(object): """ Once the boxes have been set up, this sends them to output. Since boxes can be inside of boxes inside of boxes, the main work of :class:`Ship` is done by two mutually recursive routines, :meth:`hlist_out` and :meth:`vlist_out`, which traverse the :class:`Hlist` nodes and :class:`Vlist` nodes inside of horizontal and vertical boxes. The global variables used in TeX to store state as it processes have become member variables here. """ def __call__(self, ox, oy, box): self.max_push = 0 # Deepest nesting of push commands so far self.cur_s = 0 self.cur_v = 0. self.cur_h = 0. self.off_h = ox self.off_v = oy + box.height self.hlist_out(box) def clamp(value): if value < -1000000000.: return -1000000000. if value > 1000000000.: return 1000000000. return value clamp = staticmethod(clamp) def hlist_out(self, box): cur_g = 0 cur_glue = 0. glue_order = box.glue_order glue_sign = box.glue_sign base_line = self.cur_v left_edge = self.cur_h self.cur_s += 1 self.max_push = max(self.cur_s, self.max_push) clamp = self.clamp for p in box.children: if isinstance(p, Char): p.render(self.cur_h + self.off_h, self.cur_v + self.off_v) self.cur_h += p.width elif isinstance(p, Kern): self.cur_h += p.width elif isinstance(p, List): # node623 if len(p.children) == 0: self.cur_h += p.width else: edge = self.cur_h self.cur_v = base_line + p.shift_amount if isinstance(p, Hlist): self.hlist_out(p) else: # p.vpack(box.height + box.depth, 'exactly') self.vlist_out(p) self.cur_h = edge + p.width self.cur_v = base_line elif isinstance(p, Box): # node624 rule_height = p.height rule_depth = p.depth rule_width = p.width if np.isinf(rule_height): rule_height = box.height if np.isinf(rule_depth): rule_depth = box.depth if rule_height > 0 and rule_width > 0: self.cur_v = base_line + rule_depth p.render(self.cur_h + self.off_h, self.cur_v + self.off_v, rule_width, rule_height) self.cur_v = base_line self.cur_h += rule_width elif isinstance(p, Glue): # node625 glue_spec = p.glue_spec rule_width = glue_spec.width - cur_g if glue_sign != 0: # normal if glue_sign == 1: # stretching if glue_spec.stretch_order == glue_order: cur_glue += glue_spec.stretch cur_g = round(clamp(box.glue_set * cur_glue)) elif glue_spec.shrink_order == glue_order: cur_glue += glue_spec.shrink cur_g = round(clamp(box.glue_set * cur_glue)) rule_width += cur_g self.cur_h += rule_width self.cur_s -= 1 def vlist_out(self, box): cur_g = 0 cur_glue = 0. glue_order = box.glue_order glue_sign = box.glue_sign self.cur_s += 1 self.max_push = max(self.max_push, self.cur_s) left_edge = self.cur_h self.cur_v -= box.height top_edge = self.cur_v clamp = self.clamp for p in box.children: if isinstance(p, Kern): self.cur_v += p.width elif isinstance(p, List): if len(p.children) == 0: self.cur_v += p.height + p.depth else: self.cur_v += p.height self.cur_h = left_edge + p.shift_amount save_v = self.cur_v p.width = box.width if isinstance(p, Hlist): self.hlist_out(p) else: self.vlist_out(p) self.cur_v = save_v + p.depth self.cur_h = left_edge elif isinstance(p, Box): rule_height = p.height rule_depth = p.depth rule_width = p.width if np.isinf(rule_width): rule_width = box.width rule_height += rule_depth if rule_height > 0 and rule_depth > 0: self.cur_v += rule_height p.render(self.cur_h + self.off_h, self.cur_v + self.off_v, rule_width, rule_height) elif isinstance(p, Glue): glue_spec = p.glue_spec rule_height = glue_spec.width - cur_g if glue_sign != 0: # normal if glue_sign == 1: # stretching if glue_spec.stretch_order == glue_order: cur_glue += glue_spec.stretch cur_g = round(clamp(box.glue_set * cur_glue)) elif glue_spec.shrink_order == glue_order: # shrinking cur_glue += glue_spec.shrink cur_g = round(clamp(box.glue_set * cur_glue)) rule_height += cur_g self.cur_v += rule_height elif isinstance(p, Char): raise RuntimeError( "Internal mathtext error: Char node found in vlist") self.cur_s -= 1 ship = Ship() ############################################################################## # PARSER def Error(msg): """ Helper class to raise parser errors. """ def raise_error(s, loc, toks): raise ParseFatalException(s, loc, msg) empty = Empty() empty.setParseAction(raise_error) return empty class Parser(object): """ This is the pyparsing-based parser for math expressions. It actually parses full strings *containing* math expressions, in that raw text may also appear outside of pairs of ``$``. The grammar is based directly on that in TeX, though it cuts a few corners. """ _math_style_dict = dict(displaystyle=0, textstyle=1, scriptstyle=2, scriptscriptstyle=3) _binary_operators = set(''' + * - \\pm \\sqcap \\rhd \\mp \\sqcup \\unlhd \\times \\vee \\unrhd \\div \\wedge \\oplus \\ast \\setminus \\ominus \\star \\wr \\otimes \\circ \\diamond \\oslash \\bullet \\bigtriangleup \\odot \\cdot \\bigtriangledown \\bigcirc \\cap \\triangleleft \\dagger \\cup \\triangleright \\ddagger \\uplus \\lhd \\amalg'''.split()) _relation_symbols = set(''' = < > : \\leq \\geq \\equiv \\models \\prec \\succ \\sim \\perp \\preceq \\succeq \\simeq \\mid \\ll \\gg \\asymp \\parallel \\subset \\supset \\approx \\bowtie \\subseteq \\supseteq \\cong \\Join \\sqsubset \\sqsupset \\neq \\smile \\sqsubseteq \\sqsupseteq \\doteq \\frown \\in \\ni \\propto \\vdash \\dashv \\dots \\dotplus \\doteqdot'''.split()) _arrow_symbols = set(''' \\leftarrow \\longleftarrow \\uparrow \\Leftarrow \\Longleftarrow \\Uparrow \\rightarrow \\longrightarrow \\downarrow \\Rightarrow \\Longrightarrow \\Downarrow \\leftrightarrow \\longleftrightarrow \\updownarrow \\Leftrightarrow \\Longleftrightarrow \\Updownarrow \\mapsto \\longmapsto \\nearrow \\hookleftarrow \\hookrightarrow \\searrow \\leftharpoonup \\rightharpoonup \\swarrow \\leftharpoondown \\rightharpoondown \\nwarrow \\rightleftharpoons \\leadsto'''.split()) _spaced_symbols = _binary_operators | _relation_symbols | _arrow_symbols _punctuation_symbols = set(r', ; . ! \ldotp \cdotp'.split()) _overunder_symbols = set(r''' \sum \prod \coprod \bigcap \bigcup \bigsqcup \bigvee \bigwedge \bigodot \bigotimes \bigoplus \biguplus '''.split()) _overunder_functions = set( "lim liminf limsup sup max min".split()) _dropsub_symbols = set(r'''\int \oint'''.split()) _fontnames = set( "rm cal it tt sf bf default bb frak circled scr regular".split()) _function_names = set(""" arccos csc ker min arcsin deg lg Pr arctan det lim sec arg dim liminf sin cos exp limsup sinh cosh gcd ln sup cot hom log tan coth inf max tanh""".split()) _ambi_delim = set(""" | \\| / \\backslash \\uparrow \\downarrow \\updownarrow \\Uparrow \\Downarrow \\Updownarrow . \\vert \\Vert \\\\|""".split()) _left_delim = set(r"( [ \{ < \lfloor \langle \lceil".split()) _right_delim = set(r") ] \} > \rfloor \rangle \rceil".split()) def __init__(self): p = types.SimpleNamespace() # All forward declarations are here p.accent = Forward() p.ambi_delim = Forward() p.apostrophe = Forward() p.auto_delim = Forward() p.binom = Forward() p.bslash = Forward() p.c_over_c = Forward() p.customspace = Forward() p.end_group = Forward() p.float_literal = Forward() p.font = Forward() p.frac = Forward() p.dfrac = Forward() p.function = Forward() p.genfrac = Forward() p.group = Forward() p.int_literal = Forward() p.latexfont = Forward() p.lbracket = Forward() p.left_delim = Forward() p.lbrace = Forward() p.main = Forward() p.math = Forward() p.math_string = Forward() p.non_math = Forward() p.operatorname = Forward() p.overline = Forward() p.placeable = Forward() p.rbrace = Forward() p.rbracket = Forward() p.required_group = Forward() p.right_delim = Forward() p.right_delim_safe = Forward() p.simple = Forward() p.simple_group = Forward() p.single_symbol = Forward() p.snowflake = Forward() p.space = Forward() p.sqrt = Forward() p.stackrel = Forward() p.start_group = Forward() p.subsuper = Forward() p.subsuperop = Forward() p.symbol = Forward() p.symbol_name = Forward() p.token = Forward() p.unknown_symbol = Forward() # Set names on everything -- very useful for debugging for key, val in vars(p).items(): if not key.startswith('_'): val.setName(key) p.float_literal <<= Regex(r"[-+]?([0-9]+\.?[0-9]*|\.[0-9]+)") p.int_literal <<= Regex("[-+]?[0-9]+") p.lbrace <<= Literal('{').suppress() p.rbrace <<= Literal('}').suppress() p.lbracket <<= Literal('[').suppress() p.rbracket <<= Literal(']').suppress() p.bslash <<= Literal('\\') p.space <<= oneOf(list(self._space_widths)) p.customspace <<= ( Suppress(Literal(r'\hspace')) - ((p.lbrace + p.float_literal + p.rbrace) | Error(r"Expected \hspace{n}")) ) unicode_range = "\U00000080-\U0001ffff" p.single_symbol <<= Regex( r"([a-zA-Z0-9 +\-*/<>=:,.;!\?&'@()\[\]|%s])|(\\[%%${}\[\]_|])" % unicode_range) p.snowflake <<= Suppress(p.bslash) + oneOf(self._snowflake) p.symbol_name <<= ( Combine(p.bslash + oneOf(list(tex2uni))) + FollowedBy(Regex("[^A-Za-z]").leaveWhitespace() | StringEnd()) ) p.symbol <<= (p.single_symbol | p.symbol_name).leaveWhitespace() p.apostrophe <<= Regex("'+") p.c_over_c <<= ( Suppress(p.bslash) + oneOf(list(self._char_over_chars)) ) p.accent <<= Group( Suppress(p.bslash) + oneOf([*self._accent_map, *self._wide_accents]) - p.placeable ) p.function <<= ( Suppress(p.bslash) + oneOf(list(self._function_names)) ) p.start_group <<= Optional(p.latexfont) + p.lbrace p.end_group <<= p.rbrace.copy() p.simple_group <<= Group(p.lbrace + ZeroOrMore(p.token) + p.rbrace) p.required_group<<= Group(p.lbrace + OneOrMore(p.token) + p.rbrace) p.group <<= Group( p.start_group + ZeroOrMore(p.token) + p.end_group ) p.font <<= Suppress(p.bslash) + oneOf(list(self._fontnames)) p.latexfont <<= ( Suppress(p.bslash) + oneOf(['math' + x for x in self._fontnames]) ) p.frac <<= Group( Suppress(Literal(r"\frac")) - ((p.required_group + p.required_group) | Error(r"Expected \frac{num}{den}")) ) p.dfrac <<= Group( Suppress(Literal(r"\dfrac")) - ((p.required_group + p.required_group) | Error(r"Expected \dfrac{num}{den}")) ) p.stackrel <<= Group( Suppress(Literal(r"\stackrel")) - ((p.required_group + p.required_group) | Error(r"Expected \stackrel{num}{den}")) ) p.binom <<= Group( Suppress(Literal(r"\binom")) - ((p.required_group + p.required_group) | Error(r"Expected \binom{num}{den}")) ) p.ambi_delim <<= oneOf(list(self._ambi_delim)) p.left_delim <<= oneOf(list(self._left_delim)) p.right_delim <<= oneOf(list(self._right_delim)) p.right_delim_safe <<= oneOf([*(self._right_delim - {'}'}), r'\}']) p.genfrac <<= Group( Suppress(Literal(r"\genfrac")) - (( (p.lbrace + Optional(p.ambi_delim | p.left_delim, default='') + p.rbrace) + (p.lbrace + Optional(p.ambi_delim | p.right_delim_safe, default='') + p.rbrace) + (p.lbrace + p.float_literal + p.rbrace) + p.simple_group + p.required_group + p.required_group) | Error("Expected " r"\genfrac{ldelim}{rdelim}{rulesize}{style}{num}{den}")) ) p.sqrt <<= Group( Suppress(Literal(r"\sqrt")) - ((Optional(p.lbracket + p.int_literal + p.rbracket, default=None) + p.required_group) | Error("Expected \\sqrt{value}")) ) p.overline <<= Group( Suppress(Literal(r"\overline")) - (p.required_group | Error("Expected \\overline{value}")) ) p.unknown_symbol<<= Combine(p.bslash + Regex("[A-Za-z]*")) p.operatorname <<= Group( Suppress(Literal(r"\operatorname")) - ((p.lbrace + ZeroOrMore(p.simple | p.unknown_symbol) + p.rbrace) | Error("Expected \\operatorname{value}")) ) p.placeable <<= ( p.snowflake # Must be before accent so named symbols that are # prefixed with an accent name work | p.accent # Must be before symbol as all accents are symbols | p.symbol # Must be third to catch all named symbols and single # chars not in a group | p.c_over_c | p.function | p.group | p.frac | p.dfrac | p.stackrel | p.binom | p.genfrac | p.sqrt | p.overline | p.operatorname ) p.simple <<= ( p.space | p.customspace | p.font | p.subsuper ) p.subsuperop <<= oneOf(["_", "^"]) p.subsuper <<= Group( (Optional(p.placeable) + OneOrMore(p.subsuperop - p.placeable) + Optional(p.apostrophe)) | (p.placeable + Optional(p.apostrophe)) | p.apostrophe ) p.token <<= ( p.simple | p.auto_delim | p.unknown_symbol # Must be last ) p.auto_delim <<= ( Suppress(Literal(r"\left")) - ((p.left_delim | p.ambi_delim) | Error("Expected a delimiter")) + Group(ZeroOrMore(p.simple | p.auto_delim)) + Suppress(Literal(r"\right")) - ((p.right_delim | p.ambi_delim) | Error("Expected a delimiter")) ) p.math <<= OneOrMore(p.token) p.math_string <<= QuotedString('$', '\\', unquoteResults=False) p.non_math <<= Regex(r"(?:(?:\\[$])|[^$])*").leaveWhitespace() p.main <<= ( p.non_math + ZeroOrMore(p.math_string + p.non_math) + StringEnd() ) # Set actions for key, val in vars(p).items(): if not key.startswith('_'): if hasattr(self, key): val.setParseAction(getattr(self, key)) self._expression = p.main self._math_expression = p.math def parse(self, s, fonts_object, fontsize, dpi): """ Parse expression *s* using the given *fonts_object* for output, at the given *fontsize* and *dpi*. Returns the parse tree of :class:`Node` instances. """ self._state_stack = [ self.State(fonts_object, 'default', 'rm', fontsize, dpi)] self._em_width_cache = {} try: result = self._expression.parseString(s) except ParseBaseException as err: raise ValueError("\n".join(["", err.line, " " * (err.column - 1) + "^", str(err)])) self._state_stack = None self._em_width_cache = {} self._expression.resetCache() return result[0] # The state of the parser is maintained in a stack. Upon # entering and leaving a group { } or math/non-math, the stack # is pushed and popped accordingly. The current state always # exists in the top element of the stack. class State(object): """ Stores the state of the parser. States are pushed and popped from a stack as necessary, and the "current" state is always at the top of the stack. """ def __init__(self, font_output, font, font_class, fontsize, dpi): self.font_output = font_output self._font = font self.font_class = font_class self.fontsize = fontsize self.dpi = dpi def copy(self): return Parser.State( self.font_output, self.font, self.font_class, self.fontsize, self.dpi) @property def font(self): return self._font @font.setter def font(self, name): if name == "circled": cbook.warn_deprecated( "3.1", name="\\mathcircled", obj_type="mathtext command", alternative="unicode characters (e.g. '\\N{CIRCLED LATIN " "CAPITAL LETTER A}' or '\\u24b6')") if name in ('rm', 'it', 'bf'): self.font_class = name self._font = name def get_state(self): """ Get the current :class:`State` of the parser. """ return self._state_stack[-1] def pop_state(self): """ Pop a :class:`State` off of the stack. """ self._state_stack.pop() def push_state(self): """ Push a new :class:`State` onto the stack which is just a copy of the current state. """ self._state_stack.append(self.get_state().copy()) def main(self, s, loc, toks): return [Hlist(toks)] def math_string(self, s, loc, toks): return self._math_expression.parseString(toks[0][1:-1]) def math(self, s, loc, toks): hlist = Hlist(toks) self.pop_state() return [hlist] def non_math(self, s, loc, toks): s = toks[0].replace(r'\$', '$') symbols = [Char(c, self.get_state(), math=False) for c in s] hlist = Hlist(symbols) # We're going into math now, so set font to 'it' self.push_state() self.get_state().font = rcParams['mathtext.default'] return [hlist] def _make_space(self, percentage): # All spaces are relative to em width state = self.get_state() key = (state.font, state.fontsize, state.dpi) width = self._em_width_cache.get(key) if width is None: metrics = state.font_output.get_metrics( state.font, rcParams['mathtext.default'], 'm', state.fontsize, state.dpi) width = metrics.advance self._em_width_cache[key] = width return Kern(width * percentage) _space_widths = { r'\,' : 0.16667, # 3/18 em = 3 mu r'\thinspace' : 0.16667, # 3/18 em = 3 mu r'\/' : 0.16667, # 3/18 em = 3 mu r'\>' : 0.22222, # 4/18 em = 4 mu r'\:' : 0.22222, # 4/18 em = 4 mu r'\;' : 0.27778, # 5/18 em = 5 mu r'\ ' : 0.33333, # 6/18 em = 6 mu r'~' : 0.33333, # 6/18 em = 6 mu, nonbreakable r'\enspace' : 0.5, # 9/18 em = 9 mu r'\quad' : 1, # 1 em = 18 mu r'\qquad' : 2, # 2 em = 36 mu r'\!' : -0.16667, # -3/18 em = -3 mu } def space(self, s, loc, toks): assert len(toks)==1 num = self._space_widths[toks[0]] box = self._make_space(num) return [box] def customspace(self, s, loc, toks): return [self._make_space(float(toks[0]))] def symbol(self, s, loc, toks): c = toks[0] try: char = Char(c, self.get_state()) except ValueError: raise ParseFatalException(s, loc, "Unknown symbol: %s" % c) if c in self._spaced_symbols: # iterate until we find previous character, needed for cases # such as ${ -2}$, $ -2$, or $ -2$. prev_char = next((c for c in s[:loc][::-1] if c != ' '), '') # Binary operators at start of string should not be spaced if (c in self._binary_operators and (len(s[:loc].split()) == 0 or prev_char == '{' or prev_char in self._left_delim)): return [char] else: return [Hlist([self._make_space(0.2), char, self._make_space(0.2)], do_kern = True)] elif c in self._punctuation_symbols: # Do not space commas between brackets if c == ',': prev_char = next((c for c in s[:loc][::-1] if c != ' '), '') next_char = next((c for c in s[loc + 1:] if c != ' '), '') if prev_char == '{' and next_char == '}': return [char] # Do not space dots as decimal separators if c == '.' and s[loc - 1].isdigit() and s[loc + 1].isdigit(): return [char] else: return [Hlist([char, self._make_space(0.2)], do_kern = True)] return [char] snowflake = symbol def unknown_symbol(self, s, loc, toks): c = toks[0] raise ParseFatalException(s, loc, "Unknown symbol: %s" % c) _char_over_chars = { # The first 2 entries in the tuple are (font, char, sizescale) for # the two symbols under and over. The third element is the space # (in multiples of underline height) r'AA': (('it', 'A', 1.0), (None, '\\circ', 0.5), 0.0), } def c_over_c(self, s, loc, toks): sym = toks[0] state = self.get_state() thickness = state.font_output.get_underline_thickness( state.font, state.fontsize, state.dpi) under_desc, over_desc, space = \ self._char_over_chars.get(sym, (None, None, 0.0)) if under_desc is None: raise ParseFatalException("Error parsing symbol") over_state = state.copy() if over_desc[0] is not None: over_state.font = over_desc[0] over_state.fontsize *= over_desc[2] over = Accent(over_desc[1], over_state) under_state = state.copy() if under_desc[0] is not None: under_state.font = under_desc[0] under_state.fontsize *= under_desc[2] under = Char(under_desc[1], under_state) width = max(over.width, under.width) over_centered = HCentered([over]) over_centered.hpack(width, 'exactly') under_centered = HCentered([under]) under_centered.hpack(width, 'exactly') return Vlist([ over_centered, Vbox(0., thickness * space), under_centered ]) _accent_map = { r'hat' : r'\circumflexaccent', r'breve' : r'\combiningbreve', r'bar' : r'\combiningoverline', r'grave' : r'\combininggraveaccent', r'acute' : r'\combiningacuteaccent', r'tilde' : r'\combiningtilde', r'dot' : r'\combiningdotabove', r'ddot' : r'\combiningdiaeresis', r'vec' : r'\combiningrightarrowabove', r'"' : r'\combiningdiaeresis', r"`" : r'\combininggraveaccent', r"'" : r'\combiningacuteaccent', r'~' : r'\combiningtilde', r'.' : r'\combiningdotabove', r'^' : r'\circumflexaccent', r'overrightarrow' : r'\rightarrow', r'overleftarrow' : r'\leftarrow', r'mathring' : r'\circ' } _wide_accents = set(r"widehat widetilde widebar".split()) # make a lambda and call it to get the namespace right _snowflake = (lambda am: [p for p in tex2uni if any(p.startswith(a) and a != p for a in am)] ) (set(_accent_map)) def accent(self, s, loc, toks): assert len(toks)==1 state = self.get_state() thickness = state.font_output.get_underline_thickness( state.font, state.fontsize, state.dpi) if len(toks[0]) != 2: raise ParseFatalException("Error parsing accent") accent, sym = toks[0] if accent in self._wide_accents: accent_box = AutoWidthChar( '\\' + accent, sym.width, state, char_class=Accent) else: accent_box = Accent(self._accent_map[accent], state) if accent == 'mathring': accent_box.shrink() accent_box.shrink() centered = HCentered([Hbox(sym.width / 4.0), accent_box]) centered.hpack(sym.width, 'exactly') return Vlist([ centered, Vbox(0., thickness * 2.0), Hlist([sym]) ]) def function(self, s, loc, toks): self.push_state() state = self.get_state() state.font = 'rm' hlist = Hlist([Char(c, state) for c in toks[0]]) self.pop_state() hlist.function_name = toks[0] return hlist def operatorname(self, s, loc, toks): self.push_state() state = self.get_state() state.font = 'rm' # Change the font of Chars, but leave Kerns alone for c in toks[0]: if isinstance(c, Char): c.font = 'rm' c._update_metrics() self.pop_state() return Hlist(toks[0]) def start_group(self, s, loc, toks): self.push_state() # Deal with LaTeX-style font tokens if len(toks): self.get_state().font = toks[0][4:] return [] def group(self, s, loc, toks): grp = Hlist(toks[0]) return [grp] required_group = simple_group = group def end_group(self, s, loc, toks): self.pop_state() return [] def font(self, s, loc, toks): assert len(toks)==1 name = toks[0] self.get_state().font = name return [] def is_overunder(self, nucleus): if isinstance(nucleus, Char): return nucleus.c in self._overunder_symbols elif isinstance(nucleus, Hlist) and hasattr(nucleus, 'function_name'): return nucleus.function_name in self._overunder_functions return False def is_dropsub(self, nucleus): if isinstance(nucleus, Char): return nucleus.c in self._dropsub_symbols return False def is_slanted(self, nucleus): if isinstance(nucleus, Char): return nucleus.is_slanted() return False def is_between_brackets(self, s, loc): return False def subsuper(self, s, loc, toks): assert len(toks)==1 nucleus = None sub = None super = None # Pick all of the apostrophes out, including first apostrophes that # have been parsed as characters napostrophes = 0 new_toks = [] for tok in toks[0]: if isinstance(tok, str) and tok not in ('^', '_'): napostrophes += len(tok) elif isinstance(tok, Char) and tok.c == "'": napostrophes += 1 else: new_toks.append(tok) toks = new_toks if len(toks) == 0: assert napostrophes nucleus = Hbox(0.0) elif len(toks) == 1: if not napostrophes: return toks[0] # .asList() else: nucleus = toks[0] elif len(toks) in (2, 3): # single subscript or superscript nucleus = toks[0] if len(toks) == 3 else Hbox(0.0) op, next = toks[-2:] if op == '_': sub = next else: super = next elif len(toks) in (4, 5): # subscript and superscript nucleus = toks[0] if len(toks) == 5 else Hbox(0.0) op1, next1, op2, next2 = toks[-4:] if op1 == op2: if op1 == '_': raise ParseFatalException("Double subscript") else: raise ParseFatalException("Double superscript") if op1 == '_': sub = next1 super = next2 else: super = next1 sub = next2 else: raise ParseFatalException( "Subscript/superscript sequence is too long. " "Use braces { } to remove ambiguity.") state = self.get_state() rule_thickness = state.font_output.get_underline_thickness( state.font, state.fontsize, state.dpi) xHeight = state.font_output.get_xheight( state.font, state.fontsize, state.dpi) if napostrophes: if super is None: super = Hlist([]) for i in range(napostrophes): super.children.extend(self.symbol(s, loc, ['\\prime'])) # kern() and hpack() needed to get the metrics right after # extending super.kern() super.hpack() # Handle over/under symbols, such as sum or integral if self.is_overunder(nucleus): vlist = [] shift = 0. width = nucleus.width if super is not None: super.shrink() width = max(width, super.width) if sub is not None: sub.shrink() width = max(width, sub.width) if super is not None: hlist = HCentered([super]) hlist.hpack(width, 'exactly') vlist.extend([hlist, Kern(rule_thickness * 3.0)]) hlist = HCentered([nucleus]) hlist.hpack(width, 'exactly') vlist.append(hlist) if sub is not None: hlist = HCentered([sub]) hlist.hpack(width, 'exactly') vlist.extend([Kern(rule_thickness * 3.0), hlist]) shift = hlist.height vlist = Vlist(vlist) vlist.shift_amount = shift + nucleus.depth result = Hlist([vlist]) return [result] # We remove kerning on the last character for consistency (otherwise # it will compute kerning based on non-shrunk characters and may put # them too close together when superscripted) # We change the width of the last character to match the advance to # consider some fonts with weird metrics: e.g. stix's f has a width of # 7.75 and a kerning of -4.0 for an advance of 3.72, and we want to put # the superscript at the advance last_char = nucleus if isinstance(nucleus, Hlist): new_children = nucleus.children if len(new_children): # remove last kern if (isinstance(new_children[-1], Kern) and hasattr(new_children[-2], '_metrics')): new_children = new_children[:-1] last_char = new_children[-1] if hasattr(last_char, '_metrics'): last_char.width = last_char._metrics.advance # create new Hlist without kerning nucleus = Hlist(new_children, do_kern=False) else: if isinstance(nucleus, Char): last_char.width = last_char._metrics.advance nucleus = Hlist([nucleus]) # Handle regular sub/superscripts constants = _get_font_constant_set(state) lc_height = last_char.height lc_baseline = 0 if self.is_dropsub(last_char): lc_baseline = last_char.depth # Compute kerning for sub and super superkern = constants.delta * xHeight subkern = constants.delta * xHeight if self.is_slanted(last_char): superkern += constants.delta * xHeight superkern += (constants.delta_slanted * (lc_height - xHeight * 2. / 3.)) if self.is_dropsub(last_char): subkern = (3 * constants.delta - constants.delta_integral) * lc_height superkern = (3 * constants.delta + constants.delta_integral) * lc_height else: subkern = 0 if super is None: # node757 x = Hlist([Kern(subkern), sub]) x.shrink() if self.is_dropsub(last_char): shift_down = lc_baseline + constants.subdrop * xHeight else: shift_down = constants.sub1 * xHeight x.shift_amount = shift_down else: x = Hlist([Kern(superkern), super]) x.shrink() if self.is_dropsub(last_char): shift_up = lc_height - constants.subdrop * xHeight else: shift_up = constants.sup1 * xHeight if sub is None: x.shift_amount = -shift_up else: # Both sub and superscript y = Hlist([Kern(subkern), sub]) y.shrink() if self.is_dropsub(last_char): shift_down = lc_baseline + constants.subdrop * xHeight else: shift_down = constants.sub2 * xHeight # If sub and superscript collide, move super up clr = (2.0 * rule_thickness - ((shift_up - x.depth) - (y.height - shift_down))) if clr > 0.: shift_up += clr x = Vlist([ x, Kern((shift_up - x.depth) - (y.height - shift_down)), y]) x.shift_amount = shift_down if not self.is_dropsub(last_char): x.width += constants.script_space * xHeight result = Hlist([nucleus, x]) return [result] def _genfrac(self, ldelim, rdelim, rule, style, num, den): state = self.get_state() thickness = state.font_output.get_underline_thickness( state.font, state.fontsize, state.dpi) rule = float(rule) # If style != displaystyle == 0, shrink the num and den if style != self._math_style_dict['displaystyle']: num.shrink() den.shrink() cnum = HCentered([num]) cden = HCentered([den]) width = max(num.width, den.width) cnum.hpack(width, 'exactly') cden.hpack(width, 'exactly') vlist = Vlist([cnum, # numerator Vbox(0, thickness * 2.0), # space Hrule(state, rule), # rule Vbox(0, thickness * 2.0), # space cden # denominator ]) # Shift so the fraction line sits in the middle of the # equals sign metrics = state.font_output.get_metrics( state.font, rcParams['mathtext.default'], '=', state.fontsize, state.dpi) shift = (cden.height - ((metrics.ymax + metrics.ymin) / 2 - thickness * 3.0)) vlist.shift_amount = shift result = [Hlist([vlist, Hbox(thickness * 2.)])] if ldelim or rdelim: if ldelim == '': ldelim = '.' if rdelim == '': rdelim = '.' return self._auto_sized_delimiter(ldelim, result, rdelim) return result def genfrac(self, s, loc, toks): assert len(toks) == 1 assert len(toks[0]) == 6 return self._genfrac(*tuple(toks[0])) def frac(self, s, loc, toks): assert len(toks) == 1 assert len(toks[0]) == 2 state = self.get_state() thickness = state.font_output.get_underline_thickness( state.font, state.fontsize, state.dpi) num, den = toks[0] return self._genfrac('', '', thickness, self._math_style_dict['textstyle'], num, den) def dfrac(self, s, loc, toks): assert len(toks) == 1 assert len(toks[0]) == 2 state = self.get_state() thickness = state.font_output.get_underline_thickness( state.font, state.fontsize, state.dpi) num, den = toks[0] return self._genfrac('', '', thickness, self._math_style_dict['displaystyle'], num, den) @cbook.deprecated("3.1", obj_type="mathtext command", alternative=r"\genfrac") def stackrel(self, s, loc, toks): assert len(toks) == 1 assert len(toks[0]) == 2 num, den = toks[0] return self._genfrac('', '', 0.0, self._math_style_dict['textstyle'], num, den) def binom(self, s, loc, toks): assert len(toks) == 1 assert len(toks[0]) == 2 num, den = toks[0] return self._genfrac('(', ')', 0.0, self._math_style_dict['textstyle'], num, den) def sqrt(self, s, loc, toks): root, body = toks[0] state = self.get_state() thickness = state.font_output.get_underline_thickness( state.font, state.fontsize, state.dpi) # Determine the height of the body, and add a little extra to # the height so it doesn't seem cramped height = body.height - body.shift_amount + thickness * 5.0 depth = body.depth + body.shift_amount check = AutoHeightChar(r'\__sqrt__', height, depth, state, always=True) height = check.height - check.shift_amount depth = check.depth + check.shift_amount # Put a little extra space to the left and right of the body padded_body = Hlist([Hbox(thickness * 2.0), body, Hbox(thickness * 2.0)]) rightside = Vlist([Hrule(state), Fill(), padded_body]) # Stretch the glue between the hrule and the body rightside.vpack(height + (state.fontsize * state.dpi) / (100.0 * 12.0), 'exactly', depth) # Add the root and shift it upward so it is above the tick. # The value of 0.6 is a hard-coded hack ;) if root is None: root = Box(check.width * 0.5, 0., 0.) else: root = Hlist([Char(x, state) for x in root]) root.shrink() root.shrink() root_vlist = Vlist([Hlist([root])]) root_vlist.shift_amount = -height * 0.6 hlist = Hlist([root_vlist, # Root # Negative kerning to put root over tick Kern(-check.width * 0.5), check, # Check rightside]) # Body return [hlist] def overline(self, s, loc, toks): assert len(toks)==1 assert len(toks[0])==1 body = toks[0][0] state = self.get_state() thickness = state.font_output.get_underline_thickness( state.font, state.fontsize, state.dpi) height = body.height - body.shift_amount + thickness * 3.0 depth = body.depth + body.shift_amount # Place overline above body rightside = Vlist([Hrule(state), Fill(), Hlist([body])]) # Stretch the glue between the hrule and the body rightside.vpack(height + (state.fontsize * state.dpi) / (100.0 * 12.0), 'exactly', depth) hlist = Hlist([rightside]) return [hlist] def _auto_sized_delimiter(self, front, middle, back): state = self.get_state() if len(middle): height = max(x.height for x in middle) depth = max(x.depth for x in middle) factor = None else: height = 0 depth = 0 factor = 1.0 parts = [] # \left. and \right. aren't supposed to produce any symbols if front != '.': parts.append( AutoHeightChar(front, height, depth, state, factor=factor)) parts.extend(middle) if back != '.': parts.append( AutoHeightChar(back, height, depth, state, factor=factor)) hlist = Hlist(parts) return hlist def auto_delim(self, s, loc, toks): front, middle, back = toks return self._auto_sized_delimiter(front, middle.asList(), back) ############################################################################## # MAIN class MathTextParser(object): _parser = None _backend_mapping = { 'bitmap': MathtextBackendBitmap, 'agg' : MathtextBackendAgg, 'ps' : MathtextBackendPs, 'pdf' : MathtextBackendPdf, 'svg' : MathtextBackendSvg, 'path' : MathtextBackendPath, 'cairo' : MathtextBackendCairo, 'macosx': MathtextBackendAgg, } _font_type_mapping = { 'cm' : BakomaFonts, 'dejavuserif' : DejaVuSerifFonts, 'dejavusans' : DejaVuSansFonts, 'stix' : StixFonts, 'stixsans' : StixSansFonts, 'custom' : UnicodeFonts } def __init__(self, output): """ Create a MathTextParser for the given backend *output*. """ self._output = output.lower() @functools.lru_cache(50) def parse(self, s, dpi = 72, prop = None): """ Parse the given math expression *s* at the given *dpi*. If *prop* is provided, it is a :class:`~matplotlib.font_manager.FontProperties` object specifying the "default" font to use in the math expression, used for all non-math text. The results are cached, so multiple calls to :meth:`parse` with the same expression should be fast. """ if prop is None: prop = FontProperties() if self._output == 'ps' and rcParams['ps.useafm']: font_output = StandardPsFonts(prop) else: backend = self._backend_mapping[self._output]() fontset = rcParams['mathtext.fontset'].lower() cbook._check_in_list(self._font_type_mapping, fontset=fontset) fontset_class = self._font_type_mapping[fontset] font_output = fontset_class(prop, backend) fontsize = prop.get_size_in_points() # This is a class variable so we don't rebuild the parser # with each request. if self._parser is None: self.__class__._parser = Parser() box = self._parser.parse(s, font_output, fontsize, dpi) font_output.set_canvas_size(box.width, box.height, box.depth) return font_output.get_results(box) def to_mask(self, texstr, dpi=120, fontsize=14): r""" Parameters ---------- texstr : str A valid mathtext string, e.g., r'IQ: $\sigma_i=15$'. dpi : float The dots-per-inch setting used to render the text. fontsize : int The font size in points Returns ------- array : 2D uint8 alpha Mask array of rasterized tex. depth : int Offset of the baseline from the bottom of the image, in pixels. """ assert self._output == "bitmap" prop = FontProperties(size=fontsize) ftimage, depth = self.parse(texstr, dpi=dpi, prop=prop) x = ftimage.as_array() return x, depth def to_rgba(self, texstr, color='black', dpi=120, fontsize=14): r""" Parameters ---------- texstr : str A valid mathtext string, e.g., r'IQ: $\sigma_i=15$'. color : color The text color. dpi : float The dots-per-inch setting used to render the text. fontsize : int The font size in points. Returns ------- array : (M, N, 4) array RGBA color values of rasterized tex, colorized with *color*. depth : int Offset of the baseline from the bottom of the image, in pixels. """ x, depth = self.to_mask(texstr, dpi=dpi, fontsize=fontsize) r, g, b, a = mcolors.to_rgba(color) RGBA = np.zeros((x.shape[0], x.shape[1], 4), dtype=np.uint8) RGBA[:, :, 0] = 255 * r RGBA[:, :, 1] = 255 * g RGBA[:, :, 2] = 255 * b RGBA[:, :, 3] = x return RGBA, depth def to_png(self, filename, texstr, color='black', dpi=120, fontsize=14): r""" Render a tex expression to a PNG file. Parameters ---------- filename A writable filename or fileobject. texstr : str A valid mathtext string, e.g., r'IQ: $\sigma_i=15$'. color : color The text color. dpi : float The dots-per-inch setting used to render the text. fontsize : int The font size in points. Returns ------- depth : int Offset of the baseline from the bottom of the image, in pixels. """ from matplotlib import _png rgba, depth = self.to_rgba( texstr, color=color, dpi=dpi, fontsize=fontsize) _png.write_png(rgba, filename) return depth def get_depth(self, texstr, dpi=120, fontsize=14): r""" Parameters ---------- texstr : str A valid mathtext string, e.g., r'IQ: $\sigma_i=15$'. dpi : float The dots-per-inch setting used to render the text. Returns ------- depth : int Offset of the baseline from the bottom of the image, in pixels. """ assert self._output=="bitmap" prop = FontProperties(size=fontsize) ftimage, depth = self.parse(texstr, dpi=dpi, prop=prop) return depth def math_to_image(s, filename_or_obj, prop=None, dpi=None, format=None): """ Given a math expression, renders it in a closely-clipped bounding box to an image file. *s* A math expression. The math portion should be enclosed in dollar signs. *filename_or_obj* A filepath or writable file-like object to write the image data to. *prop* If provided, a FontProperties() object describing the size and style of the text. *dpi* Override the output dpi, otherwise use the default associated with the output format. *format* The output format, e.g., 'svg', 'pdf', 'ps' or 'png'. If not provided, will be deduced from the filename. """ from matplotlib import figure # backend_agg supports all of the core output formats from matplotlib.backends import backend_agg if prop is None: prop = FontProperties() parser = MathTextParser('path') width, height, depth, _, _ = parser.parse(s, dpi=72, prop=prop) fig = figure.Figure(figsize=(width / 72.0, height / 72.0)) fig.text(0, depth/height, s, fontproperties=prop) backend_agg.FigureCanvasAgg(fig) fig.savefig(filename_or_obj, dpi=dpi, format=format) return depth
5f7f0eecae2ec43241c24ac83f12dedb2313b931
f0066a2eb7b2f92d7c04dc314af6be320724c614
/nova/pci/request.py
f9703b9962b6f268bb4bf5ab9bfa4f2a87ef5df5
[ "Apache-2.0" ]
permissive
hyphon81/nova-for-gpu-passthrough
80392ea7462ade8457e77843482387d8f6593797
7c164980d7355d8fc40a6b155e31e325191b6a5e
refs/heads/master
2021-01-20T14:10:38.016142
2017-02-10T08:03:45
2017-02-10T08:03:45
82,746,438
0
1
Apache-2.0
2020-07-24T00:41:48
2017-02-22T01:31:23
Python
UTF-8
Python
false
false
5,951
py
# Copyright 2013 Intel Corporation # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. """ Example of a PCI alias:: | pci_alias = '{ | "name": "QuicAssist", | "product_id": "0443", | "vendor_id": "8086", | "device_type": "type-PCI", | }' Aliases with the same name and the same device_type are OR operation:: | pci_alias = '{ | "name": "QuicAssist", | "product_id": "0442", | "vendor_id": "8086", | "device_type": "type-PCI", | }' These 2 aliases define a device request meaning: vendor_id is "8086" and product id is "0442" or "0443". """ import copy import jsonschema from oslo_serialization import jsonutils import six import nova.conf from nova import exception from nova.i18n import _ from nova.network import model as network_model from nova import objects from nova.objects import fields as obj_fields from nova.pci import utils PCI_NET_TAG = 'physical_network' PCI_DEVICE_TYPE_TAG = 'dev_type' DEVICE_TYPE_FOR_VNIC_TYPE = { network_model.VNIC_TYPE_DIRECT_PHYSICAL: obj_fields.PciDeviceType.SRIOV_PF } CONF = nova.conf.CONF _ALIAS_DEV_TYPE = [obj_fields.PciDeviceType.STANDARD, obj_fields.PciDeviceType.SRIOV_PF, obj_fields.PciDeviceType.SRIOV_VF] _ALIAS_CAP_TYPE = ['pci'] _ALIAS_SCHEMA = { "type": "object", "additionalProperties": False, "properties": { "name": { "type": "string", "minLength": 1, "maxLength": 256, }, "capability_type": { "type": "string", "enum": _ALIAS_CAP_TYPE, }, "product_id": { "type": "string", "pattern": utils.PCI_VENDOR_PATTERN, }, "vendor_id": { "type": "string", "pattern": utils.PCI_VENDOR_PATTERN, }, "device_type": { "type": "string", "enum": _ALIAS_DEV_TYPE, }, }, "required": ["name"], } def _get_alias_from_config(): """Parse and validate PCI aliases from the nova config.""" jaliases = CONF.pci_alias aliases = {} # map alias name to alias spec list try: for jsonspecs in jaliases: spec = jsonutils.loads(jsonspecs) jsonschema.validate(spec, _ALIAS_SCHEMA) # It should keep consistent behaviour in configuration # and extra specs to call strip() function. name = spec.pop("name").strip() dev_type = spec.pop('device_type', None) if dev_type: spec['dev_type'] = dev_type if name not in aliases: aliases[name] = [spec] else: if aliases[name][0]["dev_type"] == spec["dev_type"]: aliases[name].append(spec) else: reason = _("Device type mismatch for alias '%s'") % name raise exception.PciInvalidAlias(reason=reason) except exception.PciInvalidAlias: raise except Exception as e: raise exception.PciInvalidAlias(reason=six.text_type(e)) return aliases def _translate_alias_to_requests(alias_spec): """Generate complete pci requests from pci aliases in extra_spec.""" pci_aliases = _get_alias_from_config() pci_requests = [] # list of a specs dict for name, count in [spec.split(':') for spec in alias_spec.split(',')]: name = name.strip() if name not in pci_aliases: raise exception.PciRequestAliasNotDefined(alias=name) else: request = objects.InstancePCIRequest( count=int(count), spec=copy.deepcopy(pci_aliases[name]), alias_name=name) pci_requests.append(request) return pci_requests def get_pci_requests_from_flavor(flavor): """Get flavor's pci request. The pci_passthrough:alias scope in flavor extra_specs describes the flavor's pci requests, the key is 'pci_passthrough:alias' and the value has format 'alias_name_x:count, alias_name_y:count, ... '. The alias_name is defined in 'pci_alias' configurations. The flavor's requirement is translated into pci requests list, each entry in the list is a dictionary. The dictionary has three keys. The 'specs' gives the pci device properties requirement, the 'count' gives the number of devices, and the optional 'alias_name' is the corresponding alias definition name. Example: Assume alias configuration is:: | {'vendor_id':'8086', | 'device_id':'1502', | 'name':'alias_1'} The flavor extra specs includes: 'pci_passthrough:alias': 'alias_1:2'. The returned pci_requests are:: | pci_requests = [{'count':2, | 'specs': [{'vendor_id':'8086', | 'device_id':'1502'}], | 'alias_name': 'alias_1'}] :param flavor: the flavor to be checked :returns: a list of pci requests """ pci_requests = [] if ('extra_specs' in flavor and 'pci_passthrough:alias' in flavor['extra_specs']): pci_requests = _translate_alias_to_requests( flavor['extra_specs']['pci_passthrough:alias']) return objects.InstancePCIRequests(requests=pci_requests)
8ca2e20d5c2475857408ec3a9a8133b6303b1e7a
ef187d259d33e97c7b9ed07dfbf065cec3e41f59
/work/atcoder/abc/abc092/C/answers/257583_yurutechdon.py
a3ac0a13cdaaa6ce8a218886ee08a47873ccc801
[]
no_license
kjnh10/pcw
847f7295ea3174490485ffe14ce4cdea0931c032
8f677701bce15517fb9362cc5b596644da62dca8
refs/heads/master
2020-03-18T09:54:23.442772
2018-07-19T00:26:09
2018-07-19T00:26:09
134,586,379
0
0
null
null
null
null
UTF-8
Python
false
false
580
py
def calc(N, A, i): x = 0 r = 0 for j, a in enumerate(A): if j == i: continue r += abs(x - a) x = a r += abs(x) return r def calc0(N, A): x = 0 r = 0 for a in A: r += abs(x - a) x = a return r def calc1(N, A, ra, i): x0 = A[i - 1] x1 = A[i] x2 = A[i + 1] return ra - abs(x0 - x1) - abs(x1 - x2) + abs(x0 - x2) #N = 1000 #A = list(range(N)) N = int(input()) A = [int(_) for _ in input().split()] A += [0] ra = calc0(N, A) for i in range(N): print(calc1(N, A, ra, i))
8f7bad84627fe8cfcce026cd0a80dfd78d938e95
6e9ea85971e12928bba1f833d417fe199bd6d0ec
/bluegraph/downstream/__init__.py
98675468216819e9967d1aa094629b4f66af239c
[ "BSD-3-Clause", "CC-BY-4.0", "Apache-2.0" ]
permissive
MFSY/BlueGraph
217171a5ea96beb0bcd7389656b4637fef0522a4
e41b415aae2c82506f3e4569b078cb60269d717c
refs/heads/master
2023-07-02T12:36:03.569334
2021-07-30T15:16:07
2021-07-30T15:16:07
null
0
0
null
null
null
null
UTF-8
Python
false
false
825
py
# BlueGraph: unifying Python framework for graph analytics and co-occurrence analysis. # Copyright 2020-2021 Blue Brain Project / EPFL # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # http://www.apache.org/licenses/LICENSE-2.0 # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from .data_structures import (ElementClassifier, EmbeddingPipeline) from .utils import *
9de8a8cb58a3e52341efd46b1d033cd4c7310da3
2612f762ec75a0723a4d12ae1d63a30792e4c236
/build/dynamic_tutorials/catkin_generated/pkg.installspace.context.pc.py
7c78d468565d0bbaaf124e072286ccc7dfeb1f09
[]
no_license
aransena/catkin_ws
efdf1a52b7dbbefbfa9cb748630f7be1ffd7f628
eae6b83c80803a718a8e41569d3b4e7c1c838926
refs/heads/master
2021-01-18T21:12:48.557260
2016-06-03T13:39:22
2016-06-03T13:39:22
52,208,927
0
0
null
null
null
null
UTF-8
Python
false
false
463
py
# generated from catkin/cmake/template/pkg.context.pc.in CATKIN_PACKAGE_PREFIX = "" PROJECT_PKG_CONFIG_INCLUDE_DIRS = "/home/aransena/catkin_ws/install/include".split(';') if "/home/aransena/catkin_ws/install/include" != "" else [] PROJECT_CATKIN_DEPENDS = "".replace(';', ' ') PKG_CONFIG_LIBRARIES_WITH_PREFIX = "".split(';') if "" != "" else [] PROJECT_NAME = "dynamic_tutorials" PROJECT_SPACE_DIR = "/home/aransena/catkin_ws/install" PROJECT_VERSION = "0.0.0"
fbcd67d7d74c3ecae26dd5bef37a5504acbf0d17
183e4126b2fdb9c4276a504ff3ace42f4fbcdb16
/I семестр/Програмування (Python)/Лабораторні/Братун 6305/Labs/PRES_12/Q-q19.py
d6abad875de624e2a57c49fc115606475640bb15
[]
no_license
Computer-engineering-FICT/Computer-engineering-FICT
ab625e2ca421af8bcaff74f0d37ac1f7d363f203
80b64b43d2254e15338060aa4a6d946e8bd43424
refs/heads/master
2023-08-10T08:02:34.873229
2019-06-22T22:06:19
2019-06-22T22:06:19
193,206,403
3
0
null
2023-07-22T09:01:05
2019-06-22T07:41:22
HTML
UTF-8
Python
false
false
371
py
def func(e1, е2, е3): return e1 + е2 + е3 # Повертаємо нове значення  arr1 = [1, 2, 3, 4, 5] arr2 = [10, 20, 30, 40, 50] arr3 = [100, 200, 300, 400, 500] print(list(map(func, arr1, arr2, arr3))) #[111, 222, 333, 444, 555]
d0d370e8a80da8ba1d93250ca1666c0f4f25f327
414393a5048e5212223051d6a5541ecb873bcc53
/imagenet_VGG16/imagenet_custom_dataset.py
e2a6edb648b40588e771ff29562d5403fb9103e3
[]
no_license
byh1321/CIFAR100_Distorted_Channel_Selective
5a0fc1107ab9d60ce12504a8e474144762eda8df
897f2dea4e645329dfc3bf3df6b147c783bfa83f
refs/heads/master
2020-03-21T02:31:24.024771
2019-08-12T05:59:53
2019-08-12T05:59:53
138,002,631
0
0
null
2019-08-02T02:26:49
2018-06-20T08:26:51
Python
UTF-8
Python
false
false
2,174
py
from torch.utils.data.dataset import Dataset from torchvision import transforms import pandas as pd import numpy as np from PIL import Image ''' class IMAGENET2010VAL(Dataset): def __init__(self, csv_path): self.transformations = transforms.Compose([transforms.CenterCrop(224), transforms.ToTensor(), transforms.Normalize(mean=[0.485, 0.456, 0.406],std=[0.229, 0.224, 0.225])]) self.data_info = pd.read_csv(csv_path, header=None) self.image_arr = np.asarray(self.data_info.iloc[:, 0]) self.label_arr = np.asarray(self.data_info.iloc[:, 1]) self.data_len = len(self.data_info.index) def __getitem__(self, index): # returns the data and labels. This function is called from dataloader like this single_image_name = self.image_arr[index] img_as_img = Image.open(single_image_name) img_as_tensor = self.transformations(img_as_img) single_image_label = np.int(self.label_arr[index]) return (img_as_tensor, single_image_label) def __len__(self): return self.data_len if __name__ == '__main__': cifar100_dirty = CIFAR100DIRTY_TEST('/home/mhha/A2S/cifar100_test_targets.csv') ''' #''' class IMAGENET2010VAL(Dataset): def __init__(self, csv_path): self.transformations = transforms.Compose([transforms.Resize(256), transforms.CenterCrop(224), transforms.ToTensor(), transforms.Normalize(mean=[0.485, 0.456, 0.406],std=[0.229, 0.224, 0.225])]) self.data_info = pd.read_csv(csv_path, header=None) self.image_arr = np.asarray(self.data_info.iloc[:, 0]) self.label_arr = np.asarray(self.data_info.iloc[:, 1]) self.data_len = len(self.data_info.index) def __getitem__(self, index): # returns the data and labels. This function is called from dataloader like this single_image_name = self.image_arr[index] img_as_img = Image.open(single_image_name) img_as_tensor = self.transformations(img_as_img) single_image_label = np.int(self.label_arr[index]) return (img_as_tensor, single_image_label) def __len__(self): return self.data_len if __name__ == '__main__': cifar100_dirty = CIFAR100DIRTY_TEST('/home/mhha/A2S/cifar100_test_targets.csv') #''' """"""
8bd6b805e0f95619642fbddbf479b7164451afec
fcd64a87118a8c1e060449d8fd5b02034ac3dea7
/test/test_v1launchpadauthorization_merchant_data_customer.py
6349a458649f0386383fb31524ad115dcc8dd808
[]
no_license
carlosgalvez-tiendeo/python-paycomet_client
2b68e4e1f7cfbab81d50357513f79753cf8c2f0e
71f1fe29495ce67e37aaed4ecc9acf5994de011a
refs/heads/master
2023-08-03T02:27:50.857164
2021-06-16T13:04:46
2021-06-16T13:04:46
377,492,186
0
0
null
null
null
null
UTF-8
Python
false
false
1,147
py
# coding: utf-8 """ PAYCOMET REST API PAYCOMET API REST for customers. # noqa: E501 OpenAPI spec version: 2.28.0 Contact: [email protected] Generated by: https://github.com/swagger-api/swagger-codegen.git """ from __future__ import absolute_import import unittest import paycomet_client from paycomet_client.models.v1launchpadauthorization_merchant_data_customer import V1launchpadauthorizationMerchantDataCustomer # noqa: E501 from paycomet_client.rest import ApiException class TestV1launchpadauthorizationMerchantDataCustomer(unittest.TestCase): """V1launchpadauthorizationMerchantDataCustomer unit test stubs""" def setUp(self): pass def tearDown(self): pass def testV1launchpadauthorizationMerchantDataCustomer(self): """Test V1launchpadauthorizationMerchantDataCustomer""" # FIXME: construct object with mandatory attributes with example values # model = paycomet_client.models.v1launchpadauthorization_merchant_data_customer.V1launchpadauthorizationMerchantDataCustomer() # noqa: E501 pass if __name__ == '__main__': unittest.main()
953b99ea8392e243fb3aede49205985f3a58c2e2
ad8ec2bdb69f50768cb3faeac5865f1da6db43d5
/virtual/bin/gunicorn_paster
54c4570989b837f12d17815b4850ff67b3eb0c57
[ "MIT" ]
permissive
RisperAkinyi/NewsHighlight
319fcca85fd1af6980a6ee66e14caf6d09767865
a2e941f8158862f2b6f874458b651dfaa743c1d0
refs/heads/master
2020-06-26T16:28:05.935334
2019-07-31T08:21:40
2019-07-31T08:21:40
199,684,005
0
0
MIT
2019-08-01T06:48:05
2019-07-30T15:57:46
Python
UTF-8
Python
false
false
271
#!/home/moringa/Desktop/projects/NewsHighlight/virtual/bin/python3 # -*- coding: utf-8 -*- import re import sys from gunicorn.app.pasterapp import run if __name__ == '__main__': sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) sys.exit(run())
9bde30845ac14b116df8313ee40cac471bd37dbc
f6fa3e49fa292cb50ae5b795c52c486cd471c3e1
/crawl/test/testss.py
7ca0c0c829f3cdd27e601f629f30ef4956290019
[]
no_license
longhui001/stockAnalysis
32e84ea7ed5e21258c2b7316fb77d7b599d65ce4
2cf5c073f98ed4b36b7d048c3df577ce2fc00bc2
refs/heads/master
2021-01-20T02:54:11.604864
2015-07-30T01:17:59
2015-07-30T01:17:59
null
0
0
null
null
null
null
UTF-8
Python
false
false
276
py
scrapy crawl sinabbsCrawler -a start_url="http://guba.sina.com.cn/?s=bar&name=sz000415" scrapy shell "http://guba.sina.com.cn/?s=bar&name=sz000415" scrapy crawl sinaCrawler -a start_url="http://vip.stock.finance.sina.com.cn/corp/go.php/vCB_AllNewsStock/symbol/sz000415.phtml"
cab0e28f8d9618731251bbf91595ef878c2c5d8b
5af75a70f82257b7808246cfeea1988a3235155d
/BigGAN and DiffAugGAN/utils/load_checkpoint.py
10c47ce163f42de8f2829cf86cd511006071737f
[ "MIT" ]
permissive
MannyKayy/Ultra-Data-Efficient-GAN-Training
00be93333ecf1d1f658951582f4de32c7b676de7
11267b560a3a285582eae40d0bdcba87168f679f
refs/heads/main
2023-03-12T18:51:31.864943
2021-03-02T04:53:13
2021-03-02T04:53:13
343,878,169
1
0
MIT
2021-03-02T18:47:45
2021-03-02T18:47:45
null
UTF-8
Python
false
false
1,900
py
# PyTorch StudioGAN: https://github.com/POSTECH-CVLab/PyTorch-StudioGAN # The MIT License (MIT) # See license file or visit https://github.com/POSTECH-CVLab/PyTorch-StudioGAN for details # utils/load_checkpoint.py import os import torch import torch.nn as nn import torch.nn.utils.prune as prune def pruning_generate(model, state_dict): parameters_to_prune =[] for (name, m) in model.named_modules(): if isinstance(m, nn.Conv2d) or isinstance(m, nn.ConvTranspose2d): m = prune.custom_from_mask(m, name = 'weight', mask = state_dict[name + ".weight_mask"]) def load_checkpoint(model, optimizer, filename, metric=False, ema=False): # Note: Input model & optimizer should be pre-defined. This routine only updates their states. start_step = 0 if ema: checkpoint = torch.load(filename) #pruning_generate(model, checkpoint['state_dict']) model.load_state_dict(checkpoint['state_dict']) return model else: checkpoint = torch.load(filename) seed = checkpoint['seed'] run_name = checkpoint['run_name'] start_step = checkpoint['step'] #pruning_generate(model, checkpoint['state_dict']) model.load_state_dict(checkpoint['state_dict']) optimizer.load_state_dict(checkpoint['optimizer']) ada_p = checkpoint['ada_p'] for state in optimizer.state.values(): for k, v in state.items(): if isinstance(v, torch.Tensor): state[k] = v.cuda() if metric: best_step = checkpoint['best_step'] best_fid = checkpoint['best_fid'] best_fid_checkpoint_path = checkpoint['best_fid_checkpoint_path'] return model, optimizer, seed, run_name, start_step, ada_p, best_step, best_fid, best_fid_checkpoint_path return model, optimizer, seed, run_name, start_step, ada_p
3655136ac48e59cbf41490ad21958f3bb469b27c
e11dff811ca981f428644fd70d10a7369c671bcb
/src/tools/ecos/cvxpy/examples/extensions/mixed_integer/integer.py
4a7d49126f1aa2305ef4a38eff9d78707bca0801
[ "GPL-3.0-only", "GPL-3.0-or-later", "MIT" ]
permissive
riadnassiffe/Simulator
3c4a036b5635534929fdb04b0e9c96d64c0da71f
7d9ff09f26367d3714e3d10be3dd4a9817b8ed6b
refs/heads/master
2021-06-20T09:31:36.033427
2021-04-17T00:03:17
2021-04-17T00:03:17
16,033,879
0
0
MIT
2021-03-22T23:20:34
2014-01-18T20:58:10
Jupyter Notebook
UTF-8
Python
false
false
1,062
py
""" Copyright 2013 Steven Diamond This file is part of CVXPY. CVXPY is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. CVXPY is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with CVXPY. If not, see <http://www.gnu.org/licenses/>. """ from noncvx_variable import NonCvxVariable class IntVar(NonCvxVariable): """ An integer variable. """ # All values set rounded to the nearest integer. def _round(self, matrix): for i,v in enumerate(matrix): matrix[i] = round(v) return matrix # Constrain all entries to be the value in the matrix. def _fix(self, matrix): return [self == matrix]
576cc242fbb413901eaf07b20357bfdae1a3385d
4664328482163fd927603d66f47209b28471cf0f
/venv/lib/python3.7/site-packages/patoolib/programs/unadf.py
496cbd68757468f0b3e1f3f569b858d1f2dc4cda
[ "MIT" ]
permissive
emmetaobrien/dats-validator
08706ddab795d272391b3611cd3ba0de8c4a91a1
fb25f97a32119c2bce4eb50dc080a93d5ee77141
refs/heads/master
2020-12-19T05:03:17.179117
2020-01-22T17:28:38
2020-01-22T17:28:38
235,626,049
0
0
MIT
2020-01-22T17:24:56
2020-01-22T17:24:56
null
UTF-8
Python
false
false
1,056
py
# -*- coding: utf-8 -*- # Copyright (C) 2012-2015 Bastian Kleineidam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. """Archive commands for the unadf program.""" def extract_adf (archive, compression, cmd, verbosity, interactive, outdir): """Extract an ADF archive.""" return [cmd, archive, '-d', outdir] def list_adf (archive, compression, cmd, verbosity, interactive): """List an ADF archive.""" return [cmd, '-l', archive] test_adf = list_adf
8ba7a124b9cc544202f061e3a6b1a5171c7de535
7a6aca7d300c0752f2a73730b743a1a7361e941b
/tensorflow_graphics/projects/radiance_fields/sharf/geometry_net/model.py
00ce6b103e63258cebfce5f79b8131029bc38dc8
[ "Apache-2.0" ]
permissive
tensorflow/graphics
ef0abe102398a58eb7c41b709393df3d0b0a2811
1b0203eb538f2b6a1013ec7736d0d548416f059a
refs/heads/master
2023-09-03T20:41:25.992578
2023-08-08T21:16:36
2023-08-08T21:17:31
164,626,274
2,920
413
Apache-2.0
2023-08-27T14:26:47
2019-01-08T10:39:44
Python
UTF-8
Python
false
false
7,406
py
# Copyright 2020 The TensorFlow Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Implementation of the geometry network.""" from absl import logging import tensorflow as tf import tensorflow_graphics.projects.radiance_fields.sharf.geometry_net.layers as geometry_layers import tensorflow_graphics.projects.radiance_fields.sharf.voxel_functions as voxel_functions class GeometryNetwork: """Network for generating voxels from latent codes.""" def __init__(self, num_latent_codes=4371, latent_code_dim=256, fc_channels=512, fc_activation='relu', conv_size=4, norm3d='batchnorm', bce_gamma=0.8, proj_weight=0.01, mirror_weight=1.0): self.num_latent_codes = num_latent_codes self.latent_code_dim = latent_code_dim self.fc_channels = fc_channels self.fc_activation = fc_activation self.conv_size = conv_size self.norm3d = norm3d self.model = None self.model_backup = None self.latent_code_vars = None self.network_vars = None self.global_step = None self.latest_epoch = None self.optimizer_network = None self.optimizer_latent = None self.checkpoint = None self.manager = None self.summary_writer = None self.bce_gamma = bce_gamma self.proj_weight = proj_weight self.mirror_weight = mirror_weight self.mask_voxels = voxel_functions.get_mask_voxels() def get_model(self): """Voxel GLO network.""" fc_channels = self.fc_channels norm3d = self.norm3d activation = self.fc_activation with tf.name_scope('Network/'): latent_code = tf.keras.layers.Input(shape=(self.latent_code_dim,)) with tf.name_scope('FC_layers'): fc0 = tf.keras.layers.Dense(fc_channels, activation=activation)(latent_code) fc1 = tf.keras.layers.Dense(fc_channels, activation=activation)(fc0) fc2 = tf.keras.layers.Dense(fc_channels, activation=activation)(fc1) fc2_as_volume = tf.keras.layers.Reshape((1, 1, 1, fc_channels))(fc2) with tf.name_scope('GLO_VoxelDecoder'): decoder_1 = geometry_layers.conv_t_block_3d(fc2_as_volume, num_filters=32, size=self.conv_size, strides=2, normalization=norm3d) # 2 decoder_2 = geometry_layers.conv_t_block_3d(decoder_1, num_filters=32, size=self.conv_size, strides=2, normalization=norm3d) # 4 decoder_3 = geometry_layers.conv_t_block_3d(decoder_2, num_filters=32, size=self.conv_size, strides=2, normalization=norm3d) # 8 decoder_4 = geometry_layers.conv_t_block_3d(decoder_3, num_filters=16, size=self.conv_size, strides=2, normalization=norm3d) # 16 decoder_5 = geometry_layers.conv_t_block_3d(decoder_4, num_filters=8, size=self.conv_size, strides=2, normalization=norm3d) # 32 decoder_6 = geometry_layers.conv_t_block_3d(decoder_5, num_filters=4, size=self.conv_size, strides=2, normalization=norm3d) # 64 volume_out = tf.keras.layers.Conv3DTranspose( 1, self.conv_size, strides=2, padding='same', kernel_initializer=tf.keras.initializers.glorot_normal(), use_bias=False)(decoder_6) # 128 return tf.keras.Model(inputs=[latent_code], outputs=[volume_out]) def init_model(self): """Initialize models and variables.""" self.model = self.get_model() self.model_backup = self.get_model() self.latest_epoch = tf.Variable(0, trainable=False, dtype=tf.int64) self.global_step = tf.Variable(0, trainable=False, dtype=tf.int64) init_latent_code = tf.random.normal((self.num_latent_codes, self.latent_code_dim)) self.latent_code_vars = tf.Variable(init_latent_code, trainable=True) self.network_vars = self.model.trainable_variables def init_optimizer(self, learning_rate_network=0.0001, learning_rate_codes=0.0001): """Initialize the optimizers with a scheduler.""" self.optimizer_network = tf.keras.optimizers.Adam( learning_rate=learning_rate_network) self.optimizer_latent = tf.keras.optimizers.Adam( learning_rate=learning_rate_codes) def init_checkpoint(self, checkpoint_dir, checkpoint=None): """Initialize the checkpoints.""" self.summary_writer = tf.summary.create_file_writer(checkpoint_dir) self.checkpoint = tf.train.Checkpoint( model=self.model, latent_code_var=self.latent_code_vars, optimizer_network=self.optimizer_network, optimizer_latent=self.optimizer_latent, epoch=self.latest_epoch, global_step=self.global_step) self.manager = tf.train.CheckpointManager(checkpoint=self.checkpoint, directory=checkpoint_dir, max_to_keep=2) self.load_checkpoint(checkpoint=checkpoint) def load_checkpoint(self, checkpoint=None): """Load checkpoints.""" if checkpoint is None: latest_checkpoint = self.manager.latest_checkpoint else: latest_checkpoint = checkpoint if latest_checkpoint is not None: logging.info('Checkpoint %s restored', latest_checkpoint) _ = self.checkpoint.restore(latest_checkpoint).expect_partial() for a, b in zip(self.model_backup.variables, self.model.variables): a.assign(b) else: logging.warning('No checkpoint was restored.') def reset_models(self): for a, b in zip(self.model.variables, self.model_backup.variables): a.assign(b)
825534e31d01bd229b80de104734afbb4af5bb62
ea85e903db500eee66fe70ed3029b05577494d9d
/2020-12/1143. 最长公共子序列.py
c18e12ab3d0bf3adfc179ad5b9dcb2118d11acc3
[]
no_license
baolibin/leetcode
fcd975eb23e5ca3fc7febbd6c47ec833595b5a51
bc0540ec42131439be144cca19f6355a01de992a
refs/heads/master
2021-08-15T20:40:25.580955
2021-01-20T09:57:21
2021-01-20T09:57:21
76,557,864
0
0
null
null
null
null
UTF-8
Python
false
false
2,467
py
# coding:utf-8 ''' 1143. 最长公共子序列 给定两个字符串 text1 和 text2,返回这两个字符串的最长公共子序列的长度。 一个字符串的 子序列 是指这样一个新的字符串:它是由原字符串在不改变字符的相对顺序的情况下删除某些字符 (也可以不删除任何字符)后组成的新字符串。 例如,"ace" 是 "abcde" 的子序列,但 "aec" 不是 "abcde" 的子序列。 两个字符串的「公共子序列」是这两个字符串所共同拥有的子序列。 若这两个字符串没有公共子序列,则返回 0。 示例 1: 输入:text1 = "abcde", text2 = "ace" 输出:3 解释:最长公共子序列是 "ace",它的长度为 3。 示例 2: 输入:text1 = "abc", text2 = "abc" 输出:3 解释:最长公共子序列是 "abc",它的长度为 3。 示例 3: 输入:text1 = "abc", text2 = "def" 输出:0 解释:两个字符串没有公共子序列,返回 0。 提示: 1 <= text1.length <= 1000 1 <= text2.length <= 1000 输入的字符串只含有小写英文字符。 ''' class Solution: def longestCommonSubsequence(self, text1: str, text2: str) -> int: m, n = len(text1), len(text2) # 构建 DP table 和 base case dp = [[0] * (n + 1) for _ in range(m + 1)] # 进行状态转移 for i in range(1, m + 1): for j in range(1, n + 1): if text1[i - 1] == text2[j - 1]: # 找到一个 lcs 中的字符 dp[i][j] = 1 + dp[i - 1][j - 1] else: dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]) return dp[-1][-1] ''' 讲解可以参考这个: https://leetcode-cn.com/problems/longest-common-subsequence/solution/dong-tai-gui-hua-zhi-zui-chang-gong-gong-zi-xu-lie/ https://leetcode-cn.com/problems/longest-common-subsequence/solution/dong-tai-gui-hua-tu-wen-jie-xi-by-yijiaoqian/ 方法: 最长公共子序列(Longest Common Subsequence,简称 LCS)是一道非常经典的面试题目,因为它的解法是典型的二维动态规划,大部分比较困难的字符串问题都和这个问题一个套路,比如说编辑距离。而且,这个算法稍加改造就可以用于解决其他问题,所以说 LCS 算法是值得掌握的。 动态规划算法做的就是穷举+剪枝,它俩天生一对,所以可以说只要涉及子序列问题,十有八九都需要动态规划来解决 '''
fdb61c8e6af4574802d0dc1f18d006e9cb43e9c5
bc6492a9a30ac7228caad91643d58653b49ab9e3
/sympy/integrals/rubi/rules/tangent.py
f54b4910a33a3b7f0c1c7cb57704fc7266cea5e7
[]
no_license
cosmosZhou/sagemath
2c54ea04868882340c7ef981b7f499fb205095c9
0608b946174e86182c6d35d126cd89d819d1d0b8
refs/heads/master
2023-01-06T07:31:37.546716
2020-11-12T06:39:22
2020-11-12T06:39:22
311,177,322
1
0
null
2020-11-12T06:09:11
2020-11-08T23:42:40
Python
UTF-8
Python
false
false
333,360
py
''' This code is automatically generated. Never edit it manually. For details of generating the code see `rubi_parsing_guide.md` in `parsetools`. ''' from sympy.external import import_module matchpy = import_module("matchpy") from sympy.utilities.decorator import doctest_depends_on if matchpy: from matchpy import Pattern, ReplacementRule, CustomConstraint, is_match from sympy.integrals.rubi.utility_function import ( Int, Sum, Set, With, Module, Scan, MapAnd, FalseQ, ZeroQ, NegativeQ, NonzeroQ, FreeQ, NFreeQ, List, Log, PositiveQ, PositiveIntegerQ, NegativeIntegerQ, IntegerQ, IntegersQ, ComplexNumberQ, PureComplexNumberQ, RealNumericQ, PositiveOrZeroQ, NegativeOrZeroQ, FractionOrNegativeQ, NegQ, Equal, Unequal, IntPart, FracPart, RationalQ, ProductQ, SumQ, NonsumQ, Subst, First, Rest, SqrtNumberQ, SqrtNumberSumQ, LinearQ, Sqrt, ArcCosh, Coefficient, Denominator, Hypergeometric2F1, Not, Simplify, FractionalPart, IntegerPart, AppellF1, EllipticPi, EllipticE, EllipticF, ArcTan, ArcCot, ArcCoth, ArcTanh, ArcSin, ArcSinh, ArcCos, ArcCsc, ArcSec, ArcCsch, ArcSech, Sinh, Tanh, Cosh, Sech, Csch, Coth, LessEqual, Less, Greater, GreaterEqual, FractionQ, IntLinearcQ, Expand, IndependentQ, PowerQ, IntegerPowerQ, PositiveIntegerPowerQ, FractionalPowerQ, AtomQ, ExpQ, LogQ, Head, MemberQ, TrigQ, SinQ, CosQ, TanQ, CotQ, SecQ, CscQ, Sin, Cos, Tan, Cot, Sec, Csc, HyperbolicQ, SinhQ, CoshQ, TanhQ, CothQ, SechQ, CschQ, InverseTrigQ, SinCosQ, SinhCoshQ, LeafCount, Numerator, NumberQ, NumericQ, Length, ListQ, Im, Re, InverseHyperbolicQ, InverseFunctionQ, TrigHyperbolicFreeQ, InverseFunctionFreeQ, RealQ, EqQ, FractionalPowerFreeQ, ComplexFreeQ, PolynomialQ, FactorSquareFree, PowerOfLinearQ, Exponent, QuadraticQ, LinearPairQ, BinomialParts, TrinomialParts, PolyQ, EvenQ, OddQ, PerfectSquareQ, NiceSqrtAuxQ, NiceSqrtQ, Together, PosAux, PosQ, CoefficientList, ReplaceAll, ExpandLinearProduct, GCD, ContentFactor, NumericFactor, NonnumericFactors, MakeAssocList, GensymSubst, KernelSubst, ExpandExpression, Apart, SmartApart, MatchQ, PolynomialQuotientRemainder, FreeFactors, NonfreeFactors, RemoveContentAux, RemoveContent, FreeTerms, NonfreeTerms, ExpandAlgebraicFunction, CollectReciprocals, ExpandCleanup, AlgebraicFunctionQ, Coeff, LeadTerm, RemainingTerms, LeadFactor, RemainingFactors, LeadBase, LeadDegree, Numer, Denom, hypergeom, Expon, MergeMonomials, PolynomialDivide, BinomialQ, TrinomialQ, GeneralizedBinomialQ, GeneralizedTrinomialQ, FactorSquareFreeList, PerfectPowerTest, SquareFreeFactorTest, RationalFunctionQ, RationalFunctionFactors, NonrationalFunctionFactors, Reverse, RationalFunctionExponents, RationalFunctionExpand, ExpandIntegrand, SimplerQ, SimplerSqrtQ, SumSimplerQ, BinomialDegree, TrinomialDegree, CancelCommonFactors, SimplerIntegrandQ, GeneralizedBinomialDegree, GeneralizedBinomialParts, GeneralizedTrinomialDegree, GeneralizedTrinomialParts, MonomialQ, MonomialSumQ, MinimumMonomialExponent, MonomialExponent, LinearMatchQ, PowerOfLinearMatchQ, QuadraticMatchQ, CubicMatchQ, BinomialMatchQ, TrinomialMatchQ, GeneralizedBinomialMatchQ, GeneralizedTrinomialMatchQ, QuotientOfLinearsMatchQ, PolynomialTermQ, PolynomialTerms, NonpolynomialTerms, PseudoBinomialParts, NormalizePseudoBinomial, PseudoBinomialPairQ, PseudoBinomialQ, PolynomialGCD, PolyGCD, AlgebraicFunctionFactors, NonalgebraicFunctionFactors, QuotientOfLinearsP, QuotientOfLinearsParts, QuotientOfLinearsQ, Flatten, Sort, AbsurdNumberQ, AbsurdNumberFactors, NonabsurdNumberFactors, SumSimplerAuxQ, Prepend, Drop, CombineExponents, FactorInteger, FactorAbsurdNumber, SubstForInverseFunction, SubstForFractionalPower, SubstForFractionalPowerOfQuotientOfLinears, FractionalPowerOfQuotientOfLinears, SubstForFractionalPowerQ, SubstForFractionalPowerAuxQ, FractionalPowerOfSquareQ, FractionalPowerSubexpressionQ, Apply, FactorNumericGcd, MergeableFactorQ, MergeFactor, MergeFactors, TrigSimplifyQ, TrigSimplify, TrigSimplifyRecur, Order, FactorOrder, Smallest, OrderedQ, MinimumDegree, PositiveFactors, Sign, NonpositiveFactors, PolynomialInAuxQ, PolynomialInQ, ExponentInAux, ExponentIn, PolynomialInSubstAux, PolynomialInSubst, Distrib, DistributeDegree, FunctionOfPower, DivideDegreesOfFactors, MonomialFactor, FullSimplify, FunctionOfLinearSubst, FunctionOfLinear, NormalizeIntegrand, NormalizeIntegrandAux, NormalizeIntegrandFactor, NormalizeIntegrandFactorBase, NormalizeTogether, NormalizeLeadTermSigns, AbsorbMinusSign, NormalizeSumFactors, SignOfFactor, NormalizePowerOfLinear, SimplifyIntegrand, SimplifyTerm, TogetherSimplify, SmartSimplify, SubstForExpn, ExpandToSum, UnifySum, UnifyTerms, UnifyTerm, CalculusQ, FunctionOfInverseLinear, PureFunctionOfSinhQ, PureFunctionOfTanhQ, PureFunctionOfCoshQ, IntegerQuotientQ, OddQuotientQ, EvenQuotientQ, FindTrigFactor, FunctionOfSinhQ, FunctionOfCoshQ, OddHyperbolicPowerQ, FunctionOfTanhQ, FunctionOfTanhWeight, FunctionOfHyperbolicQ, SmartNumerator, SmartDenominator, SubstForAux, ActivateTrig, ExpandTrig, TrigExpand, SubstForTrig, SubstForHyperbolic, InertTrigFreeQ, LCM, SubstForFractionalPowerOfLinear, FractionalPowerOfLinear, InverseFunctionOfLinear, InertTrigQ, InertReciprocalQ, DeactivateTrig, FixInertTrigFunction, DeactivateTrigAux, PowerOfInertTrigSumQ, PiecewiseLinearQ, KnownTrigIntegrandQ, KnownSineIntegrandQ, KnownTangentIntegrandQ, KnownCotangentIntegrandQ, KnownSecantIntegrandQ, TryPureTanSubst, TryTanhSubst, TryPureTanhSubst, AbsurdNumberGCD, AbsurdNumberGCDList, ExpandTrigExpand, ExpandTrigReduce, ExpandTrigReduceAux, NormalizeTrig, TrigToExp, ExpandTrigToExp, TrigReduce, FunctionOfTrig, AlgebraicTrigFunctionQ, FunctionOfHyperbolic, FunctionOfQ, FunctionOfExpnQ, PureFunctionOfSinQ, PureFunctionOfCosQ, PureFunctionOfTanQ, PureFunctionOfCotQ, FunctionOfCosQ, FunctionOfSinQ, OddTrigPowerQ, FunctionOfTanQ, FunctionOfTanWeight, FunctionOfTrigQ, FunctionOfDensePolynomialsQ, FunctionOfLog, PowerVariableExpn, PowerVariableDegree, PowerVariableSubst, EulerIntegrandQ, FunctionOfSquareRootOfQuadratic, SquareRootOfQuadraticSubst, Divides, EasyDQ, ProductOfLinearPowersQ, Rt, NthRoot, AtomBaseQ, SumBaseQ, NegSumBaseQ, AllNegTermQ, SomeNegTermQ, TrigSquareQ, RtAux, TrigSquare, IntSum, IntTerm, Map2, ConstantFactor, SameQ, ReplacePart, CommonFactors, MostMainFactorPosition, FunctionOfExponentialQ, FunctionOfExponential, FunctionOfExponentialFunction, FunctionOfExponentialFunctionAux, FunctionOfExponentialTest, FunctionOfExponentialTestAux, stdev, rubi_test, If, IntQuadraticQ, IntBinomialQ, RectifyTangent, RectifyCotangent, Inequality, Condition, Simp, SimpHelp, SplitProduct, SplitSum, SubstFor, SubstForAux, FresnelS, FresnelC, Erfc, Erfi, Gamma, FunctionOfTrigOfLinearQ, ElementaryFunctionQ, Complex, UnsameQ, _SimpFixFactor, SimpFixFactor, _FixSimplify, FixSimplify, _SimplifyAntiderivativeSum, SimplifyAntiderivativeSum, _SimplifyAntiderivative, SimplifyAntiderivative, _TrigSimplifyAux, TrigSimplifyAux, Cancel, Part, PolyLog, D, Dist, Sum_doit, PolynomialQuotient, Floor, PolynomialRemainder, Factor, PolyLog, CosIntegral, SinIntegral, LogIntegral, SinhIntegral, CoshIntegral, Rule, Erf, PolyGamma, ExpIntegralEi, ExpIntegralE, LogGamma , UtilityOperator, Factorial, Zeta, ProductLog, DerivativeDivides, HypergeometricPFQ, IntHide, OneQ, Null, rubi_exp as exp, rubi_log as log, Discriminant, Negative, Quotient ) from sympy import (Integral, S, sqrt, And, Or, Integer, Float, Mod, I, Abs, simplify, Mul, Add, Pow, sign, EulerGamma) from sympy.integrals.rubi.symbol import WC from sympy.core.symbol import symbols, Symbol from sympy.functions import (sin, cos, tan, cot, csc, sec, sqrt, erf) from sympy.functions.elementary.hyperbolic import (acosh, asinh, atanh, acoth, acsch, asech, cosh, sinh, tanh, coth, sech, csch) from sympy.functions.elementary.trigonometric import (atan, acsc, asin, acot, acos, asec, atan2) from sympy import pi as Pi A_, B_, C_, F_, G_, H_, a_, b_, c_, d_, e_, f_, g_, h_, i_, j_, k_, l_, m_, n_, p_, q_, r_, t_, u_, v_, s_, w_, x_, y_, z_ = [WC(i) for i in 'ABCFGHabcdefghijklmnpqrtuvswxyz'] a1_, a2_, b1_, b2_, c1_, c2_, d1_, d2_, n1_, n2_, e1_, e2_, f1_, f2_, g1_, g2_, n1_, n2_, n3_, Pq_, Pm_, Px_, Qm_, Qr_, Qx_, jn_, mn_, non2_, RFx_, RGx_ = [WC(i) for i in ['a1', 'a2', 'b1', 'b2', 'c1', 'c2', 'd1', 'd2', 'n1', 'n2', 'e1', 'e2', 'f1', 'f2', 'g1', 'g2', 'n1', 'n2', 'n3', 'Pq', 'Pm', 'Px', 'Qm', 'Qr', 'Qx', 'jn', 'mn', 'non2', 'RFx', 'RGx']] i, ii , Pqq, Q, R, r, C, k, u = symbols('i ii Pqq Q R r C k u') _UseGamma = False ShowSteps = False StepCounter = None def tangent(rubi): from sympy.integrals.rubi.constraints import cons1508, cons2, cons3, cons48, cons125, cons21, cons4, cons1509, cons17, cons23, cons93, cons165, cons94, cons1510, cons1170, cons87, cons1511, cons89, cons166, cons683, cons31, cons266, cons32, cons1512, cons1513, cons18, cons155, cons1250, cons1514, cons1515, cons1516, cons1517, cons1518, cons1519, cons1520, cons1521, cons1522, cons80, cons79, cons1523, cons1524, cons1525, cons1526, cons27, cons5, cons1527, cons7, cons1261, cons1264, cons1439, cons463, cons1440, cons1528, cons1255, cons1529, cons88, cons1530, cons1531, cons1532, cons515, cons1533, cons1534, cons1535, cons1536, cons1537, cons1538, cons66, cons1539, cons84, cons1228, cons148, cons196, cons1540, cons85, cons70, cons1541, cons71, cons1412, cons267, cons1303, cons168, cons1542, cons1543, cons1322, cons1544, cons1323, cons1545, cons1546, cons1547, cons1548, cons77, cons1549, cons1550, cons1551, cons1423, cons1385, cons111, cons272, cons1325, cons1327, cons1334, cons1552, cons1553, cons1333, cons1554, cons1555, cons1336, cons1556, cons1557, cons808, cons380, cons208, cons147, cons1417, cons50, cons38, cons34, cons35, cons346, cons1418, cons1426, cons1558, cons1559, cons1560, cons1256, cons1561, cons36, cons33, cons1433, cons1562, cons1563, cons1564, cons1565, cons1566, cons1567, cons1568, cons1569, cons1492, cons1456, cons1570, cons1481, cons1479, cons743, cons1497, cons46, cons45, cons226, cons1480, cons62, cons528, cons1571, cons1572, cons810, cons811, cons1360, cons1573, cons1495, cons68, cons69, cons823, cons824, cons1574, cons1575, cons1576, cons1577, cons1578, cons1579, cons47, cons239, cons1580 pattern3398 = Pattern(Integral((WC('a', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons21, cons4, cons1508) def replacement3398(m, f, b, a, n, x, e): rubi.append(3398) return -Simp(b*(a*sin(e + f*x))**m*(b*tan(e + f*x))**(n + S(-1))/(f*m), x) rule3398 = ReplacementRule(pattern3398, replacement3398) pattern3399 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons21, cons4, cons1508) def replacement3399(m, f, b, a, n, x, e): rubi.append(3399) return Simp(b*(a*cos(e + f*x))**m*(b/tan(e + f*x))**(n + S(-1))/(f*m), x) rule3399 = ReplacementRule(pattern3399, replacement3399) pattern3400 = Pattern(Integral(sin(x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**WC('n', S(1)), x_), cons48, cons125, cons1509) def replacement3400(m, f, n, x, e): rubi.append(3400) return -Dist(S(1)/f, Subst(Int(x**(-n)*(-x**S(2) + S(1))**(m/S(2) + n/S(2) + S(-1)/2), x), x, cos(e + f*x)), x) rule3400 = ReplacementRule(pattern3400, replacement3400) pattern3401 = Pattern(Integral((S(1)/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1)), x_), cons48, cons125, cons1509) def replacement3401(m, f, n, x, e): rubi.append(3401) return Dist(S(1)/f, Subst(Int(x**(-n)*(-x**S(2) + S(1))**(m/S(2) + n/S(2) + S(-1)/2), x), x, sin(e + f*x)), x) rule3401 = ReplacementRule(pattern3401, replacement3401) pattern3402 = Pattern(Integral((WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*sin(x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1)), x_), cons3, cons48, cons125, cons4, cons17, cons23) def replacement3402(m, f, b, n, x, e): rubi.append(3402) return Dist(b**(-m), Int((b*tan(e + f*x))**(m + n)*(S(1)/cos(e + f*x))**(-m), x), x) rule3402 = ReplacementRule(pattern3402, replacement3402) pattern3403 = Pattern(Integral((WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*cos(x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1)), x_), cons3, cons48, cons125, cons4, cons17, cons23) def replacement3403(m, f, b, n, x, e): rubi.append(3403) return Dist(b**(-m), Int((b/tan(e + f*x))**(m + n)*(S(1)/sin(e + f*x))**(-m), x), x) rule3403 = ReplacementRule(pattern3403, replacement3403) pattern3404 = Pattern(Integral((WC('a', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons93, cons165, cons94, cons1510, cons1170) def replacement3404(m, f, b, a, n, x, e): rubi.append(3404) return -Dist(b**S(2)*(m + S(2))/(a**S(2)*(n + S(-1))), Int((a*sin(e + f*x))**(m + S(2))*(b*tan(e + f*x))**(n + S(-2)), x), x) + Simp(b*(a*sin(e + f*x))**(m + S(2))*(b*tan(e + f*x))**(n + S(-1))/(a**S(2)*f*(n + S(-1))), x) rule3404 = ReplacementRule(pattern3404, replacement3404) pattern3405 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons93, cons165, cons94, cons1510, cons1170) def replacement3405(m, f, b, a, n, x, e): rubi.append(3405) return -Dist(b**S(2)*(m + S(2))/(a**S(2)*(n + S(-1))), Int((a*cos(e + f*x))**(m + S(2))*(b/tan(e + f*x))**(n + S(-2)), x), x) - Simp(b*(a*cos(e + f*x))**(m + S(2))*(b/tan(e + f*x))**(n + S(-1))/(a**S(2)*f*(n + S(-1))), x) rule3405 = ReplacementRule(pattern3405, replacement3405) pattern3406 = Pattern(Integral((WC('a', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons21, cons87, cons165, cons1170, cons1511) def replacement3406(m, f, b, a, n, x, e): rubi.append(3406) return -Dist(b**S(2)*(m + n + S(-1))/(n + S(-1)), Int((a*sin(e + f*x))**m*(b*tan(e + f*x))**(n + S(-2)), x), x) + Simp(b*(a*sin(e + f*x))**m*(b*tan(e + f*x))**(n + S(-1))/(f*(n + S(-1))), x) rule3406 = ReplacementRule(pattern3406, replacement3406) pattern3407 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons21, cons87, cons165, cons1170, cons1511) def replacement3407(m, f, b, a, n, x, e): rubi.append(3407) return -Dist(b**S(2)*(m + n + S(-1))/(n + S(-1)), Int((a*cos(e + f*x))**m*(b/tan(e + f*x))**(n + S(-2)), x), x) - Simp(b*(a*cos(e + f*x))**m*(b/tan(e + f*x))**(n + S(-1))/(f*(n + S(-1))), x) rule3407 = ReplacementRule(pattern3407, replacement3407) pattern3408 = Pattern(Integral((WC('a', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons93, cons89, cons166, cons1170) def replacement3408(m, f, b, a, n, x, e): rubi.append(3408) return -Dist(a**S(2)*(n + S(1))/(b**S(2)*m), Int((a*sin(e + f*x))**(m + S(-2))*(b*tan(e + f*x))**(n + S(2)), x), x) + Simp((a*sin(e + f*x))**m*(b*tan(e + f*x))**(n + S(1))/(b*f*m), x) rule3408 = ReplacementRule(pattern3408, replacement3408) pattern3409 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons93, cons89, cons166, cons1170) def replacement3409(m, f, b, a, n, x, e): rubi.append(3409) return -Dist(a**S(2)*(n + S(1))/(b**S(2)*m), Int((a*cos(e + f*x))**(m + S(-2))*(b/tan(e + f*x))**(n + S(2)), x), x) - Simp((a*cos(e + f*x))**m*(b/tan(e + f*x))**(n + S(1))/(b*f*m), x) rule3409 = ReplacementRule(pattern3409, replacement3409) pattern3410 = Pattern(Integral((WC('a', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons21, cons87, cons89, cons683, cons1170) def replacement3410(m, f, b, a, n, x, e): rubi.append(3410) return -Dist((n + S(1))/(b**S(2)*(m + n + S(1))), Int((a*sin(e + f*x))**m*(b*tan(e + f*x))**(n + S(2)), x), x) + Simp((a*sin(e + f*x))**m*(b*tan(e + f*x))**(n + S(1))/(b*f*(m + n + S(1))), x) rule3410 = ReplacementRule(pattern3410, replacement3410) pattern3411 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons21, cons87, cons89, cons683, cons1170) def replacement3411(m, f, b, a, n, x, e): rubi.append(3411) return -Dist((n + S(1))/(b**S(2)*(m + n + S(1))), Int((a*cos(e + f*x))**m*(b/tan(e + f*x))**(n + S(2)), x), x) - Simp((a*cos(e + f*x))**m*(b/tan(e + f*x))**(n + S(1))/(b*f*(m + n + S(1))), x) rule3411 = ReplacementRule(pattern3411, replacement3411) pattern3412 = Pattern(Integral((WC('a', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons48, cons125, cons4, cons31, cons266, cons1170) def replacement3412(m, f, b, a, n, x, e): rubi.append(3412) return Dist(a**S(2)*(m + n + S(-1))/m, Int((a*sin(e + f*x))**(m + S(-2))*(b*tan(e + f*x))**n, x), x) - Simp(b*(a*sin(e + f*x))**m*(b*tan(e + f*x))**(n + S(-1))/(f*m), x) rule3412 = ReplacementRule(pattern3412, replacement3412) pattern3413 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons48, cons125, cons4, cons31, cons266, cons1170) def replacement3413(m, f, b, a, n, x, e): rubi.append(3413) return Dist(a**S(2)*(m + n + S(-1))/m, Int((a*cos(e + f*x))**(m + S(-2))*(b/tan(e + f*x))**n, x), x) + Simp(b*(a*cos(e + f*x))**m*(b/tan(e + f*x))**(n + S(-1))/(f*m), x) rule3413 = ReplacementRule(pattern3413, replacement3413) pattern3414 = Pattern(Integral((WC('a', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons48, cons125, cons4, cons31, cons32, cons683, cons1170) def replacement3414(m, f, b, a, n, x, e): rubi.append(3414) return Dist((m + S(2))/(a**S(2)*(m + n + S(1))), Int((a*sin(e + f*x))**(m + S(2))*(b*tan(e + f*x))**n, x), x) + Simp(b*(a*sin(e + f*x))**(m + S(2))*(b*tan(e + f*x))**(n + S(-1))/(a**S(2)*f*(m + n + S(1))), x) rule3414 = ReplacementRule(pattern3414, replacement3414) pattern3415 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons48, cons125, cons4, cons31, cons32, cons683, cons1170) def replacement3415(m, f, b, a, n, x, e): rubi.append(3415) return Dist((m + S(2))/(a**S(2)*(m + n + S(1))), Int((a*cos(e + f*x))**(m + S(2))*(b/tan(e + f*x))**n, x), x) - Simp(b*(a*cos(e + f*x))**(m + S(2))*(b/tan(e + f*x))**(n + S(-1))/(a**S(2)*f*(m + n + S(1))), x) rule3415 = ReplacementRule(pattern3415, replacement3415) pattern3416 = Pattern(Integral((WC('a', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**WC('n', S(1)), x_), cons2, cons48, cons125, cons21, cons1512) def replacement3416(m, f, a, n, x, e): rubi.append(3416) return Dist(S(1)/f, Subst(Int(x**(m + n)*(a**S(2) - x**S(2))**(-n/S(2) + S(-1)/2), x), x, a*sin(e + f*x)), x) rule3416 = ReplacementRule(pattern3416, replacement3416) pattern3417 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(S(1)/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons48, cons125, cons21, cons1512) def replacement3417(m, f, a, n, x, e): rubi.append(3417) return -Dist(S(1)/f, Subst(Int(x**(m + n)*(a**S(2) - x**S(2))**(-n/S(2) + S(-1)/2), x), x, a*cos(e + f*x)), x) rule3417 = ReplacementRule(pattern3417, replacement3417) pattern3418 = Pattern(Integral((WC('a', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons48, cons125, cons21, cons4, cons1513) def replacement3418(m, f, b, a, n, x, e): rubi.append(3418) return Dist(a**(-S(2)*IntPart(n/S(2) + S(1)/2) + S(1))*b**(S(2)*IntPart(n/S(2) + S(1)/2) + S(-1))*(a*sin(e + f*x))**(-S(2)*FracPart(n/S(2) + S(1)/2))*(b*tan(e + f*x))**(S(2)*FracPart(n/S(2) + S(1)/2))*(cos(e + f*x)**S(2))**FracPart(n/S(2) + S(1)/2)/f, Subst(Int((a*x)**(m + n)*(-x**S(2) + S(1))**(-n/S(2) + S(-1)/2), x), x, sin(e + f*x)), x) rule3418 = ReplacementRule(pattern3418, replacement3418) pattern3419 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons48, cons125, cons21, cons4, cons1513) def replacement3419(m, f, b, a, n, x, e): rubi.append(3419) return -Dist(a**(-S(2)*IntPart(n/S(2) + S(1)/2) + S(1))*b**(S(2)*IntPart(n/S(2) + S(1)/2) + S(-1))*(a*cos(e + f*x))**(-S(2)*FracPart(n/S(2) + S(1)/2))*(b/tan(e + f*x))**(S(2)*FracPart(n/S(2) + S(1)/2))*(sin(e + f*x)**S(2))**FracPart(n/S(2) + S(1)/2)/f, Subst(Int((a*x)**(m + n)*(-x**S(2) + S(1))**(-n/S(2) + S(-1)/2), x), x, cos(e + f*x)), x) rule3419 = ReplacementRule(pattern3419, replacement3419) pattern3420 = Pattern(Integral((WC('a', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons21, cons4, cons18, cons23) def replacement3420(m, f, b, a, n, x, e): rubi.append(3420) return Dist((S(1)/(a*cos(e + f*x)))**FracPart(m)*(a*cos(e + f*x))**FracPart(m), Int((S(1)/(a*cos(e + f*x)))**(-m)*(b*tan(e + f*x))**n, x), x) rule3420 = ReplacementRule(pattern3420, replacement3420) pattern3421 = Pattern(Integral((WC('a', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons21, cons4, cons18, cons23) def replacement3421(m, f, b, a, n, x, e): rubi.append(3421) return Dist((S(1)/(a*sin(e + f*x)))**FracPart(m)*(a*sin(e + f*x))**FracPart(m), Int((S(1)/(a*sin(e + f*x)))**(-m)*(b/tan(e + f*x))**n, x), x) rule3421 = ReplacementRule(pattern3421, replacement3421) pattern3422 = Pattern(Integral((WC('a', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons21, cons4, cons18, cons23) def replacement3422(m, f, b, a, n, x, e): rubi.append(3422) return Dist((a/tan(e + f*x))**m*(b*tan(e + f*x))**m, Int((b*tan(e + f*x))**(-m + n), x), x) rule3422 = ReplacementRule(pattern3422, replacement3422) pattern3423 = Pattern(Integral((WC('a', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons48, cons125, cons21, cons4, cons155) def replacement3423(m, f, b, a, n, x, e): rubi.append(3423) return -Simp((a/cos(e + f*x))**m*(b*tan(e + f*x))**(n + S(1))/(b*f*m), x) rule3423 = ReplacementRule(pattern3423, replacement3423) pattern3424 = Pattern(Integral((WC('a', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons48, cons125, cons21, cons4, cons155) def replacement3424(m, f, b, a, n, x, e): rubi.append(3424) return Simp((a/sin(e + f*x))**m*(b/tan(e + f*x))**(n + S(1))/(b*f*m), x) rule3424 = ReplacementRule(pattern3424, replacement3424) pattern3425 = Pattern(Integral((WC('a', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons48, cons125, cons21, cons1250, cons1514) def replacement3425(m, f, b, a, n, x, e): rubi.append(3425) return Dist(a/f, Subst(Int((a*x)**(m + S(-1))*(x**S(2) + S(-1))**(n/S(2) + S(-1)/2), x), x, S(1)/cos(e + f*x)), x) rule3425 = ReplacementRule(pattern3425, replacement3425) pattern3426 = Pattern(Integral((WC('a', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons48, cons125, cons21, cons1250, cons1514) def replacement3426(m, f, b, a, n, x, e): rubi.append(3426) return -Dist(a/f, Subst(Int((a*x)**(m + S(-1))*(x**S(2) + S(-1))**(n/S(2) + S(-1)/2), x), x, S(1)/sin(e + f*x)), x) rule3426 = ReplacementRule(pattern3426, replacement3426) pattern3427 = Pattern(Integral((WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(S(1)/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons3, cons48, cons125, cons4, cons1515, cons1516) def replacement3427(m, f, b, n, x, e): rubi.append(3427) return Dist(S(1)/f, Subst(Int((b*x)**n*(x**S(2) + S(1))**(m/S(2) + S(-1)), x), x, tan(e + f*x)), x) rule3427 = ReplacementRule(pattern3427, replacement3427) pattern3428 = Pattern(Integral((WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(S(1)/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons3, cons48, cons125, cons4, cons1515, cons1516) def replacement3428(m, f, b, n, x, e): rubi.append(3428) return -Dist(S(1)/f, Subst(Int((b*x)**n*(x**S(2) + S(1))**(m/S(2) + S(-1)), x), x, S(1)/tan(e + f*x)), x) rule3428 = ReplacementRule(pattern3428, replacement3428) pattern3429 = Pattern(Integral((WC('a', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons93, cons89, cons1517, cons1170) def replacement3429(m, f, b, a, n, x, e): rubi.append(3429) return -Dist(a**S(2)*(m + S(-2))/(b**S(2)*(n + S(1))), Int((a/cos(e + f*x))**(m + S(-2))*(b*tan(e + f*x))**(n + S(2)), x), x) + Simp(a**S(2)*(a/cos(e + f*x))**(m + S(-2))*(b*tan(e + f*x))**(n + S(1))/(b*f*(n + S(1))), x) rule3429 = ReplacementRule(pattern3429, replacement3429) pattern3430 = Pattern(Integral((WC('a', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons93, cons89, cons1517, cons1170) def replacement3430(m, f, b, a, n, x, e): rubi.append(3430) return -Dist(a**S(2)*(m + S(-2))/(b**S(2)*(n + S(1))), Int((a/sin(e + f*x))**(m + S(-2))*(b/tan(e + f*x))**(n + S(2)), x), x) - Simp(a**S(2)*(a/sin(e + f*x))**(m + S(-2))*(b/tan(e + f*x))**(n + S(1))/(b*f*(n + S(1))), x) rule3430 = ReplacementRule(pattern3430, replacement3430) pattern3431 = Pattern(Integral((WC('a', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons21, cons87, cons89, cons1170) def replacement3431(m, f, b, a, n, x, e): rubi.append(3431) return -Dist((m + n + S(1))/(b**S(2)*(n + S(1))), Int((a/cos(e + f*x))**m*(b*tan(e + f*x))**(n + S(2)), x), x) + Simp((a/cos(e + f*x))**m*(b*tan(e + f*x))**(n + S(1))/(b*f*(n + S(1))), x) rule3431 = ReplacementRule(pattern3431, replacement3431) pattern3432 = Pattern(Integral((WC('a', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons21, cons87, cons89, cons1170) def replacement3432(m, f, b, a, n, x, e): rubi.append(3432) return -Dist((m + n + S(1))/(b**S(2)*(n + S(1))), Int((a/sin(e + f*x))**m*(b/tan(e + f*x))**(n + S(2)), x), x) - Simp((a/sin(e + f*x))**m*(b/tan(e + f*x))**(n + S(1))/(b*f*(n + S(1))), x) rule3432 = ReplacementRule(pattern3432, replacement3432) pattern3433 = Pattern(Integral((WC('a', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons93, cons165, cons1518, cons1170) def replacement3433(m, f, b, a, n, x, e): rubi.append(3433) return -Dist(b**S(2)*(n + S(-1))/(a**S(2)*m), Int((a/cos(e + f*x))**(m + S(2))*(b*tan(e + f*x))**(n + S(-2)), x), x) + Simp(b*(a/cos(e + f*x))**m*(b*tan(e + f*x))**(n + S(-1))/(f*m), x) rule3433 = ReplacementRule(pattern3433, replacement3433) pattern3434 = Pattern(Integral((WC('a', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons93, cons165, cons1518, cons1170) def replacement3434(m, f, b, a, n, x, e): rubi.append(3434) return -Dist(b**S(2)*(n + S(-1))/(a**S(2)*m), Int((a/sin(e + f*x))**(m + S(2))*(b/tan(e + f*x))**(n + S(-2)), x), x) - Simp(b*(a/sin(e + f*x))**m*(b/tan(e + f*x))**(n + S(-1))/(f*m), x) rule3434 = ReplacementRule(pattern3434, replacement3434) pattern3435 = Pattern(Integral((WC('a', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons21, cons87, cons165, cons1519, cons1170) def replacement3435(m, f, b, a, n, x, e): rubi.append(3435) return -Dist(b**S(2)*(n + S(-1))/(m + n + S(-1)), Int((a/cos(e + f*x))**m*(b*tan(e + f*x))**(n + S(-2)), x), x) + Simp(b*(a/cos(e + f*x))**m*(b*tan(e + f*x))**(n + S(-1))/(f*(m + n + S(-1))), x) rule3435 = ReplacementRule(pattern3435, replacement3435) pattern3436 = Pattern(Integral((WC('a', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons21, cons87, cons165, cons1519, cons1170) def replacement3436(m, f, b, a, n, x, e): rubi.append(3436) return -Dist(b**S(2)*(n + S(-1))/(m + n + S(-1)), Int((a/sin(e + f*x))**m*(b/tan(e + f*x))**(n + S(-2)), x), x) - Simp(b*(a/sin(e + f*x))**m*(b/tan(e + f*x))**(n + S(-1))/(f*(m + n + S(-1))), x) rule3436 = ReplacementRule(pattern3436, replacement3436) pattern3437 = Pattern(Integral((WC('a', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons4, cons31, cons1520, cons1170) def replacement3437(m, f, b, a, n, x, e): rubi.append(3437) return Dist((m + n + S(1))/(a**S(2)*m), Int((a/cos(e + f*x))**(m + S(2))*(b*tan(e + f*x))**n, x), x) - Simp((a/cos(e + f*x))**m*(b*tan(e + f*x))**(n + S(1))/(b*f*m), x) rule3437 = ReplacementRule(pattern3437, replacement3437) pattern3438 = Pattern(Integral((WC('a', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons4, cons31, cons1520, cons1170) def replacement3438(m, f, b, a, n, x, e): rubi.append(3438) return Dist((m + n + S(1))/(a**S(2)*m), Int((a/sin(e + f*x))**(m + S(2))*(b/tan(e + f*x))**n, x), x) + Simp((a/sin(e + f*x))**m*(b/tan(e + f*x))**(n + S(1))/(b*f*m), x) rule3438 = ReplacementRule(pattern3438, replacement3438) pattern3439 = Pattern(Integral((WC('a', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons4, cons31, cons1521, cons1519, cons1170) def replacement3439(m, f, b, a, n, x, e): rubi.append(3439) return Dist(a**S(2)*(m + S(-2))/(m + n + S(-1)), Int((a/cos(e + f*x))**(m + S(-2))*(b*tan(e + f*x))**n, x), x) + Simp(a**S(2)*(a/cos(e + f*x))**(m + S(-2))*(b*tan(e + f*x))**(n + S(1))/(b*f*(m + n + S(-1))), x) rule3439 = ReplacementRule(pattern3439, replacement3439) pattern3440 = Pattern(Integral((WC('a', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons4, cons31, cons1521, cons1519, cons1170) def replacement3440(m, f, b, a, n, x, e): rubi.append(3440) return Dist(a**S(2)*(m + S(-2))/(m + n + S(-1)), Int((a/sin(e + f*x))**(m + S(-2))*(b/tan(e + f*x))**n, x), x) - Simp(a**S(2)*(a/sin(e + f*x))**(m + S(-2))*(b/tan(e + f*x))**(n + S(1))/(b*f*(m + n + S(-1))), x) rule3440 = ReplacementRule(pattern3440, replacement3440) pattern3441 = Pattern(Integral(S(1)/(sqrt(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons3, cons48, cons125, cons1522) def replacement3441(x, f, b, e): rubi.append(3441) return Dist(sqrt(sin(e + f*x))/(sqrt(b*tan(e + f*x))*sqrt(cos(e + f*x))), Int(S(1)/(sqrt(sin(e + f*x))*sqrt(cos(e + f*x))), x), x) rule3441 = ReplacementRule(pattern3441, replacement3441) pattern3442 = Pattern(Integral(S(1)/(sqrt(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons3, cons48, cons125, cons1522) def replacement3442(x, f, b, e): rubi.append(3442) return Dist(sqrt(cos(e + f*x))/(sqrt(b/tan(e + f*x))*sqrt(sin(e + f*x))), Int(S(1)/(sqrt(sin(e + f*x))*sqrt(cos(e + f*x))), x), x) rule3442 = ReplacementRule(pattern3442, replacement3442) pattern3443 = Pattern(Integral(sqrt(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*cos(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons3, cons48, cons125, cons1522) def replacement3443(x, f, b, e): rubi.append(3443) return Dist(sqrt(b*tan(e + f*x))*sqrt(cos(e + f*x))/sqrt(sin(e + f*x)), Int(sqrt(sin(e + f*x))*sqrt(cos(e + f*x)), x), x) rule3443 = ReplacementRule(pattern3443, replacement3443) pattern3444 = Pattern(Integral(sqrt(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*sin(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons3, cons48, cons125, cons1522) def replacement3444(x, f, b, e): rubi.append(3444) return Dist(sqrt(b/tan(e + f*x))*sqrt(sin(e + f*x))/sqrt(cos(e + f*x)), Int(sqrt(sin(e + f*x))*sqrt(cos(e + f*x)), x), x) rule3444 = ReplacementRule(pattern3444, replacement3444) pattern3445 = Pattern(Integral((WC('a', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons21, cons4, cons80, cons79) def replacement3445(m, f, b, a, n, x, e): rubi.append(3445) return Dist(a**(m + n)*(a/cos(e + f*x))**(-n)*(b*sin(e + f*x))**(-n)*(b*tan(e + f*x))**n, Int((b*sin(e + f*x))**n*cos(e + f*x)**(-m - n), x), x) rule3445 = ReplacementRule(pattern3445, replacement3445) pattern3446 = Pattern(Integral((WC('a', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons21, cons4, cons80, cons79) def replacement3446(m, f, b, a, n, x, e): rubi.append(3446) return Dist(a**(m + n)*(a/sin(e + f*x))**(-n)*(b*cos(e + f*x))**(-n)*(b/tan(e + f*x))**n, Int((b*cos(e + f*x))**n*sin(e + f*x)**(-m - n), x), x) rule3446 = ReplacementRule(pattern3446, replacement3446) pattern3447 = Pattern(Integral((WC('a', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons21, cons4, cons1523, cons1524) def replacement3447(m, f, b, a, n, x, e): rubi.append(3447) return Simp((a/cos(e + f*x))**m*(b*tan(e + f*x))**(n + S(1))*(cos(e + f*x)**S(2))**(m/S(2) + n/S(2) + S(1)/2)*Hypergeometric2F1(n/S(2) + S(1)/2, m/S(2) + n/S(2) + S(1)/2, n/S(2) + S(3)/2, sin(e + f*x)**S(2))/(b*f*(n + S(1))), x) rule3447 = ReplacementRule(pattern3447, replacement3447) pattern3448 = Pattern(Integral((WC('a', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons21, cons4, cons1523, cons1524) def replacement3448(m, f, b, a, n, x, e): rubi.append(3448) return -Simp((a/sin(e + f*x))**m*(b/tan(e + f*x))**(n + S(1))*(sin(e + f*x)**S(2))**(m/S(2) + n/S(2) + S(1)/2)*Hypergeometric2F1(n/S(2) + S(1)/2, m/S(2) + n/S(2) + S(1)/2, n/S(2) + S(3)/2, cos(e + f*x)**S(2))/(b*f*(n + S(1))), x) rule3448 = ReplacementRule(pattern3448, replacement3448) pattern3449 = Pattern(Integral((WC('a', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons21, cons4, cons18, cons23) def replacement3449(m, f, b, a, n, x, e): rubi.append(3449) return Dist((sin(e + f*x)/a)**FracPart(m)*(a/sin(e + f*x))**FracPart(m), Int((sin(e + f*x)/a)**(-m)*(b*tan(e + f*x))**n, x), x) rule3449 = ReplacementRule(pattern3449, replacement3449) pattern3450 = Pattern(Integral((WC('a', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons48, cons125, cons21, cons4, cons18, cons23) def replacement3450(m, f, b, a, n, x, e): rubi.append(3450) return Dist((cos(e + f*x)/a)**FracPart(m)*(a/cos(e + f*x))**FracPart(m), Int((cos(e + f*x)/a)**(-m)*(b/tan(e + f*x))**n, x), x) rule3450 = ReplacementRule(pattern3450, replacement3450) pattern3451 = Pattern(Integral(((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*WC('a', S(1)))**WC('m', S(1))*(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons5, cons87, cons165, cons1525, cons1526) def replacement3451(p, m, f, b, d, a, n, x, e): rubi.append(3451) return -Dist(b**S(2)*(n + S(-1))/(m*p + n + S(-1)), Int((a*(d/cos(e + f*x))**p)**m*(b*tan(e + f*x))**(n + S(-2)), x), x) + Simp(b*(a*(d/cos(e + f*x))**p)**m*(b*tan(e + f*x))**(n + S(-1))/(f*(m*p + n + S(-1))), x) rule3451 = ReplacementRule(pattern3451, replacement3451) pattern3452 = Pattern(Integral(((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*WC('a', S(1)))**WC('m', S(1))*(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons5, cons87, cons165, cons1525, cons1526) def replacement3452(p, m, f, b, d, a, n, x, e): rubi.append(3452) return -Dist(b**S(2)*(n + S(-1))/(m*p + n + S(-1)), Int((a*(d/sin(e + f*x))**p)**m*(b/tan(e + f*x))**(n + S(-2)), x), x) - Simp(b*(a*(d/sin(e + f*x))**p)**m*(b/tan(e + f*x))**(n + S(-1))/(f*(m*p + n + S(-1))), x) rule3452 = ReplacementRule(pattern3452, replacement3452) pattern3453 = Pattern(Integral(((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**p_*WC('a', S(1)))**WC('m', S(1))*(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons5, cons87, cons89, cons1527, cons1526) def replacement3453(p, m, f, b, d, a, n, x, e): rubi.append(3453) return -Dist((m*p + n + S(1))/(b**S(2)*(n + S(1))), Int((a*(d/cos(e + f*x))**p)**m*(b*tan(e + f*x))**(n + S(2)), x), x) + Simp((a*(d/cos(e + f*x))**p)**m*(b*tan(e + f*x))**(n + S(1))/(b*f*(n + S(1))), x) rule3453 = ReplacementRule(pattern3453, replacement3453) pattern3454 = Pattern(Integral(((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**p_*WC('a', S(1)))**WC('m', S(1))*(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons5, cons87, cons89, cons1527, cons1526) def replacement3454(p, m, f, b, d, a, n, x, e): rubi.append(3454) return -Dist((m*p + n + S(1))/(b**S(2)*(n + S(1))), Int((a*(d/sin(e + f*x))**p)**m*(b/tan(e + f*x))**(n + S(2)), x), x) + Simp((a*(d/sin(e + f*x))**p)**m*(b/tan(e + f*x))**(n + S(1))/(b*f*(n + S(1))), x) rule3454 = ReplacementRule(pattern3454, replacement3454) pattern3455 = Pattern(Integral((WC('b', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons3, cons7, cons27, cons87, cons165) def replacement3455(b, d, c, n, x): rubi.append(3455) return -Dist(b**S(2), Int((b*tan(c + d*x))**(n + S(-2)), x), x) + Simp(b*(b*tan(c + d*x))**(n + S(-1))/(d*(n + S(-1))), x) rule3455 = ReplacementRule(pattern3455, replacement3455) pattern3456 = Pattern(Integral((WC('b', S(1))/tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons3, cons7, cons27, cons87, cons165) def replacement3456(b, d, c, n, x): rubi.append(3456) return -Dist(b**S(2), Int((b/tan(c + d*x))**(n + S(-2)), x), x) - Simp(b*(b/tan(c + d*x))**(n + S(-1))/(d*(n + S(-1))), x) rule3456 = ReplacementRule(pattern3456, replacement3456) pattern3457 = Pattern(Integral((WC('b', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons3, cons7, cons27, cons87, cons89) def replacement3457(b, d, c, n, x): rubi.append(3457) return -Dist(b**(S(-2)), Int((b*tan(c + d*x))**(n + S(2)), x), x) + Simp((b*tan(c + d*x))**(n + S(1))/(b*d*(n + S(1))), x) rule3457 = ReplacementRule(pattern3457, replacement3457) pattern3458 = Pattern(Integral((WC('b', S(1))/tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons3, cons7, cons27, cons87, cons89) def replacement3458(b, d, c, n, x): rubi.append(3458) return -Dist(b**(S(-2)), Int((b/tan(c + d*x))**(n + S(2)), x), x) - Simp((b/tan(c + d*x))**(n + S(1))/(b*d*(n + S(1))), x) rule3458 = ReplacementRule(pattern3458, replacement3458) pattern3459 = Pattern(Integral(tan(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons7, cons27, cons1261) def replacement3459(d, c, x): rubi.append(3459) return -Simp(log(RemoveContent(cos(c + d*x), x))/d, x) rule3459 = ReplacementRule(pattern3459, replacement3459) pattern3460 = Pattern(Integral(S(1)/tan(x_*WC('d', S(1)) + WC('c', S(0))), x_), cons7, cons27, cons1261) def replacement3460(d, c, x): rubi.append(3460) return Simp(log(RemoveContent(sin(c + d*x), x))/d, x) rule3460 = ReplacementRule(pattern3460, replacement3460) pattern3461 = Pattern(Integral((WC('b', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons3, cons7, cons27, cons4, cons23) def replacement3461(b, d, c, n, x): rubi.append(3461) return Dist(b/d, Subst(Int(x**n/(b**S(2) + x**S(2)), x), x, b*tan(c + d*x)), x) rule3461 = ReplacementRule(pattern3461, replacement3461) pattern3462 = Pattern(Integral((WC('b', S(1))/tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons3, cons7, cons27, cons4, cons23) def replacement3462(b, d, c, n, x): rubi.append(3462) return -Dist(b/d, Subst(Int(x**n/(b**S(2) + x**S(2)), x), x, b/tan(c + d*x)), x) rule3462 = ReplacementRule(pattern3462, replacement3462) pattern3463 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0))))**S(2), x_), cons2, cons3, cons7, cons27, cons1264) def replacement3463(b, d, c, a, x): rubi.append(3463) return Dist(S(2)*a*b, Int(tan(c + d*x), x), x) + Simp(x*(a**S(2) - b**S(2)), x) + Simp(b**S(2)*tan(c + d*x)/d, x) rule3463 = ReplacementRule(pattern3463, replacement3463) pattern3464 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('d', S(1)) + WC('c', S(0))))**S(2), x_), cons2, cons3, cons7, cons27, cons1264) def replacement3464(b, d, c, a, x): rubi.append(3464) return Dist(S(2)*a*b, Int(S(1)/tan(c + d*x), x), x) + Simp(x*(a**S(2) - b**S(2)), x) - Simp(b**S(2)/(d*tan(c + d*x)), x) rule3464 = ReplacementRule(pattern3464, replacement3464) pattern3465 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons1439, cons87, cons165) def replacement3465(b, d, c, a, n, x): rubi.append(3465) return Dist(S(2)*a, Int((a + b*tan(c + d*x))**(n + S(-1)), x), x) + Simp(b*(a + b*tan(c + d*x))**(n + S(-1))/(d*(n + S(-1))), x) rule3465 = ReplacementRule(pattern3465, replacement3465) pattern3466 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons1439, cons87, cons165) def replacement3466(b, d, c, a, n, x): rubi.append(3466) return Dist(S(2)*a, Int((a + b/tan(c + d*x))**(n + S(-1)), x), x) - Simp(b*(a + b/tan(c + d*x))**(n + S(-1))/(d*(n + S(-1))), x) rule3466 = ReplacementRule(pattern3466, replacement3466) pattern3467 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons1439, cons87, cons463) def replacement3467(b, d, c, a, n, x): rubi.append(3467) return Dist(S(1)/(S(2)*a), Int((a + b*tan(c + d*x))**(n + S(1)), x), x) + Simp(a*(a + b*tan(c + d*x))**n/(S(2)*b*d*n), x) rule3467 = ReplacementRule(pattern3467, replacement3467) pattern3468 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons1439, cons87, cons463) def replacement3468(b, d, c, a, n, x): rubi.append(3468) return Dist(S(1)/(S(2)*a), Int((a + b/tan(c + d*x))**(n + S(1)), x), x) - Simp(a*(a + b/tan(c + d*x))**n/(S(2)*b*d*n), x) rule3468 = ReplacementRule(pattern3468, replacement3468) pattern3469 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1439) def replacement3469(b, d, c, a, x): rubi.append(3469) return Dist(-S(2)*b/d, Subst(Int(S(1)/(S(2)*a - x**S(2)), x), x, sqrt(a + b*tan(c + d*x))), x) rule3469 = ReplacementRule(pattern3469, replacement3469) pattern3470 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/tan(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1439) def replacement3470(b, d, c, a, x): rubi.append(3470) return Dist(S(2)*b/d, Subst(Int(S(1)/(S(2)*a - x**S(2)), x), x, sqrt(a + b/tan(c + d*x))), x) rule3470 = ReplacementRule(pattern3470, replacement3470) pattern3471 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons4, cons1439) def replacement3471(b, d, c, a, n, x): rubi.append(3471) return -Dist(b/d, Subst(Int((a + x)**(n + S(-1))/(a - x), x), x, b*tan(c + d*x)), x) rule3471 = ReplacementRule(pattern3471, replacement3471) pattern3472 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons4, cons1439) def replacement3472(b, d, c, a, n, x): rubi.append(3472) return Dist(b/d, Subst(Int((a + x)**(n + S(-1))/(a - x), x), x, b/tan(c + d*x)), x) rule3472 = ReplacementRule(pattern3472, replacement3472) pattern3473 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons1440, cons87, cons165) def replacement3473(b, d, c, a, n, x): rubi.append(3473) return Int((a + b*tan(c + d*x))**(n + S(-2))*(a**S(2) + S(2)*a*b*tan(c + d*x) - b**S(2)), x) + Simp(b*(a + b*tan(c + d*x))**(n + S(-1))/(d*(n + S(-1))), x) rule3473 = ReplacementRule(pattern3473, replacement3473) pattern3474 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons1440, cons87, cons165) def replacement3474(b, d, c, a, n, x): rubi.append(3474) return Int((a + b/tan(c + d*x))**(n + S(-2))*(a**S(2) + S(2)*a*b/tan(c + d*x) - b**S(2)), x) - Simp(b*(a + b/tan(c + d*x))**(n + S(-1))/(d*(n + S(-1))), x) rule3474 = ReplacementRule(pattern3474, replacement3474) pattern3475 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons1440, cons87, cons89) def replacement3475(b, d, c, a, n, x): rubi.append(3475) return Dist(S(1)/(a**S(2) + b**S(2)), Int((a - b*tan(c + d*x))*(a + b*tan(c + d*x))**(n + S(1)), x), x) + Simp(b*(a + b*tan(c + d*x))**(n + S(1))/(d*(a**S(2) + b**S(2))*(n + S(1))), x) rule3475 = ReplacementRule(pattern3475, replacement3475) pattern3476 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons1440, cons87, cons89) def replacement3476(b, d, c, a, n, x): rubi.append(3476) return Dist(S(1)/(a**S(2) + b**S(2)), Int((a - b/tan(c + d*x))*(a + b/tan(c + d*x))**(n + S(1)), x), x) - Simp(b*(a + b/tan(c + d*x))**(n + S(1))/(d*(a**S(2) + b**S(2))*(n + S(1))), x) rule3476 = ReplacementRule(pattern3476, replacement3476) pattern3477 = Pattern(Integral(S(1)/(a_ + WC('b', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1440) def replacement3477(b, d, c, a, x): rubi.append(3477) return Dist(b/(a**S(2) + b**S(2)), Int((-a*tan(c + d*x) + b)/(a + b*tan(c + d*x)), x), x) + Simp(a*x/(a**S(2) + b**S(2)), x) rule3477 = ReplacementRule(pattern3477, replacement3477) pattern3478 = Pattern(Integral(S(1)/(a_ + WC('b', S(1))/tan(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons1440) def replacement3478(b, d, c, a, x): rubi.append(3478) return Dist(b/(a**S(2) + b**S(2)), Int((-a/tan(c + d*x) + b)/(a + b/tan(c + d*x)), x), x) + Simp(a*x/(a**S(2) + b**S(2)), x) rule3478 = ReplacementRule(pattern3478, replacement3478) pattern3479 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons4, cons1440) def replacement3479(b, d, c, a, n, x): rubi.append(3479) return Dist(b/d, Subst(Int((a + x)**n/(b**S(2) + x**S(2)), x), x, b*tan(c + d*x)), x) rule3479 = ReplacementRule(pattern3479, replacement3479) pattern3480 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons4, cons1440) def replacement3480(b, d, c, a, n, x): rubi.append(3480) return -Dist(b/d, Subst(Int((a + x)**n/(b**S(2) + x**S(2)), x), x, b/tan(c + d*x)), x) rule3480 = ReplacementRule(pattern3480, replacement3480) pattern3481 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons21, cons1528) def replacement3481(m, f, b, d, a, x, e): rubi.append(3481) return Dist(a, Int((d/cos(e + f*x))**m, x), x) + Simp(b*(d/cos(e + f*x))**m/(f*m), x) rule3481 = ReplacementRule(pattern3481, replacement3481) pattern3482 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons21, cons1528) def replacement3482(m, f, b, d, a, x, e): rubi.append(3482) return Dist(a, Int((d/sin(e + f*x))**m, x), x) - Simp(b*(d/sin(e + f*x))**m/(f*m), x) rule3482 = ReplacementRule(pattern3482, replacement3482) pattern3483 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(S(1)/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons4, cons1439, cons1515) def replacement3483(m, f, b, a, n, x, e): rubi.append(3483) return Dist(a**(-m + S(2))/(b*f), Subst(Int((a - x)**(m/S(2) + S(-1))*(a + x)**(m/S(2) + n + S(-1)), x), x, b*tan(e + f*x)), x) rule3483 = ReplacementRule(pattern3483, replacement3483) pattern3484 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(S(1)/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons4, cons1439, cons1515) def replacement3484(m, f, b, a, n, x, e): rubi.append(3484) return -Dist(a**(-m + S(2))/(b*f), Subst(Int((a - x)**(m/S(2) + S(-1))*(a + x)**(m/S(2) + n + S(-1)), x), x, b/tan(e + f*x)), x) rule3484 = ReplacementRule(pattern3484, replacement3484) pattern3485 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1439, cons1255) def replacement3485(m, f, b, d, a, n, x, e): rubi.append(3485) return Simp(b*(d/cos(e + f*x))**m*(a + b*tan(e + f*x))**n/(a*f*m), x) rule3485 = ReplacementRule(pattern3485, replacement3485) pattern3486 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1439, cons1255) def replacement3486(m, f, b, d, a, n, x, e): rubi.append(3486) return -Simp(b*(d/sin(e + f*x))**m*(a + b/tan(e + f*x))**n/(a*f*m), x) rule3486 = ReplacementRule(pattern3486, replacement3486) pattern3487 = Pattern(Integral(S(1)/(sqrt(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons1439) def replacement3487(f, b, a, x, e): rubi.append(3487) return Dist(-S(2)*a/(b*f), Subst(Int(S(1)/(-a*x**S(2) + S(2)), x), x, S(1)/(sqrt(a + b*tan(e + f*x))*cos(e + f*x))), x) rule3487 = ReplacementRule(pattern3487, replacement3487) pattern3488 = Pattern(Integral(S(1)/(sqrt(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons1439) def replacement3488(f, b, a, x, e): rubi.append(3488) return Dist(S(2)*a/(b*f), Subst(Int(S(1)/(-a*x**S(2) + S(2)), x), x, S(1)/(sqrt(a + b/tan(e + f*x))*sin(e + f*x))), x) rule3488 = ReplacementRule(pattern3488, replacement3488) pattern3489 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons1439, cons1529, cons93, cons88) def replacement3489(m, f, b, d, a, n, x, e): rubi.append(3489) return Dist(a/(S(2)*d**S(2)), Int((d/cos(e + f*x))**(m + S(2))*(a + b*tan(e + f*x))**(n + S(-1)), x), x) + Simp(b*(d/cos(e + f*x))**m*(a + b*tan(e + f*x))**n/(a*f*m), x) rule3489 = ReplacementRule(pattern3489, replacement3489) pattern3490 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons1439, cons1529, cons93, cons88) def replacement3490(m, f, b, d, a, n, x, e): rubi.append(3490) return Dist(a/(S(2)*d**S(2)), Int((d/sin(e + f*x))**(m + S(2))*(a + b/tan(e + f*x))**(n + S(-1)), x), x) - Simp(b*(d/sin(e + f*x))**m*(a + b/tan(e + f*x))**n/(a*f*m), x) rule3490 = ReplacementRule(pattern3490, replacement3490) pattern3491 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons1439, cons1529, cons93, cons89) def replacement3491(m, f, b, d, a, n, x, e): rubi.append(3491) return Dist(S(2)*d**S(2)/a, Int((d/cos(e + f*x))**(m + S(-2))*(a + b*tan(e + f*x))**(n + S(1)), x), x) + Simp(S(2)*d**S(2)*(d/cos(e + f*x))**(m + S(-2))*(a + b*tan(e + f*x))**(n + S(1))/(b*f*(m + S(-2))), x) rule3491 = ReplacementRule(pattern3491, replacement3491) pattern3492 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons1439, cons1529, cons93, cons89) def replacement3492(m, f, b, d, a, n, x, e): rubi.append(3492) return Dist(S(2)*d**S(2)/a, Int((d/sin(e + f*x))**(m + S(-2))*(a + b/tan(e + f*x))**(n + S(1)), x), x) + Simp(-S(2)*d**S(2)*(d/sin(e + f*x))**(m + S(-2))*(a + b/tan(e + f*x))**(n + S(1))/(b*f*(m + S(-2))), x) rule3492 = ReplacementRule(pattern3492, replacement3492) pattern3493 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1439, cons1529) def replacement3493(m, f, b, d, a, n, x, e): rubi.append(3493) return Dist((a/d)**(S(2)*IntPart(n))*(d/cos(e + f*x))**(-S(2)*FracPart(n))*(a - b*tan(e + f*x))**FracPart(n)*(a + b*tan(e + f*x))**FracPart(n), Int((a - b*tan(e + f*x))**(-n), x), x) rule3493 = ReplacementRule(pattern3493, replacement3493) pattern3494 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1439, cons1529) def replacement3494(m, f, b, d, a, n, x, e): rubi.append(3494) return Dist((a/d)**(S(2)*IntPart(n))*(d/sin(e + f*x))**(-S(2)*FracPart(n))*(a - b/tan(e + f*x))**FracPart(n)*(a + b/tan(e + f*x))**FracPart(n), Int((a - b/tan(e + f*x))**(-n), x), x) rule3494 = ReplacementRule(pattern3494, replacement3494) pattern3495 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1439, cons1530) def replacement3495(m, f, b, d, a, n, x, e): rubi.append(3495) return Simp(S(2)*b*(d/cos(e + f*x))**m*(a + b*tan(e + f*x))**(n + S(-1))/(f*m), x) rule3495 = ReplacementRule(pattern3495, replacement3495) pattern3496 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1439, cons1530) def replacement3496(m, f, b, d, a, n, x, e): rubi.append(3496) return Simp(-S(2)*b*(d/sin(e + f*x))**m*(a + b/tan(e + f*x))**(n + S(-1))/(f*m), x) rule3496 = ReplacementRule(pattern3496, replacement3496) pattern3497 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1439, cons1531, cons23) def replacement3497(m, f, b, d, a, n, x, e): rubi.append(3497) return Dist(a*(m + S(2)*n + S(-2))/(m + n + S(-1)), Int((d/cos(e + f*x))**m*(a + b*tan(e + f*x))**(n + S(-1)), x), x) + Simp(b*(d/cos(e + f*x))**m*(a + b*tan(e + f*x))**(n + S(-1))/(f*(m + n + S(-1))), x) rule3497 = ReplacementRule(pattern3497, replacement3497) pattern3498 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1439, cons1531, cons23) def replacement3498(m, f, b, d, a, n, x, e): rubi.append(3498) return Dist(a*(m + S(2)*n + S(-2))/(m + n + S(-1)), Int((d/sin(e + f*x))**m*(a + b/tan(e + f*x))**(n + S(-1)), x), x) - Simp(b*(d/sin(e + f*x))**m*(a + b/tan(e + f*x))**(n + S(-1))/(f*(m + n + S(-1))), x) rule3498 = ReplacementRule(pattern3498, replacement3498) pattern3499 = Pattern(Integral(sqrt(WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1439) def replacement3499(f, b, d, a, x, e): rubi.append(3499) return Dist(-S(4)*b*d**S(2)/f, Subst(Int(x**S(2)/(a**S(2) + d**S(2)*x**S(4)), x), x, sqrt(a + b*tan(e + f*x))/sqrt(d/cos(e + f*x))), x) rule3499 = ReplacementRule(pattern3499, replacement3499) pattern3500 = Pattern(Integral(sqrt(WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1439) def replacement3500(f, b, d, a, x, e): rubi.append(3500) return Dist(S(4)*b*d**S(2)/f, Subst(Int(x**S(2)/(a**S(2) + d**S(2)*x**S(4)), x), x, sqrt(a + b/tan(e + f*x))/sqrt(d/sin(e + f*x))), x) rule3500 = ReplacementRule(pattern3500, replacement3500) pattern3501 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons1439, cons93, cons165, cons1532, cons515) def replacement3501(m, f, b, d, a, n, x, e): rubi.append(3501) return -Dist(b**S(2)*(m + S(2)*n + S(-2))/(d**S(2)*m), Int((d/cos(e + f*x))**(m + S(2))*(a + b*tan(e + f*x))**(n + S(-2)), x), x) + Simp(S(2)*b*(d/cos(e + f*x))**m*(a + b*tan(e + f*x))**(n + S(-1))/(f*m), x) rule3501 = ReplacementRule(pattern3501, replacement3501) pattern3502 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons1439, cons93, cons165, cons1533, cons515) def replacement3502(m, f, b, d, a, n, x, e): rubi.append(3502) return -Dist(b**S(2)*(m + S(2)*n + S(-2))/(d**S(2)*m), Int((d/sin(e + f*x))**(m + S(2))*(a + b/tan(e + f*x))**(n + S(-2)), x), x) + Simp(-S(2)*b*(d/sin(e + f*x))**m*(a + b/tan(e + f*x))**(n + S(-1))/(f*m), x) rule3502 = ReplacementRule(pattern3502, replacement3502) pattern3503 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons1439, cons93, cons88, cons94, cons1170) def replacement3503(m, f, b, d, a, n, x, e): rubi.append(3503) return Dist(a*(m + n)/(d**S(2)*m), Int((d/cos(e + f*x))**(m + S(2))*(a + b*tan(e + f*x))**(n + S(-1)), x), x) + Simp(b*(d/cos(e + f*x))**m*(a + b*tan(e + f*x))**n/(a*f*m), x) rule3503 = ReplacementRule(pattern3503, replacement3503) pattern3504 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons1439, cons93, cons88, cons94, cons1170) def replacement3504(m, f, b, d, a, n, x, e): rubi.append(3504) return Dist(a*(m + n)/(d**S(2)*m), Int((d/sin(e + f*x))**(m + S(2))*(a + b/tan(e + f*x))**(n + S(-1)), x), x) - Simp(b*(d/sin(e + f*x))**m*(a + b/tan(e + f*x))**n/(a*f*m), x) rule3504 = ReplacementRule(pattern3504, replacement3504) pattern3505 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons1439, cons87, cons88, cons1519, cons1170) def replacement3505(m, f, b, d, a, n, x, e): rubi.append(3505) return Dist(a*(m + S(2)*n + S(-2))/(m + n + S(-1)), Int((d/cos(e + f*x))**m*(a + b*tan(e + f*x))**(n + S(-1)), x), x) + Simp(b*(d/cos(e + f*x))**m*(a + b*tan(e + f*x))**(n + S(-1))/(f*(m + n + S(-1))), x) rule3505 = ReplacementRule(pattern3505, replacement3505) pattern3506 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons1439, cons87, cons88, cons1519, cons1170) def replacement3506(m, f, b, d, a, n, x, e): rubi.append(3506) return Dist(a*(m + S(2)*n + S(-2))/(m + n + S(-1)), Int((d/sin(e + f*x))**m*(a + b/tan(e + f*x))**(n + S(-1)), x), x) - Simp(b*(d/sin(e + f*x))**m*(a + b/tan(e + f*x))**(n + S(-1))/(f*(m + n + S(-1))), x) rule3506 = ReplacementRule(pattern3506, replacement3506) pattern3507 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)/sqrt(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1439) def replacement3507(f, b, d, a, x, e): rubi.append(3507) return Dist(d/(sqrt(a - b*tan(e + f*x))*sqrt(a + b*tan(e + f*x))*cos(e + f*x)), Int(sqrt(d/cos(e + f*x))*sqrt(a - b*tan(e + f*x)), x), x) rule3507 = ReplacementRule(pattern3507, replacement3507) pattern3508 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)/sqrt(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1439) def replacement3508(f, b, d, a, x, e): rubi.append(3508) return Dist(d/(sqrt(a - b/tan(e + f*x))*sqrt(a + b/tan(e + f*x))*sin(e + f*x)), Int(sqrt(d/sin(e + f*x))*sqrt(a - b/tan(e + f*x)), x), x) rule3508 = ReplacementRule(pattern3508, replacement3508) pattern3509 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons1439, cons87, cons89, cons1534, cons515) def replacement3509(m, f, b, d, a, n, x, e): rubi.append(3509) return -Dist(d**S(2)*(m + S(-2))/(b**S(2)*(m + S(2)*n)), Int((d/cos(e + f*x))**(m + S(-2))*(a + b*tan(e + f*x))**(n + S(2)), x), x) + Simp(S(2)*d**S(2)*(d/cos(e + f*x))**(m + S(-2))*(a + b*tan(e + f*x))**(n + S(1))/(b*f*(m + S(2)*n)), x) rule3509 = ReplacementRule(pattern3509, replacement3509) pattern3510 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons1439, cons87, cons89, cons1534, cons515) def replacement3510(m, f, b, d, a, n, x, e): rubi.append(3510) return -Dist(d**S(2)*(m + S(-2))/(b**S(2)*(m + S(2)*n)), Int((d/sin(e + f*x))**(m + S(-2))*(a + b/tan(e + f*x))**(n + S(2)), x), x) + Simp(-S(2)*d**S(2)*(d/sin(e + f*x))**(m + S(-2))*(a + b/tan(e + f*x))**(n + S(1))/(b*f*(m + S(2)*n)), x) rule3510 = ReplacementRule(pattern3510, replacement3510) pattern3511 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons1439, cons93, cons463, cons166, cons1535, cons1519, cons1170) def replacement3511(m, f, b, d, a, n, x, e): rubi.append(3511) return Dist(d**S(2)*(m + S(-2))/(a*(m + n + S(-1))), Int((d/cos(e + f*x))**(m + S(-2))*(a + b*tan(e + f*x))**(n + S(1)), x), x) + Simp(d**S(2)*(d/cos(e + f*x))**(m + S(-2))*(a + b*tan(e + f*x))**(n + S(1))/(b*f*(m + n + S(-1))), x) rule3511 = ReplacementRule(pattern3511, replacement3511) pattern3512 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons1439, cons93, cons463, cons166, cons1535, cons1519, cons1170) def replacement3512(m, f, b, d, a, n, x, e): rubi.append(3512) return Dist(d**S(2)*(m + S(-2))/(a*(m + n + S(-1))), Int((d/sin(e + f*x))**(m + S(-2))*(a + b/tan(e + f*x))**(n + S(1)), x), x) - Simp(d**S(2)*(d/sin(e + f*x))**(m + S(-2))*(a + b/tan(e + f*x))**(n + S(1))/(b*f*(m + n + S(-1))), x) rule3512 = ReplacementRule(pattern3512, replacement3512) pattern3513 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons1439, cons87, cons463, cons1536, cons1170) def replacement3513(m, f, b, d, a, n, x, e): rubi.append(3513) return Dist((m + n)/(a*(m + S(2)*n)), Int((d/cos(e + f*x))**m*(a + b*tan(e + f*x))**(n + S(1)), x), x) + Simp(a*(d/cos(e + f*x))**m*(a + b*tan(e + f*x))**n/(b*f*(m + S(2)*n)), x) rule3513 = ReplacementRule(pattern3513, replacement3513) pattern3514 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons1439, cons87, cons463, cons1536, cons1170) def replacement3514(m, f, b, d, a, n, x, e): rubi.append(3514) return Dist((m + n)/(a*(m + S(2)*n)), Int((d/sin(e + f*x))**m*(a + b/tan(e + f*x))**(n + S(1)), x), x) - Simp(a*(d/sin(e + f*x))**m*(a + b/tan(e + f*x))**n/(b*f*(m + S(2)*n)), x) rule3514 = ReplacementRule(pattern3514, replacement3514) pattern3515 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1439, cons1537, cons87) def replacement3515(m, f, b, d, a, n, x, e): rubi.append(3515) return Dist(a*(m + S(2)*n + S(-2))/(m + n + S(-1)), Int((d/cos(e + f*x))**m*(a + b*tan(e + f*x))**(n + S(-1)), x), x) + Simp(b*(d/cos(e + f*x))**m*(a + b*tan(e + f*x))**(n + S(-1))/(f*(m + n + S(-1))), x) rule3515 = ReplacementRule(pattern3515, replacement3515) pattern3516 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1439, cons1537, cons87) def replacement3516(m, f, b, d, a, n, x, e): rubi.append(3516) return Dist(a*(m + S(2)*n + S(-2))/(m + n + S(-1)), Int((d/sin(e + f*x))**m*(a + b/tan(e + f*x))**(n + S(-1)), x), x) - Simp(b*(d/sin(e + f*x))**m*(a + b/tan(e + f*x))**(n + S(-1))/(f*(m + n + S(-1))), x) rule3516 = ReplacementRule(pattern3516, replacement3516) pattern3517 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1439, cons1538, cons1536) def replacement3517(m, f, b, d, a, n, x, e): rubi.append(3517) return Dist((m + n)/(a*(m + S(2)*n)), Int((d/cos(e + f*x))**m*(a + b*tan(e + f*x))**(n + S(1)), x), x) + Simp(a*(d/cos(e + f*x))**m*(a + b*tan(e + f*x))**n/(b*f*(m + S(2)*n)), x) rule3517 = ReplacementRule(pattern3517, replacement3517) pattern3518 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1439, cons1538, cons1536) def replacement3518(m, f, b, d, a, n, x, e): rubi.append(3518) return Dist((m + n)/(a*(m + S(2)*n)), Int((d/sin(e + f*x))**m*(a + b/tan(e + f*x))**(n + S(1)), x), x) - Simp(a*(d/sin(e + f*x))**m*(a + b/tan(e + f*x))**n/(b*f*(m + S(2)*n)), x) rule3518 = ReplacementRule(pattern3518, replacement3518) pattern3519 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1439) def replacement3519(m, f, b, d, a, n, x, e): rubi.append(3519) return Dist((d/cos(e + f*x))**m*(a - b*tan(e + f*x))**(-m/S(2))*(a + b*tan(e + f*x))**(-m/S(2)), Int((a - b*tan(e + f*x))**(m/S(2))*(a + b*tan(e + f*x))**(m/S(2) + n), x), x) rule3519 = ReplacementRule(pattern3519, replacement3519) pattern3520 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1439) def replacement3520(m, f, b, d, a, n, x, e): rubi.append(3520) return Dist((d/sin(e + f*x))**m*(a - b/tan(e + f*x))**(-m/S(2))*(a + b/tan(e + f*x))**(-m/S(2)), Int((a - b/tan(e + f*x))**(m/S(2))*(a + b/tan(e + f*x))**(m/S(2) + n), x), x) rule3520 = ReplacementRule(pattern3520, replacement3520) pattern3521 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(S(1)/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons4, cons1440, cons1515) def replacement3521(m, f, b, a, n, x, e): rubi.append(3521) return Dist(S(1)/(b*f), Subst(Int((S(1) + x**S(2)/b**S(2))**(m/S(2) + S(-1))*(a + x)**n, x), x, b*tan(e + f*x)), x) rule3521 = ReplacementRule(pattern3521, replacement3521) pattern3522 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(S(1)/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons4, cons1440, cons1515) def replacement3522(m, f, b, a, n, x, e): rubi.append(3522) return -Dist(S(1)/(b*f), Subst(Int((S(1) + x**S(2)/b**S(2))**(m/S(2) + S(-1))*(a + x)**n, x), x, b/tan(e + f*x)), x) rule3522 = ReplacementRule(pattern3522, replacement3522) pattern3523 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**S(2)*cos(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons48, cons125, cons1440) def replacement3523(f, b, a, x, e): rubi.append(3523) return Simp(b**S(2)*atanh(sin(e + f*x))/f, x) + Simp((a**S(2) - b**S(2))*sin(e + f*x)/f, x) - Simp(S(2)*a*b*cos(e + f*x)/f, x) rule3523 = ReplacementRule(pattern3523, replacement3523) pattern3524 = Pattern(Integral((a_ + WC('b', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**S(2)*tan(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons2, cons3, cons48, cons125, cons1440) def replacement3524(f, b, a, x, e): rubi.append(3524) return -Simp(b**S(2)*atanh(cos(e + f*x))/f, x) - Simp((a**S(2) - b**S(2))*cos(e + f*x)/f, x) + Simp(S(2)*a*b*sin(e + f*x)/f, x) rule3524 = ReplacementRule(pattern3524, replacement3524) pattern3525 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**S(2), x_), cons2, cons3, cons27, cons48, cons125, cons21, cons1440, cons66) def replacement3525(m, f, b, d, a, x, e): rubi.append(3525) return Dist(S(1)/(m + S(1)), Int((d/cos(e + f*x))**m*(a**S(2)*(m + S(1)) + a*b*(m + S(2))*tan(e + f*x) - b**S(2)), x), x) + Simp(b*(d/cos(e + f*x))**m*(a + b*tan(e + f*x))/(f*(m + S(1))), x) rule3525 = ReplacementRule(pattern3525, replacement3525) pattern3526 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**S(2), x_), cons2, cons3, cons27, cons48, cons125, cons21, cons1440, cons66) def replacement3526(m, f, b, d, a, x, e): rubi.append(3526) return Dist(S(1)/(m + S(1)), Int((d/sin(e + f*x))**m*(a**S(2)*(m + S(1)) + a*b*(m + S(2))/tan(e + f*x) - b**S(2)), x), x) - Simp(b*(d/sin(e + f*x))**m*(a + b/tan(e + f*x))/(f*(m + S(1))), x) rule3526 = ReplacementRule(pattern3526, replacement3526) pattern3527 = Pattern(Integral(S(1)/((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons1440) def replacement3527(f, b, a, x, e): rubi.append(3527) return -Dist(S(1)/f, Subst(Int(S(1)/(a**S(2) + b**S(2) - x**S(2)), x), x, (-a*tan(e + f*x) + b)*cos(e + f*x)), x) rule3527 = ReplacementRule(pattern3527, replacement3527) pattern3528 = Pattern(Integral(S(1)/((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons1440) def replacement3528(f, b, a, x, e): rubi.append(3528) return Dist(S(1)/f, Subst(Int(S(1)/(a**S(2) + b**S(2) - x**S(2)), x), x, (-a/tan(e + f*x) + b)*sin(e + f*x)), x) rule3528 = ReplacementRule(pattern3528, replacement3528) pattern3529 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_/(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1440, cons1539) def replacement3529(m, f, b, d, a, x, e): rubi.append(3529) return -Dist(d**S(2)/b**S(2), Int((d/cos(e + f*x))**(m + S(-2))*(a - b*tan(e + f*x)), x), x) + Dist(d**S(2)*(a**S(2) + b**S(2))/b**S(2), Int((d/cos(e + f*x))**(m + S(-2))/(a + b*tan(e + f*x)), x), x) rule3529 = ReplacementRule(pattern3529, replacement3529) pattern3530 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_/(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1440, cons1539) def replacement3530(m, f, b, d, a, x, e): rubi.append(3530) return -Dist(d**S(2)/b**S(2), Int((d/sin(e + f*x))**(m + S(-2))*(a - b/tan(e + f*x)), x), x) + Dist(d**S(2)*(a**S(2) + b**S(2))/b**S(2), Int((d/sin(e + f*x))**(m + S(-2))/(a + b/tan(e + f*x)), x), x) rule3530 = ReplacementRule(pattern3530, replacement3530) pattern3531 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_/(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1440, cons84) def replacement3531(m, f, b, d, a, x, e): rubi.append(3531) return Dist(b**S(2)/(d**S(2)*(a**S(2) + b**S(2))), Int((d/cos(e + f*x))**(m + S(2))/(a + b*tan(e + f*x)), x), x) + Dist(S(1)/(a**S(2) + b**S(2)), Int((d/cos(e + f*x))**m*(a - b*tan(e + f*x)), x), x) rule3531 = ReplacementRule(pattern3531, replacement3531) pattern3532 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_/(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1440, cons84) def replacement3532(m, f, b, d, a, x, e): rubi.append(3532) return Dist(b**S(2)/(d**S(2)*(a**S(2) + b**S(2))), Int((d/sin(e + f*x))**(m + S(2))/(a + b/tan(e + f*x)), x), x) + Dist(S(1)/(a**S(2) + b**S(2)), Int((d/sin(e + f*x))**m*(a - b/tan(e + f*x)), x), x) rule3532 = ReplacementRule(pattern3532, replacement3532) pattern3533 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1440, cons1524) def replacement3533(m, f, b, d, a, n, x, e): rubi.append(3533) return Dist(d**(S(2)*IntPart(m/S(2)))*(d/cos(e + f*x))**(S(2)*FracPart(m/S(2)))*(cos(e + f*x)**(S(-2)))**(-FracPart(m/S(2)))/(b*f), Subst(Int((S(1) + x**S(2)/b**S(2))**(m/S(2) + S(-1))*(a + x)**n, x), x, b*tan(e + f*x)), x) rule3533 = ReplacementRule(pattern3533, replacement3533) pattern3534 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons1440, cons1524) def replacement3534(m, f, b, d, a, n, x, e): rubi.append(3534) return -Dist(d**(S(2)*IntPart(m/S(2)))*(d/sin(e + f*x))**(S(2)*FracPart(m/S(2)))*(sin(e + f*x)**(S(-2)))**(-FracPart(m/S(2)))/(b*f), Subst(Int((S(1) + x**S(2)/b**S(2))**(m/S(2) + S(-1))*(a + x)**n, x), x, b/tan(e + f*x)), x) rule3534 = ReplacementRule(pattern3534, replacement3534) pattern3535 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1439) def replacement3535(f, b, d, a, x, e): rubi.append(3535) return Dist(-S(4)*b/f, Subst(Int(x**S(2)/(a**S(2)*d**S(2) + x**S(4)), x), x, sqrt(d*cos(e + f*x))*sqrt(a + b*tan(e + f*x))), x) rule3535 = ReplacementRule(pattern3535, replacement3535) pattern3536 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons27, cons48, cons125, cons1439) def replacement3536(f, b, d, a, x, e): rubi.append(3536) return Dist(S(4)*b/f, Subst(Int(x**S(2)/(a**S(2)*d**S(2) + x**S(4)), x), x, sqrt(d*sin(e + f*x))*sqrt(a + b/tan(e + f*x))), x) rule3536 = ReplacementRule(pattern3536, replacement3536) pattern3537 = Pattern(Integral(S(1)/((WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)*sqrt(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons27, cons48, cons125, cons1439) def replacement3537(f, b, d, a, x, e): rubi.append(3537) return Dist(S(1)/(d*sqrt(a - b*tan(e + f*x))*sqrt(a + b*tan(e + f*x))*cos(e + f*x)), Int(sqrt(a - b*tan(e + f*x))/sqrt(d*cos(e + f*x)), x), x) rule3537 = ReplacementRule(pattern3537, replacement3537) pattern3538 = Pattern(Integral(S(1)/((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)*sqrt(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons27, cons48, cons125, cons1439) def replacement3538(f, b, d, a, x, e): rubi.append(3538) return Dist(S(1)/(d*sqrt(a - b/tan(e + f*x))*sqrt(a + b/tan(e + f*x))*sin(e + f*x)), Int(sqrt(a - b/tan(e + f*x))/sqrt(d*sin(e + f*x)), x), x) rule3538 = ReplacementRule(pattern3538, replacement3538) pattern3539 = Pattern(Integral((WC('d', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons18) def replacement3539(m, f, b, d, a, n, x, e): rubi.append(3539) return Dist((d/cos(e + f*x))**m*(d*cos(e + f*x))**m, Int((d/cos(e + f*x))**(-m)*(a + b*tan(e + f*x))**n, x), x) rule3539 = ReplacementRule(pattern3539, replacement3539) pattern3540 = Pattern(Integral((WC('d', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons18) def replacement3540(m, f, b, d, a, n, x, e): rubi.append(3540) return Dist((d/sin(e + f*x))**m*(d*sin(e + f*x))**m, Int((d/sin(e + f*x))**(-m)*(a + b/tan(e + f*x))**n, x), x) rule3540 = ReplacementRule(pattern3540, replacement3540) pattern3541 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*sin(x_*WC('f', S(1)) + WC('e', S(0)))**m_, x_), cons2, cons3, cons48, cons125, cons4, cons1515) def replacement3541(m, f, b, a, n, x, e): rubi.append(3541) return Dist(b/f, Subst(Int(x**m*(a + x)**n*(b**S(2) + x**S(2))**(-m/S(2) + S(-1)), x), x, b*tan(e + f*x)), x) rule3541 = ReplacementRule(pattern3541, replacement3541) pattern3542 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*cos(x_*WC('f', S(1)) + WC('e', S(0)))**m_, x_), cons2, cons3, cons48, cons125, cons4, cons1515) def replacement3542(m, f, b, a, n, x, e): rubi.append(3542) return -Dist(b/f, Subst(Int(x**m*(a + x)**n*(b**S(2) + x**S(2))**(-m/S(2) + S(-1)), x), x, b/tan(e + f*x)), x) rule3542 = ReplacementRule(pattern3542, replacement3542) pattern3543 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons48, cons125, cons1228, cons148) def replacement3543(m, f, b, a, n, x, e): rubi.append(3543) return Int((a + b*tan(e + f*x))**n*sin(e + f*x)**m, x) rule3543 = ReplacementRule(pattern3543, replacement3543) pattern3544 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons48, cons125, cons1228, cons148) def replacement3544(m, f, b, a, n, x, e): rubi.append(3544) return Int((a + b/tan(e + f*x))**n*cos(e + f*x)**m, x) rule3544 = ReplacementRule(pattern3544, replacement3544) pattern3545 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons48, cons125, cons1228, cons196, cons1540) def replacement3545(m, f, b, a, n, x, e): rubi.append(3545) return Int((a*cos(e + f*x) + b*sin(e + f*x))**n*sin(e + f*x)**m*cos(e + f*x)**(-n), x) rule3545 = ReplacementRule(pattern3545, replacement3545) pattern3546 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons48, cons125, cons1228, cons196, cons1540) def replacement3546(m, f, b, a, n, x, e): rubi.append(3546) return Int((a*sin(e + f*x) + b*cos(e + f*x))**n*sin(e + f*x)**(-n)*cos(e + f*x)**m, x) rule3546 = ReplacementRule(pattern3546, replacement3546) pattern3547 = Pattern(Integral((WC('d', S(1))/sin(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons18) def replacement3547(m, f, b, d, a, n, x, e): rubi.append(3547) return Dist((sin(e + f*x)/d)**FracPart(m)*(d/sin(e + f*x))**FracPart(m), Int((sin(e + f*x)/d)**(-m)*(a + b*tan(e + f*x))**n, x), x) rule3547 = ReplacementRule(pattern3547, replacement3547) pattern3548 = Pattern(Integral((WC('d', S(1))/cos(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons27, cons48, cons125, cons21, cons4, cons18) def replacement3548(m, f, b, d, a, n, x, e): rubi.append(3548) return Dist((cos(e + f*x)/d)**FracPart(m)*(d/cos(e + f*x))**FracPart(m), Int((cos(e + f*x)/d)**(-m)*(a + b/tan(e + f*x))**n, x), x) rule3548 = ReplacementRule(pattern3548, replacement3548) pattern3549 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons48, cons125, cons21, cons5, cons85) def replacement3549(p, m, f, b, a, n, x, e): rubi.append(3549) return Int((a*cos(e + f*x) + b*sin(e + f*x))**n*sin(e + f*x)**p*cos(e + f*x)**(m - n), x) rule3549 = ReplacementRule(pattern3549, replacement3549) pattern3550 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*sin(x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*cos(x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons48, cons125, cons21, cons5, cons85) def replacement3550(p, m, f, b, a, n, x, e): rubi.append(3550) return Int((a*sin(e + f*x) + b*cos(e + f*x))**n*sin(e + f*x)**(m - n)*cos(e + f*x)**p, x) rule3550 = ReplacementRule(pattern3550, replacement3550) pattern3551 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons70, cons1439, cons17, cons1541) def replacement3551(m, f, b, d, a, n, c, x, e): rubi.append(3551) return Dist(a**m*c**m, Int((c + d*tan(e + f*x))**(-m + n)*(S(1)/cos(e + f*x))**(S(2)*m), x), x) rule3551 = ReplacementRule(pattern3551, replacement3551) pattern3552 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons70, cons1439, cons17, cons1541) def replacement3552(m, f, b, d, a, n, c, x, e): rubi.append(3552) return Dist(a**m*c**m, Int((c + d/tan(e + f*x))**(-m + n)*(S(1)/sin(e + f*x))**(S(2)*m), x), x) rule3552 = ReplacementRule(pattern3552, replacement3552) pattern3553 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons70, cons1439) def replacement3553(m, f, b, d, a, c, n, x, e): rubi.append(3553) return Dist(a*c/f, Subst(Int((a + b*x)**(m + S(-1))*(c + d*x)**(n + S(-1)), x), x, tan(e + f*x)), x) rule3553 = ReplacementRule(pattern3553, replacement3553) pattern3554 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons70, cons1439) def replacement3554(m, f, b, d, a, c, n, x, e): rubi.append(3554) return -Dist(a*c/f, Subst(Int((a + b*x)**(m + S(-1))*(c + d*x)**(n + S(-1)), x), x, S(1)/tan(e + f*x)), x) rule3554 = ReplacementRule(pattern3554, replacement3554) pattern3555 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons70) def replacement3555(f, b, d, a, c, x, e): rubi.append(3555) return Simp(x*(a*c - b*d), x) + Simp(b*d*tan(e + f*x)/f, x) rule3555 = ReplacementRule(pattern3555, replacement3555) pattern3556 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(c_ + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons70) def replacement3556(f, b, d, a, c, x, e): rubi.append(3556) return Simp(x*(a*c - b*d), x) - Simp(b*d/(f*tan(e + f*x)), x) rule3556 = ReplacementRule(pattern3556, replacement3556) pattern3557 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1412) def replacement3557(f, b, d, c, a, x, e): rubi.append(3557) return Dist(a*d + b*c, Int(tan(e + f*x), x), x) + Simp(x*(a*c - b*d), x) + Simp(b*d*tan(e + f*x)/f, x) rule3557 = ReplacementRule(pattern3557, replacement3557) pattern3558 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1412) def replacement3558(f, b, d, c, a, x, e): rubi.append(3558) return Dist(a*d + b*c, Int(S(1)/tan(e + f*x), x), x) + Simp(x*(a*c - b*d), x) - Simp(b*d/(f*tan(e + f*x)), x) rule3558 = ReplacementRule(pattern3558, replacement3558) pattern3559 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons31, cons267) def replacement3559(m, f, b, d, c, a, x, e): rubi.append(3559) return Dist((a*d + b*c)/(S(2)*a*b), Int((a + b*tan(e + f*x))**(m + S(1)), x), x) - Simp((a + b*tan(e + f*x))**m*(-a*d + b*c)/(S(2)*a*f*m), x) rule3559 = ReplacementRule(pattern3559, replacement3559) pattern3560 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons31, cons267) def replacement3560(m, f, b, d, c, a, x, e): rubi.append(3560) return Dist((a*d + b*c)/(S(2)*a*b), Int((a + b/tan(e + f*x))**(m + S(1)), x), x) + Simp((a + b/tan(e + f*x))**m*(-a*d + b*c)/(S(2)*a*f*m), x) rule3560 = ReplacementRule(pattern3560, replacement3560) pattern3561 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons71, cons1439, cons1303) def replacement3561(m, f, b, d, c, a, x, e): rubi.append(3561) return Dist((a*d + b*c)/b, Int((a + b*tan(e + f*x))**m, x), x) + Simp(d*(a + b*tan(e + f*x))**m/(f*m), x) rule3561 = ReplacementRule(pattern3561, replacement3561) pattern3562 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons71, cons1439, cons1303) def replacement3562(m, f, b, d, c, a, x, e): rubi.append(3562) return Dist((a*d + b*c)/b, Int((a + b/tan(e + f*x))**m, x), x) - Simp(d*(a + b/tan(e + f*x))**m/(f*m), x) rule3562 = ReplacementRule(pattern3562, replacement3562) pattern3563 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440, cons31, cons168) def replacement3563(m, f, b, d, c, a, x, e): rubi.append(3563) return Int((a + b*tan(e + f*x))**(m + S(-1))*Simp(a*c - b*d + (a*d + b*c)*tan(e + f*x), x), x) + Simp(d*(a + b*tan(e + f*x))**m/(f*m), x) rule3563 = ReplacementRule(pattern3563, replacement3563) pattern3564 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440, cons31, cons168) def replacement3564(m, f, b, d, c, a, x, e): rubi.append(3564) return Int((a + b/tan(e + f*x))**(m + S(-1))*Simp(a*c - b*d + (a*d + b*c)/tan(e + f*x), x), x) - Simp(d*(a + b/tan(e + f*x))**m/(f*m), x) rule3564 = ReplacementRule(pattern3564, replacement3564) pattern3565 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440, cons31, cons94) def replacement3565(m, f, b, d, c, a, x, e): rubi.append(3565) return Dist(S(1)/(a**S(2) + b**S(2)), Int((a + b*tan(e + f*x))**(m + S(1))*Simp(a*c + b*d - (-a*d + b*c)*tan(e + f*x), x), x), x) + Simp((a + b*tan(e + f*x))**(m + S(1))*(-a*d + b*c)/(f*(a**S(2) + b**S(2))*(m + S(1))), x) rule3565 = ReplacementRule(pattern3565, replacement3565) pattern3566 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440, cons31, cons94) def replacement3566(m, f, b, d, c, a, x, e): rubi.append(3566) return Dist(S(1)/(a**S(2) + b**S(2)), Int((a + b/tan(e + f*x))**(m + S(1))*Simp(a*c + b*d - (-a*d + b*c)/tan(e + f*x), x), x), x) - Simp((a + b/tan(e + f*x))**(m + S(1))*(-a*d + b*c)/(f*(a**S(2) + b**S(2))*(m + S(1))), x) rule3566 = ReplacementRule(pattern3566, replacement3566) pattern3567 = Pattern(Integral((c_ + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))/(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440, cons1542) def replacement3567(f, b, d, a, c, x, e): rubi.append(3567) return Simp(c*log(RemoveContent(a*cos(e + f*x) + b*sin(e + f*x), x))/(b*f), x) rule3567 = ReplacementRule(pattern3567, replacement3567) pattern3568 = Pattern(Integral((c_ + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))/(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440, cons1542) def replacement3568(f, b, d, a, c, x, e): rubi.append(3568) return -Simp(c*log(RemoveContent(a*sin(e + f*x) + b*cos(e + f*x), x))/(b*f), x) rule3568 = ReplacementRule(pattern3568, replacement3568) pattern3569 = Pattern(Integral((WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))/(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440, cons1543) def replacement3569(f, b, d, c, a, x, e): rubi.append(3569) return Dist((-a*d + b*c)/(a**S(2) + b**S(2)), Int((-a*tan(e + f*x) + b)/(a + b*tan(e + f*x)), x), x) + Simp(x*(a*c + b*d)/(a**S(2) + b**S(2)), x) rule3569 = ReplacementRule(pattern3569, replacement3569) pattern3570 = Pattern(Integral((WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))/(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440, cons1543) def replacement3570(f, b, d, c, a, x, e): rubi.append(3570) return Dist((-a*d + b*c)/(a**S(2) + b**S(2)), Int((-a/tan(e + f*x) + b)/(a + b/tan(e + f*x)), x), x) + Simp(x*(a*c + b*d)/(a**S(2) + b**S(2)), x) rule3570 = ReplacementRule(pattern3570, replacement3570) pattern3571 = Pattern(Integral((c_ + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons3, cons7, cons27, cons48, cons125, cons1322) def replacement3571(f, b, d, c, x, e): rubi.append(3571) return Dist(-S(2)*d**S(2)/f, Subst(Int(S(1)/(b*x**S(2) + S(2)*c*d), x), x, (c - d*tan(e + f*x))/sqrt(b*tan(e + f*x))), x) rule3571 = ReplacementRule(pattern3571, replacement3571) pattern3572 = Pattern(Integral((c_ + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons3, cons7, cons27, cons48, cons125, cons1322) def replacement3572(f, b, d, c, x, e): rubi.append(3572) return Dist(S(2)*d**S(2)/f, Subst(Int(S(1)/(b*x**S(2) + S(2)*c*d), x), x, (c - d/tan(e + f*x))/sqrt(b/tan(e + f*x))), x) rule3572 = ReplacementRule(pattern3572, replacement3572) pattern3573 = Pattern(Integral((c_ + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons3, cons7, cons27, cons48, cons125, cons1544) def replacement3573(f, b, d, c, x, e): rubi.append(3573) return Dist(S(2)*c**S(2)/f, Subst(Int(S(1)/(b*c - d*x**S(2)), x), x, sqrt(b*tan(e + f*x))), x) rule3573 = ReplacementRule(pattern3573, replacement3573) pattern3574 = Pattern(Integral((c_ + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons3, cons7, cons27, cons48, cons125, cons1544) def replacement3574(f, b, d, c, x, e): rubi.append(3574) return Dist(-S(2)*c**S(2)/f, Subst(Int(S(1)/(b*c - d*x**S(2)), x), x, sqrt(b/tan(e + f*x))), x) rule3574 = ReplacementRule(pattern3574, replacement3574) pattern3575 = Pattern(Integral((c_ + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons3, cons7, cons27, cons48, cons125, cons1323, cons1545) def replacement3575(f, b, d, c, x, e): rubi.append(3575) return Dist(S(2)/f, Subst(Int((b*c + d*x**S(2))/(b**S(2) + x**S(4)), x), x, sqrt(b*tan(e + f*x))), x) rule3575 = ReplacementRule(pattern3575, replacement3575) pattern3576 = Pattern(Integral((c_ + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons3, cons7, cons27, cons48, cons125, cons1323, cons1545) def replacement3576(f, b, d, c, x, e): rubi.append(3576) return Dist(-S(2)/f, Subst(Int((b*c + d*x**S(2))/(b**S(2) + x**S(4)), x), x, sqrt(b/tan(e + f*x))), x) rule3576 = ReplacementRule(pattern3576, replacement3576) pattern3577 = Pattern(Integral((WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440, cons1545, cons1546) def replacement3577(f, b, d, c, a, x, e): rubi.append(3577) return Dist(-S(2)*d**S(2)/f, Subst(Int(S(1)/(-S(4)*a*d**S(2) + S(2)*b*c*d + x**S(2)), x), x, (-S(2)*a*d + b*c - b*d*tan(e + f*x))/sqrt(a + b*tan(e + f*x))), x) rule3577 = ReplacementRule(pattern3577, replacement3577) pattern3578 = Pattern(Integral((WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440, cons1545, cons1546) def replacement3578(f, b, d, c, a, x, e): rubi.append(3578) return Dist(S(2)*d**S(2)/f, Subst(Int(S(1)/(-S(4)*a*d**S(2) + S(2)*b*c*d + x**S(2)), x), x, (-S(2)*a*d + b*c - b*d/tan(e + f*x))/sqrt(a + b/tan(e + f*x))), x) rule3578 = ReplacementRule(pattern3578, replacement3578) def With3579(f, b, d, c, a, x, e): q = Rt(a**S(2) + b**S(2), S(2)) rubi.append(3579) return -Dist(S(1)/(S(2)*q), Int((a*c + b*d - c*q + (-a*d + b*c - d*q)*tan(e + f*x))/sqrt(a + b*tan(e + f*x)), x), x) + Dist(S(1)/(S(2)*q), Int((a*c + b*d + c*q + (-a*d + b*c + d*q)*tan(e + f*x))/sqrt(a + b*tan(e + f*x)), x), x) pattern3579 = Pattern(Integral((WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440, cons1545, cons1547, cons1548) rule3579 = ReplacementRule(pattern3579, With3579) def With3580(f, b, d, c, a, x, e): q = Rt(a**S(2) + b**S(2), S(2)) rubi.append(3580) return -Dist(S(1)/(S(2)*q), Int((a*c + b*d - c*q + (-a*d + b*c - d*q)/tan(e + f*x))/sqrt(a + b/tan(e + f*x)), x), x) + Dist(S(1)/(S(2)*q), Int((a*c + b*d + c*q + (-a*d + b*c + d*q)/tan(e + f*x))/sqrt(a + b/tan(e + f*x)), x), x) pattern3580 = Pattern(Integral((WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440, cons1545, cons1547, cons1548) rule3580 = ReplacementRule(pattern3580, With3580) pattern3581 = Pattern(Integral((c_ + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons71, cons1440, cons1544) def replacement3581(m, f, b, d, a, c, x, e): rubi.append(3581) return Dist(c*d/f, Subst(Int((a + b*x/d)**m/(c*x + d**S(2)), x), x, d*tan(e + f*x)), x) rule3581 = ReplacementRule(pattern3581, replacement3581) pattern3582 = Pattern(Integral((c_ + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons71, cons1440, cons1544) def replacement3582(m, f, b, d, a, c, x, e): rubi.append(3582) return -Dist(c*d/f, Subst(Int((a + b*x/d)**m/(c*x + d**S(2)), x), x, d/tan(e + f*x)), x) rule3582 = ReplacementRule(pattern3582, replacement3582) pattern3583 = Pattern(Integral((WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons3, cons7, cons27, cons48, cons125, cons21, cons1545, cons77) def replacement3583(m, f, b, d, c, x, e): rubi.append(3583) return Dist(c, Int((b*tan(e + f*x))**m, x), x) + Dist(d/b, Int((b*tan(e + f*x))**(m + S(1)), x), x) rule3583 = ReplacementRule(pattern3583, replacement3583) pattern3584 = Pattern(Integral((WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons3, cons7, cons27, cons48, cons125, cons21, cons1545, cons77) def replacement3584(m, f, b, d, c, x, e): rubi.append(3584) return Dist(c, Int((b/tan(e + f*x))**m, x), x) + Dist(d/b, Int((b/tan(e + f*x))**(m + S(1)), x), x) rule3584 = ReplacementRule(pattern3584, replacement3584) pattern3585 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons71, cons1440, cons1545, cons18) def replacement3585(m, f, b, d, c, a, x, e): rubi.append(3585) return Dist(c/S(2) - I*d/S(2), Int((a + b*tan(e + f*x))**m*(I*tan(e + f*x) + S(1)), x), x) + Dist(c/S(2) + I*d/S(2), Int((a + b*tan(e + f*x))**m*(-I*tan(e + f*x) + S(1)), x), x) rule3585 = ReplacementRule(pattern3585, replacement3585) pattern3586 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons71, cons1440, cons1545, cons18) def replacement3586(m, f, b, d, c, a, x, e): rubi.append(3586) return Dist(c/S(2) - I*d/S(2), Int((S(1) + I/tan(e + f*x))*(a + b/tan(e + f*x))**m, x), x) + Dist(c/S(2) + I*d/S(2), Int((S(1) - I/tan(e + f*x))*(a + b/tan(e + f*x))**m, x), x) rule3586 = ReplacementRule(pattern3586, replacement3586) pattern3587 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons31, cons32, cons1439) def replacement3587(m, f, b, d, c, a, x, e): rubi.append(3587) return Dist(S(1)/(S(2)*a**S(2)), Int((a + b*tan(e + f*x))**(m + S(1))*Simp(a*c**S(2) + a*d**S(2) - S(2)*b*c*d - S(2)*b*d**S(2)*tan(e + f*x), x), x), x) - Simp(b*(a + b*tan(e + f*x))**m*(a*c + b*d)**S(2)/(S(2)*a**S(3)*f*m), x) rule3587 = ReplacementRule(pattern3587, replacement3587) pattern3588 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons31, cons32, cons1439) def replacement3588(m, f, b, d, c, a, x, e): rubi.append(3588) return Dist(S(1)/(S(2)*a**S(2)), Int((a + b/tan(e + f*x))**(m + S(1))*Simp(a*c**S(2) + a*d**S(2) - S(2)*b*c*d - S(2)*b*d**S(2)/tan(e + f*x), x), x), x) + Simp(b*(a + b/tan(e + f*x))**m*(a*c + b*d)**S(2)/(S(2)*a**S(3)*f*m), x) rule3588 = ReplacementRule(pattern3588, replacement3588) pattern3589 = Pattern(Integral((WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**S(2)/(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440) def replacement3589(f, b, d, c, a, x, e): rubi.append(3589) return Dist((-a*d + b*c)**S(2)/b**S(2), Int(S(1)/(a + b*tan(e + f*x)), x), x) + Dist(d**S(2)/b, Int(tan(e + f*x), x), x) + Simp(d*x*(-a*d + S(2)*b*c)/b**S(2), x) rule3589 = ReplacementRule(pattern3589, replacement3589) pattern3590 = Pattern(Integral((WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**S(2)/(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440) def replacement3590(f, b, d, c, a, x, e): rubi.append(3590) return Dist((-a*d + b*c)**S(2)/b**S(2), Int(S(1)/(a + b/tan(e + f*x)), x), x) + Dist(d**S(2)/b, Int(S(1)/tan(e + f*x), x), x) + Simp(d*x*(-a*d + S(2)*b*c)/b**S(2), x) rule3590 = ReplacementRule(pattern3590, replacement3590) pattern3591 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons31, cons94, cons1440) def replacement3591(m, f, b, d, c, a, x, e): rubi.append(3591) return Dist(S(1)/(a**S(2) + b**S(2)), Int((a + b*tan(e + f*x))**(m + S(1))*Simp(a*c**S(2) - a*d**S(2) + S(2)*b*c*d - (-S(2)*a*c*d + b*c**S(2) - b*d**S(2))*tan(e + f*x), x), x), x) + Simp((a + b*tan(e + f*x))**(m + S(1))*(-a*d + b*c)**S(2)/(b*f*(a**S(2) + b**S(2))*(m + S(1))), x) rule3591 = ReplacementRule(pattern3591, replacement3591) pattern3592 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons31, cons94, cons1440) def replacement3592(m, f, b, d, c, a, x, e): rubi.append(3592) return Dist(S(1)/(a**S(2) + b**S(2)), Int((a + b/tan(e + f*x))**(m + S(1))*Simp(a*c**S(2) - a*d**S(2) + S(2)*b*c*d - (-S(2)*a*c*d + b*c**S(2) - b*d**S(2))/tan(e + f*x), x), x), x) - Simp((a + b/tan(e + f*x))**(m + S(1))*(-a*d + b*c)**S(2)/(b*f*(a**S(2) + b**S(2))*(m + S(1))), x) rule3592 = ReplacementRule(pattern3592, replacement3592) pattern3593 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons71, cons1549, cons1550) def replacement3593(m, f, b, d, c, a, x, e): rubi.append(3593) return Int((a + b*tan(e + f*x))**m*Simp(c**S(2) + S(2)*c*d*tan(e + f*x) - d**S(2), x), x) + Simp(d**S(2)*(a + b*tan(e + f*x))**(m + S(1))/(b*f*(m + S(1))), x) rule3593 = ReplacementRule(pattern3593, replacement3593) pattern3594 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons71, cons1549, cons1550) def replacement3594(m, f, b, d, c, a, x, e): rubi.append(3594) return Int((a + b/tan(e + f*x))**m*Simp(c**S(2) + S(2)*c*d/tan(e + f*x) - d**S(2), x), x) - Simp(d**S(2)*(a + b/tan(e + f*x))**(m + S(1))/(b*f*(m + S(1))), x) rule3594 = ReplacementRule(pattern3594, replacement3594) pattern3595 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545) def replacement3595(f, b, d, c, a, x, e): rubi.append(3595) return Dist(-S(2)*a*b/f, Subst(Int(S(1)/(-S(2)*a**S(2)*x**S(2) + a*c - b*d), x), x, sqrt(c + d*tan(e + f*x))/sqrt(a + b*tan(e + f*x))), x) rule3595 = ReplacementRule(pattern3595, replacement3595) pattern3596 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545) def replacement3596(f, b, d, c, a, x, e): rubi.append(3596) return Dist(S(2)*a*b/f, Subst(Int(S(1)/(-S(2)*a**S(2)*x**S(2) + a*c - b*d), x), x, sqrt(c + d/tan(e + f*x))/sqrt(a + b/tan(e + f*x))), x) rule3596 = ReplacementRule(pattern3596, replacement3596) pattern3597 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545, cons93, cons1551, cons1423) def replacement3597(m, f, b, d, c, a, n, x, e): rubi.append(3597) return Dist(S(2)*a**S(2)/(a*c - b*d), Int((a + b*tan(e + f*x))**(m + S(-1))*(c + d*tan(e + f*x))**(n + S(1)), x), x) + Simp(a*b*(a + b*tan(e + f*x))**(m + S(-1))*(c + d*tan(e + f*x))**(n + S(1))/(f*(m + S(-1))*(a*c - b*d)), x) rule3597 = ReplacementRule(pattern3597, replacement3597) pattern3598 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545, cons93, cons1551, cons1423) def replacement3598(m, f, b, d, c, n, a, x, e): rubi.append(3598) return Dist(S(2)*a**S(2)/(a*c - b*d), Int((a + b/tan(e + f*x))**(m + S(-1))*(c + d/tan(e + f*x))**(n + S(1)), x), x) - Simp(a*b*(a + b/tan(e + f*x))**(m + S(-1))*(c + d/tan(e + f*x))**(n + S(1))/(f*(m + S(-1))*(a*c - b*d)), x) rule3598 = ReplacementRule(pattern3598, replacement3598) pattern3599 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545, cons93, cons1551, cons1385) def replacement3599(m, f, b, d, c, a, n, x, e): rubi.append(3599) return -Dist((a*c - b*d)/(S(2)*b**S(2)), Int((a + b*tan(e + f*x))**(m + S(1))*(c + d*tan(e + f*x))**(n + S(-1)), x), x) + Simp(a*(a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**n/(S(2)*b*f*m), x) rule3599 = ReplacementRule(pattern3599, replacement3599) pattern3600 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545, cons93, cons1551, cons1385) def replacement3600(m, f, b, d, c, n, a, x, e): rubi.append(3600) return -Dist((a*c - b*d)/(S(2)*b**S(2)), Int((a + b/tan(e + f*x))**(m + S(1))*(c + d/tan(e + f*x))**(n + S(-1)), x), x) - Simp(a*(a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**n/(S(2)*b*f*m), x) rule3600 = ReplacementRule(pattern3600, replacement3600) pattern3601 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545, cons93, cons111, cons94) def replacement3601(m, f, b, d, c, a, n, x, e): rubi.append(3601) return Dist(S(1)/(S(2)*a), Int((a + b*tan(e + f*x))**(m + S(1))*(c + d*tan(e + f*x))**n, x), x) + Simp(a*(a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**(n + S(1))/(S(2)*f*m*(-a*d + b*c)), x) rule3601 = ReplacementRule(pattern3601, replacement3601) pattern3602 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545, cons93, cons111, cons94) def replacement3602(m, f, b, d, c, n, a, x, e): rubi.append(3602) return Dist(S(1)/(S(2)*a), Int((a + b/tan(e + f*x))**(m + S(1))*(c + d/tan(e + f*x))**n, x), x) - Simp(a*(a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**(n + S(1))/(S(2)*f*m*(-a*d + b*c)), x) rule3602 = ReplacementRule(pattern3602, replacement3602) pattern3603 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons71, cons1439, cons1545, cons155, cons272) def replacement3603(m, f, b, d, c, a, n, x, e): rubi.append(3603) return Dist(a/(a*c - b*d), Int((a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**(n + S(1)), x), x) - Simp(d*(a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**(n + S(1))/(f*m*(c**S(2) + d**S(2))), x) rule3603 = ReplacementRule(pattern3603, replacement3603) pattern3604 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons71, cons1439, cons1545, cons155, cons272) def replacement3604(m, f, b, d, c, n, a, x, e): rubi.append(3604) return Dist(a/(a*c - b*d), Int((a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**(n + S(1)), x), x) + Simp(d*(a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**(n + S(1))/(f*m*(c**S(2) + d**S(2))), x) rule3604 = ReplacementRule(pattern3604, replacement3604) pattern3605 = Pattern(Integral((WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_/(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545, cons87, cons1325) def replacement3605(f, b, d, c, a, n, x, e): rubi.append(3605) return Dist(S(1)/(S(2)*a*(-a*d + b*c)), Int((c + d*tan(e + f*x))**(n + S(-1))*Simp(a*c*d*(n + S(-1)) + b*c**S(2) + b*d**S(2)*n - d*(n + S(-1))*(-a*d + b*c)*tan(e + f*x), x), x), x) - Simp((c + d*tan(e + f*x))**n*(a*c + b*d)/(S(2)*f*(a + b*tan(e + f*x))*(-a*d + b*c)), x) rule3605 = ReplacementRule(pattern3605, replacement3605) pattern3606 = Pattern(Integral((WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_/(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545, cons87, cons1325) def replacement3606(f, b, d, c, n, a, x, e): rubi.append(3606) return Dist(S(1)/(S(2)*a*(-a*d + b*c)), Int((c + d/tan(e + f*x))**(n + S(-1))*Simp(a*c*d*(n + S(-1)) + b*c**S(2) + b*d**S(2)*n - d*(n + S(-1))*(-a*d + b*c)/tan(e + f*x), x), x), x) + Simp((c + d/tan(e + f*x))**n*(a*c + b*d)/(S(2)*f*(a + b/tan(e + f*x))*(-a*d + b*c)), x) rule3606 = ReplacementRule(pattern3606, replacement3606) pattern3607 = Pattern(Integral((WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_/(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545, cons87, cons165) def replacement3607(f, b, d, c, a, n, x, e): rubi.append(3607) return Dist(S(1)/(S(2)*a**S(2)), Int((c + d*tan(e + f*x))**(n + S(-2))*Simp(a*c**S(2) + a*d**S(2)*(n + S(-1)) - b*c*d*n - d*(a*c*(n + S(-2)) + b*d*n)*tan(e + f*x), x), x), x) + Simp((c + d*tan(e + f*x))**(n + S(-1))*(-a*d + b*c)/(S(2)*a*f*(a + b*tan(e + f*x))), x) rule3607 = ReplacementRule(pattern3607, replacement3607) pattern3608 = Pattern(Integral((WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_/(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545, cons87, cons165) def replacement3608(f, b, d, c, n, a, x, e): rubi.append(3608) return Dist(S(1)/(S(2)*a**S(2)), Int((c + d/tan(e + f*x))**(n + S(-2))*Simp(a*c**S(2) + a*d**S(2)*(n + S(-1)) - b*c*d*n - d*(a*c*(n + S(-2)) + b*d*n)/tan(e + f*x), x), x), x) - Simp((c + d/tan(e + f*x))**(n + S(-1))*(-a*d + b*c)/(S(2)*a*f*(a + b/tan(e + f*x))), x) rule3608 = ReplacementRule(pattern3608, replacement3608) pattern3609 = Pattern(Integral(S(1)/((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545) def replacement3609(f, b, d, c, a, x, e): rubi.append(3609) return Dist(b/(-a*d + b*c), Int(S(1)/(a + b*tan(e + f*x)), x), x) - Dist(d/(-a*d + b*c), Int(S(1)/(c + d*tan(e + f*x)), x), x) rule3609 = ReplacementRule(pattern3609, replacement3609) pattern3610 = Pattern(Integral(S(1)/((WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545) def replacement3610(f, b, d, c, a, x, e): rubi.append(3610) return Dist(b/(-a*d + b*c), Int(S(1)/(a + b/tan(e + f*x)), x), x) - Dist(d/(-a*d + b*c), Int(S(1)/(c + d/tan(e + f*x)), x), x) rule3610 = ReplacementRule(pattern3610, replacement3610) pattern3611 = Pattern(Integral((WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_/(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons71, cons1439, cons1545, cons1327) def replacement3611(f, b, d, c, a, n, x, e): rubi.append(3611) return Dist(S(1)/(S(2)*a*(-a*d + b*c)), Int((c + d*tan(e + f*x))**n*Simp(a*d*(n + S(-1)) + b*c - b*d*n*tan(e + f*x), x), x), x) - Simp(a*(c + d*tan(e + f*x))**(n + S(1))/(S(2)*f*(a + b*tan(e + f*x))*(-a*d + b*c)), x) rule3611 = ReplacementRule(pattern3611, replacement3611) pattern3612 = Pattern(Integral((WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_/(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons71, cons1439, cons1545, cons1327) def replacement3612(f, b, d, c, n, a, x, e): rubi.append(3612) return Dist(S(1)/(S(2)*a*(-a*d + b*c)), Int((c + d/tan(e + f*x))**n*Simp(a*d*(n + S(-1)) + b*c - b*d*n/tan(e + f*x), x), x), x) + Simp(a*(c + d/tan(e + f*x))**(n + S(1))/(S(2)*f*(a + b/tan(e + f*x))*(-a*d + b*c)), x) rule3612 = ReplacementRule(pattern3612, replacement3612) pattern3613 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545, cons93, cons166, cons89, cons1334) def replacement3613(m, f, b, d, c, a, n, x, e): rubi.append(3613) return Dist(a/(d*(n + S(1))*(a*d + b*c)), Int((a + b*tan(e + f*x))**(m + S(-2))*(c + d*tan(e + f*x))**(n + S(1))*Simp(b*(-a*d*(m - S(2)*n + S(-4)) + b*c*(m + S(-2))) + (-a**S(2)*d*(m + n + S(-1)) + a*b*c*(m + S(-2)) + b**S(2)*d*(n + S(1)))*tan(e + f*x), x), x), x) - Simp(a**S(2)*(a + b*tan(e + f*x))**(m + S(-2))*(c + d*tan(e + f*x))**(n + S(1))*(-a*d + b*c)/(d*f*(n + S(1))*(a*d + b*c)), x) rule3613 = ReplacementRule(pattern3613, replacement3613) pattern3614 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545, cons93, cons166, cons89, cons1334) def replacement3614(m, f, b, d, c, n, a, x, e): rubi.append(3614) return Dist(a/(d*(n + S(1))*(a*d + b*c)), Int((a + b/tan(e + f*x))**(m + S(-2))*(c + d/tan(e + f*x))**(n + S(1))*Simp(b*(-a*d*(m - S(2)*n + S(-4)) + b*c*(m + S(-2))) + (-a**S(2)*d*(m + n + S(-1)) + a*b*c*(m + S(-2)) + b**S(2)*d*(n + S(1)))/tan(e + f*x), x), x), x) + Simp(a**S(2)*(a + b/tan(e + f*x))**(m + S(-2))*(c + d/tan(e + f*x))**(n + S(1))*(-a*d + b*c)/(d*f*(n + S(1))*(a*d + b*c)), x) rule3614 = ReplacementRule(pattern3614, replacement3614) pattern3615 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)/(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545) def replacement3615(f, b, d, c, a, x, e): rubi.append(3615) return Dist(S(2)*a**S(2)/(a*c - b*d), Int(sqrt(a + b*tan(e + f*x)), x), x) - Dist((a*(c**S(2) - d**S(2)) + S(2)*b*c*d)/(a*(c**S(2) + d**S(2))), Int((a - b*tan(e + f*x))*sqrt(a + b*tan(e + f*x))/(c + d*tan(e + f*x)), x), x) rule3615 = ReplacementRule(pattern3615, replacement3615) pattern3616 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)/(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545) def replacement3616(f, b, d, c, a, x, e): rubi.append(3616) return Dist(S(2)*a**S(2)/(a*c - b*d), Int(sqrt(a + b/tan(e + f*x)), x), x) - Dist((a*(c**S(2) - d**S(2)) + S(2)*b*c*d)/(a*(c**S(2) + d**S(2))), Int((a - b/tan(e + f*x))*sqrt(a + b/tan(e + f*x))/(c + d/tan(e + f*x)), x), x) rule3616 = ReplacementRule(pattern3616, replacement3616) pattern3617 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)/sqrt(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545) def replacement3617(f, b, d, c, a, x, e): rubi.append(3617) return Dist(S(2)*a, Int(sqrt(a + b*tan(e + f*x))/sqrt(c + d*tan(e + f*x)), x), x) + Dist(b/a, Int(sqrt(a + b*tan(e + f*x))*(a*tan(e + f*x) + b)/sqrt(c + d*tan(e + f*x)), x), x) rule3617 = ReplacementRule(pattern3617, replacement3617) pattern3618 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)/sqrt(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545) def replacement3618(f, b, d, c, a, x, e): rubi.append(3618) return Dist(S(2)*a, Int(sqrt(a + b/tan(e + f*x))/sqrt(c + d/tan(e + f*x)), x), x) + Dist(b/a, Int(sqrt(a + b/tan(e + f*x))*(a/tan(e + f*x) + b)/sqrt(c + d/tan(e + f*x)), x), x) rule3618 = ReplacementRule(pattern3618, replacement3618) pattern3619 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons71, cons1439, cons1545, cons515, cons166, cons1519, cons1334) def replacement3619(m, f, b, d, c, a, n, x, e): rubi.append(3619) return Dist(a/(d*(m + n + S(-1))), Int((a + b*tan(e + f*x))**(m + S(-2))*(c + d*tan(e + f*x))**n*Simp(a*d*(m + S(2)*n) + b*c*(m + S(-2)) + (a*c*(m + S(-2)) + b*d*(S(3)*m + S(2)*n + S(-4)))*tan(e + f*x), x), x), x) + Simp(b**S(2)*(a + b*tan(e + f*x))**(m + S(-2))*(c + d*tan(e + f*x))**(n + S(1))/(d*f*(m + n + S(-1))), x) rule3619 = ReplacementRule(pattern3619, replacement3619) pattern3620 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons71, cons1439, cons1545, cons515, cons166, cons1519, cons1334) def replacement3620(m, f, b, d, c, n, a, x, e): rubi.append(3620) return Dist(a/(d*(m + n + S(-1))), Int((a + b/tan(e + f*x))**(m + S(-2))*(c + d/tan(e + f*x))**n*Simp(a*d*(m + S(2)*n) + b*c*(m + S(-2)) + (a*c*(m + S(-2)) + b*d*(S(3)*m + S(2)*n + S(-4)))/tan(e + f*x), x), x), x) - Simp(b**S(2)*(a + b/tan(e + f*x))**(m + S(-2))*(c + d/tan(e + f*x))**(n + S(1))/(d*f*(m + n + S(-1))), x) rule3620 = ReplacementRule(pattern3620, replacement3620) pattern3621 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*sqrt(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545, cons31, cons267, cons1552) def replacement3621(m, f, b, d, c, a, x, e): rubi.append(3621) return Dist(S(1)/(S(4)*a**S(2)*m), Int((a + b*tan(e + f*x))**(m + S(1))*Simp(S(2)*a*c*m + a*d*(S(2)*m + S(1))*tan(e + f*x) + b*d, x)/sqrt(c + d*tan(e + f*x)), x), x) - Simp(b*(a + b*tan(e + f*x))**m*sqrt(c + d*tan(e + f*x))/(S(2)*a*f*m), x) rule3621 = ReplacementRule(pattern3621, replacement3621) pattern3622 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*sqrt(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545, cons31, cons267, cons1552) def replacement3622(m, f, b, d, c, a, x, e): rubi.append(3622) return Dist(S(1)/(S(4)*a**S(2)*m), Int((a + b/tan(e + f*x))**(m + S(1))*Simp(S(2)*a*c*m + a*d*(S(2)*m + S(1))/tan(e + f*x) + b*d, x)/sqrt(c + d/tan(e + f*x)), x), x) + Simp(b*(a + b/tan(e + f*x))**m*sqrt(c + d/tan(e + f*x))/(S(2)*a*f*m), x) rule3622 = ReplacementRule(pattern3622, replacement3622) pattern3623 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545, cons93, cons267, cons165, cons1334) def replacement3623(m, f, b, d, c, a, n, x, e): rubi.append(3623) return Dist(S(1)/(S(2)*a**S(2)*m), Int((a + b*tan(e + f*x))**(m + S(1))*(c + d*tan(e + f*x))**(n + S(-2))*Simp(c*(a*c*m + b*d*(n + S(-1))) - d*(-a*c*(m + n + S(-1)) + b*d*(m - n + S(1)))*tan(e + f*x) - d*(a*d*(n + S(-1)) + b*c*m), x), x), x) - Simp((a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**(n + S(-1))*(-a*d + b*c)/(S(2)*a*f*m), x) rule3623 = ReplacementRule(pattern3623, replacement3623) pattern3624 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545, cons93, cons267, cons165, cons1334) def replacement3624(m, f, b, d, c, n, a, x, e): rubi.append(3624) return Dist(S(1)/(S(2)*a**S(2)*m), Int((a + b/tan(e + f*x))**(m + S(1))*(c + d/tan(e + f*x))**(n + S(-2))*Simp(c*(a*c*m + b*d*(n + S(-1))) - d*(-a*c*(m + n + S(-1)) + b*d*(m - n + S(1)))/tan(e + f*x) - d*(a*d*(n + S(-1)) + b*c*m), x), x), x) + Simp((a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**(n + S(-1))*(-a*d + b*c)/(S(2)*a*f*m), x) rule3624 = ReplacementRule(pattern3624, replacement3624) pattern3625 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons71, cons1439, cons1545, cons31, cons267, cons1334) def replacement3625(m, f, b, d, c, a, n, x, e): rubi.append(3625) return Dist(S(1)/(S(2)*a*m*(-a*d + b*c)), Int((a + b*tan(e + f*x))**(m + S(1))*(c + d*tan(e + f*x))**n*Simp(-a*d*(S(2)*m + n + S(1)) + b*c*m + b*d*(m + n + S(1))*tan(e + f*x), x), x), x) + Simp(a*(a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**(n + S(1))/(S(2)*f*m*(-a*d + b*c)), x) rule3625 = ReplacementRule(pattern3625, replacement3625) pattern3626 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons71, cons1439, cons1545, cons31, cons267, cons1334) def replacement3626(m, f, b, d, c, n, a, x, e): rubi.append(3626) return Dist(S(1)/(S(2)*a*m*(-a*d + b*c)), Int((a + b/tan(e + f*x))**(m + S(1))*(c + d/tan(e + f*x))**n*Simp(-a*d*(S(2)*m + n + S(1)) + b*c*m + b*d*(m + n + S(1))/tan(e + f*x), x), x), x) - Simp(a*(a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**(n + S(1))/(S(2)*f*m*(-a*d + b*c)), x) rule3626 = ReplacementRule(pattern3626, replacement3626) pattern3627 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons71, cons1439, cons1545, cons87, cons165, cons1519, cons1553) def replacement3627(m, f, b, d, c, a, n, x, e): rubi.append(3627) return -Dist(S(1)/(a*(m + n + S(-1))), Int((a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**(n + S(-2))*Simp(-a*c**S(2)*(m + n + S(-1)) + d*(-a*c*(m + S(2)*n + S(-2)) + b*d*m)*tan(e + f*x) + d*(a*d*(n + S(-1)) + b*c*m), x), x), x) + Simp(d*(a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**(n + S(-1))/(f*(m + n + S(-1))), x) rule3627 = ReplacementRule(pattern3627, replacement3627) pattern3628 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons71, cons1439, cons1545, cons87, cons165, cons1519, cons1553) def replacement3628(m, f, b, d, c, a, n, x, e): rubi.append(3628) return -Dist(S(1)/(a*(m + n + S(-1))), Int((a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**(n + S(-2))*Simp(-a*c**S(2)*(m + n + S(-1)) + d*(-a*c*(m + S(2)*n + S(-2)) + b*d*m)/tan(e + f*x) + d*(a*d*(n + S(-1)) + b*c*m), x), x), x) - Simp(d*(a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**(n + S(-1))/(f*(m + n + S(-1))), x) rule3628 = ReplacementRule(pattern3628, replacement3628) pattern3629 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons71, cons1439, cons1545, cons87, cons89, cons1553) def replacement3629(m, f, b, d, c, a, n, x, e): rubi.append(3629) return -Dist(S(1)/(a*(c**S(2) + d**S(2))*(n + S(1))), Int((a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**(n + S(1))*Simp(-a*c*(n + S(1)) + a*d*(m + n + S(1))*tan(e + f*x) + b*d*m, x), x), x) + Simp(d*(a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**(n + S(1))/(f*(c**S(2) + d**S(2))*(n + S(1))), x) rule3629 = ReplacementRule(pattern3629, replacement3629) pattern3630 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons71, cons1439, cons1545, cons87, cons89, cons1553) def replacement3630(m, f, b, d, c, n, a, x, e): rubi.append(3630) return -Dist(S(1)/(a*(c**S(2) + d**S(2))*(n + S(1))), Int((a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**(n + S(1))*Simp(-a*c*(n + S(1)) + a*d*(m + n + S(1))/tan(e + f*x) + b*d*m, x), x), x) - Simp(d*(a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**(n + S(1))/(f*(c**S(2) + d**S(2))*(n + S(1))), x) rule3630 = ReplacementRule(pattern3630, replacement3630) pattern3631 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_/(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons71, cons1439, cons1545) def replacement3631(m, f, b, d, c, a, x, e): rubi.append(3631) return Dist(a/(a*c - b*d), Int((a + b*tan(e + f*x))**m, x), x) - Dist(d/(a*c - b*d), Int((a + b*tan(e + f*x))**m*(a*tan(e + f*x) + b)/(c + d*tan(e + f*x)), x), x) rule3631 = ReplacementRule(pattern3631, replacement3631) pattern3632 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_/(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons71, cons1439, cons1545) def replacement3632(m, f, b, d, c, a, x, e): rubi.append(3632) return Dist(a/(a*c - b*d), Int((a + b/tan(e + f*x))**m, x), x) - Dist(d/(a*c - b*d), Int((a + b/tan(e + f*x))**m*(a/tan(e + f*x) + b)/(c + d/tan(e + f*x)), x), x) rule3632 = ReplacementRule(pattern3632, replacement3632) pattern3633 = Pattern(Integral(sqrt(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545) def replacement3633(f, b, d, c, a, x, e): rubi.append(3633) return Dist(d/a, Int(sqrt(a + b*tan(e + f*x))*(a*tan(e + f*x) + b)/sqrt(c + d*tan(e + f*x)), x), x) + Dist((a*c - b*d)/a, Int(sqrt(a + b*tan(e + f*x))/sqrt(c + d*tan(e + f*x)), x), x) rule3633 = ReplacementRule(pattern3633, replacement3633) pattern3634 = Pattern(Integral(sqrt(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1439, cons1545) def replacement3634(f, b, d, c, a, x, e): rubi.append(3634) return Dist(d/a, Int(sqrt(a + b/tan(e + f*x))*(a/tan(e + f*x) + b)/sqrt(c + d/tan(e + f*x)), x), x) + Dist((a*c - b*d)/a, Int(sqrt(a + b/tan(e + f*x))/sqrt(c + d/tan(e + f*x)), x), x) rule3634 = ReplacementRule(pattern3634, replacement3634) pattern3635 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons71, cons1439, cons1545) def replacement3635(m, f, b, d, c, a, n, x, e): rubi.append(3635) return Dist(a*b/f, Subst(Int((a + x)**(m + S(-1))*(c + d*x/b)**n/(a*x + b**S(2)), x), x, b*tan(e + f*x)), x) rule3635 = ReplacementRule(pattern3635, replacement3635) pattern3636 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons71, cons1439, cons1545) def replacement3636(m, f, b, d, c, a, n, x, e): rubi.append(3636) return -Dist(a*b/f, Subst(Int((a + x)**(m + S(-1))*(c + d*x/b)**n/(a*x + b**S(2)), x), x, b/tan(e + f*x)), x) rule3636 = ReplacementRule(pattern3636, replacement3636) pattern3637 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440, cons1545, cons93, cons1333, cons89, cons515) def replacement3637(m, f, b, d, c, a, n, x, e): rubi.append(3637) return -Dist(S(1)/(d*(c**S(2) + d**S(2))*(n + S(1))), Int((a + b*tan(e + f*x))**(m + S(-3))*(c + d*tan(e + f*x))**(n + S(1))*Simp(a**S(2)*d*(-a*c*(n + S(1)) + b*d*(m + S(-2))) + b*(-S(2)*a*d + b*c)*(a*d*(n + S(1)) + b*c*(m + S(-2))) - b*(a*d*(-a*d + S(2)*b*c)*(m + n + S(-1)) - b**S(2)*(c**S(2)*(m + S(-2)) - d**S(2)*(n + S(1))))*tan(e + f*x)**S(2) - d*(n + S(1))*(-a**S(3)*d + S(3)*a**S(2)*b*c + S(3)*a*b**S(2)*d - b**S(3)*c)*tan(e + f*x), x), x), x) + Simp((a + b*tan(e + f*x))**(m + S(-2))*(c + d*tan(e + f*x))**(n + S(1))*(-a*d + b*c)**S(2)/(d*f*(c**S(2) + d**S(2))*(n + S(1))), x) rule3637 = ReplacementRule(pattern3637, replacement3637) pattern3638 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440, cons1545, cons93, cons1333, cons89, cons515) def replacement3638(m, f, b, d, c, a, n, x, e): rubi.append(3638) return -Dist(S(1)/(d*(c**S(2) + d**S(2))*(n + S(1))), Int((a + b/tan(e + f*x))**(m + S(-3))*(c + d/tan(e + f*x))**(n + S(1))*Simp(a**S(2)*d*(-a*c*(n + S(1)) + b*d*(m + S(-2))) + b*(-S(2)*a*d + b*c)*(a*d*(n + S(1)) + b*c*(m + S(-2))) - b*(a*d*(-a*d + S(2)*b*c)*(m + n + S(-1)) - b**S(2)*(c**S(2)*(m + S(-2)) - d**S(2)*(n + S(1))))/tan(e + f*x)**S(2) - d*(n + S(1))*(-a**S(3)*d + S(3)*a**S(2)*b*c + S(3)*a*b**S(2)*d - b**S(3)*c)/tan(e + f*x), x), x), x) - Simp((a + b/tan(e + f*x))**(m + S(-2))*(c + d/tan(e + f*x))**(n + S(1))*(-a*d + b*c)**S(2)/(d*f*(c**S(2) + d**S(2))*(n + S(1))), x) rule3638 = ReplacementRule(pattern3638, replacement3638) pattern3639 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons71, cons1440, cons1545, cons515, cons1333, cons1554, cons1555) def replacement3639(m, f, b, d, c, a, n, x, e): rubi.append(3639) return Dist(S(1)/(d*(m + n + S(-1))), Int((a + b*tan(e + f*x))**(m + S(-3))*(c + d*tan(e + f*x))**n*Simp(a**S(3)*d*(m + n + S(-1)) - b**S(2)*(a*d*(n + S(1)) + b*c*(m + S(-2))) - b**S(2)*(-a*d*(S(3)*m + S(2)*n + S(-4)) + b*c*(m + S(-2)))*tan(e + f*x)**S(2) + b*d*(S(3)*a**S(2) - b**S(2))*(m + n + S(-1))*tan(e + f*x), x), x), x) + Simp(b**S(2)*(a + b*tan(e + f*x))**(m + S(-2))*(c + d*tan(e + f*x))**(n + S(1))/(d*f*(m + n + S(-1))), x) rule3639 = ReplacementRule(pattern3639, replacement3639) pattern3640 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons71, cons1440, cons1545, cons515, cons1333, cons1554, cons1555) def replacement3640(m, f, b, d, c, a, n, x, e): rubi.append(3640) return Dist(S(1)/(d*(m + n + S(-1))), Int((a + b/tan(e + f*x))**(m + S(-3))*(c + d/tan(e + f*x))**n*Simp(a**S(3)*d*(m + n + S(-1)) - b**S(2)*(a*d*(n + S(1)) + b*c*(m + S(-2))) - b**S(2)*(-a*d*(S(3)*m + S(2)*n + S(-4)) + b*c*(m + S(-2)))/tan(e + f*x)**S(2) + b*d*(S(3)*a**S(2) - b**S(2))*(m + n + S(-1))/tan(e + f*x), x), x), x) - Simp(b**S(2)*(a + b/tan(e + f*x))**(m + S(-2))*(c + d/tan(e + f*x))**(n + S(1))/(d*f*(m + n + S(-1))), x) rule3640 = ReplacementRule(pattern3640, replacement3640) pattern3641 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440, cons1545, cons93, cons94, cons1336, cons515) def replacement3641(m, f, b, d, c, a, n, x, e): rubi.append(3641) return Dist(S(1)/((a**S(2) + b**S(2))*(m + S(1))), Int((a + b*tan(e + f*x))**(m + S(1))*(c + d*tan(e + f*x))**(n + S(-2))*Simp(a*c**S(2)*(m + S(1)) + a*d**S(2)*(n + S(-1)) + b*c*d*(m - n + S(2)) - d*(m + n)*(-a*d + b*c)*tan(e + f*x)**S(2) - (m + S(1))*(-S(2)*a*c*d + b*c**S(2) - b*d**S(2))*tan(e + f*x), x), x), x) + Simp((a + b*tan(e + f*x))**(m + S(1))*(c + d*tan(e + f*x))**(n + S(-1))*(-a*d + b*c)/(f*(a**S(2) + b**S(2))*(m + S(1))), x) rule3641 = ReplacementRule(pattern3641, replacement3641) pattern3642 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440, cons1545, cons93, cons94, cons1336, cons515) def replacement3642(m, f, b, d, c, a, n, x, e): rubi.append(3642) return Dist(S(1)/((a**S(2) + b**S(2))*(m + S(1))), Int((a + b/tan(e + f*x))**(m + S(1))*(c + d/tan(e + f*x))**(n + S(-2))*Simp(a*c**S(2)*(m + S(1)) + a*d**S(2)*(n + S(-1)) + b*c*d*(m - n + S(2)) - d*(m + n)*(-a*d + b*c)/tan(e + f*x)**S(2) - (m + S(1))*(-S(2)*a*c*d + b*c**S(2) - b*d**S(2))/tan(e + f*x), x), x), x) - Simp((a + b/tan(e + f*x))**(m + S(1))*(c + d/tan(e + f*x))**(n + S(-1))*(-a*d + b*c)/(f*(a**S(2) + b**S(2))*(m + S(1))), x) rule3642 = ReplacementRule(pattern3642, replacement3642) pattern3643 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440, cons1545, cons93, cons94, cons88, cons515) def replacement3643(m, f, b, d, c, a, n, x, e): rubi.append(3643) return Dist(S(1)/((a**S(2) + b**S(2))*(m + S(1))), Int((a + b*tan(e + f*x))**(m + S(1))*(c + d*tan(e + f*x))**(n + S(-1))*Simp(a*c*(m + S(1)) - b*d*n - b*d*(m + n + S(1))*tan(e + f*x)**S(2) - (m + S(1))*(-a*d + b*c)*tan(e + f*x), x), x), x) + Simp(b*(a + b*tan(e + f*x))**(m + S(1))*(c + d*tan(e + f*x))**n/(f*(a**S(2) + b**S(2))*(m + S(1))), x) rule3643 = ReplacementRule(pattern3643, replacement3643) pattern3644 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440, cons1545, cons93, cons94, cons88, cons515) def replacement3644(m, f, b, d, c, a, n, x, e): rubi.append(3644) return Dist(S(1)/((a**S(2) + b**S(2))*(m + S(1))), Int((a + b/tan(e + f*x))**(m + S(1))*(c + d/tan(e + f*x))**(n + S(-1))*Simp(a*c*(m + S(1)) - b*d*n - b*d*(m + n + S(1))/tan(e + f*x)**S(2) - (m + S(1))*(-a*d + b*c)/tan(e + f*x), x), x), x) - Simp(b*(a + b/tan(e + f*x))**(m + S(1))*(c + d/tan(e + f*x))**n/(f*(a**S(2) + b**S(2))*(m + S(1))), x) rule3644 = ReplacementRule(pattern3644, replacement3644) pattern3645 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons71, cons1440, cons1545, cons515, cons94, cons1556, cons1557) def replacement3645(m, f, b, d, c, a, n, x, e): rubi.append(3645) return Dist(S(1)/((a**S(2) + b**S(2))*(m + S(1))*(-a*d + b*c)), Int((a + b*tan(e + f*x))**(m + S(1))*(c + d*tan(e + f*x))**n*Simp(a*(m + S(1))*(-a*d + b*c) - b**S(2)*d*(m + n + S(2))*tan(e + f*x)**S(2) - b**S(2)*d*(m + n + S(2)) - b*(m + S(1))*(-a*d + b*c)*tan(e + f*x), x), x), x) + Simp(b**S(2)*(a + b*tan(e + f*x))**(m + S(1))*(c + d*tan(e + f*x))**(n + S(1))/(f*(a**S(2) + b**S(2))*(m + S(1))*(-a*d + b*c)), x) rule3645 = ReplacementRule(pattern3645, replacement3645) pattern3646 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons71, cons1440, cons1545, cons515, cons94, cons1556, cons1557) def replacement3646(m, f, b, d, c, a, n, x, e): rubi.append(3646) return Dist(S(1)/((a**S(2) + b**S(2))*(m + S(1))*(-a*d + b*c)), Int((a + b/tan(e + f*x))**(m + S(1))*(c + d/tan(e + f*x))**n*Simp(a*(m + S(1))*(-a*d + b*c) - b**S(2)*d*(m + n + S(2)) - b**S(2)*d*(m + n + S(2))/tan(e + f*x)**S(2) - b*(m + S(1))*(-a*d + b*c)/tan(e + f*x), x), x), x) - Simp(b**S(2)*(a + b/tan(e + f*x))**(m + S(1))*(c + d/tan(e + f*x))**(n + S(1))/(f*(a**S(2) + b**S(2))*(m + S(1))*(-a*d + b*c)), x) rule3646 = ReplacementRule(pattern3646, replacement3646) pattern3647 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440, cons1545, cons93, cons166, cons88, cons808) def replacement3647(m, f, b, d, c, a, n, x, e): rubi.append(3647) return Dist(S(1)/(m + n + S(-1)), Int((a + b*tan(e + f*x))**(m + S(-2))*(c + d*tan(e + f*x))**(n + S(-1))*Simp(a**S(2)*c*(m + n + S(-1)) - b*(a*d*n + b*c*(m + S(-1))) + b*(a*d*(S(2)*m + n + S(-2)) + b*c*n)*tan(e + f*x)**S(2) + (m + n + S(-1))*(a**S(2)*d + S(2)*a*b*c - b**S(2)*d)*tan(e + f*x), x), x), x) + Simp(b*(a + b*tan(e + f*x))**(m + S(-1))*(c + d*tan(e + f*x))**n/(f*(m + n + S(-1))), x) rule3647 = ReplacementRule(pattern3647, replacement3647) pattern3648 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440, cons1545, cons93, cons166, cons88, cons808) def replacement3648(m, f, b, d, c, a, n, x, e): rubi.append(3648) return Dist(S(1)/(m + n + S(-1)), Int((a + b/tan(e + f*x))**(m + S(-2))*(c + d/tan(e + f*x))**(n + S(-1))*Simp(a**S(2)*c*(m + n + S(-1)) - b*(a*d*n + b*c*(m + S(-1))) + b*(a*d*(S(2)*m + n + S(-2)) + b*c*n)/tan(e + f*x)**S(2) + (m + n + S(-1))*(a**S(2)*d + S(2)*a*b*c - b**S(2)*d)/tan(e + f*x), x), x), x) - Simp(b*(a + b/tan(e + f*x))**(m + S(-1))*(c + d/tan(e + f*x))**n/(f*(m + n + S(-1))), x) rule3648 = ReplacementRule(pattern3648, replacement3648) pattern3649 = Pattern(Integral(S(1)/((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440, cons1545) def replacement3649(f, b, d, c, a, x, e): rubi.append(3649) return Dist(b**S(2)/((a**S(2) + b**S(2))*(-a*d + b*c)), Int((-a*tan(e + f*x) + b)/(a + b*tan(e + f*x)), x), x) - Dist(d**S(2)/((c**S(2) + d**S(2))*(-a*d + b*c)), Int((-c*tan(e + f*x) + d)/(c + d*tan(e + f*x)), x), x) + Simp(x*(a*c - b*d)/((a**S(2) + b**S(2))*(c**S(2) + d**S(2))), x) rule3649 = ReplacementRule(pattern3649, replacement3649) pattern3650 = Pattern(Integral(S(1)/((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440, cons1545) def replacement3650(f, b, d, c, a, x, e): rubi.append(3650) return Dist(b**S(2)/((a**S(2) + b**S(2))*(-a*d + b*c)), Int((-a/tan(e + f*x) + b)/(a + b/tan(e + f*x)), x), x) - Dist(d**S(2)/((c**S(2) + d**S(2))*(-a*d + b*c)), Int((-c/tan(e + f*x) + d)/(c + d/tan(e + f*x)), x), x) + Simp(x*(a*c - b*d)/((a**S(2) + b**S(2))*(c**S(2) + d**S(2))), x) rule3650 = ReplacementRule(pattern3650, replacement3650) pattern3651 = Pattern(Integral(sqrt(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))/(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons71, cons1440, cons1545) def replacement3651(f, b, d, c, a, x, e): rubi.append(3651) return -Dist(d*(-a*d + b*c)/(c**S(2) + d**S(2)), Int((tan(e + f*x)**S(2) + S(1))/(sqrt(a + b*tan(e + f*x))*(c + d*tan(e + f*x))), x), x) + Dist(S(1)/(c**S(2) + d**S(2)), Int(Simp(a*c + b*d + (-a*d + b*c)*tan(e + f*x), x)/sqrt(a + b*tan(e + f*x)), x), x) rule3651 = ReplacementRule(pattern3651, replacement3651) pattern3652 = Pattern(Integral(sqrt(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))/(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons71, cons1440, cons1545) def replacement3652(f, b, d, c, a, x, e): rubi.append(3652) return -Dist(d*(-a*d + b*c)/(c**S(2) + d**S(2)), Int((S(1) + tan(e + f*x)**(S(-2)))/(sqrt(a + b/tan(e + f*x))*(c + d/tan(e + f*x))), x), x) + Dist(S(1)/(c**S(2) + d**S(2)), Int(Simp(a*c + b*d + (-a*d + b*c)/tan(e + f*x), x)/sqrt(a + b/tan(e + f*x)), x), x) rule3652 = ReplacementRule(pattern3652, replacement3652) pattern3653 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)/(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440, cons1545) def replacement3653(f, b, d, c, a, x, e): rubi.append(3653) return Dist((-a*d + b*c)**S(2)/(c**S(2) + d**S(2)), Int((tan(e + f*x)**S(2) + S(1))/(sqrt(a + b*tan(e + f*x))*(c + d*tan(e + f*x))), x), x) + Dist(S(1)/(c**S(2) + d**S(2)), Int(Simp(a**S(2)*c + S(2)*a*b*d - b**S(2)*c + (-a**S(2)*d + S(2)*a*b*c + b**S(2)*d)*tan(e + f*x), x)/sqrt(a + b*tan(e + f*x)), x), x) rule3653 = ReplacementRule(pattern3653, replacement3653) pattern3654 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**(S(3)/2)/(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons71, cons1440, cons1545) def replacement3654(f, b, d, c, a, x, e): rubi.append(3654) return Dist((-a*d + b*c)**S(2)/(c**S(2) + d**S(2)), Int((S(1) + tan(e + f*x)**(S(-2)))/(sqrt(a + b/tan(e + f*x))*(c + d/tan(e + f*x))), x), x) + Dist(S(1)/(c**S(2) + d**S(2)), Int(Simp(a**S(2)*c + S(2)*a*b*d - b**S(2)*c + (-a**S(2)*d + S(2)*a*b*c + b**S(2)*d)/tan(e + f*x), x)/sqrt(a + b/tan(e + f*x)), x), x) rule3654 = ReplacementRule(pattern3654, replacement3654) pattern3655 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_/(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons71, cons1440, cons1545, cons18) def replacement3655(m, f, b, d, c, a, x, e): rubi.append(3655) return Dist(d**S(2)/(c**S(2) + d**S(2)), Int((a + b*tan(e + f*x))**m*(tan(e + f*x)**S(2) + S(1))/(c + d*tan(e + f*x)), x), x) + Dist(S(1)/(c**S(2) + d**S(2)), Int((a + b*tan(e + f*x))**m*(c - d*tan(e + f*x)), x), x) rule3655 = ReplacementRule(pattern3655, replacement3655) pattern3656 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_/(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons71, cons1440, cons1545, cons18) def replacement3656(m, f, b, d, c, a, x, e): rubi.append(3656) return Dist(d**S(2)/(c**S(2) + d**S(2)), Int((S(1) + tan(e + f*x)**(S(-2)))*(a + b/tan(e + f*x))**m/(c + d/tan(e + f*x)), x), x) + Dist(S(1)/(c**S(2) + d**S(2)), Int((a + b/tan(e + f*x))**m*(c - d/tan(e + f*x)), x), x) rule3656 = ReplacementRule(pattern3656, replacement3656) pattern3657 = Pattern(Integral((c_ + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons71, cons1440, cons1545) def replacement3657(m, f, b, d, a, c, n, x, e): rubi.append(3657) return Dist(b/f, Subst(Int((a + x)**m*(c + d*x/b)**n/(b**S(2) + x**S(2)), x), x, b*tan(e + f*x)), x) rule3657 = ReplacementRule(pattern3657, replacement3657) pattern3658 = Pattern(Integral((c_ + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons71, cons1440, cons1545) def replacement3658(m, f, b, d, a, c, n, x, e): rubi.append(3658) return -Dist(b/f, Subst(Int((a + x)**m*(c + d*x/b)**n/(b**S(2) + x**S(2)), x), x, b/tan(e + f*x)), x) rule3658 = ReplacementRule(pattern3658, replacement3658) pattern3659 = Pattern(Integral((WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons27, cons48, cons125, cons4, cons23, cons17) def replacement3659(m, f, b, d, a, n, x, e): rubi.append(3659) return Dist(d**m, Int((d/tan(e + f*x))**(-m + n)*(a/tan(e + f*x) + b)**m, x), x) rule3659 = ReplacementRule(pattern3659, replacement3659) pattern3660 = Pattern(Integral((WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons27, cons48, cons125, cons4, cons23, cons17) def replacement3660(m, f, b, d, a, n, x, e): rubi.append(3660) return Dist(d**m, Int((d*tan(e + f*x))**(-m + n)*(a*tan(e + f*x) + b)**m, x), x) rule3660 = ReplacementRule(pattern3660, replacement3660) pattern3661 = Pattern(Integral(((WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**p_*WC('c', S(1)))**n_*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons23, cons18) def replacement3661(p, m, f, b, d, c, a, n, x, e): rubi.append(3661) return Dist(c**IntPart(n)*(c*(d*tan(e + f*x))**p)**FracPart(n)*(d*tan(e + f*x))**(-p*FracPart(n)), Int((d*tan(e + f*x))**(n*p)*(a + b*tan(e + f*x))**m, x), x) rule3661 = ReplacementRule(pattern3661, replacement3661) pattern3662 = Pattern(Integral(((WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**p_*WC('c', S(1)))**n_*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons23, cons18) def replacement3662(p, m, f, b, d, a, c, n, x, e): rubi.append(3662) return Dist(c**IntPart(n)*(c*(d/tan(e + f*x))**p)**FracPart(n)*(d/tan(e + f*x))**(-p*FracPart(n)), Int((d/tan(e + f*x))**(n*p)*(a + b/tan(e + f*x))**m, x), x) rule3662 = ReplacementRule(pattern3662, replacement3662) pattern3663 = Pattern(Integral((WC('g', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons380) def replacement3663(p, m, f, g, b, d, a, c, n, x, e): rubi.append(3663) return Int((g*tan(e + f*x))**p*(a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**n, x) rule3663 = ReplacementRule(pattern3663, replacement3663) pattern3664 = Pattern(Integral((WC('g', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons380) def replacement3664(p, m, f, b, g, d, a, c, n, x, e): rubi.append(3664) return Int((g/tan(e + f*x))**p*(a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**n, x) rule3664 = ReplacementRule(pattern3664, replacement3664) pattern3665 = Pattern(Integral((WC('g', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(c_ + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons5, cons147, cons17, cons85) def replacement3665(p, m, f, g, b, d, a, n, c, x, e): rubi.append(3665) return Dist(g**(m + n), Int((g/tan(e + f*x))**(-m - n + p)*(a/tan(e + f*x) + b)**m*(c/tan(e + f*x) + d)**n, x), x) rule3665 = ReplacementRule(pattern3665, replacement3665) pattern3666 = Pattern(Integral((WC('g', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(c_ + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons5, cons147, cons17, cons85) def replacement3666(p, m, f, b, g, d, a, n, c, x, e): rubi.append(3666) return Dist(g**(m + n), Int((g*tan(e + f*x))**(-m - n + p)*(a*tan(e + f*x) + b)**m*(c*tan(e + f*x) + d)**n, x), x) rule3666 = ReplacementRule(pattern3666, replacement3666) pattern3667 = Pattern(Integral((WC('g', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**q_)**p_*(c_ + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons50, cons147, cons1417) def replacement3667(p, m, f, g, b, d, a, n, c, x, q, e): rubi.append(3667) return Dist((g*tan(e + f*x))**(-p*q)*(g*tan(e + f*x)**q)**p, Int((g*tan(e + f*x))**(p*q)*(a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**n, x), x) rule3667 = ReplacementRule(pattern3667, replacement3667) pattern3668 = Pattern(Integral(((S(1)/tan(x_*WC('f', S(1)) + WC('e', S(0))))**q_*WC('g', S(1)))**p_*(c_ + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons50, cons147, cons1417) def replacement3668(p, m, f, b, g, d, a, n, c, x, q, e): rubi.append(3668) return Dist((g*(S(1)/tan(e + f*x))**q)**p*(g/tan(e + f*x))**(-p*q), Int((g/tan(e + f*x))**(p*q)*(a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**n, x), x) rule3668 = ReplacementRule(pattern3668, replacement3668) pattern3669 = Pattern(Integral((WC('g', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons85) def replacement3669(p, m, g, f, b, d, c, n, a, x, e): rubi.append(3669) return Dist(g**n, Int((g*tan(e + f*x))**(-n + p)*(a + b*tan(e + f*x))**m*(c*tan(e + f*x) + d)**n, x), x) rule3669 = ReplacementRule(pattern3669, replacement3669) pattern3670 = Pattern(Integral((WC('g', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons5, cons85) def replacement3670(p, m, f, b, g, d, a, n, c, x, e): rubi.append(3670) return Dist(g**n, Int((g/tan(e + f*x))**(-n + p)*(a + b/tan(e + f*x))**m*(c/tan(e + f*x) + d)**n, x), x) rule3670 = ReplacementRule(pattern3670, replacement3670) pattern3671 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*tan(x_*WC('f', S(1)) + WC('e', S(0)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons23, cons17, cons38) def replacement3671(p, m, f, b, d, c, n, a, x, e): rubi.append(3671) return Int((c + d/tan(e + f*x))**n*(a/tan(e + f*x) + b)**m*(S(1)/tan(e + f*x))**(-m - p), x) rule3671 = ReplacementRule(pattern3671, replacement3671) pattern3672 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(S(1)/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons23, cons17, cons38) def replacement3672(p, m, f, b, d, a, c, n, x, e): rubi.append(3672) return Int((c + d*tan(e + f*x))**n*(a*tan(e + f*x) + b)**m*tan(e + f*x)**(-m - p), x) rule3672 = ReplacementRule(pattern3672, replacement3672) pattern3673 = Pattern(Integral((WC('g', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons5, cons23, cons17, cons147) def replacement3673(p, m, f, b, g, d, c, n, a, x, e): rubi.append(3673) return Dist((g*tan(e + f*x))**p*(S(1)/tan(e + f*x))**p, Int((c + d/tan(e + f*x))**n*(a/tan(e + f*x) + b)**m*(S(1)/tan(e + f*x))**(-m - p), x), x) rule3673 = ReplacementRule(pattern3673, replacement3673) pattern3674 = Pattern(Integral((WC('g', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**p_*(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons4, cons5, cons23, cons17, cons147) def replacement3674(p, m, f, b, g, d, a, c, n, x, e): rubi.append(3674) return Dist((g/tan(e + f*x))**p*tan(e + f*x)**p, Int((c + d*tan(e + f*x))**n*(a*tan(e + f*x) + b)**m*tan(e + f*x)**(-m - p), x), x) rule3674 = ReplacementRule(pattern3674, replacement3674) pattern3675 = Pattern(Integral((WC('g', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons23, cons18) def replacement3675(p, m, f, g, b, d, c, n, a, x, e): rubi.append(3675) return Dist((g*tan(e + f*x))**n*(c + d/tan(e + f*x))**n*(c*tan(e + f*x) + d)**(-n), Int((g*tan(e + f*x))**(-n + p)*(a + b*tan(e + f*x))**m*(c*tan(e + f*x) + d)**n, x), x) rule3675 = ReplacementRule(pattern3675, replacement3675) pattern3676 = Pattern(Integral((WC('g', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('p', S(1))*(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(c_ + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons208, cons21, cons4, cons5, cons23, cons18) def replacement3676(p, m, f, b, g, d, a, c, n, x, e): rubi.append(3676) return Dist((g/tan(e + f*x))**n*(c + d*tan(e + f*x))**n*(c/tan(e + f*x) + d)**(-n), Int((g/tan(e + f*x))**(-n + p)*(a + b/tan(e + f*x))**m*(c/tan(e + f*x) + d)**n, x), x) rule3676 = ReplacementRule(pattern3676, replacement3676) pattern3677 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons4, cons70, cons1439) def replacement3677(B, e, m, f, b, d, a, n, c, x, A): rubi.append(3677) return Dist(a*c/f, Subst(Int((A + B*x)*(a + b*x)**(m + S(-1))*(c + d*x)**(n + S(-1)), x), x, tan(e + f*x)), x) rule3677 = ReplacementRule(pattern3677, replacement3677) pattern3678 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(c_ + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons4, cons70, cons1439) def replacement3678(B, m, f, b, d, a, n, c, A, x, e): rubi.append(3678) return -Dist(a*c/f, Subst(Int((A + B*x)*(a + b*x)**(m + S(-1))*(c + d*x)**(n + S(-1)), x), x, S(1)/tan(e + f*x)), x) rule3678 = ReplacementRule(pattern3678, replacement3678) pattern3679 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))/(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71) def replacement3679(B, e, f, b, d, a, c, x, A): rubi.append(3679) return Dist(S(1)/b, Int(Simp(A*b*c + (A*b*d + B*(-a*d + b*c))*tan(e + f*x), x)/(a + b*tan(e + f*x)), x), x) + Dist(B*d/b, Int(tan(e + f*x), x), x) rule3679 = ReplacementRule(pattern3679, replacement3679) pattern3680 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))/(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71) def replacement3680(B, e, f, b, d, a, c, x, A): rubi.append(3680) return Dist(S(1)/b, Int(Simp(A*b*c + (A*b*d + B*(-a*d + b*c))/tan(e + f*x), x)/(a + b/tan(e + f*x)), x), x) + Dist(B*d/b, Int(S(1)/tan(e + f*x), x), x) rule3680 = ReplacementRule(pattern3680, replacement3680) pattern3681 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons31, cons94, cons1439) def replacement3681(B, e, m, f, b, d, c, a, x, A): rubi.append(3681) return Dist(S(1)/(S(2)*a*b), Int((a + b*tan(e + f*x))**(m + S(1))*Simp(A*a*d + A*b*c + B*a*c + S(2)*B*a*d*tan(e + f*x) + B*b*d, x), x), x) - Simp((a + b*tan(e + f*x))**m*(A*b - B*a)*(a*c + b*d)/(S(2)*a**S(2)*f*m), x) rule3681 = ReplacementRule(pattern3681, replacement3681) pattern3682 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons31, cons94, cons1439) def replacement3682(B, m, f, b, d, c, a, A, x, e): rubi.append(3682) return Dist(S(1)/(S(2)*a*b), Int((a + b/tan(e + f*x))**(m + S(1))*Simp(A*a*d + A*b*c + B*a*c + S(2)*B*a*d/tan(e + f*x) + B*b*d, x), x), x) + Simp((a + b/tan(e + f*x))**m*(A*b - B*a)*(a*c + b*d)/(S(2)*a**S(2)*f*m), x) rule3682 = ReplacementRule(pattern3682, replacement3682) pattern3683 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons31, cons94, cons1440) def replacement3683(B, e, m, f, b, d, a, c, x, A): rubi.append(3683) return Dist(S(1)/(a**S(2) + b**S(2)), Int((a + b*tan(e + f*x))**(m + S(1))*Simp(A*a*c + A*b*d - B*a*d + B*b*c - (-A*a*d + A*b*c - B*a*c - B*b*d)*tan(e + f*x), x), x), x) + Simp((a + b*tan(e + f*x))**(m + S(1))*(A*b - B*a)*(-a*d + b*c)/(b*f*(a**S(2) + b**S(2))*(m + S(1))), x) rule3683 = ReplacementRule(pattern3683, replacement3683) pattern3684 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons31, cons94, cons1440) def replacement3684(B, e, m, f, b, d, a, c, x, A): rubi.append(3684) return Dist(S(1)/(a**S(2) + b**S(2)), Int((a + b/tan(e + f*x))**(m + S(1))*Simp(A*a*c + A*b*d - B*a*d + B*b*c - (-A*a*d + A*b*c - B*a*c - B*b*d)/tan(e + f*x), x), x), x) - Simp((a + b/tan(e + f*x))**(m + S(1))*(A*b - B*a)*(-a*d + b*c)/(b*f*(a**S(2) + b**S(2))*(m + S(1))), x) rule3684 = ReplacementRule(pattern3684, replacement3684) pattern3685 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons71, cons1549) def replacement3685(B, m, f, b, d, a, c, A, x, e): rubi.append(3685) return Int((a + b*tan(e + f*x))**m*Simp(A*c - B*d + (A*d + B*c)*tan(e + f*x), x), x) + Simp(B*d*(a + b*tan(e + f*x))**(m + S(1))/(b*f*(m + S(1))), x) rule3685 = ReplacementRule(pattern3685, replacement3685) pattern3686 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons71, cons1549) def replacement3686(B, m, f, b, d, a, c, A, x, e): rubi.append(3686) return Int((a + b/tan(e + f*x))**m*Simp(A*c - B*d + (A*d + B*c)/tan(e + f*x), x), x) - Simp(B*d*(a + b/tan(e + f*x))**(m + S(1))/(b*f*(m + S(1))), x) rule3686 = ReplacementRule(pattern3686, replacement3686) pattern3687 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1439, cons93, cons166, cons89) def replacement3687(B, e, m, f, b, d, c, a, n, x, A): rubi.append(3687) return -Dist(a/(d*(n + S(1))*(a*d + b*c)), Int((a + b*tan(e + f*x))**(m + S(-1))*(c + d*tan(e + f*x))**(n + S(1))*Simp(A*b*d*(m - n + S(-2)) - B*(a*d*(n + S(1)) + b*c*(m + S(-1))) + (A*a*d*(m + n) - B*(a*c*(m + S(-1)) + b*d*(n + S(1))))*tan(e + f*x), x), x), x) - Simp(a**S(2)*(a + b*tan(e + f*x))**(m + S(-1))*(c + d*tan(e + f*x))**(n + S(1))*(-A*d + B*c)/(d*f*(n + S(1))*(a*d + b*c)), x) rule3687 = ReplacementRule(pattern3687, replacement3687) pattern3688 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1439, cons93, cons166, cons89) def replacement3688(B, m, f, b, d, c, n, a, A, x, e): rubi.append(3688) return -Dist(a/(d*(n + S(1))*(a*d + b*c)), Int((a + b/tan(e + f*x))**(m + S(-1))*(c + d/tan(e + f*x))**(n + S(1))*Simp(A*b*d*(m - n + S(-2)) - B*(a*d*(n + S(1)) + b*c*(m + S(-1))) + (A*a*d*(m + n) - B*(a*c*(m + S(-1)) + b*d*(n + S(1))))/tan(e + f*x), x), x), x) + Simp(a**S(2)*(a + b/tan(e + f*x))**(m + S(-1))*(c + d/tan(e + f*x))**(n + S(1))*(-A*d + B*c)/(d*f*(n + S(1))*(a*d + b*c)), x) rule3688 = ReplacementRule(pattern3688, replacement3688) pattern3689 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons4, cons71, cons1439, cons31, cons166, cons346) def replacement3689(B, e, m, f, b, d, c, a, n, x, A): rubi.append(3689) return Dist(S(1)/(d*(m + n)), Int((a + b*tan(e + f*x))**(m + S(-1))*(c + d*tan(e + f*x))**n*Simp(A*a*d*(m + n) + B*(a*c*(m + S(-1)) - b*d*(n + S(1))) - (B*(m + S(-1))*(-a*d + b*c) - d*(m + n)*(A*b + B*a))*tan(e + f*x), x), x), x) + Simp(B*b*(a + b*tan(e + f*x))**(m + S(-1))*(c + d*tan(e + f*x))**(n + S(1))/(d*f*(m + n)), x) rule3689 = ReplacementRule(pattern3689, replacement3689) pattern3690 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons4, cons71, cons1439, cons31, cons166, cons346) def replacement3690(B, m, f, b, d, c, n, a, A, x, e): rubi.append(3690) return Dist(S(1)/(d*(m + n)), Int((a + b/tan(e + f*x))**(m + S(-1))*(c + d/tan(e + f*x))**n*Simp(A*a*d*(m + n) + B*(a*c*(m + S(-1)) - b*d*(n + S(1))) - (B*(m + S(-1))*(-a*d + b*c) - d*(m + n)*(A*b + B*a))/tan(e + f*x), x), x), x) - Simp(B*b*(a + b/tan(e + f*x))**(m + S(-1))*(c + d/tan(e + f*x))**(n + S(1))/(d*f*(m + n)), x) rule3690 = ReplacementRule(pattern3690, replacement3690) pattern3691 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1439, cons93, cons267, cons88) def replacement3691(B, e, m, f, b, d, c, a, n, x, A): rubi.append(3691) return Dist(S(1)/(S(2)*a**S(2)*m), Int((a + b*tan(e + f*x))**(m + S(1))*(c + d*tan(e + f*x))**(n + S(-1))*Simp(A*(a*c*m + b*d*n) - B*(a*d*n + b*c*m) - d*(-A*a*(m + n) + B*b*(m - n))*tan(e + f*x), x), x), x) - Simp((a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**n*(A*b - B*a)/(S(2)*a*f*m), x) rule3691 = ReplacementRule(pattern3691, replacement3691) pattern3692 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1439, cons93, cons267, cons88) def replacement3692(B, m, f, b, d, c, n, a, A, x, e): rubi.append(3692) return Dist(S(1)/(S(2)*a**S(2)*m), Int((a + b/tan(e + f*x))**(m + S(1))*(c + d/tan(e + f*x))**(n + S(-1))*Simp(A*(a*c*m + b*d*n) - B*(a*d*n + b*c*m) - d*(-A*a*(m + n) + B*b*(m - n))/tan(e + f*x), x), x), x) + Simp((a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**n*(A*b - B*a)/(S(2)*a*f*m), x) rule3692 = ReplacementRule(pattern3692, replacement3692) pattern3693 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons4, cons71, cons1439, cons31, cons267, cons1327) def replacement3693(B, e, m, f, b, d, c, a, n, x, A): rubi.append(3693) return Dist(S(1)/(S(2)*a*m*(-a*d + b*c)), Int((a + b*tan(e + f*x))**(m + S(1))*(c + d*tan(e + f*x))**n*Simp(A*(-a*d*(S(2)*m + n + S(1)) + b*c*m) + B*(a*c*m - b*d*(n + S(1))) + d*(A*b - B*a)*(m + n + S(1))*tan(e + f*x), x), x), x) + Simp((a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**(n + S(1))*(A*a + B*b)/(S(2)*f*m*(-a*d + b*c)), x) rule3693 = ReplacementRule(pattern3693, replacement3693) pattern3694 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons4, cons71, cons1439, cons31, cons267, cons1327) def replacement3694(B, m, f, b, d, c, n, a, A, x, e): rubi.append(3694) return Dist(S(1)/(S(2)*a*m*(-a*d + b*c)), Int((a + b/tan(e + f*x))**(m + S(1))*(c + d/tan(e + f*x))**n*Simp(A*(-a*d*(S(2)*m + n + S(1)) + b*c*m) + B*(a*c*m - b*d*(n + S(1))) + d*(A*b - B*a)*(m + n + S(1))/tan(e + f*x), x), x), x) - Simp((a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**(n + S(1))*(A*a + B*b)/(S(2)*f*m*(-a*d + b*c)), x) rule3694 = ReplacementRule(pattern3694, replacement3694) pattern3695 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons71, cons1439, cons87, cons88) def replacement3695(B, e, m, f, b, d, c, a, n, x, A): rubi.append(3695) return Dist(S(1)/(a*(m + n)), Int((a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**(n + S(-1))*Simp(A*a*c*(m + n) - B*(a*d*n + b*c*m) + (A*a*d*(m + n) - B*(-a*c*n + b*d*m))*tan(e + f*x), x), x), x) + Simp(B*(a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**n/(f*(m + n)), x) rule3695 = ReplacementRule(pattern3695, replacement3695) pattern3696 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons71, cons1439, cons87, cons88) def replacement3696(B, m, f, b, d, c, n, a, A, x, e): rubi.append(3696) return Dist(S(1)/(a*(m + n)), Int((a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**(n + S(-1))*Simp(A*a*c*(m + n) - B*(a*d*n + b*c*m) + (A*a*d*(m + n) - B*(-a*c*n + b*d*m))/tan(e + f*x), x), x), x) - Simp(B*(a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**n/(f*(m + n)), x) rule3696 = ReplacementRule(pattern3696, replacement3696) pattern3697 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons71, cons1439, cons87, cons89) def replacement3697(B, e, m, f, b, d, c, a, n, x, A): rubi.append(3697) return -Dist(S(1)/(a*(c**S(2) + d**S(2))*(n + S(1))), Int((a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**(n + S(1))*Simp(A*(-a*c*(n + S(1)) + b*d*m) - B*(a*d*(n + S(1)) + b*c*m) - a*(-A*d + B*c)*(m + n + S(1))*tan(e + f*x), x), x), x) + Simp((a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**(n + S(1))*(A*d - B*c)/(f*(c**S(2) + d**S(2))*(n + S(1))), x) rule3697 = ReplacementRule(pattern3697, replacement3697) pattern3698 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons71, cons1439, cons87, cons89) def replacement3698(B, m, f, b, d, c, n, a, A, x, e): rubi.append(3698) return -Dist(S(1)/(a*(c**S(2) + d**S(2))*(n + S(1))), Int((a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**(n + S(1))*Simp(A*(-a*c*(n + S(1)) + b*d*m) - B*(a*d*(n + S(1)) + b*c*m) - a*(-A*d + B*c)*(m + n + S(1))/tan(e + f*x), x), x), x) - Simp((a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**(n + S(1))*(A*d - B*c)/(f*(c**S(2) + d**S(2))*(n + S(1))), x) rule3698 = ReplacementRule(pattern3698, replacement3698) pattern3699 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons4, cons71, cons1439, cons1418) def replacement3699(B, e, m, f, b, d, c, a, n, x, A): rubi.append(3699) return Dist(B*b/f, Subst(Int((a + b*x)**(m + S(-1))*(c + d*x)**n, x), x, tan(e + f*x)), x) rule3699 = ReplacementRule(pattern3699, replacement3699) pattern3700 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons4, cons71, cons1439, cons1418) def replacement3700(B, m, f, b, d, c, n, a, A, x, e): rubi.append(3700) return -Dist(B*b/f, Subst(Int((a + b*x)**(m + S(-1))*(c + d*x)**n, x), x, S(1)/tan(e + f*x)), x) rule3700 = ReplacementRule(pattern3700, replacement3700) pattern3701 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))/(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons71, cons1439, cons1426) def replacement3701(B, e, m, f, b, d, c, a, x, A): rubi.append(3701) return Dist((A*b + B*a)/(a*d + b*c), Int((a + b*tan(e + f*x))**m, x), x) - Dist((-A*d + B*c)/(a*d + b*c), Int((a - b*tan(e + f*x))*(a + b*tan(e + f*x))**m/(c + d*tan(e + f*x)), x), x) rule3701 = ReplacementRule(pattern3701, replacement3701) pattern3702 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))/(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons71, cons1439, cons1426) def replacement3702(B, m, f, b, d, c, a, A, x, e): rubi.append(3702) return Dist((A*b + B*a)/(a*d + b*c), Int((a + b/tan(e + f*x))**m, x), x) - Dist((-A*d + B*c)/(a*d + b*c), Int((a - b/tan(e + f*x))*(a + b/tan(e + f*x))**m/(c + d/tan(e + f*x)), x), x) rule3702 = ReplacementRule(pattern3702, replacement3702) pattern3703 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons4, cons71, cons1439, cons1426) def replacement3703(B, e, m, f, b, d, c, a, n, x, A): rubi.append(3703) return -Dist(B/b, Int((a - b*tan(e + f*x))*(a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**n, x), x) + Dist((A*b + B*a)/b, Int((a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**n, x), x) rule3703 = ReplacementRule(pattern3703, replacement3703) pattern3704 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons4, cons71, cons1439, cons1426) def replacement3704(B, m, f, b, d, c, n, a, A, x, e): rubi.append(3704) return -Dist(B/b, Int((a - b/tan(e + f*x))*(a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**n, x), x) + Dist((A*b + B*a)/b, Int((a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**n, x), x) rule3704 = ReplacementRule(pattern3704, replacement3704) pattern3705 = Pattern(Integral((A_ + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons4, cons71, cons1440, cons18, cons23, cons1513, cons1558) def replacement3705(B, m, f, b, d, a, c, n, A, x, e): rubi.append(3705) return Dist(A**S(2)/f, Subst(Int((a + b*x)**m*(c + d*x)**n/(A - B*x), x), x, tan(e + f*x)), x) rule3705 = ReplacementRule(pattern3705, replacement3705) pattern3706 = Pattern(Integral((A_ + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons4, cons71, cons1440, cons18, cons23, cons1513, cons1558) def replacement3706(B, m, f, b, d, c, a, n, A, x, e): rubi.append(3706) return -Dist(A**S(2)/f, Subst(Int((a + b*x)**m*(c + d*x)**n/(A - B*x), x), x, S(1)/tan(e + f*x)), x) rule3706 = ReplacementRule(pattern3706, replacement3706) pattern3707 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons4, cons71, cons1440, cons18, cons23, cons1513, cons1559) def replacement3707(B, e, m, f, b, d, a, c, n, x, A): rubi.append(3707) return Dist(A/S(2) - I*B/S(2), Int((a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**n*(I*tan(e + f*x) + S(1)), x), x) + Dist(A/S(2) + I*B/S(2), Int((a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**n*(-I*tan(e + f*x) + S(1)), x), x) rule3707 = ReplacementRule(pattern3707, replacement3707) pattern3708 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons4, cons71, cons1440, cons18, cons23, cons1513, cons1559) def replacement3708(B, e, m, f, b, d, a, c, n, x, A): rubi.append(3708) return Dist(A/S(2) - I*B/S(2), Int((S(1) + I/tan(e + f*x))*(a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**n, x), x) + Dist(A/S(2) + I*B/S(2), Int((S(1) - I/tan(e + f*x))*(a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**n, x), x) rule3708 = ReplacementRule(pattern3708, replacement3708) pattern3709 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1440, cons1545, cons93, cons166, cons89, cons1334) def replacement3709(B, e, m, f, b, d, a, c, n, x, A): rubi.append(3709) return -Dist(S(1)/(d*(c**S(2) + d**S(2))*(n + S(1))), Int((a + b*tan(e + f*x))**(m + S(-2))*(c + d*tan(e + f*x))**(n + S(1))*Simp(A*a*d*(-a*c*(n + S(1)) + b*d*(m + S(-1))) - b*(-B*b*(c**S(2)*(m + S(-1)) - d**S(2)*(n + S(1))) + d*(m + n)*(-A*a*d + A*b*c + B*a*c))*tan(e + f*x)**S(2) - d*(n + S(1))*((A*a - B*b)*(-a*d + b*c) + (A*b + B*a)*(a*c + b*d))*tan(e + f*x) + (B*b*c - d*(A*b + B*a))*(a*d*(n + S(1)) + b*c*(m + S(-1))), x), x), x) + Simp((a + b*tan(e + f*x))**(m + S(-1))*(c + d*tan(e + f*x))**(n + S(1))*(-A*d + B*c)*(-a*d + b*c)/(d*f*(c**S(2) + d**S(2))*(n + S(1))), x) rule3709 = ReplacementRule(pattern3709, replacement3709) pattern3710 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1440, cons1545, cons93, cons166, cons89, cons1334) def replacement3710(B, e, m, f, b, d, a, c, n, x, A): rubi.append(3710) return -Dist(S(1)/(d*(c**S(2) + d**S(2))*(n + S(1))), Int((a + b/tan(e + f*x))**(m + S(-2))*(c + d/tan(e + f*x))**(n + S(1))*Simp(A*a*d*(-a*c*(n + S(1)) + b*d*(m + S(-1))) - b*(-B*b*(c**S(2)*(m + S(-1)) - d**S(2)*(n + S(1))) + d*(m + n)*(-A*a*d + A*b*c + B*a*c))/tan(e + f*x)**S(2) - d*(n + S(1))*((A*a - B*b)*(-a*d + b*c) + (A*b + B*a)*(a*c + b*d))/tan(e + f*x) + (B*b*c - d*(A*b + B*a))*(a*d*(n + S(1)) + b*c*(m + S(-1))), x), x), x) - Simp((a + b/tan(e + f*x))**(m + S(-1))*(c + d/tan(e + f*x))**(n + S(1))*(-A*d + B*c)*(-a*d + b*c)/(d*f*(c**S(2) + d**S(2))*(n + S(1))), x) rule3710 = ReplacementRule(pattern3710, replacement3710) pattern3711 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons4, cons71, cons1440, cons1545, cons31, cons166, cons1334, cons1560) def replacement3711(B, e, m, f, b, d, a, c, n, x, A): rubi.append(3711) return Dist(S(1)/(d*(m + n)), Int((a + b*tan(e + f*x))**(m + S(-2))*(c + d*tan(e + f*x))**n*Simp(A*a**S(2)*d*(m + n) - B*b*(a*d*(n + S(1)) + b*c*(m + S(-1))) + d*(m + n)*(S(2)*A*a*b + B*(a**S(2) - b**S(2)))*tan(e + f*x) - (B*b*(m + S(-1))*(-a*d + b*c) - b*d*(m + n)*(A*b + B*a))*tan(e + f*x)**S(2), x), x), x) + Simp(B*b*(a + b*tan(e + f*x))**(m + S(-1))*(c + d*tan(e + f*x))**(n + S(1))/(d*f*(m + n)), x) rule3711 = ReplacementRule(pattern3711, replacement3711) pattern3712 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons4, cons71, cons1440, cons1545, cons31, cons166, cons1334, cons1560) def replacement3712(B, e, m, f, b, d, a, c, n, x, A): rubi.append(3712) return Dist(S(1)/(d*(m + n)), Int((a + b/tan(e + f*x))**(m + S(-2))*(c + d/tan(e + f*x))**n*Simp(A*a**S(2)*d*(m + n) - B*b*(a*d*(n + S(1)) + b*c*(m + S(-1))) + d*(m + n)*(S(2)*A*a*b + B*(a**S(2) - b**S(2)))/tan(e + f*x) - (B*b*(m + S(-1))*(-a*d + b*c) - b*d*(m + n)*(A*b + B*a))/tan(e + f*x)**S(2), x), x), x) - Simp(B*b*(a + b/tan(e + f*x))**(m + S(-1))*(c + d/tan(e + f*x))**(n + S(1))/(d*f*(m + n)), x) rule3712 = ReplacementRule(pattern3712, replacement3712) pattern3713 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1440, cons1545, cons93, cons94, cons1325, cons1334) def replacement3713(B, e, m, f, b, d, a, c, n, x, A): rubi.append(3713) return Dist(S(1)/(b*(a**S(2) + b**S(2))*(m + S(1))), Int((a + b*tan(e + f*x))**(m + S(1))*(c + d*tan(e + f*x))**(n + S(-1))*Simp(A*b*(a*c*(m + S(1)) - b*d*n) + B*b*(a*d*n + b*c*(m + S(1))) - b*d*(A*b - B*a)*(m + n + S(1))*tan(e + f*x)**S(2) - b*(m + S(1))*(A*(-a*d + b*c) - B*(a*c + b*d))*tan(e + f*x), x), x), x) + Simp((a + b*tan(e + f*x))**(m + S(1))*(c + d*tan(e + f*x))**n*(A*b - B*a)/(f*(a**S(2) + b**S(2))*(m + S(1))), x) rule3713 = ReplacementRule(pattern3713, replacement3713) pattern3714 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1440, cons1545, cons93, cons94, cons1325, cons1334) def replacement3714(B, e, m, f, b, d, a, c, n, x, A): rubi.append(3714) return Dist(S(1)/(b*(a**S(2) + b**S(2))*(m + S(1))), Int((a + b/tan(e + f*x))**(m + S(1))*(c + d/tan(e + f*x))**(n + S(-1))*Simp(A*b*(a*c*(m + S(1)) - b*d*n) + B*b*(a*d*n + b*c*(m + S(1))) - b*d*(A*b - B*a)*(m + n + S(1))/tan(e + f*x)**S(2) - b*(m + S(1))*(A*(-a*d + b*c) - B*(a*c + b*d))/tan(e + f*x), x), x), x) - Simp((a + b/tan(e + f*x))**(m + S(1))*(c + d/tan(e + f*x))**n*(A*b - B*a)/(f*(a**S(2) + b**S(2))*(m + S(1))), x) rule3714 = ReplacementRule(pattern3714, replacement3714) pattern3715 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons4, cons71, cons1440, cons1545, cons31, cons94, cons1334, cons1557) def replacement3715(B, e, m, f, b, d, a, c, n, x, A): rubi.append(3715) return Dist(S(1)/((a**S(2) + b**S(2))*(m + S(1))*(-a*d + b*c)), Int((a + b*tan(e + f*x))**(m + S(1))*(c + d*tan(e + f*x))**n*Simp(A*(a*(m + S(1))*(-a*d + b*c) - b**S(2)*d*(m + n + S(2))) + B*b*(a*d*(n + S(1)) + b*c*(m + S(1))) - b*d*(A*b - B*a)*(m + n + S(2))*tan(e + f*x)**S(2) - (m + S(1))*(A*b - B*a)*(-a*d + b*c)*tan(e + f*x), x), x), x) + Simp(b*(a + b*tan(e + f*x))**(m + S(1))*(c + d*tan(e + f*x))**(n + S(1))*(A*b - B*a)/(f*(a**S(2) + b**S(2))*(m + S(1))*(-a*d + b*c)), x) rule3715 = ReplacementRule(pattern3715, replacement3715) pattern3716 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons4, cons71, cons1440, cons1545, cons31, cons94, cons1334, cons1557) def replacement3716(B, e, m, f, b, d, a, c, n, x, A): rubi.append(3716) return Dist(S(1)/((a**S(2) + b**S(2))*(m + S(1))*(-a*d + b*c)), Int((a + b/tan(e + f*x))**(m + S(1))*(c + d/tan(e + f*x))**n*Simp(A*(a*(m + S(1))*(-a*d + b*c) - b**S(2)*d*(m + n + S(2))) + B*b*(a*d*(n + S(1)) + b*c*(m + S(1))) - b*d*(A*b - B*a)*(m + n + S(2))/tan(e + f*x)**S(2) - (m + S(1))*(A*b - B*a)*(-a*d + b*c)/tan(e + f*x), x), x), x) - Simp(b*(a + b/tan(e + f*x))**(m + S(1))*(c + d/tan(e + f*x))**(n + S(1))*(A*b - B*a)/(f*(a**S(2) + b**S(2))*(m + S(1))*(-a*d + b*c)), x) rule3716 = ReplacementRule(pattern3716, replacement3716) pattern3717 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1440, cons1545, cons93, cons1256, cons1325) def replacement3717(B, e, m, f, b, d, a, c, n, x, A): rubi.append(3717) return Dist(S(1)/(m + n), Int((a + b*tan(e + f*x))**(m + S(-1))*(c + d*tan(e + f*x))**(n + S(-1))*Simp(A*a*c*(m + n) - B*(a*d*n + b*c*m) + (m + n)*(A*a*d + A*b*c + B*a*c - B*b*d)*tan(e + f*x) + (A*b*d*(m + n) + B*(a*d*m + b*c*n))*tan(e + f*x)**S(2), x), x), x) + Simp(B*(a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**n/(f*(m + n)), x) rule3717 = ReplacementRule(pattern3717, replacement3717) pattern3718 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1440, cons1545, cons93, cons1256, cons1325) def replacement3718(B, e, m, f, b, d, a, c, n, x, A): rubi.append(3718) return Dist(S(1)/(m + n), Int((a + b/tan(e + f*x))**(m + S(-1))*(c + d/tan(e + f*x))**(n + S(-1))*Simp(A*a*c*(m + n) - B*(a*d*n + b*c*m) + (m + n)*(A*a*d + A*b*c + B*a*c - B*b*d)/tan(e + f*x) + (A*b*d*(m + n) + B*(a*d*m + b*c*n))/tan(e + f*x)**S(2), x), x), x) - Simp(B*(a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**n/(f*(m + n)), x) rule3718 = ReplacementRule(pattern3718, replacement3718) pattern3719 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))/((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1440, cons1545) def replacement3719(B, e, f, b, d, c, a, x, A): rubi.append(3719) return Dist(b*(A*b - B*a)/((a**S(2) + b**S(2))*(-a*d + b*c)), Int((-a*tan(e + f*x) + b)/(a + b*tan(e + f*x)), x), x) + Dist(d*(-A*d + B*c)/((c**S(2) + d**S(2))*(-a*d + b*c)), Int((-c*tan(e + f*x) + d)/(c + d*tan(e + f*x)), x), x) + Simp(x*(A*(a*c - b*d) + B*(a*d + b*c))/((a**S(2) + b**S(2))*(c**S(2) + d**S(2))), x) rule3719 = ReplacementRule(pattern3719, replacement3719) pattern3720 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))/((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1440, cons1545) def replacement3720(B, f, b, d, c, a, A, x, e): rubi.append(3720) return Dist(b*(A*b - B*a)/((a**S(2) + b**S(2))*(-a*d + b*c)), Int((-a/tan(e + f*x) + b)/(a + b/tan(e + f*x)), x), x) + Dist(d*(-A*d + B*c)/((c**S(2) + d**S(2))*(-a*d + b*c)), Int((-c/tan(e + f*x) + d)/(c + d/tan(e + f*x)), x), x) + Simp(x*(A*(a*c - b*d) + B*(a*d + b*c))/((a**S(2) + b**S(2))*(c**S(2) + d**S(2))), x) rule3720 = ReplacementRule(pattern3720, replacement3720) pattern3721 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))/(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1440, cons1545) def replacement3721(B, e, f, b, d, a, c, x, A): rubi.append(3721) return -Dist((-A*b + B*a)*(-a*d + b*c)/(a**S(2) + b**S(2)), Int((tan(e + f*x)**S(2) + S(1))/((a + b*tan(e + f*x))*sqrt(c + d*tan(e + f*x))), x), x) + Dist(S(1)/(a**S(2) + b**S(2)), Int(Simp(A*(a*c + b*d) + B*(-a*d + b*c) - (A*(-a*d + b*c) - B*(a*c + b*d))*tan(e + f*x), x)/sqrt(c + d*tan(e + f*x)), x), x) rule3721 = ReplacementRule(pattern3721, replacement3721) pattern3722 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))/(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1440, cons1545) def replacement3722(B, e, f, b, d, a, c, x, A): rubi.append(3722) return -Dist((-A*b + B*a)*(-a*d + b*c)/(a**S(2) + b**S(2)), Int((S(1) + tan(e + f*x)**(S(-2)))/((a + b/tan(e + f*x))*sqrt(c + d/tan(e + f*x))), x), x) + Dist(S(1)/(a**S(2) + b**S(2)), Int(Simp(A*(a*c + b*d) + B*(-a*d + b*c) - (A*(-a*d + b*c) - B*(a*c + b*d))/tan(e + f*x), x)/sqrt(c + d/tan(e + f*x)), x), x) rule3722 = ReplacementRule(pattern3722, replacement3722) pattern3723 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_/(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons4, cons71, cons1440, cons1545) def replacement3723(B, e, f, b, d, a, c, n, x, A): rubi.append(3723) return Dist(b*(A*b - B*a)/(a**S(2) + b**S(2)), Int((c + d*tan(e + f*x))**n*(tan(e + f*x)**S(2) + S(1))/(a + b*tan(e + f*x)), x), x) + Dist(S(1)/(a**S(2) + b**S(2)), Int((c + d*tan(e + f*x))**n*Simp(A*a + B*b - (A*b - B*a)*tan(e + f*x), x), x), x) rule3723 = ReplacementRule(pattern3723, replacement3723) pattern3724 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_/(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons4, cons71, cons1440, cons1545) def replacement3724(B, e, f, b, d, a, c, n, x, A): rubi.append(3724) return Dist(b*(A*b - B*a)/(a**S(2) + b**S(2)), Int((S(1) + tan(e + f*x)**(S(-2)))*(c + d/tan(e + f*x))**n/(a + b/tan(e + f*x)), x), x) + Dist(S(1)/(a**S(2) + b**S(2)), Int((c + d/tan(e + f*x))**n*Simp(A*a + B*b - (A*b - B*a)/tan(e + f*x), x), x), x) rule3724 = ReplacementRule(pattern3724, replacement3724) pattern3725 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1440, cons1545) def replacement3725(B, e, f, b, d, a, c, x, A): rubi.append(3725) return Dist(B*b, Int((tan(e + f*x)**S(2) + S(1))/(sqrt(a + b*tan(e + f*x))*sqrt(c + d*tan(e + f*x))), x), x) + Int(Simp(A*a - B*b + (A*b + B*a)*tan(e + f*x), x)/(sqrt(a + b*tan(e + f*x))*sqrt(c + d*tan(e + f*x))), x) rule3725 = ReplacementRule(pattern3725, replacement3725) pattern3726 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*sqrt(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))/sqrt(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons71, cons1440, cons1545) def replacement3726(B, e, f, b, d, a, c, x, A): rubi.append(3726) return Dist(B*b, Int((S(1) + tan(e + f*x)**(S(-2)))/(sqrt(a + b/tan(e + f*x))*sqrt(c + d/tan(e + f*x))), x), x) + Int(Simp(A*a - B*b + (A*b + B*a)/tan(e + f*x), x)/(sqrt(a + b/tan(e + f*x))*sqrt(c + d/tan(e + f*x))), x) rule3726 = ReplacementRule(pattern3726, replacement3726) pattern3727 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons4, cons71, cons1440, cons1558) def replacement3727(B, e, m, f, b, d, a, c, n, x, A): rubi.append(3727) return Dist(A**S(2)/f, Subst(Int((a + b*x)**m*(c + d*x)**n/(A - B*x), x), x, tan(e + f*x)), x) rule3727 = ReplacementRule(pattern3727, replacement3727) pattern3728 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons4, cons71, cons1440, cons1558) def replacement3728(B, e, m, f, b, d, a, c, n, x, A): rubi.append(3728) return -Dist(A**S(2)/f, Subst(Int((a + b*x)**m*(c + d*x)**n/(A - B*x), x), x, S(1)/tan(e + f*x)), x) rule3728 = ReplacementRule(pattern3728, replacement3728) pattern3729 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons4, cons71, cons1440, cons1559) def replacement3729(B, e, m, f, b, d, a, c, n, x, A): rubi.append(3729) return Dist(A/S(2) - I*B/S(2), Int((a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**n*(I*tan(e + f*x) + S(1)), x), x) + Dist(A/S(2) + I*B/S(2), Int((a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**n*(-I*tan(e + f*x) + S(1)), x), x) rule3729 = ReplacementRule(pattern3729, replacement3729) pattern3730 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons21, cons4, cons71, cons1440, cons1559) def replacement3730(B, e, m, f, b, d, a, c, n, x, A): rubi.append(3730) return Dist(A/S(2) - I*B/S(2), Int((S(1) + I/tan(e + f*x))*(a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**n, x), x) + Dist(A/S(2) + I*B/S(2), Int((S(1) - I/tan(e + f*x))*(a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**n, x), x) rule3730 = ReplacementRule(pattern3730, replacement3730) pattern3731 = Pattern(Integral((A_ + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons21, cons1561) def replacement3731(C, m, f, b, a, A, x, e): rubi.append(3731) return Dist(A/(b*f), Subst(Int((a + x)**m, x), x, b*tan(e + f*x)), x) rule3731 = ReplacementRule(pattern3731, replacement3731) pattern3732 = Pattern(Integral((A_ + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons21, cons1561) def replacement3732(C, m, f, b, a, A, x, e): rubi.append(3732) return -Dist(A/(b*f), Subst(Int((a + x)**m, x), x, b/tan(e + f*x)), x) rule3732 = ReplacementRule(pattern3732, replacement3732) pattern3733 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons21, cons33) def replacement3733(B, C, m, f, b, a, A, x, e): rubi.append(3733) return Dist(b**(S(-2)), Int((a + b*tan(e + f*x))**(m + S(1))*Simp(B*b - C*a + C*b*tan(e + f*x), x), x), x) rule3733 = ReplacementRule(pattern3733, replacement3733) pattern3734 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons21, cons33) def replacement3734(B, C, m, f, b, a, A, x, e): rubi.append(3734) return Dist(b**(S(-2)), Int((a + b/tan(e + f*x))**(m + S(1))*Simp(B*b - C*a + C*b/tan(e + f*x), x), x), x) rule3734 = ReplacementRule(pattern3734, replacement3734) pattern3735 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons21, cons1433) def replacement3735(C, m, f, b, a, A, x, e): rubi.append(3735) return -Dist(C/b**S(2), Int((a - b*tan(e + f*x))*(a + b*tan(e + f*x))**(m + S(1)), x), x) rule3735 = ReplacementRule(pattern3735, replacement3735) pattern3736 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons21, cons1433) def replacement3736(C, m, f, b, a, A, x, e): rubi.append(3736) return -Dist(C/b**S(2), Int((a - b/tan(e + f*x))*(a + b/tan(e + f*x))**(m + S(1)), x), x) rule3736 = ReplacementRule(pattern3736, replacement3736) pattern3737 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons1562, cons31, cons32, cons1439) def replacement3737(B, C, m, f, b, a, A, x, e): rubi.append(3737) return Dist(S(1)/(S(2)*a**S(2)*m), Int((a + b*tan(e + f*x))**(m + S(1))*Simp(A*a*(S(2)*m + S(1)) + B*b - C*a - (C*b*(m + S(-1)) + (m + S(1))*(A*b - B*a))*tan(e + f*x), x), x), x) - Simp((a + b*tan(e + f*x))**m*(A*a + B*b - C*a)*tan(e + f*x)/(S(2)*a*f*m), x) rule3737 = ReplacementRule(pattern3737, replacement3737) pattern3738 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons1562, cons31, cons32, cons1439) def replacement3738(B, C, m, f, b, a, A, x, e): rubi.append(3738) return Dist(S(1)/(S(2)*a**S(2)*m), Int((a + b/tan(e + f*x))**(m + S(1))*Simp(A*a*(S(2)*m + S(1)) + B*b - C*a - (C*b*(m + S(-1)) + (m + S(1))*(A*b - B*a))/tan(e + f*x), x), x), x) + Simp((a + b/tan(e + f*x))**m*(A*a + B*b - C*a)/(S(2)*a*f*m*tan(e + f*x)), x) rule3738 = ReplacementRule(pattern3738, replacement3738) pattern3739 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons1563, cons31, cons32, cons1439) def replacement3739(C, m, f, b, a, A, x, e): rubi.append(3739) return Dist(S(1)/(S(2)*a**S(2)*m), Int((a + b*tan(e + f*x))**(m + S(1))*Simp(A*a*(S(2)*m + S(1)) - C*a - (A*b*(m + S(1)) + C*b*(m + S(-1)))*tan(e + f*x), x), x), x) - Simp((a + b*tan(e + f*x))**m*(A*a - C*a)*tan(e + f*x)/(S(2)*a*f*m), x) rule3739 = ReplacementRule(pattern3739, replacement3739) pattern3740 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons1563, cons31, cons32, cons1439) def replacement3740(C, m, f, b, a, A, x, e): rubi.append(3740) return Dist(S(1)/(S(2)*a**S(2)*m), Int((a + b/tan(e + f*x))**(m + S(1))*Simp(A*a*(S(2)*m + S(1)) - C*a - (A*b*(m + S(1)) + C*b*(m + S(-1)))/tan(e + f*x), x), x), x) + Simp((a + b/tan(e + f*x))**m*(A*a - C*a)/(S(2)*a*f*m*tan(e + f*x)), x) rule3740 = ReplacementRule(pattern3740, replacement3740) pattern3741 = Pattern(Integral((A_ + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons1440, cons1564) def replacement3741(B, C, f, b, a, A, x, e): rubi.append(3741) return Dist((A*b**S(2) - B*a*b + C*a**S(2))/(a**S(2) + b**S(2)), Int((tan(e + f*x)**S(2) + S(1))/(a + b*tan(e + f*x)), x), x) + Simp(x*(A*a + B*b - C*a)/(a**S(2) + b**S(2)), x) rule3741 = ReplacementRule(pattern3741, replacement3741) pattern3742 = Pattern(Integral((A_ + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons1440, cons1564) def replacement3742(B, C, f, b, a, A, x, e): rubi.append(3742) return Dist((A*b**S(2) - B*a*b + C*a**S(2))/(a**S(2) + b**S(2)), Int((S(1) + tan(e + f*x)**(S(-2)))/(a + b/tan(e + f*x)), x), x) + Simp(x*(A*a + B*b - C*a)/(a**S(2) + b**S(2)), x) rule3742 = ReplacementRule(pattern3742, replacement3742) pattern3743 = Pattern(Integral((A_ + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/tan(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons48, cons125, cons34, cons35, cons36, cons1565) def replacement3743(B, C, f, A, x, e): rubi.append(3743) return Dist(A, Int(S(1)/tan(e + f*x), x), x) + Dist(C, Int(tan(e + f*x), x), x) + Simp(B*x, x) rule3743 = ReplacementRule(pattern3743, replacement3743) pattern3744 = Pattern(Integral((A_ + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*tan(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons48, cons125, cons34, cons35, cons36, cons1565) def replacement3744(B, C, f, A, x, e): rubi.append(3744) return Dist(A, Int(tan(e + f*x), x), x) + Dist(C, Int(S(1)/tan(e + f*x), x), x) + Simp(B*x, x) rule3744 = ReplacementRule(pattern3744, replacement3744) pattern3745 = Pattern(Integral((A_ + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/tan(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons48, cons125, cons34, cons36, cons1565) def replacement3745(C, e, f, x, A): rubi.append(3745) return Dist(A, Int(S(1)/tan(e + f*x), x), x) + Dist(C, Int(tan(e + f*x), x), x) rule3745 = ReplacementRule(pattern3745, replacement3745) pattern3746 = Pattern(Integral((A_ + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*tan(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons48, cons125, cons34, cons36, cons1565) def replacement3746(C, e, f, x, A): rubi.append(3746) return Dist(A, Int(tan(e + f*x), x), x) + Dist(C, Int(S(1)/tan(e + f*x), x), x) rule3746 = ReplacementRule(pattern3746, replacement3746) pattern3747 = Pattern(Integral((A_ + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons1562, cons1440, cons1566) def replacement3747(B, C, f, b, a, A, x, e): rubi.append(3747) return -Dist((A*b - B*a - C*b)/(a**S(2) + b**S(2)), Int(tan(e + f*x), x), x) + Dist((A*b**S(2) - B*a*b + C*a**S(2))/(a**S(2) + b**S(2)), Int((tan(e + f*x)**S(2) + S(1))/(a + b*tan(e + f*x)), x), x) + Simp(x*(A*a + B*b - C*a)/(a**S(2) + b**S(2)), x) rule3747 = ReplacementRule(pattern3747, replacement3747) pattern3748 = Pattern(Integral((A_ + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons1562, cons1440, cons1566) def replacement3748(B, C, f, b, a, A, x, e): rubi.append(3748) return -Dist((A*b - B*a - C*b)/(a**S(2) + b**S(2)), Int(S(1)/tan(e + f*x), x), x) + Dist((A*b**S(2) - B*a*b + C*a**S(2))/(a**S(2) + b**S(2)), Int((S(1) + tan(e + f*x)**(S(-2)))/(a + b/tan(e + f*x)), x), x) + Simp(x*(A*a + B*b - C*a)/(a**S(2) + b**S(2)), x) rule3748 = ReplacementRule(pattern3748, replacement3748) pattern3749 = Pattern(Integral((A_ + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons1563, cons1440, cons1565) def replacement3749(C, f, b, a, A, x, e): rubi.append(3749) return Dist((A*b**S(2) + C*a**S(2))/(a**S(2) + b**S(2)), Int((tan(e + f*x)**S(2) + S(1))/(a + b*tan(e + f*x)), x), x) - Dist(b*(A - C)/(a**S(2) + b**S(2)), Int(tan(e + f*x), x), x) + Simp(a*x*(A - C)/(a**S(2) + b**S(2)), x) rule3749 = ReplacementRule(pattern3749, replacement3749) pattern3750 = Pattern(Integral((A_ + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons1563, cons1440, cons1565) def replacement3750(C, f, b, a, A, x, e): rubi.append(3750) return Dist((A*b**S(2) + C*a**S(2))/(a**S(2) + b**S(2)), Int((S(1) + tan(e + f*x)**(S(-2)))/(a + b/tan(e + f*x)), x), x) - Dist(b*(A - C)/(a**S(2) + b**S(2)), Int(S(1)/tan(e + f*x), x), x) + Simp(a*x*(A - C)/(a**S(2) + b**S(2)), x) rule3750 = ReplacementRule(pattern3750, replacement3750) pattern3751 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons1562, cons31, cons94, cons1440) def replacement3751(B, C, e, m, f, b, a, x, A): rubi.append(3751) return Dist(S(1)/(a**S(2) + b**S(2)), Int((a + b*tan(e + f*x))**(m + S(1))*Simp(B*b + a*(A - C) - (A*b - B*a - C*b)*tan(e + f*x), x), x), x) + Simp((a + b*tan(e + f*x))**(m + S(1))*(A*b**S(2) - B*a*b + C*a**S(2))/(b*f*(a**S(2) + b**S(2))*(m + S(1))), x) rule3751 = ReplacementRule(pattern3751, replacement3751) pattern3752 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons1562, cons31, cons94, cons1440) def replacement3752(B, C, e, m, f, b, a, x, A): rubi.append(3752) return Dist(S(1)/(a**S(2) + b**S(2)), Int((a + b/tan(e + f*x))**(m + S(1))*Simp(B*b + a*(A - C) - (A*b - B*a - C*b)/tan(e + f*x), x), x), x) - Simp((a + b/tan(e + f*x))**(m + S(1))*(A*b**S(2) - B*a*b + C*a**S(2))/(b*f*(a**S(2) + b**S(2))*(m + S(1))), x) rule3752 = ReplacementRule(pattern3752, replacement3752) pattern3753 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons34, cons36, cons1563, cons31, cons94, cons1440) def replacement3753(C, e, m, f, b, a, x, A): rubi.append(3753) return Dist(S(1)/(a**S(2) + b**S(2)), Int((a + b*tan(e + f*x))**(m + S(1))*Simp(a*(A - C) - (A*b - C*b)*tan(e + f*x), x), x), x) + Simp((a + b*tan(e + f*x))**(m + S(1))*(A*b**S(2) + C*a**S(2))/(b*f*(a**S(2) + b**S(2))*(m + S(1))), x) rule3753 = ReplacementRule(pattern3753, replacement3753) pattern3754 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_, x_), cons2, cons3, cons48, cons125, cons34, cons36, cons1563, cons31, cons94, cons1440) def replacement3754(C, e, m, f, b, a, x, A): rubi.append(3754) return Dist(S(1)/(a**S(2) + b**S(2)), Int((a + b/tan(e + f*x))**(m + S(1))*Simp(a*(A - C) - (A*b - C*b)/tan(e + f*x), x), x), x) - Simp((a + b/tan(e + f*x))**(m + S(1))*(A*b**S(2) + C*a**S(2))/(b*f*(a**S(2) + b**S(2))*(m + S(1))), x) rule3754 = ReplacementRule(pattern3754, replacement3754) pattern3755 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons21, cons1562, cons1549) def replacement3755(B, C, m, f, b, a, A, x, e): rubi.append(3755) return Int((a + b*tan(e + f*x))**m*Simp(A + B*tan(e + f*x) - C, x), x) + Simp(C*(a + b*tan(e + f*x))**(m + S(1))/(b*f*(m + S(1))), x) rule3755 = ReplacementRule(pattern3755, replacement3755) pattern3756 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons48, cons125, cons34, cons35, cons36, cons21, cons1562, cons1549) def replacement3756(B, C, m, f, b, a, A, x, e): rubi.append(3756) return Int((a + b/tan(e + f*x))**m*Simp(A + B/tan(e + f*x) - C, x), x) - Simp(C*(a + b/tan(e + f*x))**(m + S(1))/(b*f*(m + S(1))), x) rule3756 = ReplacementRule(pattern3756, replacement3756) pattern3757 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons21, cons1563, cons1549) def replacement3757(C, m, f, b, a, A, x, e): rubi.append(3757) return Dist(A - C, Int((a + b*tan(e + f*x))**m, x), x) + Simp(C*(a + b*tan(e + f*x))**(m + S(1))/(b*f*(m + S(1))), x) rule3757 = ReplacementRule(pattern3757, replacement3757) pattern3758 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons48, cons125, cons34, cons36, cons21, cons1563, cons1549) def replacement3758(C, m, f, b, a, A, x, e): rubi.append(3758) return Dist(A - C, Int((a + b/tan(e + f*x))**m, x), x) - Simp(C*(a + b/tan(e + f*x))**(m + S(1))/(b*f*(m + S(1))), x) rule3758 = ReplacementRule(pattern3758, replacement3758) pattern3759 = Pattern(Integral((A_ + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons21, cons4, cons1561) def replacement3759(C, m, f, b, d, a, c, n, A, x, e): rubi.append(3759) return Dist(A/f, Subst(Int((a + b*x)**m*(c + d*x)**n, x), x, tan(e + f*x)), x) rule3759 = ReplacementRule(pattern3759, replacement3759) pattern3760 = Pattern(Integral((A_ + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons21, cons4, cons1561) def replacement3760(C, m, f, b, d, a, c, n, A, x, e): rubi.append(3760) return -Dist(A/f, Subst(Int((a + b*x)**m*(c + d*x)**n, x), x, S(1)/tan(e + f*x)), x) rule3760 = ReplacementRule(pattern3760, replacement3760) pattern3761 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons71, cons1545, cons87, cons89) def replacement3761(B, C, f, b, d, c, a, n, A, x, e): rubi.append(3761) return Dist(S(1)/(d*(c**S(2) + d**S(2))), Int((c + d*tan(e + f*x))**(n + S(1))*Simp(C*b*(c**S(2) + d**S(2))*tan(e + f*x)**S(2) + a*d*(A*c + B*d - C*c) + b*(A*d**S(2) - B*c*d + C*c**S(2)) + d*(-A*a*d + A*b*c + B*a*c + B*b*d + C*a*d - C*b*c)*tan(e + f*x), x), x), x) - Simp((c + d*tan(e + f*x))**(n + S(1))*(-a*d + b*c)*(A*d**S(2) - B*c*d + C*c**S(2))/(d**S(2)*f*(c**S(2) + d**S(2))*(n + S(1))), x) rule3761 = ReplacementRule(pattern3761, replacement3761) pattern3762 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons71, cons1545, cons87, cons89) def replacement3762(B, C, e, f, b, d, a, c, n, x, A): rubi.append(3762) return Dist(S(1)/(d*(c**S(2) + d**S(2))), Int((c + d/tan(e + f*x))**(n + S(1))*Simp(C*b*(c**S(2) + d**S(2))/tan(e + f*x)**S(2) + a*d*(A*c + B*d - C*c) + b*(A*d**S(2) - B*c*d + C*c**S(2)) + d*(-A*a*d + A*b*c + B*a*c + B*b*d + C*a*d - C*b*c)/tan(e + f*x), x), x), x) + Simp((c + d/tan(e + f*x))**(n + S(1))*(-a*d + b*c)*(A*d**S(2) - B*c*d + C*c**S(2))/(d**S(2)*f*(c**S(2) + d**S(2))*(n + S(1))), x) rule3762 = ReplacementRule(pattern3762, replacement3762) pattern3763 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons71, cons1545, cons87, cons89) def replacement3763(C, f, b, d, c, a, n, A, x, e): rubi.append(3763) return Dist(S(1)/(d*(c**S(2) + d**S(2))), Int((c + d*tan(e + f*x))**(n + S(1))*Simp(C*b*(c**S(2) + d**S(2))*tan(e + f*x)**S(2) + a*d*(A*c - C*c) + b*(A*d**S(2) + C*c**S(2)) + d*(-A*a*d + A*b*c + C*a*d - C*b*c)*tan(e + f*x), x), x), x) - Simp((c + d*tan(e + f*x))**(n + S(1))*(A*d**S(2) + C*c**S(2))*(-a*d + b*c)/(d**S(2)*f*(c**S(2) + d**S(2))*(n + S(1))), x) rule3763 = ReplacementRule(pattern3763, replacement3763) pattern3764 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons71, cons1545, cons87, cons89) def replacement3764(C, e, f, b, d, a, c, n, x, A): rubi.append(3764) return Dist(S(1)/(d*(c**S(2) + d**S(2))), Int((c + d/tan(e + f*x))**(n + S(1))*Simp(C*b*(c**S(2) + d**S(2))/tan(e + f*x)**S(2) + a*d*(A*c - C*c) + b*(A*d**S(2) + C*c**S(2)) + d*(-A*a*d + A*b*c + C*a*d - C*b*c)/tan(e + f*x), x), x), x) + Simp((c + d/tan(e + f*x))**(n + S(1))*(A*d**S(2) + C*c**S(2))*(-a*d + b*c)/(d**S(2)*f*(c**S(2) + d**S(2))*(n + S(1))), x) rule3764 = ReplacementRule(pattern3764, replacement3764) pattern3765 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons4, cons71, cons1545, cons346) def replacement3765(B, C, f, b, d, c, n, a, A, x, e): rubi.append(3765) return -Dist(S(1)/(d*(n + S(2))), Int((c + d*tan(e + f*x))**n*Simp(-A*a*d*(n + S(2)) + C*b*c - d*(n + S(2))*(A*b + B*a - C*b)*tan(e + f*x) - (C*a*d*(n + S(2)) - b*(-B*d*(n + S(2)) + C*c))*tan(e + f*x)**S(2), x), x), x) + Simp(C*b*(c + d*tan(e + f*x))**(n + S(1))*tan(e + f*x)/(d*f*(n + S(2))), x) rule3765 = ReplacementRule(pattern3765, replacement3765) pattern3766 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons4, cons71, cons1545, cons346) def replacement3766(B, C, f, b, d, c, n, a, A, x, e): rubi.append(3766) return -Dist(S(1)/(d*(n + S(2))), Int((c + d/tan(e + f*x))**n*Simp(-A*a*d*(n + S(2)) + C*b*c - d*(n + S(2))*(A*b + B*a - C*b)/tan(e + f*x) - (C*a*d*(n + S(2)) - b*(-B*d*(n + S(2)) + C*c))/tan(e + f*x)**S(2), x), x), x) - Simp(C*b*(c + d/tan(e + f*x))**(n + S(1))/(d*f*(n + S(2))*tan(e + f*x)), x) rule3766 = ReplacementRule(pattern3766, replacement3766) pattern3767 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('A', S(0)) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons4, cons71, cons1545, cons346) def replacement3767(C, f, b, d, c, n, a, A, x, e): rubi.append(3767) return -Dist(S(1)/(d*(n + S(2))), Int((c + d*tan(e + f*x))**n*Simp(-A*a*d*(n + S(2)) + C*b*c - d*(n + S(2))*(A*b - C*b)*tan(e + f*x) - (C*a*d*(n + S(2)) - C*b*c)*tan(e + f*x)**S(2), x), x), x) + Simp(C*b*(c + d*tan(e + f*x))**(n + S(1))*tan(e + f*x)/(d*f*(n + S(2))), x) rule3767 = ReplacementRule(pattern3767, replacement3767) pattern3768 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('A', S(0)) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons4, cons71, cons1545, cons346) def replacement3768(C, f, b, d, c, n, a, A, x, e): rubi.append(3768) return -Dist(S(1)/(d*(n + S(2))), Int((c + d/tan(e + f*x))**n*Simp(-A*a*d*(n + S(2)) + C*b*c - d*(n + S(2))*(A*b - C*b)/tan(e + f*x) - (C*a*d*(n + S(2)) - C*b*c)/tan(e + f*x)**S(2), x), x), x) - Simp(C*b*(c + d/tan(e + f*x))**(n + S(1))/(d*f*(n + S(2))*tan(e + f*x)), x) rule3768 = ReplacementRule(pattern3768, replacement3768) pattern3769 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons4, cons71, cons1439, cons1567) def replacement3769(B, C, m, f, b, d, c, n, a, A, x, e): rubi.append(3769) return Dist(S(1)/(S(2)*a*m*(-a*d + b*c)), Int((a + b*tan(e + f*x))**(m + S(1))*(c + d*tan(e + f*x))**n*Simp(a*(-A*d*(S(2)*m + n + S(1)) + B*c*m + C*d*(n + S(1))) + b*(-B*d*(n + S(1)) + c*m*(A + C)) + (A*b*d*(m + n + S(1)) + C*b*d*(m - n + S(-1)) + a*(-B*d*(m + n + S(1)) + S(2)*C*c*m))*tan(e + f*x), x), x), x) + Simp((a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**(n + S(1))*(A*a + B*b - C*a)/(S(2)*f*m*(-a*d + b*c)), x) rule3769 = ReplacementRule(pattern3769, replacement3769) pattern3770 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons4, cons71, cons1439, cons1567) def replacement3770(B, C, m, f, b, d, c, n, a, A, x, e): rubi.append(3770) return Dist(S(1)/(S(2)*a*m*(-a*d + b*c)), Int((a + b/tan(e + f*x))**(m + S(1))*(c + d/tan(e + f*x))**n*Simp(a*(-A*d*(S(2)*m + n + S(1)) + B*c*m + C*d*(n + S(1))) + b*(-B*d*(n + S(1)) + c*m*(A + C)) + (A*b*d*(m + n + S(1)) + C*b*d*(m - n + S(-1)) + a*(-B*d*(m + n + S(1)) + S(2)*C*c*m))/tan(e + f*x), x), x), x) - Simp((a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**(n + S(1))*(A*a + B*b - C*a)/(S(2)*f*m*(-a*d + b*c)), x) rule3770 = ReplacementRule(pattern3770, replacement3770) pattern3771 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons4, cons71, cons1439, cons1567) def replacement3771(C, m, f, b, d, c, n, a, A, x, e): rubi.append(3771) return Dist(S(1)/(S(2)*a*m*(-a*d + b*c)), Int((a + b*tan(e + f*x))**(m + S(1))*(c + d*tan(e + f*x))**n*Simp(a*(-A*d*(S(2)*m + n + S(1)) + C*d*(n + S(1))) + b*c*m*(A + C) + (A*b*d*(m + n + S(1)) + S(2)*C*a*c*m + C*b*d*(m - n + S(-1)))*tan(e + f*x), x), x), x) + Simp(a*(A - C)*(a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**(n + S(1))/(S(2)*f*m*(-a*d + b*c)), x) rule3771 = ReplacementRule(pattern3771, replacement3771) pattern3772 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('A', S(0)) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons4, cons71, cons1439, cons1567) def replacement3772(C, m, f, b, d, c, n, a, A, x, e): rubi.append(3772) return Dist(S(1)/(S(2)*a*m*(-a*d + b*c)), Int((a + b/tan(e + f*x))**(m + S(1))*(c + d/tan(e + f*x))**n*Simp(a*(-A*d*(S(2)*m + n + S(1)) + C*d*(n + S(1))) + b*c*m*(A + C) + (A*b*d*(m + n + S(1)) + S(2)*C*a*c*m + C*b*d*(m - n + S(-1)))/tan(e + f*x), x), x), x) - Simp(a*(A - C)*(a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**(n + S(1))/(S(2)*f*m*(-a*d + b*c)), x) rule3772 = ReplacementRule(pattern3772, replacement3772) pattern3773 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons21, cons71, cons1439, cons1303, cons87, cons89, cons1545) def replacement3773(B, C, m, f, b, d, c, a, n, A, x, e): rubi.append(3773) return -Dist(S(1)/(a*d*(c**S(2) + d**S(2))*(n + S(1))), Int((a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**(n + S(1))*Simp(-a*d*(n + S(1))*(A*c + B*d - C*c) - a*(-C*(c**S(2)*m - d**S(2)*(n + S(1))) + d*(-A*d + B*c)*(m + n + S(1)))*tan(e + f*x) + b*m*(A*d**S(2) - B*c*d + C*c**S(2)), x), x), x) + Simp((a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**(n + S(1))*(A*d**S(2) - B*c*d + C*c**S(2))/(d*f*(c**S(2) + d**S(2))*(n + S(1))), x) rule3773 = ReplacementRule(pattern3773, replacement3773) pattern3774 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons21, cons71, cons1439, cons1303, cons87, cons89, cons1545) def replacement3774(B, C, m, f, b, d, c, n, a, A, x, e): rubi.append(3774) return -Dist(S(1)/(a*d*(c**S(2) + d**S(2))*(n + S(1))), Int((a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**(n + S(1))*Simp(-a*d*(n + S(1))*(A*c + B*d - C*c) - a*(-C*(c**S(2)*m - d**S(2)*(n + S(1))) + d*(-A*d + B*c)*(m + n + S(1)))/tan(e + f*x) + b*m*(A*d**S(2) - B*c*d + C*c**S(2)), x), x), x) - Simp((a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**(n + S(1))*(A*d**S(2) - B*c*d + C*c**S(2))/(d*f*(c**S(2) + d**S(2))*(n + S(1))), x) rule3774 = ReplacementRule(pattern3774, replacement3774) pattern3775 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons21, cons71, cons1439, cons1303, cons87, cons89, cons1545) def replacement3775(C, m, f, b, d, c, a, n, A, x, e): rubi.append(3775) return -Dist(S(1)/(a*d*(c**S(2) + d**S(2))*(n + S(1))), Int((a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**(n + S(1))*Simp(-a*d*(n + S(1))*(A*c - C*c) - a*(-A*d**S(2)*(m + n + S(1)) - C*(c**S(2)*m - d**S(2)*(n + S(1))))*tan(e + f*x) + b*m*(A*d**S(2) + C*c**S(2)), x), x), x) + Simp((a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**(n + S(1))*(A*d**S(2) + C*c**S(2))/(d*f*(c**S(2) + d**S(2))*(n + S(1))), x) rule3775 = ReplacementRule(pattern3775, replacement3775) pattern3776 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons21, cons71, cons1439, cons1303, cons87, cons89, cons1545) def replacement3776(C, m, f, b, d, c, n, a, A, x, e): rubi.append(3776) return -Dist(S(1)/(a*d*(c**S(2) + d**S(2))*(n + S(1))), Int((a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**(n + S(1))*Simp(-a*d*(n + S(1))*(A*c - C*c) - a*(-A*d**S(2)*(m + n + S(1)) - C*(c**S(2)*m - d**S(2)*(n + S(1))))/tan(e + f*x) + b*m*(A*d**S(2) + C*c**S(2)), x), x), x) - Simp((a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**(n + S(1))*(A*d**S(2) + C*c**S(2))/(d*f*(c**S(2) + d**S(2))*(n + S(1))), x) rule3776 = ReplacementRule(pattern3776, replacement3776) pattern3777 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons21, cons4, cons71, cons1439, cons1303, cons683) def replacement3777(B, C, m, f, b, d, c, n, a, A, x, e): rubi.append(3777) return Dist(S(1)/(b*d*(m + n + S(1))), Int((a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**n*Simp(A*b*d*(m + n + S(1)) + C*(a*c*m - b*d*(n + S(1))) - (-B*b*d*(m + n + S(1)) + C*m*(-a*d + b*c))*tan(e + f*x), x), x), x) + Simp(C*(a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**(n + S(1))/(d*f*(m + n + S(1))), x) rule3777 = ReplacementRule(pattern3777, replacement3777) pattern3778 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons21, cons4, cons71, cons1439, cons1303, cons683) def replacement3778(B, C, m, f, b, d, c, n, a, A, x, e): rubi.append(3778) return Dist(S(1)/(b*d*(m + n + S(1))), Int((a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**n*Simp(A*b*d*(m + n + S(1)) + C*(a*c*m - b*d*(n + S(1))) - (-B*b*d*(m + n + S(1)) + C*m*(-a*d + b*c))/tan(e + f*x), x), x), x) - Simp(C*(a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**(n + S(1))/(d*f*(m + n + S(1))), x) rule3778 = ReplacementRule(pattern3778, replacement3778) pattern3779 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons21, cons4, cons71, cons1439, cons1303, cons683) def replacement3779(C, m, f, b, d, c, n, a, A, x, e): rubi.append(3779) return Dist(S(1)/(b*d*(m + n + S(1))), Int((a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**n*Simp(A*b*d*(m + n + S(1)) - C*m*(-a*d + b*c)*tan(e + f*x) + C*(a*c*m - b*d*(n + S(1))), x), x), x) + Simp(C*(a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**(n + S(1))/(d*f*(m + n + S(1))), x) rule3779 = ReplacementRule(pattern3779, replacement3779) pattern3780 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('A', S(0)) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons21, cons4, cons71, cons1439, cons1303, cons683) def replacement3780(C, m, f, b, d, c, n, a, A, x, e): rubi.append(3780) return Dist(S(1)/(b*d*(m + n + S(1))), Int((a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**n*Simp(A*b*d*(m + n + S(1)) - C*m*(-a*d + b*c)/tan(e + f*x) + C*(a*c*m - b*d*(n + S(1))), x), x), x) - Simp(C*(a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**(n + S(1))/(d*f*(m + n + S(1))), x) rule3780 = ReplacementRule(pattern3780, replacement3780) pattern3781 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons71, cons1440, cons1545, cons93, cons168, cons89) def replacement3781(B, C, m, f, b, d, c, a, n, A, x, e): rubi.append(3781) return -Dist(S(1)/(d*(c**S(2) + d**S(2))*(n + S(1))), Int((a + b*tan(e + f*x))**(m + S(-1))*(c + d*tan(e + f*x))**(n + S(1))*Simp(A*d*(-a*c*(n + S(1)) + b*d*m) - b*(-C*(c**S(2)*m - d**S(2)*(n + S(1))) + d*(-A*d + B*c)*(m + n + S(1)))*tan(e + f*x)**S(2) - d*(n + S(1))*(B*(a*c + b*d) + (A - C)*(-a*d + b*c))*tan(e + f*x) + (-B*d + C*c)*(a*d*(n + S(1)) + b*c*m), x), x), x) + Simp((a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**(n + S(1))*(A*d**S(2) + c*(-B*d + C*c))/(d*f*(c**S(2) + d**S(2))*(n + S(1))), x) rule3781 = ReplacementRule(pattern3781, replacement3781) pattern3782 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons71, cons1440, cons1545, cons93, cons168, cons89) def replacement3782(B, C, e, m, f, b, d, a, c, n, x, A): rubi.append(3782) return -Dist(S(1)/(d*(c**S(2) + d**S(2))*(n + S(1))), Int((a + b/tan(e + f*x))**(m + S(-1))*(c + d/tan(e + f*x))**(n + S(1))*Simp(A*d*(-a*c*(n + S(1)) + b*d*m) - b*(-C*(c**S(2)*m - d**S(2)*(n + S(1))) + d*(-A*d + B*c)*(m + n + S(1)))/tan(e + f*x)**S(2) - d*(n + S(1))*(B*(a*c + b*d) + (A - C)*(-a*d + b*c))/tan(e + f*x) + (-B*d + C*c)*(a*d*(n + S(1)) + b*c*m), x), x), x) - Simp((a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**(n + S(1))*(A*d**S(2) + c*(-B*d + C*c))/(d*f*(c**S(2) + d**S(2))*(n + S(1))), x) rule3782 = ReplacementRule(pattern3782, replacement3782) pattern3783 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons71, cons1440, cons1545, cons93, cons168, cons89) def replacement3783(C, m, f, b, d, c, a, n, A, x, e): rubi.append(3783) return -Dist(S(1)/(d*(c**S(2) + d**S(2))*(n + S(1))), Int((a + b*tan(e + f*x))**(m + S(-1))*(c + d*tan(e + f*x))**(n + S(1))*Simp(A*d*(-a*c*(n + S(1)) + b*d*m) + C*c*(a*d*(n + S(1)) + b*c*m) + b*(A*d**S(2)*(m + n + S(1)) + C*(c**S(2)*m - d**S(2)*(n + S(1))))*tan(e + f*x)**S(2) - d*(A - C)*(n + S(1))*(-a*d + b*c)*tan(e + f*x), x), x), x) + Simp((a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**(n + S(1))*(A*d**S(2) + C*c**S(2))/(d*f*(c**S(2) + d**S(2))*(n + S(1))), x) rule3783 = ReplacementRule(pattern3783, replacement3783) pattern3784 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons71, cons1440, cons1545, cons93, cons168, cons89) def replacement3784(C, e, m, f, b, d, a, c, n, x, A): rubi.append(3784) return -Dist(S(1)/(d*(c**S(2) + d**S(2))*(n + S(1))), Int((a + b/tan(e + f*x))**(m + S(-1))*(c + d/tan(e + f*x))**(n + S(1))*Simp(A*d*(-a*c*(n + S(1)) + b*d*m) + C*c*(a*d*(n + S(1)) + b*c*m) + b*(A*d**S(2)*(m + n + S(1)) + C*(c**S(2)*m - d**S(2)*(n + S(1))))/tan(e + f*x)**S(2) - d*(A - C)*(n + S(1))*(-a*d + b*c)/tan(e + f*x), x), x), x) - Simp((a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**(n + S(1))*(A*d**S(2) + C*c**S(2))/(d*f*(c**S(2) + d**S(2))*(n + S(1))), x) rule3784 = ReplacementRule(pattern3784, replacement3784) pattern3785 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons4, cons71, cons1440, cons1545, cons31, cons168, cons1568) def replacement3785(B, C, m, f, b, d, a, c, n, A, x, e): rubi.append(3785) return Dist(S(1)/(d*(m + n + S(1))), Int((a + b*tan(e + f*x))**(m + S(-1))*(c + d*tan(e + f*x))**n*Simp(A*a*d*(m + n + S(1)) - C*(a*d*(n + S(1)) + b*c*m) + d*(m + n + S(1))*(A*b + B*a - C*b)*tan(e + f*x) - (-B*b*d*(m + n + S(1)) + C*m*(-a*d + b*c))*tan(e + f*x)**S(2), x), x), x) + Simp(C*(a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**(n + S(1))/(d*f*(m + n + S(1))), x) rule3785 = ReplacementRule(pattern3785, replacement3785) pattern3786 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons4, cons71, cons1440, cons1545, cons31, cons168, cons1568) def replacement3786(B, C, m, f, b, d, a, c, n, A, x, e): rubi.append(3786) return Dist(S(1)/(d*(m + n + S(1))), Int((a + b/tan(e + f*x))**(m + S(-1))*(c + d/tan(e + f*x))**n*Simp(A*a*d*(m + n + S(1)) - C*(a*d*(n + S(1)) + b*c*m) + d*(m + n + S(1))*(A*b + B*a - C*b)/tan(e + f*x) - (-B*b*d*(m + n + S(1)) + C*m*(-a*d + b*c))/tan(e + f*x)**S(2), x), x), x) - Simp(C*(a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**(n + S(1))/(d*f*(m + n + S(1))), x) rule3786 = ReplacementRule(pattern3786, replacement3786) pattern3787 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons4, cons71, cons1440, cons1545, cons31, cons168, cons1568) def replacement3787(C, m, f, b, d, a, c, n, A, x, e): rubi.append(3787) return Dist(S(1)/(d*(m + n + S(1))), Int((a + b*tan(e + f*x))**(m + S(-1))*(c + d*tan(e + f*x))**n*Simp(A*a*d*(m + n + S(1)) - C*m*(-a*d + b*c)*tan(e + f*x)**S(2) - C*(a*d*(n + S(1)) + b*c*m) + d*(A*b - C*b)*(m + n + S(1))*tan(e + f*x), x), x), x) + Simp(C*(a + b*tan(e + f*x))**m*(c + d*tan(e + f*x))**(n + S(1))/(d*f*(m + n + S(1))), x) rule3787 = ReplacementRule(pattern3787, replacement3787) pattern3788 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('m', S(1))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons4, cons71, cons1440, cons1545, cons31, cons168, cons1568) def replacement3788(C, m, f, b, d, a, c, n, A, x, e): rubi.append(3788) return Dist(S(1)/(d*(m + n + S(1))), Int((a + b/tan(e + f*x))**(m + S(-1))*(c + d/tan(e + f*x))**n*Simp(A*a*d*(m + n + S(1)) - C*m*(-a*d + b*c)/tan(e + f*x)**S(2) - C*(a*d*(n + S(1)) + b*c*m) + d*(A*b - C*b)*(m + n + S(1))/tan(e + f*x), x), x), x) - Simp(C*(a + b/tan(e + f*x))**m*(c + d/tan(e + f*x))**(n + S(1))/(d*f*(m + n + S(1))), x) rule3788 = ReplacementRule(pattern3788, replacement3788) pattern3789 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons4, cons71, cons1440, cons1545, cons31, cons94, cons1557) def replacement3789(B, C, m, f, b, d, c, a, n, A, x, e): rubi.append(3789) return Dist(S(1)/((a**S(2) + b**S(2))*(m + S(1))*(-a*d + b*c)), Int((a + b*tan(e + f*x))**(m + S(1))*(c + d*tan(e + f*x))**n*Simp(A*(a*(m + S(1))*(-a*d + b*c) - b**S(2)*d*(m + n + S(2))) - d*(A*b**S(2) - a*(B*b - C*a))*(m + n + S(2))*tan(e + f*x)**S(2) - (m + S(1))*(-a*d + b*c)*(A*b - B*a - C*b)*tan(e + f*x) + (B*b - C*a)*(a*d*(n + S(1)) + b*c*(m + S(1))), x), x), x) + Simp((a + b*tan(e + f*x))**(m + S(1))*(c + d*tan(e + f*x))**(n + S(1))*(A*b**S(2) - a*(B*b - C*a))/(f*(a**S(2) + b**S(2))*(m + S(1))*(-a*d + b*c)), x) rule3789 = ReplacementRule(pattern3789, replacement3789) pattern3790 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons4, cons71, cons1440, cons1545, cons31, cons94, cons1557) def replacement3790(B, C, e, m, f, b, d, a, c, n, x, A): rubi.append(3790) return Dist(S(1)/((a**S(2) + b**S(2))*(m + S(1))*(-a*d + b*c)), Int((a + b/tan(e + f*x))**(m + S(1))*(c + d/tan(e + f*x))**n*Simp(A*(a*(m + S(1))*(-a*d + b*c) - b**S(2)*d*(m + n + S(2))) - d*(A*b**S(2) - a*(B*b - C*a))*(m + n + S(2))/tan(e + f*x)**S(2) - (m + S(1))*(-a*d + b*c)*(A*b - B*a - C*b)/tan(e + f*x) + (B*b - C*a)*(a*d*(n + S(1)) + b*c*(m + S(1))), x), x), x) - Simp((a + b/tan(e + f*x))**(m + S(1))*(c + d/tan(e + f*x))**(n + S(1))*(A*b**S(2) - a*(B*b - C*a))/(f*(a**S(2) + b**S(2))*(m + S(1))*(-a*d + b*c)), x) rule3790 = ReplacementRule(pattern3790, replacement3790) pattern3791 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons4, cons71, cons1440, cons1545, cons31, cons94, cons1557) def replacement3791(C, m, f, b, d, c, a, n, A, x, e): rubi.append(3791) return Dist(S(1)/((a**S(2) + b**S(2))*(m + S(1))*(-a*d + b*c)), Int((a + b*tan(e + f*x))**(m + S(1))*(c + d*tan(e + f*x))**n*Simp(A*(a*(m + S(1))*(-a*d + b*c) - b**S(2)*d*(m + n + S(2))) - C*a*(a*d*(n + S(1)) + b*c*(m + S(1))) - d*(A*b**S(2) + C*a**S(2))*(m + n + S(2))*tan(e + f*x)**S(2) - (m + S(1))*(A*b - C*b)*(-a*d + b*c)*tan(e + f*x), x), x), x) + Simp((a + b*tan(e + f*x))**(m + S(1))*(c + d*tan(e + f*x))**(n + S(1))*(A*b**S(2) + C*a**S(2))/(f*(a**S(2) + b**S(2))*(m + S(1))*(-a*d + b*c)), x) rule3791 = ReplacementRule(pattern3791, replacement3791) pattern3792 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons4, cons71, cons1440, cons1545, cons31, cons94, cons1557) def replacement3792(C, e, m, f, b, d, a, c, n, x, A): rubi.append(3792) return Dist(S(1)/((a**S(2) + b**S(2))*(m + S(1))*(-a*d + b*c)), Int((a + b/tan(e + f*x))**(m + S(1))*(c + d/tan(e + f*x))**n*Simp(A*(a*(m + S(1))*(-a*d + b*c) - b**S(2)*d*(m + n + S(2))) - C*a*(a*d*(n + S(1)) + b*c*(m + S(1))) - d*(A*b**S(2) + C*a**S(2))*(m + n + S(2))/tan(e + f*x)**S(2) - (m + S(1))*(A*b - C*b)*(-a*d + b*c)/tan(e + f*x), x), x), x) - Simp((a + b/tan(e + f*x))**(m + S(1))*(c + d/tan(e + f*x))**(n + S(1))*(A*b**S(2) + C*a**S(2))/(f*(a**S(2) + b**S(2))*(m + S(1))*(-a*d + b*c)), x) rule3792 = ReplacementRule(pattern3792, replacement3792) pattern3793 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons71, cons1440, cons1545) def replacement3793(B, C, f, b, d, c, a, A, x, e): rubi.append(3793) return Dist((A*b**S(2) - B*a*b + C*a**S(2))/((a**S(2) + b**S(2))*(-a*d + b*c)), Int((-a*tan(e + f*x) + b)/(a + b*tan(e + f*x)), x), x) - Dist((A*d**S(2) - B*c*d + C*c**S(2))/((c**S(2) + d**S(2))*(-a*d + b*c)), Int((-c*tan(e + f*x) + d)/(c + d*tan(e + f*x)), x), x) + Simp(x*(a*(A*c + B*d - C*c) + b*(-A*d + B*c + C*d))/((a**S(2) + b**S(2))*(c**S(2) + d**S(2))), x) rule3793 = ReplacementRule(pattern3793, replacement3793) pattern3794 = Pattern(Integral((WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons71, cons1440, cons1545) def replacement3794(B, C, f, b, d, c, a, A, x, e): rubi.append(3794) return Dist((A*b**S(2) - B*a*b + C*a**S(2))/((a**S(2) + b**S(2))*(-a*d + b*c)), Int((-a/tan(e + f*x) + b)/(a + b/tan(e + f*x)), x), x) - Dist((A*d**S(2) - B*c*d + C*c**S(2))/((c**S(2) + d**S(2))*(-a*d + b*c)), Int((-c/tan(e + f*x) + d)/(c + d/tan(e + f*x)), x), x) + Simp(x*(a*(A*c + B*d - C*c) + b*(-A*d + B*c + C*d))/((a**S(2) + b**S(2))*(c**S(2) + d**S(2))), x) rule3794 = ReplacementRule(pattern3794, replacement3794) pattern3795 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons71, cons1440, cons1545) def replacement3795(C, f, b, d, c, a, A, x, e): rubi.append(3795) return Dist((A*b**S(2) + C*a**S(2))/((a**S(2) + b**S(2))*(-a*d + b*c)), Int((-a*tan(e + f*x) + b)/(a + b*tan(e + f*x)), x), x) - Dist((A*d**S(2) + C*c**S(2))/((c**S(2) + d**S(2))*(-a*d + b*c)), Int((-c*tan(e + f*x) + d)/(c + d*tan(e + f*x)), x), x) + Simp(x*(a*(A*c - C*c) - b*(A*d - C*d))/((a**S(2) + b**S(2))*(c**S(2) + d**S(2))), x) rule3795 = ReplacementRule(pattern3795, replacement3795) pattern3796 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons71, cons1440, cons1545) def replacement3796(C, f, b, d, c, a, A, x, e): rubi.append(3796) return Dist((A*b**S(2) + C*a**S(2))/((a**S(2) + b**S(2))*(-a*d + b*c)), Int((-a/tan(e + f*x) + b)/(a + b/tan(e + f*x)), x), x) - Dist((A*d**S(2) + C*c**S(2))/((c**S(2) + d**S(2))*(-a*d + b*c)), Int((-c/tan(e + f*x) + d)/(c + d/tan(e + f*x)), x), x) + Simp(x*(a*(A*c - C*c) - b*(A*d - C*d))/((a**S(2) + b**S(2))*(c**S(2) + d**S(2))), x) rule3796 = ReplacementRule(pattern3796, replacement3796) pattern3797 = Pattern(Integral((WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons4, cons71, cons1440, cons1545, cons1327, cons1569) def replacement3797(B, C, f, b, d, c, a, n, A, x, e): rubi.append(3797) return Dist((A*b**S(2) - B*a*b + C*a**S(2))/(a**S(2) + b**S(2)), Int((c + d*tan(e + f*x))**n*(tan(e + f*x)**S(2) + S(1))/(a + b*tan(e + f*x)), x), x) + Dist(S(1)/(a**S(2) + b**S(2)), Int((c + d*tan(e + f*x))**n*Simp(B*b + a*(A - C) + (B*a - b*(A - C))*tan(e + f*x), x), x), x) rule3797 = ReplacementRule(pattern3797, replacement3797) pattern3798 = Pattern(Integral((WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))/(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons4, cons71, cons1440, cons1545, cons1327, cons1569) def replacement3798(B, C, e, f, b, d, a, c, n, x, A): rubi.append(3798) return Dist((A*b**S(2) - B*a*b + C*a**S(2))/(a**S(2) + b**S(2)), Int((S(1) + tan(e + f*x)**(S(-2)))*(c + d/tan(e + f*x))**n/(a + b/tan(e + f*x)), x), x) + Dist(S(1)/(a**S(2) + b**S(2)), Int((c + d/tan(e + f*x))**n*Simp(B*b + a*(A - C) + (B*a - b*(A - C))/tan(e + f*x), x), x), x) rule3798 = ReplacementRule(pattern3798, replacement3798) pattern3799 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_/(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons4, cons71, cons1440, cons1545, cons1327, cons1569) def replacement3799(C, f, b, d, c, a, n, A, x, e): rubi.append(3799) return Dist((A*b**S(2) + C*a**S(2))/(a**S(2) + b**S(2)), Int((c + d*tan(e + f*x))**n*(tan(e + f*x)**S(2) + S(1))/(a + b*tan(e + f*x)), x), x) + Dist(S(1)/(a**S(2) + b**S(2)), Int((c + d*tan(e + f*x))**n*Simp(a*(A - C) - (A*b - C*b)*tan(e + f*x), x), x), x) rule3799 = ReplacementRule(pattern3799, replacement3799) pattern3800 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_/(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons4, cons71, cons1440, cons1545, cons1327, cons1569) def replacement3800(C, e, f, b, d, a, c, n, x, A): rubi.append(3800) return Dist((A*b**S(2) + C*a**S(2))/(a**S(2) + b**S(2)), Int((S(1) + tan(e + f*x)**(S(-2)))*(c + d/tan(e + f*x))**n/(a + b/tan(e + f*x)), x), x) + Dist(S(1)/(a**S(2) + b**S(2)), Int((c + d/tan(e + f*x))**n*Simp(a*(A - C) - (A*b - C*b)/tan(e + f*x), x), x), x) rule3800 = ReplacementRule(pattern3800, replacement3800) pattern3801 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('A', S(0)) + WC('B', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons21, cons4, cons71, cons1440, cons1545) def replacement3801(B, C, m, f, b, d, c, a, n, A, x, e): rubi.append(3801) return Dist(S(1)/(b*f), Subst(Int((a + x)**m*(c + d*x/b)**n*(A*b**S(2) + B*b*x + C*x**S(2))/(b**S(2) + x**S(2)), x), x, b*tan(e + f*x)), x) rule3801 = ReplacementRule(pattern3801, replacement3801) pattern3802 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(WC('A', S(0)) + WC('B', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons35, cons36, cons21, cons4, cons71, cons1440, cons1545) def replacement3802(B, C, e, m, f, b, d, a, c, n, x, A): rubi.append(3802) return -Dist(S(1)/(b*f), Subst(Int((a + x)**m*(c + d*x/b)**n*(A*b**S(2) + B*b*x + C*x**S(2))/(b**S(2) + x**S(2)), x), x, b/tan(e + f*x)), x) rule3802 = ReplacementRule(pattern3802, replacement3802) pattern3803 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons21, cons4, cons71, cons1440, cons1545) def replacement3803(C, m, f, b, d, c, a, n, A, x, e): rubi.append(3803) return Dist(S(1)/(b*f), Subst(Int((a + x)**m*(c + d*x/b)**n*(A*b**S(2) + C*x**S(2))/(b**S(2) + x**S(2)), x), x, b*tan(e + f*x)), x) rule3803 = ReplacementRule(pattern3803, replacement3803) pattern3804 = Pattern(Integral((WC('A', S(0)) + WC('C', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))**S(2))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**m_*(WC('c', S(0)) + WC('d', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons34, cons36, cons21, cons4, cons71, cons1440, cons1545) def replacement3804(C, e, m, f, b, d, a, c, n, x, A): rubi.append(3804) return -Dist(S(1)/(b*f), Subst(Int((a + x)**m*(c + d*x/b)**n*(A*b**S(2) + C*x**S(2))/(b**S(2) + x**S(2)), x), x, b/tan(e + f*x)), x) rule3804 = ReplacementRule(pattern3804, replacement3804) pattern3805 = Pattern(Integral(S(1)/(a_ + WC('b', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons1492) def replacement3805(b, d, c, a, x): rubi.append(3805) return Dist(S(1)/a, Int(cos(c + d*x)**S(2), x), x) rule3805 = ReplacementRule(pattern3805, replacement3805) pattern3806 = Pattern(Integral(S(1)/(a_ + WC('b', S(1))/tan(x_*WC('d', S(1)) + WC('c', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons1492) def replacement3806(b, d, c, a, x): rubi.append(3806) return Dist(S(1)/a, Int(sin(c + d*x)**S(2), x), x) rule3806 = ReplacementRule(pattern3806, replacement3806) pattern3807 = Pattern(Integral(S(1)/(a_ + WC('b', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons1456) def replacement3807(b, d, c, a, x): rubi.append(3807) return -Dist(b/(a - b), Int(S(1)/((a + b*tan(c + d*x)**S(2))*cos(c + d*x)**S(2)), x), x) + Simp(x/(a - b), x) rule3807 = ReplacementRule(pattern3807, replacement3807) pattern3808 = Pattern(Integral(S(1)/(a_ + WC('b', S(1))/tan(x_*WC('d', S(1)) + WC('c', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons1456) def replacement3808(b, d, c, a, x): rubi.append(3808) return -Dist(b/(a - b), Int(S(1)/((a + b/tan(c + d*x)**S(2))*sin(c + d*x)**S(2)), x), x) + Simp(x/(a - b), x) rule3808 = ReplacementRule(pattern3808, replacement3808) pattern3809 = Pattern(Integral((a_ + (WC('e', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons1570) def replacement3809(p, b, d, c, a, n, x, e): rubi.append(3809) return Dist(e/d, Subst(Int((a + b*x**n)**p/(e**S(2) + x**S(2)), x), x, e*tan(c + d*x)), x) rule3809 = ReplacementRule(pattern3809, replacement3809) pattern3810 = Pattern(Integral((a_ + (WC('e', S(1))/tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_*WC('b', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons1570) def replacement3810(p, b, d, c, n, a, x, e): rubi.append(3810) return -Dist(e/d, Subst(Int((a + b*x**n)**p/(e**S(2) + x**S(2)), x), x, e/tan(c + d*x)), x) rule3810 = ReplacementRule(pattern3810, replacement3810) def With3811(p, m, b, d, c, a, n, x, e): f = FreeFactors(tan(c + d*x), x) rubi.append(3811) return Dist(f**(m + S(1))/d, Subst(Int(x**m*(a + b*(e*f*x)**n)**p*(f**S(2)*x**S(2) + S(1))**(-m/S(2) + S(-1)), x), x, tan(c + d*x)/f), x) pattern3811 = Pattern(Integral((a_ + (WC('e', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_*WC('b', S(1)))**p_*sin(x_*WC('d', S(1)) + WC('c', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons1515) rule3811 = ReplacementRule(pattern3811, With3811) def With3812(p, m, b, d, c, n, a, x, e): f = FreeFactors(S(1)/tan(c + d*x), x) rubi.append(3812) return -Dist(f**(m + S(1))/d, Subst(Int(x**m*(a + b*(e*f*x)**n)**p*(f**S(2)*x**S(2) + S(1))**(-m/S(2) + S(-1)), x), x, S(1)/(f*tan(c + d*x))), x) pattern3812 = Pattern(Integral((a_ + (WC('e', S(1))/tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_*WC('b', S(1)))**p_*cos(x_*WC('d', S(1)) + WC('c', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons1515) rule3812 = ReplacementRule(pattern3812, With3812) def With3813(p, m, b, d, c, a, n, x): f = FreeFactors(cos(c + d*x), x) rubi.append(3813) return -Dist(f/d, Subst(Int((f*x)**(-n*p)*(-f**S(2)*x**S(2) + S(1))**(m/S(2) + S(-1)/2)*ExpandToSum(a*(f*x)**n + b*(-f**S(2)*x**S(2) + S(1))**(n/S(2)), x)**p, x), x, cos(c + d*x)/f), x) pattern3813 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0)))**n_)**WC('p', S(1))*sin(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons1481, cons1479, cons38) rule3813 = ReplacementRule(pattern3813, With3813) def With3814(p, m, b, d, c, n, a, x): f = FreeFactors(sin(c + d*x), x) rubi.append(3814) return Dist(f/d, Subst(Int((f*x)**(-n*p)*(-f**S(2)*x**S(2) + S(1))**(m/S(2) + S(-1)/2)*ExpandToSum(a*(f*x)**n + b*(-f**S(2)*x**S(2) + S(1))**(n/S(2)), x)**p, x), x, sin(c + d*x)/f), x) pattern3814 = Pattern(Integral((a_ + (S(1)/tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_*WC('b', S(1)))**WC('p', S(1))*cos(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons1481, cons1479, cons38) rule3814 = ReplacementRule(pattern3814, With3814) def With3815(p, m, b, d, c, a, n, x, e): f = FreeFactors(tan(c + d*x), x) rubi.append(3815) return Dist(f/d, Subst(Int((a + b*(e*f*x)**n)**p*(f**S(2)*x**S(2) + S(1))**(m/S(2) + S(-1)), x), x, tan(c + d*x)/f), x) pattern3815 = Pattern(Integral((a_ + (WC('e', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_*WC('b', S(1)))**WC('p', S(1))*(S(1)/cos(x_*WC('d', S(1)) + WC('c', S(0))))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons1515) rule3815 = ReplacementRule(pattern3815, With3815) def With3816(p, m, b, d, c, n, a, x, e): f = FreeFactors(S(1)/tan(c + d*x), x) rubi.append(3816) return -Dist(f/d, Subst(Int((a + b*(e*f*x)**n)**p*(f**S(2)*x**S(2) + S(1))**(m/S(2) + S(-1)), x), x, S(1)/(f*tan(c + d*x))), x) pattern3816 = Pattern(Integral((a_ + (WC('e', S(1))/tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_*WC('b', S(1)))**WC('p', S(1))*(S(1)/sin(x_*WC('d', S(1)) + WC('c', S(0))))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons4, cons5, cons1515) rule3816 = ReplacementRule(pattern3816, With3816) def With3817(p, m, b, d, c, a, n, x): f = FreeFactors(sin(c + d*x), x) rubi.append(3817) return Dist(f/d, Subst(Int((-f**S(2)*x**S(2) + S(1))**(-m/S(2) - n*p/S(2) + S(-1)/2)*ExpandToSum(a*(-f**S(2)*x**S(2) + S(1))**(n/S(2)) + b*(f*x)**n, x)**p, x), x, sin(c + d*x)/f), x) pattern3817 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0)))**n_)**WC('p', S(1))*(S(1)/cos(x_*WC('d', S(1)) + WC('c', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons1228, cons743, cons38) rule3817 = ReplacementRule(pattern3817, With3817) def With3818(p, m, b, d, c, n, a, x): f = FreeFactors(cos(c + d*x), x) rubi.append(3818) return -Dist(f/d, Subst(Int((-f**S(2)*x**S(2) + S(1))**(-m/S(2) - n*p/S(2) + S(-1)/2)*ExpandToSum(a*(-f**S(2)*x**S(2) + S(1))**(n/S(2)) + b*(f*x)**n, x)**p, x), x, cos(c + d*x)/f), x) pattern3818 = Pattern(Integral((a_ + (S(1)/tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_*WC('b', S(1)))**WC('p', S(1))*(S(1)/sin(x_*WC('d', S(1)) + WC('c', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons1228, cons743, cons38) rule3818 = ReplacementRule(pattern3818, With3818) pattern3819 = Pattern(Integral((a_ + (WC('e', S(1))*tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_*WC('b', S(1)))**p_*tan(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons1497) def replacement3819(p, m, b, d, c, a, n, x, e): rubi.append(3819) return Dist(e/d, Subst(Int((x/e)**m*(a + b*x**n)**p/(e**S(2) + x**S(2)), x), x, e*tan(c + d*x)), x) rule3819 = ReplacementRule(pattern3819, replacement3819) pattern3820 = Pattern(Integral((a_ + (WC('e', S(1))/tan(x_*WC('d', S(1)) + WC('c', S(0))))**n_*WC('b', S(1)))**p_*(S(1)/tan(x_*WC('d', S(1)) + WC('c', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons1497) def replacement3820(p, m, b, d, c, n, a, x, e): rubi.append(3820) return -Dist(e/d, Subst(Int((x/e)**m*(a + b*x**n)**p/(e**S(2) + x**S(2)), x), x, e/tan(c + d*x)), x) rule3820 = ReplacementRule(pattern3820, replacement3820) pattern3821 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)) + WC('c', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n2', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons46, cons45, cons38) def replacement3821(p, b, n2, d, c, n, a, x, e): rubi.append(3821) return Dist(S(4)**(-p)*c**(-p), Int((b + S(2)*c*tan(d + e*x)**n)**(S(2)*p), x), x) rule3821 = ReplacementRule(pattern3821, replacement3821) pattern3822 = Pattern(Integral((a_ + (S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*WC('b', S(1)) + (S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n2', S(1))*WC('c', S(1)))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons46, cons45, cons38) def replacement3822(p, b, n2, d, c, n, a, x, e): rubi.append(3822) return Dist(S(4)**(-p)*c**(-p), Int((b + S(2)*c*(S(1)/tan(d + e*x))**n)**(S(2)*p), x), x) rule3822 = ReplacementRule(pattern3822, replacement3822) pattern3823 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)) + WC('c', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n2', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons4, cons46, cons45, cons147) def replacement3823(p, b, n2, d, c, n, a, x, e): rubi.append(3823) return Dist((b + S(2)*c*tan(d + e*x)**n)**(-S(2)*p)*(a + b*tan(d + e*x)**n + c*tan(d + e*x)**(S(2)*n))**p, Int((b + S(2)*c*tan(d + e*x)**n)**(S(2)*p), x), x) rule3823 = ReplacementRule(pattern3823, replacement3823) pattern3824 = Pattern(Integral((a_ + (S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*WC('b', S(1)) + (S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n2', S(1))*WC('c', S(1)))**p_, x_), cons2, cons3, cons7, cons27, cons48, cons4, cons46, cons45, cons147) def replacement3824(p, b, n2, d, c, n, a, x, e): rubi.append(3824) return Dist((b + S(2)*c*(S(1)/tan(d + e*x))**n)**(-S(2)*p)*(a + b*(S(1)/tan(d + e*x))**n + c*(S(1)/tan(d + e*x))**(S(2)*n))**p, Int((b + S(2)*c*(S(1)/tan(d + e*x))**n)**(S(2)*p), x), x) rule3824 = ReplacementRule(pattern3824, replacement3824) def With3825(b, n2, d, a, n, c, x, e): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(3825) return Dist(S(2)*c/q, Int(S(1)/(b + S(2)*c*tan(d + e*x)**n - q), x), x) - Dist(S(2)*c/q, Int(S(1)/(b + S(2)*c*tan(d + e*x)**n + q), x), x) pattern3825 = Pattern(Integral(S(1)/(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)) + WC('c', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n2', S(1))), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons46, cons226) rule3825 = ReplacementRule(pattern3825, With3825) def With3826(b, n2, d, a, n, c, x, e): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(3826) return Dist(S(2)*c/q, Int(S(1)/(b + S(2)*c*(S(1)/tan(d + e*x))**n - q), x), x) - Dist(S(2)*c/q, Int(S(1)/(b + S(2)*c*(S(1)/tan(d + e*x))**n + q), x), x) pattern3826 = Pattern(Integral(S(1)/((S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*WC('b', S(1)) + (S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons4, cons46, cons226) rule3826 = ReplacementRule(pattern3826, With3826) pattern3827 = Pattern(Integral(((WC('f', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*WC('b', S(1)) + (WC('f', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**p_*sin(x_*WC('e', S(1)) + WC('d', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons5, cons46, cons1515) def replacement3827(p, m, f, b, n2, d, a, n, c, x, e): rubi.append(3827) return Dist(f/e, Subst(Int(x**m*(f**S(2) + x**S(2))**(-m/S(2) + S(-1))*(a + b*x**n + c*x**(S(2)*n))**p, x), x, f*tan(d + e*x)), x) rule3827 = ReplacementRule(pattern3827, replacement3827) pattern3828 = Pattern(Integral(((WC('f', S(1))/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*WC('b', S(1)) + (WC('f', S(1))/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**p_*cos(x_*WC('e', S(1)) + WC('d', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons5, cons46, cons1515) def replacement3828(p, m, f, b, n2, d, a, n, c, x, e): rubi.append(3828) return -Dist(f/e, Subst(Int(x**m*(f**S(2) + x**S(2))**(-m/S(2) + S(-1))*(a + b*x**n + c*x**(S(2)*n))**p, x), x, f/tan(d + e*x)), x) rule3828 = ReplacementRule(pattern3828, replacement3828) def With3829(p, m, b, n2, d, a, n, c, x, e): g = FreeFactors(cos(d + e*x), x) rubi.append(3829) return -Dist(g/e, Subst(Int((g*x)**(-S(2)*n*p)*(-g**S(2)*x**S(2) + S(1))**(m/S(2) + S(-1)/2)*ExpandToSum(a*(g*x)**(S(2)*n) + b*(g*x)**n*(-g**S(2)*x**S(2) + S(1))**(n/S(2)) + c*(-g**S(2)*x**S(2) + S(1))**n, x)**p, x), x, cos(d + e*x)/g), x) pattern3829 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)) + WC('c', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n2', S(1)))**WC('p', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons46, cons1481, cons1479, cons38) rule3829 = ReplacementRule(pattern3829, With3829) def With3830(p, m, b, n2, d, a, n, c, x, e): g = FreeFactors(sin(d + e*x), x) rubi.append(3830) return Dist(g/e, Subst(Int((g*x)**(-S(2)*n*p)*(-g**S(2)*x**S(2) + S(1))**(m/S(2) + S(-1)/2)*ExpandToSum(a*(g*x)**(S(2)*n) + b*(g*x)**n*(-g**S(2)*x**S(2) + S(1))**(n/S(2)) + c*(-g**S(2)*x**S(2) + S(1))**n, x)**p, x), x, sin(d + e*x)/g), x) pattern3830 = Pattern(Integral(((S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0)) + WC('c', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n2', S(1)))**WC('p', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons46, cons1481, cons1479, cons38) rule3830 = ReplacementRule(pattern3830, With3830) pattern3831 = Pattern(Integral(((WC('f', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*WC('b', S(1)) + (WC('f', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**WC('p', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons5, cons46, cons1480) def replacement3831(p, m, f, b, n2, d, a, n, c, x, e): rubi.append(3831) return Dist(f**(m + S(1))/e, Subst(Int((f**S(2) + x**S(2))**(-m/S(2) + S(-1))*(a + b*x**n + c*x**(S(2)*n))**p, x), x, f*tan(d + e*x)), x) rule3831 = ReplacementRule(pattern3831, replacement3831) pattern3832 = Pattern(Integral(((WC('f', S(1))/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*WC('b', S(1)) + (WC('f', S(1))/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**WC('p', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons4, cons5, cons46, cons1480) def replacement3832(p, m, f, b, n2, d, a, n, c, x, e): rubi.append(3832) return -Dist(f**(m + S(1))/e, Subst(Int((f**S(2) + x**S(2))**(-m/S(2) + S(-1))*(a + b*x**n + c*x**(S(2)*n))**p, x), x, f/tan(d + e*x)), x) rule3832 = ReplacementRule(pattern3832, replacement3832) def With3833(p, m, b, n2, d, a, n, c, x, e): g = FreeFactors(sin(d + e*x), x) rubi.append(3833) return Dist(g/e, Subst(Int((-g**S(2)*x**S(2) + S(1))**(m/S(2) - n*p + S(-1)/2)*ExpandToSum(a*(-x**S(2) + S(1))**n + b*x**n*(-x**S(2) + S(1))**(n/S(2)) + c*x**(S(2)*n), x)**p, x), x, sin(d + e*x)/g), x) pattern3833 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)) + WC('c', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n2', S(1)))**WC('p', S(1))*cos(x_*WC('e', S(1)) + WC('d', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons46, cons1481, cons1479, cons38) rule3833 = ReplacementRule(pattern3833, With3833) def With3834(p, m, b, n2, d, a, n, c, x, e): g = FreeFactors(cos(d + e*x), x) rubi.append(3834) return -Dist(g/e, Subst(Int((-g**S(2)*x**S(2) + S(1))**(m/S(2) - n*p + S(-1)/2)*ExpandToSum(a*(-x**S(2) + S(1))**n + b*x**n*(-x**S(2) + S(1))**(n/S(2)) + c*x**(S(2)*n), x)**p, x), x, cos(d + e*x)/g), x) pattern3834 = Pattern(Integral(((S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*WC('b', S(1)) + (S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**WC('p', S(1))*sin(x_*WC('e', S(1)) + WC('d', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons46, cons1481, cons1479, cons38) rule3834 = ReplacementRule(pattern3834, With3834) pattern3835 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)) + WC('c', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n2', S(1)))**p_*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons46, cons45, cons38) def replacement3835(p, m, b, n2, d, a, n, c, x, e): rubi.append(3835) return Dist(S(4)**(-p)*c**(-p), Int((b + S(2)*c*tan(d + e*x)**n)**(S(2)*p)*tan(d + e*x)**m, x), x) rule3835 = ReplacementRule(pattern3835, replacement3835) pattern3836 = Pattern(Integral(((S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*WC('b', S(1)) + (S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**p_*(S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons46, cons45, cons38) def replacement3836(p, m, b, n2, d, a, n, c, x, e): rubi.append(3836) return Dist(S(4)**(-p)*c**(-p), Int((b + S(2)*c*(S(1)/tan(d + e*x))**n)**(S(2)*p)*(S(1)/tan(d + e*x))**m, x), x) rule3836 = ReplacementRule(pattern3836, replacement3836) pattern3837 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)) + WC('c', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n2', S(1)))**p_*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons46, cons45, cons147) def replacement3837(p, m, b, n2, d, a, n, c, x, e): rubi.append(3837) return Dist((b + S(2)*c*tan(d + e*x)**n)**(-S(2)*p)*(a + b*tan(d + e*x)**n + c*tan(d + e*x)**(S(2)*n))**p, Int((b + S(2)*c*tan(d + e*x)**n)**(S(2)*p)*tan(d + e*x)**m, x), x) rule3837 = ReplacementRule(pattern3837, replacement3837) pattern3838 = Pattern(Integral(((S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*WC('b', S(1)) + (S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**p_*(S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons46, cons45, cons147) def replacement3838(p, m, b, n2, d, a, n, c, x, e): rubi.append(3838) return Dist((b + S(2)*c*(S(1)/tan(d + e*x))**n)**(-S(2)*p)*(a + b*(S(1)/tan(d + e*x))**n + c*(S(1)/tan(d + e*x))**(S(2)*n))**p, Int((b + S(2)*c*(S(1)/tan(d + e*x))**n)**(S(2)*p)*(S(1)/tan(d + e*x))**m, x), x) rule3838 = ReplacementRule(pattern3838, replacement3838) pattern3839 = Pattern(Integral(((WC('f', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*WC('b', S(1)) + (WC('f', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**p_*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons46, cons226) def replacement3839(p, m, f, b, n2, d, a, n, c, x, e): rubi.append(3839) return Dist(f/e, Subst(Int((x/f)**m*(a + b*x**n + c*x**(S(2)*n))**p/(f**S(2) + x**S(2)), x), x, f*tan(d + e*x)), x) rule3839 = ReplacementRule(pattern3839, replacement3839) pattern3840 = Pattern(Integral(((WC('f', S(1))/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*WC('b', S(1)) + (WC('f', S(1))/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**p_*(S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons5, cons46, cons226) def replacement3840(p, m, f, b, n2, d, a, n, c, x, e): rubi.append(3840) return -Dist(f/e, Subst(Int((x/f)**m*(a + b*x**n + c*x**(S(2)*n))**p/(f**S(2) + x**S(2)), x), x, f/tan(d + e*x)), x) rule3840 = ReplacementRule(pattern3840, replacement3840) pattern3841 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)) + WC('c', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n2', S(1)))**WC('p', S(1))*(S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons46, cons45, cons38) def replacement3841(p, m, b, n2, d, a, n, c, x, e): rubi.append(3841) return Dist(S(4)**(-p)*c**(-p), Int((b + S(2)*c*tan(d + e*x)**n)**(S(2)*p)*(S(1)/tan(d + e*x))**m, x), x) rule3841 = ReplacementRule(pattern3841, replacement3841) pattern3842 = Pattern(Integral(((S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*WC('b', S(1)) + (S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**WC('p', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons46, cons45, cons38) def replacement3842(p, m, b, n2, d, a, n, c, x, e): rubi.append(3842) return Dist(S(4)**(-p)*c**(-p), Int((b + S(2)*c*(S(1)/tan(d + e*x))**n)**(S(2)*p)*tan(d + e*x)**m, x), x) rule3842 = ReplacementRule(pattern3842, replacement3842) pattern3843 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n', S(1)) + WC('c', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('n2', S(1)))**p_*(S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons46, cons45, cons147) def replacement3843(p, m, b, n2, d, a, n, c, x, e): rubi.append(3843) return Dist((b + S(2)*c*tan(d + e*x)**n)**(-S(2)*p)*(a + b*tan(d + e*x)**n + c*tan(d + e*x)**(S(2)*n))**p, Int((b + S(2)*c*tan(d + e*x)**n)**(S(2)*p)*(S(1)/tan(d + e*x))**m, x), x) rule3843 = ReplacementRule(pattern3843, replacement3843) pattern3844 = Pattern(Integral(((S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n', S(1))*WC('b', S(1)) + (S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**p_*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons46, cons45, cons147) def replacement3844(p, m, b, n2, d, a, n, c, x, e): rubi.append(3844) return Dist((b + S(2)*c*(S(1)/tan(d + e*x))**n)**(-S(2)*p)*(a + b*(S(1)/tan(d + e*x))**n + c*(S(1)/tan(d + e*x))**(S(2)*n))**p, Int((b + S(2)*c*(S(1)/tan(d + e*x))**n)**(S(2)*p)*tan(d + e*x)**m, x), x) rule3844 = ReplacementRule(pattern3844, replacement3844) def With3845(p, m, b, n2, d, a, c, n, x, e): g = FreeFactors(S(1)/tan(d + e*x), x) rubi.append(3845) return Dist(g/e, Subst(Int((g*x)**(m - S(2)*n*p)*(a*(g*x)**(S(2)*n) + b*(g*x)**n + c)**p/(g**S(2)*x**S(2) + S(1)), x), x, S(1)/(g*tan(d + e*x))), x) pattern3845 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**n_ + WC('c', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**n2_)**WC('p', S(1))*(S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons5, cons46, cons226, cons1479) rule3845 = ReplacementRule(pattern3845, With3845) def With3846(p, m, b, n2, d, c, a, n, x, e): g = FreeFactors(tan(d + e*x), x) rubi.append(3846) return -Dist(g/e, Subst(Int((g*x)**(m - S(2)*n*p)*(a*(g*x)**(S(2)*n) + b*(g*x)**n + c)**p/(g**S(2)*x**S(2) + S(1)), x), x, tan(d + e*x)/g), x) pattern3846 = Pattern(Integral(((S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**n2_*WC('c', S(1)) + (S(1)/tan(x_*WC('e', S(1)) + WC('d', S(0))))**n_*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons5, cons46, cons226, cons1479) rule3846 = ReplacementRule(pattern3846, With3846) pattern3847 = Pattern(Integral((A_ + WC('B', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0))))*(a_ + WC('b', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**S(2))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons45, cons85) def replacement3847(B, b, d, c, a, n, A, x, e): rubi.append(3847) return Dist(S(4)**(-n)*c**(-n), Int((A + B*tan(d + e*x))*(b + S(2)*c*tan(d + e*x))**(S(2)*n), x), x) rule3847 = ReplacementRule(pattern3847, replacement3847) pattern3848 = Pattern(Integral((A_ + WC('B', S(1))/tan(x_*WC('e', S(1)) + WC('d', S(0))))*(a_ + WC('b', S(1))/tan(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))/tan(x_*WC('e', S(1)) + WC('d', S(0)))**S(2))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons45, cons85) def replacement3848(B, b, d, c, a, n, A, x, e): rubi.append(3848) return Dist(S(4)**(-n)*c**(-n), Int((A + B/tan(d + e*x))*(b + S(2)*c/tan(d + e*x))**(S(2)*n), x), x) rule3848 = ReplacementRule(pattern3848, replacement3848) pattern3849 = Pattern(Integral((A_ + WC('B', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0))))*(a_ + WC('b', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**S(2))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons45, cons23) def replacement3849(B, b, d, c, a, n, A, x, e): rubi.append(3849) return Dist((b + S(2)*c*tan(d + e*x))**(-S(2)*n)*(a + b*tan(d + e*x) + c*tan(d + e*x)**S(2))**n, Int((A + B*tan(d + e*x))*(b + S(2)*c*tan(d + e*x))**(S(2)*n), x), x) rule3849 = ReplacementRule(pattern3849, replacement3849) pattern3850 = Pattern(Integral((A_ + WC('B', S(1))/tan(x_*WC('e', S(1)) + WC('d', S(0))))*(a_ + WC('b', S(1))/tan(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))/tan(x_*WC('e', S(1)) + WC('d', S(0)))**S(2))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons45, cons23) def replacement3850(B, b, d, c, a, n, A, x, e): rubi.append(3850) return Dist((b + S(2)*c/tan(d + e*x))**(-S(2)*n)*(a + b/tan(d + e*x) + c/tan(d + e*x)**S(2))**n, Int((A + B/tan(d + e*x))*(b + S(2)*c/tan(d + e*x))**(S(2)*n), x), x) rule3850 = ReplacementRule(pattern3850, replacement3850) def With3851(B, b, d, a, c, A, x, e): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(3851) return Dist(B - (-S(2)*A*c + B*b)/q, Int(S(1)/Simp(b + S(2)*c*tan(d + e*x) - q, x), x), x) + Dist(B + (-S(2)*A*c + B*b)/q, Int(S(1)/Simp(b + S(2)*c*tan(d + e*x) + q, x), x), x) pattern3851 = Pattern(Integral((A_ + WC('B', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0))))/(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons226) rule3851 = ReplacementRule(pattern3851, With3851) def With3852(B, b, d, c, a, A, x, e): q = Rt(-S(4)*a*c + b**S(2), S(2)) rubi.append(3852) return Dist(B - (-S(2)*A*c + B*b)/q, Int(S(1)/Simp(b + S(2)*c/tan(d + e*x) - q, x), x), x) + Dist(B + (-S(2)*A*c + B*b)/q, Int(S(1)/Simp(b + S(2)*c/tan(d + e*x) + q, x), x), x) pattern3852 = Pattern(Integral((A_ + WC('B', S(1))/tan(x_*WC('e', S(1)) + WC('d', S(0))))/(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))/tan(x_*WC('e', S(1)) + WC('d', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons226) rule3852 = ReplacementRule(pattern3852, With3852) pattern3853 = Pattern(Integral((A_ + WC('B', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0))))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))*tan(x_*WC('e', S(1)) + WC('d', S(0)))**S(2))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons226, cons85) def replacement3853(B, b, d, a, c, n, A, x, e): rubi.append(3853) return Int(ExpandTrig((A + B*tan(d + e*x))*(a + b*tan(d + e*x) + c*tan(d + e*x)**S(2))**n, x), x) rule3853 = ReplacementRule(pattern3853, replacement3853) pattern3854 = Pattern(Integral((A_ + WC('B', S(1))/tan(x_*WC('e', S(1)) + WC('d', S(0))))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('e', S(1)) + WC('d', S(0))) + WC('c', S(1))/tan(x_*WC('e', S(1)) + WC('d', S(0)))**S(2))**n_, x_), cons2, cons3, cons7, cons27, cons48, cons34, cons35, cons226, cons85) def replacement3854(B, b, d, c, a, n, A, x, e): rubi.append(3854) return Int(ExpandTrig((A + B/tan(d + e*x))*(a + b/tan(d + e*x) + c/tan(d + e*x)**S(2))**n, x), x) rule3854 = ReplacementRule(pattern3854, replacement3854) pattern3855 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons7, cons27, cons48, cons125, cons62) def replacement3855(m, f, d, c, x, e): rubi.append(3855) return -Dist(S(2)*I, Int((c + d*x)**m*exp(S(2)*I*(e + f*x))/(exp(S(2)*I*(e + f*x)) + S(1)), x), x) + Simp(I*(c + d*x)**(m + S(1))/(d*(m + S(1))), x) rule3855 = ReplacementRule(pattern3855, replacement3855) pattern3856 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))), x_), cons7, cons27, cons48, cons125, cons62) def replacement3856(m, f, d, c, x, e): rubi.append(3856) return -Dist(S(2)*I, Int((c + d*x)**m*exp(S(2)*I*(e + f*x))/(-exp(S(2)*I*(e + f*x)) + S(1)), x), x) - Simp(I*(c + d*x)**(m + S(1))/(d*(m + S(1))), x) rule3856 = ReplacementRule(pattern3856, replacement3856) pattern3857 = Pattern(Integral((WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons3, cons7, cons27, cons48, cons125, cons93, cons165, cons168) def replacement3857(m, f, b, d, c, n, x, e): rubi.append(3857) return -Dist(b**S(2), Int((b*tan(e + f*x))**(n + S(-2))*(c + d*x)**m, x), x) - Dist(b*d*m/(f*(n + S(-1))), Int((b*tan(e + f*x))**(n + S(-1))*(c + d*x)**(m + S(-1)), x), x) + Simp(b*(b*tan(e + f*x))**(n + S(-1))*(c + d*x)**m/(f*(n + S(-1))), x) rule3857 = ReplacementRule(pattern3857, replacement3857) pattern3858 = Pattern(Integral((WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons3, cons7, cons27, cons48, cons125, cons93, cons165, cons168) def replacement3858(m, f, b, d, c, n, x, e): rubi.append(3858) return -Dist(b**S(2), Int((b/tan(e + f*x))**(n + S(-2))*(c + d*x)**m, x), x) + Dist(b*d*m/(f*(n + S(-1))), Int((b/tan(e + f*x))**(n + S(-1))*(c + d*x)**(m + S(-1)), x), x) - Simp(b*(b/tan(e + f*x))**(n + S(-1))*(c + d*x)**m/(f*(n + S(-1))), x) rule3858 = ReplacementRule(pattern3858, replacement3858) pattern3859 = Pattern(Integral((WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons3, cons7, cons27, cons48, cons125, cons93, cons89, cons168) def replacement3859(m, f, b, d, c, n, x, e): rubi.append(3859) return -Dist(b**(S(-2)), Int((b*tan(e + f*x))**(n + S(2))*(c + d*x)**m, x), x) - Dist(d*m/(b*f*(n + S(1))), Int((b*tan(e + f*x))**(n + S(1))*(c + d*x)**(m + S(-1)), x), x) + Simp((b*tan(e + f*x))**(n + S(1))*(c + d*x)**m/(b*f*(n + S(1))), x) rule3859 = ReplacementRule(pattern3859, replacement3859) pattern3860 = Pattern(Integral((WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons3, cons7, cons27, cons48, cons125, cons93, cons89, cons168) def replacement3860(m, f, b, d, c, n, x, e): rubi.append(3860) return -Dist(b**(S(-2)), Int((b/tan(e + f*x))**(n + S(2))*(c + d*x)**m, x), x) + Dist(d*m/(b*f*(n + S(1))), Int((b/tan(e + f*x))**(n + S(1))*(c + d*x)**(m + S(-1)), x), x) - Simp((b/tan(e + f*x))**(n + S(1))*(c + d*x)**m/(b*f*(n + S(1))), x) rule3860 = ReplacementRule(pattern3860, replacement3860) pattern3861 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons528) def replacement3861(m, f, b, d, c, n, a, x, e): rubi.append(3861) return Int(ExpandIntegrand((c + d*x)**m, (a + b*tan(e + f*x))**n, x), x) rule3861 = ReplacementRule(pattern3861, replacement3861) pattern3862 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1))*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons528) def replacement3862(m, f, b, d, c, n, a, x, e): rubi.append(3862) return Int(ExpandIntegrand((c + d*x)**m, (a + b/tan(e + f*x))**n, x), x) rule3862 = ReplacementRule(pattern3862, replacement3862) pattern3863 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))/(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1439, cons31, cons168) def replacement3863(m, f, b, d, c, a, x, e): rubi.append(3863) return Dist(a*d*m/(S(2)*b*f), Int((c + d*x)**(m + S(-1))/(a + b*tan(e + f*x)), x), x) + Simp((c + d*x)**(m + S(1))/(S(2)*a*d*(m + S(1))), x) - Simp(a*(c + d*x)**m/(S(2)*b*f*(a + b*tan(e + f*x))), x) rule3863 = ReplacementRule(pattern3863, replacement3863) pattern3864 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))/(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1439, cons31, cons168) def replacement3864(m, f, b, d, c, a, x, e): rubi.append(3864) return -Dist(a*d*m/(S(2)*b*f), Int((c + d*x)**(m + S(-1))/(a + b/tan(e + f*x)), x), x) + Simp((c + d*x)**(m + S(1))/(S(2)*a*d*(m + S(1))), x) + Simp(a*(c + d*x)**m/(S(2)*b*f*(a + b/tan(e + f*x))), x) rule3864 = ReplacementRule(pattern3864, replacement3864) pattern3865 = Pattern(Integral(S(1)/((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(x_*WC('d', S(1)) + WC('c', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1439) def replacement3865(f, b, d, c, a, x, e): rubi.append(3865) return -Dist(f/(a*d), Int(sin(S(2)*e + S(2)*f*x)/(c + d*x), x), x) + Dist(f/(b*d), Int(cos(S(2)*e + S(2)*f*x)/(c + d*x), x), x) - Simp(S(1)/(d*(a + b*tan(e + f*x))*(c + d*x)), x) rule3865 = ReplacementRule(pattern3865, replacement3865) pattern3866 = Pattern(Integral(S(1)/((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(x_*WC('d', S(1)) + WC('c', S(0)))**S(2)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1439) def replacement3866(f, b, d, c, a, x, e): rubi.append(3866) return Dist(f/(a*d), Int(sin(S(2)*e + S(2)*f*x)/(c + d*x), x), x) + Dist(f/(b*d), Int(cos(S(2)*e + S(2)*f*x)/(c + d*x), x), x) - Simp(S(1)/(d*(a + b/tan(e + f*x))*(c + d*x)), x) rule3866 = ReplacementRule(pattern3866, replacement3866) pattern3867 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**m_/(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1439, cons31, cons94, cons1510) def replacement3867(m, f, b, d, c, a, x, e): rubi.append(3867) return Dist(S(2)*b*f/(a*d*(m + S(1))), Int((c + d*x)**(m + S(1))/(a + b*tan(e + f*x)), x), x) + Simp((c + d*x)**(m + S(1))/(d*(a + b*tan(e + f*x))*(m + S(1))), x) + Simp(f*(c + d*x)**(m + S(2))/(b*d**S(2)*(m + S(1))*(m + S(2))), x) rule3867 = ReplacementRule(pattern3867, replacement3867) pattern3868 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**m_/(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1439, cons31, cons94, cons1510) def replacement3868(m, f, b, d, c, a, x, e): rubi.append(3868) return -Dist(S(2)*b*f/(a*d*(m + S(1))), Int((c + d*x)**(m + S(1))/(a + b/tan(e + f*x)), x), x) + Simp((c + d*x)**(m + S(1))/(d*(a + b/tan(e + f*x))*(m + S(1))), x) - Simp(f*(c + d*x)**(m + S(2))/(b*d**S(2)*(m + S(1))*(m + S(2))), x) rule3868 = ReplacementRule(pattern3868, replacement3868) pattern3869 = Pattern(Integral(S(1)/((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))*(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1439) def replacement3869(f, b, d, c, a, x, e): rubi.append(3869) return Dist(S(1)/(S(2)*a), Int(cos(S(2)*e + S(2)*f*x)/(c + d*x), x), x) + Dist(S(1)/(S(2)*b), Int(sin(S(2)*e + S(2)*f*x)/(c + d*x), x), x) + Simp(log(c + d*x)/(S(2)*a*d), x) rule3869 = ReplacementRule(pattern3869, replacement3869) pattern3870 = Pattern(Integral(S(1)/((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))*(x_*WC('d', S(1)) + WC('c', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1439) def replacement3870(f, b, d, c, a, x, e): rubi.append(3870) return -Dist(S(1)/(S(2)*a), Int(cos(S(2)*e + S(2)*f*x)/(c + d*x), x), x) + Dist(S(1)/(S(2)*b), Int(sin(S(2)*e + S(2)*f*x)/(c + d*x), x), x) + Simp(log(c + d*x)/(S(2)*a*d), x) rule3870 = ReplacementRule(pattern3870, replacement3870) pattern3871 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**m_/(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1439, cons18) def replacement3871(m, f, b, d, c, a, x, e): rubi.append(3871) return Dist(S(1)/(S(2)*a), Int((c + d*x)**m*exp(S(2)*a*(e + f*x)/b), x), x) + Simp((c + d*x)**(m + S(1))/(S(2)*a*d*(m + S(1))), x) rule3871 = ReplacementRule(pattern3871, replacement3871) pattern3872 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**m_/(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1439, cons18) def replacement3872(m, f, b, d, c, a, x, e): rubi.append(3872) return -Dist(S(1)/(S(2)*a), Int((c + d*x)**m*exp(-S(2)*a*(e + f*x)/b), x), x) + Simp((c + d*x)**(m + S(1))/(S(2)*a*d*(m + S(1))), x) rule3872 = ReplacementRule(pattern3872, replacement3872) pattern3873 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1439, cons1571) def replacement3873(m, f, b, d, c, a, n, x, e): rubi.append(3873) return Int(ExpandIntegrand((c + d*x)**m, (sin(S(2)*e + S(2)*f*x)/(S(2)*b) + cos(S(2)*e + S(2)*f*x)/(S(2)*a) + S(1)/(S(2)*a))**(-n), x), x) rule3873 = ReplacementRule(pattern3873, replacement3873) pattern3874 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1439, cons1571) def replacement3874(m, f, b, d, c, a, n, x, e): rubi.append(3874) return Int(ExpandIntegrand((c + d*x)**m, (sin(S(2)*e + S(2)*f*x)/(S(2)*b) - cos(S(2)*e + S(2)*f*x)/(S(2)*a) + S(1)/(S(2)*a))**(-n), x), x) rule3874 = ReplacementRule(pattern3874, replacement3874) pattern3875 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1439, cons196) def replacement3875(m, f, b, d, c, a, n, x, e): rubi.append(3875) return Int(ExpandIntegrand((c + d*x)**m, (exp(S(2)*a*(e + f*x)/b)/(S(2)*a) + S(1)/(S(2)*a))**(-n), x), x) rule3875 = ReplacementRule(pattern3875, replacement3875) pattern3876 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**m_, x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons1439, cons196) def replacement3876(m, f, b, d, c, a, n, x, e): rubi.append(3876) return Int(ExpandIntegrand((c + d*x)**m, (S(1)/(S(2)*a) - exp(-S(2)*a*(e + f*x)/b)/(S(2)*a))**(-n), x), x) rule3876 = ReplacementRule(pattern3876, replacement3876) def With3877(m, f, b, d, c, a, n, x, e): u = IntHide((a + b*tan(e + f*x))**n, x) rubi.append(3877) return -Dist(d*m, Int(Dist((c + d*x)**(m + S(-1)), u, x), x), x) + Dist((c + d*x)**m, u, x) pattern3877 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1439, cons1572, cons31, cons168) rule3877 = ReplacementRule(pattern3877, With3877) def With3878(m, f, b, d, c, a, n, x, e): u = IntHide((a + b/tan(e + f*x))**n, x) rubi.append(3878) return -Dist(d*m, Int(Dist((c + d*x)**(m + S(-1)), u, x), x), x) + Dist((c + d*x)**m, u, x) pattern3878 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1439, cons1572, cons31, cons168) rule3878 = ReplacementRule(pattern3878, With3878) pattern3879 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))/(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1440, cons62) def replacement3879(m, f, b, d, c, a, x, e): rubi.append(3879) return -Dist(S(2)*I*b, Int((c + d*x)**m/(a**S(2) + b**S(2) + (a - I*b)**S(2)*exp(S(2)*I*(e + f*x))), x), x) + Simp((c + d*x)**(m + S(1))/(d*(a - I*b)*(m + S(1))), x) rule3879 = ReplacementRule(pattern3879, replacement3879) pattern3880 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))/(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0)))), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1440, cons62) def replacement3880(m, f, b, d, c, a, x, e): rubi.append(3880) return Dist(S(2)*I*b, Int((c + d*x)**m/(a**S(2) + b**S(2) - (a + I*b)**S(2)*exp(S(2)*I*(e + f*x))), x), x) + Simp((c + d*x)**(m + S(1))/(d*(a + I*b)*(m + S(1))), x) rule3880 = ReplacementRule(pattern3880, replacement3880) pattern3881 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))/(a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1440) def replacement3881(f, b, d, c, a, x, e): rubi.append(3881) return Dist(S(1)/(f*(a**S(2) + b**S(2))), Int((S(2)*a*c*f + S(2)*a*d*f*x + b*d)/(a + b*tan(e + f*x)), x), x) - Simp((c + d*x)**S(2)/(S(2)*d*(a**S(2) + b**S(2))), x) - Simp(b*(c + d*x)/(f*(a + b*tan(e + f*x))*(a**S(2) + b**S(2))), x) rule3881 = ReplacementRule(pattern3881, replacement3881) pattern3882 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))/(a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**S(2), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1440) def replacement3882(f, b, d, c, a, x, e): rubi.append(3882) return -Dist(S(1)/(f*(a**S(2) + b**S(2))), Int((-S(2)*a*c*f - S(2)*a*d*f*x + b*d)/(a + b/tan(e + f*x)), x), x) - Simp((c + d*x)**S(2)/(S(2)*d*(a**S(2) + b**S(2))), x) + Simp(b*(c + d*x)/(f*(a + b/tan(e + f*x))*(a**S(2) + b**S(2))), x) rule3882 = ReplacementRule(pattern3882, replacement3882) pattern3883 = Pattern(Integral((a_ + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1440, cons196, cons62) def replacement3883(m, f, b, d, c, a, n, x, e): rubi.append(3883) return Int(ExpandIntegrand((c + d*x)**m, (-S(2)*I*b/(a**S(2) + b**S(2) + (a - I*b)**S(2)*exp(S(2)*I*(e + f*x))) + S(1)/(a - I*b))**(-n), x), x) rule3883 = ReplacementRule(pattern3883, replacement3883) pattern3884 = Pattern(Integral((a_ + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**n_*(x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons1440, cons196, cons62) def replacement3884(m, f, b, d, c, a, n, x, e): rubi.append(3884) return Int(ExpandIntegrand((c + d*x)**m, (S(2)*I*b/(a**S(2) + b**S(2) - (a + I*b)**S(2)*exp(S(2)*I*(e + f*x))) + S(1)/(a + I*b))**(-n), x), x) rule3884 = ReplacementRule(pattern3884, replacement3884) pattern3885 = Pattern(Integral(u_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*tan(v_))**WC('n', S(1)), x_), cons2, cons3, cons21, cons4, cons810, cons811) def replacement3885(v, u, m, b, a, n, x): rubi.append(3885) return Int((a + b*tan(ExpandToSum(v, x)))**n*ExpandToSum(u, x)**m, x) rule3885 = ReplacementRule(pattern3885, replacement3885) pattern3886 = Pattern(Integral(u_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))/tan(v_))**WC('n', S(1)), x_), cons2, cons3, cons21, cons4, cons810, cons811) def replacement3886(v, u, m, b, a, n, x): rubi.append(3886) return Int((a + b/tan(ExpandToSum(v, x)))**n*ExpandToSum(u, x)**m, x) rule3886 = ReplacementRule(pattern3886, replacement3886) pattern3887 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons1360) def replacement3887(m, f, b, d, c, a, n, x, e): rubi.append(3887) return Int((a + b*tan(e + f*x))**n*(c + d*x)**m, x) rule3887 = ReplacementRule(pattern3887, replacement3887) pattern3888 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))/tan(x_*WC('f', S(1)) + WC('e', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons125, cons21, cons4, cons1360) def replacement3888(m, f, b, d, a, n, c, x, e): rubi.append(3888) return Int((a + b/tan(e + f*x))**n*(c + d*x)**m, x) rule3888 = ReplacementRule(pattern3888, replacement3888) pattern3889 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons5, cons1573, cons38) def replacement3889(p, b, d, c, a, n, x): rubi.append(3889) return Dist(S(1)/n, Subst(Int(x**(S(-1) + S(1)/n)*(a + b*tan(c + d*x))**p, x), x, x**n), x) rule3889 = ReplacementRule(pattern3889, replacement3889) pattern3890 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons5, cons1573, cons38) def replacement3890(p, b, d, a, c, n, x): rubi.append(3890) return Dist(S(1)/n, Subst(Int(x**(S(-1) + S(1)/n)*(a + b/tan(c + d*x))**p, x), x, x**n), x) rule3890 = ReplacementRule(pattern3890, replacement3890) pattern3891 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons5, cons1495) def replacement3891(p, b, d, c, a, n, x): rubi.append(3891) return Int((a + b*tan(c + d*x**n))**p, x) rule3891 = ReplacementRule(pattern3891, replacement3891) pattern3892 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons5, cons1495) def replacement3892(p, b, d, a, c, n, x): rubi.append(3892) return Int((a + b/tan(c + d*x**n))**p, x) rule3892 = ReplacementRule(pattern3892, replacement3892) pattern3893 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(u_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons5, cons68, cons69) def replacement3893(p, u, b, d, c, a, n, x): rubi.append(3893) return Dist(S(1)/Coefficient(u, x, S(1)), Subst(Int((a + b*tan(c + d*x**n))**p, x), x, u), x) rule3893 = ReplacementRule(pattern3893, replacement3893) pattern3894 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(u_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons4, cons5, cons68, cons69) def replacement3894(p, u, b, d, a, c, n, x): rubi.append(3894) return Dist(S(1)/Coefficient(u, x, S(1)), Subst(Int((a + b/tan(c + d*x**n))**p, x), x, u), x) rule3894 = ReplacementRule(pattern3894, replacement3894) pattern3895 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*tan(u_))**WC('p', S(1)), x_), cons2, cons3, cons5, cons823, cons824) def replacement3895(p, u, b, a, x): rubi.append(3895) return Int((a + b*tan(ExpandToSum(u, x)))**p, x) rule3895 = ReplacementRule(pattern3895, replacement3895) pattern3896 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))/tan(u_))**WC('p', S(1)), x_), cons2, cons3, cons5, cons823, cons824) def replacement3896(p, u, b, a, x): rubi.append(3896) return Int((a + b/tan(ExpandToSum(u, x)))**p, x) rule3896 = ReplacementRule(pattern3896, replacement3896) pattern3897 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*tan(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons5, cons1574, cons38) def replacement3897(p, m, b, d, c, a, n, x): rubi.append(3897) return Dist(S(1)/n, Subst(Int(x**(S(-1) + (m + S(1))/n)*(a + b*tan(c + d*x))**p, x), x, x**n), x) rule3897 = ReplacementRule(pattern3897, replacement3897) pattern3898 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))/tan(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons5, cons1574, cons38) def replacement3898(p, m, b, d, a, c, n, x): rubi.append(3898) return Dist(S(1)/n, Subst(Int(x**(S(-1) + (m + S(1))/n)*(a + b/tan(c + d*x))**p, x), x, x**n), x) rule3898 = ReplacementRule(pattern3898, replacement3898) pattern3899 = Pattern(Integral(x_**WC('m', S(1))*tan(x_**n_*WC('d', S(1)) + WC('c', S(0)))**S(2), x_), cons7, cons27, cons21, cons4, cons1575) def replacement3899(m, d, c, n, x): rubi.append(3899) return -Dist((m - n + S(1))/(d*n), Int(x**(m - n)*tan(c + d*x**n), x), x) - Int(x**m, x) + Simp(x**(m - n + S(1))*tan(c + d*x**n)/(d*n), x) rule3899 = ReplacementRule(pattern3899, replacement3899) pattern3900 = Pattern(Integral(x_**WC('m', S(1))/tan(x_**n_*WC('d', S(1)) + WC('c', S(0)))**S(2), x_), cons7, cons27, cons21, cons4, cons1575) def replacement3900(m, d, c, n, x): rubi.append(3900) return Dist((m - n + S(1))/(d*n), Int(x**(m - n)/tan(c + d*x**n), x), x) - Int(x**m, x) - Simp(x**(m - n + S(1))/(d*n*tan(c + d*x**n)), x) rule3900 = ReplacementRule(pattern3900, replacement3900) pattern3901 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*tan(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons5, cons1576) def replacement3901(p, m, b, d, c, a, n, x): rubi.append(3901) return Int(x**m*(a + b*tan(c + d*x**n))**p, x) rule3901 = ReplacementRule(pattern3901, replacement3901) pattern3902 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))/tan(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons21, cons4, cons5, cons1576) def replacement3902(p, m, b, d, a, c, n, x): rubi.append(3902) return Int(x**m*(a + b/tan(c + d*x**n))**p, x) rule3902 = ReplacementRule(pattern3902, replacement3902) pattern3903 = Pattern(Integral((e_*x_)**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*tan(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons1497) def replacement3903(p, m, b, d, c, a, n, x, e): rubi.append(3903) return Dist(e**IntPart(m)*x**(-FracPart(m))*(e*x)**FracPart(m), Int(x**m*(a + b*tan(c + d*x**n))**p, x), x) rule3903 = ReplacementRule(pattern3903, replacement3903) pattern3904 = Pattern(Integral((e_*x_)**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))/tan(x_**n_*WC('d', S(1)) + WC('c', S(0))))**WC('p', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons5, cons1497) def replacement3904(p, m, b, d, a, c, n, x, e): rubi.append(3904) return Dist(e**IntPart(m)*x**(-FracPart(m))*(e*x)**FracPart(m), Int(x**m*(a + b/tan(c + d*x**n))**p, x), x) rule3904 = ReplacementRule(pattern3904, replacement3904) pattern3905 = Pattern(Integral((e_*x_)**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*tan(u_))**WC('p', S(1)), x_), cons2, cons3, cons48, cons21, cons5, cons823, cons824) def replacement3905(p, u, m, b, a, x, e): rubi.append(3905) return Int((e*x)**m*(a + b*tan(ExpandToSum(u, x)))**p, x) rule3905 = ReplacementRule(pattern3905, replacement3905) pattern3906 = Pattern(Integral((e_*x_)**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))/tan(u_))**WC('p', S(1)), x_), cons2, cons3, cons48, cons21, cons5, cons823, cons824) def replacement3906(p, u, m, b, a, x, e): rubi.append(3906) return Int((e*x)**m*(a + b/tan(ExpandToSum(u, x)))**p, x) rule3906 = ReplacementRule(pattern3906, replacement3906) pattern3907 = Pattern(Integral(x_**WC('m', S(1))*(S(1)/cos(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0))))**WC('p', S(1))*tan(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0)))**WC('q', S(1)), x_), cons2, cons3, cons5, cons31, cons85, cons1577, cons1578) def replacement3907(p, m, b, a, n, x, q): rubi.append(3907) return -Dist((m - n + S(1))/(b*n*p), Int(x**(m - n)*(S(1)/cos(a + b*x**n))**p, x), x) + Simp(x**(m - n + S(1))*(S(1)/cos(a + b*x**n))**p/(b*n*p), x) rule3907 = ReplacementRule(pattern3907, replacement3907) pattern3908 = Pattern(Integral(x_**WC('m', S(1))*(S(1)/sin(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0))))**WC('p', S(1))*(S(1)/tan(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0))))**WC('q', S(1)), x_), cons2, cons3, cons5, cons31, cons85, cons1577, cons1578) def replacement3908(p, m, b, a, n, x, q): rubi.append(3908) return Dist((m - n + S(1))/(b*n*p), Int(x**(m - n)*(S(1)/sin(a + b*x**n))**p, x), x) - Simp(x**(m - n + S(1))*(S(1)/sin(a + b*x**n))**p/(b*n*p), x) rule3908 = ReplacementRule(pattern3908, replacement3908) pattern3909 = Pattern(Integral(tan(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1)), x_), cons2, cons3, cons7, cons4, cons1579) def replacement3909(b, c, a, n, x): rubi.append(3909) return Int(tan(a + b*x + c*x**S(2))**n, x) rule3909 = ReplacementRule(pattern3909, replacement3909) pattern3910 = Pattern(Integral((S(1)/tan(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons4, cons1579) def replacement3910(b, c, a, n, x): rubi.append(3910) return Int((S(1)/tan(a + b*x + c*x**S(2)))**n, x) rule3910 = ReplacementRule(pattern3910, replacement3910) pattern3911 = Pattern(Integral((d_ + x_*WC('e', S(1)))*tan(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons47) def replacement3911(b, d, c, a, x, e): rubi.append(3911) return -Simp(e*log(cos(a + b*x + c*x**S(2)))/(S(2)*c), x) rule3911 = ReplacementRule(pattern3911, replacement3911) pattern3912 = Pattern(Integral((d_ + x_*WC('e', S(1)))/tan(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons47) def replacement3912(b, d, c, a, x, e): rubi.append(3912) return Simp(e*log(sin(a + b*x + c*x**S(2)))/(S(2)*c), x) rule3912 = ReplacementRule(pattern3912, replacement3912) pattern3913 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))*tan(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons239) def replacement3913(b, d, c, a, x, e): rubi.append(3913) return Dist((-b*e + S(2)*c*d)/(S(2)*c), Int(tan(a + b*x + c*x**S(2)), x), x) - Simp(e*log(cos(a + b*x + c*x**S(2)))/(S(2)*c), x) rule3913 = ReplacementRule(pattern3913, replacement3913) pattern3914 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))/tan(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))), x_), cons2, cons3, cons7, cons27, cons48, cons239) def replacement3914(b, d, c, a, x, e): rubi.append(3914) return Dist((-b*e + S(2)*c*d)/(S(2)*c), Int(S(1)/tan(a + b*x + c*x**S(2)), x), x) + Simp(e*log(sin(a + b*x + c*x**S(2)))/(S(2)*c), x) rule3914 = ReplacementRule(pattern3914, replacement3914) pattern3915 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*tan(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons1580) def replacement3915(m, b, d, a, c, n, x, e): rubi.append(3915) return Int((d + e*x)**m*tan(a + b*x + c*x**S(2))**n, x) rule3915 = ReplacementRule(pattern3915, replacement3915) pattern3916 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(S(1)/tan(x_**S(2)*WC('c', S(1)) + x_*WC('b', S(1)) + WC('a', S(0))))**WC('n', S(1)), x_), cons2, cons3, cons7, cons27, cons48, cons21, cons4, cons1580) def replacement3916(m, b, d, c, a, n, x, e): rubi.append(3916) return Int((d + e*x)**m*(S(1)/tan(a + b*x + c*x**S(2)))**n, x) rule3916 = ReplacementRule(pattern3916, replacement3916) return [rule3398, rule3399, rule3400, rule3401, rule3402, rule3403, rule3404, rule3405, rule3406, rule3407, rule3408, rule3409, rule3410, rule3411, rule3412, rule3413, rule3414, rule3415, rule3416, rule3417, rule3418, rule3419, rule3420, rule3421, rule3422, rule3423, rule3424, rule3425, rule3426, rule3427, rule3428, rule3429, rule3430, rule3431, rule3432, rule3433, rule3434, rule3435, rule3436, rule3437, rule3438, rule3439, rule3440, rule3441, rule3442, rule3443, rule3444, rule3445, rule3446, rule3447, rule3448, rule3449, rule3450, rule3451, rule3452, rule3453, rule3454, rule3455, rule3456, rule3457, rule3458, rule3459, rule3460, rule3461, rule3462, rule3463, rule3464, rule3465, rule3466, rule3467, rule3468, rule3469, rule3470, rule3471, rule3472, rule3473, rule3474, rule3475, rule3476, rule3477, rule3478, rule3479, rule3480, rule3481, rule3482, rule3483, rule3484, rule3485, rule3486, rule3487, rule3488, rule3489, rule3490, rule3491, rule3492, rule3493, rule3494, rule3495, rule3496, rule3497, rule3498, rule3499, rule3500, rule3501, rule3502, rule3503, rule3504, rule3505, rule3506, rule3507, rule3508, rule3509, rule3510, rule3511, rule3512, rule3513, rule3514, rule3515, rule3516, rule3517, rule3518, rule3519, rule3520, rule3521, rule3522, rule3523, rule3524, rule3525, rule3526, rule3527, rule3528, rule3529, rule3530, rule3531, rule3532, rule3533, rule3534, rule3535, rule3536, rule3537, rule3538, rule3539, rule3540, rule3541, rule3542, rule3543, rule3544, rule3545, rule3546, rule3547, rule3548, rule3549, rule3550, rule3551, rule3552, rule3553, rule3554, rule3555, rule3556, rule3557, rule3558, rule3559, rule3560, rule3561, rule3562, rule3563, rule3564, rule3565, rule3566, rule3567, rule3568, rule3569, rule3570, rule3571, rule3572, rule3573, rule3574, rule3575, rule3576, rule3577, rule3578, rule3579, rule3580, rule3581, rule3582, rule3583, rule3584, rule3585, rule3586, rule3587, rule3588, rule3589, rule3590, rule3591, rule3592, rule3593, rule3594, rule3595, rule3596, rule3597, rule3598, rule3599, rule3600, rule3601, rule3602, rule3603, rule3604, rule3605, rule3606, rule3607, rule3608, rule3609, rule3610, rule3611, rule3612, rule3613, rule3614, rule3615, rule3616, rule3617, rule3618, rule3619, rule3620, rule3621, rule3622, rule3623, rule3624, rule3625, rule3626, rule3627, rule3628, rule3629, rule3630, rule3631, rule3632, rule3633, rule3634, rule3635, rule3636, rule3637, rule3638, rule3639, rule3640, rule3641, rule3642, rule3643, rule3644, rule3645, rule3646, rule3647, rule3648, rule3649, rule3650, rule3651, rule3652, rule3653, rule3654, rule3655, rule3656, rule3657, rule3658, rule3659, rule3660, rule3661, rule3662, rule3663, rule3664, rule3665, rule3666, rule3667, rule3668, rule3669, rule3670, rule3671, rule3672, rule3673, rule3674, rule3675, rule3676, rule3677, rule3678, rule3679, rule3680, rule3681, rule3682, rule3683, rule3684, rule3685, rule3686, rule3687, rule3688, rule3689, rule3690, rule3691, rule3692, rule3693, rule3694, rule3695, rule3696, rule3697, rule3698, rule3699, rule3700, rule3701, rule3702, rule3703, rule3704, rule3705, rule3706, rule3707, rule3708, rule3709, rule3710, rule3711, rule3712, rule3713, rule3714, rule3715, rule3716, rule3717, rule3718, rule3719, rule3720, rule3721, rule3722, rule3723, rule3724, rule3725, rule3726, rule3727, rule3728, rule3729, rule3730, rule3731, rule3732, rule3733, rule3734, rule3735, rule3736, rule3737, rule3738, rule3739, rule3740, rule3741, rule3742, rule3743, rule3744, rule3745, rule3746, rule3747, rule3748, rule3749, rule3750, rule3751, rule3752, rule3753, rule3754, rule3755, rule3756, rule3757, rule3758, rule3759, rule3760, rule3761, rule3762, rule3763, rule3764, rule3765, rule3766, rule3767, rule3768, rule3769, rule3770, rule3771, rule3772, rule3773, rule3774, rule3775, rule3776, rule3777, rule3778, rule3779, rule3780, rule3781, rule3782, rule3783, rule3784, rule3785, rule3786, rule3787, rule3788, rule3789, rule3790, rule3791, rule3792, rule3793, rule3794, rule3795, rule3796, rule3797, rule3798, rule3799, rule3800, rule3801, rule3802, rule3803, rule3804, rule3805, rule3806, rule3807, rule3808, rule3809, rule3810, rule3811, rule3812, rule3813, rule3814, rule3815, rule3816, rule3817, rule3818, rule3819, rule3820, rule3821, rule3822, rule3823, rule3824, rule3825, rule3826, rule3827, rule3828, rule3829, rule3830, rule3831, rule3832, rule3833, rule3834, rule3835, rule3836, rule3837, rule3838, rule3839, rule3840, rule3841, rule3842, rule3843, rule3844, rule3845, rule3846, rule3847, rule3848, rule3849, rule3850, rule3851, rule3852, rule3853, rule3854, rule3855, rule3856, rule3857, rule3858, rule3859, rule3860, rule3861, rule3862, rule3863, rule3864, rule3865, rule3866, rule3867, rule3868, rule3869, rule3870, rule3871, rule3872, rule3873, rule3874, rule3875, rule3876, rule3877, rule3878, rule3879, rule3880, rule3881, rule3882, rule3883, rule3884, rule3885, rule3886, rule3887, rule3888, rule3889, rule3890, rule3891, rule3892, rule3893, rule3894, rule3895, rule3896, rule3897, rule3898, rule3899, rule3900, rule3901, rule3902, rule3903, rule3904, rule3905, rule3906, rule3907, rule3908, rule3909, rule3910, rule3911, rule3912, rule3913, rule3914, rule3915, rule3916, ]
f0fdfb313f836334f86fec0fc730452bc26f13dd
12e9b24bb74f26af6d3f8041a5260421d1c6094d
/urls.py
5f666db040ee70dfea1979320411ca4c465a73d7
[]
no_license
elcosca/Local-de-Juegos
a0a7cf52d57691790614fc9a5b26ffbc8a4b538f
2ddd525e0e382131e08a1fa329fe6c80bfd2f010
refs/heads/master
2021-01-17T22:12:09.189331
2016-06-06T14:17:05
2016-06-06T14:17:05
60,530,076
0
0
null
null
null
null
UTF-8
Python
false
false
117
py
from django.conf.urls import url from . import views urlpatterns = [ url(r'^$', views.vistaclientes), ]
cd87b175cdbc12d805759c77827d25017d9a2df3
5182b22e2262dabfb11f0b89a8512de7491791b0
/ceska/spiders/spider.py
947674400c7d713bd221011e9012960641942fc4
[]
no_license
SimeonYS/ceska
10d6bd8510012862a4c8ef536b9f5a816e73a9cf
7ccea2162639f8dc2c54f7f47e7da7660cead430
refs/heads/main
2023-03-24T18:38:29.212626
2021-03-19T12:36:51
2021-03-19T12:36:51
349,417,726
0
0
null
null
null
null
UTF-8
Python
false
false
1,913
py
import re import scrapy from scrapy.loader import ItemLoader from ..items import CeskaItem from itemloaders.processors import TakeFirst pattern = r'(\xa0)?' base = 'https://www.cnb.cz/system/modules/org.opencms.apollo/elements/list-ajax.jsp?contentpath=/cs/.content/lists/l_00014.xml&instanceId=li_793d48a5&elementId=le_3f676017&sitepath=/cs/cnb-news/aktuality/&subsite=/sites/cnb/cs/&__locale=cs&loc=cs&option=append&hideOptions=true&reloaded&sort=priority_d&page={}' class CeskaSpider(scrapy.Spider): name = 'ceska' page = 1 start_urls = [base.format(page)] def parse(self, response): articles = response.xpath('//div[@class="teaser "]') for article in articles: date = ''.join(article.xpath('.//div[@class="date"]/text()').get().split()) post_links = article.xpath('.//h2/a/@href').get() try: if not 'pdf' in post_links: yield response.follow(post_links, self.parse_post, cb_kwargs=dict(date=date)) except TypeError: print("Article not available") if response.xpath('//h2/a').get(): self.page += 1 yield response.follow(base.format(self.page), self.parse) def parse_post(self, response, date): title = response.xpath('//h1/text()').get() content = response.xpath('//div[@class="text"]//text() | //div[@class="block news"]/div/p//text() | //main//div[@class="ap-section "]//text()[not (ancestor::div[@class="ap-panel panel-group"])] | //table//text() | //div//em//text()|//div[@class="boarddecision-record"]/div//following-sibling::p|//div[@class="block vlog"]/div//text()').getall() content = [p.strip() for p in content if p.strip()] content = re.sub(pattern, "",' '.join(content)) item = ItemLoader(item=CeskaItem(), response=response) item.default_output_processor = TakeFirst() item.add_value('title', title) item.add_value('link', response.url) item.add_value('content', content) item.add_value('date', date) yield item.load_item()
6a4a56e8e4f6c66d3f76478204297dccc60f4250
358519772669c73092f625f630722c38e1d33783
/ctools/Testing/Types/CrossBondAngleAngleType.py
339e54158084f93f3295be2ef32cb069ec76645f
[]
no_license
minghao2016/mmtools
e7e61aca084498408ceae965dd6c9450ad89eafa
3ade988afb51cd54ee5a4067d8deaad88afbb0fe
refs/heads/master
2021-09-21T01:02:22.522187
2014-09-19T03:40:03
2014-09-19T03:40:03
null
0
0
null
null
null
null
UTF-8
Python
false
false
609
py
import sys sys.path.append('..') from Decorators import * from Types.AbstractAngleType import * class CrossBondAngleAngleType(AbstractAngleType): @accepts_compatible_units(None, None, None, None, units.nanometers, units.nanometers, units.nanometers, units.kilojoules_per_mole * units.nanometers**(-2)) def __init__(self, atom1, atom2, atom3, type, r1, r2, r3, k): AbstractAngleType.__init__(self, atom1, atom2, atom3, type) self.r1 = r1 self.r2 = r2 self.r3 = r3 self.k = k
96d971c15a7a79c262bd96806888c96e132fc4fa
9743d5fd24822f79c156ad112229e25adb9ed6f6
/xai/brain/wordbase/otherforms/_chaperons.py
4d072675f3dfa5acff95f8dd2a06dec5ec22139e
[ "MIT" ]
permissive
cash2one/xai
de7adad1758f50dd6786bf0111e71a903f039b64
e76f12c9f4dcf3ac1c7c08b0cc8844c0b0a104b6
refs/heads/master
2021-01-19T12:33:54.964379
2017-01-28T02:00:50
2017-01-28T02:00:50
null
0
0
null
null
null
null
UTF-8
Python
false
false
230
py
#calss header class _CHAPERONS(): def __init__(self,): self.name = "CHAPERONS" self.definitions = chaperon self.parents = [] self.childen = [] self.properties = [] self.jsondata = {} self.basic = ['chaperon']
1aba486226c54e541a0a920e558d5808fe2eb584
0b358a0d64eb03655c030b36c0ae87880b153951
/mmcv-1.4.7/tests/test_ops/test_roiaware_pool3d.py
1d63e398dabaf0ac6cfdf28bcb617a18368f6fd5
[ "Apache-2.0" ]
permissive
jshilong/DDQ
db05ff309d63316c62faa59b28c66d65eef973d1
de9331e4579aaafab4d69e3a9a3c6638efc5392c
refs/heads/main
2023-06-03T15:02:09.949907
2023-05-24T03:32:12
2023-05-24T03:32:12
498,974,099
199
6
Apache-2.0
2022-06-02T05:01:53
2022-06-02T03:10:25
null
UTF-8
Python
false
false
6,209
py
# Copyright (c) OpenMMLab. All rights reserved. import numpy as np import pytest import torch from mmcv.ops import (RoIAwarePool3d, points_in_boxes_all, points_in_boxes_cpu, points_in_boxes_part) @pytest.mark.skipif( not torch.cuda.is_available(), reason='requires CUDA support') def test_RoIAwarePool3d(): roiaware_pool3d_max = RoIAwarePool3d( out_size=4, max_pts_per_voxel=128, mode='max') roiaware_pool3d_avg = RoIAwarePool3d( out_size=4, max_pts_per_voxel=128, mode='avg') rois = torch.tensor( [[1.0, 2.0, 3.0, 5.0, 4.0, 6.0, -0.3 - np.pi / 2], [-10.0, 23.0, 16.0, 20.0, 10.0, 20.0, -0.5 - np.pi / 2]], dtype=torch.float32).cuda( ) # boxes (m, 7) with bottom center in lidar coordinate pts = torch.tensor( [[1, 2, 3.3], [1.2, 2.5, 3.0], [0.8, 2.1, 3.5], [1.6, 2.6, 3.6], [0.8, 1.2, 3.9], [-9.2, 21.0, 18.2], [3.8, 7.9, 6.3], [4.7, 3.5, -12.2], [3.8, 7.6, -2], [-10.6, -12.9, -20], [-16, -18, 9], [-21.3, -52, -5], [0, 0, 0], [6, 7, 8], [-2, -3, -4]], dtype=torch.float32).cuda() # points (n, 3) in lidar coordinate pts_feature = pts.clone() pooled_features_max = roiaware_pool3d_max( rois=rois, pts=pts, pts_feature=pts_feature) assert pooled_features_max.shape == torch.Size([2, 4, 4, 4, 3]) assert torch.allclose(pooled_features_max.sum(), torch.tensor(51.100).cuda(), 1e-3) pooled_features_avg = roiaware_pool3d_avg( rois=rois, pts=pts, pts_feature=pts_feature) assert pooled_features_avg.shape == torch.Size([2, 4, 4, 4, 3]) assert torch.allclose(pooled_features_avg.sum(), torch.tensor(49.750).cuda(), 1e-3) @pytest.mark.skipif( not torch.cuda.is_available(), reason='requires CUDA support') def test_points_in_boxes_part(): boxes = torch.tensor( [[[1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 0.3]], [[-10.0, 23.0, 16.0, 10, 20, 20, 0.5]]], dtype=torch.float32).cuda( ) # boxes (b, t, 7) with bottom center in lidar coordinate pts = torch.tensor( [[[1, 2, 3.3], [1.2, 2.5, 3.0], [0.8, 2.1, 3.5], [1.6, 2.6, 3.6], [0.8, 1.2, 3.9], [-9.2, 21.0, 18.2], [3.8, 7.9, 6.3], [4.7, 3.5, -12.2]], [[3.8, 7.6, -2], [-10.6, -12.9, -20], [-16, -18, 9], [-21.3, -52, -5], [0, 0, 0], [6, 7, 8], [-2, -3, -4], [6, 4, 9]]], dtype=torch.float32).cuda() # points (b, m, 3) in lidar coordinate point_indices = points_in_boxes_part(points=pts, boxes=boxes) expected_point_indices = torch.tensor( [[0, 0, 0, 0, 0, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1]], dtype=torch.int32).cuda() assert point_indices.shape == torch.Size([2, 8]) assert (point_indices == expected_point_indices).all() boxes = torch.tensor([[[0.0, 0.0, 0.0, 1.0, 20.0, 1.0, 0.523598]]], dtype=torch.float32).cuda() # 30 degrees pts = torch.tensor( [[[4, 6.928, 0], [6.928, 4, 0], [4, -6.928, 0], [6.928, -4, 0], [-4, 6.928, 0], [-6.928, 4, 0], [-4, -6.928, 0], [-6.928, -4, 0]]], dtype=torch.float32).cuda() point_indices = points_in_boxes_part(points=pts, boxes=boxes) expected_point_indices = torch.tensor([[-1, -1, 0, -1, 0, -1, -1, -1]], dtype=torch.int32).cuda() assert (point_indices == expected_point_indices).all() def test_points_in_boxes_cpu(): boxes = torch.tensor( [[[1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 0.3], [-10.0, 23.0, 16.0, 10, 20, 20, 0.5]]], dtype=torch.float32 ) # boxes (m, 7) with bottom center in lidar coordinate pts = torch.tensor( [[[1, 2, 3.3], [1.2, 2.5, 3.0], [0.8, 2.1, 3.5], [1.6, 2.6, 3.6], [0.8, 1.2, 3.9], [-9.2, 21.0, 18.2], [3.8, 7.9, 6.3], [4.7, 3.5, -12.2], [3.8, 7.6, -2], [-10.6, -12.9, -20], [ -16, -18, 9 ], [-21.3, -52, -5], [0, 0, 0], [6, 7, 8], [-2, -3, -4]]], dtype=torch.float32) # points (n, 3) in lidar coordinate point_indices = points_in_boxes_cpu(points=pts, boxes=boxes) expected_point_indices = torch.tensor( [[[1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [0, 1], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]], dtype=torch.int32) assert point_indices.shape == torch.Size([1, 15, 2]) assert (point_indices == expected_point_indices).all() boxes = torch.tensor([[[0.0, 0.0, 0.0, 1.0, 20.0, 1.0, 0.523598]]], dtype=torch.float32) # 30 degrees pts = torch.tensor( [[[4, 6.928, 0], [6.928, 4, 0], [4, -6.928, 0], [6.928, -4, 0], [-4, 6.928, 0], [-6.928, 4, 0], [-4, -6.928, 0], [-6.928, -4, 0]]], dtype=torch.float32) point_indices = points_in_boxes_cpu(points=pts, boxes=boxes) expected_point_indices = torch.tensor( [[[0], [0], [1], [0], [1], [0], [0], [0]]], dtype=torch.int32) assert (point_indices == expected_point_indices).all() @pytest.mark.skipif( not torch.cuda.is_available(), reason='requires CUDA support') def test_points_in_boxes_all(): boxes = torch.tensor( [[[1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 0.3], [-10.0, 23.0, 16.0, 10, 20, 20, 0.5]]], dtype=torch.float32).cuda( ) # boxes (m, 7) with bottom center in lidar coordinate pts = torch.tensor( [[[1, 2, 3.3], [1.2, 2.5, 3.0], [0.8, 2.1, 3.5], [1.6, 2.6, 3.6], [0.8, 1.2, 3.9], [-9.2, 21.0, 18.2], [3.8, 7.9, 6.3], [4.7, 3.5, -12.2], [3.8, 7.6, -2], [-10.6, -12.9, -20], [ -16, -18, 9 ], [-21.3, -52, -5], [0, 0, 0], [6, 7, 8], [-2, -3, -4]]], dtype=torch.float32).cuda() # points (n, 3) in lidar coordinate point_indices = points_in_boxes_all(points=pts, boxes=boxes) expected_point_indices = torch.tensor( [[[1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [0, 1], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]], dtype=torch.int32).cuda() assert point_indices.shape == torch.Size([1, 15, 2]) assert (point_indices == expected_point_indices).all()
1f06329bdb958c952b45f9999504208e107b2d5f
9df795e57589a99838199f97945e96811e288e75
/W1H6.py
c7697994bf32feea0b63e1fc816073e065b0b847
[]
no_license
JakeAttard/2810ICTPythonExercises
945783908a6bf981fc8128a5fc0b4bda6fd52eea
199cc42402a5cf4d8b86060af377d3906af00429
refs/heads/master
2020-06-17T19:07:46.788283
2019-07-16T11:22:15
2019-07-16T11:22:15
196,018,674
0
0
null
null
null
null
UTF-8
Python
false
false
933
py
from PyTest import * ##//////////////////////////// PROBLEM STATEMENT ////////////////////////// ## Given a list of ints, decide which is larger of the first and // ## last elements in the list, and set all the other elements to be that // ## that value. Print the changed list. Implement functions for: // ## - reading the list // ## - finding the maximum of 2 integers // ## - setting all elements of a list to a single value // ## - printing a list // ## 1, 2, 3 -> 3, 3, 3 // ## 11, 5, 9 -> 11, 11, 11 // ## 2, 11, 3 -> 3, 3, 3 // ##/////////////////////////////////////////////////////////////////////////
5111a6203d84626a25438f3983595a8afe6d5062
6679fd1102802bf190294ef43c434b6047840dc2
/openconfig_bindings/bgp/neighbors/neighbor/afi_safis/afi_safi/l2vpn_evpn/prefix_limit/__init__.py
d39885c64343ce820dca9f5c1b53b778f4985ee5
[]
no_license
robshakir/pyangbind-openconfig-napalm
d49a26fc7e38bbdb0419c7ad1fbc590b8e4b633e
907979dc14f1578f4bbfb1c1fb80a2facf03773c
refs/heads/master
2023-06-13T17:17:27.612248
2016-05-10T16:46:58
2016-05-10T16:46:58
58,091,515
5
0
null
null
null
null
UTF-8
Python
false
false
7,293
py
from operator import attrgetter import pyangbind.lib.xpathhelper as xpathhelper from pyangbind.lib.yangtypes import RestrictedPrecisionDecimalType, RestrictedClassType, TypedListType from pyangbind.lib.yangtypes import YANGBool, YANGListType, YANGDynClass, ReferenceType from pyangbind.lib.base import PybindBase from decimal import Decimal from bitarray import bitarray import config import state class prefix_limit(PybindBase): """ This class was auto-generated by the PythonClass plugin for PYANG from YANG module openconfig-bgp - based on the path /bgp/neighbors/neighbor/afi-safis/afi-safi/l2vpn-evpn/prefix-limit. Each member element of the container is represented as a class variable - with a specific YANG type. YANG Description: Configure the maximum number of prefixes that will be accepted from a peer """ __slots__ = ('_pybind_generated_by', '_path_helper', '_yang_name', '_extmethods', '__config','__state',) _yang_name = 'prefix-limit' _pybind_generated_by = 'container' def __init__(self, *args, **kwargs): helper = kwargs.pop("path_helper", None) if helper is False: self._path_helper = False elif helper is not None and isinstance(helper, xpathhelper.YANGPathHelper): self._path_helper = helper elif hasattr(self, "_parent"): helper = getattr(self._parent, "_path_helper", False) self._path_helper = helper else: self._path_helper = False self._extmethods = False self.__state = YANGDynClass(base=state.state, is_container='container', yang_name="state", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/bgp', defining_module='openconfig-bgp', yang_type='container', is_config=True) self.__config = YANGDynClass(base=config.config, is_container='container', yang_name="config", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/bgp', defining_module='openconfig-bgp', yang_type='container', is_config=True) load = kwargs.pop("load", None) if args: if len(args) > 1: raise TypeError("cannot create a YANG container with >1 argument") all_attr = True for e in self._pyangbind_elements: if not hasattr(args[0], e): all_attr = False break if not all_attr: raise ValueError("Supplied object did not have the correct attributes") for e in self._pyangbind_elements: nobj = getattr(args[0], e) if nobj._changed() is False: continue setmethod = getattr(self, "_set_%s" % e) if load is None: setmethod(getattr(args[0], e)) else: setmethod(getattr(args[0], e), load=load) def _path(self): if hasattr(self, "_parent"): return self._parent._path()+[self._yang_name] else: return [u'bgp', u'neighbors', u'neighbor', u'afi-safis', u'afi-safi', u'l2vpn-evpn', u'prefix-limit'] def _get_config(self): """ Getter method for config, mapped from YANG variable /bgp/neighbors/neighbor/afi_safis/afi_safi/l2vpn_evpn/prefix_limit/config (container) YANG Description: Configuration parameters relating to the prefix limit for the AFI-SAFI """ return self.__config def _set_config(self, v, load=False): """ Setter method for config, mapped from YANG variable /bgp/neighbors/neighbor/afi_safis/afi_safi/l2vpn_evpn/prefix_limit/config (container) If this variable is read-only (config: false) in the source YANG file, then _set_config is considered as a private method. Backends looking to populate this variable should do so via calling thisObj._set_config() directly. YANG Description: Configuration parameters relating to the prefix limit for the AFI-SAFI """ try: t = YANGDynClass(v,base=config.config, is_container='container', yang_name="config", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/bgp', defining_module='openconfig-bgp', yang_type='container', is_config=True) except (TypeError, ValueError): raise ValueError({ 'error-string': """config must be of a type compatible with container""", 'defined-type': "container", 'generated-type': """YANGDynClass(base=config.config, is_container='container', yang_name="config", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/bgp', defining_module='openconfig-bgp', yang_type='container', is_config=True)""", }) self.__config = t if hasattr(self, '_set'): self._set() def _unset_config(self): self.__config = YANGDynClass(base=config.config, is_container='container', yang_name="config", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/bgp', defining_module='openconfig-bgp', yang_type='container', is_config=True) def _get_state(self): """ Getter method for state, mapped from YANG variable /bgp/neighbors/neighbor/afi_safis/afi_safi/l2vpn_evpn/prefix_limit/state (container) YANG Description: State information relating to the prefix-limit for the AFI-SAFI """ return self.__state def _set_state(self, v, load=False): """ Setter method for state, mapped from YANG variable /bgp/neighbors/neighbor/afi_safis/afi_safi/l2vpn_evpn/prefix_limit/state (container) If this variable is read-only (config: false) in the source YANG file, then _set_state is considered as a private method. Backends looking to populate this variable should do so via calling thisObj._set_state() directly. YANG Description: State information relating to the prefix-limit for the AFI-SAFI """ try: t = YANGDynClass(v,base=state.state, is_container='container', yang_name="state", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/bgp', defining_module='openconfig-bgp', yang_type='container', is_config=True) except (TypeError, ValueError): raise ValueError({ 'error-string': """state must be of a type compatible with container""", 'defined-type': "container", 'generated-type': """YANGDynClass(base=state.state, is_container='container', yang_name="state", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/bgp', defining_module='openconfig-bgp', yang_type='container', is_config=True)""", }) self.__state = t if hasattr(self, '_set'): self._set() def _unset_state(self): self.__state = YANGDynClass(base=state.state, is_container='container', yang_name="state", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, namespace='http://openconfig.net/yang/bgp', defining_module='openconfig-bgp', yang_type='container', is_config=True) config = property(_get_config, _set_config) state = property(_get_state, _set_state) _pyangbind_elements = {'config': config, 'state': state, }
58d84b967fea13f23dfd606dbbbaff2c1b0c6fca
eefb06b0d8c8c98c1e9cfc4c3852d5c453eb5429
/data/input/arq5x/gemini/gemini/gemini_subjects.py
8e37ac5264f4dcab2ca74e6bbb8e117536329421
[]
no_license
bopopescu/pythonanalyzer
db839453bde13bf9157b76e54735f11c2262593a
8390a0139137574ab237b3ff5fe8ea61e8a0b76b
refs/heads/master
2022-11-22T02:13:52.949119
2019-05-07T18:42:52
2019-05-07T18:42:52
282,079,884
0
0
null
2020-07-23T23:46:09
2020-07-23T23:46:08
null
UTF-8
Python
false
false
5,028
py
#!/usr/bin/env python import sys from collections import defaultdict from compiler import compile from inheritance import Family import sqlalchemy as sql import database from gemini_constants import * import GeminiQuery from functools import wraps def compile_decorator(f): """decorator to automatically compile the eval strings returned from the filter methods""" @wraps(f) def wrapper(*args, **kwargs): query_string = f(*args, **kwargs) if query_string == "False" or query_string == {"any": "False"}: return None if not isinstance(query_string, dict): return compile(query_string, "<string>", "eval") query_dict = query_string for k, stmt in query_dict.iteritems(): query_dict[k] = compile(stmt, "<string>", "eval") return query_dict return wrapper def get_phred_query(sample_id, gt_ll, genotype, prefix=" and ", invert=False): """Default is to test < where a low value phred-scale is high confidence for that genotype >>> get_phred_query(2, 22, "het") ' and gt_phred_ll_het[1] < 22' >>> get_phred_query(2, 22, "het", prefix="") 'gt_phred_ll_het[1] < 22' >>> get_phred_query(2, 22, "het", prefix="", invert=True) 'gt_phred_ll_het[1] > 22' """ assert genotype in ("het", "homref", "homalt") if not gt_ll: return "" # they passed in the subject: if hasattr(sample_id, "sample_id"): sample_id = sample_id.sample_id sign = ["<", ">"][int(invert)] s = "gt_phred_ll_{genotype}[{sample_id}] {sign} {gt_ll}"\ .format(sample_id=sample_id-1, genotype=genotype, gt_ll=gt_ll, sign=sign) return prefix + s class Subject(object): """ Describe a single subject in the the samples table. """ def __init__(self, row): self._set_fields_from_row(row) def __repr__(self): return "\t".join(map(str, [self.name, self.paternal_id, self.maternal_id, self.phenotype])) def set_father(self): self.father = True def set_mother(self): self.mother = True def _set_fields_from_row(self, row): self.__dict__.update(row) #for k, v in zip(row.keys(), row): # self.__dict__[k] = v self.phenotype = int(self.phenotype) if self._has_phenotype() else None self._set_affected_status() def _has_phenotype(self): if hasattr(self, 'phenotype') and self.phenotype is not None: return True def _set_affected_status(self): # 1 = unaffected # 2 = affected # 0 or -9 is unknown. # http://pngu.mgh.harvard.edu/~purcell/plink/data.shtml#ped pheno = str(self.phenotype) if pheno == "2": self.affected = True elif pheno == "1": self.affected = False # distinguish unknown from known to be unaffected. else: self.affected = None def get_families(db, selected_families=None): """ Query the samples table to return a list of Family objects that each contain all of the Subjects in a Family. """ conn, metadata = database.get_session_metadata(db) families_dict = Family.from_cursor(conn) # if the user has specified a set of selected families # to which the analysis should be restricted, then # first sanity check that the family ids they specified are valid. if selected_families is not None: for family in selected_families.split(','): if family not in families_dict: sys.exit("ERROR: family \"%s\" is not a valid family_id\n" % family) families = [] for fam in families_dict: if selected_families is None or fam in selected_families: families.append(families_dict[fam]) return families def get_family_dict(args): families = defaultdict(list) subjects = get_subjects(args) for subject in subjects.values(): families[subject.family_id].append(subject) return families def get_subjects(args, skip_filter=False): """ return a dictionary of subjects, optionally using the subjects_query argument to filter them. """ gq = GeminiQuery.GeminiQuery(args.db) #query = "SELECT * FROM samples" query = "" if not skip_filter: if hasattr(args, 'sample_filter') and args.sample_filter: query += args.sample_filter res = gq.metadata.tables["samples"].select().where(sql.text(query)).execute() samples_dict = {} for row in res: subject = Subject(row) samples_dict[subject.name] = subject return samples_dict def get_subjects_in_family(args, family): subjects = get_subjects(args) family_names = [f.name for f in family] subject_dict = {} for subject in subjects: if subject in family_names: subject_dict[subject] = subjects[subject] return subject_dict if __name__ == "__main__": import doctest doctest.testmod()
846c2d99b09c295dd8697264c90fbd338692b861
cdca191b2a50d173dc2768d2401b069983b4bc5a
/log_entries/core/test/test_models.py
dcfe95f2012cd39abbc739917742869882ad5220
[]
no_license
lffsantos/demo_django_rest_framework
20bdefd7ab302eba54034ee52e361a8a38d4bc3d
f8eb5d23187a7de83254b2ff15f18135312d8d64
refs/heads/master
2021-01-21T10:46:26.734931
2017-03-08T02:35:42
2017-03-08T02:35:42
83,486,265
1
0
null
null
null
null
UTF-8
Python
false
false
881
py
from datetime import datetime from django.contrib.auth.models import User from django.test import TestCase from log_entries.core.models import Category, Event class CategoryModelTest(TestCase): def setUp(self): self.category = Category.objects.create(name='Category Name') def test_create(self): self.assertTrue(Category.objects.exists()) class EventModelTest(TestCase): def setUp(self): self.user = User.objects.create(username='lffsantos', password='test', email='[email protected]') self.category = Category.objects.create(name='Category Name') self.event = Event.objects.create( start_date=datetime.now(), note='small note', category=self.category, user=self.user ) def test_create(self): self.assertTrue(Category.objects.exists())
96c4c58bea2421f64d9d6901a99f7c763bf37060
5dd7c4ec44b76180040badc67849ad44f81690f9
/unittests/test_taskbar.py
4b2756dc29ed07e37d2acf6e41035bf09ba17dfb
[]
no_license
myluco/Phoenix
68f9abe15a673fe56da6ef4375849ba6a642622d
2de746beda35b8b5db547658cae1c65cfe164039
refs/heads/master
2021-01-18T15:59:05.001240
2016-12-04T00:08:36
2016-12-04T00:08:36
null
0
0
null
null
null
null
UTF-8
Python
false
false
1,202
py
import unittest from unittests import wtc import wx import wx.adv import os icoFile = os.path.join(os.path.dirname(__file__), 'mondrian.ico') #--------------------------------------------------------------------------- class taskbar_Tests(wtc.WidgetTestCase): def test_taskbar1(self): icon = wx.adv.TaskBarIcon(wx.adv.TBI_DOCK) icon.SetIcon(wx.Icon(icoFile), "The tip string") self.assertTrue(icon.IsOk()) icon.Destroy() self.myYield() def test_taskbar2(self): wx.adv.TBI_DOCK wx.adv.TBI_CUSTOM_STATUSITEM wx.adv.TBI_DEFAULT_TYPE wx.adv.TaskBarIconEvent wx.adv.wxEVT_TASKBAR_MOVE wx.adv.wxEVT_TASKBAR_LEFT_DOWN wx.adv.wxEVT_TASKBAR_LEFT_UP wx.adv.wxEVT_TASKBAR_RIGHT_DOWN wx.adv.wxEVT_TASKBAR_RIGHT_UP wx.adv.wxEVT_TASKBAR_LEFT_DCLICK wx.adv.wxEVT_TASKBAR_RIGHT_DCLICK wx.adv.wxEVT_TASKBAR_CLICK wx.adv.wxEVT_TASKBAR_BALLOON_TIMEOUT wx.adv.wxEVT_TASKBAR_BALLOON_CLICK #--------------------------------------------------------------------------- if __name__ == '__main__': unittest.main()
8d9aa0ed19ba794ae0ed1f5ff5699dc0c7a128fc
a93cf8f695c1d1d97b8d0b9ccec6932c5e499ff8
/프로그래머스/프로그래머스/seungjun/더맵게.py
416fd1611e932a873f6f1a24c27cc884e86eb9dc
[]
no_license
tmdwns1101/AlgorithmStudy
0abc108a7a73895934da2633998c7a90137d49ea
e8ca069e202f40e074b7311626fe8da8af057589
refs/heads/master
2021-07-22T11:32:30.817108
2020-05-20T16:28:27
2020-05-20T16:28:27
165,377,838
0
1
null
2020-02-07T07:56:16
2019-01-12T11:02:59
C++
UTF-8
Python
false
false
521
py
import heapq def more_spicy(scoville, K): ans = 0 heapq.heapify(scoville) print(scoville) while True: first_low = heapq.heappop(scoville) if first_low >= K: break ans += 1 if len(scoville) < 1: ans = -1 break second_low = heapq.heappop(scoville) new_scoville = first_low + (second_low *2) heapq.heappush(scoville, new_scoville) return ans res = more_spicy([1, 12, 3, 9, 10, 2], 7) print(res)
7c6fbf8d50d58b7f0a0e3921338317cc87a7d3ef
6c8579c6d825ba6bb8ca6eee3bbdd49149989eca
/second_phase/ex02_Greedy.py
f82876045c9a7e044e31bb99505c592ed3e7f808
[ "MIT" ]
permissive
kapuni/exercise_py
d7fc137d6da332174e86b28a4bec9596efca17c9
b60ba8462d2545cae57483bcb0b3428b03c5d522
refs/heads/master
2020-06-24T00:56:20.566689
2019-09-28T02:22:44
2019-09-28T02:22:44
198,801,143
0
0
null
null
null
null
UTF-8
Python
false
false
1,247
py
""" 贪婪法:在对问题求解时,总是做出在当前看来是最好的选择,不追求最优解,快速找到满意解。 输入: 20 6 电脑 200 20 收音机 20 4 钟 175 10 花瓶 50 2 书 10 1 油画 90 9 """ class Thing(object): """物品""" def __init__(self, name, price, weight): self.name = name self.price = price self.weight = weight @property def value(self): """价格重量比""" return self.price / self.weight def input_thing(): """输入物品信息""" name_str, price_str, weight_str = input().split() return name_str, int(price_str), int(weight_str) def main(): """主函数""" max_weight, num_of_things = map(int, input().split()) all_things = [] for _ in range(num_of_things): all_things.append(Thing(*input_thing())) all_things.sort(key=lambda x: x.value, reverse=True) total_weight = 0 total_price = 0 for thing in all_things: if total_weight + thing.weight <= max_weight: print(f'小偷拿走了{thing.name}') total_weight += thing.weight total_price += thing.price print(f'总价值: {total_price}美元') if __name__ == '__main__': main()
727ffe3c5be6860e52c9b43e1c5b8da8a1c06e48
bc539788b876773e294383863252c1637de9eb7f
/scrapy/PycharmProjects/Reptile/ven/renrenche.py
9d7e185cb2e3ca6d2f245a584b281c79b339c800
[]
no_license
umsung/scrapy
4eb56bf74f3e617e49dcdec61cf77010eb912f4f
deacd9f289159c5af114b0dd3110448ad7eb43e8
refs/heads/master
2020-05-31T14:11:46.530793
2019-10-16T01:32:25
2019-10-16T01:32:25
190,321,772
3
0
null
null
null
null
UTF-8
Python
false
false
6,628
py
# -*- coding: utf-8 -*- import scrapy import re from fontTools.ttLib import TTFont import requests class RenrencheSpider(scrapy.Spider): name = 'renrenche' start_urls = ['https://www.renrenche.com/gz/ershouche/?&plog_id=bd49e5ed507aebb8599cdde8188a3eef'] def start_requests(self): # for i in range(1, 5, 1): # self.start_urls.append( # 'https://www.renrenche.com/gz/ershouche/p{}/?&plog_id=79d79d263044559732d687b64c258ab4'.format(i)) for url in self.start_urls: yield scrapy.Request(url=url, callback=self.parse) def parse(self, response): """ https://www.renrenche.com/gz/ershouche/p1/?&plog_id=79d79d263044559732d687b64c258ab4 初步看了下,从列表页到内容页,并没有用ajax加载数据,只需要用xpath提取元素字段即可。 打开源代码会发现,原来TM有“投毒”,源代码数据与显示数据不一致,看来这也是一种反爬措施 """ # html = response.body.decode('utf-8') # select = etree.HTML(html) # style = select.xpath('//style/text()')[0] # # url('https://misc.rrcimg.com/ttf/rrcttf86293b76594a1bf9ace9fd979b62db63.woff') format('woff') # font_url = re.search(r"url\('(.*?\.woff)'\) format\('woff'\),", str(style)).group(1) # 获取字体url font_url = re.findall('(https://misc.rrcimg.com.*\.ttf)', response.body.decode('utf-8'))[0] # 字体文件下载 with open('人人车.ttf', 'wb') as f: f.write(requests.get(font_url).content) font_dict = font_name('人人车.ttf') node_list = response.xpath('//*[@id="search_list_wrapper"]/div/div/div[1]/ul//li') for node in node_list: item = {} # 车的名字 item['car_name'] = node.xpath('./a/h3/text()').extract_first('') item['car_name'] = base_font(font_dict, item['car_name']), response.url # 车的信息 item['car_info'] = node.xpath('./a/div[2]/span').xpath('string(.)').extract_first('') item['car_info'] = re.sub('\s', '', item['car_info']) item['car_info'] = base_font(font_dict, item['car_info']), response.url # 车的价格 item['car_price'] = node.xpath('./a/div[4]/div/text()').extract_first('') item['car_price'] = re.sub('\s', '', item['car_price']) # 首付金额 item['car_down_payment'] = node.xpath('./a/div[4]//div[@class="m-l"]/text()').extract_first('') # 链接 item['car_link'] = node.xpath('./a/@href').extract_first('') item['car_link'] = response.urljoin(item['car_link']) yield scrapy.Request(url=item['car_link'], callback=self.parse_item, meta={'item': item}) next_pages = response.xpath('//ul[@class="pagination js-pagination"]/li[last()]/a/@href').extract_first('') next_pages = response.urljoin(next_pages) yield scrapy.Request(url=next_pages, callback=self.parse) def parse_item(self, response): item = response.meta['item'] # 新车购置税 item['car_tax'] = response.xpath('//div[@class="middle-content"]/div/div').xpath('string(.)').extract_first('') item['car_tax'] = re.sub('\s', '', item['car_tax']) # 购买方式 item['car_method'] = response.xpath('//div[@class="list payment-list"]/p[1]/text()').extract_first('') # 首付金额 item['car_payment'] = response.xpath('//div[@class="list payment-list"]/p[2]/text()').extract_first('') # 月供金额 item['car_month'] = response.xpath('//div[@class="list payment-list"]/p[3]/text()').extract_first('') # 服务费 item['car_fee'] = response.xpath('//div[@class="detail-version3-service"]/p[2]').xpath( 'string(.)').extract_first('') item['car_fee'] = re.sub('\s', '', item['car_fee']) # 车牌所在地 item['car_location'] = response.xpath('//div[@class="licensed-city"]/p/strong/text()').extract_first('') # 外迁查询 item['car_find'] = response.xpath('//li[@class="span5 car-fluid-standard"]/div/p/strong/text()').extract_first( '') # # 车辆到期时间 # item['car_annual'] = response.xpath('//div[@class="info-about-car"]/div/ul/li[2]/text()').extract_first('') # item['car_annual'] = re.sub('\s', '', item['car_annual']) # # 商业险到期时间 # item['car_insurance'] = response.xpath('//div[@class="info-about-car"]/div/ul/li[4]/text()').extract_first( # default='') # item['car_insurance'] = re.sub('\s', '', item['car_insurance']) # # 有无发票 # item['car_invoice'] = response.xpath('//div[@class="info-about-car"]/div/ul/li[6]/text()').extract_first( # default='') # item['car_invoice'] = re.sub('\s', '', item['car_invoice']) # # 是否保养 # item['car_maintenance'] = response.xpath('//div[@class="info-about-car"]/div/ul/li[8]/text()').extract_first( # default='') # item['car_maintenance'] = re.sub('\s', '', item['car_maintenance']) yield item def font_name(name): ''' 通过手敲的映射关系,解析字体文件 ''' number_map = {'eight': '8', 'five': '5', 'one': '1', 'nine': '9', 'period': '?', 'three': '3', 'six': '6', 'two': '2', 'seven': '7', 'four': '4', 'zero': '0'} # 下载下来的font文件 font = TTFont(name) num = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] # 取出来font文件中的zero到nine,从第一个开始 font_num = font.getGlyphOrder()[1:] # print('--------------',font_num) # ['zero', 'one', 'two', 'three', 'four', 'five', 'seven', 'eight', 'six', 'nine'] dic_font = dict(zip(num, font_num)) # print('**************',dic_font) # {'0': 'zero', '1': 'one', '2': 'two', '3': 'three', '4': 'four', '5': 'five', '6': 'seven', '7': 'eight', '8': 'six', '9': 'nine'} dict_num = {} for k, v in dic_font.items(): for x, y in number_map.items(): if dic_font[k] == x: dict_num[y] = k return dict_num def base_font(dict, base_str): ''' 对照字典,解码字符串 :param dict: :param base_str: :return: ''' str_lis = [] num_lis = list(dict.keys()) for i in base_str: if i in num_lis: i = dict[i] str_lis.append(i) else: i = i str_lis.append(i) str_ = ''.join(str_lis) return str_
a2345ab272adc99d54adbc6b432d99beb050fffd
19c198a6b7c39d5d5bf617071ff4e04da00bc37c
/utils/__init__.py
a6109e2f30dbf1816ac7f9be98bee1326e09776b
[ "MIT" ]
permissive
corenel/lintcode
3bed15e023468ab748f81bdad0f57288c90a10e7
e985cc8541ad26352a4ae2c8c8e4a572a5368e43
refs/heads/master
2020-04-24T04:11:16.034144
2019-03-30T05:33:48
2019-03-30T05:33:48
171,694,555
1
0
null
null
null
null
UTF-8
Python
false
false
180
py
from .linked_list import ListNode, DListNode, LinkedList from .binary_tree import TreeNode, BinaryTree __all__ = ( ListNode, DListNode, LinkedList, TreeNode, BinaryTree )
9d3bdd21b443a2196b748c9140a0d1065a874532
a0c030be3f64e854fb93f9068463574a71445409
/smartlink2/base/management/commands/load_initial_data.py
d2bf603b0eeb17a67532ac42300e285127ba126d
[ "Apache-2.0" ]
permissive
quanpower/smartlink2
a233178fb5cecd95fcbcb7f29819035e05a31aee
051d4a1b63de7885f47d141d37f1dd8e667bc977
refs/heads/master
2020-03-12T03:54:57.119170
2018-05-16T07:49:18
2018-05-16T07:49:18
130,433,872
0
0
null
null
null
null
UTF-8
Python
false
false
999
py
import os from django.conf import settings from django.core.management.base import BaseCommand from django.core.management import call_command from wagtail.core.models import Site, Page class Command(BaseCommand): def handle(self, **options): fixtures_dir = os.path.join(settings.BASE_DIR, 'base', 'fixtures') fixture_file = os.path.join(fixtures_dir, 'smartlink2.json') # Wagtail creates default Site and Page instances during install, but we already have # them in the data load. Remove the auto-generated ones. if Site.objects.filter(hostname='localhost').exists(): Site.objects.get(hostname='localhost').delete() if Page.objects.filter(title='Welcome to your new Wagtail site!').exists(): Page.objects.get(title='Welcome to your new Wagtail site!').delete() call_command('loaddata', fixture_file, verbosity=0) print("Awesome. Your data is loaded! The bakery's doors are almost ready to open...")
d861c921f2e725ebbd2057ade0e240359e77ffb4
b2b01127348882a086509f1c1dbad27aa4c46539
/BillProject/manage.py
fc6da05e12636e2edd95a21b2536cf03e04c5123
[]
no_license
cs-fullstack-2019-fall/django_auth_lecture
fa4368af0fa17f686f525e3940a1cca4ed07b032
2229362d02d9446b8228eb0eab1d2665ba09da2b
refs/heads/master
2020-08-09T03:51:52.586628
2019-10-10T13:57:04
2019-10-10T13:57:04
213,990,112
0
0
null
null
null
null
UTF-8
Python
false
false
543
py
#!/usr/bin/env python import os import sys if __name__ == "__main__": os.environ.setdefault("DJANGO_SETTINGS_MODULE", "BillProject.settings") try: from django.core.management import execute_from_command_line except ImportError as exc: raise ImportError( "Couldn't import Django. Are you sure it's installed and " "available on your PYTHONPATH environment variable? Did you " "forget to activate a virtual environment?" ) from exc execute_from_command_line(sys.argv)
c8b517029204f44f4f96df1948befb308303c2a2
7b3711d4c6d7284255ba0270d49d120f984bf7c6
/problems/993_cousins_in_binary_tree.py
5f16f8c11d24961eae2193364d16e0279402ba9f
[]
no_license
loganyu/leetcode
2d336f30feb55379aaf8bf0273d00e11414e31df
77c206305dd5cde0a249365ce7591a644effabfc
refs/heads/master
2023-08-18T09:43:10.124687
2023-08-18T00:44:51
2023-08-18T00:44:51
177,875,222
0
0
null
null
null
null
UTF-8
Python
false
false
1,844
py
''' In a binary tree, the root node is at depth 0, and children of each depth k node are at depth k+1. Two nodes of a binary tree are cousins if they have the same depth, but have different parents. We are given the root of a binary tree with unique values, and the values x and y of two different nodes in the tree. Return true if and only if the nodes corresponding to the values x and y are cousins. Example 1: Input: root = [1,2,3,4], x = 4, y = 3 Output: false Example 2: Input: root = [1,2,3,null,4,null,5], x = 5, y = 4 Output: true Example 3: Input: root = [1,2,3,null,4], x = 2, y = 3 Output: false Note: The number of nodes in the tree will be between 2 and 100. Each node has a unique integer value from 1 to 100. ''' # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def isCousins(self, root: TreeNode, x: int, y: int) -> bool: x_found = False y_found = False queue = collections.deque([root]) while queue: for _ in range(len(queue)): node = queue.popleft() if node.val == x: x_found = True elif node.val == y: y_found = True if node.left and node.right: if node.left.val == x and node.right.val == y: return False elif node.left.val == y and node.right.val == x: return False if node.left: queue.append(node.left) if node.right: queue.append(node.right) if x_found or y_found: return x_found and y_found return False
137f03b89a24f65eb9a523a4f90a4cc5e1d107ba
4806f706b703a4b9ccd8cbca8fcbf300621c32ec
/easy/Remove Duplicates from Sorted List/solution.py
1ee8ac610e9793d7cf1a9a39cada702b76117f65
[ "MIT" ]
permissive
vishsanghishetty/LC-Python
aa46151162d74ae3d1edb89462848c56e6e39575
65f99a3694549af88c7702b598de1a8ccb7db5fb
refs/heads/main
2023-07-19T00:08:50.813224
2021-09-14T15:32:09
2021-09-14T15:32:09
null
0
0
null
null
null
null
UTF-8
Python
false
false
607
py
# Time complexity: O(n) # Approach: Two pointer Solution # Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def deleteDuplicates(self, head: Optional[ListNode]) -> Optional[ListNode]: nHead = ListNode(-1) nHead.next = head tmp, tmp2 = nHead.next, nHead.next while tmp and tmp2: while tmp and tmp2 and tmp.val==tmp2.val: tmp2 = tmp2.next tmp.next = tmp2 tmp = tmp.next return nHead.next
23c0c6b7b562579f9c4d1030cb28c3548153bc47
15fb5a41109e43fb185fad66b8d452f177d1d24c
/conf.py
87f80182776cd8fd60f5599ec19aea5f74ce31c2
[ "MIT" ]
permissive
Rgveda/QUANTAXIS
2f546a3de00f2aacfd09dc257c39bafbdbc41be0
70a0ff84774253b0c23a5d0e39b7e772df440b7c
refs/heads/master
2021-06-20T21:49:59.500785
2021-01-29T03:52:51
2021-01-29T03:52:51
177,425,581
20
7
MIT
2020-02-26T15:24:55
2019-03-24T14:26:17
Python
UTF-8
Python
false
false
6,131
py
# -*- coding: utf-8 -*- # # Configuration file for the Sphinx documentation builder. # # This file does only contain a selection of the most common options. For a # full list see the documentation: # http://www.sphinx-doc.org/en/stable/config # -- Path setup -------------------------------------------------------------- # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # import sphinx_rtd_theme import os import sys import QUANTAXIS as QA # sys.path.insert(0, os.path.abspath('.')) # -- Project information ----------------------------------------------------- sys.path.insert(0, os.path.abspath('QUANTAXIS')) project = 'QUANTAXIS' copyright = '2018, yutiansut' author = 'yutiansut' # The short X.Y version version = QA.__version__ # The full version, including alpha/beta/rc tags release = QA.__version__ # -- General configuration --------------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. # # needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ 'sphinx.ext.autodoc', 'sphinx.ext.intersphinx', 'sphinx.ext.todo', 'sphinx.ext.mathjax', 'sphinx.ext.ifconfig', 'sphinx.ext.viewcode', 'sphinx.ext.githubpages', #'sphinx_automodapi.automodapi' ] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: # # source_suffix = ['.rst', '.md'] source_suffix = '.rst' # The master toctree document. master_doc = 'index' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. language = 'python' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This pattern also affects html_static_path and html_extra_path . exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # -- Options for HTML output ------------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # html_theme = 'alabaster' #html_theme = "sphinx_rtd_theme" html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. # # html_theme_options = {} # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] # Custom sidebar templates, must be a dictionary that maps document names # to template names. # # The default sidebars (for documents that don't match any pattern) are # defined by theme itself. Builtin themes are using these templates by # default: ``['localtoc.html', 'relations.html', 'sourcelink.html', # 'searchbox.html']``. # # html_sidebars = {} # -- Options for HTMLHelp output --------------------------------------------- # Output file base name for HTML help builder. htmlhelp_basename = 'QUANTAXISdoc' # -- Options for LaTeX output ------------------------------------------------ latex_elements = { # The paper size ('letterpaper' or 'a4paper'). # # 'papersize': 'letterpaper', # The font size ('10pt', '11pt' or '12pt'). # # 'pointsize': '10pt', # Additional stuff for the LaTeX preamble. # # 'preamble': '', # Latex figure (float) alignment # # 'figure_align': 'htbp', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ (master_doc, 'QUANTAXIS.tex', 'QUANTAXIS Documentation', 'yutiansut', 'manual'), ] # -- Options for manual page output ------------------------------------------ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ (master_doc, 'quantaxis', 'QUANTAXIS Documentation', [author], 1) ] # -- Options for Texinfo output ---------------------------------------------- # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ (master_doc, 'QUANTAXIS', 'QUANTAXIS Documentation', author, 'QUANTAXIS', 'One line description of project.', 'Miscellaneous'), ] # -- Options for Epub output ------------------------------------------------- # Bibliographic Dublin Core info. epub_title = project epub_author = author epub_publisher = author epub_copyright = copyright # The unique identifier of the text. This can be a ISBN number # or the project homepage. # # epub_identifier = '' # A unique identification for the text. # # epub_uid = '' # A list of files that should not be packed into the epub file. epub_exclude_files = ['search.html'] # -- Extension configuration ------------------------------------------------- # -- Options for intersphinx extension --------------------------------------- # Example configuration for intersphinx: refer to the Python standard library. intersphinx_mapping = {'https://docs.python.org/': None} # -- Options for todo extension ---------------------------------------------- # If true, `todo` and `todoList` produce output, else they produce nothing. todo_include_todos = True
8f27fc860cbf3d5e3ea2a895c92a3dc2146be44c
fb8cbebdf034b2f478943752d5443afc82c6eef5
/tuirer/venv/lib/python3.6/site-packages/pygments/lexers/fortran.py
8fbd92026508d7a41dec048e55aa0b3a2f58caac
[]
no_license
fariasjr/CitiTuirer
f64e0ec93ef088f8140bb0961d2ad4ed3b59448a
deb3f7a9c2d45b8a7f54639037f097b99abdac11
refs/heads/master
2020-03-24T05:10:36.261050
2018-08-01T20:24:30
2018-08-01T20:24:30
142,477,521
0
0
null
null
null
null
UTF-8
Python
false
false
9,792
py
# -*- coding: utf-8 -*- """ pygments.lexers.fortran ~~~~~~~~~~~~~~~~~~~~~~~ Lexers for Fortran languages. :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details. """ import re from pygments.lexer import RegexLexer, bygroups, default, include, using, words from pygments.token import (Comment, Generic, Keyword, Name, Number, Operator, Punctuation, String, Text) __all__ = ['FortranLexer', 'FortranFixedLexer'] class FortranLexer(RegexLexer): """ Lexer for FORTRAN 90 code. .. versionadded:: 0.10 """ name = 'Fortran' aliases = ['fortran'] filenames = ['*.f03', '*.f90', '*.F03', '*.F90'] mimetypes = ['text/x-fortran'] flags = re.IGNORECASE | re.MULTILINE # Data Types: INTEGER, REAL, COMPLEX, LOGICAL, CHARACTER and DOUBLE PRECISION # Operators: **, *, +, -, /, <, >, <=, >=, ==, /= # Logical (?): NOT, AND, OR, EQV, NEQV # Builtins: # http://gcc.gnu.org/onlinedocs/gcc-3.4.6/g77/Table-of-Intrinsic-Functions.html tokens = { 'root': [ (r'^#.*\n', Comment.Preproc), (r'!.*\n', Comment), include('strings'), include('core'), (r'[a-z][\w$]*', Name), include('nums'), (r'[\s]+', Text), ], 'core': [ # Statements (words(( 'ABSTRACT', 'ACCEPT', 'ALL', 'ALLSTOP', 'ALLOCATABLE', 'ALLOCATE', 'ARRAY', 'ASSIGN', 'ASSOCIATE', 'ASYNCHRONOUS', 'BACKSPACE', 'BIND', 'BLOCK', 'BLOCKDATA', 'BYTE', 'CALL', 'CASE', 'CLASS', 'CLOSE', 'CODIMENSION', 'COMMON', 'CONCURRRENT', 'CONTIGUOUS', 'CONTAINS', 'CONTINUE', 'CRITICAL', 'CYCLE', 'DATA', 'DEALLOCATE', 'DECODE', 'DEFERRED', 'DIMENSION', 'DO', 'ELEMENTAL', 'ELSE', 'ENCODE', 'END', 'ENTRY', 'ENUM', 'ENUMERATOR', 'EQUIVALENCE', 'EXIT', 'EXTENDS', 'EXTERNAL', 'EXTRINSIC', 'FILE', 'FINAL', 'FORALL', 'FORMAT', 'FUNCTION', 'GENERIC', 'GOTO', 'IF', 'IMAGES', 'IMPLICIT', 'IMPORT', 'IMPURE', 'INCLUDE', 'INQUIRE', 'INTENT', 'INTERFACE', 'INTRINSIC', 'IS', 'LOCK', 'MEMORY', 'MODULE', 'NAMELIST', 'NULLIFY', 'NONE', 'NON_INTRINSIC', 'NON_OVERRIDABLE', 'NOPASS', 'OPEN', 'OPTIONAL', 'OPTIONS', 'PARAMETER', 'PASS', 'PAUSE', 'POINTER', 'PRINT', 'PRIVATE', 'PROGRAM', 'PROCEDURE', 'PROTECTED', 'PUBLIC', 'PURE', 'READ', 'RECURSIVE', 'RESULT', 'RETURN', 'REWIND', 'SAVE', 'SELECT', 'SEQUENCE', 'STOP', 'SUBMODULE', 'SUBROUTINE', 'SYNC', 'SYNCALL', 'SYNCIMAGES', 'SYNCMEMORY', 'TARGET', 'THEN', 'TYPE', 'UNLOCK', 'USE', 'VALUE', 'VOLATILE', 'WHERE', 'WRITE', 'WHILE'), prefix=r'\b', suffix=r'\s*\b'), Keyword), # Data Types (words(( 'CHARACTER', 'COMPLEX', 'DOUBLE PRECISION', 'DOUBLE COMPLEX', 'INTEGER', 'LOGICAL', 'REAL', 'C_INT', 'C_SHORT', 'C_LONG', 'C_LONG_LONG', 'C_SIGNED_CHAR', 'C_SIZE_T', 'C_INT8_T', 'C_INT16_T', 'C_INT32_T', 'C_INT64_T', 'C_INT_LEAST8_T', 'C_INT_LEAST16_T', 'C_INT_LEAST32_T', 'C_INT_LEAST64_T', 'C_INT_FAST8_T', 'C_INT_FAST16_T', 'C_INT_FAST32_T', 'C_INT_FAST64_T', 'C_INTMAX_T', 'C_INTPTR_T', 'C_FLOAT', 'C_DOUBLE', 'C_LONG_DOUBLE', 'C_FLOAT_COMPLEX', 'C_DOUBLE_COMPLEX', 'C_LONG_DOUBLE_COMPLEX', 'C_BOOL', 'C_CHAR', 'C_PTR', 'C_FUNPTR'), prefix=r'\b', suffix=r'\s*\b'), Keyword.Type), # Operators (r'(\*\*|\*|\+|-|\/|<|>|<=|>=|==|\/=|=)', Operator), (r'(::)', Keyword.Declaration), (r'[()\[\],:&%;.]', Punctuation), # Intrinsics (words(( 'Abort', 'Abs', 'Access', 'AChar', 'ACos', 'ACosH', 'AdjustL', 'AdjustR', 'AImag', 'AInt', 'Alarm', 'All', 'Allocated', 'ALog', 'AMax', 'AMin', 'AMod', 'And', 'ANInt', 'Any', 'ASin', 'ASinH', 'Associated', 'ATan', 'ATanH', 'Atomic_Define', 'Atomic_Ref', 'BesJ', 'BesJN', 'Bessel_J0', 'Bessel_J1', 'Bessel_JN', 'Bessel_Y0', 'Bessel_Y1', 'Bessel_YN', 'BesY', 'BesYN', 'BGE', 'BGT', 'BLE', 'BLT', 'Bit_Size', 'BTest', 'CAbs', 'CCos', 'Ceiling', 'CExp', 'Char', 'ChDir', 'ChMod', 'CLog', 'Cmplx', 'Command_Argument_Count', 'Complex', 'Conjg', 'Cos', 'CosH', 'Count', 'CPU_Time', 'CShift', 'CSin', 'CSqRt', 'CTime', 'C_Loc', 'C_Associated', 'C_Null_Ptr', 'C_Null_Funptr', 'C_F_Pointer', 'C_F_ProcPointer', 'C_Null_Char', 'C_Alert', 'C_Backspace', 'C_Form_Feed', 'C_FunLoc', 'C_Sizeof', 'C_New_Line', 'C_Carriage_Return', 'C_Horizontal_Tab', 'C_Vertical_Tab', 'DAbs', 'DACos', 'DASin', 'DATan', 'Date_and_Time', 'DbesJ', 'DbesJN', 'DbesY', 'DbesYN', 'Dble', 'DCos', 'DCosH', 'DDiM', 'DErF', 'DErFC', 'DExp', 'Digits', 'DiM', 'DInt', 'DLog', 'DMax', 'DMin', 'DMod', 'DNInt', 'Dot_Product', 'DProd', 'DSign', 'DSinH', 'DShiftL', 'DShiftR', 'DSin', 'DSqRt', 'DTanH', 'DTan', 'DTime', 'EOShift', 'Epsilon', 'ErF', 'ErFC', 'ErFC_Scaled', 'ETime', 'Execute_Command_Line', 'Exit', 'Exp', 'Exponent', 'Extends_Type_Of', 'FDate', 'FGet', 'FGetC', 'FindLoc', 'Float', 'Floor', 'Flush', 'FNum', 'FPutC', 'FPut', 'Fraction', 'FSeek', 'FStat', 'FTell', 'Gamma', 'GError', 'GetArg', 'Get_Command', 'Get_Command_Argument', 'Get_Environment_Variable', 'GetCWD', 'GetEnv', 'GetGId', 'GetLog', 'GetPId', 'GetUId', 'GMTime', 'HostNm', 'Huge', 'Hypot', 'IAbs', 'IAChar', 'IAll', 'IAnd', 'IAny', 'IArgC', 'IBClr', 'IBits', 'IBSet', 'IChar', 'IDate', 'IDiM', 'IDInt', 'IDNInt', 'IEOr', 'IErrNo', 'IFix', 'Imag', 'ImagPart', 'Image_Index', 'Index', 'Int', 'IOr', 'IParity', 'IRand', 'IsaTty', 'IShft', 'IShftC', 'ISign', 'Iso_C_Binding', 'Is_Contiguous', 'Is_Iostat_End', 'Is_Iostat_Eor', 'ITime', 'Kill', 'Kind', 'LBound', 'LCoBound', 'Len', 'Len_Trim', 'LGe', 'LGt', 'Link', 'LLe', 'LLt', 'LnBlnk', 'Loc', 'Log', 'Log_Gamma', 'Logical', 'Long', 'LShift', 'LStat', 'LTime', 'MaskL', 'MaskR', 'MatMul', 'Max', 'MaxExponent', 'MaxLoc', 'MaxVal', 'MClock', 'Merge', 'Merge_Bits', 'Move_Alloc', 'Min', 'MinExponent', 'MinLoc', 'MinVal', 'Mod', 'Modulo', 'MvBits', 'Nearest', 'New_Line', 'NInt', 'Norm2', 'Not', 'Null', 'Num_Images', 'Or', 'Pack', 'Parity', 'PError', 'Precision', 'Present', 'Product', 'Radix', 'Rand', 'Random_Number', 'Random_Seed', 'Range', 'Real', 'RealPart', 'Rename', 'Repeat', 'Reshape', 'RRSpacing', 'RShift', 'Same_Type_As', 'Scale', 'Scan', 'Second', 'Selected_Char_Kind', 'Selected_Int_Kind', 'Selected_Real_Kind', 'Set_Exponent', 'Shape', 'ShiftA', 'ShiftL', 'ShiftR', 'Short', 'Sign', 'Signal', 'SinH', 'Sin', 'Sleep', 'Sngl', 'Spacing', 'Spread', 'SqRt', 'SRand', 'Stat', 'Storage_Size', 'Sum', 'SymLnk', 'System', 'System_Clock', 'Tan', 'TanH', 'Time', 'This_Image', 'Tiny', 'TrailZ', 'Transfer', 'Transpose', 'Trim', 'TtyNam', 'UBound', 'UCoBound', 'UMask', 'Unlink', 'Unpack', 'Verify', 'XOr', 'ZAbs', 'ZCos', 'ZExp', 'ZLog', 'ZSin', 'ZSqRt'), prefix=r'\b', suffix=r'\s*\b'), Name.Builtin), # Booleans (r'\.(true|false)\.', Name.Builtin), # Comparing Operators (r'\.(eq|ne|lt|le|gt|ge|not|and|or|eqv|neqv)\.', Operator.Word), ], 'strings': [ (r'(?s)"(\\\\|\\[0-7]+|\\.|[^"\\])*"', String.Double), (r"(?s)'(\\\\|\\[0-7]+|\\.|[^'\\])*'", String.Single), ], 'nums': [ (r'\d+(?![.e])(_[a-z]\w+)?', Number.Integer), (r'[+-]?\d*\.\d+([ed][-+]?\d+)?(_[a-z]\w+)?', Number.Float), (r'[+-]?\d+\.\d*([ed][-+]?\d+)?(_[a-z]\w+)?', Number.Float), ], } class FortranFixedLexer(RegexLexer): """ Lexer for fixed format Fortran. .. versionadded:: 2.1 """ name = 'FortranFixed' aliases = ['fortranfixed'] filenames = ['*.f', '*.F'] flags = re.IGNORECASE def _lex_fortran(self, match, ctx=None): """Lex a line just as free form fortran without line break.""" lexer = FortranLexer() text = match.group(0) + "\n" for index, token, value in lexer.get_tokens_unprocessed(text): value = value.replace('\n', '') if value != '': yield index, token, value tokens = { 'root': [ (r'[C*].*\n', Comment), (r'#.*\n', Comment.Preproc), (r' {0,4}!.*\n', Comment), (r'(.{5})', Name.Label, 'cont-char'), (r'.*\n', using(FortranLexer)), ], 'cont-char': [ (' ', Text, 'code'), ('0', Comment, 'code'), ('.', Generic.Strong, 'code'), ], 'code': [ (r'(.{66})(.*)(\n)', bygroups(_lex_fortran, Comment, Text), 'root'), (r'(.*)(\n)', bygroups(_lex_fortran, Text), 'root'), default('root'), ] }
404480e38772e6e23ad814affd5741458f500b04
4b17e8bf7a0692dbec3423d73834d704829cbf3c
/server/dvaapp/models.py
380ed9b8d1f0cdd7a4a0ad47930d6ed8aadcceb6
[ "BSD-3-Clause", "MIT", "Apache-2.0" ]
permissive
Fan-Hua/DeepVideoAnalytics
395f4d5645dc3a0276f6dc749f91b3e4e7f9e801
8f281809387a8950ffd16e423ce9a85635aed071
refs/heads/master
2020-03-21T19:34:34.948273
2018-06-27T16:06:07
2018-06-27T16:06:07
null
0
0
null
null
null
null
UTF-8
Python
false
false
33,674
py
from __future__ import unicode_literals import os, json, gzip, sys, shutil, zipfile, uuid, hashlib sys.path.append(os.path.join(os.path.dirname(__file__), "../../client/")) # This ensures that the constants are same between client and server from django.db import models from django.contrib.auth.models import User from django.contrib.postgres.fields import JSONField from django.conf import settings from django.utils import timezone from dvaclient import constants from . import fs from PIL import Image try: import numpy as np except ImportError: pass from uuid import UUID from json import JSONEncoder JSONEncoder_old = JSONEncoder.default def JSONEncoder_new(self, o): if isinstance(o, UUID): return str(o) return JSONEncoder_old(self, o) JSONEncoder.default = JSONEncoder_new class Worker(models.Model): queue_name = models.CharField(max_length=500, default="") host = models.CharField(max_length=500, default="") pid = models.IntegerField() alive = models.BooleanField(default=True) last_ping = models.DateTimeField('date last ping', null=True) created = models.DateTimeField('date created', auto_now_add=True) class DVAPQL(models.Model): SCHEDULE = constants.SCHEDULE PROCESS = constants.PROCESS QUERY = constants.QUERY TYPE_CHOICES = ((SCHEDULE, 'Schedule'), (PROCESS, 'Process'), (QUERY, 'Query')) process_type = models.CharField(max_length=1, choices=TYPE_CHOICES, default=QUERY, ) created = models.DateTimeField('date created', auto_now_add=True) user = models.ForeignKey(User, null=True, related_name="submitter") script = JSONField(blank=True, null=True) results_metadata = models.TextField(default="") results_available = models.BooleanField(default=False) completed = models.BooleanField(default=False) failed = models.BooleanField(default=False) error_message = models.TextField(default="", blank=True, null=True) uuid = models.UUIDField(default=uuid.uuid4, editable=False, unique=True) class TrainingSet(models.Model): DETECTION = constants.DETECTION INDEXING = constants.INDEXING TRAINAPPROX = constants.TRAINAPPROX CLASSIFICATION = constants.CLASSIFICATION IMAGES = constants.IMAGES VIDEOS = constants.VIDEOS INDEX = constants.INDEX INSTANCE_TYPES = ( (IMAGES, 'images'), (INDEX, 'index'), (VIDEOS, 'videos'), ) TRAIN_TASK_TYPES = ( (DETECTION, 'Detection'), (INDEXING, 'Indexing'), (TRAINAPPROX, 'Approximation'), (CLASSIFICATION, 'Classification') ) uuid = models.UUIDField(default=uuid.uuid4, editable=False, unique=True) source_filters = JSONField(blank=True, null=True) training_task_type = models.CharField(max_length=1, choices=TRAIN_TASK_TYPES, db_index=True, default=DETECTION) instance_type = models.CharField(max_length=1, choices=INSTANCE_TYPES, db_index=True, default=IMAGES) count = models.IntegerField(null=True) name = models.CharField(max_length=500, default="") files = JSONField(blank=True, null=True) built = models.BooleanField(default=False) created = models.DateTimeField('date created', auto_now_add=True) class Video(models.Model): id = models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True) name = models.CharField(max_length=500, default="") length_in_seconds = models.IntegerField(default=0) height = models.IntegerField(default=0) width = models.IntegerField(default=0) metadata = models.TextField(default="") frames = models.IntegerField(default=0) created = models.DateTimeField('date created', auto_now_add=True) description = models.TextField(default="") uploaded = models.BooleanField(default=False) dataset = models.BooleanField(default=False) uploader = models.ForeignKey(User, null=True) segments = models.IntegerField(default=0) stream = models.BooleanField(default=False) url = models.TextField(default="") parent_process = models.ForeignKey(DVAPQL, null=True) def __unicode__(self): return u'{}'.format(self.name) def path(self, media_root=None): if not (media_root is None): return "{}/{}/video/{}.mp4".format(media_root, self.pk, self.pk) else: return "{}/{}/video/{}.mp4".format(settings.MEDIA_ROOT, self.pk, self.pk) def segments_dir(self, media_root=None): if not (media_root is None): return "{}/{}/segments/".format(media_root, self.pk, self.pk) else: return "{}/{}/segments/".format(settings.MEDIA_ROOT, self.pk, self.pk) def get_frame_list(self, media_root=None): if media_root is None: media_root = settings.MEDIA_ROOT framelist_path = "{}/{}/framelist".format(media_root, self.pk) if os.path.isfile('{}.json'.format(framelist_path)): return json.load(file('{}.json'.format(framelist_path))) elif os.path.isfile('{}.gz'.format(framelist_path)): return json.load(gzip.GzipFile('{}.gz'.format(framelist_path))) else: raise ValueError("Frame list could not be found at {}".format(framelist_path)) def create_directory(self, create_subdirs=True): d = '{}/{}'.format(settings.MEDIA_ROOT, self.pk) if not os.path.exists(d): try: os.mkdir(d) except OSError: pass if create_subdirs: for s in ['video', 'frames', 'segments', 'indexes', 'regions', 'transforms', 'audio']: d = '{}/{}/{}/'.format(settings.MEDIA_ROOT, self.pk, s) if not os.path.exists(d): try: os.mkdir(d) except OSError: pass class TEvent(models.Model): id = models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True) started = models.BooleanField(default=False) completed = models.BooleanField(default=False) errored = models.BooleanField(default=False) worker = models.ForeignKey(Worker, null=True) error_message = models.TextField(default="") video = models.ForeignKey(Video, null=True) training_set = models.ForeignKey(TrainingSet, null=True) operation = models.CharField(max_length=100, default="") queue = models.CharField(max_length=100, default="") created = models.DateTimeField('date created', auto_now_add=True) start_ts = models.DateTimeField('date started', null=True) duration = models.FloatField(default=-1) arguments = JSONField(blank=True, null=True) task_id = models.TextField(null=True) parent = models.ForeignKey('self', null=True) parent_process = models.ForeignKey(DVAPQL, null=True) imported = models.BooleanField(default=False) task_group_id = models.IntegerField(default=-1) def finalize(self,bulk_create): created_regions = [] created_tubes = [] if 'Region' in bulk_create: temp = [] for i, d in enumerate(bulk_create['Region']): d.per_event_index = i d.id = '{}_{}'.format(self.id.hex, i) temp.append(d) created_regions = Region.objects.bulk_create(temp, batch_size=1000) if 'Tube' in bulk_create: temp = [] for i, d in enumerate(bulk_create['Tube']): d.per_event_index = i d.id = '{}_{}'.format(self.id.hex, i) temp.append(d) created_tubes = Tube.objects.bulk_create(temp, batch_size=1000) if 'RegionRelation' in bulk_create: temp = [] for i, d_value_map in enumerate(bulk_create['RegionRelation']): d,value_map = d_value_map if 'source_region_id' in value_map: d.source_region_id = created_regions[value_map['source_region_id']].id if 'target_region_id' in value_map: d.target_region_id = created_regions[value_map['target_region_id']].id d.per_event_index = i temp.append(d) RegionRelation.objects.bulk_create(temp, batch_size=1000) if 'TubeRelation' in bulk_create: temp = [] for i, d_value_map in enumerate(bulk_create['TubeRelation']): d, value_map = d_value_map d.per_event_index = i temp.append(d) TubeRelation.objects.bulk_create(temp, batch_size=1000) if 'TubeRegionRelation' in bulk_create: temp = [] for i, d_value_map in enumerate(bulk_create['TubeRegionRelation']): d, value_map = d_value_map d.per_event_index = i temp.append(d) TubeRegionRelation.objects.bulk_create(temp, batch_size=1000) if 'HyperRegionRelation' in bulk_create: temp = [] for i, d_value_map in enumerate(bulk_create['HyperRegionRelation']): d, value_map = d_value_map if 'region_id' in value_map: d.region_id = created_regions[value_map['region_id']].id else: if d.region_id is None: raise ValueError(d_value_map) d.per_event_index = i temp.append(d) HyperRegionRelation.objects.bulk_create(temp, batch_size=1000) if 'HyperTubeRegionRelation' in bulk_create: temp = [] for i, d_value_map in enumerate(bulk_create['HyperTubeRegionRelation']): d, value_map = d_value_map d.per_event_index = i temp.append(d) HyperTubeRegionRelation.objects.bulk_create(temp, batch_size=1000) class TrainedModel(models.Model): """ A model Model """ TENSORFLOW = constants.TENSORFLOW CAFFE = constants.CAFFE PYTORCH = constants.PYTORCH OPENCV = constants.OPENCV MXNET = constants.MXNET INDEXER = constants.INDEXER APPROXIMATOR = constants.APPROXIMATOR DETECTOR = constants.DETECTOR ANALYZER = constants.ANALYZER SEGMENTER = constants.SEGMENTER YOLO = constants.YOLO TFD = constants.TFD DETECTOR_TYPES = ( (TFD, 'Tensorflow'), (YOLO, 'YOLO V2'), ) MODES = ( (TENSORFLOW, 'Tensorflow'), (CAFFE, 'Caffe'), (PYTORCH, 'Pytorch'), (OPENCV, 'OpenCV'), (MXNET, 'MXNet'), ) MTYPE = ( (APPROXIMATOR, 'Approximator'), (INDEXER, 'Indexer'), (DETECTOR, 'Detector'), (ANALYZER, 'Analyzer'), (SEGMENTER, 'Segmenter'), ) detector_type = models.CharField(max_length=1, choices=DETECTOR_TYPES, db_index=True, null=True) mode = models.CharField(max_length=1, choices=MODES, db_index=True, default=TENSORFLOW) model_type = models.CharField(max_length=1, choices=MTYPE, db_index=True, default=INDEXER) name = models.CharField(max_length=100) algorithm = models.CharField(max_length=100, default="") shasum = models.CharField(max_length=40, null=True, unique=True) model_filename = models.CharField(max_length=200, default="", null=True) created = models.DateTimeField('date created', auto_now_add=True) arguments = JSONField(null=True, blank=True) event = models.ForeignKey(TEvent) trained = models.BooleanField(default=False) training_set = models.ForeignKey(TrainingSet, null=True) url = models.CharField(max_length=200, default="") files = JSONField(null=True, blank=True) produces_labels = models.BooleanField(default=False) produces_json = models.BooleanField(default=False) produces_text = models.BooleanField(default=False) # Following allows us to have a hierarchy of models (E.g. inception pretrained -> inception fine tuned) parent = models.ForeignKey('self', null=True) uuid = models.UUIDField(default=uuid.uuid4, editable=False, unique=True) def create_directory(self): if not os.path.isdir('{}/models/'.format(settings.MEDIA_ROOT)): try: os.mkdir('{}/models/'.format(settings.MEDIA_ROOT)) except: pass try: os.mkdir('{}/models/{}'.format(settings.MEDIA_ROOT, self.uuid)) except: pass def get_model_path(self, root_dir=None): if root_dir is None: root_dir = settings.MEDIA_ROOT if self.model_filename: return "{}/models/{}/{}".format(root_dir, self.uuid, self.model_filename) elif self.files: return "{}/models/{}/{}".format(root_dir, self.uuid, self.files[0]['filename']) else: return None def upload(self): for m in self.files: if settings.ENABLE_CLOUDFS and sys.platform != 'darwin': fs.upload_file_to_remote("/models/{}/{}".format(self.uuid, m['filename'])) def download(self): root_dir = settings.MEDIA_ROOT model_type_dir = "{}/models/".format(root_dir) if not os.path.isdir(model_type_dir): os.mkdir(model_type_dir) model_dir = "{}/models/{}".format(root_dir, self.uuid) if not os.path.isdir(model_dir): try: os.mkdir(model_dir) except: pass shasums = [] for m in self.files: dlpath = "{}/{}".format(model_dir, m['filename']) if m['url'].startswith('/'): shutil.copy(m['url'], dlpath) else: fs.get_path_to_file(m['url'], dlpath) shasums.append(str(hashlib.sha1(file(dlpath).read()).hexdigest())) if self.shasum is None: if len(shasums) == 1: self.shasum = shasums[0] else: self.shasum = str(hashlib.sha1(''.join(sorted(shasums))).hexdigest()) self.save() self.upload() if self.model_type == TrainedModel.DETECTOR and self.detector_type == TrainedModel.YOLO: source_zip = "{}/models/{}/model.zip".format(settings.MEDIA_ROOT, self.uuid) zipf = zipfile.ZipFile(source_zip, 'r') zipf.extractall("{}/models/{}/".format(settings.MEDIA_ROOT, self.uuid)) zipf.close() os.remove(source_zip) self.save() elif self.model_type == self.INDEXER: if settings.ENABLE_FAISS: dr, dcreated = Retriever.objects.get_or_create(name=self.name, source_filters={}, algorithm=Retriever.FAISS, indexer_shasum=self.shasum) else: dr, dcreated = Retriever.objects.get_or_create(name=self.name, source_filters={}, algorithm=Retriever.EXACT, indexer_shasum=self.shasum) if dcreated: dr.last_built = timezone.now() dr.save() elif self.model_type == self.APPROXIMATOR: algo = Retriever.LOPQ if self.algorithm == 'LOPQ' else Retriever.EXACT dr, dcreated = Retriever.objects.get_or_create(name=self.name, source_filters={}, algorithm=algo, approximator_shasum=self.shasum, indexer_shasum=self.arguments['indexer_shasum']) if dcreated: dr.last_built = timezone.now() dr.save() def ensure(self): for m in self.files: dlpath = "{}/models/{}/{}".format(settings.MEDIA_ROOT, self.uuid, m['filename']) if not os.path.isfile(dlpath): fs.ensure("/models/{}/{}".format(self.uuid, m['filename'])) class Retriever(models.Model): """ Here Exact is an L2 Flat retriever """ EXACT = 'E' LOPQ = 'L' FAISS = 'F' MODES = ( (LOPQ, 'LOPQ'), (EXACT, 'Exact'), (FAISS, 'FAISS'), ) algorithm = models.CharField(max_length=1, choices=MODES, db_index=True, default=EXACT) name = models.CharField(max_length=200, default="") indexer_shasum = models.CharField(max_length=40, null=True) approximator_shasum = models.CharField(max_length=40, null=True) source_filters = JSONField() created = models.DateTimeField('date created', auto_now_add=True) class Frame(models.Model): video = models.ForeignKey(Video) event = models.ForeignKey(TEvent) frame_index = models.IntegerField() name = models.CharField(max_length=200, null=True) h = models.IntegerField(default=0) w = models.IntegerField(default=0) t = models.FloatField(null=True) # time in seconds for keyframes keyframe = models.BooleanField(default=False) # is this a key frame for a video? segment_index = models.IntegerField(null=True) class Meta: unique_together = (("video", "frame_index"),) def __unicode__(self): return u'{}:{}'.format(self.video_id, self.frame_index) def path(self, media_root=None): if not (media_root is None): return "{}/{}/frames/{}.jpg".format(media_root, self.video_id, self.frame_index) else: return "{}/{}/frames/{}.jpg".format(settings.MEDIA_ROOT, self.video_id, self.frame_index) def original_path(self): return self.name def global_path(self): if self.video.dataset: if self.name and not self.name.startswith('/'): return self.name else: return "{}/{}".format(self.video.url, self.name) else: return "{}::{}".format(self.video.url, self.frame_index) class Segment(models.Model): """ A video segment useful for parallel dense decoding+processing as well as streaming """ video = models.ForeignKey(Video) segment_index = models.IntegerField() start_time = models.FloatField(default=0.0) end_time = models.FloatField(default=0.0) event = models.ForeignKey(TEvent) metadata = models.TextField(default="{}") frame_count = models.IntegerField(default=0) start_index = models.IntegerField(default=0) framelist = JSONField(blank=True, null=True) class Meta: unique_together = (("video", "segment_index"),) def __unicode__(self): return u'{}:{}'.format(self.video_id, self.segment_index) def path(self, media_root=None): if not (media_root is None): return "{}/{}/segments/{}.mp4".format(media_root, self.video_id, self.segment_index) else: return "{}/{}/segments/{}.mp4".format(settings.MEDIA_ROOT, self.video_id, self.segment_index) class Region(models.Model): """ Any 2D region over an image. Detections & Transforms have an associated image data. """ id = models.CharField(max_length=100, primary_key=True) ANNOTATION = constants.ANNOTATION DETECTION = constants.DETECTION SEGMENTATION = constants.SEGMENTATION TRANSFORM = constants.TRANSFORM POLYGON = constants.POLYGON REGION_TYPES = ( (ANNOTATION, 'Annotation'), (DETECTION, 'Detection'), (POLYGON, 'Polygon'), (SEGMENTATION, 'Segmentation'), (TRANSFORM, 'Transform'), ) region_type = models.CharField(max_length=1, choices=REGION_TYPES, db_index=True) video = models.ForeignKey(Video) user = models.ForeignKey(User, null=True) # frame = models.ForeignKey(Frame, null=True, on_delete=models.SET_NULL) # After significant deliberation I decided that having frame_index was sufficient and ensuring that this relation # is updated when frames are decoded breaks the immutability. Instead frame_index allows "lazy" relation enabling # cases such as user annotating a video frame which has not been decoded and stored explicitly as a Frame. event = models.ForeignKey(TEvent) # TEvent that created this region frame_index = models.IntegerField(default=-1) segment_index = models.IntegerField(default=-1, null=True) # This ensures that for a specific event Regions are always ordered. (event_uuid, per_event_index) serves as # a global unique identifier. per_event_index = models.IntegerField() text = models.TextField(default="") metadata = JSONField(blank=True, null=True) full_frame = models.BooleanField(default=False) x = models.IntegerField(default=0) y = models.IntegerField(default=0) h = models.IntegerField(default=0) w = models.IntegerField(default=0) polygon_points = JSONField(blank=True, null=True) created = models.DateTimeField('date created', auto_now_add=True) object_name = models.CharField(max_length=100) confidence = models.FloatField(default=0.0) png = models.BooleanField(default=False) def path(self, media_root=None, temp_root=None): if temp_root: return "{}/{}_{}.jpg".format(temp_root, self.video_id, self.pk) elif not (media_root is None): return "{}/{}/regions/{}.jpg".format(media_root, self.video_id, self.pk) else: return "{}/{}/regions/{}.jpg".format(settings.MEDIA_ROOT, self.video_id, self.pk) def frame_path(self, media_root=None): if not (media_root is None): return "{}/{}/frames/{}.jpg".format(media_root, self.video_id, self.frame_index) else: return "{}/{}/frames/{}.jpg".format(settings.MEDIA_ROOT, self.video_id, self.frame_index) def crop_and_get_region_path(self, images, temp_root): bare_path = self.path(media_root="") cached_data = fs.get_from_cache(bare_path) region_path = self.path(temp_root=temp_root) if cached_data: with open(region_path, 'wb') as out: out.write(cached_data) else: frame_path = self.frame_path() if frame_path not in images: images[frame_path] = Image.open(frame_path) img2 = images[frame_path].crop((self.x, self.y, self.x + self.w, self.y + self.h)) img2.save(region_path) with open(region_path, 'rb') as fr: fs.cache_path(bare_path, payload=fr.read()) return region_path def global_frame_path(self): if self.video.dataset: df = Frame.objects.get(video=self.video,frame_index=self.frame_index) if df.name and not df.name.startswith('/'): return df.name else: return "{}/{}".format(self.video.url, df.name) else: return "{}::{}".format(self.video.url, self.frame_index) class Meta: unique_together = (("event","per_event_index"),) class QueryRegion(models.Model): """ Any 2D region over a query image. """ ANNOTATION = constants.ANNOTATION DETECTION = constants.DETECTION SEGMENTATION = constants.SEGMENTATION TRANSFORM = constants.TRANSFORM POLYGON = constants.POLYGON REGION_TYPES = ( (ANNOTATION, 'Annotation'), (DETECTION, 'Detection'), (POLYGON, 'Polygon'), (SEGMENTATION, 'Segmentation'), (TRANSFORM, 'Transform'), ) region_type = models.CharField(max_length=1, choices=REGION_TYPES, db_index=True) query = models.ForeignKey(DVAPQL) event = models.ForeignKey(TEvent) # TEvent that created this region text = models.TextField(default="") metadata = JSONField(blank=True, null=True) full_frame = models.BooleanField(default=False) x = models.IntegerField(default=0) y = models.IntegerField(default=0) h = models.IntegerField(default=0) w = models.IntegerField(default=0) polygon_points = JSONField(blank=True, null=True) created = models.DateTimeField('date created', auto_now_add=True) object_name = models.CharField(max_length=100) confidence = models.FloatField(default=0.0) png = models.BooleanField(default=False) class QueryResults(models.Model): query = models.ForeignKey(DVAPQL) retrieval_event = models.ForeignKey(TEvent) query_region = models.ForeignKey(QueryRegion, null=True) video = models.ForeignKey(Video) frame_index = models.IntegerField() detection = models.ForeignKey(Region, null=True) rank = models.IntegerField() algorithm = models.CharField(max_length=100) distance = models.FloatField(default=0.0) class IndexEntries(models.Model): video = models.ForeignKey(Video) features_file_name = models.CharField(max_length=100) entries = JSONField(blank=True, null=True) metadata = JSONField(blank=True, null=True) algorithm = models.CharField(max_length=100) indexer_shasum = models.CharField(max_length=40) approximator_shasum = models.CharField(max_length=40, null=True) target = models.CharField(max_length=100) count = models.IntegerField() approximate = models.BooleanField(default=False) created = models.DateTimeField('date created', auto_now_add=True) event = models.ForeignKey(TEvent) def __unicode__(self): return "{} in {} index by {}".format(self.target, self.algorithm, self.video.name) def npy_path(self, media_root=None): if not (media_root is None): return "{}/{}/indexes/{}".format(media_root, self.video_id, self.features_file_name) else: return "{}/{}/indexes/{}".format(settings.MEDIA_ROOT, self.video_id, self.features_file_name) def load_index(self, media_root=None): if media_root is None: media_root = settings.MEDIA_ROOT video_dir = "{}/{}".format(media_root, self.video_id) if not os.path.isdir(video_dir): os.mkdir(video_dir) index_dir = "{}/{}/indexes".format(media_root, self.video_id) if not os.path.isdir(index_dir): os.mkdir(index_dir) dirnames = {} if self.features_file_name.strip(): fs.ensure(self.npy_path(media_root=''), dirnames, media_root) if self.features_file_name.endswith('.npy'): vectors = np.load(self.npy_path(media_root)) else: vectors = self.npy_path(media_root) else: vectors = None return vectors, self.entries class Tube(models.Model): """ A tube is a collection of sequential frames / regions that track a certain object or describe a specific scene """ id = models.CharField(max_length=100, primary_key=True) video = models.ForeignKey(Video, null=True) frame_level = models.BooleanField(default=False) full_video = models.BooleanField(default=False) full_segment = models.BooleanField(default=False) start_frame_index = models.IntegerField() end_frame_index = models.IntegerField() start_region = models.ForeignKey(Region, null=True, related_name="start_region") end_region = models.ForeignKey(Region, null=True, related_name="end_region") text = models.TextField(default="") metadata = JSONField(blank=True, null=True) event = models.ForeignKey(TEvent) per_event_index = models.IntegerField() class Meta: unique_together = (("event","per_event_index"),) class RegionRelation(models.Model): """ Captures relations between Regions within a video/dataset. """ video = models.ForeignKey(Video) source_region = models.ForeignKey(Region, related_name='source_region') target_region = models.ForeignKey(Region, related_name='target_region') event = models.ForeignKey(TEvent) name = models.CharField(max_length=400) weight = models.FloatField(null=True) metadata = JSONField(blank=True, null=True) per_event_index = models.IntegerField() class Meta: unique_together = (("event", "per_event_index"),) class HyperRegionRelation(models.Model): """ Captures relations between a Region in a video/dataset and an external globally addressed path / URL. HyperRegionRelation is an equivalent of anchor tags / hyperlinks. e.g. Region -> http://http://akshaybhat.com/static/img/akshay.jpg """ video = models.ForeignKey(Video) region = models.ForeignKey(Region) event = models.ForeignKey(TEvent) name = models.CharField(max_length=400) weight = models.FloatField(null=True) metadata = JSONField(blank=True, null=True) path = models.TextField() full_frame = models.BooleanField(default=False) x = models.IntegerField(default=0) y = models.IntegerField(default=0) h = models.IntegerField(default=0) w = models.IntegerField(default=0) # Unlike region frame_index is only required if the path points to a video or a .gif frame_index = models.IntegerField(null=True) segment_index = models.IntegerField(null=True) per_event_index = models.IntegerField() class Meta: unique_together = (("event", "per_event_index"),) class HyperTubeRegionRelation(models.Model): """ Captures relations between a Tube in a video/dataset and an external globally addressed path / URL. HyperTubeRegionRelation is an equivalent of anchor tags / hyperlinks. e.g. Tube -> http://http://akshaybhat.com/static/img/akshay.jpg """ video = models.ForeignKey(Video) tube = models.ForeignKey(Tube) event = models.ForeignKey(TEvent) name = models.CharField(max_length=400) weight = models.FloatField(null=True) metadata = JSONField(blank=True, null=True) path = models.TextField() full_frame = models.BooleanField(default=False) x = models.IntegerField(default=0) y = models.IntegerField(default=0) h = models.IntegerField(default=0) w = models.IntegerField(default=0) # Unlike region frame_index is only required if the path points to a video or a .gif frame_index = models.IntegerField(null=True) segment_index = models.IntegerField(null=True) per_event_index = models.IntegerField() class Meta: unique_together = (("event", "per_event_index"),) class TubeRelation(models.Model): """ Captures relations between Tubes within a video/dataset. """ video = models.ForeignKey(Video) source_tube = models.ForeignKey(Tube, related_name='source_tube') target_tube = models.ForeignKey(Tube, related_name='target_tube') event = models.ForeignKey(TEvent) name = models.CharField(max_length=400) weight = models.FloatField(null=True) metadata = JSONField(blank=True, null=True) per_event_index = models.IntegerField() class Meta: unique_together = (("event", "per_event_index"),) class TubeRegionRelation(models.Model): """ Captures relations between Tube and Region within a video/dataset. """ video = models.ForeignKey(Video) tube = models.ForeignKey(Tube) region = models.ForeignKey(Region) event = models.ForeignKey(TEvent) name = models.CharField(max_length=400) weight = models.FloatField(null=True) metadata = JSONField(blank=True, null=True) per_event_index = models.IntegerField() class Meta: unique_together = (("event", "per_event_index"),) class DeletedVideo(models.Model): deleter = models.ForeignKey(User, related_name="user_deleter", null=True) video_uuid = models.UUIDField(default=uuid.uuid4, null=True) created = models.DateTimeField('date created', auto_now_add=True) def __unicode__(self): return u'Deleted {} by {}'.format(self.video_uuid, self.deleter) class ManagementAction(models.Model): parent_task = models.CharField(max_length=500, default="") op = models.CharField(max_length=500, default="") host = models.CharField(max_length=500, default="") message = models.TextField() created = models.DateTimeField('date created', auto_now_add=True) ping_index = models.IntegerField(null=True) class SystemState(models.Model): created = models.DateTimeField('date created', auto_now_add=True) process_stats = JSONField(blank=True, null=True) worker_stats = JSONField(blank=True, null=True) redis_stats = JSONField(blank=True, null=True) queues = JSONField(blank=True, null=True) hosts = JSONField(blank=True, null=True) class QueryRegionIndexVector(models.Model): event = models.ForeignKey(TEvent) query_region = models.ForeignKey(QueryRegion) vector = models.BinaryField() created = models.DateTimeField('date created', auto_now_add=True) class Export(models.Model): MODEL_EXPORT = constants.MODEL_EXPORT VIDEO_EXPORT = constants.VIDEO_EXPORT EXPORT_TYPES = ( (MODEL_EXPORT, 'Model export'), (VIDEO_EXPORT, 'Video export'), ) export_type = models.CharField(max_length=1, choices=EXPORT_TYPES, db_index=True) event = models.ForeignKey(TEvent) url = models.TextField(default="") created = models.DateTimeField('date created', auto_now_add=True) class TaskRestart(models.Model): original_event_pk = models.UUIDField(default=uuid.uuid4, null=False) launched_event_pk = models.UUIDField(default=uuid.uuid4, null=False) attempts = models.IntegerField(default=0) arguments = JSONField(blank=True, null=True) operation = models.CharField(max_length=100, default="") queue = models.CharField(max_length=100, default="") video_uuid = models.UUIDField(default=uuid.uuid4, null=True) process = models.ForeignKey(DVAPQL) created = models.DateTimeField('date created', auto_now_add=True)
42bdc6b8462003678eef904f90fc3fb8a5bebc0b
3cefad27ca9f6ba70cd76237d320f402299ac6ac
/antlir/tests/test_subvol_utils_inner.py
3595ec4b74c93008399eed4a9a5d662e40cb3954
[ "MIT" ]
permissive
lhl2617/antlir
1880be26c1d5aa46d8e516dd294f3eb040b75847
1041732e8163c1316d3e45c0ba4db7937faa4809
refs/heads/main
2023-05-29T03:25:17.558306
2021-06-12T23:44:59
2021-06-12T23:45:50
376,619,288
0
0
MIT
2021-06-13T21:15:55
2021-06-13T18:58:56
null
UTF-8
Python
false
false
1,939
py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import os import platform import unittest from ..fs_utils import temp_dir from ..subvol_utils import ( Subvol, volume_dir, ) class InnerSubvolTestCase(unittest.TestCase): def test_delete_inner_subvols(self): # This branch is used for testing inside an image via the # `:test-subvol-utils-inner` test. The hostname is set in the # test definition. if platform.node() == "test-subvol-utils-inner": volume_tmp_dir = b"/" # This branch is used for "non-image" testing, ie: when the test is run # in the context of the host via a standard `python_unittest`. else: volume_tmp_dir = volume_dir() / "tmp" try: os.mkdir(volume_tmp_dir) except FileExistsError: pass with temp_dir( dir=volume_tmp_dir.decode(), prefix="delete_recursive" ) as td: try: outer = Subvol(td / "outer") outer.create() inner1 = Subvol(td / "outer/inner1") inner1.create() inner2 = Subvol(td / "outer/inner1/inner2") inner2.create() inner3 = Subvol(td / "outer/inner3") inner3.create() outer.delete() self.assertEqual([], td.listdir()) except BaseException: # Clean up even on Ctrl-C try: inner2.delete() finally: try: inner1.delete() finally: try: inner3.delete() finally: outer.delete() raise
a015801564b213bcb89b27edf3d4d90abb2ecac3
52b5773617a1b972a905de4d692540d26ff74926
/.history/maxProduct_20200731211104.py
6ad7e36b9ea31311c74a36dc56eac3420a783a37
[]
no_license
MaryanneNjeri/pythonModules
56f54bf098ae58ea069bf33f11ae94fa8eedcabc
f4e56b1e4dda2349267af634a46f6b9df6686020
refs/heads/master
2022-12-16T02:59:19.896129
2020-09-11T12:05:22
2020-09-11T12:05:22
null
0
0
null
null
null
null
UTF-8
Python
false
false
154
py
import sys def maxThree(arr): if len(arr) < 3: return -1 maxProduct = -(sys.maxsize -1) print(maxProduct) maxThree([-3,1,2,-])
bdd51190ad4dd56994b752ddc0e68c516bb6af37
53fab060fa262e5d5026e0807d93c75fb81e67b9
/backup/user_084/ch88_2020_06_22_17_23_50_676212.py
adf3e7aaf91173c5155e038a15e213075660b05a
[]
no_license
gabriellaec/desoft-analise-exercicios
b77c6999424c5ce7e44086a12589a0ad43d6adca
01940ab0897aa6005764fc220b900e4d6161d36b
refs/heads/main
2023-01-31T17:19:42.050628
2020-12-16T05:21:31
2020-12-16T05:21:31
306,735,108
0
0
null
null
null
null
UTF-8
Python
false
false
322
py
from math import * class retangulo: def __init__(self,P1,P2): self.IE=P1 self.SD=P2 def calcula_perimetro(self): P=2*(abs(self.IE.x-self.SD.x)+abs(self.IE.y+self.SD.y)) return P def calcula_area(self): A=abs(self.IE.x-self.SD.x)*abs(self.IE.y-self.SD.y) return A
e61fc4c01995d4e2b99acccdde8d6e7b89fbbcbd
f0120ec71e44284f59f1fca92e41ff6d05df4d9b
/production/server/server_interface.py
fea942e61f1141957fcfcdf264f06ab0b0f4c4d7
[]
no_license
Vlad-Shcherbina/icfpc2017-tbd
55d8c7022485843d47723c4c0c9fddbba5b8ee56
695e9e525e460b231c75461294176d6ebc0a6f3d
refs/heads/master
2021-03-30T15:46:19.387400
2017-10-14T16:01:04
2017-10-14T16:01:04
80,864,945
0
0
null
null
null
null
UTF-8
Python
false
false
2,138
py
from typing import NamedTuple, List, Dict from datetime import datetime from time import time from production.bot_interface import Map, Settings INFINITY = 3600 class PlayerStats(NamedTuple): ID: int name: str token: str games: int mu: float sigma: float class GameStats(NamedTuple): ID: int mapname: str futures: bool options: bool splurges: bool participants: List[str] scores: List[int] timestamp: int # TODO: datetime? class MatchInfo(NamedTuple): participants: List[str] map: Map mapname: str settings: Settings class ServerInterrupt(KeyboardInterrupt): pass class Estimation: def __init__(self): self.estimation = time() pass def start(self, N, turns): self.timestart = time() self.turns = turns self.estimation = time() + 10 * N + turns def set(self, i): if i == 0: return self.estimation = (time() - self.timestart) / i * self.turns + self.timestart def get(self): return self.estimation class Player: def __init__(self, stats: PlayerStats): self.stats = stats # self.lastgame = lastgame self.waiting = [] self.ongoing = [] def new_conn(self, deadline): self.waiting.append(deadline) def dead_conn(self, deadline): self.waiting.remove(deadline) def in_game(self, deadline, time_estimation): self.waiting.remove(deadline) self.ongoing.append(time_estimation) def end_game(self, time_estimation): while time_estimation in self.ongoing: self.ongoing.remove(time_estimation) def count(self): return len(self.waiting) + len(self.ongoing) def first_deadline(self): return min(self.waiting) if self.waiting else time() + INFINITY def first_finish(self): return min(x.get() for x in self.ongoing) if self.ongoing else time() + INFINITY def copy(self): newplayer = Player(self.stats) newplayer.waiting = self.waiting[:] newplayer.ongoing = self.ongoing[:] return newplayer
36b9219320ef7ae902f5c5382bf8b2556c502906
5f845ebbc2c9b40eea702833c91928ae90ae7ee5
/python/write-a-function.py
511404a3bdee2d3e060c21a5a7b1cfe501d09287
[ "MIT" ]
permissive
imgeekabhi/HackerRank
7a1917fee5af01976aebb9c82aa1045a36487016
7fe4a308abad85ce446a28328324be480672e6fc
refs/heads/master
2022-12-28T19:13:49.098090
2020-10-11T09:29:08
2020-10-11T09:29:08
300,023,395
1
0
MIT
2020-09-30T18:48:12
2020-09-30T18:48:11
null
UTF-8
Python
false
false
90
py
def is_leap(year): return (year % 400 == 0) or ((year % 4 == 0) and (year % 100 != 0))
18dac39adcc333a22da632fed347ba1293ee4a39
5e6d8b9989247801718dd1f10009f0f7f54c1eb4
/sdk/python/pulumi_azure_native/network/v20200501/hub_route_table.py
8f6fcd19889eabedeaa571fc60c1abc52d684cad
[ "BSD-3-Clause", "Apache-2.0" ]
permissive
vivimouret29/pulumi-azure-native
d238a8f91688c9bf09d745a7280b9bf2dd6d44e0
1cbd988bcb2aa75a83e220cb5abeb805d6484fce
refs/heads/master
2023-08-26T05:50:40.560691
2021-10-21T09:25:07
2021-10-21T09:25:07
null
0
0
null
null
null
null
UTF-8
Python
false
false
14,147
py
# coding=utf-8 # *** WARNING: this file was generated by the Pulumi SDK Generator. *** # *** Do not edit by hand unless you're certain you know what you are doing! *** import warnings import pulumi import pulumi.runtime from typing import Any, Mapping, Optional, Sequence, Union, overload from ... import _utilities from . import outputs from ._inputs import * __all__ = ['HubRouteTableArgs', 'HubRouteTable'] @pulumi.input_type class HubRouteTableArgs: def __init__(__self__, *, resource_group_name: pulumi.Input[str], virtual_hub_name: pulumi.Input[str], id: Optional[pulumi.Input[str]] = None, labels: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None, name: Optional[pulumi.Input[str]] = None, route_table_name: Optional[pulumi.Input[str]] = None, routes: Optional[pulumi.Input[Sequence[pulumi.Input['HubRouteArgs']]]] = None): """ The set of arguments for constructing a HubRouteTable resource. :param pulumi.Input[str] resource_group_name: The resource group name of the VirtualHub. :param pulumi.Input[str] virtual_hub_name: The name of the VirtualHub. :param pulumi.Input[str] id: Resource ID. :param pulumi.Input[Sequence[pulumi.Input[str]]] labels: List of labels associated with this route table. :param pulumi.Input[str] name: The name of the resource that is unique within a resource group. This name can be used to access the resource. :param pulumi.Input[str] route_table_name: The name of the RouteTable. :param pulumi.Input[Sequence[pulumi.Input['HubRouteArgs']]] routes: List of all routes. """ pulumi.set(__self__, "resource_group_name", resource_group_name) pulumi.set(__self__, "virtual_hub_name", virtual_hub_name) if id is not None: pulumi.set(__self__, "id", id) if labels is not None: pulumi.set(__self__, "labels", labels) if name is not None: pulumi.set(__self__, "name", name) if route_table_name is not None: pulumi.set(__self__, "route_table_name", route_table_name) if routes is not None: pulumi.set(__self__, "routes", routes) @property @pulumi.getter(name="resourceGroupName") def resource_group_name(self) -> pulumi.Input[str]: """ The resource group name of the VirtualHub. """ return pulumi.get(self, "resource_group_name") @resource_group_name.setter def resource_group_name(self, value: pulumi.Input[str]): pulumi.set(self, "resource_group_name", value) @property @pulumi.getter(name="virtualHubName") def virtual_hub_name(self) -> pulumi.Input[str]: """ The name of the VirtualHub. """ return pulumi.get(self, "virtual_hub_name") @virtual_hub_name.setter def virtual_hub_name(self, value: pulumi.Input[str]): pulumi.set(self, "virtual_hub_name", value) @property @pulumi.getter def id(self) -> Optional[pulumi.Input[str]]: """ Resource ID. """ return pulumi.get(self, "id") @id.setter def id(self, value: Optional[pulumi.Input[str]]): pulumi.set(self, "id", value) @property @pulumi.getter def labels(self) -> Optional[pulumi.Input[Sequence[pulumi.Input[str]]]]: """ List of labels associated with this route table. """ return pulumi.get(self, "labels") @labels.setter def labels(self, value: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]]): pulumi.set(self, "labels", value) @property @pulumi.getter def name(self) -> Optional[pulumi.Input[str]]: """ The name of the resource that is unique within a resource group. This name can be used to access the resource. """ return pulumi.get(self, "name") @name.setter def name(self, value: Optional[pulumi.Input[str]]): pulumi.set(self, "name", value) @property @pulumi.getter(name="routeTableName") def route_table_name(self) -> Optional[pulumi.Input[str]]: """ The name of the RouteTable. """ return pulumi.get(self, "route_table_name") @route_table_name.setter def route_table_name(self, value: Optional[pulumi.Input[str]]): pulumi.set(self, "route_table_name", value) @property @pulumi.getter def routes(self) -> Optional[pulumi.Input[Sequence[pulumi.Input['HubRouteArgs']]]]: """ List of all routes. """ return pulumi.get(self, "routes") @routes.setter def routes(self, value: Optional[pulumi.Input[Sequence[pulumi.Input['HubRouteArgs']]]]): pulumi.set(self, "routes", value) class HubRouteTable(pulumi.CustomResource): @overload def __init__(__self__, resource_name: str, opts: Optional[pulumi.ResourceOptions] = None, id: Optional[pulumi.Input[str]] = None, labels: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None, name: Optional[pulumi.Input[str]] = None, resource_group_name: Optional[pulumi.Input[str]] = None, route_table_name: Optional[pulumi.Input[str]] = None, routes: Optional[pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['HubRouteArgs']]]]] = None, virtual_hub_name: Optional[pulumi.Input[str]] = None, __props__=None): """ RouteTable resource in a virtual hub. :param str resource_name: The name of the resource. :param pulumi.ResourceOptions opts: Options for the resource. :param pulumi.Input[str] id: Resource ID. :param pulumi.Input[Sequence[pulumi.Input[str]]] labels: List of labels associated with this route table. :param pulumi.Input[str] name: The name of the resource that is unique within a resource group. This name can be used to access the resource. :param pulumi.Input[str] resource_group_name: The resource group name of the VirtualHub. :param pulumi.Input[str] route_table_name: The name of the RouteTable. :param pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['HubRouteArgs']]]] routes: List of all routes. :param pulumi.Input[str] virtual_hub_name: The name of the VirtualHub. """ ... @overload def __init__(__self__, resource_name: str, args: HubRouteTableArgs, opts: Optional[pulumi.ResourceOptions] = None): """ RouteTable resource in a virtual hub. :param str resource_name: The name of the resource. :param HubRouteTableArgs args: The arguments to use to populate this resource's properties. :param pulumi.ResourceOptions opts: Options for the resource. """ ... def __init__(__self__, resource_name: str, *args, **kwargs): resource_args, opts = _utilities.get_resource_args_opts(HubRouteTableArgs, pulumi.ResourceOptions, *args, **kwargs) if resource_args is not None: __self__._internal_init(resource_name, opts, **resource_args.__dict__) else: __self__._internal_init(resource_name, *args, **kwargs) def _internal_init(__self__, resource_name: str, opts: Optional[pulumi.ResourceOptions] = None, id: Optional[pulumi.Input[str]] = None, labels: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None, name: Optional[pulumi.Input[str]] = None, resource_group_name: Optional[pulumi.Input[str]] = None, route_table_name: Optional[pulumi.Input[str]] = None, routes: Optional[pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['HubRouteArgs']]]]] = None, virtual_hub_name: Optional[pulumi.Input[str]] = None, __props__=None): if opts is None: opts = pulumi.ResourceOptions() if not isinstance(opts, pulumi.ResourceOptions): raise TypeError('Expected resource options to be a ResourceOptions instance') if opts.version is None: opts.version = _utilities.get_version() if opts.id is None: if __props__ is not None: raise TypeError('__props__ is only valid when passed in combination with a valid opts.id to get an existing resource') __props__ = HubRouteTableArgs.__new__(HubRouteTableArgs) __props__.__dict__["id"] = id __props__.__dict__["labels"] = labels __props__.__dict__["name"] = name if resource_group_name is None and not opts.urn: raise TypeError("Missing required property 'resource_group_name'") __props__.__dict__["resource_group_name"] = resource_group_name __props__.__dict__["route_table_name"] = route_table_name __props__.__dict__["routes"] = routes if virtual_hub_name is None and not opts.urn: raise TypeError("Missing required property 'virtual_hub_name'") __props__.__dict__["virtual_hub_name"] = virtual_hub_name __props__.__dict__["associated_connections"] = None __props__.__dict__["etag"] = None __props__.__dict__["propagating_connections"] = None __props__.__dict__["provisioning_state"] = None __props__.__dict__["type"] = None alias_opts = pulumi.ResourceOptions(aliases=[pulumi.Alias(type_="azure-nextgen:network/v20200501:HubRouteTable"), pulumi.Alias(type_="azure-native:network:HubRouteTable"), pulumi.Alias(type_="azure-nextgen:network:HubRouteTable"), pulumi.Alias(type_="azure-native:network/v20200401:HubRouteTable"), pulumi.Alias(type_="azure-nextgen:network/v20200401:HubRouteTable"), pulumi.Alias(type_="azure-native:network/v20200601:HubRouteTable"), pulumi.Alias(type_="azure-nextgen:network/v20200601:HubRouteTable"), pulumi.Alias(type_="azure-native:network/v20200701:HubRouteTable"), pulumi.Alias(type_="azure-nextgen:network/v20200701:HubRouteTable"), pulumi.Alias(type_="azure-native:network/v20200801:HubRouteTable"), pulumi.Alias(type_="azure-nextgen:network/v20200801:HubRouteTable"), pulumi.Alias(type_="azure-native:network/v20201101:HubRouteTable"), pulumi.Alias(type_="azure-nextgen:network/v20201101:HubRouteTable"), pulumi.Alias(type_="azure-native:network/v20210201:HubRouteTable"), pulumi.Alias(type_="azure-nextgen:network/v20210201:HubRouteTable"), pulumi.Alias(type_="azure-native:network/v20210301:HubRouteTable"), pulumi.Alias(type_="azure-nextgen:network/v20210301:HubRouteTable")]) opts = pulumi.ResourceOptions.merge(opts, alias_opts) super(HubRouteTable, __self__).__init__( 'azure-native:network/v20200501:HubRouteTable', resource_name, __props__, opts) @staticmethod def get(resource_name: str, id: pulumi.Input[str], opts: Optional[pulumi.ResourceOptions] = None) -> 'HubRouteTable': """ Get an existing HubRouteTable resource's state with the given name, id, and optional extra properties used to qualify the lookup. :param str resource_name: The unique name of the resulting resource. :param pulumi.Input[str] id: The unique provider ID of the resource to lookup. :param pulumi.ResourceOptions opts: Options for the resource. """ opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id)) __props__ = HubRouteTableArgs.__new__(HubRouteTableArgs) __props__.__dict__["associated_connections"] = None __props__.__dict__["etag"] = None __props__.__dict__["labels"] = None __props__.__dict__["name"] = None __props__.__dict__["propagating_connections"] = None __props__.__dict__["provisioning_state"] = None __props__.__dict__["routes"] = None __props__.__dict__["type"] = None return HubRouteTable(resource_name, opts=opts, __props__=__props__) @property @pulumi.getter(name="associatedConnections") def associated_connections(self) -> pulumi.Output[Sequence[str]]: """ List of all connections associated with this route table. """ return pulumi.get(self, "associated_connections") @property @pulumi.getter def etag(self) -> pulumi.Output[str]: """ A unique read-only string that changes whenever the resource is updated. """ return pulumi.get(self, "etag") @property @pulumi.getter def labels(self) -> pulumi.Output[Optional[Sequence[str]]]: """ List of labels associated with this route table. """ return pulumi.get(self, "labels") @property @pulumi.getter def name(self) -> pulumi.Output[Optional[str]]: """ The name of the resource that is unique within a resource group. This name can be used to access the resource. """ return pulumi.get(self, "name") @property @pulumi.getter(name="propagatingConnections") def propagating_connections(self) -> pulumi.Output[Sequence[str]]: """ List of all connections that advertise to this route table. """ return pulumi.get(self, "propagating_connections") @property @pulumi.getter(name="provisioningState") def provisioning_state(self) -> pulumi.Output[str]: """ The provisioning state of the RouteTable resource. """ return pulumi.get(self, "provisioning_state") @property @pulumi.getter def routes(self) -> pulumi.Output[Optional[Sequence['outputs.HubRouteResponse']]]: """ List of all routes. """ return pulumi.get(self, "routes") @property @pulumi.getter def type(self) -> pulumi.Output[str]: """ Resource type. """ return pulumi.get(self, "type")
baeb1d0716b3fe402977b96429be369bb60a25c8
c49590eb7f01df37c8ec5fef00d0ffc7250fa321
/openapi_client/models/sell.py
b079fbb0b63c1a32d9a27046bc53008c0892fdb4
[]
no_license
harshad5498/ks-orderapi-python
373a4b85a56ff97e2367eebd076f67f972e92f51
237da6fc3297c02e85f0fff1a34857aaa4c1d295
refs/heads/master
2022-12-09T19:55:21.938764
2020-09-03T05:22:51
2020-09-03T05:22:51
293,533,651
0
0
null
2020-09-07T13:19:25
2020-09-07T13:19:24
null
UTF-8
Python
false
false
4,247
py
# coding: utf-8 """ KS Trade API's The version of the OpenAPI document: 1.0 """ import pprint import re # noqa: F401 import six from openapi_client.configuration import Configuration class Sell(object): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech """ """ Attributes: openapi_types (dict): The key is attribute name and the value is attribute type. attribute_map (dict): The key is attribute name and the value is json key in definition. """ openapi_types = { 'price': 'float', 'quantity': 'int', 'orders': 'int' } attribute_map = { 'price': 'price', 'quantity': 'quantity', 'orders': 'orders' } def __init__(self, price=None, quantity=None, orders=None, local_vars_configuration=None): # noqa: E501 """Sell - a model defined in OpenAPI""" # noqa: E501 if local_vars_configuration is None: local_vars_configuration = Configuration() self.local_vars_configuration = local_vars_configuration self._price = None self._quantity = None self._orders = None self.discriminator = None if price is not None: self.price = price if quantity is not None: self.quantity = quantity if orders is not None: self.orders = orders @property def price(self): """Gets the price of this Sell. # noqa: E501 :return: The price of this Sell. # noqa: E501 :rtype: float """ return self._price @price.setter def price(self, price): """Sets the price of this Sell. :param price: The price of this Sell. # noqa: E501 :type price: float """ self._price = price @property def quantity(self): """Gets the quantity of this Sell. # noqa: E501 :return: The quantity of this Sell. # noqa: E501 :rtype: int """ return self._quantity @quantity.setter def quantity(self, quantity): """Sets the quantity of this Sell. :param quantity: The quantity of this Sell. # noqa: E501 :type quantity: int """ self._quantity = quantity @property def orders(self): """Gets the orders of this Sell. # noqa: E501 :return: The orders of this Sell. # noqa: E501 :rtype: int """ return self._orders @orders.setter def orders(self, orders): """Sets the orders of this Sell. :param orders: The orders of this Sell. # noqa: E501 :type orders: int """ self._orders = orders def to_dict(self): """Returns the model properties as a dict""" result = {} for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): result[attr] = list(map( lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value )) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): result[attr] = dict(map( lambda item: (item[0], item[1].to_dict()) if hasattr(item[1], "to_dict") else item, value.items() )) else: result[attr] = value return result def to_str(self): """Returns the string representation of the model""" return pprint.pformat(self.to_dict()) def __repr__(self): """For `print` and `pprint`""" return self.to_str() def __eq__(self, other): """Returns true if both objects are equal""" if not isinstance(other, Sell): return False return self.to_dict() == other.to_dict() def __ne__(self, other): """Returns true if both objects are not equal""" if not isinstance(other, Sell): return True return self.to_dict() != other.to_dict()
6c4ccb2da13c5f4a8c909a769b8db1f7f5e11b6a
62e45255088abb536e9ea6fcbe497e83bad171a0
/ippython/funciones_duplica_348.py
7e6eeddb5b9a16c421c5e012523191dca58e6cca
[]
no_license
jmery24/python
a24f562c8d893a97a5d9011e9283eba948b8b6dc
3e35ac9c9efbac4ff20374e1dfa75a7af6003ab9
refs/heads/master
2020-12-25T21:56:17.063767
2015-06-18T04:59:05
2015-06-18T04:59:05
36,337,473
0
0
null
2015-05-27T02:26:54
2015-05-27T02:26:54
null
UTF-8
Python
false
false
623
py
# -*- coding: utf-8 -*- """ Created on Wed Jun 5 07:30:41 2013 @author: daniel """ #programa: funciones_duplica_numero_348.py #definir una funcion que duplique los valores de la lista original #modificando la lista original #ejercicio 348 #definir funcion <duplica> def duplica(lista): for i in range(len(lista)): lista[i] = lista[i]*2 return lista #cuerpo del programa #input numeros = [1, 6, 15, 25, 30, 40] #activa procedimiento print 'Numeros originales: ', numeros print print 'Numeros duplicados: ', duplica(numeros) print print 'lista original modificada: ', numeros
83ceaca4cedb1cf4a5f043b17207f25b96b7b66c
ab72563047515d98cd43481d8c42b4be73a9e7ae
/tests/trac/test-trac-0179.py
30e2ee5a8132e3a0e2351f6fdeabecfebef6ecc4
[ "Python-2.0", "MIT", "Apache-2.0" ]
permissive
CantemoInternal/pyxb
08924a260886106cf499617a225de71cbf075a84
6979a4d3c13e10059da2e2d096acef6c06fc1ced
refs/heads/master
2021-01-18T10:52:39.712997
2014-10-19T11:18:38
2014-10-19T11:18:38
null
0
0
null
null
null
null
UTF-8
Python
false
false
1,454
py
# -*- coding: utf-8 -*- import logging if __name__ == '__main__': logging.basicConfig() _log = logging.getLogger(__name__) import pyxb.binding.generate import pyxb.utils.domutils from xml.dom import Node import os.path xsd='''<?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:complexType name="tAny"> <xsd:all minOccurs="0"> <xsd:element type="xsd:int" name="a" minOccurs="1"/> <xsd:element type="xsd:int" name="b" minOccurs="1"/> </xsd:all> </xsd:complexType> <xsd:element name="eAny" type="tAny"/> </xsd:schema>''' code = pyxb.binding.generate.GeneratePython(schema_text=xsd) #open('code.py', 'w').write(code) rv = compile(code, 'test', 'exec') eval(rv) from pyxb.exceptions_ import * import unittest class TestTrac0179 (unittest.TestCase): def testBasic (self): instance = CreateFromDocument("<eAny/>") self.assertTrue(instance.a is None) self.assertTrue(instance.b is None) instance = CreateFromDocument("<eAny><a>1</a><b>2</b></eAny>") self.assertEqual(instance.a, 1) self.assertEqual(instance.b, 2) instance = CreateFromDocument("<eAny><b>2</b><a>1</a></eAny>") self.assertEqual(instance.a, 1) self.assertEqual(instance.b, 2) self.assertRaises(pyxb.IncompleteElementContentError, CreateFromDocument, "<eAny><a>1</a></eAny>") if __name__ == '__main__': unittest.main()
5754ed817e041ad412ca2d519e7f16fc4c733763
deaf519d1ee104784a56df98a7eb3705efbd1120
/carsir_test/easy_sell/test/test_log_control.py
b2644c4aff10847586c5947bca5e5578339e16e4
[]
no_license
606keng/weeds_study
6391fbb47fb06abf67b7651250373f169fbdfd3e
df9d96009cbdf84176efbf4b02f43cb1d5208524
refs/heads/master
2021-04-23T07:43:52.472097
2021-04-07T13:10:58
2021-04-07T13:10:58
249,910,294
1
0
null
null
null
null
UTF-8
Python
false
false
527
py
import time import logging logging.basicConfig(level=logging.DEBUG) def test_1(): log = logging.getLogger('test_1') time.sleep(1) log.debug('after 1 sec') time.sleep(1) log.debug('after 2 sec') time.sleep(1) log.debug('after 3 sec') assert 1, 'should pass' def test_2(): log = logging.getLogger('test_2') time.sleep(1) log.debug('after 1 sec') time.sleep(1) log.debug('after 2 sec') time.sleep(1) log.debug('after 3 sec') assert 0, 'failing for demo purposes'
009d0651c358c2e02347a5fb7444f1ed0a5ab0c3
23a4dcb819f4cc7fa0b046f8804be35b05b2779a
/modules/debugger/breakpoints/function_breakpoints.py
815e220b5e77546d5613b4d4ae2115ae0eb6b3dd
[ "MIT" ]
permissive
quycao/sublime_debugger
07784b5892af9d3eacd5c9df59af541b268f4f42
2a168e409300fc260c85f3e2c8786577223e4232
refs/heads/master
2020-09-13T20:38:28.677494
2019-11-26T03:59:22
2019-11-26T03:59:22
222,896,722
0
0
MIT
2019-11-20T09:12:56
2019-11-20T09:12:55
null
UTF-8
Python
false
false
3,660
py
from ... typecheck import * from ... import core from ... import ui from ... import dap class FunctionBreakpoint: def __init__(self, dap: dap.FunctionBreakpoint, enabled: bool = True) -> None: self.enabled = enabled self.dap = dap self.result = None #type: Optional[dap.BreakpointResult] def into_json(self) -> dict: return { 'dap': self.dap.into_json(), 'enabled': self.enabled } @staticmethod def from_json(json: dict) -> 'FunctionBreakpoint': return FunctionBreakpoint( dap.FunctionBreakpoint.from_json(json['dap']), json['enabled'] ) @property def image(self) -> ui.Image: if not self.enabled: return ui.Images.shared.dot_disabled if not self.verified: return ui.Images.shared.dot_emtpy return ui.Images.shared.dot @property def tag(self) -> Optional[str]: return 'ƒn' @property def name(self): return self.dap.name @property def condition(self): return self.dap.condition @property def hitCondition(self): return self.dap.hitCondition @property def verified(self): if self.result: return self.result.verified return True class FunctionBreakpoints: def __init__(self): self.breakpoints = [] #type: List[FunctionBreakpoint] self.on_updated = core.Event() #type: core.Event[List[FunctionBreakpoint]] self.on_send = core.Event() #type: core.Event[List[FunctionBreakpoint]] def __iter__(self): return iter(self.breakpoints) def into_json(self) -> list: return list(map(lambda b: b.into_json(), self.breakpoints)) def load_json(self, json: list): self.breakpoints = list(map(lambda j: FunctionBreakpoint.from_json(j), json)) self.on_updated(self.breakpoints) def clear_session_data(self): for breakpoint in self.breakpoints: breakpoint.result = None self.updated(send=False) def updated(self, send: bool=True): self.on_updated(self.breakpoints) if send: self.on_send(self.breakpoints) def set_result(self, breakpoint: FunctionBreakpoint, result: dap.BreakpointResult) -> None: breakpoint.result = result self.updated(send=False) def toggle(self, breakpoint: FunctionBreakpoint): breakpoint.enabled = not breakpoint.enabled self.updated() def edit(self, breakpoint: FunctionBreakpoint): def set_name(value: str): if value: breakpoint.dap.name = value self.updated() def set_condition(value: str): breakpoint.dap.condition = value or None self.updated() def set_hit_condition(value: str): breakpoint.dap.hitCondition = value or None self.updated() def toggle_enabled(): self.toggle(breakpoint) def remove(): self.breakpoints.remove(breakpoint) self.updated() return ui.InputList([ ui.InputListItemCheckedText( set_name, "Function", "Name of function to break on", breakpoint.dap.name, ), ui.InputListItemCheckedText( set_condition, "Condition", "Breaks when expression is true", breakpoint.dap.condition, ), ui.InputListItemCheckedText( set_hit_condition, "Count", "Breaks when hit count condition is met", breakpoint.dap.hitCondition, ), ui.InputListItemChecked ( toggle_enabled, "Enabled", "Disabled", breakpoint.enabled, ), ui.InputListItem( remove, "Remove" ), ], placeholder= "Edit Breakpoint on function {}".format(breakpoint.name)) def add_command(self) -> None: ui.InputText(self.add, "Name of function to break on").run() def add(self, name: str): self.breakpoints.append( FunctionBreakpoint( dap=dap.FunctionBreakpoint(name, None, None), enabled=True ) ) self.updated() def remove_all(self): self.breakpoints = [] self.updated()
e5dea951b67d3261a0a4358277126467dce5125d
7087a5dd1772c9456f098bc024a894dcaeef5432
/backup/file.py
d15661444d72f8287c7ccfca0d168d0ba5d63f21
[]
no_license
santhoshchami/kubecctl-python
5be7a5a17cc6f08ec717b3eb1c11719ef7653aba
cd45af465e25b0799d65c573e841e2acb983ee68
refs/heads/master
2021-06-23T11:00:43.615062
2019-07-10T16:57:06
2019-07-10T16:57:06
145,669,246
0
0
null
null
null
null
UTF-8
Python
false
false
331
py
import sys import re file_name=sys.argv[1] with open(file_name) as fh: def svcFile(value): for line in fh: if(re.search("^name=", line)): data = re.findall('".*"', line) name=re.sub('"', '', data[0]) print(name) svcFile('name')
321f5336901f7df97e60f69f2d097b40ba5aa0d8
2c4763aa544344a3a615f9a65d1ded7d0f59ae50
/waflib/Build.py
a12cea5430afaaed1e437b8d3ecf725efb2028e4
[]
no_license
afeldman/waf
572bf95d6b11571bbb2941ba0fe463402b1e39f3
4c489b38fe1520ec1bc0fa7e1521f7129c20f8b6
refs/heads/master
2021-05-09T18:18:16.598191
2019-03-05T06:33:42
2019-03-05T06:33:42
58,713,085
0
0
null
2016-05-13T07:34:33
2016-05-13T07:34:33
null
UTF-8
Python
false
false
44,520
py
#!/usr/bin/env python # encoding: utf-8 # Thomas Nagy, 2005-2018 (ita) """ Classes related to the build phase (build, clean, install, step, etc) The inheritance tree is the following: """ import os, sys, errno, re, shutil, stat try: import cPickle except ImportError: import pickle as cPickle from waflib import Node, Runner, TaskGen, Utils, ConfigSet, Task, Logs, Options, Context, Errors CACHE_DIR = 'c4che' """Name of the cache directory""" CACHE_SUFFIX = '_cache.py' """ConfigSet cache files for variants are written under :py:attr:´waflib.Build.CACHE_DIR´ in the form ´variant_name´_cache.py""" INSTALL = 1337 """Positive value '->' install, see :py:attr:`waflib.Build.BuildContext.is_install`""" UNINSTALL = -1337 """Negative value '<-' uninstall, see :py:attr:`waflib.Build.BuildContext.is_install`""" SAVED_ATTRS = 'root node_sigs task_sigs imp_sigs raw_deps node_deps'.split() """Build class members to save between the runs; these should be all dicts except for `root` which represents a :py:class:`waflib.Node.Node` instance """ CFG_FILES = 'cfg_files' """Files from the build directory to hash before starting the build (``config.h`` written during the configuration)""" POST_AT_ONCE = 0 """Post mode: all task generators are posted before any task executed""" POST_LAZY = 1 """Post mode: post the task generators group after group, the tasks in the next group are created when the tasks in the previous groups are done""" PROTOCOL = -1 if sys.platform == 'cli': PROTOCOL = 0 class BuildContext(Context.Context): '''executes the build''' cmd = 'build' variant = '' def __init__(self, **kw): super(BuildContext, self).__init__(**kw) self.is_install = 0 """Non-zero value when installing or uninstalling file""" self.top_dir = kw.get('top_dir', Context.top_dir) """See :py:attr:`waflib.Context.top_dir`; prefer :py:attr:`waflib.Build.BuildContext.srcnode`""" self.out_dir = kw.get('out_dir', Context.out_dir) """See :py:attr:`waflib.Context.out_dir`; prefer :py:attr:`waflib.Build.BuildContext.bldnode`""" self.run_dir = kw.get('run_dir', Context.run_dir) """See :py:attr:`waflib.Context.run_dir`""" self.launch_dir = Context.launch_dir """See :py:attr:`waflib.Context.out_dir`; prefer :py:meth:`waflib.Build.BuildContext.launch_node`""" self.post_mode = POST_LAZY """Whether to post the task generators at once or group-by-group (default is group-by-group)""" self.cache_dir = kw.get('cache_dir') if not self.cache_dir: self.cache_dir = os.path.join(self.out_dir, CACHE_DIR) self.all_envs = {} """Map names to :py:class:`waflib.ConfigSet.ConfigSet`, the empty string must map to the default environment""" # ======================================= # # cache variables self.node_sigs = {} """Dict mapping build nodes to task identifier (uid), it indicates whether a task created a particular file (persists across builds)""" self.task_sigs = {} """Dict mapping task identifiers (uid) to task signatures (persists across builds)""" self.imp_sigs = {} """Dict mapping task identifiers (uid) to implicit task dependencies used for scanning targets (persists across builds)""" self.node_deps = {} """Dict mapping task identifiers (uid) to node dependencies found by :py:meth:`waflib.Task.Task.scan` (persists across builds)""" self.raw_deps = {} """Dict mapping task identifiers (uid) to custom data returned by :py:meth:`waflib.Task.Task.scan` (persists across builds)""" self.task_gen_cache_names = {} self.jobs = Options.options.jobs """Amount of jobs to run in parallel""" self.targets = Options.options.targets """List of targets to build (default: \\*)""" self.keep = Options.options.keep """Whether the build should continue past errors""" self.progress_bar = Options.options.progress_bar """ Level of progress status: 0. normal output 1. progress bar 2. IDE output 3. No output at all """ # Manual dependencies. self.deps_man = Utils.defaultdict(list) """Manual dependencies set by :py:meth:`waflib.Build.BuildContext.add_manual_dependency`""" # just the structure here self.current_group = 0 """ Current build group """ self.groups = [] """ List containing lists of task generators """ self.group_names = {} """ Map group names to the group lists. See :py:meth:`waflib.Build.BuildContext.add_group` """ for v in SAVED_ATTRS: if not hasattr(self, v): setattr(self, v, {}) def get_variant_dir(self): """Getter for the variant_dir attribute""" if not self.variant: return self.out_dir return os.path.join(self.out_dir, os.path.normpath(self.variant)) variant_dir = property(get_variant_dir, None) def __call__(self, *k, **kw): """ Create a task generator and add it to the current build group. The following forms are equivalent:: def build(bld): tg = bld(a=1, b=2) def build(bld): tg = bld() tg.a = 1 tg.b = 2 def build(bld): tg = TaskGen.task_gen(a=1, b=2) bld.add_to_group(tg, None) :param group: group name to add the task generator to :type group: string """ kw['bld'] = self ret = TaskGen.task_gen(*k, **kw) self.task_gen_cache_names = {} # reset the cache, each time self.add_to_group(ret, group=kw.get('group')) return ret def __copy__(self): """ Build contexts cannot be copied :raises: :py:class:`waflib.Errors.WafError` """ raise Errors.WafError('build contexts cannot be copied') def load_envs(self): """ The configuration command creates files of the form ``build/c4che/NAMEcache.py``. This method creates a :py:class:`waflib.ConfigSet.ConfigSet` instance for each ``NAME`` by reading those files and stores them in :py:attr:`waflib.Build.BuildContext.allenvs`. """ node = self.root.find_node(self.cache_dir) if not node: raise Errors.WafError('The project was not configured: run "waf configure" first!') lst = node.ant_glob('**/*%s' % CACHE_SUFFIX, quiet=True) if not lst: raise Errors.WafError('The cache directory is empty: reconfigure the project') for x in lst: name = x.path_from(node).replace(CACHE_SUFFIX, '').replace('\\', '/') env = ConfigSet.ConfigSet(x.abspath()) self.all_envs[name] = env for f in env[CFG_FILES]: newnode = self.root.find_resource(f) if not newnode or not newnode.exists(): raise Errors.WafError('Missing configuration file %r, reconfigure the project!' % f) def init_dirs(self): """ Initialize the project directory and the build directory by creating the nodes :py:attr:`waflib.Build.BuildContext.srcnode` and :py:attr:`waflib.Build.BuildContext.bldnode` corresponding to ``top_dir`` and ``variant_dir`` respectively. The ``bldnode`` directory is created if necessary. """ if not (os.path.isabs(self.top_dir) and os.path.isabs(self.out_dir)): raise Errors.WafError('The project was not configured: run "waf configure" first!') self.path = self.srcnode = self.root.find_dir(self.top_dir) self.bldnode = self.root.make_node(self.variant_dir) self.bldnode.mkdir() def execute(self): """ Restore data from previous builds and call :py:meth:`waflib.Build.BuildContext.execute_build`. Overrides from :py:func:`waflib.Context.Context.execute` """ self.restore() if not self.all_envs: self.load_envs() self.execute_build() def execute_build(self): """ Execute the build by: * reading the scripts (see :py:meth:`waflib.Context.Context.recurse`) * calling :py:meth:`waflib.Build.BuildContext.pre_build` to call user build functions * calling :py:meth:`waflib.Build.BuildContext.compile` to process the tasks * calling :py:meth:`waflib.Build.BuildContext.post_build` to call user build functions """ Logs.info("Waf: Entering directory `%s'", self.variant_dir) self.recurse([self.run_dir]) self.pre_build() # display the time elapsed in the progress bar self.timer = Utils.Timer() try: self.compile() finally: if self.progress_bar == 1 and sys.stderr.isatty(): c = self.producer.processed or 1 m = self.progress_line(c, c, Logs.colors.BLUE, Logs.colors.NORMAL) Logs.info(m, extra={'stream': sys.stderr, 'c1': Logs.colors.cursor_off, 'c2' : Logs.colors.cursor_on}) Logs.info("Waf: Leaving directory `%s'", self.variant_dir) try: self.producer.bld = None del self.producer except AttributeError: pass self.post_build() def restore(self): """ Load data from a previous run, sets the attributes listed in :py:const:`waflib.Build.SAVED_ATTRS` """ try: env = ConfigSet.ConfigSet(os.path.join(self.cache_dir, 'build.config.py')) except EnvironmentError: pass else: if env.version < Context.HEXVERSION: raise Errors.WafError('Project was configured with a different version of Waf, please reconfigure it') for t in env.tools: self.setup(**t) dbfn = os.path.join(self.variant_dir, Context.DBFILE) try: data = Utils.readf(dbfn, 'rb') except (EnvironmentError, EOFError): # handle missing file/empty file Logs.debug('build: Could not load the build cache %s (missing)', dbfn) else: try: Node.pickle_lock.acquire() Node.Nod3 = self.node_class try: data = cPickle.loads(data) except Exception as e: Logs.debug('build: Could not pickle the build cache %s: %r', dbfn, e) else: for x in SAVED_ATTRS: setattr(self, x, data.get(x, {})) finally: Node.pickle_lock.release() self.init_dirs() def store(self): """ Store data for next runs, set the attributes listed in :py:const:`waflib.Build.SAVED_ATTRS`. Uses a temporary file to avoid problems on ctrl+c. """ data = {} for x in SAVED_ATTRS: data[x] = getattr(self, x) db = os.path.join(self.variant_dir, Context.DBFILE) try: Node.pickle_lock.acquire() Node.Nod3 = self.node_class x = cPickle.dumps(data, PROTOCOL) finally: Node.pickle_lock.release() Utils.writef(db + '.tmp', x, m='wb') try: st = os.stat(db) os.remove(db) if not Utils.is_win32: # win32 has no chown but we're paranoid os.chown(db + '.tmp', st.st_uid, st.st_gid) except (AttributeError, OSError): pass # do not use shutil.move (copy is not thread-safe) os.rename(db + '.tmp', db) def compile(self): """ Run the build by creating an instance of :py:class:`waflib.Runner.Parallel` The cache file is written when at least a task was executed. :raises: :py:class:`waflib.Errors.BuildError` in case the build fails """ Logs.debug('build: compile()') # delegate the producer-consumer logic to another object to reduce the complexity self.producer = Runner.Parallel(self, self.jobs) self.producer.biter = self.get_build_iterator() try: self.producer.start() except KeyboardInterrupt: if self.is_dirty(): self.store() raise else: if self.is_dirty(): self.store() if self.producer.error: raise Errors.BuildError(self.producer.error) def is_dirty(self): return self.producer.dirty def setup(self, tool, tooldir=None, funs=None): """ Import waf tools defined during the configuration:: def configure(conf): conf.load('glib2') def build(bld): pass # glib2 is imported implicitly :param tool: tool list :type tool: list :param tooldir: optional tool directory (sys.path) :type tooldir: list of string :param funs: unused variable """ if isinstance(tool, list): for i in tool: self.setup(i, tooldir) return module = Context.load_tool(tool, tooldir) if hasattr(module, "setup"): module.setup(self) def get_env(self): """Getter for the env property""" try: return self.all_envs[self.variant] except KeyError: return self.all_envs[''] def set_env(self, val): """Setter for the env property""" self.all_envs[self.variant] = val env = property(get_env, set_env) def add_manual_dependency(self, path, value): """ Adds a dependency from a node object to a value:: def build(bld): bld.add_manual_dependency( bld.path.find_resource('wscript'), bld.root.find_resource('/etc/fstab')) :param path: file path :type path: string or :py:class:`waflib.Node.Node` :param value: value to depend :type value: :py:class:`waflib.Node.Node`, byte object, or function returning a byte object """ if not path: raise ValueError('Invalid input path %r' % path) if isinstance(path, Node.Node): node = path elif os.path.isabs(path): node = self.root.find_resource(path) else: node = self.path.find_resource(path) if not node: raise ValueError('Could not find the path %r' % path) if isinstance(value, list): self.deps_man[node].extend(value) else: self.deps_man[node].append(value) def launch_node(self): """Returns the launch directory as a :py:class:`waflib.Node.Node` object (cached)""" try: # private cache return self.p_ln except AttributeError: self.p_ln = self.root.find_dir(self.launch_dir) return self.p_ln def hash_env_vars(self, env, vars_lst): """ Hashes configuration set variables:: def build(bld): bld.hash_env_vars(bld.env, ['CXX', 'CC']) This method uses an internal cache. :param env: Configuration Set :type env: :py:class:`waflib.ConfigSet.ConfigSet` :param vars_lst: list of variables :type vars_list: list of string """ if not env.table: env = env.parent if not env: return Utils.SIG_NIL idx = str(id(env)) + str(vars_lst) try: cache = self.cache_env except AttributeError: cache = self.cache_env = {} else: try: return self.cache_env[idx] except KeyError: pass lst = [env[a] for a in vars_lst] cache[idx] = ret = Utils.h_list(lst) Logs.debug('envhash: %s %r', Utils.to_hex(ret), lst) return ret def get_tgen_by_name(self, name): """ Fetches a task generator by its name or its target attribute; the name must be unique in a build:: def build(bld): tg = bld(name='foo') tg == bld.get_tgen_by_name('foo') This method use a private internal cache. :param name: Task generator name :raises: :py:class:`waflib.Errors.WafError` in case there is no task genenerator by that name """ cache = self.task_gen_cache_names if not cache: # create the index lazily for g in self.groups: for tg in g: try: cache[tg.name] = tg except AttributeError: # raised if not a task generator, which should be uncommon pass try: return cache[name] except KeyError: raise Errors.WafError('Could not find a task generator for the name %r' % name) def progress_line(self, idx, total, col1, col2): """ Computes a progress bar line displayed when running ``waf -p`` :returns: progress bar line :rtype: string """ if not sys.stderr.isatty(): return '' n = len(str(total)) Utils.rot_idx += 1 ind = Utils.rot_chr[Utils.rot_idx % 4] pc = (100. * idx)/total fs = "[%%%dd/%%d][%%s%%2d%%%%%%s][%s][" % (n, ind) left = fs % (idx, total, col1, pc, col2) right = '][%s%s%s]' % (col1, self.timer, col2) cols = Logs.get_term_cols() - len(left) - len(right) + 2*len(col1) + 2*len(col2) if cols < 7: cols = 7 ratio = ((cols * idx)//total) - 1 bar = ('='*ratio+'>').ljust(cols) msg = Logs.indicator % (left, bar, right) return msg def declare_chain(self, *k, **kw): """ Wraps :py:func:`waflib.TaskGen.declare_chain` for convenience """ return TaskGen.declare_chain(*k, **kw) def pre_build(self): """Executes user-defined methods before the build starts, see :py:meth:`waflib.Build.BuildContext.add_pre_fun`""" for m in getattr(self, 'pre_funs', []): m(self) def post_build(self): """Executes user-defined methods after the build is successful, see :py:meth:`waflib.Build.BuildContext.add_post_fun`""" for m in getattr(self, 'post_funs', []): m(self) def add_pre_fun(self, meth): """ Binds a callback method to execute after the scripts are read and before the build starts:: def mycallback(bld): print("Hello, world!") def build(bld): bld.add_pre_fun(mycallback) """ try: self.pre_funs.append(meth) except AttributeError: self.pre_funs = [meth] def add_post_fun(self, meth): """ Binds a callback method to execute immediately after the build is successful:: def call_ldconfig(bld): bld.exec_command('/sbin/ldconfig') def build(bld): if bld.cmd == 'install': bld.add_pre_fun(call_ldconfig) """ try: self.post_funs.append(meth) except AttributeError: self.post_funs = [meth] def get_group(self, x): """ Returns the build group named `x`, or the current group if `x` is None :param x: name or number or None :type x: string, int or None """ if not self.groups: self.add_group() if x is None: return self.groups[self.current_group] if x in self.group_names: return self.group_names[x] return self.groups[x] def add_to_group(self, tgen, group=None): """Adds a task or a task generator to the build; there is no attempt to remove it if it was already added.""" assert(isinstance(tgen, TaskGen.task_gen) or isinstance(tgen, Task.Task)) tgen.bld = self self.get_group(group).append(tgen) def get_group_name(self, g): """ Returns the name of the input build group :param g: build group object or build group index :type g: integer or list :return: name :rtype: string """ if not isinstance(g, list): g = self.groups[g] for x in self.group_names: if id(self.group_names[x]) == id(g): return x return '' def get_group_idx(self, tg): """ Returns the index of the group containing the task generator given as argument:: def build(bld): tg = bld(name='nada') 0 == bld.get_group_idx(tg) :param tg: Task generator object :type tg: :py:class:`waflib.TaskGen.task_gen` :rtype: int """ se = id(tg) for i, tmp in enumerate(self.groups): for t in tmp: if id(t) == se: return i return None def add_group(self, name=None, move=True): """ Adds a new group of tasks/task generators. By default the new group becomes the default group for new task generators (make sure to create build groups in order). :param name: name for this group :type name: string :param move: set this new group as default group (True by default) :type move: bool :raises: :py:class:`waflib.Errors.WafError` if a group by the name given already exists """ if name and name in self.group_names: raise Errors.WafError('add_group: name %s already present', name) g = [] self.group_names[name] = g self.groups.append(g) if move: self.current_group = len(self.groups) - 1 def set_group(self, idx): """ Sets the build group at position idx as current so that newly added task generators are added to this one by default:: def build(bld): bld(rule='touch ${TGT}', target='foo.txt') bld.add_group() # now the current group is 1 bld(rule='touch ${TGT}', target='bar.txt') bld.set_group(0) # now the current group is 0 bld(rule='touch ${TGT}', target='truc.txt') # build truc.txt before bar.txt :param idx: group name or group index :type idx: string or int """ if isinstance(idx, str): g = self.group_names[idx] for i, tmp in enumerate(self.groups): if id(g) == id(tmp): self.current_group = i break else: self.current_group = idx def total(self): """ Approximate task count: this value may be inaccurate if task generators are posted lazily (see :py:attr:`waflib.Build.BuildContext.post_mode`). The value :py:attr:`waflib.Runner.Parallel.total` is updated during the task execution. :rtype: int """ total = 0 for group in self.groups: for tg in group: try: total += len(tg.tasks) except AttributeError: total += 1 return total def get_targets(self): """ This method returns a pair containing the index of the last build group to post, and the list of task generator objects corresponding to the target names. This is used internally by :py:meth:`waflib.Build.BuildContext.get_build_iterator` to perform partial builds:: $ waf --targets=myprogram,myshlib :return: the minimum build group index, and list of task generators :rtype: tuple """ to_post = [] min_grp = 0 for name in self.targets.split(','): tg = self.get_tgen_by_name(name) m = self.get_group_idx(tg) if m > min_grp: min_grp = m to_post = [tg] elif m == min_grp: to_post.append(tg) return (min_grp, to_post) def get_all_task_gen(self): """ Returns a list of all task generators for troubleshooting purposes. """ lst = [] for g in self.groups: lst.extend(g) return lst def post_group(self): """ Post task generators from the group indexed by self.current_group; used internally by :py:meth:`waflib.Build.BuildContext.get_build_iterator` """ def tgpost(tg): try: f = tg.post except AttributeError: pass else: f() if self.targets == '*': for tg in self.groups[self.current_group]: tgpost(tg) elif self.targets: if self.current_group < self._min_grp: for tg in self.groups[self.current_group]: tgpost(tg) else: for tg in self._exact_tg: tg.post() else: ln = self.launch_node() if ln.is_child_of(self.bldnode): Logs.warn('Building from the build directory, forcing --targets=*') ln = self.srcnode elif not ln.is_child_of(self.srcnode): Logs.warn('CWD %s is not under %s, forcing --targets=* (run distclean?)', ln.abspath(), self.srcnode.abspath()) ln = self.srcnode def is_post(tg, ln): try: p = tg.path except AttributeError: pass else: if p.is_child_of(ln): return True def is_post_group(): for i, g in enumerate(self.groups): if i > self.current_group: for tg in g: if is_post(tg, ln): return True if self.post_mode == POST_LAZY and ln != self.srcnode: # partial folder builds require all targets from a previous build group if is_post_group(): ln = self.srcnode for tg in self.groups[self.current_group]: if is_post(tg, ln): tgpost(tg) def get_tasks_group(self, idx): """ Returns all task instances for the build group at position idx, used internally by :py:meth:`waflib.Build.BuildContext.get_build_iterator` :rtype: list of :py:class:`waflib.Task.Task` """ tasks = [] for tg in self.groups[idx]: try: tasks.extend(tg.tasks) except AttributeError: # not a task generator tasks.append(tg) return tasks def get_build_iterator(self): """ Creates a Python generator object that returns lists of tasks that may be processed in parallel. :return: tasks which can be executed immediately :rtype: generator returning lists of :py:class:`waflib.Task.Task` """ if self.targets and self.targets != '*': (self._min_grp, self._exact_tg) = self.get_targets() if self.post_mode != POST_LAZY: for self.current_group, _ in enumerate(self.groups): self.post_group() for self.current_group, _ in enumerate(self.groups): # first post the task generators for the group if self.post_mode != POST_AT_ONCE: self.post_group() # then extract the tasks tasks = self.get_tasks_group(self.current_group) # if the constraints are set properly (ext_in/ext_out, before/after) # the call to set_file_constraints may be removed (can be a 15% penalty on no-op rebuilds) # (but leave set_file_constraints for the installation step) # # if the tasks have only files, set_file_constraints is required but set_precedence_constraints is not necessary # Task.set_file_constraints(tasks) Task.set_precedence_constraints(tasks) self.cur_tasks = tasks if tasks: yield tasks while 1: # the build stops once there are no tasks to process yield [] def install_files(self, dest, files, **kw): """ Creates a task generator to install files on the system:: def build(bld): bld.install_files('${DATADIR}', self.path.find_resource('wscript')) :param dest: path representing the destination directory :type dest: :py:class:`waflib.Node.Node` or string (absolute path) :param files: input files :type files: list of strings or list of :py:class:`waflib.Node.Node` :param env: configuration set to expand *dest* :type env: :py:class:`waflib.ConfigSet.ConfigSet` :param relative_trick: preserve the folder hierarchy when installing whole folders :type relative_trick: bool :param cwd: parent node for searching srcfile, when srcfile is not an instance of :py:class:`waflib.Node.Node` :type cwd: :py:class:`waflib.Node.Node` :param postpone: execute the task immediately to perform the installation (False by default) :type postpone: bool """ assert(dest) tg = self(features='install_task', install_to=dest, install_from=files, **kw) tg.dest = tg.install_to tg.type = 'install_files' if not kw.get('postpone', True): tg.post() return tg def install_as(self, dest, srcfile, **kw): """ Creates a task generator to install a file on the system with a different name:: def build(bld): bld.install_as('${PREFIX}/bin', 'myapp', chmod=Utils.O755) :param dest: destination file :type dest: :py:class:`waflib.Node.Node` or string (absolute path) :param srcfile: input file :type srcfile: string or :py:class:`waflib.Node.Node` :param cwd: parent node for searching srcfile, when srcfile is not an instance of :py:class:`waflib.Node.Node` :type cwd: :py:class:`waflib.Node.Node` :param env: configuration set for performing substitutions in dest :type env: :py:class:`waflib.ConfigSet.ConfigSet` :param postpone: execute the task immediately to perform the installation (False by default) :type postpone: bool """ assert(dest) tg = self(features='install_task', install_to=dest, install_from=srcfile, **kw) tg.dest = tg.install_to tg.type = 'install_as' if not kw.get('postpone', True): tg.post() return tg def symlink_as(self, dest, src, **kw): """ Creates a task generator to install a symlink:: def build(bld): bld.symlink_as('${PREFIX}/lib/libfoo.so', 'libfoo.so.1.2.3') :param dest: absolute path of the symlink :type dest: :py:class:`waflib.Node.Node` or string (absolute path) :param src: link contents, which is a relative or absolute path which may exist or not :type src: string :param env: configuration set for performing substitutions in dest :type env: :py:class:`waflib.ConfigSet.ConfigSet` :param add: add the task created to a build group - set ``False`` only if the installation task is created after the build has started :type add: bool :param postpone: execute the task immediately to perform the installation :type postpone: bool :param relative_trick: make the symlink relative (default: ``False``) :type relative_trick: bool """ assert(dest) tg = self(features='install_task', install_to=dest, install_from=src, **kw) tg.dest = tg.install_to tg.type = 'symlink_as' tg.link = src # TODO if add: self.add_to_group(tsk) if not kw.get('postpone', True): tg.post() return tg @TaskGen.feature('install_task') @TaskGen.before_method('process_rule', 'process_source') def process_install_task(self): """Creates the installation task for the current task generator; uses :py:func:`waflib.Build.add_install_task` internally.""" self.add_install_task(**self.__dict__) @TaskGen.taskgen_method def add_install_task(self, **kw): """ Creates the installation task for the current task generator, and executes it immediately if necessary :returns: An installation task :rtype: :py:class:`waflib.Build.inst` """ if not self.bld.is_install: return if not kw['install_to']: return if kw['type'] == 'symlink_as' and Utils.is_win32: if kw.get('win32_install'): kw['type'] = 'install_as' else: # just exit return tsk = self.install_task = self.create_task('inst') tsk.chmod = kw.get('chmod', Utils.O644) tsk.link = kw.get('link', '') or kw.get('install_from', '') tsk.relative_trick = kw.get('relative_trick', False) tsk.type = kw['type'] tsk.install_to = tsk.dest = kw['install_to'] tsk.install_from = kw['install_from'] tsk.relative_base = kw.get('cwd') or kw.get('relative_base', self.path) tsk.install_user = kw.get('install_user') tsk.install_group = kw.get('install_group') tsk.init_files() if not kw.get('postpone', True): tsk.run_now() return tsk @TaskGen.taskgen_method def add_install_files(self, **kw): """ Creates an installation task for files :returns: An installation task :rtype: :py:class:`waflib.Build.inst` """ kw['type'] = 'install_files' return self.add_install_task(**kw) @TaskGen.taskgen_method def add_install_as(self, **kw): """ Creates an installation task for a single file :returns: An installation task :rtype: :py:class:`waflib.Build.inst` """ kw['type'] = 'install_as' return self.add_install_task(**kw) @TaskGen.taskgen_method def add_symlink_as(self, **kw): """ Creates an installation task for a symbolic link :returns: An installation task :rtype: :py:class:`waflib.Build.inst` """ kw['type'] = 'symlink_as' return self.add_install_task(**kw) class inst(Task.Task): """Task that installs files or symlinks; it is typically executed by :py:class:`waflib.Build.InstallContext` and :py:class:`waflib.Build.UnInstallContext`""" def __str__(self): """Returns an empty string to disable the standard task display""" return '' def uid(self): """Returns a unique identifier for the task""" lst = self.inputs + self.outputs + [self.link, self.generator.path.abspath()] return Utils.h_list(lst) def init_files(self): """ Initializes the task input and output nodes """ if self.type == 'symlink_as': inputs = [] else: inputs = self.generator.to_nodes(self.install_from) if self.type == 'install_as': assert len(inputs) == 1 self.set_inputs(inputs) dest = self.get_install_path() outputs = [] if self.type == 'symlink_as': if self.relative_trick: self.link = os.path.relpath(self.link, os.path.dirname(dest)) outputs.append(self.generator.bld.root.make_node(dest)) elif self.type == 'install_as': outputs.append(self.generator.bld.root.make_node(dest)) else: for y in inputs: if self.relative_trick: destfile = os.path.join(dest, y.path_from(self.relative_base)) else: destfile = os.path.join(dest, y.name) outputs.append(self.generator.bld.root.make_node(destfile)) self.set_outputs(outputs) def runnable_status(self): """ Installation tasks are always executed, so this method returns either :py:const:`waflib.Task.ASK_LATER` or :py:const:`waflib.Task.RUN_ME`. """ ret = super(inst, self).runnable_status() if ret == Task.SKIP_ME and self.generator.bld.is_install: return Task.RUN_ME return ret def post_run(self): """ Disables any post-run operations """ pass def get_install_path(self, destdir=True): """ Returns the destination path where files will be installed, pre-pending `destdir`. Relative paths will be interpreted relative to `PREFIX` if no `destdir` is given. :rtype: string """ if isinstance(self.install_to, Node.Node): dest = self.install_to.abspath() else: dest = os.path.normpath(Utils.subst_vars(self.install_to, self.env)) if not os.path.isabs(dest): dest = os.path.join(self.env.PREFIX, dest) if destdir and Options.options.destdir: dest = os.path.join(Options.options.destdir, os.path.splitdrive(dest)[1].lstrip(os.sep)) return dest def copy_fun(self, src, tgt): """ Copies a file from src to tgt, preserving permissions and trying to work around path limitations on Windows platforms. On Unix-like platforms, the owner/group of the target file may be set through install_user/install_group :param src: absolute path :type src: string :param tgt: absolute path :type tgt: string """ # override this if you want to strip executables # kw['tsk'].source is the task that created the files in the build if Utils.is_win32 and len(tgt) > 259 and not tgt.startswith('\\\\?\\'): tgt = '\\\\?\\' + tgt shutil.copy2(src, tgt) self.fix_perms(tgt) def rm_empty_dirs(self, tgt): """ Removes empty folders recursively when uninstalling. :param tgt: absolute path :type tgt: string """ while tgt: tgt = os.path.dirname(tgt) try: os.rmdir(tgt) except OSError: break def run(self): """ Performs file or symlink installation """ is_install = self.generator.bld.is_install if not is_install: # unnecessary? return for x in self.outputs: if is_install == INSTALL: x.parent.mkdir() if self.type == 'symlink_as': fun = is_install == INSTALL and self.do_link or self.do_unlink fun(self.link, self.outputs[0].abspath()) else: fun = is_install == INSTALL and self.do_install or self.do_uninstall launch_node = self.generator.bld.launch_node() for x, y in zip(self.inputs, self.outputs): fun(x.abspath(), y.abspath(), x.path_from(launch_node)) def run_now(self): """ Try executing the installation task right now :raises: :py:class:`waflib.Errors.TaskNotReady` """ status = self.runnable_status() if status not in (Task.RUN_ME, Task.SKIP_ME): raise Errors.TaskNotReady('Could not process %r: status %r' % (self, status)) self.run() self.hasrun = Task.SUCCESS def do_install(self, src, tgt, lbl, **kw): """ Copies a file from src to tgt with given file permissions. The actual copy is only performed if the source and target file sizes or timestamps differ. When the copy occurs, the file is always first removed and then copied so as to prevent stale inodes. :param src: file name as absolute path :type src: string :param tgt: file destination, as absolute path :type tgt: string :param lbl: file source description :type lbl: string :param chmod: installation mode :type chmod: int :raises: :py:class:`waflib.Errors.WafError` if the file cannot be written """ if not Options.options.force: # check if the file is already there to avoid a copy try: st1 = os.stat(tgt) st2 = os.stat(src) except OSError: pass else: # same size and identical timestamps -> make no copy if st1.st_mtime + 2 >= st2.st_mtime and st1.st_size == st2.st_size: if not self.generator.bld.progress_bar: Logs.info('- install %s (from %s)', tgt, lbl) return False if not self.generator.bld.progress_bar: Logs.info('+ install %s (from %s)', tgt, lbl) # Give best attempt at making destination overwritable, # like the 'install' utility used by 'make install' does. try: os.chmod(tgt, Utils.O644 | stat.S_IMODE(os.stat(tgt).st_mode)) except EnvironmentError: pass # following is for shared libs and stale inodes (-_-) try: os.remove(tgt) except OSError: pass try: self.copy_fun(src, tgt) except EnvironmentError as e: if not os.path.exists(src): Logs.error('File %r does not exist', src) elif not os.path.isfile(src): Logs.error('Input %r is not a file', src) raise Errors.WafError('Could not install the file %r' % tgt, e) def fix_perms(self, tgt): """ Change the ownership of the file/folder/link pointed by the given path This looks up for `install_user` or `install_group` attributes on the task or on the task generator:: def build(bld): bld.install_as('${PREFIX}/wscript', 'wscript', install_user='nobody', install_group='nogroup') bld.symlink_as('${PREFIX}/wscript_link', Utils.subst_vars('${PREFIX}/wscript', bld.env), install_user='nobody', install_group='nogroup') """ if not Utils.is_win32: user = getattr(self, 'install_user', None) or getattr(self.generator, 'install_user', None) group = getattr(self, 'install_group', None) or getattr(self.generator, 'install_group', None) if user or group: Utils.lchown(tgt, user or -1, group or -1) if not os.path.islink(tgt): os.chmod(tgt, self.chmod) def do_link(self, src, tgt, **kw): """ Creates a symlink from tgt to src. :param src: file name as absolute path :type src: string :param tgt: file destination, as absolute path :type tgt: string """ if os.path.islink(tgt) and os.readlink(tgt) == src: if not self.generator.bld.progress_bar: Logs.info('- symlink %s (to %s)', tgt, src) else: try: os.remove(tgt) except OSError: pass if not self.generator.bld.progress_bar: Logs.info('+ symlink %s (to %s)', tgt, src) os.symlink(src, tgt) self.fix_perms(tgt) def do_uninstall(self, src, tgt, lbl, **kw): """ See :py:meth:`waflib.Build.inst.do_install` """ if not self.generator.bld.progress_bar: Logs.info('- remove %s', tgt) #self.uninstall.append(tgt) try: os.remove(tgt) except OSError as e: if e.errno != errno.ENOENT: if not getattr(self, 'uninstall_error', None): self.uninstall_error = True Logs.warn('build: some files could not be uninstalled (retry with -vv to list them)') if Logs.verbose > 1: Logs.warn('Could not remove %s (error code %r)', e.filename, e.errno) self.rm_empty_dirs(tgt) def do_unlink(self, src, tgt, **kw): """ See :py:meth:`waflib.Build.inst.do_link` """ try: if not self.generator.bld.progress_bar: Logs.info('- remove %s', tgt) os.remove(tgt) except OSError: pass self.rm_empty_dirs(tgt) class InstallContext(BuildContext): '''installs the targets on the system''' cmd = 'install' def __init__(self, **kw): super(InstallContext, self).__init__(**kw) self.is_install = INSTALL class UninstallContext(InstallContext): '''removes the targets installed''' cmd = 'uninstall' def __init__(self, **kw): super(UninstallContext, self).__init__(**kw) self.is_install = UNINSTALL class CleanContext(BuildContext): '''cleans the project''' cmd = 'clean' def execute(self): """ See :py:func:`waflib.Build.BuildContext.execute`. """ self.restore() if not self.all_envs: self.load_envs() self.recurse([self.run_dir]) try: self.clean() finally: self.store() def clean(self): """ Remove most files from the build directory, and reset all caches. Custom lists of files to clean can be declared as `bld.clean_files`. For example, exclude `build/program/myprogram` from getting removed:: def build(bld): bld.clean_files = bld.bldnode.ant_glob('**', excl='.lock* config.log c4che/* config.h program/myprogram', quiet=True, generator=True) """ Logs.debug('build: clean called') if hasattr(self, 'clean_files'): for n in self.clean_files: n.delete() elif self.bldnode != self.srcnode: # would lead to a disaster if top == out lst = [] for env in self.all_envs.values(): lst.extend(self.root.find_or_declare(f) for f in env[CFG_FILES]) excluded_dirs = '.lock* *conf_check_*/** config.log %s/*' % CACHE_DIR for n in self.bldnode.ant_glob('**/*', excl=excluded_dirs, quiet=True): if n in lst: continue n.delete() self.root.children = {} for v in SAVED_ATTRS: if v == 'root': continue setattr(self, v, {}) class ListContext(BuildContext): '''lists the targets to execute''' cmd = 'list' def execute(self): """ In addition to printing the name of each build target, a description column will include text for each task generator which has a "description" field set. See :py:func:`waflib.Build.BuildContext.execute`. """ self.restore() if not self.all_envs: self.load_envs() self.recurse([self.run_dir]) self.pre_build() # display the time elapsed in the progress bar self.timer = Utils.Timer() for g in self.groups: for tg in g: try: f = tg.post except AttributeError: pass else: f() try: # force the cache initialization self.get_tgen_by_name('') except Errors.WafError: pass targets = sorted(self.task_gen_cache_names) # figure out how much to left-justify, for largest target name line_just = max(len(t) for t in targets) if targets else 0 for target in targets: tgen = self.task_gen_cache_names[target] # Support displaying the description for the target # if it was set on the tgen descript = getattr(tgen, 'description', '') if descript: target = target.ljust(line_just) descript = ': %s' % descript Logs.pprint('GREEN', target, label=descript) class StepContext(BuildContext): '''executes tasks in a step-by-step fashion, for debugging''' cmd = 'step' def __init__(self, **kw): super(StepContext, self).__init__(**kw) self.files = Options.options.files def compile(self): """ Overrides :py:meth:`waflib.Build.BuildContext.compile` to perform a partial build on tasks matching the input/output pattern given (regular expression matching):: $ waf step --files=foo.c,bar.c,in:truc.c,out:bar.o $ waf step --files=in:foo.cpp.1.o # link task only """ if not self.files: Logs.warn('Add a pattern for the debug build, for example "waf step --files=main.c,app"') BuildContext.compile(self) return targets = [] if self.targets and self.targets != '*': targets = self.targets.split(',') for g in self.groups: for tg in g: if targets and tg.name not in targets: continue try: f = tg.post except AttributeError: pass else: f() for pat in self.files.split(','): matcher = self.get_matcher(pat) for tg in g: if isinstance(tg, Task.Task): lst = [tg] else: lst = tg.tasks for tsk in lst: do_exec = False for node in tsk.inputs: if matcher(node, output=False): do_exec = True break for node in tsk.outputs: if matcher(node, output=True): do_exec = True break if do_exec: ret = tsk.run() Logs.info('%s -> exit %r', tsk, ret) def get_matcher(self, pat): """ Converts a step pattern into a function :param: pat: pattern of the form in:truc.c,out:bar.o :returns: Python function that uses Node objects as inputs and returns matches :rtype: function """ # this returns a function inn = True out = True if pat.startswith('in:'): out = False pat = pat.replace('in:', '') elif pat.startswith('out:'): inn = False pat = pat.replace('out:', '') anode = self.root.find_node(pat) pattern = None if not anode: if not pat.startswith('^'): pat = '^.+?%s' % pat if not pat.endswith('$'): pat = '%s$' % pat pattern = re.compile(pat) def match(node, output): if output and not out: return False if not output and not inn: return False if anode: return anode == node else: return pattern.match(node.abspath()) return match class EnvContext(BuildContext): """Subclass EnvContext to create commands that require configuration data in 'env'""" fun = cmd = None def execute(self): """ See :py:func:`waflib.Build.BuildContext.execute`. """ self.restore() if not self.all_envs: self.load_envs() self.recurse([self.run_dir])
1fc5307b3291a2b0e92303e64475cd3a710feca0
a47e4480d1584c5a2bb4c31ac512c864d0c2c240
/accounts/urls.py
42d5bde8efc177ff49bf52cb3041896c8e39f631
[ "MIT" ]
permissive
shaymk1/ke-nako-shop
014bd960e2048d4e2b5cc77c0b2d99f2058208d4
5c6f3dfb6b1e89efe111c1c6daa21434c7843ddc
refs/heads/main
2023-08-02T08:19:31.702068
2021-09-20T19:21:53
2021-09-20T19:21:53
406,715,370
0
0
null
null
null
null
UTF-8
Python
false
false
80
py
from django.urls import path from . import views urlpatterns = [ ]
72d0e3a9aa321c3bce22f15f1bc1f9a7979fafaa
3ee85c3a459ac04cb28da0a40dc50c88aaee7fd3
/src/python3/sdp/scripts/animation.py
d9e4d415957dc00f5311ae8318787f509e3d05fb
[ "Apache-2.0", "BSD-3-Clause" ]
permissive
LeiShi/Synthetic-Diagnostics-Platform
48b6f99da6f9a1c70cd1c1387745e76fbcee4ef4
870120d3fd14b2a3c89c6e6e85625d1e9109a2de
refs/heads/master
2021-03-30T17:36:13.497935
2020-04-11T23:45:43
2020-04-11T23:45:43
52,027,597
7
5
BSD-3-Clause
2018-04-09T22:50:08
2016-02-18T18:08:18
Python
UTF-8
Python
false
false
889
py
""" Short script providing simple animation creation functions """ import numpy as np import matplotlib.animation as anim import matplotlib.pyplot as plt class MovieMaker: """create 2D movie from data Inputs: data: 3-dimension ndarray, shape (NT,NY,NX), NT is the time steps, NY,NX the vertical and horizontal pixel number """ def __init__(self,data,interval=50,**im_para): self.data = data self.interval = interval self.frame = 0 self.fig = plt.figure() self.im = plt.imshow(data[0],**im_para) self.t_tag = self.fig.text(0.9,0.9,'t=0',ha = 'right',va='top') def updatefig(self,t): self.im.set_array(self.data[t]) self.t_tag.set_text('t={0}'.format(t)) def showmovie(self): ani = anim.FuncAnimation(self.fig,self.updatefig,interval = self.interval) plt.show()
7f8a1c183fc1bc1863fe7a285aad59a164b6bb76
fdb9bdc6c4ab2f14ba71e544493706d5e275899f
/fhir/resources/R4B/tests/test_enrollmentrequest.py
4470f6d2976fc1a82c1c5d502126c8e936f53030
[ "BSD-3-Clause" ]
permissive
nazrulworld/fhir.resources
6ae8aea8180c611b0c5050759c6dcdf63e4cb061
1fd6ea476b27b3fcb8c4ef8f23bc51cf161e69e3
refs/heads/main
2023-08-30T18:27:27.277249
2023-07-03T19:57:06
2023-07-03T19:57:06
165,297,877
256
83
NOASSERTION
2023-08-24T15:34:05
2019-01-11T19:26:41
Python
UTF-8
Python
false
false
1,958
py
# -*- coding: utf-8 -*- """ Profile: http://hl7.org/fhir/StructureDefinition/EnrollmentRequest Release: R4B Version: 4.3.0 Build ID: c475c22 Last updated: 2022-05-28T12:47:40.239+10:00 """ from pydantic.validators import bytes_validator # noqa: F401 from .. import fhirtypes # noqa: F401 from .. import enrollmentrequest def impl_enrollmentrequest_1(inst): assert inst.candidate.reference == "Patient/1" assert inst.coverage.reference == "Coverage/9876B1" assert inst.created == fhirtypes.DateTime.validate("2014-08-16") assert inst.id == "22345" assert inst.identifier[0].system == "http://happyvalley.com/enrollmentrequest" assert inst.identifier[0].value == "EN22345" assert inst.insurer.reference == "Organization/2" assert inst.meta.tag[0].code == "HTEST" assert inst.meta.tag[0].display == "test health data" assert ( inst.meta.tag[0].system == "http://terminology.hl7.org/CodeSystem/v3-ActReason" ) assert inst.provider.reference == "Organization/1" assert inst.status == "active" assert inst.text.div == ( '<div xmlns="http://www.w3.org/1999/xhtml">A human-readable' " rendering of the EnrollmentRequest.</div>" ) assert inst.text.status == "generated" def test_enrollmentrequest_1(base_settings): """No. 1 tests collection for EnrollmentRequest. Test File: enrollmentrequest-example.json """ filename = base_settings["unittest_data_dir"] / "enrollmentrequest-example.json" inst = enrollmentrequest.EnrollmentRequest.parse_file( filename, content_type="application/json", encoding="utf-8" ) assert "EnrollmentRequest" == inst.resource_type impl_enrollmentrequest_1(inst) # testing reverse by generating data from itself and create again. data = inst.dict() assert "EnrollmentRequest" == data["resourceType"] inst2 = enrollmentrequest.EnrollmentRequest(**data) impl_enrollmentrequest_1(inst2)
673687f08641540fd9ab5e89b4947b4216c2a265
f07a42f652f46106dee4749277d41c302e2b7406
/Data Set/bug-fixing-1/2c581ccde8187fbaad06bf1a57c4d61576a13386-<_meijerint_indefinite_1>-bug.py
1f2dc6ecd5e2843ba758fb7e0f266e0b13a1513c
[]
no_license
wsgan001/PyFPattern
e0fe06341cc5d51b3ad0fe29b84098d140ed54d1
cc347e32745f99c0cd95e79a18ddacc4574d7faa
refs/heads/main
2023-08-25T23:48:26.112133
2021-10-23T14:11:22
2021-10-23T14:11:22
null
0
0
null
null
null
null
UTF-8
Python
false
false
2,405
py
def _meijerint_indefinite_1(f, x): ' Helper that does not attempt any substitution. ' from sympy import Integral, piecewise_fold, nan, zoo _debug('Trying to compute the indefinite integral of', f, 'wrt', x) gs = _rewrite1(f, x) if (gs is None): return None (fac, po, gl, cond) = gs _debug(' could rewrite:', gs) res = S(0) for (C, s, g) in gl: (a, b) = _get_coeff_exp(g.argument, x) (_, c) = _get_coeff_exp(po, x) c += s fac_ = ((fac * C) / (b * (a ** ((1 + c) / b)))) rho = (((c + 1) / b) - 1) t = _dummy('t', 'meijerint-indefinite', S(1)) def tr(p): return [((a + rho) + 1) for a in p] if any(((b.is_integer and ((b <= 0) == True)) for b in tr(g.bm))): r = (- meijerg(tr(g.an), (tr(g.aother) + [1]), (tr(g.bm) + [0]), tr(g.bother), t)) else: r = meijerg((tr(g.an) + [1]), tr(g.aother), tr(g.bm), (tr(g.bother) + [0]), t) place = 0 if ((b < 0) or f.subs(x, 0).has(nan, zoo)): place = None r = hyperexpand(r.subs(t, (a * (x ** b))), place=place) res += powdenest((fac_ * r), polar=True) def _clean(res): "This multiplies out superfluous powers of x we created, and chops off\n constants:\n\n >> _clean(x*(exp(x)/x - 1/x) + 3)\n exp(x)\n\n cancel is used before mul_expand since it is possible for an\n expression to have an additive constant that doesn't become isolated\n with simple expansion. Such a situation was identified in issue 6369:\n\n\n >>> from sympy import sqrt, cancel\n >>> from sympy.abc import x\n >>> a = sqrt(2*x + 1)\n >>> bad = (3*x*a**5 + 2*x - a**5 + 1)/a**2\n >>> bad.expand().as_independent(x)[0]\n 0\n >>> cancel(bad).expand().as_independent(x)[0]\n 1\n " from sympy import cancel res = expand_mul(cancel(res), deep=False) return Add._from_args(res.as_coeff_add(x)[1]) res = piecewise_fold(res) if res.is_Piecewise: newargs = [] for (expr, cond) in res.args: expr = _my_unpolarify(_clean(expr)) newargs += [(expr, cond)] res = Piecewise(*newargs) else: res = _my_unpolarify(_clean(res)) return Piecewise((res, _my_unpolarify(cond)), (Integral(f, x), True))
1fe5a25fee8855277893c53410b7569c72bd622f
ce08ceeeb6a681db53c7dbd07398e885e4367f8c
/lunmap.py
b1509024b070bdfaeb7e00cc41587bba5fce23ab
[]
no_license
FengZiQ/cli
f4efb5caaeec5fae6b5abfdca0046316033413f7
49b14acb6bb04ecfc757918835e71397794f66c0
refs/heads/master
2021-09-07T14:52:11.143413
2018-02-24T08:20:57
2018-02-24T08:20:57
99,288,642
0
0
null
null
null
null
UTF-8
Python
false
false
3,901
py
# -*- coding = utf-8 -*- # 2018.01.23 from ssh_connect import ssh_conn from cli_test import * from remote import server import json from find_unconfigured_pd_id import find_pd_id data = 'data/lunmap.xlsx' def precondition(): try: clean_up_environment() pdId = find_pd_id() # create pool server.webapi('post', 'pool', {"name": "T_lunMap_P0", "pds": pdId[6:9], "raid_level": "raid5"}) # create volume and export it for i in range(3): server.webapi('post', 'volume', {'pool_id': 0, 'name': 'T_lunMap_V' + str(i), 'capacity': '100GB'}) server.webapi('post', 'volume/' + str(i) + '/export') # create snapshot and export it for i in range(3): server.webapi('post', 'snapshot', {"name": "T_lunMap_SS" + str(i), "type": 'volume', "source_id": 2}) server.webapi('post', 'snapshot/' + str(i) + '/export') # create clone and export it for i in range(3): server.webapi('post', 'clone', {"name": "T_lunMap_C" + str(i), "source_id": 2}) server.webapi('post', 'clone/' + str(i) + '/export') # create initiator for i in range(4): server.webapi('post', 'initiator', {'type': 'iSCSI', 'name': 'T.com' + str(i)}) server.webapi('post', 'initiator', {'type': 'fc', 'name': '00-11-22-33-00-00-11-1' + str(i)}) except: tolog("precondition is failed\r\n") return def clean_up_environment(): initiator_request = server.webapi('get', 'initiator') try: initiator_info = json.loads(initiator_request["text"]) for initiator in initiator_info: # delete all initiator server.webapi('delete', 'initiator/' + str(initiator['id'])) except: tolog("precondition is failed\r\n") return def enable_lmm(c): cli_setting = cli_test_setting() cli_setting.setting(c, data, 'enable_lmm') return cli_setting.FailFlag def add_lunmap(c): # precondition precondition() cli_setting = cli_test_setting() cli_setting.setting(c, data, 'add_lunmap') return cli_setting.FailFlag def addun_lunmap(c): cli_setting = cli_test_setting() cli_setting.setting(c, data, 'addun_lunmap') return cli_setting.FailFlag def list_lunmap(c): cli_list = cli_test_list() cli_list.list(c, data, 'list_lunmap') return cli_list.FailFlag def del_lunmap(c): cli_delete = cli_test_delete() cli_delete.delete(c, data, 'del_lunmap', 5) return cli_delete.FailFlag def dellun_lunmap(c): cli_delete = cli_test_delete() cli_delete.delete(c, data, 'dellun_lunmap') return cli_delete.FailFlag def disable_lmm(c): cli_setting = cli_test_setting() cli_setting.setting(c, data, 'disable_lmm') return cli_setting.FailFlag def invalid_setting_for_lunmap(c): cli_failed_test = cli_test_failed_test() cli_failed_test.failed_test(c, data, 'invalid_setting_for_lunmap') return cli_failed_test.FailFlag def invalid_option_for_lunmap(c): cli_failed_test = cli_test_failed_test() cli_failed_test.failed_test(c, data, 'invalid_option_for_lunmap') return cli_failed_test.FailFlag def missing_parameter_for_lunmap(c): cli_failed_test = cli_test_failed_test() cli_failed_test.failed_test(c, data, 'missing_parameter_for_lunmap') # clean up environment clean_up_environment() find_pd_id() return cli_failed_test.FailFlag if __name__ == "__main__": start = time.clock() c, ssh = ssh_conn() enable_lmm(c) add_lunmap(c) addun_lunmap(c) list_lunmap(c) del_lunmap(c) dellun_lunmap(c) disable_lmm(c) invalid_setting_for_lunmap(c) invalid_option_for_lunmap(c) missing_parameter_for_lunmap(c) ssh.close() elasped = time.clock() - start print "Elasped %s" % elasped
0fd640f856ffa0cc035d95776d7187fcc91031a4
1c7fa268ee031395806f38d52b6a7282ba5a4633
/hr_python/regex_parse/easy/DetectFloat.py
b2754c393f1d48d70ee773ddd148ef937800d8f8
[]
no_license
murugesan-narayan/hr_python
d2f562ecd2aa6c4eef4aab8363d5d040447ed727
86542342fc77cf7c95ebd08e5142186410f6385d
refs/heads/master
2022-04-12T14:59:16.293611
2020-03-24T14:25:30
2020-03-24T14:25:30
249,729,320
0
0
null
null
null
null
UTF-8
Python
false
false
152
py
import re if __name__ == '__main__': for i in range(int(input())): f = input() print(re.match(r"^[+-]?\d*\.\d+$", f) is not None)
b3733a246955de76c0490f84a680b6c786c3c7c3
1511782b2cc3dcf1f7e058e5046ec67a5561ba51
/2020/0310-0312_DP_gasshuku/abc007c.py
f12f7a270968711d5e8f016e556d2c6e22b48622
[]
no_license
keiouok/atcoder
7d8a053b0cf5b42e71e265450121d1ad686fee6d
9af301c6d63b0c2db60ac8af5bbe1431e14bb289
refs/heads/master
2021-09-07T11:48:55.953252
2021-07-31T15:29:50
2021-07-31T15:29:50
186,214,079
4
0
null
null
null
null
UTF-8
Python
false
false
1,447
py
import sys, re, os from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from itertools import permutations, combinations, product, accumulate from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_uppercase, digits from fractions import gcd def input(): return sys.stdin.readline().strip() def INT(): return int(input()) def MAP(): return map(int, input().split()) def S_MAP(): return map(str, input().split()) def LIST(): return list(map(int, input().split())) def S_LIST(): return list(map(str, input().split())) sys.setrecursionlimit(10 ** 9) INF = float('inf') mod = 10 ** 9 + 7 H, W = MAP() sy, sx = MAP() gy, gx = MAP() sy = sy - 1 sx = sx - 1 gy = gy - 1 gx = gx - 1 visited = [[False] * W for i in range(H)] C = [list(input()) for i in range(H)] dx = [-1, 0, 1, 0] dy = [0, 1, 0, -1] def bfs(): que = deque([(sy, sx)]) C[sy][sx] = 0 visited[sy][sx] = True while que: y, x = que.popleft() for i in range(4): nx = x + dx[i] ny = y + dy[i] if 0 <= nx < W and 0 <= ny < H and C[ny][nx] != "#" and visited[ny][nx] == False: C[ny][nx] = C[y][x] + 1 visited[ny][nx] = True que.append((ny, nx)) print(C[gy][gx]) if __name__ == "__main__": bfs()
d73ea65a3ef7e920759b7d60129d750bb29618ce
87dd9022421d5f23f815ca6d794af48c007579dc
/items/admin.py
afe7d4f0b45ead1a4305f077baf2f05e1e4e2b22
[]
no_license
iKenshu/todo-list
c94fc0558ef00625d9a59a45cbed7510947ff2b3
f115d4035b9f7fc82253388a51982637fcd98276
refs/heads/master
2020-03-19T18:37:21.852860
2018-06-19T13:13:36
2018-06-19T13:13:36
112,334,181
1
0
null
null
null
null
UTF-8
Python
false
false
256
py
from django.contrib import admin from .models import Item @admin.register(Item) class ItemAdmin(admin.ModelAdmin): list_display = ('name', 'description', 'pub_date') list_editable = ('description',) prepopulated_fields = {'slug': ('name',)}
4f86f318e0f21834f77d5873ea25905b86d87f12
d227fb26e33128afe868bef60e3042f7c6576643
/editor/Welder/src/Core/MapEditor/BrushPanels.py
c8b08cf9ca3a4fbf50aa695014c5d2459f9d58bb
[]
no_license
boisei0/arcreator
1e57b9cc61d5b38bfd0d62237592cfd9f371eca9
555739cafdeeed19d3c25c4948416a6ecb7697d5
refs/heads/master
2020-12-02T05:02:36.242572
2014-08-05T19:25:41
2014-08-05T19:25:41
22,642,617
1
0
null
null
null
null
UTF-8
Python
false
false
2,801
py
import wx from Boot import WelderImport Kernel = WelderImport('Kernel') Core = WelderImport('Core') KM = Kernel.Manager Panels = Core.Panels class TilesetPanel(wx.ScrolledWindow, Panels.PanelBase): _arc_panel_info_string = "Name Caption Left CloseB BestS MinimizeM Layer Row Pos MinimizeB DestroyOC" _arc_panel_info_data = { "Name": "Tileset", "Caption": "Tileset", "CloseB": False, "BestS": (32 * 8, 32 * 12), "MinimizeM": ["POS_SMART", "CAPT_SMART"], "Layer": 1, "Row": 1, "Pos": 1, "MinimizeB": True } def __init__(self, parent): wx.ScrolledWindow.__init__(self, parent, wx.ID_ANY) self.bindFocus() self.panel = wx.Panel(self, wx.ID_ANY) self.SetScrollbars(32, 32, 8, 50) class MapTreePanel(wx.Panel, Panels.PanelBase): _arc_panel_info_string = "Name Caption Left CloseB BestS MinimizeM Layer Row Pos MinimizeB IconARCM DestroyOC" _arc_panel_info_data = { "Name": "Maps", "Caption": "Maps", "CloseB": False, "BestS": (32 * 8, 32 * 4), "MinimizeM": ["POS_SMART", "CAPT_SMART"], "Layer": 1, "Row": 1, "Pos": 1, "MinimizeB": True, 'IconARCM': 'project_icon' } def __init__(self, parent, mapEditerPanel=None): wx.Panel.__init__(self, parent) self.mapEditerPanel = mapEditerPanel #set up Sizer box = wx.BoxSizer(wx.VERTICAL) #set up tree mapTreeCtrl = KM.get_component("MapTreeCtrl").object self.treectrl = mapTreeCtrl(self, -1, wx.Point(0, 0), wx.Size(160, 250), True) #add ctrls to sizer box.Add(self.treectrl, 1, wx.ALL | wx.EXPAND) #set sizer self.SetSizerAndFit(box) #bind events self.treectrl.Bind(wx.EVT_LEFT_DCLICK, self.TreeLeftDClick) def TreeLeftDClick(self, event): pt = event.GetPosition() item, flags = self.treectrl.HitTest(pt) if item: data = self.treectrl.GetItemData(item).GetData() if data: map_id, name = data project = Kernel.GlobalObjects.get_value("PROJECT") map_ = project.getMapData(map_id) tilesets = project.getData("Tilesets") if Kernel.GlobalObjects.has_key("PanelManager"): Kernel.GlobalObjects.get_value("PanelManager")\ .dispatch_panel("MapEditorPanel", "Map Editor Panel " + str(map_id), arguments=[map_, tilesets], info="Name Caption", data={"Name": "[" + str(map_id) + "] " + name, "Caption": "[" + str(map_id) + "] " + name}) event.Skip()
f2f9a5156fb3464632cd897c3b08dbc1fec13a43
e65a448da4f82d6e7c95cfadc5e8dfd06ed05c62
/cinder/cinder/tests/test_hp3par.py
93719067fa27f2e92d60f66b64880ea2faeb8bfb
[ "Apache-2.0" ]
permissive
bopopescu/devstack
7a9d11bcc37884f3686e7178ebc25c178a6da283
6b73b164af7e5895501f1ca5dafebbba90510846
refs/heads/master
2022-11-19T19:58:43.536574
2015-01-29T09:00:59
2015-01-29T09:00:59
282,101,378
0
0
null
2020-07-24T02:17:48
2020-07-24T02:17:47
null
UTF-8
Python
false
false
176,500
py
# # (c) Copyright 2013 Hewlett-Packard Development Company, L.P. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. """Unit tests for OpenStack Cinder volume drivers.""" import mock import ast from oslo.config import cfg from oslo.utils import units from cinder import context from cinder import exception from cinder.openstack.common import log as logging from cinder import test from cinder.tests import fake_hp_3par_client as hp3parclient from cinder.volume.drivers.san.hp import hp_3par_common as hpcommon from cinder.volume.drivers.san.hp import hp_3par_fc as hpfcdriver from cinder.volume.drivers.san.hp import hp_3par_iscsi as hpdriver from cinder.volume import qos_specs from cinder.volume import utils as volume_utils from cinder.volume import volume_types hpexceptions = hp3parclient.hpexceptions LOG = logging.getLogger(__name__) CONF = cfg.CONF HP3PAR_CPG = 'OpenStackCPG' HP3PAR_CPG2 = 'fakepool' HP3PAR_CPG_QOS = 'qospool' HP3PAR_CPG_SNAP = 'OpenStackCPGSnap' HP3PAR_USER_NAME = 'testUser' HP3PAR_USER_PASS = 'testPassword' HP3PAR_SAN_IP = '2.2.2.2' HP3PAR_SAN_SSH_PORT = 999 HP3PAR_SAN_SSH_CON_TIMEOUT = 44 HP3PAR_SAN_SSH_PRIVATE = 'foobar' CHAP_USER_KEY = "HPQ-cinder-CHAP-name" CHAP_PASS_KEY = "HPQ-cinder-CHAP-secret" class HP3PARBaseDriver(object): class CommentMatcher(object): def __init__(self, f, expect): self.assertEqual = f self.expect = expect def __eq__(self, actual): actual_as_dict = dict(ast.literal_eval(actual)) self.assertEqual(self.expect, actual_as_dict) return True VOLUME_ID = 'd03338a9-9115-48a3-8dfc-35cdfcdc15a7' CLONE_ID = 'd03338a9-9115-48a3-8dfc-000000000000' VOLUME_NAME = 'volume-' + VOLUME_ID VOLUME_NAME_3PAR = 'osv-0DM4qZEVSKON-DXN-NwVpw' SNAPSHOT_ID = '2f823bdc-e36e-4dc8-bd15-de1c7a28ff31' SNAPSHOT_NAME = 'snapshot-2f823bdc-e36e-4dc8-bd15-de1c7a28ff31' VOLUME_3PAR_NAME = 'osv-0DM4qZEVSKON-DXN-NwVpw' SNAPSHOT_3PAR_NAME = 'oss-L4I73ONuTci9Fd4ceij-MQ' FAKE_HOST = 'fakehost' USER_ID = '2689d9a913974c008b1d859013f23607' PROJECT_ID = 'fac88235b9d64685a3530f73e490348f' VOLUME_ID_SNAP = '761fc5e5-5191-4ec7-aeba-33e36de44156' FAKE_DESC = 'test description name' FAKE_FC_PORTS = [{'portPos': {'node': 7, 'slot': 1, 'cardPort': 1}, 'portWWN': '0987654321234', 'protocol': 1, 'mode': 2, 'linkState': 4}, {'portPos': {'node': 6, 'slot': 1, 'cardPort': 1}, 'portWWN': '123456789000987', 'protocol': 1, 'mode': 2, 'linkState': 4}] QOS = {'qos:maxIOPS': '1000', 'qos:maxBWS': '50', 'qos:minIOPS': '100', 'qos:minBWS': '25', 'qos:latency': '25', 'qos:priority': 'low'} QOS_SPECS = {'maxIOPS': '1000', 'maxBWS': '50', 'minIOPS': '100', 'minBWS': '25', 'latency': '25', 'priority': 'low'} VVS_NAME = "myvvs" FAKE_ISCSI_PORT = {'portPos': {'node': 8, 'slot': 1, 'cardPort': 1}, 'protocol': 2, 'mode': 2, 'IPAddr': '1.1.1.2', 'iSCSIName': ('iqn.2000-05.com.3pardata:' '21810002ac00383d'), 'linkState': 4} volume = {'name': VOLUME_NAME, 'id': VOLUME_ID, 'display_name': 'Foo Volume', 'size': 2, 'host': FAKE_HOST, 'volume_type': None, 'volume_type_id': None} volume_pool = {'name': VOLUME_NAME, 'id': VOLUME_ID, 'display_name': 'Foo Volume', 'size': 2, 'host': volume_utils.append_host(FAKE_HOST, HP3PAR_CPG2), 'volume_type': None, 'volume_type_id': None} volume_qos = {'name': VOLUME_NAME, 'id': VOLUME_ID, 'display_name': 'Foo Volume', 'size': 2, 'host': FAKE_HOST, 'volume_type': None, 'volume_type_id': 'gold'} snapshot = {'name': SNAPSHOT_NAME, 'id': SNAPSHOT_ID, 'user_id': USER_ID, 'project_id': PROJECT_ID, 'volume_id': VOLUME_ID_SNAP, 'volume_name': VOLUME_NAME, 'status': 'creating', 'progress': '0%', 'volume_size': 2, 'display_name': 'fakesnap', 'display_description': FAKE_DESC} wwn = ["123456789012345", "123456789054321"] connector = {'ip': '10.0.0.2', 'initiator': 'iqn.1993-08.org.debian:01:222', 'wwpns': [wwn[0], wwn[1]], 'wwnns': ["223456789012345", "223456789054321"], 'host': FAKE_HOST} volume_type = {'name': 'gold', 'deleted': False, 'updated_at': None, 'extra_specs': {'cpg': HP3PAR_CPG2, 'qos:maxIOPS': '1000', 'qos:maxBWS': '50', 'qos:minIOPS': '100', 'qos:minBWS': '25', 'qos:latency': '25', 'qos:priority': 'low'}, 'deleted_at': None, 'id': 'gold'} cpgs = [ {'SAGrowth': {'LDLayout': {'diskPatterns': [{'diskType': 2}]}, 'incrementMiB': 8192}, 'SAUsage': {'rawTotalMiB': 24576, 'rawUsedMiB': 768, 'totalMiB': 8192, 'usedMiB': 256}, 'SDGrowth': {'LDLayout': {'RAIDType': 4, 'diskPatterns': [{'diskType': 2}]}, 'incrementMiB': 32768}, 'SDUsage': {'rawTotalMiB': 49152, 'rawUsedMiB': 1023, 'totalMiB': 36864, 'usedMiB': 1024 * 1}, 'UsrUsage': {'rawTotalMiB': 57344, 'rawUsedMiB': 43349, 'totalMiB': 43008, 'usedMiB': 1024 * 20}, 'additionalStates': [], 'degradedStates': [], 'failedStates': [], 'id': 5, 'name': HP3PAR_CPG, 'numFPVVs': 2, 'numTPVVs': 0, 'state': 1, 'uuid': '29c214aa-62b9-41c8-b198-543f6cf24edf'}] TASK_DONE = 1 TASK_ACTIVE = 2 STATUS_DONE = {'status': 1} STATUS_ACTIVE = {'status': 2} mock_client_conf = { 'PORT_MODE_TARGET': 2, 'PORT_STATE_READY': 4, 'PORT_PROTO_ISCSI': 2, 'PORT_PROTO_FC': 1, 'TASK_DONE': TASK_DONE, 'TASK_ACTIVE': TASK_ACTIVE, 'HOST_EDIT_ADD': 1, 'CHAP_INITIATOR': 1, 'CHAP_TARGET': 2, 'getPorts.return_value': { 'members': FAKE_FC_PORTS + [FAKE_ISCSI_PORT] } } RETYPE_VVS_NAME = "yourvvs" RETYPE_HOST = { u'host': u'mark-stack1@3parfc', u'capabilities': { 'QoS_support': True, u'location_info': u'HP3PARDriver:1234567:MARK_TEST_CPG', u'timestamp': u'2014-06-04T19:03:32.485540', u'allocated_capacity_gb': 0, u'volume_backend_name': u'3parfc', u'free_capacity_gb': u'infinite', u'driver_version': u'2.0.3', u'total_capacity_gb': u'infinite', u'reserved_percentage': 0, u'vendor_name': u'Hewlett-Packard', u'storage_protocol': u'FC' } } RETYPE_HOST_NOT3PAR = { u'host': u'mark-stack1@3parfc', u'capabilities': { u'location_info': u'XXXDriverXXX:1610771:MARK_TEST_CPG', } } RETYPE_QOS_SPECS = {'maxIOPS': '1000', 'maxBWS': '50', 'minIOPS': '100', 'minBWS': '25', 'latency': '25', 'priority': 'high'} RETYPE_VOLUME_TYPE_ID = "FakeVolId" RETYPE_VOLUME_TYPE_0 = { 'name': 'red', 'id': RETYPE_VOLUME_TYPE_ID, 'extra_specs': { 'cpg': HP3PAR_CPG, 'snap_cpg': HP3PAR_CPG_SNAP, 'vvs': RETYPE_VVS_NAME, 'qos': RETYPE_QOS_SPECS, 'tpvv': True, 'volume_type': volume_type } } RETYPE_VOLUME_TYPE_1 = { 'name': 'white', 'id': RETYPE_VOLUME_TYPE_ID, 'extra_specs': { 'cpg': HP3PAR_CPG, 'snap_cpg': HP3PAR_CPG_SNAP, 'vvs': VVS_NAME, 'qos': QOS, 'tpvv': True, 'volume_type': volume_type } } RETYPE_VOLUME_TYPE_2 = { 'name': 'blue', 'id': RETYPE_VOLUME_TYPE_ID, 'extra_specs': { 'cpg': HP3PAR_CPG_QOS, 'snap_cpg': HP3PAR_CPG_SNAP, 'vvs': RETYPE_VVS_NAME, 'qos': RETYPE_QOS_SPECS, 'tpvv': True, 'volume_type': volume_type } } RETYPE_VOLUME_TYPE_BAD_PERSONA = { 'name': 'bad_persona', 'id': 'any_id', 'extra_specs': { 'hp3par:persona': '99 - invalid' } } RETYPE_VOLUME_TYPE_BAD_CPG = { 'name': 'bad_cpg', 'id': 'any_id', 'extra_specs': { 'cpg': 'bogus', 'snap_cpg': 'bogus', 'hp3par:persona': '2 - Generic-ALUA' } } MANAGE_VOLUME_INFO = { 'userCPG': 'testUserCpg0', 'snapCPG': 'testSnapCpg0', 'provisioningType': 1, 'comment': "{'display_name': 'Foo Volume'}" } RETYPE_TEST_COMMENT = "{'retype_test': 'test comment'}" RETYPE_VOLUME_INFO_0 = { 'name': VOLUME_NAME, 'id': VOLUME_ID, 'display_name': 'Retype Vol0', 'size': 1, 'host': RETYPE_HOST, 'userCPG': 'testUserCpg0', 'snapCPG': 'testSnapCpg0', 'provisioningType': 1, 'comment': RETYPE_TEST_COMMENT } RETYPE_TEST_COMMENT_1 = "{'retype_test': 'test comment 1'}" RETYPE_VOLUME_INFO_1 = { 'name': VOLUME_NAME, 'id': VOLUME_ID, 'display_name': 'Retype Vol1', 'size': 1, 'host': RETYPE_HOST, 'userCPG': HP3PAR_CPG, 'snapCPG': HP3PAR_CPG_SNAP, 'provisioningType': 1, 'comment': RETYPE_TEST_COMMENT } # Test for when we don't get a snapCPG. RETYPE_VOLUME_INFO_NO_SNAP = { 'name': VOLUME_NAME, 'id': VOLUME_ID, 'display_name': 'Retype Vol2', 'size': 1, 'host': RETYPE_HOST, 'userCPG': 'testUserCpg2', 'provisioningType': 1, 'comment': '{}' } RETYPE_CONF = { 'TASK_ACTIVE': TASK_ACTIVE, 'TASK_DONE': TASK_DONE, 'getTask.return_value': STATUS_DONE, 'getStorageSystemInfo.return_value': {'serialNumber': '1234567'}, 'getVolume.return_value': RETYPE_VOLUME_INFO_0, 'modifyVolume.return_value': ("anyResponse", {'taskid': 1}) } # 3PAR retype currently doesn't use the diff. Existing code and fresh info # from the array work better for the most part. Some use of the diff was # intentionally removed to make _retype more usable for other use cases. RETYPE_DIFF = None standard_login = [ mock.call.login(HP3PAR_USER_NAME, HP3PAR_USER_PASS), mock.call.setSSHOptions( HP3PAR_SAN_IP, HP3PAR_USER_NAME, HP3PAR_USER_PASS, missing_key_policy='AutoAddPolicy', privatekey=HP3PAR_SAN_SSH_PRIVATE, known_hosts_file=mock.ANY, port=HP3PAR_SAN_SSH_PORT, conn_timeout=HP3PAR_SAN_SSH_CON_TIMEOUT)] standard_logout = [ mock.call.logout()] def setup_configuration(self): configuration = mock.Mock() configuration.hp3par_debug = False configuration.hp3par_username = HP3PAR_USER_NAME configuration.hp3par_password = HP3PAR_USER_PASS configuration.hp3par_api_url = 'https://1.1.1.1/api/v1' configuration.hp3par_cpg = [HP3PAR_CPG, HP3PAR_CPG2] configuration.hp3par_cpg_snap = HP3PAR_CPG_SNAP configuration.iscsi_ip_address = '1.1.1.2' configuration.iscsi_port = '1234' configuration.san_ip = HP3PAR_SAN_IP configuration.san_login = HP3PAR_USER_NAME configuration.san_password = HP3PAR_USER_PASS configuration.san_ssh_port = HP3PAR_SAN_SSH_PORT configuration.ssh_conn_timeout = HP3PAR_SAN_SSH_CON_TIMEOUT configuration.san_private_key = HP3PAR_SAN_SSH_PRIVATE configuration.hp3par_snapshot_expiration = "" configuration.hp3par_snapshot_retention = "" configuration.hp3par_iscsi_ips = [] configuration.hp3par_iscsi_chap_enabled = False return configuration @mock.patch( 'hp3parclient.client.HP3ParClient', spec=True, ) def setup_mock_client(self, _m_client, driver, conf=None, m_conf=None): _m_client = _m_client.return_value # Configure the base constants, defaults etc... _m_client.configure_mock(**self.mock_client_conf) # If m_conf, drop those over the top of the base_conf. if m_conf is not None: _m_client.configure_mock(**m_conf) if conf is None: conf = self.setup_configuration() self.driver = driver(configuration=conf) self.driver.do_setup(None) return _m_client @mock.patch('hp3parclient.version', "3.0.9") def test_unsupported_client_version(self): self.assertRaises(exception.InvalidInput, self.setup_driver) @mock.patch('hp3parclient.version', "3.1.2") def test_ssh_options(self): expected_hosts_key_file = "test_hosts_key_file" orig_ssh_hosts_key_file = CONF.ssh_hosts_key_file orig_strict_ssh_host_key_policy = CONF.strict_ssh_host_key_policy CONF.ssh_hosts_key_file = expected_hosts_key_file CONF.strict_ssh_host_key_policy = False self.ctxt = context.get_admin_context() mock_client = self.setup_mock_client(driver=hpfcdriver.HP3PARFCDriver) CONF.ssh_hosts_key_file = orig_ssh_hosts_key_file CONF.strict_ssh_host_key_policy = orig_strict_ssh_host_key_policy expected = [ mock.call.login(HP3PAR_USER_NAME, HP3PAR_USER_PASS), mock.call.setSSHOptions( HP3PAR_SAN_IP, HP3PAR_USER_NAME, HP3PAR_USER_PASS, privatekey=HP3PAR_SAN_SSH_PRIVATE, known_hosts_file=expected_hosts_key_file, missing_key_policy="AutoAddPolicy", port=HP3PAR_SAN_SSH_PORT, conn_timeout=HP3PAR_SAN_SSH_CON_TIMEOUT), mock.call.getCPG(HP3PAR_CPG), mock.call.getCPG(HP3PAR_CPG2)] mock_client.assert_has_calls( expected + self.standard_logout) @mock.patch('hp3parclient.version', "3.1.2") def test_ssh_options_strict(self): expected_hosts_key_file = "test_hosts_key_file" orig_ssh_hosts_key_file = CONF.ssh_hosts_key_file orig_strict_ssh_host_key_policy = CONF.strict_ssh_host_key_policy CONF.ssh_hosts_key_file = expected_hosts_key_file CONF.strict_ssh_host_key_policy = True self.ctxt = context.get_admin_context() mock_client = self.setup_mock_client(driver=hpfcdriver.HP3PARFCDriver) CONF.ssh_hosts_key_file = orig_ssh_hosts_key_file CONF.strict_ssh_host_key_policy = orig_strict_ssh_host_key_policy expected = [ mock.call.login(HP3PAR_USER_NAME, HP3PAR_USER_PASS), mock.call.setSSHOptions( HP3PAR_SAN_IP, HP3PAR_USER_NAME, HP3PAR_USER_PASS, privatekey=HP3PAR_SAN_SSH_PRIVATE, known_hosts_file=expected_hosts_key_file, missing_key_policy="RejectPolicy", port=HP3PAR_SAN_SSH_PORT, conn_timeout=HP3PAR_SAN_SSH_CON_TIMEOUT), mock.call.getCPG(HP3PAR_CPG), mock.call.getCPG(HP3PAR_CPG2)] mock_client.assert_has_calls(expected + self.standard_logout) def test_task_waiter(self): task_statuses = [self.STATUS_ACTIVE, self.STATUS_ACTIVE] def side_effect(*args): return task_statuses and task_statuses.pop(0) or self.STATUS_DONE conf = {'getTask.side_effect': side_effect} mock_client = self.setup_driver(mock_conf=conf) task_id = 1234 interval = .001 with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() waiter = common.TaskWaiter(mock_client, task_id, interval) status = waiter.wait_for_task() expected = [ mock.call.getTask(task_id), mock.call.getTask(task_id), mock.call.getTask(task_id) ] mock_client.assert_has_calls(expected) self.assertEqual(status, self.STATUS_DONE) def test_create_volume(self): # setup_mock_client drive with default configuration # and return the mock HTTP 3PAR client mock_client = self.setup_driver() with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client self.driver.create_volume(self.volume) comment = ( '{"display_name": "Foo Volume", "type": "OpenStack",' ' "name": "volume-d03338a9-9115-48a3-8dfc-35cdfcdc15a7",' ' "volume_id": "d03338a9-9115-48a3-8dfc-35cdfcdc15a7"}') expected = [ mock.call.createVolume( self.VOLUME_3PAR_NAME, HP3PAR_CPG, 1907, { 'comment': comment, 'tpvv': True, 'snapCPG': HP3PAR_CPG_SNAP})] mock_client.assert_has_calls( self.standard_login + expected + self.standard_logout) def test_create_volume_in_pool(self): # setup_mock_client drive with default configuration # and return the mock HTTP 3PAR client mock_client = self.setup_driver() with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client return_model = self.driver.create_volume(self.volume_pool) comment = ( '{"display_name": "Foo Volume", "type": "OpenStack",' ' "name": "volume-d03338a9-9115-48a3-8dfc-35cdfcdc15a7",' ' "volume_id": "d03338a9-9115-48a3-8dfc-35cdfcdc15a7"}') expected = [ mock.call.createVolume( self.VOLUME_3PAR_NAME, HP3PAR_CPG2, 1907, { 'comment': comment, 'tpvv': True, 'snapCPG': HP3PAR_CPG_SNAP})] mock_client.assert_has_calls( self.standard_login + expected + self.standard_logout) self.assertEqual(return_model, None) @mock.patch.object(volume_types, 'get_volume_type') def test_get_snap_cpg_from_volume_type(self, _mock_volume_types): mock_client = self.setup_driver() expected_type_snap_cpg = "type_snap_cpg" _mock_volume_types.return_value = { 'name': 'gold', 'extra_specs': { 'cpg': HP3PAR_CPG, 'snap_cpg': expected_type_snap_cpg, 'volume_type': self.volume_type}} with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() result = common.get_volume_settings_from_type_id( "mock", self.driver.configuration.hp3par_cpg) self.assertEqual(expected_type_snap_cpg, result['snap_cpg']) @mock.patch.object(volume_types, 'get_volume_type') def test_get_snap_cpg_from_volume_type_cpg(self, _mock_volume_types): mock_client = self.setup_driver() expected_cpg = 'use_extra_specs_cpg' _mock_volume_types.return_value = { 'name': 'gold', 'extra_specs': { 'cpg': expected_cpg, 'volume_type': self.volume_type}} with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() result = common.get_volume_settings_from_type_id( "mock", self.driver.configuration.hp3par_cpg) self.assertEqual(expected_cpg, result['snap_cpg']) @mock.patch.object(volume_types, 'get_volume_type') def test_get_snap_cpg_from_volume_type_conf_snap_cpg( self, _mock_volume_types): _mock_volume_types.return_value = { 'name': 'gold', 'extra_specs': { 'volume_type': self.volume_type}} conf = self.setup_configuration() expected_snap_cpg = conf.hp3par_cpg_snap mock_client = self.setup_driver(config=conf) with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() result = common.get_volume_settings_from_type_id( "mock", self.driver.configuration.hp3par_cpg) self.assertEqual(expected_snap_cpg, result['snap_cpg']) @mock.patch.object(volume_types, 'get_volume_type') def test_get_snap_cpg_from_volume_type_conf_cpg( self, _mock_volume_types): _mock_volume_types.return_value = { 'name': 'gold', 'extra_specs': { 'volume_type': self.volume_type}} conf = self.setup_configuration() conf.hp3par_cpg_snap = None expected_cpg = conf.hp3par_cpg mock_client = self.setup_driver(config=conf) with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() result = common.get_volume_settings_from_type_id( "mock", self.driver.configuration.hp3par_cpg) self.assertEqual(expected_cpg, result['snap_cpg']) @mock.patch.object(volume_types, 'get_volume_type') def test_create_volume_qos(self, _mock_volume_types): # setup_mock_client drive with default configuration # and return the mock HTTP 3PAR client mock_client = self.setup_driver() _mock_volume_types.return_value = { 'name': 'gold', 'extra_specs': { 'cpg': HP3PAR_CPG_QOS, 'snap_cpg': HP3PAR_CPG_SNAP, 'vvs_name': self.VVS_NAME, 'qos': self.QOS, 'tpvv': True, 'volume_type': self.volume_type}} with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client return_model = self.driver.create_volume(self.volume_qos) comment = ( '{"volume_type_name": "gold", "display_name": "Foo Volume"' ', "name": "volume-d03338a9-9115-48a3-8dfc-35cdfcdc15a7' '", "volume_type_id": "gold", "volume_id": "d03338a9-91' '15-48a3-8dfc-35cdfcdc15a7", "qos": {}, "type": "OpenStack"}') expected = [ mock.call.getCPG(HP3PAR_CPG_QOS), mock.call.createVolume( self.VOLUME_3PAR_NAME, HP3PAR_CPG_QOS, 1907, { 'comment': comment, 'tpvv': True, 'snapCPG': HP3PAR_CPG_SNAP})] mock_client.assert_has_calls( self.standard_login + expected + self.standard_logout) self.assertEqual(return_model, {'host': volume_utils.append_host( self.FAKE_HOST, HP3PAR_CPG_QOS)}) @mock.patch.object(volume_types, 'get_volume_type') def test_retype_not_3par(self, _mock_volume_types): _mock_volume_types.return_value = self.RETYPE_VOLUME_TYPE_1 mock_client = self.setup_driver(mock_conf=self.RETYPE_CONF) with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client self.assertRaises(exception.InvalidHost, self.driver.retype, self.ctxt, self.RETYPE_VOLUME_INFO_0, self.RETYPE_VOLUME_TYPE_1, self.RETYPE_DIFF, self.RETYPE_HOST_NOT3PAR) expected = [mock.call.getVolume(self.VOLUME_3PAR_NAME)] mock_client.assert_has_calls( self.standard_login + expected + self.standard_logout) @mock.patch.object(volume_types, 'get_volume_type') def test_retype_volume_not_found(self, _mock_volume_types): _mock_volume_types.return_value = self.RETYPE_VOLUME_TYPE_1 mock_client = self.setup_driver(mock_conf=self.RETYPE_CONF) mock_client.getVolume.side_effect = hpexceptions.HTTPNotFound with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client self.assertRaises(hpexceptions.HTTPNotFound, self.driver.retype, self.ctxt, self.RETYPE_VOLUME_INFO_0, self.RETYPE_VOLUME_TYPE_1, self.RETYPE_DIFF, self.RETYPE_HOST) expected = [mock.call.getVolume(self.VOLUME_3PAR_NAME)] mock_client.assert_has_calls( self.standard_login + expected + self.standard_logout) @mock.patch.object(volume_types, 'get_volume_type') def test_retype_specs_error_reverts_snap_cpg(self, _mock_volume_types): _mock_volume_types.side_effect = [ self.RETYPE_VOLUME_TYPE_1, self.RETYPE_VOLUME_TYPE_0] mock_client = self.setup_driver(mock_conf=self.RETYPE_CONF) mock_client.getVolume.return_value = self.RETYPE_VOLUME_INFO_0 # Fail the QOS setting to test the revert of the snap CPG rename. mock_client.addVolumeToVolumeSet.side_effect = \ hpexceptions.HTTPForbidden with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client self.assertRaises(hpexceptions.HTTPForbidden, self.driver.retype, self.ctxt, {'id': self.VOLUME_ID}, self.RETYPE_VOLUME_TYPE_0, self.RETYPE_DIFF, self.RETYPE_HOST) old_settings = { 'snapCPG': self.RETYPE_VOLUME_INFO_0['snapCPG'], 'comment': self.RETYPE_VOLUME_INFO_0['comment']} new_settings = { 'snapCPG': ( self.RETYPE_VOLUME_TYPE_1['extra_specs']['snap_cpg']), 'comment': mock.ANY} expected = [ mock.call.modifyVolume(self.VOLUME_3PAR_NAME, new_settings) ] mock_client.assert_has_calls(expected) expected = [ mock.call.modifyVolume(self.VOLUME_3PAR_NAME, old_settings) ] mock_client.assert_has_calls(expected + self.standard_logout) @mock.patch.object(volume_types, 'get_volume_type') def test_retype_revert_comment(self, _mock_volume_types): _mock_volume_types.side_effect = [ self.RETYPE_VOLUME_TYPE_2, self.RETYPE_VOLUME_TYPE_1] mock_client = self.setup_driver(mock_conf=self.RETYPE_CONF) mock_client.getVolume.return_value = self.RETYPE_VOLUME_INFO_1 # Fail the QOS setting to test the revert of the snap CPG rename. mock_client.deleteVolumeSet.side_effect = hpexceptions.HTTPForbidden with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client self.assertRaises(hpexceptions.HTTPForbidden, self.driver.retype, self.ctxt, {'id': self.VOLUME_ID}, self.RETYPE_VOLUME_TYPE_2, self.RETYPE_DIFF, self.RETYPE_HOST) original = { 'snapCPG': self.RETYPE_VOLUME_INFO_1['snapCPG'], 'comment': self.RETYPE_VOLUME_INFO_1['comment']} expected = [ mock.call.modifyVolume('osv-0DM4qZEVSKON-DXN-NwVpw', original)] mock_client.assert_has_calls(expected + self.standard_logout) @mock.patch.object(volume_types, 'get_volume_type') def test_retype_different_array(self, _mock_volume_types): _mock_volume_types.return_value = self.RETYPE_VOLUME_TYPE_1 mock_client = self.setup_driver(mock_conf=self.RETYPE_CONF) mock_client.getStorageSystemInfo.return_value = { 'serialNumber': 'XXXXXXX'} with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client self.assertRaises(exception.InvalidHost, self.driver.retype, self.ctxt, self.RETYPE_VOLUME_INFO_0, self.RETYPE_VOLUME_TYPE_1, self.RETYPE_DIFF, self.RETYPE_HOST) expected = [ mock.call.getVolume(self.VOLUME_3PAR_NAME), mock.call.getStorageSystemInfo()] mock_client.assert_has_calls( self.standard_login + expected + self.standard_logout) @mock.patch.object(volume_types, 'get_volume_type') def test_retype_across_cpg_domains(self, _mock_volume_types): _mock_volume_types.return_value = self.RETYPE_VOLUME_TYPE_1 mock_client = self.setup_driver(mock_conf=self.RETYPE_CONF) mock_client.getCPG.side_effect = [ {'domain': 'domain1'}, {'domain': 'domain2'}, ] with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client self.assertRaises(exception.Invalid3PARDomain, self.driver.retype, self.ctxt, self.RETYPE_VOLUME_INFO_0, self.RETYPE_VOLUME_TYPE_1, self.RETYPE_DIFF, self.RETYPE_HOST) expected = [ mock.call.getVolume(self.VOLUME_3PAR_NAME), mock.call.getStorageSystemInfo(), mock.call.getCPG(self.RETYPE_VOLUME_INFO_0['userCPG']), mock.call.getCPG( self.RETYPE_VOLUME_TYPE_1['extra_specs']['cpg']) ] mock_client.assert_has_calls( self.standard_login + expected + self.standard_logout) @mock.patch.object(volume_types, 'get_volume_type') def test_retype_across_snap_cpg_domains(self, _mock_volume_types): _mock_volume_types.return_value = self.RETYPE_VOLUME_TYPE_1 mock_client = self.setup_driver(mock_conf=self.RETYPE_CONF) mock_client.getCPG.side_effect = [ {'domain': 'cpg_domain'}, {'domain': 'cpg_domain'}, {'domain': 'snap_cpg_domain_1'}, ] with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client self.assertRaises(exception.Invalid3PARDomain, self.driver.retype, self.ctxt, self.RETYPE_VOLUME_INFO_0, self.RETYPE_VOLUME_TYPE_1, self.RETYPE_DIFF, self.RETYPE_HOST) expected = [ mock.call.getVolume(self.VOLUME_3PAR_NAME), mock.call.getStorageSystemInfo(), mock.call.getCPG(self.RETYPE_VOLUME_INFO_0['userCPG']), mock.call.getCPG( self.RETYPE_VOLUME_TYPE_1['extra_specs']['cpg']), mock.call.getCPG( self.RETYPE_VOLUME_TYPE_1['extra_specs']['snap_cpg']) ] mock_client.assert_has_calls( self.standard_login + expected + self.standard_logout) @mock.patch.object(volume_types, 'get_volume_type') def test_retype_to_bad_persona(self, _mock_volume_types): _mock_volume_types.return_value = self.RETYPE_VOLUME_TYPE_BAD_PERSONA mock_client = self.setup_driver(mock_conf=self.RETYPE_CONF) with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client self.assertRaises(exception.InvalidInput, self.driver.retype, self.ctxt, self.RETYPE_VOLUME_INFO_0, self.RETYPE_VOLUME_TYPE_BAD_PERSONA, self.RETYPE_DIFF, self.RETYPE_HOST) expected = [mock.call.getVolume(self.VOLUME_3PAR_NAME)] mock_client.assert_has_calls( self.standard_login + expected + self.standard_logout) @mock.patch.object(volume_types, 'get_volume_type') def test_retype_to_bad_cpg(self, _mock_volume_types): _mock_volume_types.return_value = self.RETYPE_VOLUME_TYPE_BAD_CPG mock_client = self.setup_driver(mock_conf=self.RETYPE_CONF) mock_client.getCPG.side_effect = hpexceptions.HTTPNotFound with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client self.assertRaises(exception.InvalidInput, self.driver.retype, self.ctxt, self.RETYPE_VOLUME_INFO_0, self.RETYPE_VOLUME_TYPE_BAD_CPG, self.RETYPE_DIFF, self.RETYPE_HOST) expected = [ mock.call.getCPG( self.RETYPE_VOLUME_TYPE_BAD_CPG['extra_specs']['cpg']) ] mock_client.assert_has_calls( self.standard_login + expected + self.standard_logout) @mock.patch.object(volume_types, 'get_volume_type') def test_retype_tune(self, _mock_volume_types): _mock_volume_types.return_value = self.RETYPE_VOLUME_TYPE_1 mock_client = self.setup_driver(mock_conf=self.RETYPE_CONF) qos_ref = qos_specs.create(self.ctxt, 'qos-specs-1', self.QOS) type_ref = volume_types.create(self.ctxt, "type1", {"qos:maxIOPS": "100", "qos:maxBWS": "50", "qos:minIOPS": "10", "qos:minBWS": "20", "qos:latency": "5", "qos:priority": "high"}) qos_specs.associate_qos_with_type(self.ctxt, qos_ref['id'], type_ref['id']) type_ref = volume_types.get_volume_type(self.ctxt, type_ref['id']) volume = {'id': HP3PARBaseDriver.CLONE_ID} with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client retyped = self.driver.retype( self.ctxt, volume, type_ref, None, self.RETYPE_HOST) self.assertTrue(retyped) expected = [ mock.call.modifyVolume('osv-0DM4qZEVSKON-AAAAAAAAA', {'comment': mock.ANY, 'snapCPG': 'OpenStackCPGSnap'}), mock.call.deleteVolumeSet('vvs-0DM4qZEVSKON-AAAAAAAAA'), mock.call.addVolumeToVolumeSet('myvvs', 'osv-0DM4qZEVSKON-AAAAAAAAA'), mock.call.modifyVolume('osv-0DM4qZEVSKON-AAAAAAAAA', {'action': 6, 'userCPG': 'OpenStackCPG', 'conversionOperation': 1, 'tuneOperation': 1}), mock.call.getTask(1) ] mock_client.assert_has_calls(expected + self.standard_logout) @mock.patch.object(volume_types, 'get_volume_type') def test_retype_qos_spec(self, _mock_volume_types): _mock_volume_types.return_value = self.RETYPE_VOLUME_TYPE_1 mock_client = self.setup_driver(mock_conf=self.RETYPE_CONF) cpg = "any_cpg" snap_cpg = "any_cpg" with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() common._retype(self.volume, HP3PARBaseDriver.VOLUME_3PAR_NAME, "old_type", "old_type_id", HP3PARBaseDriver.RETYPE_HOST, None, cpg, cpg, snap_cpg, snap_cpg, True, True, None, None, self.QOS_SPECS, self.RETYPE_QOS_SPECS, "{}") expected = [ mock.call.createVolumeSet('vvs-0DM4qZEVSKON-DXN-NwVpw', None), mock.call.createQoSRules( 'vvs-0DM4qZEVSKON-DXN-NwVpw', {'ioMinGoal': 100, 'ioMaxLimit': 1000, 'bwMinGoalKB': 25600, 'bwMaxLimitKB': 51200, 'priority': 3, 'latencyGoal': 25} ), mock.call.addVolumeToVolumeSet( 'vvs-0DM4qZEVSKON-DXN-NwVpw', 'osv-0DM4qZEVSKON-DXN-NwVpw')] mock_client.assert_has_calls(expected) def test_delete_volume(self): # setup_mock_client drive with default configuration # and return the mock HTTP 3PAR client mock_client = self.setup_driver() with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client self.driver.delete_volume(self.volume) expected = [mock.call.deleteVolume(self.VOLUME_3PAR_NAME)] mock_client.assert_has_calls( self.standard_login + expected + self.standard_logout) def test_create_cloned_volume(self): # setup_mock_client drive with default configuration # and return the mock HTTP 3PAR client mock_client = self.setup_driver() mock_client.copyVolume.return_value = {'taskid': 1} with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client volume = {'name': HP3PARBaseDriver.VOLUME_NAME, 'id': HP3PARBaseDriver.CLONE_ID, 'display_name': 'Foo Volume', 'size': 2, 'host': volume_utils.append_host(self.FAKE_HOST, HP3PAR_CPG2), 'source_volid': HP3PARBaseDriver.VOLUME_ID} src_vref = {} model_update = self.driver.create_cloned_volume(volume, src_vref) self.assertIsNone(model_update) expected = [ mock.call.copyVolume( self.VOLUME_3PAR_NAME, 'osv-0DM4qZEVSKON-AAAAAAAAA', HP3PAR_CPG2, {'snapCPG': 'OpenStackCPGSnap', 'tpvv': True, 'online': True})] mock_client.assert_has_calls( self.standard_login + expected + self.standard_logout) @mock.patch.object(volume_types, 'get_volume_type') def test_create_cloned_qos_volume(self, _mock_volume_types): _mock_volume_types.return_value = self.RETYPE_VOLUME_TYPE_2 mock_client = self.setup_driver() mock_client.copyVolume.return_value = {'taskid': 1} with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client src_vref = {} volume = self.volume_qos.copy() host = "TEST_HOST" pool = "TEST_POOL" volume_host = volume_utils.append_host(host, pool) expected_cpg = self.RETYPE_VOLUME_TYPE_2['extra_specs']['cpg'] expected_volume_host = volume_utils.append_host(host, expected_cpg) volume['id'] = HP3PARBaseDriver.CLONE_ID volume['host'] = volume_host volume['source_volid'] = HP3PARBaseDriver.VOLUME_ID model_update = self.driver.create_cloned_volume(volume, src_vref) self.assertEqual(model_update, {'host': expected_volume_host}) expected = [ mock.call.getCPG(expected_cpg), mock.call.copyVolume( self.VOLUME_3PAR_NAME, 'osv-0DM4qZEVSKON-AAAAAAAAA', expected_cpg, {'snapCPG': 'OpenStackCPGSnap', 'tpvv': True, 'online': True})] mock_client.assert_has_calls( self.standard_login + expected + self.standard_logout) def test_migrate_volume(self): conf = { 'getStorageSystemInfo.return_value': { 'serialNumber': '1234'}, 'getTask.return_value': { 'status': 1}, 'getCPG.return_value': {}, 'copyVolume.return_value': {'taskid': 1}, 'getVolume.return_value': self.RETYPE_VOLUME_INFO_1 } mock_client = self.setup_driver(mock_conf=conf) mock_client.getVolume.return_value = self.MANAGE_VOLUME_INFO mock_client.modifyVolume.return_value = ("anyResponse", {'taskid': 1}) mock_client.getTask.return_value = self.STATUS_DONE volume = {'name': HP3PARBaseDriver.VOLUME_NAME, 'id': HP3PARBaseDriver.CLONE_ID, 'display_name': 'Foo Volume', 'volume_type_id': None, 'size': 2, 'status': 'available', 'host': HP3PARBaseDriver.FAKE_HOST, 'source_volid': HP3PARBaseDriver.VOLUME_ID} with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() volume_name_3par = common._encode_name(volume['id']) loc_info = 'HP3PARDriver:1234:CPG-FC1' host = {'host': 'stack@3parfc1#CPG-FC1', 'capabilities': {'location_info': loc_info}} result = self.driver.migrate_volume(context.get_admin_context(), volume, host) self.assertIsNotNone(result) self.assertEqual((True, None), result) osv_matcher = 'osv-' + volume_name_3par expected = [ mock.call.modifyVolume( osv_matcher, {'comment': '{"qos": {}, "display_name": "Foo Volume"}', 'snapCPG': HP3PAR_CPG_SNAP}), mock.call.modifyVolume(osv_matcher, {'action': 6, 'userCPG': 'CPG-FC1', 'conversionOperation': 1, 'tuneOperation': 1}), mock.call.getTask(mock.ANY) ] mock_client.assert_has_calls(expected + self.standard_logout) @mock.patch.object(volume_types, 'get_volume_type') def test_migrate_volume_with_type(self, _mock_volume_types): _mock_volume_types.return_value = self.RETYPE_VOLUME_TYPE_2 conf = { 'getStorageSystemInfo.return_value': { 'serialNumber': '1234'}, 'getTask.return_value': { 'status': 1}, 'getCPG.return_value': {}, 'copyVolume.return_value': {'taskid': 1}, 'getVolume.return_value': self.RETYPE_VOLUME_INFO_1 } mock_client = self.setup_driver(mock_conf=conf) mock_client.getVolume.return_value = self.MANAGE_VOLUME_INFO mock_client.modifyVolume.return_value = ("anyResponse", {'taskid': 1}) mock_client.getTask.return_value = self.STATUS_DONE display_name = 'Foo Volume' volume = {'name': HP3PARBaseDriver.VOLUME_NAME, 'id': HP3PARBaseDriver.CLONE_ID, 'display_name': display_name, "volume_type_id": self.RETYPE_VOLUME_TYPE_2['id'], 'size': 2, 'status': 'available', 'host': HP3PARBaseDriver.FAKE_HOST, 'source_volid': HP3PARBaseDriver.VOLUME_ID} with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() volume_name_3par = common._encode_name(volume['id']) loc_info = 'HP3PARDriver:1234:CPG-FC1' host = {'host': 'stack@3parfc1#CPG-FC1', 'capabilities': {'location_info': loc_info}} result = self.driver.migrate_volume(context.get_admin_context(), volume, host) self.assertIsNotNone(result) expected_host = volume_utils.append_host( "stack@3parfc1", self.RETYPE_VOLUME_TYPE_2['extra_specs']['cpg']) self.assertEqual((True, {'host': expected_host}), result) osv_matcher = 'osv-' + volume_name_3par expected_comment = { "display_name": display_name, "volume_type_id": self.RETYPE_VOLUME_TYPE_2['id'], "volume_type_name": self.RETYPE_VOLUME_TYPE_2['name'], "vvs": self.RETYPE_VOLUME_TYPE_2['extra_specs']['vvs'] } expected = [ mock.call.modifyVolume( osv_matcher, {'comment': self.CommentMatcher(self.assertEqual, expected_comment), 'snapCPG': self.RETYPE_VOLUME_TYPE_2 ['extra_specs']['snap_cpg']}), mock.call.modifyVolume( osv_matcher, {'action': 6, 'userCPG': self.RETYPE_VOLUME_TYPE_2 ['extra_specs']['cpg'], 'conversionOperation': 1, 'tuneOperation': 1}), mock.call.getTask(mock.ANY) ] mock_client.assert_has_calls( expected + self.standard_logout) def test_migrate_volume_diff_host(self): conf = { 'getStorageSystemInfo.return_value': { 'serialNumber': 'different'}, } mock_client = self.setup_driver(mock_conf=conf) volume = {'name': HP3PARBaseDriver.VOLUME_NAME, 'id': HP3PARBaseDriver.CLONE_ID, 'display_name': 'Foo Volume', 'volume_type_id': None, 'size': 2, 'status': 'available', 'host': HP3PARBaseDriver.FAKE_HOST, 'source_volid': HP3PARBaseDriver.VOLUME_ID} loc_info = 'HP3PARDriver:1234:CPG-FC1' host = {'host': 'stack@3parfc1', 'capabilities': {'location_info': loc_info}} with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client result = self.driver.migrate_volume(context.get_admin_context(), volume, host) self.assertIsNotNone(result) self.assertEqual((False, None), result) @mock.patch.object(volume_types, 'get_volume_type') def test_migrate_volume_diff_domain(self, _mock_volume_types): _mock_volume_types.return_value = self.volume_type conf = { 'getStorageSystemInfo.return_value': { 'serialNumber': '1234'}, 'getTask.return_value': { 'status': 1}, 'getCPG.return_value': {}, 'copyVolume.return_value': {'taskid': 1}, 'getVolume.return_value': self.RETYPE_VOLUME_INFO_1 } mock_client = self.setup_driver(mock_conf=conf) mock_client.getVolume.return_value = self.MANAGE_VOLUME_INFO mock_client.modifyVolume.return_value = ("anyResponse", {'taskid': 1}) mock_client.getTask.return_value = self.STATUS_DONE volume = {'name': HP3PARBaseDriver.VOLUME_NAME, 'id': HP3PARBaseDriver.CLONE_ID, 'display_name': 'Foo Volume', 'volume_type_id': None, 'size': 2, 'status': 'available', 'host': HP3PARBaseDriver.FAKE_HOST, 'source_volid': HP3PARBaseDriver.VOLUME_ID} with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() volume_name_3par = common._encode_name(volume['id']) loc_info = 'HP3PARDriver:1234:CPG-FC1' host = {'host': 'stack@3parfc1#CPG-FC1', 'capabilities': {'location_info': loc_info}} result = self.driver.migrate_volume(context.get_admin_context(), volume, host) self.assertIsNotNone(result) self.assertEqual((True, None), result) osv_matcher = 'osv-' + volume_name_3par expected = [ mock.call.modifyVolume( osv_matcher, {'comment': '{"qos": {}, "display_name": "Foo Volume"}', 'snapCPG': HP3PAR_CPG_SNAP}), mock.call.modifyVolume(osv_matcher, {'action': 6, 'userCPG': 'CPG-FC1', 'conversionOperation': 1, 'tuneOperation': 1}), mock.call.getTask(mock.ANY), ] mock_client.assert_has_calls(expected + self.standard_logout) @mock.patch.object(volume_types, 'get_volume_type') def test_migrate_volume_attached(self, _mock_volume_types): _mock_volume_types.return_value = self.RETYPE_VOLUME_TYPE_1 mock_client = self.setup_driver(mock_conf=self.RETYPE_CONF) volume = {'name': HP3PARBaseDriver.VOLUME_NAME, 'volume_type_id': None, 'id': HP3PARBaseDriver.CLONE_ID, 'display_name': 'Foo Volume', 'size': 2, 'status': 'in-use', 'host': HP3PARBaseDriver.FAKE_HOST, 'source_volid': HP3PARBaseDriver.VOLUME_ID} with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() volume_name_3par = common._encode_name(volume['id']) osv_matcher = 'osv-' + volume_name_3par loc_info = 'HP3PARDriver:1234567:CPG-FC1' protocol = "FC" if self.properties['driver_volume_type'] == "iscsi": protocol = "iSCSI" host = {'host': 'stack@3parfc1', 'capabilities': {'location_info': loc_info, 'storage_protocol': protocol}} result = self.driver.migrate_volume(context.get_admin_context(), volume, host) new_comment = {"qos": {}, "retype_test": "test comment"} expected = [ mock.call.modifyVolume(osv_matcher, {'comment': self.CommentMatcher( self.assertEqual, new_comment), 'snapCPG': 'OpenStackCPGSnap'}), mock.call.modifyVolume(osv_matcher, {'action': 6, 'userCPG': 'OpenStackCPG', 'conversionOperation': 1, 'tuneOperation': 1}), mock.call.getTask(1), mock.call.logout() ] mock_client.assert_has_calls(expected) self.assertIsNotNone(result) self.assertEqual((True, {'host': 'stack@3parfc1#OpenStackCPG'}), result) @mock.patch.object(volume_types, 'get_volume_type') def test_migrate_volume_attached_diff_protocol(self, _mock_volume_types): _mock_volume_types.return_value = self.RETYPE_VOLUME_TYPE_1 mock_client = self.setup_driver(mock_conf=self.RETYPE_CONF) protocol = "OTHER" volume = {'name': HP3PARBaseDriver.VOLUME_NAME, 'volume_type_id': None, 'id': HP3PARBaseDriver.CLONE_ID, 'display_name': 'Foo Volume', 'size': 2, 'status': 'in-use', 'host': HP3PARBaseDriver.FAKE_HOST, 'source_volid': HP3PARBaseDriver.VOLUME_ID} loc_info = 'HP3PARDriver:1234567:CPG-FC1' host = {'host': 'stack@3parfc1', 'capabilities': {'location_info': loc_info, 'storage_protocol': protocol}} result = self.driver.migrate_volume(context.get_admin_context(), volume, host) self.assertIsNotNone(result) self.assertEqual((False, None), result) expected = [] mock_client.assert_has_calls(expected) def test_attach_volume(self): # setup_mock_client drive with default configuration # and return the mock HTTP 3PAR client mock_client = self.setup_driver() with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client self.driver.attach_volume(context.get_admin_context(), self.volume, 'abcdef', 'newhost', '/dev/vdb') expected = [ mock.call.setVolumeMetaData( self.VOLUME_3PAR_NAME, 'HPQ-CS-instance_uuid', 'abcdef')] mock_client.assert_has_calls(expected) # test the exception mock_client.setVolumeMetaData.side_effect = Exception('Custom ex') self.assertRaises(exception.CinderException, self.driver.attach_volume, context.get_admin_context(), self.volume, 'abcdef', 'newhost', '/dev/vdb') def test_detach_volume(self): # setup_mock_client drive with default configuration # and return the mock HTTP 3PAR client mock_client = self.setup_driver() with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client self.driver.detach_volume(context.get_admin_context(), self.volume) expected = [ mock.call.removeVolumeMetaData( self.VOLUME_3PAR_NAME, 'HPQ-CS-instance_uuid')] mock_client.assert_has_calls(expected) # test the exception mock_client.removeVolumeMetaData.side_effect = Exception( 'Custom ex') self.assertRaises(exception.CinderException, self.driver.detach_volume, context.get_admin_context(), self.volume) def test_create_snapshot(self): # setup_mock_client drive with default configuration # and return the mock HTTP 3PAR client mock_client = self.setup_driver() with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client self.driver.create_snapshot(self.snapshot) comment = ( '{"volume_id": "761fc5e5-5191-4ec7-aeba-33e36de44156",' ' "display_name": "fakesnap",' ' "description": "test description name",' ' "volume_name":' ' "volume-d03338a9-9115-48a3-8dfc-35cdfcdc15a7"}') expected = [ mock.call.createSnapshot( 'oss-L4I73ONuTci9Fd4ceij-MQ', 'osv-dh-F5VGRTseuujPjbeRBVg', { 'comment': comment, 'readOnly': True})] mock_client.assert_has_calls( self.standard_login + expected + self.standard_logout) def test_delete_snapshot(self): # setup_mock_client drive with default configuration # and return the mock HTTP 3PAR client mock_client = self.setup_driver() with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client self.driver.delete_snapshot(self.snapshot) expected = [ mock.call.deleteVolume('oss-L4I73ONuTci9Fd4ceij-MQ')] mock_client.assert_has_calls( self.standard_login + expected + self.standard_logout) def test_delete_snapshot_in_use(self): # setup_mock_client drive with default configuration # and return the mock HTTP 3PAR client mock_client = self.setup_driver() with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client self.driver.create_snapshot(self.snapshot) self.driver.create_volume_from_snapshot(self.volume, self.snapshot) ex = hpexceptions.HTTPConflict("In use") mock_client.deleteVolume = mock.Mock(side_effect=ex) # Deleting the snapshot that a volume is dependent on should fail self.assertRaises(exception.SnapshotIsBusy, self.driver.delete_snapshot, self.snapshot) def test_delete_snapshot_not_found(self): # setup_mock_client drive with default configuration # and return the mock HTTP 3PAR client mock_client = self.setup_driver() self.driver.create_snapshot(self.snapshot) try: ex = hpexceptions.HTTPNotFound("not found") mock_client.deleteVolume = mock.Mock(side_effect=ex) self.driver.delete_snapshot(self.snapshot) except Exception: self.fail("Deleting a snapshot that is missing should act as if " "it worked.") def test_create_volume_from_snapshot(self): # setup_mock_client drive with default configuration # and return the mock HTTP 3PAR client mock_client = self.setup_driver() with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client model_update = self.driver.create_volume_from_snapshot( self.volume, self.snapshot) self.assertIsNone(model_update) comment = ( '{"snapshot_id": "2f823bdc-e36e-4dc8-bd15-de1c7a28ff31",' ' "display_name": "Foo Volume",' ' "volume_id": "d03338a9-9115-48a3-8dfc-35cdfcdc15a7"}') expected = [ mock.call.createSnapshot( self.VOLUME_3PAR_NAME, 'oss-L4I73ONuTci9Fd4ceij-MQ', { 'comment': comment, 'readOnly': False})] mock_client.assert_has_calls( self.standard_login + expected + self.standard_logout) volume = self.volume.copy() volume['size'] = 1 self.assertRaises(exception.InvalidInput, self.driver.create_volume_from_snapshot, volume, self.snapshot) def test_create_volume_from_snapshot_and_extend(self): # setup_mock_client drive with default configuration # and return the mock HTTP 3PAR client conf = { 'getTask.return_value': { 'status': 1}, 'copyVolume.return_value': {'taskid': 1}, 'getVolume.return_value': {} } mock_client = self.setup_driver(mock_conf=conf) with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() volume = self.volume.copy() volume['size'] = self.volume['size'] + 10 model_update = self.driver.create_volume_from_snapshot( volume, self.snapshot) self.assertEqual(model_update, {'host': volume_utils.append_host(self.FAKE_HOST, HP3PAR_CPG)}) comment = ( '{"snapshot_id": "2f823bdc-e36e-4dc8-bd15-de1c7a28ff31",' ' "display_name": "Foo Volume",' ' "volume_id": "d03338a9-9115-48a3-8dfc-35cdfcdc15a7"}') volume_name_3par = common._encode_name(volume['id']) osv_matcher = 'osv-' + volume_name_3par omv_matcher = 'omv-' + volume_name_3par expected = [ mock.call.createSnapshot( self.VOLUME_3PAR_NAME, 'oss-L4I73ONuTci9Fd4ceij-MQ', { 'comment': comment, 'readOnly': False}), mock.call.copyVolume( osv_matcher, omv_matcher, HP3PAR_CPG, mock.ANY), mock.call.getTask(mock.ANY), mock.call.getVolume(osv_matcher), mock.call.deleteVolume(osv_matcher), mock.call.modifyVolume(omv_matcher, {'newName': osv_matcher}), mock.call.growVolume(osv_matcher, 10 * 1024)] mock_client.assert_has_calls( self.standard_login + expected + self.standard_logout) @mock.patch.object(volume_types, 'get_volume_type') def test_create_volume_from_snapshot_and_extend_with_qos( self, _mock_volume_types): # setup_mock_client drive with default configuration # and return the mock HTTP 3PAR client conf = { 'getTask.return_value': { 'status': 1}, 'copyVolume.return_value': {'taskid': 1}, 'getVolume.return_value': {} } mock_client = self.setup_driver(mock_conf=conf) _mock_volume_types.return_value = { 'name': 'gold', 'extra_specs': { 'cpg': HP3PAR_CPG_QOS, 'snap_cpg': HP3PAR_CPG_SNAP, 'vvs_name': self.VVS_NAME, 'qos': self.QOS, 'tpvv': True, 'volume_type': self.volume_type}} with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() volume = self.volume_qos.copy() volume['size'] = self.volume['size'] + 10 model_update = self.driver.create_volume_from_snapshot( volume, self.snapshot) self.assertEqual(model_update, {'host': volume_utils.append_host( self.FAKE_HOST, HP3PAR_CPG_QOS)}) comment = ( '{"snapshot_id": "2f823bdc-e36e-4dc8-bd15-de1c7a28ff31",' ' "display_name": "Foo Volume",' ' "volume_id": "d03338a9-9115-48a3-8dfc-35cdfcdc15a7"}') volume_name_3par = common._encode_name(volume['id']) osv_matcher = 'osv-' + volume_name_3par omv_matcher = 'omv-' + volume_name_3par expected = [ mock.call.createSnapshot( self.VOLUME_3PAR_NAME, 'oss-L4I73ONuTci9Fd4ceij-MQ', { 'comment': comment, 'readOnly': False}), mock.call.getCPG(HP3PAR_CPG_QOS), mock.call.copyVolume( osv_matcher, omv_matcher, HP3PAR_CPG_QOS, mock.ANY), mock.call.getTask(mock.ANY), mock.call.getVolume(osv_matcher), mock.call.deleteVolume(osv_matcher), mock.call.modifyVolume(omv_matcher, {'newName': osv_matcher}), mock.call.growVolume(osv_matcher, 10 * 1024)] mock_client.assert_has_calls( self.standard_login + expected + self.standard_logout) def test_create_volume_from_snapshot_and_extend_copy_fail(self): # setup_mock_client drive with default configuration # and return the mock HTTP 3PAR client conf = { 'getTask.return_value': { 'status': 4, 'failure message': 'out of disk space'}, 'copyVolume.return_value': {'taskid': 1}, 'getVolume.return_value': {} } self.setup_driver(mock_conf=conf) volume = self.volume.copy() volume['size'] = self.volume['size'] + 10 self.assertRaises(exception.CinderException, self.driver.create_volume_from_snapshot, volume, self.snapshot) @mock.patch.object(volume_types, 'get_volume_type') def test_create_volume_from_snapshot_qos(self, _mock_volume_types): # setup_mock_client drive with default configuration # and return the mock HTTP 3PAR client mock_client = self.setup_driver() with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client _mock_volume_types.return_value = { 'name': 'gold', 'extra_specs': { 'cpg': HP3PAR_CPG, 'snap_cpg': HP3PAR_CPG_SNAP, 'vvs_name': self.VVS_NAME, 'qos': self.QOS, 'tpvv': True, 'volume_type': self.volume_type}} self.driver.create_volume_from_snapshot( self.volume_qos, self.snapshot) comment = ( '{"snapshot_id": "2f823bdc-e36e-4dc8-bd15-de1c7a28ff31",' ' "display_name": "Foo Volume",' ' "volume_id": "d03338a9-9115-48a3-8dfc-35cdfcdc15a7"}') expected = [ mock.call.createSnapshot( self.VOLUME_3PAR_NAME, 'oss-L4I73ONuTci9Fd4ceij-MQ', { 'comment': comment, 'readOnly': False})] mock_client.assert_has_calls( self.standard_login + expected + self.standard_logout) volume = self.volume.copy() volume['size'] = 1 self.assertRaises(exception.InvalidInput, self.driver.create_volume_from_snapshot, volume, self.snapshot) def test_terminate_connection(self): # setup_mock_client drive with default configuration # and return the mock HTTP 3PAR client mock_client = self.setup_driver() mock_client.getHostVLUNs.return_value = [ {'active': True, 'volumeName': self.VOLUME_3PAR_NAME, 'lun': None, 'type': 0}] with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client self.driver.terminate_connection( self.volume, self.connector, force=True) expected = [ mock.call.getHostVLUNs(self.FAKE_HOST), mock.call.deleteVLUN( self.VOLUME_3PAR_NAME, None, self.FAKE_HOST), mock.call.deleteHost(self.FAKE_HOST), mock.call.removeVolumeMetaData( self.VOLUME_3PAR_NAME, CHAP_USER_KEY), mock.call.removeVolumeMetaData( self.VOLUME_3PAR_NAME, CHAP_PASS_KEY)] mock_client.assert_has_calls( self.standard_login + expected + self.standard_logout) def test_update_volume_key_value_pair(self): # setup_mock_client drive with default configuration # and return the mock HTTP 3PAR client mock_client = self.setup_driver() key = 'a' value = 'b' with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() common.update_volume_key_value_pair( self.volume, key, value) expected = [ mock.call.setVolumeMetaData(self.VOLUME_3PAR_NAME, key, value)] mock_client.assert_has_calls(expected) # check exception mock_client.setVolumeMetaData.side_effect = Exception('fake') self.assertRaises(exception.VolumeBackendAPIException, common.update_volume_key_value_pair, self.volume, None, 'b') def test_clear_volume_key_value_pair(self): # setup_mock_client drive with default configuration # and return the mock HTTP 3PAR client mock_client = self.setup_driver() with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client key = 'a' common = self.driver._login() common.clear_volume_key_value_pair(self.volume, key) expected = [ mock.call.removeVolumeMetaData(self.VOLUME_3PAR_NAME, key)] mock_client.assert_has_calls(expected) # check the exception mock_client.removeVolumeMetaData.side_effect = Exception('fake') self.assertRaises(exception.VolumeBackendAPIException, common.clear_volume_key_value_pair, self.volume, None) def test_extend_volume(self): # setup_mock_client drive with default configuration # and return the mock HTTP 3PAR client mock_client = self.setup_driver() with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client grow_size = 3 old_size = self.volume['size'] new_size = old_size + grow_size self.driver.extend_volume(self.volume, str(new_size)) growth_size_mib = grow_size * units.Ki expected = [ mock.call.growVolume(self.VOLUME_3PAR_NAME, growth_size_mib)] mock_client.assert_has_calls(expected) def test_extend_volume_non_base(self): extend_ex = hpexceptions.HTTPForbidden(error={'code': 150}) conf = { 'getTask.return_value': { 'status': 1}, 'getCPG.return_value': {}, 'copyVolume.return_value': {'taskid': 1}, 'getVolume.return_value': {}, # Throw an exception first time only 'growVolume.side_effect': [extend_ex, None], } mock_client = self.setup_driver(mock_conf=conf) with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client grow_size = 3 old_size = self.volume['size'] new_size = old_size + grow_size self.driver.extend_volume(self.volume, str(new_size)) self.assertEqual(2, mock_client.growVolume.call_count) def test_extend_volume_non_base_failure(self): extend_ex = hpexceptions.HTTPForbidden(error={'code': 150}) conf = { 'getTask.return_value': { 'status': 1}, 'getCPG.return_value': {}, 'copyVolume.return_value': {'taskid': 1}, 'getVolume.return_value': {}, # Always fail 'growVolume.side_effect': extend_ex } mock_client = self.setup_driver(mock_conf=conf) with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client grow_size = 3 old_size = self.volume['size'] new_size = old_size + grow_size self.assertRaises(hpexceptions.HTTPForbidden, self.driver.extend_volume, self.volume, str(new_size)) def test_get_ports(self): # setup_mock_client drive with default configuration # and return the mock HTTP 3PAR client mock_client = self.setup_driver() mock_client.getPorts.return_value = { 'members': [ {'portPos': {'node': 0, 'slot': 8, 'cardPort': 2}, 'protocol': 2, 'IPAddr': '10.10.120.252', 'linkState': 4, 'device': [], 'iSCSIName': 'iqn.2000-05.com.3pardata:21810002ac00383d', 'mode': 2, 'HWAddr': '2C27D75375D2', 'type': 8}, {'portPos': {'node': 1, 'slot': 8, 'cardPort': 1}, 'protocol': 2, 'IPAddr': '10.10.220.253', 'linkState': 4, 'device': [], 'iSCSIName': 'iqn.2000-05.com.3pardata:21810002ac00383d', 'mode': 2, 'HWAddr': '2C27D75375D6', 'type': 8}, {'portWWN': '20210002AC00383D', 'protocol': 1, 'linkState': 4, 'mode': 2, 'device': ['cage2'], 'nodeWWN': '20210002AC00383D', 'type': 2, 'portPos': {'node': 0, 'slot': 6, 'cardPort': 3}}]} with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() ports = common.get_ports()['members'] self.assertEqual(len(ports), 3) def test_get_by_qos_spec_with_scoping(self): mock_client = self.setup_driver() with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() qos_ref = qos_specs.create(self.ctxt, 'qos-specs-1', self.QOS) type_ref = volume_types.create(self.ctxt, "type1", {"qos:maxIOPS": "100", "qos:maxBWS": "50", "qos:minIOPS": "10", "qos:minBWS": "20", "qos:latency": "5", "qos:priority": "high"}) qos_specs.associate_qos_with_type(self.ctxt, qos_ref['id'], type_ref['id']) type_ref = volume_types.get_volume_type(self.ctxt, type_ref['id']) qos = common._get_qos_by_volume_type(type_ref) self.assertEqual(qos, {'maxIOPS': '1000', 'maxBWS': '50', 'minIOPS': '100', 'minBWS': '25', 'latency': '25', 'priority': 'low'}) def test_get_by_qos_spec(self): mock_client = self.setup_driver() with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() qos_ref = qos_specs.create( self.ctxt, 'qos-specs-1', self.QOS_SPECS) type_ref = volume_types.create(self.ctxt, "type1", {"qos:maxIOPS": "100", "qos:maxBWS": "50", "qos:minIOPS": "10", "qos:minBWS": "20", "qos:latency": "5", "qos:priority": "high"}) qos_specs.associate_qos_with_type(self.ctxt, qos_ref['id'], type_ref['id']) type_ref = volume_types.get_volume_type(self.ctxt, type_ref['id']) qos = common._get_qos_by_volume_type(type_ref) self.assertEqual(qos, {'maxIOPS': '1000', 'maxBWS': '50', 'minIOPS': '100', 'minBWS': '25', 'latency': '25', 'priority': 'low'}) def test_get_by_qos_by_type_only(self): mock_client = self.setup_driver() with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() type_ref = volume_types.create(self.ctxt, "type1", {"qos:maxIOPS": "100", "qos:maxBWS": "50", "qos:minIOPS": "10", "qos:minBWS": "20", "qos:latency": "5", "qos:priority": "high"}) type_ref = volume_types.get_volume_type(self.ctxt, type_ref['id']) qos = common._get_qos_by_volume_type(type_ref) self.assertEqual(qos, {'maxIOPS': '100', 'maxBWS': '50', 'minIOPS': '10', 'minBWS': '20', 'latency': '5', 'priority': 'high'}) def test_create_vlun(self): host = 'fake-host' lun_id = 11 nsp = '1:2:3' mock_client = self.setup_driver() with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client location = ("%(name)s,%(lunid)s,%(host)s,%(nsp)s" % {'name': self.VOLUME_NAME, 'lunid': lun_id, 'host': host, 'nsp': nsp}) mock_client.createVLUN.return_value = location expected_info = {'volume_name': self.VOLUME_NAME, 'lun_id': lun_id, 'host_name': host, 'nsp': nsp} common = self.driver._login() vlun_info = common._create_3par_vlun( self.VOLUME_NAME, host, nsp) self.assertEqual(expected_info, vlun_info) location = ("%(name)s,%(lunid)s,%(host)s" % {'name': self.VOLUME_NAME, 'lunid': lun_id, 'host': host}) mock_client.createVLUN.return_value = location expected_info = {'volume_name': self.VOLUME_NAME, 'lun_id': lun_id, 'host_name': host} vlun_info = common._create_3par_vlun( self.VOLUME_NAME, host, None) self.assertEqual(expected_info, vlun_info) def test__get_existing_volume_ref_name(self): mock_client = self.setup_driver() with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() unm_matcher = common._get_3par_unm_name(self.volume['id']) existing_ref = {'source-name': unm_matcher} result = common._get_existing_volume_ref_name(existing_ref) self.assertEqual(unm_matcher, result) existing_ref = {'source-id': self.volume['id']} result = common._get_existing_volume_ref_name(existing_ref) self.assertEqual(unm_matcher, result) existing_ref = {'bad-key': 'foo'} self.assertRaises( exception.ManageExistingInvalidReference, common._get_existing_volume_ref_name, existing_ref) @mock.patch.object(volume_types, 'get_volume_type') def test_manage_existing(self, _mock_volume_types): _mock_volume_types.return_value = self.volume_type mock_client = self.setup_driver() new_comment = {"display_name": "Foo Volume", "name": "volume-007dbfce-7579-40bc-8f90-a20b3902283e", "volume_id": "007dbfce-7579-40bc-8f90-a20b3902283e", "type": "OpenStack"} volume = {'display_name': None, 'host': 'my-stack1@3parxxx#CPGNOTUSED', 'volume_type': 'gold', 'volume_type_id': 'acfa9fa4-54a0-4340-a3d8-bfcf19aea65e', 'id': '007dbfce-7579-40bc-8f90-a20b3902283e'} mock_client.getVolume.return_value = self.MANAGE_VOLUME_INFO mock_client.modifyVolume.return_value = ("anyResponse", {'taskid': 1}) mock_client.getTask.return_value = self.STATUS_DONE with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() unm_matcher = common._get_3par_unm_name(self.volume['id']) osv_matcher = common._get_3par_vol_name(volume['id']) vvs_matcher = common._get_3par_vvs_name(volume['id']) existing_ref = {'source-name': unm_matcher} expected_obj = {'display_name': 'Foo Volume', 'host': 'my-stack1@3parxxx#fakepool'} obj = self.driver.manage_existing(volume, existing_ref) expected_manage = [ mock.call.getVolume(existing_ref['source-name']), mock.call.modifyVolume(existing_ref['source-name'], {'newName': osv_matcher, 'comment': self.CommentMatcher( self.assertEqual, new_comment)}), ] retype_comment_qos = { "display_name": "Foo Volume", "volume_type_name": self.volume_type['name'], "volume_type_id": self.volume_type['id'], "qos": { 'maxIOPS': '1000', 'maxBWS': '50', 'minIOPS': '100', 'minBWS': '25', 'latency': '25', 'priority': 'low' } } expected_snap_cpg = self.volume_type['extra_specs']['cpg'] expected_retype_modify = [ mock.call.modifyVolume(osv_matcher, {'comment': self.CommentMatcher( self.assertEqual, retype_comment_qos), 'snapCPG': expected_snap_cpg}), mock.call.deleteVolumeSet(vvs_matcher), ] expected_retype_specs = [ mock.call.createVolumeSet(vvs_matcher, None), mock.call.createQoSRules( vvs_matcher, {'ioMinGoal': 100, 'ioMaxLimit': 1000, 'bwMinGoalKB': 25600, 'priority': 1, 'latencyGoal': 25, 'bwMaxLimitKB': 51200}), mock.call.addVolumeToVolumeSet(vvs_matcher, osv_matcher), mock.call.modifyVolume( osv_matcher, {'action': 6, 'userCPG': self.volume_type['extra_specs']['cpg'], 'conversionOperation': 1, 'tuneOperation': 1}), mock.call.getTask(1) ] mock_client.assert_has_calls(self.standard_login + expected_manage) mock_client.assert_has_calls(expected_retype_modify) mock_client.assert_has_calls( expected_retype_specs + self.standard_logout) self.assertEqual(expected_obj, obj) @mock.patch.object(volume_types, 'get_volume_type') def test_manage_existing_vvs(self, _mock_volume_types): test_volume_type = self.RETYPE_VOLUME_TYPE_2 vvs = test_volume_type['extra_specs']['vvs'] _mock_volume_types.return_value = test_volume_type mock_client = self.setup_driver() mock_client.getVolume.return_value = self.MANAGE_VOLUME_INFO mock_client.modifyVolume.return_value = ("anyResponse", {'taskid': 1}) mock_client.getTask.return_value = self.STATUS_DONE id = '007abcde-7579-40bc-8f90-a20b3902283e' new_comment = {"display_name": "Test Volume", "name": ("volume-%s" % id), "volume_id": id, "type": "OpenStack"} volume = {'display_name': 'Test Volume', 'host': 'my-stack1@3parxxx#CPGNOTUSED', 'volume_type': 'gold', 'volume_type_id': 'acfa9fa4-54a0-4340-a3d8-bfcf19aea65e', 'id': id} with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() unm_matcher = common._get_3par_unm_name(self.volume['id']) osv_matcher = common._get_3par_vol_name(volume['id']) vvs_matcher = common._get_3par_vvs_name(volume['id']) existing_ref = {'source-name': unm_matcher} obj = self.driver.manage_existing(volume, existing_ref) expected_obj = {'display_name': 'Test Volume', 'host': 'my-stack1@3parxxx#qospool'} expected_manage = [ mock.call.getVolume(existing_ref['source-name']), mock.call.modifyVolume(existing_ref['source-name'], {'newName': osv_matcher, 'comment': self.CommentMatcher( self.assertEqual, new_comment)}) ] retype_comment_vvs = { "display_name": "Foo Volume", "volume_type_name": test_volume_type['name'], "volume_type_id": test_volume_type['id'], "vvs": vvs } expected_retype = [ mock.call.modifyVolume(osv_matcher, {'comment': self.CommentMatcher( self.assertEqual, retype_comment_vvs), 'snapCPG': 'OpenStackCPGSnap'}), mock.call.deleteVolumeSet(vvs_matcher), mock.call.addVolumeToVolumeSet(vvs, osv_matcher), mock.call.modifyVolume(osv_matcher, {'action': 6, 'userCPG': test_volume_type['extra_specs']['cpg'], 'conversionOperation': 1, 'tuneOperation': 1}), mock.call.getTask(1) ] mock_client.assert_has_calls(self.standard_login + expected_manage) mock_client.assert_has_calls( expected_retype + self.standard_logout) self.assertEqual(expected_obj, obj) def test_manage_existing_no_volume_type(self): mock_client = self.setup_driver() comment = ( '{"display_name": "Foo Volume"}') new_comment = ( '{"type": "OpenStack",' ' "display_name": "Foo Volume",' ' "name": "volume-007dbfce-7579-40bc-8f90-a20b3902283e",' ' "volume_id": "007dbfce-7579-40bc-8f90-a20b3902283e"}') volume = {'display_name': None, 'volume_type': None, 'volume_type_id': None, 'id': '007dbfce-7579-40bc-8f90-a20b3902283e'} mock_client.getVolume.return_value = {'comment': comment} with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() unm_matcher = common._get_3par_unm_name(self.volume['id']) osv_matcher = common._get_3par_vol_name(volume['id']) existing_ref = {'source-name': unm_matcher} obj = self.driver.manage_existing(volume, existing_ref) expected_obj = {'display_name': 'Foo Volume'} expected = [ mock.call.getVolume(existing_ref['source-name']), mock.call.modifyVolume(existing_ref['source-name'], {'newName': osv_matcher, 'comment': new_comment}) ] mock_client.assert_has_calls( self.standard_login + expected + self.standard_logout) self.assertEqual(expected_obj, obj) volume['display_name'] = 'Test Volume' obj = self.driver.manage_existing(volume, existing_ref) expected_obj = {'display_name': 'Test Volume'} expected = [ mock.call.getVolume(existing_ref['source-name']), mock.call.modifyVolume(existing_ref['source-name'], {'newName': osv_matcher, 'comment': new_comment}) ] mock_client.assert_has_calls( self.standard_login + expected + self.standard_logout) self.assertEqual(expected_obj, obj) mock_client.getVolume.return_value = {} volume['display_name'] = None common = self.driver._login() obj = self.driver.manage_existing(volume, existing_ref) expected_obj = {'display_name': None} expected = [ mock.call.getVolume(existing_ref['source-name']), mock.call.modifyVolume(existing_ref['source-name'], {'newName': osv_matcher, 'comment': new_comment}) ] mock_client.assert_has_calls( self.standard_login + expected + self.standard_logout) self.assertEqual(expected_obj, obj) def test_manage_existing_invalid_input(self): mock_client = self.setup_driver() volume = {'display_name': None, 'volume_type': None, 'id': '007dbfce-7579-40bc-8f90-a20b3902283e'} mock_client.getVolume.side_effect = hpexceptions.HTTPNotFound('fake') with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() unm_matcher = common._get_3par_unm_name(self.volume['id']) existing_ref = {'source-name': unm_matcher} self.assertRaises(exception.InvalidInput, self.driver.manage_existing, volume=volume, existing_ref=existing_ref) expected = [mock.call.getVolume(existing_ref['source-name'])] mock_client.assert_has_calls( self.standard_login + expected + self.standard_logout) def test_manage_existing_volume_type_exception(self): mock_client = self.setup_driver() comment = ( '{"display_name": "Foo Volume"}') volume = {'display_name': None, 'volume_type': 'gold', 'volume_type_id': 'bcfa9fa4-54a0-4340-a3d8-bfcf19aea65e', 'id': '007dbfce-7579-40bc-8f90-a20b3902283e'} mock_client.getVolume.return_value = {'comment': comment} with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() unm_matcher = common._get_3par_unm_name(self.volume['id']) existing_ref = {'source-name': unm_matcher} self.assertRaises(exception.ManageExistingVolumeTypeMismatch, self.driver.manage_existing, volume=volume, existing_ref=existing_ref) expected = [mock.call.getVolume(existing_ref['source-name'])] mock_client.assert_has_calls( self.standard_login + expected + self.standard_logout) @mock.patch.object(volume_types, 'get_volume_type') def test_manage_existing_retype_exception(self, _mock_volume_types): mock_client = self.setup_driver() _mock_volume_types.return_value = { 'name': 'gold', 'id': 'gold-id', 'extra_specs': { 'cpg': HP3PAR_CPG, 'snap_cpg': HP3PAR_CPG_SNAP, 'vvs_name': self.VVS_NAME, 'qos': self.QOS, 'tpvv': True, 'volume_type': self.volume_type}} volume = {'display_name': None, 'host': 'stack1@3pariscsi#POOL1', 'volume_type': 'gold', 'volume_type_id': 'bcfa9fa4-54a0-4340-a3d8-bfcf19aea65e', 'id': '007dbfce-7579-40bc-8f90-a20b3902283e'} mock_client.getVolume.return_value = self.MANAGE_VOLUME_INFO mock_client.modifyVolume.return_value = ("anyResponse", {'taskid': 1}) mock_client.getTask.return_value = self.STATUS_DONE mock_client.getCPG.side_effect = [ {'domain': 'domain1'}, {'domain': 'domain2'}, {'domain': 'domain3'}, ] with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() unm_matcher = common._get_3par_unm_name(self.volume['id']) osv_matcher = common._get_3par_vol_name(volume['id']) existing_ref = {'source-name': unm_matcher} self.assertRaises(exception.Invalid3PARDomain, self.driver.manage_existing, volume=volume, existing_ref=existing_ref) expected = [ mock.call.getVolume(unm_matcher), mock.call.modifyVolume( unm_matcher, { 'newName': osv_matcher, 'comment': mock.ANY}), mock.call.getCPG('OpenStackCPG'), mock.call.getVolume(osv_matcher), mock.call.getCPG('testUserCpg0'), mock.call.getCPG('OpenStackCPG'), mock.call.modifyVolume( osv_matcher, {'newName': unm_matcher, 'comment': self.MANAGE_VOLUME_INFO ['comment']}) ] mock_client.assert_has_calls( self.standard_login + expected + self.standard_logout) def test_manage_existing_get_size(self): mock_client = self.setup_driver() mock_client.getVolume.return_value = {'sizeMiB': 2048} with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() unm_matcher = common._get_3par_unm_name(self.volume['id']) volume = {} existing_ref = {'source-name': unm_matcher} size = self.driver.manage_existing_get_size(volume, existing_ref) expected_size = 2 expected = [mock.call.getVolume(existing_ref['source-name'])] mock_client.assert_has_calls( self.standard_login + expected + self.standard_logout) self.assertEqual(expected_size, size) def test_manage_existing_get_size_invalid_reference(self): mock_client = self.setup_driver() with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client volume = {} existing_ref = {'source-name': self.VOLUME_3PAR_NAME} self.assertRaises(exception.ManageExistingInvalidReference, self.driver.manage_existing_get_size, volume=volume, existing_ref=existing_ref) mock_client.assert_has_calls( self.standard_login + self.standard_logout) existing_ref = {} self.assertRaises(exception.ManageExistingInvalidReference, self.driver.manage_existing_get_size, volume=volume, existing_ref=existing_ref) mock_client.assert_has_calls( self.standard_login + self.standard_logout) def test_manage_existing_get_size_invalid_input(self): mock_client = self.setup_driver() mock_client.getVolume.side_effect = hpexceptions.HTTPNotFound('fake') with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() unm_matcher = common._get_3par_unm_name(self.volume['id']) volume = {} existing_ref = {'source-name': unm_matcher} self.assertRaises(exception.InvalidInput, self.driver.manage_existing_get_size, volume=volume, existing_ref=existing_ref) expected = [mock.call.getVolume(existing_ref['source-name'])] mock_client.assert_has_calls( self.standard_login + expected + self.standard_logout) def test_unmanage(self): mock_client = self.setup_driver() with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() self.driver.unmanage(self.volume) osv_matcher = common._get_3par_vol_name(self.volume['id']) unm_matcher = common._get_3par_unm_name(self.volume['id']) expected = [ mock.call.modifyVolume(osv_matcher, {'newName': unm_matcher}) ] mock_client.assert_has_calls( self.standard_login + expected + self.standard_logout) def test__safe_hostname(self): long_hostname = "abc123abc123abc123abc123abc123abc123" fixed_hostname = "abc123abc123abc123abc123abc123a" common = hpcommon.HP3PARCommon(None) safe_host = common._safe_hostname(long_hostname) self.assertEqual(fixed_hostname, safe_host) class TestHP3PARFCDriver(HP3PARBaseDriver, test.TestCase): properties = { 'driver_volume_type': 'fibre_channel', 'data': { 'target_lun': 90, 'target_wwn': ['0987654321234', '123456789000987'], 'target_discovered': True, 'initiator_target_map': {'123456789012345': ['0987654321234', '123456789000987'], '123456789054321': ['0987654321234', '123456789000987'], }}} def setup_driver(self, config=None, mock_conf=None): self.ctxt = context.get_admin_context() mock_client = self.setup_mock_client( conf=config, m_conf=mock_conf, driver=hpfcdriver.HP3PARFCDriver) expected = [ mock.call.getCPG(HP3PAR_CPG), mock.call.getCPG(HP3PAR_CPG2)] mock_client.assert_has_calls( self.standard_login + expected + self.standard_logout) mock_client.reset_mock() return mock_client def test_initialize_connection(self): # setup_mock_client drive with default configuration # and return the mock HTTP 3PAR client mock_client = self.setup_driver() mock_client.getVolume.return_value = {'userCPG': HP3PAR_CPG} mock_client.getCPG.return_value = {} mock_client.getHost.side_effect = [ hpexceptions.HTTPNotFound('fake'), {'name': self.FAKE_HOST, 'FCPaths': [{'driverVersion': None, 'firmwareVersion': None, 'hostSpeed': 0, 'model': None, 'portPos': {'cardPort': 1, 'node': 1, 'slot': 2}, 'vendor': None, 'wwn': self.wwn[0]}, {'driverVersion': None, 'firmwareVersion': None, 'hostSpeed': 0, 'model': None, 'portPos': {'cardPort': 1, 'node': 0, 'slot': 2}, 'vendor': None, 'wwn': self.wwn[1]}]}] mock_client.queryHost.return_value = { 'members': [{ 'name': self.FAKE_HOST }] } mock_client.getHostVLUNs.return_value = [ {'active': True, 'volumeName': self.VOLUME_3PAR_NAME, 'lun': 90, 'type': 0}] location = ("%(volume_name)s,%(lun_id)s,%(host)s,%(nsp)s" % {'volume_name': self.VOLUME_3PAR_NAME, 'lun_id': 90, 'host': self.FAKE_HOST, 'nsp': 'something'}) mock_client.createVLUN.return_value = location with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client result = self.driver.initialize_connection( self.volume, self.connector) expected = [ mock.call.getVolume(self.VOLUME_3PAR_NAME), mock.call.getCPG(HP3PAR_CPG), mock.call.getHost(self.FAKE_HOST), mock.call.queryHost(wwns=['123456789012345', '123456789054321']), mock.call.getHost(self.FAKE_HOST), mock.call.getPorts(), mock.call.createVLUN( self.VOLUME_3PAR_NAME, auto=True, hostname=self.FAKE_HOST), mock.call.getHostVLUNs(self.FAKE_HOST)] mock_client.assert_has_calls( self.standard_login + expected + self.standard_logout) self.assertDictMatch(result, self.properties) @mock.patch('cinder.zonemanager.utils.create_lookup_service') def test_initialize_connection_with_lookup_single_nsp(self, mock_lookup): # setup_mock_client drive with default configuration # and return the mock HTTP 3PAR client class fake_lookup_object: def get_device_mapping_from_network(self, connector, target_wwns): fake_map = { 'FAB_1': { 'target_port_wwn_list': ['0987654321234'], 'initiator_port_wwn_list': ['123456789012345'] } } return fake_map mock_lookup.return_value = fake_lookup_object() mock_client = self.setup_driver() mock_client.getVolume.return_value = {'userCPG': HP3PAR_CPG} mock_client.getCPG.return_value = {} mock_client.getHost.side_effect = [ hpexceptions.HTTPNotFound('fake'), {'name': self.FAKE_HOST, 'FCPaths': [{'driverVersion': None, 'firmwareVersion': None, 'hostSpeed': 0, 'model': None, 'portPos': {'cardPort': 1, 'node': 1, 'slot': 2}, 'vendor': None, 'wwn': self.wwn[0]}]}] mock_client.queryHost.return_value = { 'members': [{ 'name': self.FAKE_HOST }] } mock_client.getHostVLUNs.return_value = [ {'active': True, 'volumeName': self.VOLUME_3PAR_NAME, 'lun': 90, 'type': 0}] location = ("%(volume_name)s,%(lun_id)s,%(host)s,%(nsp)s" % {'volume_name': self.VOLUME_3PAR_NAME, 'lun_id': 90, 'host': self.FAKE_HOST, 'nsp': 'something'}) mock_client.createVLUN.return_value = location connector = {'ip': '10.0.0.2', 'initiator': 'iqn.1993-08.org.debian:01:222', 'wwpns': [self.wwn[0]], 'wwnns': ["223456789012345"], 'host': self.FAKE_HOST} expected_properties = { 'driver_volume_type': 'fibre_channel', 'data': { 'target_lun': 90, 'target_wwn': ['0987654321234'], 'target_discovered': True, 'initiator_target_map': {'123456789012345': ['0987654321234'] }}} with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client result = self.driver.initialize_connection(self.volume, connector) expected = [ mock.call.getVolume(self.VOLUME_3PAR_NAME), mock.call.getCPG(HP3PAR_CPG), mock.call.getHost(self.FAKE_HOST), mock.ANY, mock.call.getHost(self.FAKE_HOST), mock.call.getPorts(), mock.call.getPorts(), mock.call.createVLUN( self.VOLUME_3PAR_NAME, auto=True, hostname=self.FAKE_HOST, portPos={'node': 7, 'slot': 1, 'cardPort': 1}), mock.call.getHostVLUNs(self.FAKE_HOST)] mock_client.assert_has_calls( self.standard_login + expected + self.standard_logout) self.assertDictMatch(result, expected_properties) def test_terminate_connection(self): # setup_mock_client drive with default configuration # and return the mock HTTP 3PAR client mock_client = self.setup_driver() effects = [ [{'active': True, 'volumeName': self.VOLUME_3PAR_NAME, 'lun': None, 'type': 0}], hpexceptions.HTTPNotFound] mock_client.getHostVLUNs.side_effect = effects expected = [ mock.call.getHostVLUNs(self.FAKE_HOST), mock.call.deleteVLUN( self.VOLUME_3PAR_NAME, None, self.FAKE_HOST), mock.call.deleteHost(self.FAKE_HOST), mock.call.getHostVLUNs(self.FAKE_HOST), mock.call.getPorts()] with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client conn_info = self.driver.terminate_connection(self.volume, self.connector) mock_client.assert_has_calls( self.standard_login + expected + self.standard_logout) self.assertIn('data', conn_info) self.assertIn('initiator_target_map', conn_info['data']) mock_client.reset_mock() mock_client.getHostVLUNs.side_effect = effects # mock some deleteHost exceptions that are handled delete_with_vlun = hpexceptions.HTTPConflict( error={'message': "has exported VLUN"}) delete_with_hostset = hpexceptions.HTTPConflict( error={'message': "host is a member of a set"}) mock_client.deleteHost = mock.Mock( side_effect=[delete_with_vlun, delete_with_hostset]) conn_info = self.driver.terminate_connection(self.volume, self.connector) mock_client.assert_has_calls( self.standard_login + expected + self.standard_logout) mock_client.reset_mock() mock_client.getHostVLUNs.side_effect = effects conn_info = self.driver.terminate_connection(self.volume, self.connector) mock_client.assert_has_calls( self.standard_login + expected + self.standard_logout) @mock.patch('cinder.zonemanager.utils.create_lookup_service') def test_terminate_connection_with_lookup(self, mock_lookup): # setup_mock_client drive with default configuration # and return the mock HTTP 3PAR client class fake_lookup_object: def get_device_mapping_from_network(self, connector, target_wwns): fake_map = { 'FAB_1': { 'target_port_wwn_list': ['0987654321234'], 'initiator_port_wwn_list': ['123456789012345'] } } return fake_map mock_lookup.return_value = fake_lookup_object() mock_client = self.setup_driver() effects = [ [{'active': True, 'volumeName': self.VOLUME_3PAR_NAME, 'lun': None, 'type': 0}], hpexceptions.HTTPNotFound] mock_client.getHostVLUNs.side_effect = effects expected = [ mock.call.getHostVLUNs(self.FAKE_HOST), mock.call.deleteVLUN( self.VOLUME_3PAR_NAME, None, self.FAKE_HOST), mock.call.deleteHost(self.FAKE_HOST), mock.call.getHostVLUNs(self.FAKE_HOST), mock.call.getPorts()] with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client conn_info = self.driver.terminate_connection(self.volume, self.connector) mock_client.assert_has_calls( self.standard_login + expected + self.standard_logout) self.assertIn('data', conn_info) self.assertIn('initiator_target_map', conn_info['data']) mock_client.reset_mock() mock_client.getHostVLUNs.side_effect = effects # mock some deleteHost exceptions that are handled delete_with_vlun = hpexceptions.HTTPConflict( error={'message': "has exported VLUN"}) delete_with_hostset = hpexceptions.HTTPConflict( error={'message': "host is a member of a set"}) mock_client.deleteHost = mock.Mock( side_effect=[delete_with_vlun, delete_with_hostset]) conn_info = self.driver.terminate_connection(self.volume, self.connector) mock_client.assert_has_calls( self.standard_login + expected + self.standard_logout) mock_client.reset_mock() mock_client.getHostVLUNs.side_effect = effects conn_info = self.driver.terminate_connection(self.volume, self.connector) mock_client.assert_has_calls( self.standard_login + expected + self.standard_logout) def test_terminate_connection_more_vols(self): mock_client = self.setup_driver() # mock more than one vlun on the host (don't even try to remove host) mock_client.getHostVLUNs.return_value = \ [ {'active': True, 'volumeName': self.VOLUME_3PAR_NAME, 'lun': None, 'type': 0}, {'active': True, 'volumeName': 'there-is-another-volume', 'lun': None, 'type': 0}, ] expect_less = [ mock.call.getHostVLUNs(self.FAKE_HOST), mock.call.deleteVLUN( self.VOLUME_3PAR_NAME, None, self.FAKE_HOST), mock.call.getHostVLUNs(self.FAKE_HOST)] with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client conn_info = self.driver.terminate_connection(self.volume, self.connector) mock_client.assert_has_calls( self.standard_login + expect_less + self.standard_logout) self.assertNotIn('initiator_target_map', conn_info['data']) def test_get_volume_stats(self): # setup_mock_client drive with default configuration # and return the mock HTTP 3PAR client mock_client = self.setup_driver() mock_client.getCPG.return_value = self.cpgs[0] mock_client.getStorageSystemInfo.return_value = { 'serialNumber': '1234' } # cpg has no limit mock_client.getCPGAvailableSpace.return_value = { "capacityEfficiency": {u'compaction': 594.4}, "rawFreeMiB": 1024.0 * 6, "usableFreeMiB": 1024.0 * 3 } with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() stats = self.driver.get_volume_stats(True) const = 0.0009765625 self.assertEqual(stats['storage_protocol'], 'FC') self.assertEqual(stats['total_capacity_gb'], 0) self.assertEqual(stats['free_capacity_gb'], 0) self.assertEqual(stats['pools'][0]['total_capacity_gb'], 24.0) self.assertEqual(stats['pools'][0]['free_capacity_gb'], 3.0) expected = [ mock.call.getStorageSystemInfo(), mock.call.getCPG(HP3PAR_CPG), mock.call.getCPGAvailableSpace(HP3PAR_CPG), mock.call.getCPG(HP3PAR_CPG2), mock.call.getCPGAvailableSpace(HP3PAR_CPG2)] mock_client.assert_has_calls( self.standard_login + expected + self.standard_logout) stats = self.driver.get_volume_stats(True) self.assertEqual(stats['storage_protocol'], 'FC') self.assertEqual(stats['total_capacity_gb'], 0) self.assertEqual(stats['free_capacity_gb'], 0) self.assertEqual(stats['pools'][0]['total_capacity_gb'], 24.0) self.assertEqual(stats['pools'][0]['free_capacity_gb'], 3.0) cpg2 = self.cpgs[0].copy() cpg2.update({'SDGrowth': {'limitMiB': 8192}}) mock_client.getCPG.return_value = cpg2 stats = self.driver.get_volume_stats(True) self.assertEqual(stats['storage_protocol'], 'FC') total_capacity_gb = 8192 * const self.assertEqual(stats['total_capacity_gb'], 0) self.assertEqual(stats['pools'][0]['total_capacity_gb'], total_capacity_gb) free_capacity_gb = int( (8192 - self.cpgs[0]['UsrUsage']['usedMiB']) * const) self.assertEqual(stats['free_capacity_gb'], 0) self.assertEqual(stats['pools'][0]['free_capacity_gb'], free_capacity_gb) common.client.deleteCPG(HP3PAR_CPG) common.client.createCPG(HP3PAR_CPG, {}) def test_create_host(self): # setup_mock_client drive with default configuration # and return the mock HTTP 3PAR client mock_client = self.setup_driver() mock_client.getVolume.return_value = {'userCPG': HP3PAR_CPG} mock_client.getCPG.return_value = {} mock_client.getHost.side_effect = [ hpexceptions.HTTPNotFound('fake'), {'name': self.FAKE_HOST, 'FCPaths': [{'driverVersion': None, 'firmwareVersion': None, 'hostSpeed': 0, 'model': None, 'portPos': {'cardPort': 1, 'node': 1, 'slot': 2}, 'vendor': None, 'wwn': self.wwn[0]}, {'driverVersion': None, 'firmwareVersion': None, 'hostSpeed': 0, 'model': None, 'portPos': {'cardPort': 1, 'node': 0, 'slot': 2}, 'vendor': None, 'wwn': self.wwn[1]}]}] mock_client.queryHost.return_value = None mock_client.getVLUN.return_value = {'lun': 186} with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() host = self.driver._create_host( common, self.volume, self.connector) expected = [ mock.call.getVolume('osv-0DM4qZEVSKON-DXN-NwVpw'), mock.call.getCPG(HP3PAR_CPG), mock.call.getHost(self.FAKE_HOST), mock.call.queryHost(wwns=['123456789012345', '123456789054321']), mock.call.createHost( self.FAKE_HOST, FCWwns=['123456789012345', '123456789054321'], optional={'domain': None, 'persona': 2}), mock.call.getHost(self.FAKE_HOST)] mock_client.assert_has_calls(expected) self.assertEqual(host['name'], self.FAKE_HOST) def test_create_invalid_host(self): # setup_mock_client drive with default configuration # and return the mock HTTP 3PAR client mock_client = self.setup_driver() mock_client.getVolume.return_value = {'userCPG': HP3PAR_CPG} mock_client.getCPG.return_value = {} mock_client.getHost.side_effect = [ hpexceptions.HTTPNotFound('Host not found.'), { 'name': 'fakehost.foo', 'FCPaths': [{'wwn': '123456789012345'}, { 'wwn': '123456789054321'}]}] mock_client.queryHost.return_value = { 'members': [{ 'name': 'fakehost.foo' }] } with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() host = self.driver._create_host( common, self.volume, self.connector) expected = [ mock.call.getVolume('osv-0DM4qZEVSKON-DXN-NwVpw'), mock.call.getCPG(HP3PAR_CPG), mock.call.getHost('fakehost'), mock.call.queryHost(wwns=['123456789012345', '123456789054321']), mock.call.getHost('fakehost.foo')] mock_client.assert_has_calls(expected) self.assertEqual(host['name'], 'fakehost.foo') def test_create_modify_host(self): # setup_mock_client drive with default configuration # and return the mock HTTP 3PAR client mock_client = self.setup_driver() mock_client.getVolume.return_value = {'userCPG': HP3PAR_CPG} mock_client.getCPG.return_value = {} mock_client.getHost.side_effect = [{ 'name': self.FAKE_HOST, 'FCPaths': []}, {'name': self.FAKE_HOST, 'FCPaths': [{'wwn': '123456789012345'}, { 'wwn': '123456789054321'}]}] with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() host = self.driver._create_host( common, self.volume, self.connector) expected = [ mock.call.getVolume('osv-0DM4qZEVSKON-DXN-NwVpw'), mock.call.getCPG(HP3PAR_CPG), mock.call.getHost('fakehost'), mock.call.modifyHost( 'fakehost', { 'FCWWNs': ['123456789012345', '123456789054321'], 'pathOperation': 1}), mock.call.getHost('fakehost')] mock_client.assert_has_calls(expected) self.assertEqual(host['name'], self.FAKE_HOST) self.assertEqual(len(host['FCPaths']), 2) def test_modify_host_with_new_wwn(self): # setup_mock_client drive with default configuration # and return the mock HTTP 3PAR client mock_client = self.setup_driver() mock_client.getVolume.return_value = {'userCPG': HP3PAR_CPG} mock_client.getCPG.return_value = {} getHost_ret1 = { 'name': self.FAKE_HOST, 'FCPaths': [{'wwn': '123456789054321'}]} getHost_ret2 = { 'name': self.FAKE_HOST, 'FCPaths': [{'wwn': '123456789012345'}, {'wwn': '123456789054321'}]} mock_client.getHost.side_effect = [getHost_ret1, getHost_ret2] with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() host = self.driver._create_host( common, self.volume, self.connector) expected = [ mock.call.getVolume('osv-0DM4qZEVSKON-DXN-NwVpw'), mock.call.getCPG(HP3PAR_CPG), mock.call.getHost('fakehost'), mock.call.modifyHost( 'fakehost', { 'FCWWNs': ['123456789012345'], 'pathOperation': 1}), mock.call.getHost('fakehost')] mock_client.assert_has_calls(expected) self.assertEqual(host['name'], self.FAKE_HOST) self.assertEqual(len(host['FCPaths']), 2) def test_modify_host_with_unknown_wwn_and_new_wwn(self): # setup_mock_client drive with default configuration # and return the mock HTTP 3PAR client mock_client = self.setup_driver() mock_client.getVolume.return_value = {'userCPG': HP3PAR_CPG} mock_client.getCPG.return_value = {} getHost_ret1 = { 'name': self.FAKE_HOST, 'FCPaths': [{'wwn': '123456789054321'}, {'wwn': 'xxxxxxxxxxxxxxx'}]} getHost_ret2 = { 'name': self.FAKE_HOST, 'FCPaths': [{'wwn': '123456789012345'}, {'wwn': '123456789054321'}, {'wwn': 'xxxxxxxxxxxxxxx'}]} mock_client.getHost.side_effect = [getHost_ret1, getHost_ret2] with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() host = self.driver._create_host( common, self.volume, self.connector) expected = [ mock.call.getVolume('osv-0DM4qZEVSKON-DXN-NwVpw'), mock.call.getCPG(HP3PAR_CPG), mock.call.getHost('fakehost'), mock.call.modifyHost( 'fakehost', { 'FCWWNs': ['123456789012345'], 'pathOperation': 1}), mock.call.getHost('fakehost')] mock_client.assert_has_calls(expected) self.assertEqual(host['name'], self.FAKE_HOST) self.assertEqual(len(host['FCPaths']), 3) class TestHP3PARISCSIDriver(HP3PARBaseDriver, test.TestCase): TARGET_IQN = 'iqn.2000-05.com.3pardata:21810002ac00383d' TARGET_LUN = 186 properties = { 'driver_volume_type': 'iscsi', 'data': {'target_discovered': True, 'target_iqn': TARGET_IQN, 'target_lun': TARGET_LUN, 'target_portal': '1.1.1.2:1234'}} def setup_driver(self, config=None, mock_conf=None): self.ctxt = context.get_admin_context() mock_client = self.setup_mock_client( conf=config, m_conf=mock_conf, driver=hpdriver.HP3PARISCSIDriver) expected_get_cpgs = [ mock.call.getCPG(HP3PAR_CPG), mock.call.getCPG(HP3PAR_CPG2)] expected_get_ports = [mock.call.getPorts()] mock_client.assert_has_calls( self.standard_login + expected_get_cpgs + self.standard_logout + self.standard_login + expected_get_ports + self.standard_logout) mock_client.reset_mock() return mock_client def test_initialize_connection(self): # setup_mock_client drive with default configuration # and return the mock HTTP 3PAR client mock_client = self.setup_driver() mock_client.getVolume.return_value = {'userCPG': HP3PAR_CPG} mock_client.getCPG.return_value = {} mock_client.getHost.side_effect = [ hpexceptions.HTTPNotFound('fake'), {'name': self.FAKE_HOST}] mock_client.queryHost.return_value = { 'members': [{ 'name': self.FAKE_HOST }] } mock_client.getHostVLUNs.return_value = [ {'active': True, 'volumeName': self.VOLUME_3PAR_NAME, 'lun': self.TARGET_LUN, 'type': 0}] location = ("%(volume_name)s,%(lun_id)s,%(host)s,%(nsp)s" % {'volume_name': self.VOLUME_3PAR_NAME, 'lun_id': self.TARGET_LUN, 'host': self.FAKE_HOST, 'nsp': 'something'}) mock_client.createVLUN.return_value = location with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client result = self.driver.initialize_connection( self.volume, self.connector) expected = [ mock.call.getVolume(self.VOLUME_3PAR_NAME), mock.call.getCPG(HP3PAR_CPG), mock.call.getHost(self.FAKE_HOST), mock.call.queryHost(iqns=['iqn.1993-08.org.debian:01:222']), mock.call.getHost(self.FAKE_HOST), mock.call.createVLUN( self.VOLUME_3PAR_NAME, auto=True, hostname='fakehost', portPos={'node': 8, 'slot': 1, 'cardPort': 1}), mock.call.getHostVLUNs(self.FAKE_HOST)] mock_client.assert_has_calls( self.standard_login + expected + self.standard_logout) self.assertDictMatch(result, self.properties) def test_get_volume_stats(self): # setup_mock_client drive with default configuration # and return the mock HTTP 3PAR client mock_client = self.setup_driver() mock_client.getCPG.return_value = self.cpgs[0] mock_client.getStorageSystemInfo.return_value = { 'serialNumber': '1234' } # cpg has no limit mock_client.getCPGAvailableSpace.return_value = { "capacityEfficiency": {u'compaction': 594.4}, "rawFreeMiB": 1024.0 * 6, "usableFreeMiB": 1024.0 * 3 } with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client stats = self.driver.get_volume_stats(True) const = 0.0009765625 self.assertEqual(stats['storage_protocol'], 'iSCSI') self.assertEqual(stats['total_capacity_gb'], 0) self.assertEqual(stats['free_capacity_gb'], 0) self.assertEqual(stats['pools'][0]['total_capacity_gb'], 24.0) self.assertEqual(stats['pools'][0]['free_capacity_gb'], 3.0) expected = [ mock.call.getStorageSystemInfo(), mock.call.getCPG(HP3PAR_CPG), mock.call.getCPGAvailableSpace(HP3PAR_CPG), mock.call.getCPG(HP3PAR_CPG2), mock.call.getCPGAvailableSpace(HP3PAR_CPG2)] mock_client.assert_has_calls( self.standard_login + expected + self.standard_logout) cpg2 = self.cpgs[0].copy() cpg2.update({'SDGrowth': {'limitMiB': 8192}}) mock_client.getCPG.return_value = cpg2 stats = self.driver.get_volume_stats(True) self.assertEqual(stats['storage_protocol'], 'iSCSI') total_capacity_gb = 8192 * const self.assertEqual(stats['total_capacity_gb'], 0) self.assertEqual(stats['pools'][0]['total_capacity_gb'], total_capacity_gb) free_capacity_gb = int( (8192 - self.cpgs[0]['UsrUsage']['usedMiB']) * const) self.assertEqual(stats['free_capacity_gb'], 0) self.assertEqual(stats['pools'][0]['free_capacity_gb'], free_capacity_gb) def test_create_host(self): # setup_mock_client drive with default configuration # and return the mock HTTP 3PAR client mock_client = self.setup_driver() mock_client.getVolume.return_value = {'userCPG': HP3PAR_CPG} mock_client.getCPG.return_value = {} mock_client.getHost.side_effect = [ hpexceptions.HTTPNotFound('fake'), {'name': self.FAKE_HOST}] mock_client.queryHost.return_value = None mock_client.getVLUN.return_value = {'lun': self.TARGET_LUN} with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() host, auth_username, auth_password = self.driver._create_host( common, self.volume, self.connector) expected = [ mock.call.getVolume('osv-0DM4qZEVSKON-DXN-NwVpw'), mock.call.getCPG(HP3PAR_CPG), mock.call.getHost(self.FAKE_HOST), mock.call.queryHost(iqns=['iqn.1993-08.org.debian:01:222']), mock.call.createHost( self.FAKE_HOST, optional={'domain': None, 'persona': 2}, iscsiNames=['iqn.1993-08.org.debian:01:222']), mock.call.getHost(self.FAKE_HOST)] mock_client.assert_has_calls(expected) self.assertEqual(host['name'], self.FAKE_HOST) self.assertEqual(auth_username, None) self.assertEqual(auth_password, None) def test_create_host_chap_enabled(self): # setup_mock_client drive with CHAP enabled configuration # and return the mock HTTP 3PAR client config = self.setup_configuration() config.hp3par_iscsi_chap_enabled = True mock_client = self.setup_driver(config=config) mock_client.getVolume.return_value = {'userCPG': HP3PAR_CPG} mock_client.getCPG.return_value = {} mock_client.getHost.side_effect = [ hpexceptions.HTTPNotFound('fake'), {'name': self.FAKE_HOST}] mock_client.queryHost.return_value = None mock_client.getVLUN.return_value = {'lun': self.TARGET_LUN} expected_mod_request = { 'chapOperation': mock_client.HOST_EDIT_ADD, 'chapOperationMode': mock_client.CHAP_INITIATOR, 'chapName': 'test-user', 'chapSecret': 'test-pass' } def get_side_effect(*args): data = {'value': None} if args[1] == CHAP_USER_KEY: data['value'] = 'test-user' elif args[1] == CHAP_PASS_KEY: data['value'] = 'test-pass' return data mock_client.getVolumeMetaData.side_effect = get_side_effect with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() host, auth_username, auth_password = self.driver._create_host( common, self.volume, self.connector) expected = [ mock.call.getVolume('osv-0DM4qZEVSKON-DXN-NwVpw'), mock.call.getCPG(HP3PAR_CPG), mock.call.getVolumeMetaData( 'osv-0DM4qZEVSKON-DXN-NwVpw', CHAP_USER_KEY), mock.call.getVolumeMetaData( 'osv-0DM4qZEVSKON-DXN-NwVpw', CHAP_PASS_KEY), mock.call.getHost(self.FAKE_HOST), mock.call.queryHost(iqns=['iqn.1993-08.org.debian:01:222']), mock.call.createHost( self.FAKE_HOST, optional={'domain': None, 'persona': 2}, iscsiNames=['iqn.1993-08.org.debian:01:222']), mock.call.modifyHost( 'fakehost', expected_mod_request), mock.call.getHost(self.FAKE_HOST) ] mock_client.assert_has_calls(expected) self.assertEqual(host['name'], self.FAKE_HOST) self.assertEqual(auth_username, 'test-user') self.assertEqual(auth_password, 'test-pass') def test_create_invalid_host(self): # setup_mock_client drive with default configuration # and return the mock HTTP 3PAR client mock_client = self.setup_driver() mock_client.getVolume.return_value = {'userCPG': HP3PAR_CPG} mock_client.getCPG.return_value = {} mock_client.getHost.side_effect = [ hpexceptions.HTTPNotFound('Host not found.'), {'name': 'fakehost.foo'}] mock_client.queryHost.return_value = { 'members': [{ 'name': 'fakehost.foo' }] } with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() host, auth_username, auth_password = self.driver._create_host( common, self.volume, self.connector) expected = [ mock.call.getVolume('osv-0DM4qZEVSKON-DXN-NwVpw'), mock.call.getCPG(HP3PAR_CPG), mock.call.getHost(self.FAKE_HOST), mock.call.queryHost(iqns=['iqn.1993-08.org.debian:01:222']), mock.call.getHost('fakehost.foo')] mock_client.assert_has_calls(expected) self.assertEqual(host['name'], 'fakehost.foo') self.assertEqual(auth_username, None) self.assertEqual(auth_password, None) def test_create_invalid_host_chap_enabled(self): # setup_mock_client drive with CHAP enabled configuration # and return the mock HTTP 3PAR client config = self.setup_configuration() config.hp3par_iscsi_chap_enabled = True mock_client = self.setup_driver(config=config) mock_client.getVolume.return_value = {'userCPG': HP3PAR_CPG} mock_client.getCPG.return_value = {} mock_client.getHost.side_effect = [ hpexceptions.HTTPNotFound('Host not found.'), {'name': 'fakehost.foo'}] mock_client.queryHost.return_value = { 'members': [{ 'name': 'fakehost.foo' }] } def get_side_effect(*args): data = {'value': None} if args[1] == CHAP_USER_KEY: data['value'] = 'test-user' elif args[1] == CHAP_PASS_KEY: data['value'] = 'test-pass' return data mock_client.getVolumeMetaData.side_effect = get_side_effect expected_mod_request = { 'chapOperation': mock_client.HOST_EDIT_ADD, 'chapOperationMode': mock_client.CHAP_INITIATOR, 'chapName': 'test-user', 'chapSecret': 'test-pass' } with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() host, auth_username, auth_password = self.driver._create_host( common, self.volume, self.connector) expected = [ mock.call.getVolume('osv-0DM4qZEVSKON-DXN-NwVpw'), mock.call.getCPG(HP3PAR_CPG), mock.call.getVolumeMetaData( 'osv-0DM4qZEVSKON-DXN-NwVpw', CHAP_USER_KEY), mock.call.getVolumeMetaData( 'osv-0DM4qZEVSKON-DXN-NwVpw', CHAP_PASS_KEY), mock.call.getHost(self.FAKE_HOST), mock.call.queryHost(iqns=['iqn.1993-08.org.debian:01:222']), mock.call.modifyHost( 'fakehost.foo', expected_mod_request), mock.call.getHost('fakehost.foo') ] mock_client.assert_has_calls(expected) self.assertEqual(host['name'], 'fakehost.foo') self.assertEqual(auth_username, 'test-user') self.assertEqual(auth_password, 'test-pass') def test_create_modify_host(self): # setup_mock_client drive with default configuration # and return the mock HTTP 3PAR client mock_client = self.setup_driver() mock_client.getVolume.return_value = {'userCPG': HP3PAR_CPG} mock_client.getCPG.return_value = {} mock_client.getHost.side_effect = [ {'name': self.FAKE_HOST, 'FCPaths': []}, {'name': self.FAKE_HOST, 'FCPaths': [{'wwn': '123456789012345'}, {'wwn': '123456789054321'}]}] with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() host, auth_username, auth_password = self.driver._create_host( common, self.volume, self.connector) expected = [ mock.call.getVolume('osv-0DM4qZEVSKON-DXN-NwVpw'), mock.call.getCPG(HP3PAR_CPG), mock.call.getHost(self.FAKE_HOST), mock.call.modifyHost( self.FAKE_HOST, {'pathOperation': 1, 'iSCSINames': ['iqn.1993-08.org.debian:01:222']}), mock.call.getHost(self.FAKE_HOST)] mock_client.assert_has_calls(expected) self.assertEqual(host['name'], self.FAKE_HOST) self.assertEqual(auth_username, None) self.assertEqual(auth_password, None) self.assertEqual(len(host['FCPaths']), 2) def test_create_modify_host_chap_enabled(self): # setup_mock_client drive with CHAP enabled configuration # and return the mock HTTP 3PAR client config = self.setup_configuration() config.hp3par_iscsi_chap_enabled = True mock_client = self.setup_driver(config=config) mock_client.getVolume.return_value = {'userCPG': HP3PAR_CPG} mock_client.getCPG.return_value = {} mock_client.getHost.side_effect = [ {'name': self.FAKE_HOST, 'FCPaths': []}, {'name': self.FAKE_HOST, 'FCPaths': [{'wwn': '123456789012345'}, {'wwn': '123456789054321'}]}] def get_side_effect(*args): data = {'value': None} if args[1] == CHAP_USER_KEY: data['value'] = 'test-user' elif args[1] == CHAP_PASS_KEY: data['value'] = 'test-pass' return data mock_client.getVolumeMetaData.side_effect = get_side_effect expected_mod_request = { 'chapOperation': mock_client.HOST_EDIT_ADD, 'chapOperationMode': mock_client.CHAP_INITIATOR, 'chapName': 'test-user', 'chapSecret': 'test-pass' } with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() host, auth_username, auth_password = self.driver._create_host( common, self.volume, self.connector) expected = [ mock.call.getVolume('osv-0DM4qZEVSKON-DXN-NwVpw'), mock.call.getCPG(HP3PAR_CPG), mock.call.getVolumeMetaData( 'osv-0DM4qZEVSKON-DXN-NwVpw', CHAP_USER_KEY), mock.call.getVolumeMetaData( 'osv-0DM4qZEVSKON-DXN-NwVpw', CHAP_PASS_KEY), mock.call.getHost(self.FAKE_HOST), mock.call.modifyHost( self.FAKE_HOST, {'pathOperation': 1, 'iSCSINames': ['iqn.1993-08.org.debian:01:222']}), mock.call.modifyHost( self.FAKE_HOST, expected_mod_request ), mock.call.getHost(self.FAKE_HOST)] mock_client.assert_has_calls(expected) self.assertEqual(host['name'], self.FAKE_HOST) self.assertEqual(auth_username, 'test-user') self.assertEqual(auth_password, 'test-pass') self.assertEqual(len(host['FCPaths']), 2) def test_get_least_used_nsp_for_host_single(self): # setup_mock_client drive with default configuration # and return the mock HTTP 3PAR client mock_client = self.setup_driver() mock_client.getPorts.return_value = PORTS_RET mock_client.getVLUNs.return_value = VLUNS1_RET with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() #Setup a single ISCSI IP iscsi_ips = ["10.10.220.253"] self.driver.configuration.hp3par_iscsi_ips = iscsi_ips self.driver.initialize_iscsi_ports(common) nsp = self.driver._get_least_used_nsp_for_host(common, 'newhost') self.assertEqual(nsp, "1:8:1") def test_get_least_used_nsp_for_host_new(self): # setup_mock_client drive with default configuration # and return the mock HTTP 3PAR client mock_client = self.setup_driver() mock_client.getPorts.return_value = PORTS_RET mock_client.getVLUNs.return_value = VLUNS1_RET with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() #Setup two ISCSI IPs iscsi_ips = ["10.10.220.252", "10.10.220.253"] self.driver.configuration.hp3par_iscsi_ips = iscsi_ips self.driver.initialize_iscsi_ports(common) # Host 'newhost' does not yet have any iscsi paths, # so the 'least used' is returned nsp = self.driver._get_least_used_nsp_for_host(common, 'newhost') self.assertEqual(nsp, "1:8:2") def test_get_least_used_nsp_for_host_reuse(self): # setup_mock_client drive with default configuration # and return the mock HTTP 3PAR client mock_client = self.setup_driver() mock_client.getPorts.return_value = PORTS_RET mock_client.getVLUNs.return_value = VLUNS1_RET with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() #Setup two ISCSI IPs iscsi_ips = ["10.10.220.252", "10.10.220.253"] self.driver.configuration.hp3par_iscsi_ips = iscsi_ips self.driver.initialize_iscsi_ports(common) # hosts 'foo' and 'bar' already have active iscsi paths # the same one should be used nsp = self.driver._get_least_used_nsp_for_host(common, 'foo') self.assertEqual(nsp, "1:8:2") nsp = self.driver._get_least_used_nsp_for_host(common, 'bar') self.assertEqual(nsp, "1:8:1") def test_get_least_used_nps_for_host_fc(self): # setup_mock_client drive with default configuration # and return the mock HTTP 3PAR client mock_client = self.setup_driver() mock_client.getPorts.return_value = PORTS1_RET mock_client.getVLUNs.return_value = VLUNS5_RET #Setup two ISCSI IPs iscsi_ips = ["10.10.220.252", "10.10.220.253"] self.driver.configuration.hp3par_iscsi_ips = iscsi_ips with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() self.driver.initialize_iscsi_ports(common) nsp = self.driver._get_least_used_nsp_for_host(common, 'newhost') self.assertNotEqual(nsp, "0:6:3") self.assertEqual(nsp, "1:8:1") def test_invalid_iscsi_ip(self): config = self.setup_configuration() config.hp3par_iscsi_ips = ['10.10.220.250', '10.10.220.251'] config.iscsi_ip_address = '10.10.10.10' mock_conf = { 'getPorts.return_value': { 'members': [ {'portPos': {'node': 1, 'slot': 8, 'cardPort': 2}, 'protocol': 2, 'IPAddr': '10.10.220.252', 'linkState': 4, 'device': [], 'iSCSIName': self.TARGET_IQN, 'mode': 2, 'HWAddr': '2C27D75375D2', 'type': 8}, {'portPos': {'node': 1, 'slot': 8, 'cardPort': 1}, 'protocol': 2, 'IPAddr': '10.10.220.253', 'linkState': 4, 'device': [], 'iSCSIName': self.TARGET_IQN, 'mode': 2, 'HWAddr': '2C27D75375D6', 'type': 8}]}} # no valid ip addr should be configured. self.assertRaises(exception.InvalidInput, self.setup_driver, config=config, mock_conf=mock_conf) def test_get_least_used_nsp(self): # setup_mock_client drive with default configuration # and return the mock HTTP 3PAR client mock_client = self.setup_driver() ports = [ {'portPos': {'node': 1, 'slot': 8, 'cardPort': 2}, 'active': True}, {'portPos': {'node': 1, 'slot': 8, 'cardPort': 1}, 'active': True}, {'portPos': {'node': 1, 'slot': 8, 'cardPort': 2}, 'active': True}, {'portPos': {'node': 0, 'slot': 2, 'cardPort': 2}, 'active': True}, {'portPos': {'node': 0, 'slot': 2, 'cardPort': 1}, 'active': True}, {'portPos': {'node': 0, 'slot': 2, 'cardPort': 1}, 'active': True}, {'portPos': {'node': 0, 'slot': 2, 'cardPort': 1}, 'active': True}, {'portPos': {'node': 0, 'slot': 2, 'cardPort': 1}, 'active': True}] mock_client.getVLUNs.return_value = {'members': ports} with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() # in use count vluns = common.client.getVLUNs() nsp = self.driver._get_least_used_nsp(common, vluns['members'], ['0:2:1', '1:8:1']) self.assertEqual(nsp, '1:8:1') ports = [ {'portPos': {'node': 1, 'slot': 2, 'cardPort': 1}, 'active': True}, {'portPos': {'node': 1, 'slot': 2, 'cardPort': 1}, 'active': True}, {'portPos': {'node': 1, 'slot': 2, 'cardPort': 1}, 'active': True}, {'portPos': {'node': 1, 'slot': 2, 'cardPort': 1}, 'active': True}, {'portPos': {'node': 0, 'slot': 2, 'cardPort': 1}, 'active': True}, {'portPos': {'node': 0, 'slot': 2, 'cardPort': 1}, 'active': True}, {'portPos': {'node': 0, 'slot': 2, 'cardPort': 1}, 'active': True}, {'portPos': {'node': 0, 'slot': 2, 'cardPort': 1}, 'active': True}, {'portPos': {'node': 0, 'slot': 2, 'cardPort': 1}, 'active': True}] mock_client.getVLUNs.return_value = {'members': ports} # in use count common = self.driver._login() vluns = common.client.getVLUNs() nsp = self.driver._get_least_used_nsp(common, vluns['members'], ['0:2:1', '1:2:1']) self.assertEqual(nsp, '1:2:1') ports = [ {'portPos': {'node': 1, 'slot': 2, 'cardPort': 1}, 'active': True}, {'portPos': {'node': 1, 'slot': 2, 'cardPort': 1}, 'active': True}, {'portPos': {'node': 1, 'slot': 2, 'cardPort': 1}, 'active': True}, {'portPos': {'node': 1, 'slot': 2, 'cardPort': 1}, 'active': True}, {'portPos': {'node': 0, 'slot': 2, 'cardPort': 1}, 'active': True}, {'portPos': {'node': 0, 'slot': 2, 'cardPort': 1}, 'active': True}, {'portPos': {'node': 0, 'slot': 2, 'cardPort': 1}, 'active': True}, {'portPos': {'node': 0, 'slot': 2, 'cardPort': 1}, 'active': True}, {'portPos': {'node': 0, 'slot': 2, 'cardPort': 1}, 'active': True}] mock_client.getVLUNs.return_value = {'members': ports} # in use count common = self.driver._login() vluns = common.client.getVLUNs() nsp = self.driver._get_least_used_nsp(common, vluns['members'], ['1:1:1', '1:2:1']) self.assertEqual(nsp, '1:1:1') def test_set_3par_chaps(self): # setup_mock_client drive with default configuration # and return the mock HTTP 3PAR client mock_client = self.setup_driver() with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() expected = [] self.driver._set_3par_chaps( common, 'test-host', 'test-vol', 'test-host', 'pass') mock_client.assert_has_calls(expected) # setup_mock_client drive with CHAP enabled configuration # and return the mock HTTP 3PAR client config = self.setup_configuration() config.hp3par_iscsi_chap_enabled = True mock_client = self.setup_driver(config=config) with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() expected_mod_request = { 'chapOperation': mock_client.HOST_EDIT_ADD, 'chapOperationMode': mock_client.CHAP_INITIATOR, 'chapName': 'test-host', 'chapSecret': 'fake' } expected = [ mock.call.modifyHost('test-host', expected_mod_request) ] self.driver._set_3par_chaps( common, 'test-host', 'test-vol', 'test-host', 'fake') mock_client.assert_has_calls(expected) @mock.patch('cinder.volume.utils.generate_password') def test_do_export(self, mock_utils): # setup_mock_client drive with default configuration # and return the mock HTTP 3PAR client mock_client = self.setup_driver() volume = {'host': 'test-host@3pariscsi', 'id': 'd03338a9-9115-48a3-8dfc-35cdfcdc15a7'} mock_utils.return_value = 'random-pass' mock_client.getHostVLUNs.return_value = [ {'active': True, 'volumeName': self.VOLUME_3PAR_NAME, 'lun': None, 'type': 0, 'remoteName': 'iqn.1993-08.org.debian:01:222'} ] mock_client.getHost.return_value = { 'name': 'osv-0DM4qZEVSKON-DXN-NwVpw', 'initiatorChapEnabled': True } mock_client.getVolumeMetaData.return_value = { 'value': 'random-pass' } expected = [] expected_model = {'provider_auth': None} with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() model = self.driver._do_export(common, volume) mock_client.assert_has_calls(expected) self.assertEqual(expected_model, model) mock_client.reset_mock() # setup_mock_client drive with CHAP enabled configuration # and return the mock HTTP 3PAR client config = self.setup_configuration() config.hp3par_iscsi_chap_enabled = True mock_client = self.setup_driver(config=config) volume = {'host': 'test-host@3pariscsi', 'id': 'd03338a9-9115-48a3-8dfc-35cdfcdc15a7'} mock_utils.return_value = 'random-pass' mock_client.getHostVLUNs.return_value = [ {'active': True, 'volumeName': self.VOLUME_3PAR_NAME, 'lun': None, 'type': 0, 'remoteName': 'iqn.1993-08.org.debian:01:222'} ] mock_client.getHost.return_value = { 'name': 'osv-0DM4qZEVSKON-DXN-NwVpw', 'initiatorChapEnabled': True } mock_client.getVolumeMetaData.return_value = { 'value': 'random-pass' } expected = [ mock.call.getHostVLUNs('test-host'), mock.call.getHost('test-host'), mock.call.getVolumeMetaData( 'osv-0DM4qZEVSKON-DXN-NwVpw', CHAP_PASS_KEY), mock.call.setVolumeMetaData( 'osv-0DM4qZEVSKON-DXN-NwVpw', CHAP_USER_KEY, 'test-host'), mock.call.setVolumeMetaData( 'osv-0DM4qZEVSKON-DXN-NwVpw', CHAP_PASS_KEY, 'random-pass') ] expected_model = {'provider_auth': 'CHAP test-host random-pass'} with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() model = self.driver._do_export(common, volume) mock_client.assert_has_calls(expected) self.assertEqual(expected_model, model) @mock.patch('cinder.volume.utils.generate_password') def test_do_export_host_not_found(self, mock_utils): # setup_mock_client drive with CHAP enabled configuration # and return the mock HTTP 3PAR client config = self.setup_configuration() config.hp3par_iscsi_chap_enabled = True mock_client = self.setup_driver(config=config) volume = {'host': 'test-host@3pariscsi', 'id': 'd03338a9-9115-48a3-8dfc-35cdfcdc15a7'} mock_utils.return_value = "random-pass" mock_client.getHostVLUNs.side_effect = hpexceptions.HTTPNotFound( 'fake') mock_client.getVolumeMetaData.return_value = { 'value': 'random-pass' } expected = [ mock.call.getHostVLUNs('test-host'), mock.call.setVolumeMetaData( 'osv-0DM4qZEVSKON-DXN-NwVpw', CHAP_USER_KEY, 'test-host'), mock.call.setVolumeMetaData( 'osv-0DM4qZEVSKON-DXN-NwVpw', CHAP_PASS_KEY, 'random-pass') ] expected_model = {'provider_auth': 'CHAP test-host random-pass'} with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() model = self.driver._do_export(common, volume) mock_client.assert_has_calls(expected) self.assertEqual(expected_model, model) @mock.patch('cinder.volume.utils.generate_password') def test_do_export_host_chap_disabled(self, mock_utils): # setup_mock_client drive with CHAP enabled configuration # and return the mock HTTP 3PAR client config = self.setup_configuration() config.hp3par_iscsi_chap_enabled = True mock_client = self.setup_driver(config=config) volume = {'host': 'test-host@3pariscsi', 'id': 'd03338a9-9115-48a3-8dfc-35cdfcdc15a7'} mock_utils.return_value = 'random-pass' mock_client.getHostVLUNs.return_value = [ {'active': True, 'volumeName': self.VOLUME_3PAR_NAME, 'lun': None, 'type': 0, 'remoteName': 'iqn.1993-08.org.debian:01:222'} ] mock_client.getHost.return_value = { 'name': 'fake-host', 'initiatorChapEnabled': False } mock_client.getVolumeMetaData.return_value = { 'value': 'random-pass' } expected = [ mock.call.getHostVLUNs('test-host'), mock.call.getHost('test-host'), mock.call.getVolumeMetaData( 'osv-0DM4qZEVSKON-DXN-NwVpw', CHAP_PASS_KEY), mock.call.setVolumeMetaData( 'osv-0DM4qZEVSKON-DXN-NwVpw', CHAP_USER_KEY, 'test-host'), mock.call.setVolumeMetaData( 'osv-0DM4qZEVSKON-DXN-NwVpw', CHAP_PASS_KEY, 'random-pass') ] expected_model = {'provider_auth': 'CHAP test-host random-pass'} with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() model = self.driver._do_export(common, volume) mock_client.assert_has_calls(expected) self.assertEqual(expected_model, model) @mock.patch('cinder.volume.utils.generate_password') def test_do_export_no_active_vluns(self, mock_utils): # setup_mock_client drive with CHAP enabled configuration # and return the mock HTTP 3PAR client config = self.setup_configuration() config.hp3par_iscsi_chap_enabled = True mock_client = self.setup_driver(config=config) volume = {'host': 'test-host@3pariscsi', 'id': 'd03338a9-9115-48a3-8dfc-35cdfcdc15a7'} mock_utils.return_value = "random-pass" mock_client.getHostVLUNs.return_value = [ {'active': False, 'volumeName': self.VOLUME_3PAR_NAME, 'lun': None, 'type': 0, 'remoteName': 'iqn.1993-08.org.debian:01:222'} ] mock_client.getHost.return_value = { 'name': 'fake-host', 'initiatorChapEnabled': True } mock_client.getVolumeMetaData.return_value = { 'value': 'random-pass' } expected = [ mock.call.getHostVLUNs('test-host'), mock.call.getHost('test-host'), mock.call.setVolumeMetaData( 'osv-0DM4qZEVSKON-DXN-NwVpw', CHAP_USER_KEY, 'test-host'), mock.call.setVolumeMetaData( 'osv-0DM4qZEVSKON-DXN-NwVpw', CHAP_PASS_KEY, 'random-pass') ] expected_model = {'provider_auth': 'CHAP test-host random-pass'} with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() model = self.driver._do_export(common, volume) mock_client.assert_has_calls(expected) self.assertEqual(model, expected_model) def test_ensure_export(self): # setup_mock_client drive with default configuration # and return the mock HTTP 3PAR client mock_client = self.setup_driver() volume = {'host': 'test-host@3pariscsi', 'id': 'd03338a9-9115-48a3-8dfc-35cdfcdc15a7'} mock_client.getAllVolumeMetaData.return_value = { 'total': 0, 'members': [] } with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client model = self.driver.ensure_export(None, volume) expected = [ mock.call.getVolume('osv-0DM4qZEVSKON-DXN-NwVpw'), mock.call.getAllVolumeMetaData('osv-0DM4qZEVSKON-DXN-NwVpw') ] expected_model = {'provider_auth': None} mock_client.assert_has_calls( self.standard_login + expected + self.standard_logout) self.assertEqual(model, expected_model) mock_client.getAllVolumeMetaData.return_value = { 'total': 2, 'members': [ { 'creationTimeSec': 1406074222, 'value': 'fake-host', 'key': CHAP_USER_KEY, 'creationTime8601': '2014-07-22T17:10:22-07:00' }, { 'creationTimeSec': 1406074222, 'value': 'random-pass', 'key': CHAP_PASS_KEY, 'creationTime8601': '2014-07-22T17:10:22-07:00' } ] } model = self.driver.ensure_export(None, volume) expected = [ mock.call.getVolume('osv-0DM4qZEVSKON-DXN-NwVpw'), mock.call.getAllVolumeMetaData('osv-0DM4qZEVSKON-DXN-NwVpw') ] expected_model = {'provider_auth': "CHAP fake-host random-pass"} mock_client.assert_has_calls( self.standard_login + expected + self.standard_logout) self.assertEqual(model, expected_model) def test_ensure_export_missing_volume(self): # setup_mock_client drive with default configuration # and return the mock HTTP 3PAR client mock_client = self.setup_driver() volume = {'host': 'test-host@3pariscsi', 'id': 'd03338a9-9115-48a3-8dfc-35cdfcdc15a7'} mock_client.getVolume.side_effect = hpexceptions.HTTPNotFound( 'fake') with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client model = self.driver.ensure_export(None, volume) expected = [mock.call.getVolume('osv-0DM4qZEVSKON-DXN-NwVpw')] expected_model = None mock_client.assert_has_calls( self.standard_login + expected + self.standard_logout) self.assertEqual(model, expected_model) @mock.patch.object(volume_types, 'get_volume_type') def test_get_volume_settings_default_pool(self, _mock_volume_types): _mock_volume_types.return_value = { 'name': 'gold', 'id': 'gold-id', 'extra_specs': {}} mock_client = self.setup_driver() with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() volume = {'host': 'test-host@3pariscsi#pool_foo', 'id': 'd03338a9-9115-48a3-8dfc-35cdfcdc15a7'} pool = volume_utils.extract_host(volume['host'], 'pool') model = common.get_volume_settings_from_type_id('gold-id', pool) self.assertEqual(model['cpg'], 'pool_foo') def test_get_model_update(self): mock_client = self.setup_driver() with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\ as mock_create_client: mock_create_client.return_value = mock_client common = self.driver._login() model_update = common._get_model_update('xxx@yyy#zzz', 'CPG') self.assertEqual(model_update, {'host': 'xxx@yyy#CPG'}) VLUNS5_RET = ({'members': [{'portPos': {'node': 0, 'slot': 8, 'cardPort': 2}, 'active': True}, {'portPos': {'node': 1, 'slot': 8, 'cardPort': 1}, 'active': True}]}) PORTS_RET = ({'members': [{'portPos': {'node': 1, 'slot': 8, 'cardPort': 2}, 'protocol': 2, 'IPAddr': '10.10.220.252', 'linkState': 4, 'device': [], 'iSCSIName': 'iqn.2000-05.com.3pardata:21820002ac00383d', 'mode': 2, 'HWAddr': '2C27D75375D2', 'type': 8}, {'portPos': {'node': 1, 'slot': 8, 'cardPort': 1}, 'protocol': 2, 'IPAddr': '10.10.220.253', 'linkState': 4, 'device': [], 'iSCSIName': 'iqn.2000-05.com.3pardata:21810002ac00383d', 'mode': 2, 'HWAddr': '2C27D75375D6', 'type': 8}]}) VLUNS1_RET = ({'members': [{'portPos': {'node': 1, 'slot': 8, 'cardPort': 2}, 'hostname': 'foo', 'active': True}, {'portPos': {'node': 1, 'slot': 8, 'cardPort': 1}, 'hostname': 'bar', 'active': True}, {'portPos': {'node': 1, 'slot': 8, 'cardPort': 1}, 'hostname': 'bar', 'active': True}, {'portPos': {'node': 1, 'slot': 8, 'cardPort': 1}, 'hostname': 'bar', 'active': True}]}) PORTS1_RET = ({'members': [{'portPos': {'node': 0, 'slot': 8, 'cardPort': 2}, 'protocol': 2, 'IPAddr': '10.10.120.252', 'linkState': 4, 'device': [], 'iSCSIName': 'iqn.2000-05.com.3pardata:21820002ac00383d', 'mode': 2, 'HWAddr': '2C27D75375D2', 'type': 8}, {'portPos': {'node': 1, 'slot': 8, 'cardPort': 1}, 'protocol': 2, 'IPAddr': '10.10.220.253', 'linkState': 4, 'device': [], 'iSCSIName': 'iqn.2000-05.com.3pardata:21810002ac00383d', 'mode': 2, 'HWAddr': '2C27D75375D6', 'type': 8}, {'portWWN': '20210002AC00383D', 'protocol': 1, 'linkState': 4, 'mode': 2, 'device': ['cage2'], 'nodeWWN': '20210002AC00383D', 'type': 2, 'portPos': {'node': 0, 'slot': 6, 'cardPort': 3}}]})
527ab3f5e0e2ee94f044e89480b14ae779c9d6ae
b87b80f29d0012827582890d6e47ec98f85376a5
/prediction-models/app.py
151dc0fe2b45c3559a1822c92234f2fab0d2ebee
[]
no_license
amlannandy/FitnessLive
843058a6b84029fc91ef53d0731804b715ceaf19
8514520c00804a42c5e46fc4dbdaff57de56a591
refs/heads/master
2023-03-08T02:02:22.036686
2021-02-19T07:43:20
2021-02-19T07:43:20
331,222,344
0
0
null
2021-02-19T06:36:59
2021-01-20T07:07:45
Dart
UTF-8
Python
false
false
1,484
py
from flask import Flask, jsonify, request from scripts.chd import run_chd_model from scripts.diabetes import run_diabetes_model app = Flask(__name__) @app.route('/') def home(): return 'Flask server is working!', 200 @app.route('/diabetes', methods=['POST']) def run_diabetes(): try: data = request.get_json() except: response = { 'success': False, 'msg': 'Health data missing', } return jsonify(response), 400 try: glucose = data['glucose'] blood_pressure = data['bloodPressure'] res = run_diabetes_model(glucose, blood_pressure) response = { 'success': True, 'result': res, } return jsonify(response), 200 except: response = { 'success': False, 'msg': 'Server Error' } return jsonify(response), 500 @app.route('/coronary-heart-disease', methods=['POST']) def run_chd(): try: data = request.get_json() except: response = { 'success': False, 'msg': 'Health data missing', } return jsonify(response), 400 try: res = run_chd_model() response = { 'success': True, 'result': res, } return jsonify(response), 200 except: response = { 'success': False, 'msg': 'Server Error' } return jsonify(response), 500
ec558fecae74fcd4bc138c1706c2befffa2bf1a1
0abd5799f42e169ecd7eb25970d32121cd483bfd
/xpdtools/pipelines/save_tiff.py
c0682d205300daa24f1e67311d1d99acbf40bd0f
[]
no_license
CJ-Wright/xpdtools
7ecede857d8e7b91e58861b064c53d5ab88ef540
680c79bb30d7b58c9ed03eb286b5a438161c39df
refs/heads/master
2021-06-24T07:14:04.308324
2017-12-05T18:54:50
2017-12-05T18:54:50
113,220,820
0
0
null
2017-12-05T18:55:09
2017-12-05T18:55:09
null
UTF-8
Python
false
false
7,878
py
"""Save tiff pipeline""" import os from operator import sub import shed.event_streams as es import tifffile from shed.event_streams import star from bluesky.callbacks.broker import LiveImage from streamz import Stream from xpdan.db_utils import query_dark, temporal_prox from xpdan.dev_utils import _timestampstr from xpdan.formatters import render_and_clean from xpdan.io import dump_yml from xpdan.pipelines.pipeline_utils import (if_dark, base_template) _s = set() # TODO: refactor templating def conf_save_tiff_pipeline(db, save_dir, *, write_to_disk=False, vis=True, image_data_key='pe1_image'): """Total data processing pipeline for XPD Parameters ---------- db: databroker.broker.Broker instance The databroker holding the data, this must be specified as a `db=` in the function call (keyword only argument) write_to_disk: bool, optional If True write files to disk, defaults to False save_dir: str The folder in which to save the data, this must be specified as a `save_dir=` in the function call (keyword only argument) vis: bool, optional If True visualize the data. Defaults to False image_data_key: str, optional The key for the image data, defaults to `pe1_image` Returns ------- source: Stream The source for the graph See also -------- xpdan.tools.mask_img """ print('start pipeline configuration') light_template = os.path.join(save_dir, base_template) raw_source = Stream(stream_name='Raw Data') # raw data source = es.fill_events(db, raw_source) # filled raw data # DARK PROCESSING # if not dark do dark subtraction if_not_dark_stream = es.filter(lambda x: not if_dark(x), source, input_info={0: ((), 0)}, document_name='start', stream_name='If not dark', full_event=True) eventify_raw_start = es.Eventify(if_not_dark_stream, stream_name='eventify raw start') h_timestamp_stream = es.map(_timestampstr, if_not_dark_stream, input_info={0: 'time'}, output_info=[('human_timestamp', {'dtype': 'str'})], full_event=True, stream_name='human timestamp') # only the primary stream if_not_dark_stream_primary = es.filter(lambda x: x[0]['name'] == 'primary', if_not_dark_stream, document_name='descriptor', stream_name='Primary') dark_query = es.Query(db, if_not_dark_stream, query_function=query_dark, query_decider=temporal_prox, stream_name='Query for FG Dark') dark_query_results = es.QueryUnpacker(db, dark_query, stream_name='Unpack FG Dark') # Do the dark subtraction zlid = es.zip_latest(if_not_dark_stream_primary, dark_query_results, stream_name='Combine darks and lights') dark_sub_fg = es.map(sub, zlid, input_info={0: (image_data_key, 0), 1: (image_data_key, 1)}, output_info=[('img', {'dtype': 'array', 'source': 'testing'})], md=dict(stream_name='Dark Subtracted Foreground', analysis_stage='dark_sub')) if vis: dark_sub_fg.sink(star(LiveImage('img'))) if write_to_disk: eventify_raw_descriptor = es.Eventify( if_not_dark_stream, stream_name='eventify raw descriptor', document='descriptor') exts = ['.tiff'] eventify_input_streams = [dark_sub_fg] input_infos = [ {'data': ('img', 0), 'file': ('filename', 1)}, ] saver_kwargs = [{}] eventifies = [es.Eventify( s, stream_name='eventify {}'.format(s.stream_name)) for s in eventify_input_streams] mega_render = [ es.map(render_and_clean, es.zip_latest( es.zip(h_timestamp_stream, # human readable event timestamp if_not_dark_stream, # raw events, stream_name='mega_render zip' ), eventify_raw_start, eventify_raw_descriptor, analysed_eventify ), string=light_template, input_info={ 'human_timestamp': (('data', 'human_timestamp'), 0), 'raw_event': ((), 1), 'raw_start': (('data',), 2), 'raw_descriptor': (('data',), 3), 'analyzed_start': (('data',), 4) }, ext=ext, full_event=True, output_info=[('filename', {'dtype': 'str'})], stream_name='mega render ' '{}'.format(analysed_eventify.stream_name) ) for ext, analysed_eventify in zip(exts, eventifies)] streams_to_be_saved = [dark_sub_fg] save_callables = [tifffile.imsave] md_render = es.map(render_and_clean, eventify_raw_start, string=light_template, input_info={'raw_start': (('data',), 0), }, output_info=[('filename', {'dtype': 'str'})], ext='.yml', full_event=True, stream_name='MD render') make_dirs = [es.map(lambda x: os.makedirs(os.path.split(x)[0], exist_ok=True), cs, input_info={0: 'filename'}, output_info=[('filename', {'dtype': 'str'})], stream_name='Make dirs {}'.format(cs.stream_name) ) for cs in mega_render] _s.update([es.map(writer_templater, es.zip_latest( es.zip(s1, s2, stream_name='zip render and data', zip_type='truncate'), made_dir, stream_name='zl dirs and render and data' ), input_info=ii, output_info=[('final_filename', {'dtype': 'str'})], stream_name='Write {}'.format(s1.stream_name), **kwargs) for s1, s2, made_dir, ii, writer_templater, kwargs in zip( streams_to_be_saved, mega_render, make_dirs, # prevent run condition btwn dirs and files input_infos, save_callables, saver_kwargs )]) _s.add(es.map(dump_yml, es.zip(eventify_raw_start, md_render), input_info={0: (('data', 'filename'), 1), 1: (('data',), 0)}, full_event=True, stream_name='dump yaml')) return raw_source
80677bded8716a07e70e5804d50d2234c9f17802
de306933f1e34da0790a1a45e487ca23cb2270a5
/python/examples/basics/hello_world.py
f096da0d9e5f8055e15f7f3b22e1149383c8e2fd
[]
no_license
storasvyras/slides
7e2bb3a77c6a097ba086ca853d10c9e96b0ce500
1ae7eeb9da153bd2260a4bf1a30c2898b5b68f40
refs/heads/main
2020-09-05T09:25:38.913204
2019-11-06T13:19:14
2019-11-06T13:19:14
null
0
0
null
null
null
null
UTF-8
Python
false
false
110
py
#!/usr/bin/env python def main(): print("Hello World") return print("before") main() print("after")
f30fe56073906398d23caa61ccf0a8e2ab8e16db
323f58ecefddd602431eeb285b60ac81316b774a
/aioreactive/operators/map.py
fabc6f774561b5bc2cf3945aa07c3b09a5d2753b
[ "MIT" ]
permissive
tr11/aioreactive
aa9798ee5c2f98c0f5301111732e72093232ab8e
6219f9a0761f69fa1765129b990762affdf661c8
refs/heads/master
2021-01-25T13:58:51.892021
2018-03-02T22:01:23
2018-03-02T22:01:23
123,635,129
0
0
MIT
2018-03-02T21:56:46
2018-03-02T21:56:46
null
UTF-8
Python
false
false
1,727
py
from asyncio import iscoroutinefunction from typing import Callable, TypeVar from aioreactive.abc import AsyncDisposable from aioreactive.core import AsyncObserver, AsyncObservable from aioreactive.core import AsyncSingleStream, chain, AsyncCompositeDisposable T1 = TypeVar('T1') T2 = TypeVar('T2') class Map(AsyncObservable[T2]): def __init__(self, mapper: Callable[[T1], T2], source: AsyncObservable[T1]) -> None: self._source = source self._mapper = mapper async def __asubscribe__(self, observer: AsyncObserver[T2]) -> AsyncDisposable: sink = Map.Sink(self) # type: AsyncSingleStream[T2] down = await chain(sink, observer) up = await chain(self._source, sink) # type: AsyncDisposable return AsyncCompositeDisposable(up, down) class Sink(AsyncSingleStream[T2]): def __init__(self, source: "Map") -> None: super().__init__() self._mapper = source._mapper async def asend_core(self, value: T1) -> None: try: result = self._mapper(value) except Exception as err: await self._observer.athrow(err) else: await self._observer.asend(result) def map(mapper: Callable[[T1], T2], source: AsyncObservable[T1]) -> AsyncObservable[T2]: """Project each item of the source observable. xs = map(lambda value: value * value, source) Keyword arguments: mapper: A transform function to apply to each source item. Returns an observable sequence whose elements are the result of invoking the mapper function on each element of source. """ assert not iscoroutinefunction(mapper) return Map(mapper, source)
0d0f62bd8373f10edd9d4cca4095b3fef9693ba4
c4544c22c0618451746795090e07c80bc85a0877
/DTL_filter_demo/DTL_filter_demo/urls.py
9ba5f60e135b8a1d3661d44054a7ae21f10cdfee
[]
no_license
RelaxedDong/Django_course
35f7027dc552ad148d2dc8679a19a1ffb12b8d14
2965089d15e4c80cd6402d362ee37f8cc675c08b
refs/heads/master
2022-01-09T14:28:40.503099
2019-05-24T07:07:03
2019-05-24T07:07:03
null
0
0
null
null
null
null
UTF-8
Python
false
false
804
py
"""DTL_filter_demo URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/2.0/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: path('', views.home, name='home') Class-based views 1. Add an import: from other_app.views import Home 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') Including another URLconf 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin from django.urls import path from . import views urlpatterns = [ path('admin/', admin.site.urls), path('', views.index), ]
00f660fdd4366d928e2b66f54f12ac2b923b5079
ce55c319f5a78b69fefc63595d433864a2e531b5
/后端知识/houduan/MyBlog/userapp/migrations/0001_initial.py
abcc3a807d851aa0ec3562c9d6c944221c0501b8
[]
no_license
Suijng/1809_data
a072c875e8746190e3b715e53f1afe3323f4666b
45f8a57089f5c30ccc1a3cddb03b76dc95355417
refs/heads/master
2022-12-21T12:38:30.458291
2019-09-27T01:14:41
2019-09-27T01:14:41
211,207,071
0
0
null
2022-11-22T03:16:18
2019-09-27T00:55:21
HTML
UTF-8
Python
false
false
3,860
py
# -*- coding: utf-8 -*- # Generated by Django 1.11 on 2018-12-03 08:10 from __future__ import unicode_literals import django.contrib.auth.models import django.contrib.auth.validators from django.db import migrations, models import django.utils.timezone class Migration(migrations.Migration): initial = True dependencies = [ ('auth', '0008_alter_user_username_max_length'), ] operations = [ migrations.CreateModel( name='BlogUser', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('password', models.CharField(max_length=128, verbose_name='password')), ('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')), ('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')), ('username', models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=150, unique=True, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name='username')), ('first_name', models.CharField(blank=True, max_length=30, verbose_name='first name')), ('last_name', models.CharField(blank=True, max_length=30, verbose_name='last name')), ('email', models.EmailField(blank=True, max_length=254, verbose_name='email address')), ('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')), ('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')), ('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')), ('nickname', models.CharField(default='', max_length=20)), ('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups')), ('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions')), ], options={ 'verbose_name_plural': 'users', 'verbose_name': 'user', 'abstract': False, }, managers=[ ('objects', django.contrib.auth.models.UserManager()), ], ), migrations.CreateModel( name='EmailVerifyRecord', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('code', models.CharField(default='', max_length=50, verbose_name='验证码')), ('email', models.EmailField(max_length=50, verbose_name='邮箱')), ('send_type', models.CharField(choices=[('register', '注册'), ('forget', '找回密码'), ('update_email', '修改邮箱')], max_length=30, verbose_name='验证码类型')), ('send_time', models.DateTimeField(auto_now_add=True, verbose_name='发送时间')), ], options={ 'verbose_name_plural': '邮箱验证码', 'verbose_name': '邮箱验证码', }, ), ]
2d4d044affb7d0cc3e77b5f6551c82aae70f4994
588b28e9be045543a22f0a8ca99ba527199dc429
/chapter18/__init__.py
29bb6dee7092d73411e10f9fd9bbd06c99d000f3
[ "MIT" ]
permissive
NetworkRanger/python-spider-project
7404d4e36ac6a2cd70584d78dd81fec65a320628
f501e331a59608d9a321a0d7254fcbcf81b50ec2
refs/heads/master
2020-04-15T06:05:53.374965
2019-01-28T13:35:14
2019-01-28T13:35:14
164,448,396
2
0
null
null
null
null
UTF-8
Python
false
false
632
py
#!/usr/bin/python2.7 # -*- coding:utf-8 -*- # Author: NetworkRanger # Date: 2019/1/28 9:31 PM import logging LOG_FORMAT = "[%(asctime)s] [%(processName)s:%(threadName)s] [%(levelname)s:%(filename)s:%(funcName)s:%(lineno)d] %(message)s" logging.basicConfig(level=logging.DEBUG, format=LOG_FORMAT) Logger = logging.getLogger(__name__) class Demo(object): def __init__(self): pass def step1(self): Logger.debug('step1') def step2(self): Logger.debug('step2') def run(self): self.step1() self.step2() def main(): Demo().run() if __name__ == '__main__': main()
1eb949c67d59888a91f020f8cad66698876c2348
130daef988750806f3d6ad66f94a4ff9ee4d8edd
/brambling/auth_backends.py
2a91a4a33e3d7f973717ff7c858fe9a43be17b65
[ "BSD-3-Clause" ]
permissive
dancerfly/django-brambling
01866bc57add5b82d93e3c6c869906ec8c864b23
69aa3f5f702814969b41d62c19cd53db1f164397
refs/heads/master
2023-07-26T21:58:09.606139
2023-07-17T20:35:54
2023-07-17T20:35:54
16,976,982
2
1
BSD-3-Clause
2023-07-19T20:26:59
2014-02-19T07:33:46
Python
UTF-8
Python
false
false
972
py
class BramblingBackend(object): """ Handles object-based permissions for brambling models. """ def authenticate(self, **kwargs): pass def get_user(self, user_id): pass def get_all_permissions(self, user_obj, obj=None): if obj is None: return set() if not user_obj.is_authenticated() or not user_obj.is_active: return set() if not hasattr(user_obj, '_brambling_perm_cache'): user_obj._brambling_perm_cache = {} perm_cache = user_obj._brambling_perm_cache cls_name = obj.__class__.__name__ if cls_name not in perm_cache: perm_cache[cls_name] = {} if obj.pk not in perm_cache[cls_name]: perm_cache[cls_name][obj.pk] = set(obj.get_permissions(user_obj)) return perm_cache[cls_name][obj.pk] def has_perm(self, user_obj, perm, obj=None): return perm in self.get_all_permissions(user_obj, obj)
afc46575b44bee62133c56169fa4210dd6ad9eb5
8760f182049d4caf554c02b935684f56f6a0b39a
/fabfile.py
518eb36179dfc6b586e00e71d9f2ce269767debe
[ "BSD-3-Clause" ]
permissive
boar/boar
c674bc65623ee361af31c7569dd16c6eb8da3b03
6772ad31ee5bb910e56e650cc201a476adf216bc
refs/heads/master
2020-06-09T06:59:31.658154
2012-02-28T19:28:58
2012-02-28T19:28:58
1,734,103
1
2
null
null
null
null
UTF-8
Python
true
false
2,939
py
from fabric.api import * from fabric.contrib.files import exists, upload_template from fabric.contrib.project import rsync_project import time env.user = 'root' env.project_name = 'boar' env.hosts = ['137.205.98.90'] env.path = '/var/www/theboar.org' env.version = 'current' ###################################### # Helpers ###################################### def version_path(): return '%s/releases/%s' % (env.path, env.version) def version(v): env.version = v def wwwrun(c): sudo(c, user='www-data') ###################################### # Tasks ###################################### def bootstrap(): sudo('apt-get install -y puppet rsync') def deploy(): require('hosts', 'path') if not exists(env.path): sudo('mkdir -p "%s"' % env.path) sudo('chown -R www-data:www-data "%s"' % env.path) version(time.strftime('%Y%m%d%H%M%S')) with cd(env.path): #if exists('releases/current'): # wwwrun('cp -a releases/current releases/%s' % env.version) #else: wwwrun('mkdir -p releases/%s' % env.version) rsync_project( local_dir=".", remote_dir=version_path(), delete=True, extra_opts='--exclude=static_root --exclude=".git*" --exclude="*.pyc" --exclude="apache-solr-*" --exclude="*.pyc" --exclude="*~" --exclude="._*" --exclude="boar/media" --exclude=".*.swp" --exclude=".DS_Store"' ) with cd(version_path()): revision = local( 'git rev-list HEAD | head -1 | cut -c-20', capture=True ).strip() upload_template('boar/settings/live.py', 'boar/settings/live.py', { 'GIT_REVISION': revision }) sudo('chown -R www-data:www-data .') with cd('deploy'): sudo('puppet --templatedir=. deps.pp') if exists('ve'): run('rm -rf ve') run('mkdir ve') run('virtualenv ve') run('pip install --upgrade -E ve -r requirements.txt', shell=True) manage('collectstatic --noinput') manage('compress') with cd(env.path): if exists('releases/previous'): run('rm releases/previous') if exists('releases/current'): run('mv releases/current releases/previous') run('ln -s %s releases/current' % version_path()) sudo('cp %s/solr/conf/schema.xml /etc/solr/conf/schema.xml' % version_path()) restart() def restart(): sudo('/etc/init.d/supervisor stop') env.warn_only = True while True: out = sudo('/etc/init.d/supervisor start') if not out.failed: break time.sleep(1) env.warn_only = False sudo('/etc/init.d/nginx reload') sudo('/etc/init.d/jetty force-reload') def manage(c): with cd(version_path()): wwwrun('ve/bin/python boar/manage.py %s --settings=boar.settings.live' % c)
c67ddc97da2553f8afb6a05eabb283fa8e04bd6a
df0afd5c143fbd799e47b2c1113c75edd16861dc
/train_config/training_server/image_classification/tensornet/data/utils.py
ae15a4c7718907e0a7194ee741d20850ca81224f
[ "MIT" ]
permissive
amitkayal/Flash
7ee0021e6ebd143d250f702465b038bd081ef115
14a8b61e34b97d06aa9c9d1870ec37dc5a16e907
refs/heads/master
2023-02-17T06:50:05.146681
2021-01-16T09:09:25
2021-01-16T09:09:25
null
0
0
null
null
null
null
UTF-8
Python
false
false
3,173
py
import torch import numpy as np def unnormalize(image, mean, std, transpose=False): """Un-normalize a given image. Args: image (numpy.ndarray or torch.Tensor): A ndarray or tensor. If tensor, it should be in CPU. mean (float or tuple): Mean. It can be a single value or a tuple with 3 values (one for each channel). std (float or tuple): Standard deviation. It can be a single value or a tuple with 3 values (one for each channel). transpose (bool, optional): If True, transposed output will be returned. This param is effective only when image is a tensor. If tensor, the output will have channel number as the last dim. (default: False) Returns: Unnormalized image """ # Check if image is tensor, convert to numpy array tensor = False if type(image) == torch.Tensor: # tensor tensor = True if len(image.size()) == 3: image = image.transpose(0, 1).transpose(1, 2) image = np.array(image) # Perform normalization image = image * std + mean # Convert image back to its original data type if tensor: if not transpose and len(image.shape) == 3: image = np.transpose(image, (2, 0, 1)) image = torch.Tensor(image) return image def normalize(image, mean, std, transpose=False): """Normalize a given image. Args: image (numpy.ndarray or torch.Tensor): A ndarray or tensor. If tensor, it should be in CPU. mean (float or tuple): Mean. It can be a single value or a tuple with 3 values (one for each channel). std (float or tuple): Standard deviation. It can be a single value or a tuple with 3 values (one for each channel). transpose (bool, optional): If True, transposed output will be returned. This param is effective only when image is a tensor. If tensor, the output will have channel number as the last dim. (default: False) Returns: Normalized image """ # Check if image is tensor, convert to numpy array tensor = False if type(image) == torch.Tensor: # tensor tensor = True if len(image.size()) == 3: image = image.transpose(0, 1).transpose(1, 2) image = np.array(image) # Perform normalization image = (image - mean) / std # Convert image back to its original data type if tensor: if not transpose and len(image.shape) == 3: image = np.transpose(image, (2, 0, 1)) image = torch.Tensor(image) return image def to_numpy(tensor): """Convert 3-D torch tensor to a 3-D numpy array. Args: tensor (torch.Tensor): Tensor to be converted. Returns: numpy.ndarray """ return tensor.transpose(0, 1).transpose(1, 2).clone().numpy() def to_tensor(ndarray): """Convert 3-D numpy array to 3-D torch tensor. Args: ndarray (numpy.ndarray): Array to be converted. Returns: torch.Tensor """ return torch.Tensor(np.transpose(ndarray, (2, 0, 1)))
8e11f65766869a66e9111df36118b83b5dd1434f
d2c4934325f5ddd567963e7bd2bdc0673f92bc40
/tests/artificial/transf_Quantization/trend_MovingMedian/cycle_5/ar_12/test_artificial_32_Quantization_MovingMedian_5_12_100.py
40e8975b9b2b2180572bfb7c615e4fcc63f2f0b4
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
jmabry/pyaf
797acdd585842474ff4ae1d9db5606877252d9b8
afbc15a851a2445a7824bf255af612dc429265af
refs/heads/master
2020-03-20T02:14:12.597970
2018-12-17T22:08:11
2018-12-17T22:08:11
137,104,552
0
0
BSD-3-Clause
2018-12-17T22:08:12
2018-06-12T17:15:43
Python
UTF-8
Python
false
false
276
py
import pyaf.Bench.TS_datasets as tsds import pyaf.tests.artificial.process_artificial_dataset as art art.process_dataset(N = 32 , FREQ = 'D', seed = 0, trendtype = "MovingMedian", cycle_length = 5, transform = "Quantization", sigma = 0.0, exog_count = 100, ar_order = 12);
52acc46cc82e17279e6e3e8f336bb42e466867ba
522cbeb324df9843f9433d190af60f090119b4b1
/PythonAulas_Desafios/Desafios/aula006desafio3.py
3ecff1916da58627f403711a9dd57a67c1a2dbf0
[]
no_license
Andremarcucci98/CursoEmVideo
52d7c78d42b9dc2a28eef8f7db77972c774dece6
751d1fcd0f37da1201218d23828a6cf526f9d029
refs/heads/master
2023-05-29T03:38:36.002154
2021-06-23T14:28:50
2021-06-23T14:28:50
353,194,123
0
0
null
null
null
null
UTF-8
Python
false
false
130
py
n1 = int(input('Digite um numero:')) n2 = int(input('Digite outro:')) soma = n1 + n2 print (f'A soma de {n1} e {n2} vale {soma}')
a81c6aaf8228b7c68e349d1d0a4adb1928bc36d4
a2e638cd0c124254e67963bda62c21351881ee75
/Extensions/_am_utils_py/FPythonCode/FValidator.py
4f4b74aa575bf4b403617ac0957f80f30b42d05e
[]
no_license
webclinic017/fa-absa-py3
1ffa98f2bd72d541166fdaac421d3c84147a4e01
5e7cc7de3495145501ca53deb9efee2233ab7e1c
refs/heads/main
2023-04-19T10:41:21.273030
2021-05-10T08:50:05
2021-05-10T08:50:05
null
0
0
null
null
null
null
UTF-8
Python
false
false
3,323
py
""" Compiled: 2020-09-18 10:38:50 """ #__src_file__ = "extensions/AMUtils/./etc/FValidator.py" import collections class ValidationError(object): INFO = 0 WARN = 1 ERROR = 2 FATAL = 3 def __init__(self, errorMsg, obj, errorLevel=None, **kwargs): self._errorMsg = errorMsg self._obj = obj if errorLevel is None: self._errorLevel = self.ERROR else: self._errorLevel = errorLevel self._additionalArguments = kwargs def FormatObject(self): return str(self.Object()) def LongMessage(self): return self.FormatErrorMessage() def FormatErrorMessage(self): errorLevel = {self.INFO:'INFO', self.WARN:'WARN', self.ERROR:'ERROR', self.FATAL:'FATAL'}[self.ErrorLevel()] return '{0} {1}: {2}'.format(errorLevel, self.FormatObject(), self.ErrorMessage()) def __str__(self): return self.FormatErrorMessage() def ErrorMessage(self): return self._errorMsg def Object(self): return self._obj def ErrorLevel(self): return self._errorLevel class ErrorList(list): def __init__(self, parameter, sourceChain=None, errorClass=ValidationError): list.__init__(self) self._parameter = parameter self._sourceChain = sourceChain self._errorClass = errorClass def AddError(self, msg, errorLevel=None, **kwargs): error = self._errorClass(msg, self._parameter, errorLevel, **kwargs) self.append(error) class Validator(object): @classmethod def Validate(cls, obj, validObjectTypes=None): errors = [] if isinstance(validObjectTypes, str): validObjectTypes = [validObjectTypes] elif isinstance(validObjectTypes, collections.Iterable): validObjectTypes = list(validObjectTypes) else: validObjectTypes = None try: obj = cls.Object(obj) except Exception as e: return [cls.CreateError(str(e), obj)] objType = cls.GetType(obj) if not objType: return [cls.CreateError('No Type', obj)] elif validObjectTypes is not None and not objType in validObjectTypes: return [cls.CreateError('Type "{0}" is not in the valid object types {1}'.format(objType, validObjectTypes), obj)] try: #Should use a deque or something instead function = getattr(cls, 'Validate'+objType) except AttributeError: return [cls.CreateError('Validator function "{0}" available'.format('Validate'+objType), obj, ValidationError.WARN)] try: errors.extend(function(obj)) except Exception as e: return [cls.CreateError('Could not run validator function {0}: {1}'.format('Validate'+objType, e), obj)] return errors @classmethod def CreateError(cls, errorMsg, obj, errorLevel=None, **kwargs): return ValidationError(errorMsg, obj, errorLevel, **kwargs) @classmethod def GetType(cls, parameter): return type(parameter).__name__ @classmethod def Object(cls, obj): return obj @classmethod def _ErrorList(cls, parameter, sourceChain): return ErrorList(parameter, sourceChain, cls.CreateError)
6fd25986dcd401e439b7c239e56c59d3c42dba76
a33098d9f7f7402d07c7bb0663e260cab4772fd2
/src/users/utils/generator/id_generator.py
da8a6ddab5d9285c1249e943045094d9a071d462
[]
no_license
EgbieAndersonUku1/myBlog
7906803c5c2f4300f1bcc672f397045894cc65b2
e4344064012aefa79042ba8d39911b29fb5b7554
refs/heads/master
2018-09-08T09:28:25.532806
2018-06-04T22:45:48
2018-06-04T22:45:48
106,434,750
0
0
null
null
null
null
UTF-8
Python
false
false
55
py
import uuid def gen_id(): return uuid.uuid4().hex
b96b505e0cb1220ac2b4625113c4bcca0a413048
59b72b8f662cd605b3ce31f54779c17e5ca066d0
/interview_q/剑指offer/10_斐波那契数列.py
de292e4f6715a9faab8360d5bd0767643da352c0
[]
no_license
dongyang2/hello-world
c1f5853ccafd6b8f23836192547ab36f898e0891
1f859b53e2b21ed5a648da09b84950f03ec1b370
refs/heads/master
2022-12-11T22:07:22.853912
2022-11-24T03:52:35
2022-11-24T03:52:35
119,025,960
0
0
null
2018-01-26T10:09:58
2018-01-26T08:28:10
null
UTF-8
Python
false
false
689
py
# 6,7,8,9都是C里面才有的数据结构的操作,Python里实现和操作都不太一样,这里先跳一跳 # coding: utf-8 # Python 3 # 这就是传说中的跳台阶,最最经典的动态规划。 def jump(n: int): if n < 0: raise ValueError() if n == 0: return 0 if n == 1: return 1 fn_2 = 0 fn_1 = 1 f = 0 for i in range(1, n): f = fn_1 + fn_2 fn_1, fn_2 = fn_1, f return f def main(): print(jump(4)) if __name__ == '__main__': import time print('-' * 15, 'Start', time.ctime(), '-' * 15, '\n') main() print('%s%s %s %s %s' % ('\n', '-' * 16, 'End', time.ctime(), '-' * 16))
26990edf4fc3ae419d9308a62e95b9b113c53e05
89c9142a8d6e004f28cd0d22aa455d8571035ec4
/PyMOTW/datetime/datetime_datetime_strptime.py
6c457710fddeecaf1aefd1959bb80bc758485840
[]
no_license
pkueecslibo/amw-python-study
c8d34f2151877fe098c06d71c51563dafd71e652
ff789e148158bfa8f7ae2b749240b868eed1e0bc
refs/heads/master
2021-01-20T17:27:16.262750
2014-08-19T15:18:54
2014-08-19T15:18:54
28,998,135
1
0
null
2015-01-09T03:09:50
2015-01-09T03:09:48
null
UTF-8
Python
false
false
368
py
#!/usr/bin/python #!-*- coding:utf-8 -*- ''' Formatting and Parsing format: 将时间格式化 parse : 将时间解析 ''' import datetime format = '%a %b %d %H:%M:%S %Y' today = datetime.datetime.today() print 'ISO :', today s = today.strftime(format) print 'strftime :', s d = datetime.datetime.strptime(s, format) print 'strptime :', d.strftime(format)
[ "[email protected]@cdea0e49-4e81-d697-b58f-f95e96613c0c" ]
[email protected]@cdea0e49-4e81-d697-b58f-f95e96613c0c
3081afd88171246db3595e811a6f40c46cb95911
a79da24bda658f588fd8e71c7e63f01931c1a694
/bigapple/venv/lib/python3.7/site-packages/plotly/graph_objs/scatterternary/hoverlabel/_font.py
a99014cb69551ed29c1a722d07bb2206b34387af
[]
no_license
replicantdeca/bigapple-insys
60519b486f13e1a3eb18b5ba637e45deaf8e1d8e
5e7328fb94362fbb04a71c2e297bffd83443eebc
refs/heads/master
2020-03-27T12:57:31.894182
2019-12-01T11:25:13
2019-12-01T11:25:13
146,580,916
0
1
null
2018-08-29T10:00:28
2018-08-29T10:00:27
null
UTF-8
Python
false
false
10,789
py
from plotly.basedatatypes import BaseTraceHierarchyType import copy class Font(BaseTraceHierarchyType): # color # ----- @property def color(self): """ The 'color' property is a color and may be specified as: - A hex string (e.g. '#ff0000') - An rgb/rgba string (e.g. 'rgb(255,0,0)') - An hsl/hsla string (e.g. 'hsl(0,100%,50%)') - An hsv/hsva string (e.g. 'hsv(0,100%,100%)') - A named CSS color: aliceblue, antiquewhite, aqua, aquamarine, azure, beige, bisque, black, blanchedalmond, blue, blueviolet, brown, burlywood, cadetblue, chartreuse, chocolate, coral, cornflowerblue, cornsilk, crimson, cyan, darkblue, darkcyan, darkgoldenrod, darkgray, darkgrey, darkgreen, darkkhaki, darkmagenta, darkolivegreen, darkorange, darkorchid, darkred, darksalmon, darkseagreen, darkslateblue, darkslategray, darkslategrey, darkturquoise, darkviolet, deeppink, deepskyblue, dimgray, dimgrey, dodgerblue, firebrick, floralwhite, forestgreen, fuchsia, gainsboro, ghostwhite, gold, goldenrod, gray, grey, green, greenyellow, honeydew, hotpink, indianred, indigo, ivory, khaki, lavender, lavenderblush, lawngreen, lemonchiffon, lightblue, lightcoral, lightcyan, lightgoldenrodyellow, lightgray, lightgrey, lightgreen, lightpink, lightsalmon, lightseagreen, lightskyblue, lightslategray, lightslategrey, lightsteelblue, lightyellow, lime, limegreen, linen, magenta, maroon, mediumaquamarine, mediumblue, mediumorchid, mediumpurple, mediumseagreen, mediumslateblue, mediumspringgreen, mediumturquoise, mediumvioletred, midnightblue, mintcream, mistyrose, moccasin, navajowhite, navy, oldlace, olive, olivedrab, orange, orangered, orchid, palegoldenrod, palegreen, paleturquoise, palevioletred, papayawhip, peachpuff, peru, pink, plum, powderblue, purple, red, rosybrown, royalblue, saddlebrown, salmon, sandybrown, seagreen, seashell, sienna, silver, skyblue, slateblue, slategray, slategrey, snow, springgreen, steelblue, tan, teal, thistle, tomato, turquoise, violet, wheat, white, whitesmoke, yellow, yellowgreen - A list or array of any of the above Returns ------- str|numpy.ndarray """ return self['color'] @color.setter def color(self, val): self['color'] = val # colorsrc # -------- @property def colorsrc(self): """ Sets the source reference on plot.ly for color . The 'colorsrc' property must be specified as a string or as a plotly.grid_objs.Column object Returns ------- str """ return self['colorsrc'] @colorsrc.setter def colorsrc(self, val): self['colorsrc'] = val # family # ------ @property def family(self): """ HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on- premise) generates images on a server, where only a select number of fonts are installed and supported. These include "Arial", "Balto", "Courier New", "Droid Sans",, "Droid Serif", "Droid Sans Mono", "Gravitas One", "Old Standard TT", "Open Sans", "Overpass", "PT Sans Narrow", "Raleway", "Times New Roman". The 'family' property is a string and must be specified as: - A non-empty string - A tuple, list, or one-dimensional numpy array of the above Returns ------- str|numpy.ndarray """ return self['family'] @family.setter def family(self, val): self['family'] = val # familysrc # --------- @property def familysrc(self): """ Sets the source reference on plot.ly for family . The 'familysrc' property must be specified as a string or as a plotly.grid_objs.Column object Returns ------- str """ return self['familysrc'] @familysrc.setter def familysrc(self, val): self['familysrc'] = val # size # ---- @property def size(self): """ The 'size' property is a number and may be specified as: - An int or float in the interval [1, inf] - A tuple, list, or one-dimensional numpy array of the above Returns ------- int|float|numpy.ndarray """ return self['size'] @size.setter def size(self, val): self['size'] = val # sizesrc # ------- @property def sizesrc(self): """ Sets the source reference on plot.ly for size . The 'sizesrc' property must be specified as a string or as a plotly.grid_objs.Column object Returns ------- str """ return self['sizesrc'] @sizesrc.setter def sizesrc(self, val): self['sizesrc'] = val # property parent name # -------------------- @property def _parent_path_str(self): return 'scatterternary.hoverlabel' # Self properties description # --------------------------- @property def _prop_descriptions(self): return """\ color colorsrc Sets the source reference on plot.ly for color . family HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include "Arial", "Balto", "Courier New", "Droid Sans",, "Droid Serif", "Droid Sans Mono", "Gravitas One", "Old Standard TT", "Open Sans", "Overpass", "PT Sans Narrow", "Raleway", "Times New Roman". familysrc Sets the source reference on plot.ly for family . size sizesrc Sets the source reference on plot.ly for size . """ def __init__( self, arg=None, color=None, colorsrc=None, family=None, familysrc=None, size=None, sizesrc=None, **kwargs ): """ Construct a new Font object Sets the font used in hover labels. Parameters ---------- arg dict of properties compatible with this constructor or an instance of plotly.graph_objs.scatterternary.hoverlabel.Font color colorsrc Sets the source reference on plot.ly for color . family HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include "Arial", "Balto", "Courier New", "Droid Sans",, "Droid Serif", "Droid Sans Mono", "Gravitas One", "Old Standard TT", "Open Sans", "Overpass", "PT Sans Narrow", "Raleway", "Times New Roman". familysrc Sets the source reference on plot.ly for family . size sizesrc Sets the source reference on plot.ly for size . Returns ------- Font """ super(Font, self).__init__('font') # Validate arg # ------------ if arg is None: arg = {} elif isinstance(arg, self.__class__): arg = arg.to_plotly_json() elif isinstance(arg, dict): arg = copy.copy(arg) else: raise ValueError( """\ The first argument to the plotly.graph_objs.scatterternary.hoverlabel.Font constructor must be a dict or an instance of plotly.graph_objs.scatterternary.hoverlabel.Font""" ) # Import validators # ----------------- from plotly.validators.scatterternary.hoverlabel import ( font as v_font ) # Initialize validators # --------------------- self._validators['color'] = v_font.ColorValidator() self._validators['colorsrc'] = v_font.ColorsrcValidator() self._validators['family'] = v_font.FamilyValidator() self._validators['familysrc'] = v_font.FamilysrcValidator() self._validators['size'] = v_font.SizeValidator() self._validators['sizesrc'] = v_font.SizesrcValidator() # Populate data dict with properties # ---------------------------------- _v = arg.pop('color', None) self.color = color if color is not None else _v _v = arg.pop('colorsrc', None) self.colorsrc = colorsrc if colorsrc is not None else _v _v = arg.pop('family', None) self.family = family if family is not None else _v _v = arg.pop('familysrc', None) self.familysrc = familysrc if familysrc is not None else _v _v = arg.pop('size', None) self.size = size if size is not None else _v _v = arg.pop('sizesrc', None) self.sizesrc = sizesrc if sizesrc is not None else _v # Process unknown kwargs # ---------------------- self._process_kwargs(**dict(arg, **kwargs))
877fd07042c488cbdf86a261d01d710b07426eb9
1017b513cd3a53cc09af81eebe03a86f18505bc7
/test/test_utils.py
45c3001ab7d709d135f5c9bf66ef26607d378d57
[ "MIT" ]
permissive
jerowe/bioconda-utils
c90ebd5ff106aef1379213d1bbd82ec33c7dbbcf
9cc370acc11ed3520f92ba706b871a7decbc3617
refs/heads/master
2021-01-19T09:54:27.497076
2017-03-14T13:33:37
2017-03-14T13:33:37
87,797,314
0
0
null
2017-04-10T10:14:07
2017-04-10T10:14:06
null
UTF-8
Python
false
false
19,424
py
import os import subprocess as sp import pytest import yaml import tempfile import requests import uuid import contextlib from bioconda_utils import utils from bioconda_utils import pkg_test from bioconda_utils import docker_utils from bioconda_utils import cli from bioconda_utils import build from bioconda_utils import upload from helpers import ensure_missing, Recipes, tmp_env_matrix from conda_build import api from conda_build.metadata import MetaData # TODO: need channel order tests. Could probably do this by adding different # file:// channels with different variants of the same package # Label that will be used for uploading test packages to anaconda/binstar TEST_LABEL = 'bioconda-utils-test' SKIP_DOCKER_TESTS = os.environ.get('TRAVIS_OS_NAME') == 'osx' if SKIP_DOCKER_TESTS: PARAMS = [False] IDS = ['system conda'] else: PARAMS = [True, False] IDS = ['with docker', 'system conda'] @contextlib.contextmanager def ensure_env_missing(env_name): """ context manager that makes sure a conda env of a particular name does not exist, deleting it if needed. """ def _clean(): p = sp.run( ['conda', 'env', 'list'], stdout=sp.PIPE, stderr=sp.STDOUT, check=True, universal_newlines=True) if env_name in p.stdout: p = sp.run( ['conda', 'env', 'remove', '-y', '-n', env_name], stdout=sp.PIPE, stderr=sp.STDOUT, check=True, universal_newlines=True) _clean() yield _clean() # ---------------------------------------------------------------------------- # FIXTURES # @pytest.fixture(scope='module') def recipes_fixture(): """ Writes example recipes (based on test_case.yaml), figures out the package paths and attaches them to the Recipes instance, and cleans up afterward. """ r = Recipes('test_case.yaml') r.write_recipes() r.pkgs = {} for k, v in r.recipe_dirs.items(): r.pkgs[k] = utils.built_package_path(v) yield r for v in r.pkgs.values(): ensure_missing(v) @pytest.fixture(scope='module', params=PARAMS, ids=IDS) def single_build(request, recipes_fixture): """ Builds the "one" recipe. """ env_matrix = list(utils.EnvMatrix(tmp_env_matrix()))[0] if request.param: docker_builder = docker_utils.RecipeBuilder(use_host_conda_bld=True) else: docker_builder = None build.build( recipe=recipes_fixture.recipe_dirs['one'], recipe_folder='.', docker_builder=docker_builder, env=env_matrix, ) built_package = recipes_fixture.pkgs['one'] yield built_package ensure_missing(built_package) # TODO: need to have a variant of this where TRAVIS_BRANCH_NAME="master" in # order to properly test for upload. @pytest.fixture(scope='module', params=PARAMS, ids=IDS) def multi_build(request, recipes_fixture): """ Builds the "one", "two", and "three" recipes. """ if request.param: docker_builder = docker_utils.RecipeBuilder(use_host_conda_bld=True) else: docker_builder = None build.build_recipes( recipe_folder=recipes_fixture.basedir, docker_builder=docker_builder, config={}, disable_upload=True, ) built_packages = recipes_fixture.pkgs yield built_packages for v in built_packages.values(): ensure_missing(v) @pytest.fixture(scope='module') def single_upload(): """ Creates a randomly-named recipe and uploads it using a label so that it doesn't affect the main bioconda channel. Tests that depend on this fixture get a tuple of name, pakage, recipe dir. Cleans up when it's done. """ name = 'upload-test-' + str(uuid.uuid4()).split('-')[0] r = Recipes( ''' {0}: meta.yaml: | package: name: {0} version: "0.1" '''.format(name), from_string=True) r.write_recipes() env_matrix = list(utils.EnvMatrix(tmp_env_matrix()))[0] build.build( recipe=r.recipe_dirs[name], recipe_folder='.', docker_builder=None, mulled_test=False, env=env_matrix, ) pkg = utils.built_package_path(r.recipe_dirs[name]) with utils.temp_env(dict( TRAVIS_BRANCH='master', TRAVIS_PULL_REQUEST='false') ): upload.upload(pkg, label=TEST_LABEL) yield (name, pkg, r.recipe_dirs[name]) p = sp.run( ['anaconda', '-t', os.environ.get('ANACONDA_TOKEN'), 'remove', 'bioconda/{0}'.format(name), '--force'], stdout=sp.PIPE, stderr=sp.STDOUT, check=True, universal_newlines=True) # ---------------------------------------------------------------------------- @pytest.mark.skipif( not os.environ.get('ANACONDA_TOKEN'), reason='No ANACONDA_TOKEN found' ) def test_upload(single_upload): name, pkg, recipe = single_upload env_name = 'bioconda-utils-test-' + str(uuid.uuid4()).split('-')[0] with ensure_env_missing(env_name): p = sp.run( ['conda', 'create', '-n', env_name, '-c', 'bioconda/label/{0}'.format(TEST_LABEL), name], stdout=sp.PIPE, stderr=sp.STDOUT, check=True, universal_newlines=True) def test_single_build_only(single_build): assert os.path.exists(single_build) def test_single_build_with_post_test(single_build): pkg_test.test_package(single_build) def test_multi_build(multi_build): for v in multi_build.values(): assert os.path.exists(v) @pytest.mark.skipif(SKIP_DOCKER_TESTS, reason='skipping on osx') def test_docker_builder_build(recipes_fixture): """ Tests just the build_recipe method of a RecipeBuilder object. """ docker_builder = docker_utils.RecipeBuilder(use_host_conda_bld=True) docker_builder.build_recipe( recipes_fixture.recipe_dirs['one'], build_args='', env={}) assert os.path.exists(recipes_fixture.pkgs['one']) @pytest.mark.skipif(SKIP_DOCKER_TESTS, reason='skipping on osx') def test_docker_build_fails(recipes_fixture): "test for expected failure when a recipe fails to build" docker_builder = docker_utils.RecipeBuilder( build_script_template="exit 1") assert docker_builder.build_script_template == 'exit 1' result = build.build_recipes( recipes_fixture.basedir, config={}, docker_builder=docker_builder, mulled_test=True, disable_upload=True, ) assert not result @pytest.mark.skipif(SKIP_DOCKER_TESTS, reason='skipping on osx') def test_docker_build_image_fails(): template = ( """ FROM {self.image} RUN nonexistent command """) with pytest.raises(sp.CalledProcessError): docker_builder = docker_utils.RecipeBuilder( dockerfile_template=template) def test_conda_purge_cleans_up(): def tmp_dir_exists(d): contents = os.listdir(d) for i in contents: if i.startswith('tmp') and '_' in i: return True bld = docker_utils.get_host_conda_bld(purge=False) assert tmp_dir_exists(bld) bld = docker_utils.get_host_conda_bld(purge=True) assert not tmp_dir_exists(bld) def test_get_deps(): r = Recipes( """ one: meta.yaml: | package: name: one version: 0.1 two: meta.yaml: | package: name: two version: 0.1 requirements: build: - one three: meta.yaml: | package: name: three version: 0.1 requirements: build: - one run: - two """, from_string=True) r.write_recipes() assert list(utils.get_deps(r.recipe_dirs['two'])) == ['one'] assert list(utils.get_deps(r.recipe_dirs['three'], build=True)) == ['one'] assert list(utils.get_deps(r.recipe_dirs['three'], build=False)) == ['two'] def test_env_matrix(): contents = { 'CONDA_PY': [27, 35], 'CONDA_BOOST': '1.60' } with open(tempfile.NamedTemporaryFile().name, 'w') as fout: fout.write(yaml.dump(contents, default_flow_style=False)) e1 = utils.EnvMatrix(contents) e2 = utils.EnvMatrix(fout.name) assert e1.env == e2.env assert sorted( [sorted(i) for i in e1]) == sorted([sorted(i) for i in e2]) == [ [ ('CONDA_BOOST', '1.60'), ('CONDA_PY', 27), ], [ ('CONDA_BOOST', '1.60'), ('CONDA_PY', 35), ] ] def test_filter_recipes_no_skipping(): """ No recipes have skip so make sure none are filtered out. """ r = Recipes( """ one: meta.yaml: | package: name: one version: "0.1" """, from_string=True) r.write_recipes() env_matrix = { 'CONDA_PY': [27, 35], 'CONDA_BOOST': '1.60' } recipes = list(r.recipe_dirs.values()) assert len(recipes) == 1 filtered = list( utils.filter_recipes(recipes, env_matrix, channels=['bioconda'])) assert len(filtered) == 1 def test_filter_recipes_skip_is_true(): """ """ r = Recipes( """ one: meta.yaml: | package: name: one version: "0.1" build: skip: true """, from_string=True) r.write_recipes() env_matrix = {} recipes = list(r.recipe_dirs.values()) filtered = list( utils.filter_recipes(recipes, env_matrix)) assert len(filtered) == 0 def test_filter_recipes_skip_py27(): """ When we add build/skip = True # [py27] to recipe, it should not be filtered out. This is because python version is not encoded in the output package name, and so one-0.1-0.tar.bz2 will still be created for py35. """ r = Recipes( """ one: meta.yaml: | package: name: one version: "0.1" build: skip: true # [py27] """, from_string=True) r.write_recipes() env_matrix = { 'CONDA_PY': [27, 35], 'CONDA_BOOST': '1.60' } recipes = list(r.recipe_dirs.values()) filtered = list( utils.filter_recipes(recipes, env_matrix, channels=['bioconda'])) assert len(filtered) == 1 def test_filter_recipes_skip_py27_in_build_string(): """ When CONDA_PY is in the build string, py27 should be skipped """ r = Recipes( """ one: meta.yaml: | package: name: one version: "0.1" build: string: {{CONDA_PY}}_{{PKG_BUILDNUM}} """, from_string=True) r.write_recipes() env_matrix = { 'CONDA_PY': [27, 35], } recipes = list(r.recipe_dirs.values()) filtered = list( utils.filter_recipes(recipes, env_matrix, channels=['bioconda'])) # one recipe, two targets assert len(filtered) == 1 assert len(filtered[0][1]) == 2 r = Recipes( """ one: meta.yaml: | package: name: one version: "0.1" build: string: {{CONDA_PY}}_{{PKG_BUILDNUM}} skip: True # [py27] """, from_string=True) r.write_recipes() env_matrix = { 'CONDA_PY': [27, 35], } recipes = list(r.recipe_dirs.values()) filtered = list( utils.filter_recipes(recipes, env_matrix, channels=['bioconda'])) # one recipe, one target assert len(filtered) == 1 assert len(filtered[0][1]) == 1 def test_filter_recipes_extra_in_build_string(): """ If CONDA_EXTRA is in os.environ, the pkg name should still be identifiable. This helps test env vars that don't have other defaults like CONDA_PY does (e.g., CONDA_BOOST in bioconda) """ r = Recipes( """ one: meta.yaml: | package: name: one version: "0.1" build: number: 0 string: {{CONDA_EXTRA}}_{{PKG_BUILDNUM}} """, from_string=True) r.write_recipes() recipe = r.recipe_dirs['one'] from conda_build.render import bldpkg_path metadata = MetaData(recipe, api.Config(**dict(CONDA_EXTRA='asdf'))) print(bldpkg_path(metadata, metadata.config)) os.environ['CONDA_EXTRA'] = 'asdf' pkg = utils.built_package_path(recipe) assert os.path.basename(pkg) == 'one-0.1-asdf_0.tar.bz2' def test_filter_recipes_existing_package(): "use a known-to-exist package in bioconda" # note that we need python as a run requirement in order to get the "pyXY" # in the build string that matches the existing bioconda built package. r = Recipes( """ one: meta.yaml: | package: name: gffutils version: "0.8.7.1" requirements: run: - python """, from_string=True) r.write_recipes() recipes = list(r.recipe_dirs.values()) env_matrix = { 'CONDA_PY': [27, 35], } pkgs = utils.get_channel_packages('bioconda') pth = utils.built_package_path(recipes[0]) filtered = list( utils.filter_recipes(recipes, env_matrix, channels=['bioconda'])) assert len(filtered) == 0 def test_filter_recipes_force_existing_package(): "same as above but force the recipe" # same as above, but this time force the recipe # TODO: refactor as py.test fixture r = Recipes( """ one: meta.yaml: | package: name: gffutils version: "0.8.7.1" requirements: run: - python """, from_string=True) r.write_recipes() recipes = list(r.recipe_dirs.values()) env_matrix = { 'CONDA_PY': [27, 35], } pkgs = utils.get_channel_packages('bioconda') pth = utils.built_package_path(recipes[0]) filtered = list( utils.filter_recipes( recipes, env_matrix, channels=['bioconda'], force=True)) assert len(filtered) == 1 def test_get_channel_packages(): with pytest.raises(requests.HTTPError): utils.get_channel_packages('bioconda_xyz_nonexistent_channel') utils.get_channel_packages('bioconda') def test_built_package_path(): r = Recipes( """ one: meta.yaml: | package: name: one version: "0.1" requirements: run: - python two: meta.yaml: | package: name: two version: "0.1" build: number: 0 string: ncurses{{ CONDA_NCURSES }}_{{ PKG_BUILDNUM }} """, from_string=True) r.write_recipes() # assumes we're running on py35 assert os.path.basename( utils.built_package_path(r.recipe_dirs['one']) ) == 'one-0.1-py35_0.tar.bz2' # resetting with a different CONDA_PY passed as env dict assert os.path.basename( utils.built_package_path(r.recipe_dirs['one'], env=dict(CONDA_PY=27)) ) == 'one-0.1-py27_0.tar.bz2' # resetting CONDA_PY using os.environ existing_env = dict(os.environ) try: os.environ['CONDA_PY'] = '27' assert os.path.basename( utils.built_package_path(r.recipe_dirs['one']) ) == 'one-0.1-py27_0.tar.bz2' os.environ = existing_env except: os.environ = existing_env raise def test_built_package_path2(): r = Recipes( """ one: meta.yaml: | package: name: one version: "0.1" requirements: run: - python two: meta.yaml: | package: name: two version: "0.1" build: number: 0 string: ncurses{{ CONDA_NCURSES }}_{{ PKG_BUILDNUM }} """, from_string=True) r.write_recipes() os.environ['CONDA_NCURSES'] = '9.0' assert os.path.basename( utils.built_package_path(r.recipe_dirs['two'], env=os.environ) ) == 'two-0.1-ncurses9.0_0.tar.bz2' del os.environ['CONDA_NCURSES'] assert os.path.basename( utils.built_package_path( r.recipe_dirs['two'], env=dict(CONDA_NCURSES='9.0')) ) == 'two-0.1-ncurses9.0_0.tar.bz2' def test_pkgname_with_numpy_x_x(): r = Recipes( """ one: meta.yaml: | package: name: one version: "0.1" requirements: run: - python - numpy x.x build: - python - numpy x.x """, from_string=True) r.write_recipes() os.environ['CONDA_NPY'] = '1.9' assert os.path.basename( utils.built_package_path(r.recipe_dirs['one'], env=os.environ) ) == 'one-0.1-np19py35_0.tar.bz2' def test_string_or_float_to_integer_python(): f = utils._string_or_float_to_integer_python assert f(27) == f('27') == f(2.7) == f('2.7') == 27 def test_skip_dependencies(): r = Recipes( """ one: meta.yaml: | package: name: one version: 0.1 two: meta.yaml: | package: name: two version: 0.1 requirements: build: - one - nonexistent three: meta.yaml: | package: name: three version: 0.1 requirements: build: - one run: - two """, from_string=True) r.write_recipes() pkgs = {} for k, v in r.recipe_dirs.items(): pkgs[k] = utils.built_package_path(v) for p in pkgs.values(): ensure_missing(p) build.build_recipes( r.basedir, config={}, packages="*", testonly=False, force=False, mulled_test=False, disable_upload=True, ) assert os.path.exists(pkgs['one']) assert not os.path.exists(pkgs['two']) assert not os.path.exists(pkgs['three']) # clean up for p in pkgs.values(): ensure_missing(p) class TestSubdags(object): def _build(self, recipes_fixture): build.build_recipes(recipes_fixture.basedir, config={}, mulled_test=False, disable_upload=True) def test_subdags_out_of_range(self, recipes_fixture): with pytest.raises(ValueError): with utils.temp_env({'SUBDAGS': '1', 'SUBDAG': '5'}): self._build(recipes_fixture) def test_subdags_more_than_recipes(self, caplog, recipes_fixture): with utils.temp_env({'SUBDAGS': '5', 'SUBDAG': '4'}): self._build(recipes_fixture) assert 'Nothing to be done' in caplog.records[-1].getMessage() def test_zero_packages(): """ Regression test; make sure filter_recipes exits cleanly if no recipes were provided. """ assert list(utils.filter_recipes([], {'CONDA_PY': [27, 35]})) == []
2da6c28b633110d0155aa61f511c304e59717da3
ec719492ce4df9f5074929335b9bc6d2a3f706d3
/djangodev/wsgi.py
ec56df023819c081a7ca4e2c658e2e584a0a4d9c
[]
no_license
qhqnf/utils-with-django
55e3a76e96df18e9d47ba907e4a7f91a9e039f19
19011e2a4bfe16b9718ce989f652924b3628db4b
refs/heads/master
2022-12-17T16:15:50.361072
2020-09-22T13:41:57
2020-09-22T13:41:57
297,660,740
0
0
null
null
null
null
UTF-8
Python
false
false
395
py
""" WSGI config for djangodev project. It exposes the WSGI callable as a module-level variable named ``application``. For more information on this file, see https://docs.djangoproject.com/en/3.0/howto/deployment/wsgi/ """ import os from django.core.wsgi import get_wsgi_application os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'djangodev.settings') application = get_wsgi_application()
37221c2bd8bec9865778877ca06c82ed0f57ca5a
531c47c15b97cbcb263ec86821d7f258c81c0aaf
/sdk/compute/azure-mgmt-compute/azure/mgmt/compute/v2019_12_01/aio/operations_async/_usage_operations_async.py
7c8a86de0c22b7f573b55b71abac3155b9dcafb2
[ "LicenseRef-scancode-generic-cla", "LGPL-2.1-or-later", "MIT" ]
permissive
YijunXieMS/azure-sdk-for-python
be364d3b88204fd3c7d223df23756386ff7a3361
f779de8e53dbec033f98f976284e6d9491fd60b3
refs/heads/master
2021-07-15T18:06:28.748507
2020-09-04T15:48:52
2020-09-04T15:48:52
205,457,088
1
2
MIT
2020-06-16T16:38:15
2019-08-30T21:08:55
Python
UTF-8
Python
false
false
5,107
py
# coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class UsageOperations: """UsageOperations async operations. You should not instantiate this class directly. Instead, you should create a Client instance that instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. :type models: ~azure.mgmt.compute.v2019_12_01.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. """ models = models def __init__(self, client, config, serializer, deserializer) -> None: self._client = client self._serialize = serializer self._deserialize = deserializer self._config = config def list( self, location: str, **kwargs ) -> AsyncIterable["models.ListUsagesResult"]: """Gets, for the specified location, the current compute resource usage information as well as the limits for compute resources under the subscription. :param location: The location for which resource usage is queried. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListUsagesResult or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.compute.v2019_12_01.models.ListUsagesResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.ListUsagesResult"] error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop('error_map', {})) api_version = "2019-12-01" def prepare_request(next_link=None): if not next_link: # Construct URL url = self.list.metadata['url'] # type: ignore path_format_arguments = { 'location': self._serialize.url("location", location, 'str', pattern=r'^[-\w\._]+$'), 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link query_parameters = {} # type: Dict[str, Any] # Construct headers header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = 'application/json' # Construct and send request request = self._client.get(url, query_parameters, header_parameters) return request async def extract_data(pipeline_response): deserialized = self._deserialize('ListUsagesResult', pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/usages'} # type: ignore
87335b3cb32c9e311cccd7caea020d28d7f292f7
d3f4da28261585201e151270a344ae8d07d55392
/app/views.py
b184b72bd30079103e0e687dabc96ba264d6617b
[]
no_license
405102091/flask
abe4f44b36c9f3549f1cab4d82fe3b9f33536232
b1b5c74a652c269769a1551ce689885e5af9ee21
refs/heads/master
2020-03-06T18:24:50.352066
2018-04-03T12:00:27
2018-04-03T12:00:27
127,006,501
0
0
null
null
null
null
UTF-8
Python
false
false
931
py
#coding:utf-8 from app import app from flask import request,render_template,send_from_directory,url_for,redirect @app.route('/') def index_page(): return render_template('index.html') @app.route('/<path:path>') def other_page(path): if path=='favicon.ico': return redirect(url_for('send_icons',path='favicon.ico')) return render_template(path) # auto search in templates folder @app.route('/file/<path:path>') def send_file(path): return send_from_directory('./file',path) @app.route('/js/<path:path>') def send_js(path): return send_from_directory('./static/js',path) @app.route('/css/<path:path>') def send_css(path): return send_from_directory('./static/css',path) @app.route('/images/<path:path>') def send_images(path): return send_from_directory('./static/images',path) @app.route('/icons/<path:path>') def send_icons(path): return send_from_directory('./static/icons',path)
c4bf4a77e5b015ff710707e34e1d6c31e69f806a
6601acd5ba7aaaa11f8620df9509e951574373b4
/rachel_modules/rachel_dict.py
42831b95ea8cfdf1a6180d4069f12d2e0d72f04a
[]
no_license
rachawker/Hawker_ACP_2021-UM_CASIM_paper
852d07519e4c15791e38bdf8ba7ae4ee9ac3707c
ff3cdd0b1ff72b0fed477824679ab7da49976aa3
refs/heads/main
2023-04-07T20:23:16.738292
2021-04-22T13:07:22
2021-04-22T13:14:40
360,516,902
0
0
null
null
null
null
UTF-8
Python
false
false
19,499
py
#My dictionary for defining functions #Rachel Hawker from __future__ import division import matplotlib.gridspec as gridspec import iris #import iris.coord_categorisation import iris.quickplot as qplt import cartopy import cartopy.feature as cfeat import rachel_dict as ra #import iris # library for atmos data import cartopy.crs as ccrs import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt import copy import matplotlib.colors as cols import matplotlib.cm as cmx from matplotlib.colors import BoundaryNorm import netCDF4 import matplotlib.ticker as mticker from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER import os,sys import colormaps as cmaps from matplotlib.patches import Polygon from mpl_toolkits.basemap import Basemap import sys import UKCA_lib as ukl import glob import netCDF4 as nc import scipy.ndimage import pandas as pd import rachel_lists as rl from mpl_toolkits.axes_grid1 import make_axes_locatable import csv from scipy import stats def import_modules(): #from __future__ import division import matplotlib.gridspec as gridspec import iris #import iris.coord_categorisation import iris.quickplot as qplt import cartopy import cartopy.feature as cfeat import rachel_dict as ra #import iris # library for atmos data #import cartopy.crs as ccrs import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt import copy import matplotlib.colors as cols import matplotlib.cm as cmx from matplotlib.colors import BoundaryNorm import netCDF4 import matplotlib.ticker as mticker from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER import os,sys import colormaps as cmaps from matplotlib.patches import Polygon from mpl_toolkits.basemap import Basemap import sys import UKCA_lib as ukl import glob import netCDF4 as nc import scipy.ndimage import pandas as pd import rachel_lists as rl def align_yaxis(ax1, ax2): y_lims = np.array([ax.get_ylim() for ax in [ax1, ax2]]) # force 0 to appear on both axes, comment if don't need y_lims[:, 0] = y_lims[:, 0].clip(None, 0) y_lims[:, 1] = y_lims[:, 1].clip(0, None) # normalize both axes y_mags = (y_lims[:,1] - y_lims[:,0]).reshape(len(y_lims),1) y_lims_normalized = y_lims / y_mags # find combined range y_new_lims_normalized = np.array([np.min(y_lims_normalized), np.max(y_lims_normalized)]) # denormalize combined range to get new axes new_lim1, new_lim2 = y_new_lims_normalized * y_mags ax1.set_ylim(new_lim1) ax2.set_ylim(new_lim2) def correlation_calc(data1,data2,var_name,slope_writer): slope, intercept, r_value, p_value, std_err = stats.linregress(data1,data2) r_sq = r_value**2 sls = [var_name, str(slope), str(intercept), str(r_value), str(r_sq), str(p_value), str(std_err)] slope_writer.writerow(sls) def plot_1d_histogram_non_log(model, xtitle, name, saving_folder): plt.hist(model, bins=40, label='model') plt.xlabel(xtitle) plt.ylabel('Normalised Frequency') plt.title('In-cloud histogram: '+name) plt.savefig(saving_folder+name,dpi=300) plt.show() def plot_1d_histogram_norm(model, xtitle, name, saving_folder): plt.hist(model, bins=40, normed=bool, label='model') plt.xlabel(xtitle) plt.ylabel('Normalised Frequency') plt.title('In-cloud histogram: '+name) plt.savefig(saving_folder+name,dpi=300) plt.show() def plot_1d_histogram(model, xtitle, name, saving_folder): plt.hist(model, bins=40, log=True, normed=bool, label='model') plt.xlabel(xtitle) plt.ylabel('Normalised Frequency') plt.title('In-cloud histogram: '+name) plt.savefig(saving_folder+name,dpi=300) plt.show() def plot_1d_histogram_aircraft_and_model(aircraft, model, xtitle, name, saving_folder): plt.hist([aircraft, model], bins=40, log=True, normed=bool, label=['aircraft','model']) plt.xlabel(xtitle) plt.ylabel('Normalised Frequency') plt.title('In-cloud histogram: '+name) plt.legend() plt.savefig(saving_folder+name,dpi=300) plt.show() def plot_1d_histogram_aircraft_and_model_not_log(aircraft, model, xtitle, name, saving_folder): plt.hist([aircraft, model], bins=40, normed=bool, label=['aircraft','model']) plt.xlabel(xtitle) plt.ylabel('Normalised Frequency') plt.title('In-cloud histogram: '+name) plt.legend() plt.savefig(saving_folder+name,dpi=300) plt.show() def load_cube(input_file,stash): iris_cube = iris.load_cube(input_file,(iris.AttributeConstraint(STASH=stash))) new = iris_cube.data del iris_cube return new def load_and_limit_cube_xy(input_file,stash,x1,x2,y1,y2): iris_cube = iris.load_cube(input_file,(iris.AttributeConstraint(STASH=stash))) new = iris_cube.data[x1:x2,y1:y2] del iris_cube return new def load_and_limit_cube_xy_unchanged_z(input_file,stash,x1,x2,y1,y2): iris_cube = iris.load_cube(input_file,(iris.AttributeConstraint(STASH=stash))) new = iris_cube.data[:,x1:x2,y1:y2] del iris_cube return new def load_and_limit_cube_zxy(input_file,stash,z1,z2,x1,x2,y1,y2): iris_cube = iris.load_cube(input_file,(iris.AttributeConstraint(STASH=stash))) new = iris_cube.data[z1:z2,x1:x2,y1:y2] del iris_cube return new def load_and_limit_cube_tzxy(input_file,stash,z1,z2,x1,x2,y1,y2): iris_cube = iris.load_cube(input_file,(iris.AttributeConstraint(STASH=stash))) new = iris_cube.data[0,z1:z2,x1:x2,y1:y2] del iris_cube return new def load_and_limit_cube_txy(input_file,stash,x1,x2,y1,y2): iris_cube = iris.load_cube(input_file,(iris.AttributeConstraint(STASH=stash))) new = iris_cube.data[0,x1:x2,y1:y2] del iris_cube return new def limit_cube_xy(iris_cube,x1,x2,y1,y2): new = iris_cube.data[x1:x2,y1:y2] del iris_cube return new def limit_cube_xy_unchanged_z(iris_cube,x1,x2,y1,y2): new = iris_cube.data[:,x1:x2,y1:y2] del iris_cube return new def limit_cube_zxy(iris_cube,z1,z2,x1,x2,y1,y2): new = iris_cube.data[z1:z2,x1:x2,y1:y2] del iris_cube return new def limit_cube_tzxy(iris_cube,z1,z2,x1,x2,y1,y2): new = iris_cube.data[0,z1:z2,x1:x2,y1:y2] del iris_cube return new def limit_cube_txy(iris_cube,x1,x2,y1,y2): new = iris_cube.data[0,x1:x2,y1:y2] del iris_cube return new def draw_screen_poly( lats, lons): #prior define lats and lons like: #lons = [lower left, upper left, upper right, lower right] #lats = [lower left, upper left, upper right, lower right] x, y = ( lons, lats ) xy = zip(x,y) poly = Polygon( xy, facecolor='none', edgecolor='blue', lw=3, alpha=1,label='Extended domain for second run' ) plt.gca().add_patch(poly) def unrot_coor(cube,rotated_lon,rotated_lat): rot_lat = cube.coord('grid_latitude').points[:] rot_lon = cube.coord('grid_longitude').points[:] rlon,rlat=np.meshgrid(rot_lon,rot_lat) lon,lat = iris.analysis.cartography.unrotate_pole(rlon,rlat,rotated_lon,rotated_lat) return lon, lat def find_nearest_vector_index(array, value): n = np.array([abs(i-value) for i in array]) nindex=np.apply_along_axis(np.argmin,0,n) return nindex def create_box_for_calculations_2D_vars(cube, lon, lat, lon1, lon2, lat1, lat2): lons = lon[0,:] lats = lat[:,0] lon_i1 = lons.find_nearest_vector_index(lons, lon1) lon_i2 = lons.find_nearest_vector_index(lons, lon2) lat_i1 = lats.find_nearest_vector_index(lats, lat1) lat_i2 = lats.find_nearest_vector_index(lats, lat2) lons_box = lons[loni1:lon_i2] lats_box = lats[lat_i1:lat_i2] calc_cube = cube[lat_i1:lat_i2,loni1:lon_i2] return calc_cube def calculate_time_mean_and_accumulated_for_3D_arrays(cube,start,no_of_timesteps,step,empty_array_1,empty_array_2): for t in np.arange(start,no_of_timesteps,step): time_limited = cube.data[t,:,:] timestep_mean = np.mean(time_limited) empty_array_1.append(timestep_mean) accumulated_times = cube.data[:t,:,:] a2D = np.sum(accumulated_times, axis=0) a1D = np.sum(a2D, axis=0) accumulated_value = np.sum(a1D, axis=0) empty_array_2.append(accumulated_value) return empty_array_1, empty_array_2 def subset_aircraft_to_in_cloud_one_per_second(start_secs, end_secs,input_data,twc_data, variable_name): air_file = '/group_workspaces/jasmin2/asci/rhawker/bae146_data_29_Jan/badc_raw_data/b933-aug-21/b933_processed_from_Richard_Cotton/b933_data_20150821_1hz_r0.nc' ncfile = nc.Dataset(air_file) time = ncfile.variables['TIME'] cdp = input_data TWC = twc_data print cdp new_data = [] for i in range(0,len(start_secs)): print i i1 = ra.find_nearest_vector_index(time,start_secs[i]) i2 = ra.find_nearest_vector_index(time,end_secs[i]) print i1 print i2 print start_secs[i] print end_secs[i] data1 = cdp[i1:i2] print data1.shape run_twc = TWC[i1:i2] data1[run_twc<10e-3]=np.nan data_final = data1[~np.isnan(data1)] print data_final.shape print 'are the above different?' print data_final new_data.append(data_final) a = np.asarray(new_data) b = np.concatenate(a, axis=0) data_path = '/group_workspaces/jasmin2/asci/rhawker/ICED_b933_case/ICED_CASIM_master_scripts/aircraft_comparisons/In_cloud_aircraft_data/' out_file = data_path+variable_name+'1hz_in_cloud_with_same_TWC_limit_as_model_aircraft_data.nc' ncfile = nc.Dataset(out_file,mode='w',format='NETCDF4_CLASSIC') index = ncfile.createDimension('index',None) var = ncfile.createVariable(variable_name+'_in_cloud_aircraft_data', np.float32, ('index',)) var[:] = b ncfile.close() return b def subset_aircraft_to_in_cloud_32_per_second(start_secs, end_secs,input_data,twc_data): air_file = '/group_workspaces/jasmin2/asci/rhawker/bae146_data_29_Jan/badc_raw_data/b933-aug-21/core_processed/core_faam_20150821_v004_r3_b933.nc' ncfile = nc.Dataset(air_file) time = ncfile.variables['Time'] cdp = input_data TWC = twc_data print cdp new_data = [] for i in range(0,len(start_secs)): print i i1 = ra.find_nearest_vector_index(time,start_secs[i]) i2 = ra.find_nearest_vector_index(time,end_secs[i]) print i1 print i2 print start_secs[i] print end_secs[i] #if data_file == cdp_pcasp_file: #data1 = cdp[i1:i2] run_twc[i1:i2,:] = (TWC[i1:i2,0:-1:2]+TWC[i1:i2,1::2])/2 if cdp[0,:].shape == (64,): data1[i1:i2,:] = (cdp[i1:i2,0:-1:2]+cdp[i1:i2,1::2])/2 else: data1 = cdp[i1:i2,:] print data1.shape data1 = data1.flatten() #print data1 run_twc = run_twc.flatten() data1[run_twc<10e-3]=np.nan data_final = data1[~np.isnan(data1)] print data_final new_data.append(data_final) a = np.asarray(new_data) b = np.concatenate(a, axis=0) data_path = '/group_workspaces/jasmin2/asci/rhawker/ICED_b933_case/ICED_CASIM_master_scripts/aircraft_comparisons/In_cloud_aircraft_data/' out_file = data_path+variable_name_in_nc+'32hz_in_cloud_with_same_TWC_limit_as_model_aircraft_data.nc' ncfile = nc.Dataset(out_file,mode='w',format='NETCDF4_CLASSIC') index = ncfile.createDimension('index',None) var = ncfile.createVariable(variable_name_in_nc+'_in_cloud_aircraft_data', np.float32, ('index',)) var[:] = b ncfile.close() return b def make_2D_hist(x,y,PLOT_TITLE,x_label,y_label,fig_dir,figname): xmin = x.min() xmax = x.max() ymin = y.min() ymax = y.max() cmap = plt.matplotlib.colors.LinearSegmentedColormap('radar',cmaps.radar.colors) #cmap.set_over('k') cmap.set_under('w') plt.hexbin(x,y,mincnt=1,bins='log',cmap=cmap) #plt.hexbin(x,y,cmap=cmap) plt.axis([xmin, xmax, ymin, ymax]) plt.title(PLOT_TITLE) cb = plt.colorbar() cb.set_label('log10(N)') plt.ylabel(y_label) plt.xlabel(x_label) plt.savefig(fig_dir+figname, dpi=300) plt.show() def make_2D_hist_simple(data_path,x,y,x_title,y_title,x_label,x_unit,y_label,y_unit): fig_dir = data_path+'PLOTS_Histograms/' PLOT_TITLE = x_label+' v '+y_label figname = '2D_histogram_'+x_title+'_v_'+y_title+'.png' xmin = x.min() xmax = x.max() ymin = y.min() ymax = y.max() cmap = plt.matplotlib.colors.LinearSegmentedColormap('radar',cmaps.radar.colors) #cmap.set_over('k') cmap.set_under('w') plt.hexbin(x,y,mincnt=1,bins='log',cmap=cmap) #plt.hexbin(x,y,cmap=cmap) plt.axis([xmin, xmax, ymin, ymax]) plt.title(PLOT_TITLE) cb = plt.colorbar() cb.set_label('log10(N)') plt.ylabel(y_label+y_unit) plt.xlabel(x_label+x_unit) plt.savefig(fig_dir+figname, dpi=300) plt.show() def make_2D_hist_param_name(data_path,param_name,x,y,x_title,y_title,x_label,x_unit,y_label,y_unit): fig_dir = data_path+'PLOTS_Histograms/' PLOT_TITLE = x_label+' v '+y_label figname = param_name+'2D_histogram_'+x_title+'_v_'+y_title+'.png' xmin = x.min() xmax = x.max() ymin = y.min() ymax = y.max() cmap = plt.matplotlib.colors.LinearSegmentedColormap('radar',cmaps.radar.colors) #cmap.set_over('k') cmap.set_under('w') plt.hexbin(x,y,mincnt=1,bins='log',cmap=cmap) #plt.hexbin(x,y,cmap=cmap) plt.axis([xmin, xmax, ymin, ymax]) plt.title(PLOT_TITLE) cb = plt.colorbar() cb.set_label('log10(N)') plt.ylabel(y_label+y_unit) plt.xlabel(x_label+x_unit) plt.savefig(fig_dir+figname, dpi=300) plt.show() def make_2D_hist_param_name_dont_save(ax,data_path,param_name,x,y,x_title,y_title,x_label,x_unit,y_label,y_unit): fig_dir = data_path+'PLOTS_Histograms/' PLOT_TITLE = x_label+' v '+y_label figname = param_name+'2D_histogram_'+x_title+'_v_'+y_title+'.png' xmin = x.min() xmax = x.max() ymin = y.min() ymax = y.max() cmap = cmx.get_cmap('jet_r') #cmap = plt.matplotlib.colors.LinearSegmentedColormap('radar',cmaps.radar.colors) #cmap.set_over('k') cmap.set_under('w') #ax.hexbin(x,y,mincnt=1,bins='log',cmap=cmap, norm=True) hb = plt.hexbin(x,y, cmap=cmap) ax.cla() f = ax.hexbin(x, y, C=np.ones_like(y, dtype=np.float) / hb.get_array().max(), cmap=cmap, reduce_C_function=np.sum) #plt.hexbin(x,y,cmap=cmap) ax.set_xlim(xmin, xmax)#, ymin, ymax]) ax.set_ylim(ymin,ymax) ax.set_title(PLOT_TITLE) #divider = make_axes_locatable(ax) #cax = divider.append_axes('right', size='5%', pad=0.05) ##cb = ax.colorbar() #fig.colorbar(f, cax=cax, orientation='vertical') #cb.set_label('log10(N)') plt.ylabel(y_label+y_unit) plt.xlabel(x_label+x_unit) def make_2D_hist_overlay_aircraft(x,y,air_x,air_y,PLOT_TITLE,x_label,y_label,fig_dir,figname): if y_label=='ICNC'+rl.per_cm_cubed and x_label=='Altitude '+rl.Kelvin: x[x<4000]=0 x[x>9000]=0 y[x==0]=np.nan x[x==0]=np.nan y = y[~np.isnan(y)] x = x[~np.isnan(x)] xmin = x.min() xmax = x.max() ymin = y.min() ymax = y.max() cmap = plt.matplotlib.colors.LinearSegmentedColormap('radar',cmaps.radar.colors) #cmap.set_over('k') cmap.set_under('w') plt.hexbin(x,y,mincnt=1,bins='log',cmap=cmap) plt.plot(air_x,air_y,'o',markerfacecolor='none', markeredgecolor='k') #plt.hexbin(x,y,cmap=cmap) plt.axis([xmin, xmax, ymin, ymax]) plt.title(PLOT_TITLE) cb = plt.colorbar() cb.set_label('log10(N)') #if y_label=='ICNC'+rl.per_cm_cubed and x_label=='Altitude '+rl.Kelvin: #plt.ylim(0,1) #plt.yscale('log') plt.ylabel(y_label) plt.xlabel(x_label) plt.savefig(fig_dir+figname, dpi=300) plt.show() def read_in_nc_variables(file_name, variable_name): x_file = nc.Dataset(file_name,mode='r') x_data = x_file.variables[variable_name] x = x_data[:] return x def read_in_nc_variables_maintain_meta_data(file_name, variable_name): x_file = nc.Dataset(file_name,mode='r') x_data = x_file.variables[variable_name] x = x_data return x def cloud_cover_write_csv(array, name): fig_dir = '/group_workspaces/jasmin2/asci/rhawker/ICED_b933_case/ICED_CASIM_b933_time_series/cirrus_and_anvil/csv_files/' A=array names = rl.all_name columns = rl.cloud_cover_cats df = pd.DataFrame(A, index=names, columns=columns) df.to_csv(fig_dir+name+'.csv', index=True, header=True, sep=',') print df def cloud_cover_each_and_combos_write_csv(array, name): fig_dir = '/group_workspaces/jasmin2/asci/rhawker/ICED_b933_case/ICED_CASIM_b933_time_series/cirrus_and_anvil/csv_files/' A=array names = rl.all_name columns = rl.cloud_cover_cats_each_and_combo df = pd.DataFrame(A, index=names, columns=columns) df.to_csv(fig_dir+name+'.csv', index=True, header=True, sep=',') print df def cloud_cover_HM_diff_write_csv(array, name): A=array fig_dir = '/group_workspaces/jasmin2/asci/rhawker/ICED_b933_case/ICED_CASIM_b933_time_series/cirrus_and_anvil/csv_files/' names = rl.name columns = rl.cloud_cover_cats df = pd.DataFrame(A, index=names, columns=columns) df.to_csv(fig_dir+name+'.csv', index=True, header=True, sep=',') print df def cloud_cover_HM_diff_each_and_combos_write_csv(array, name): A=array fig_dir = '/group_workspaces/jasmin2/asci/rhawker/ICED_b933_case/ICED_CASIM_b933_time_series/cirrus_and_anvil/csv_files/' names = rl.name columns = rl.cloud_cover_cats_each_and_combo df = pd.DataFrame(A, index=names, columns=columns) df.to_csv(fig_dir+name+'.csv', index=True, header=True, sep=',') print df def cloud_cover_HM_diff_each_and_combos_plus_total_write_csv(array, name): A=array fig_dir = '/group_workspaces/jasmin2/asci/rhawker/ICED_b933_case/ICED_CASIM_b933_time_series/cirrus_and_anvil/csv_files/' names = rl.name[0:5] columns = rl.cloud_cover_cats_each_and_combo_plus_total df = pd.DataFrame(A, index=names, columns=columns) df.to_csv(fig_dir+name+'.csv', index=True, header=True, sep=',') print df def one_variable_mean_write_csv(array, name): fig_dir = '/group_workspaces/jasmin2/asci/rhawker/ICED_b933_case/ICED_CASIM_b933_time_series/cirrus_and_anvil/csv_files/' A=array names = rl.all_name columns = ['Average'] df = pd.DataFrame(A, index=names, columns=columns) df.to_csv(fig_dir+name+'.csv', index=True, header=True, sep=',') print df def one_variable_difference_write_csv(array, name): fig_dir = '/group_workspaces/jasmin2/asci/rhawker/ICED_b933_case/ICED_CASIM_b933_time_series/cirrus_and_anvil/csv_files/' A=array names = rl.name columns = ['Difference'] df = pd.DataFrame(A, index=names, columns=columns) df.to_csv(fig_dir+name+'.csv', index=True, header=True, sep=',') print df def write_csv(csv_dir,array,csv_name,index,columns): A=array df = pd.DataFrame(A, index=index, columns=columns) df.to_csv(csv_dir+csv_name+'.csv', index=True, header=True, sep=',') print df
ceb91a2b78e5a5ea055566071356b0781e484914
a8be4698c0a43edc3622837fbe2a98e92680f48a
/Programmers/DynamicProgramming/등굣길.py
1a6dab6d68269c829b646266b58b5d87d7d4cd50
[]
no_license
blueboy1593/algorithm
fa8064241f7738a12b33544413c299e7c1e1a908
9d6fdd82b711ba16ad613edcc041cbecadd85e2d
refs/heads/master
2021-06-23T22:44:06.120932
2021-02-21T10:44:16
2021-02-21T10:44:16
199,543,744
0
0
null
null
null
null
UTF-8
Python
false
false
1,339
py
from heapq import heappop, heappush def solution(n, m, puddles): answer = 0 road_map = [ [ 0 ] * n for _ in range(m) ] for puddle in puddles: road_map[puddle[1] - 1][puddle[0] - 1] = 1 visited = [ [ (float('inf'), 1) ] * n for _ in range(m) ] print(*road_map, sep='\n') print(*visited, sep='\n') D = [(0, 1), (1, 0), (0, -1), (-1, 0)] heap_stack = [] # [최단거리, i, j] heappush(heap_stack, [0, 0, 0]) while heap_stack: print(heap_stack) a = heappop(heap_stack) dis, i, j = a for k in range(4): idy = i + D[k][0] jdx = j + D[k][1] if 0 <= idy < m and 0 <= jdx < n: if road_map[idy][jdx] == 0: if dis + 1 < visited[idy][jdx][0]: visited[idy][jdx] = (dis + 1, visited[i][j][1]) heappush(heap_stack, [dis + 1, idy, jdx]) elif dis + 1 == visited[idy][jdx][0]: visited[idy][jdx] = (dis + 1, visited[idy][jdx][1] + visited[i][j][1]) # print(visited) if visited[m-1][n-1][0] == float('inf'): return 0 answer = visited[m-1][n-1][1] % 1000000007 print(answer) print(*visited, sep='\n') return answer solution(4,3,[[2, 2]]) solution(4,3,[[1,2],[2, 2]])
145bcf7fdca12ee0dff9f5c8c86ce0531ba16418
8f68af7b8854d8c5000f8ecbe3a3c4330b4d6a7c
/docs/interviewPrep/designPatterns/Behavioral_patterns/Visitor/python/Component.py
ef9ff0e13ced6286d405b95e35de59790d077f6c
[]
no_license
reshinto/reshinto.github.io
7590d0fb26cbf239b2545fd3b745416ab31aa7aa
71e5b82d49a11d9a9171a38bcb3ac23dd07ee62f
refs/heads/dev
2022-12-05T13:45:53.578262
2022-12-01T15:34:59
2022-12-01T15:34:59
211,689,735
6
0
null
2022-08-07T22:07:36
2019-09-29T16:11:25
TypeScript
UTF-8
Python
false
false
261
py
from abc import ABC, abstractmethod class Component(ABC): """ The Component interface declares an `accept` method that should take the base visitor interface as an argument. """ @abstractmethod def accept(self, visitor): pass
32b4f98ea46f4d147614fd31e0b5a7c4576d7bea
1d7a40fde9c4da1cdb70f7e641a7dd65a8eba1a8
/libretto/migrations/0031_add_distribution_constraint.py
763b24cf80de146c9d943f4073935520cbb3a53c
[ "BSD-3-Clause" ]
permissive
dezede/dezede
675c5f6c05beffa5ad855ab521c19c077a188039
f50d2d478b473ac2acce1c5f6f9748c6211d593c
refs/heads/master
2023-08-25T13:26:47.939378
2023-08-14T20:24:51
2023-08-14T20:25:02
9,086,660
18
6
BSD-3-Clause
2023-06-05T16:32:57
2013-03-28T21:22:39
Python
UTF-8
Python
false
false
645
py
from django.db import models, migrations class Migration(migrations.Migration): dependencies = [ ('libretto', '0030_auto_20150626_1634'), ] operations = [ migrations.RunSQL(""" DELETE FROM libretto_elementdedistribution WHERE individu_id IS NULL AND ensemble_id IS NULL; ALTER TABLE libretto_elementdedistribution ADD CONSTRAINT individu_xor_ensemble CHECK (individu_id IS NOT NULL <> ensemble_id IS NOT NULL); """, """ ALTER TABLE libretto_elementdedistribution DROP CONSTRAINT individu_xor_ensemble; """) ]
ee8246209d3f04aeb9f85bc70bc5260d1e00824d
1dd7fecaa182c1d7a29460dc5385066b68bcf676
/Add or Subtract Leading Spaces/add_spaces.py
cd0734d7a6b693d7a4c01b14afb10a06c50c1dcd
[]
no_license
mainka1f/PythonUtilities
f081df31e6ea4311d4973ef7ba6bc0ff6be75fb1
f310d088a7a7a5f2c95c27cba3a7985207568d62
refs/heads/master
2021-12-02T19:21:11.915510
2012-05-01T21:43:57
2012-05-01T21:43:57
null
0
0
null
null
null
null
UTF-8
Python
false
false
3,598
py
# filename: add_leading_spaces.py # date of creation: # Oct 9, 2008 # purpose: # to add a specified number of spaces in # front of designated lines; these occur when # python code from one program is copied to # a module, for example, where the defs start in # column 1. import os # to get current directory, etc. import string # filenames are strings, dude from tkFileDialog import * # for 'askopenfilename()', etc import sys # for sys.exit() from tkMessageBox import * # askokcancel, showinfo, showerror, etc. def say_goodbye(): print '\nYou have elected to end this session.' print 'Program terminated\n\n' sys.exit() currentDirectory = os.getcwd() print '\n ** Welcome to "add_leading_spaces.py"' print '\nThis program adds a user-specified amount' print ' of leading spaces to each line of a code.' print print ' "Starting line" and "Ending line" are line numbers' print ' as shown in any text editor.' # define dictionary of options for askopenfilename(); open only python extensions initially options = {} options = { 'defaultextension' : '', 'filetypes' : [('All files','.*')], # 'initialdir' : currentDirectory, 'initialfile' : '', # 'parent' : root, 'title' : 'Open any text file...' } # get filename # dirname, filename = os.path.split(askopenfilename(**options)) inputFile = askopenfilename(**options) file=open(inputFile,'rU').readlines() print '\nInput file:',inputFile lenFile=len(file) print '\nInput file has %s lines.' % len(file) lineStart=int(raw_input('\nStarting line: ')) lineEnd=int(raw_input('Ending line: ')) numSpaces=int(raw_input('Number of leading white spaces to add: ')) if lineStart > lineEnd: print '\nWARNING - "Ending line" cannot be less than "Starting line" ' print '\n Starting line =',lineStart print ' Ending line =',lineEnd print ' Check your input and start over.\n' sys.exit() if lineStart > lenFile or lineEnd > lenFile: print '\nWARNING - Starting or Ending line numbers out of range' print ' Max line number:',lenFile print ' Starting line:',lineStart print ' Ending line:',lineEnd print ' Check your input and start over.\n' sys.exit() ans = askokcancel( 'start and end line numbers ok?', 'File = ' + inputFile + '\n' + '\nStarting line = ' + str(lineStart) + '\n' + 'Ending line = ' + str(lineEnd) + '\n' + 'Leading white spaces to add per line = ' + str(numSpaces) + '\n\n' + 'Is this ok?' ) if ans: diff = lineEnd - lineStart + 1 print for i in range(diff): lineNumber=lineStart+i line = file[lineNumber-1] print '\nBefore change ...' print '%s. %s' % (lineNumber,line) if line[0] <> '#': lineNew=' '*numSpaces + line print ' After change ...' print '%s. %s' % (lineNumber,lineNew) file[lineNumber-1]=lineNew else: print ' Comment - no change' # check if ok to write file back out to disk ans=askokcancel( 'Write file...', 'OK to write file out to disk?' ) if ans: options={'title' : 'Save a file...'} outputFile=asksaveasfilename(**options) fileOut=open(outputFile,'w') fileOut.writelines(file) print '\nOutput file:',outputFile print ' successfully written!\n' print ' Program ended\n' else: say_goodbye() else: say_goodbye()
8a3fa06daa3e454e257d5ac5eb773cb0916a5d79
704976ea552111c6a5af9cd7cb62b9d9abaf3996
/pypy/objspace/std/test/test_setstrategies.py
1088d8c734cb348fdbe86ccf222f729d02453262
[ "BSD-3-Clause" ]
permissive
mesalock-linux/mesapy
4f02c5819ce7f2f6e249d34840f1aa097577645d
ed546d59a21b36feb93e2309d5c6b75aa0ad95c9
refs/heads/mesapy2.7
2023-08-16T21:33:02.239581
2019-08-13T10:29:43
2019-08-13T18:06:45
136,080,721
396
33
NOASSERTION
2020-04-01T03:05:18
2018-06-04T20:45:17
Python
UTF-8
Python
false
false
6,034
py
from pypy.objspace.std.setobject import W_SetObject from pypy.objspace.std.setobject import ( BytesIteratorImplementation, BytesSetStrategy, EmptySetStrategy, IntegerIteratorImplementation, IntegerSetStrategy, ObjectSetStrategy, UnicodeIteratorImplementation, UnicodeSetStrategy) from pypy.objspace.std.listobject import W_ListObject class TestW_SetStrategies: def wrapped(self, l): return W_ListObject(self.space, [self.space.wrap(x) for x in l]) def test_from_list(self): s = W_SetObject(self.space, self.wrapped([1,2,3,4,5])) assert s.strategy is self.space.fromcache(IntegerSetStrategy) s = W_SetObject(self.space, self.wrapped([1,"two",3,"four",5])) assert s.strategy is self.space.fromcache(ObjectSetStrategy) s = W_SetObject(self.space) assert s.strategy is self.space.fromcache(EmptySetStrategy) s = W_SetObject(self.space, self.wrapped([])) assert s.strategy is self.space.fromcache(EmptySetStrategy) s = W_SetObject(self.space, self.wrapped(["a", "b"])) assert s.strategy is self.space.fromcache(BytesSetStrategy) s = W_SetObject(self.space, self.wrapped([u"a", u"b"])) assert s.strategy is self.space.fromcache(UnicodeSetStrategy) def test_switch_to_object(self): s = W_SetObject(self.space, self.wrapped([1,2,3,4,5])) s.add(self.space.wrap("six")) assert s.strategy is self.space.fromcache(ObjectSetStrategy) s1 = W_SetObject(self.space, self.wrapped([1,2,3,4,5])) s2 = W_SetObject(self.space, self.wrapped(["six", "seven"])) s1.update(s2) assert s1.strategy is self.space.fromcache(ObjectSetStrategy) def test_switch_to_unicode(self): s = W_SetObject(self.space, self.wrapped([])) s.add(self.space.wrap(u"six")) assert s.strategy is self.space.fromcache(UnicodeSetStrategy) def test_symmetric_difference(self): s1 = W_SetObject(self.space, self.wrapped([1,2,3,4,5])) s2 = W_SetObject(self.space, self.wrapped(["six", "seven"])) s1.symmetric_difference_update(s2) assert s1.strategy is self.space.fromcache(ObjectSetStrategy) def test_intersection(self): s1 = W_SetObject(self.space, self.wrapped([1,2,3,4,5])) s2 = W_SetObject(self.space, self.wrapped([4,5, "six", "seven"])) s3 = s1.intersect(s2) skip("for now intersection with ObjectStrategy always results in another ObjectStrategy") assert s3.strategy is self.space.fromcache(IntegerSetStrategy) def test_clear(self): s1 = W_SetObject(self.space, self.wrapped([1,2,3,4,5])) s1.clear() assert s1.strategy is self.space.fromcache(EmptySetStrategy) def test_remove(self): s1 = W_SetObject(self.space, self.wrapped([1])) self.space.call_method(s1, 'remove', self.space.wrap(1)) assert s1.strategy is self.space.fromcache(EmptySetStrategy) def test_union(self): s1 = W_SetObject(self.space, self.wrapped([1,2,3,4,5])) s2 = W_SetObject(self.space, self.wrapped([4,5,6,7])) s3 = W_SetObject(self.space, self.wrapped([4,'5','6',7])) s4 = s1.descr_union(self.space, [s2]) s5 = s1.descr_union(self.space, [s3]) assert s4.strategy is self.space.fromcache(IntegerSetStrategy) assert s5.strategy is self.space.fromcache(ObjectSetStrategy) def test_discard(self): class FakeInt(object): def __init__(self, value): self.value = value def __hash__(self): return hash(self.value) def __eq__(self, other): if other == self.value: return True return False s1 = W_SetObject(self.space, self.wrapped([1,2,3,4,5])) s1.descr_discard(self.space, self.space.wrap("five")) skip("currently not supported") assert s1.strategy is self.space.fromcache(IntegerSetStrategy) set_discard__Set_ANY(self.space, s1, self.space.wrap(FakeInt(5))) assert s1.strategy is self.space.fromcache(ObjectSetStrategy) def test_has_key(self): class FakeInt(object): def __init__(self, value): self.value = value def __hash__(self): return hash(self.value) def __eq__(self, other): if other == self.value: return True return False s1 = W_SetObject(self.space, self.wrapped([1,2,3,4,5])) assert not s1.has_key(self.space.wrap("five")) skip("currently not supported") assert s1.strategy is self.space.fromcache(IntegerSetStrategy) assert s1.has_key(self.space.wrap(FakeInt(2))) assert s1.strategy is self.space.fromcache(ObjectSetStrategy) def test_iter(self): space = self.space s = W_SetObject(space, self.wrapped([1,2])) it = s.iter() assert isinstance(it, IntegerIteratorImplementation) assert space.unwrap(it.next()) == 1 assert space.unwrap(it.next()) == 2 # s = W_SetObject(space, self.wrapped(["a", "b"])) it = s.iter() assert isinstance(it, BytesIteratorImplementation) assert space.unwrap(it.next()) == "a" assert space.unwrap(it.next()) == "b" # s = W_SetObject(space, self.wrapped([u"a", u"b"])) it = s.iter() assert isinstance(it, UnicodeIteratorImplementation) assert space.unwrap(it.next()) == u"a" assert space.unwrap(it.next()) == u"b" def test_listview(self): space = self.space s = W_SetObject(space, self.wrapped([1,2])) assert sorted(space.listview_int(s)) == [1, 2] # s = W_SetObject(space, self.wrapped(["a", "b"])) assert sorted(space.listview_bytes(s)) == ["a", "b"] # s = W_SetObject(space, self.wrapped([u"a", u"b"])) assert sorted(space.listview_unicode(s)) == [u"a", u"b"]
2c41931f9bfd7eaf9c22cbb2f15ada81301aaba1
84e661d5d293ec0c544fedab7727767f01e7ddcf
/gallery/migrations-old/0008_auto_20161104_1658.py
72efb6c44b6a86b56afd429493b3b02f9b29ad1d
[ "BSD-3-Clause" ]
permissive
groundupnews/gu
ea6734fcb9509efc407061e35724dfe8ba056044
4c036e79fd735dcb1e5a4f15322cdf87dc015a42
refs/heads/master
2023-08-31T13:13:47.178119
2023-08-18T11:42:58
2023-08-18T11:42:58
48,944,009
21
23
BSD-3-Clause
2023-09-14T13:06:42
2016-01-03T11:56:48
JavaScript
UTF-8
Python
false
false
408
py
# -*- coding: utf-8 -*- # Generated by Django 1.9.6 on 2016-11-04 14:58 from __future__ import unicode_literals from django.db import migrations class Migration(migrations.Migration): dependencies = [ ('gallery', '0007_auto_20161011_0201'), ] operations = [ migrations.AlterModelOptions( name='album', options={'ordering': ['name']}, ), ]
58fcbce7e64476764524eb41a4a3d7d43b76f249
95495baeb47fd40b9a7ecb372b79d3847aa7a139
/test/test_ftd_cluster_device_container_list_container.py
f3f0da9a2931d619b0f6edf9e2553da51679d8ac
[]
no_license
pt1988/fmc-api
b1d8ff110e12c13aa94d737f3fae9174578b019c
075f229585fcf9bd9486600200ff9efea5371912
refs/heads/main
2023-01-07T09:22:07.685524
2020-10-30T03:21:24
2020-10-30T03:21:24
308,226,669
0
0
null
null
null
null
UTF-8
Python
false
false
1,392
py
# coding: utf-8 """ Cisco Firepower Management Center Open API Specification **Specifies the REST URLs and methods supported in the Cisco Firepower Management Center API. Refer to the version specific [REST API Quick Start Guide](https://www.cisco.com/c/en/us/support/security/defense-center/products-programming-reference-guides-list.html) for additional information.** # noqa: E501 OpenAPI spec version: 1.0.0 Contact: [email protected] Generated by: https://github.com/swagger-api/swagger-codegen.git """ from __future__ import absolute_import import unittest import swagger_client from swagger_client.models.ftd_cluster_device_container_list_container import FTDClusterDeviceContainerListContainer # noqa: E501 from swagger_client.rest import ApiException class TestFTDClusterDeviceContainerListContainer(unittest.TestCase): """FTDClusterDeviceContainerListContainer unit test stubs""" def setUp(self): pass def tearDown(self): pass def testFTDClusterDeviceContainerListContainer(self): """Test FTDClusterDeviceContainerListContainer""" # FIXME: construct object with mandatory attributes with example values # model = swagger_client.models.ftd_cluster_device_container_list_container.FTDClusterDeviceContainerListContainer() # noqa: E501 pass if __name__ == '__main__': unittest.main()
c62d5cb8a7929433b3e253ae3b75017865bea0da
85a9ffeccb64f6159adbd164ff98edf4ac315e33
/pysnmp/A3COM-HUAWEI-MIRRORGROUP-MIB.py
feeb62f55c3fd80aa49e9c8ec7795db145eee7a2
[ "Apache-2.0" ]
permissive
agustinhenze/mibs.snmplabs.com
5d7d5d4da84424c5f5a1ed2752f5043ae00019fb
1fc5c07860542b89212f4c8ab807057d9a9206c7
refs/heads/master
2020-12-26T12:41:41.132395
2019-08-16T15:51:41
2019-08-16T15:53:57
237,512,469
0
0
Apache-2.0
2020-01-31T20:41:36
2020-01-31T20:41:35
null
UTF-8
Python
false
false
8,647
py
# # PySNMP MIB module A3COM-HUAWEI-MIRRORGROUP-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/A3COM-HUAWEI-MIRRORGROUP-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 16:51:23 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15) # h3cCommon, = mibBuilder.importSymbols("A3COM-HUAWEI-OID-MIB", "h3cCommon") OctetString, Integer, ObjectIdentifier = mibBuilder.importSymbols("ASN1", "OctetString", "Integer", "ObjectIdentifier") NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") ConstraintsUnion, ValueRangeConstraint, ValueSizeConstraint, ConstraintsIntersection, SingleValueConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "ValueRangeConstraint", "ValueSizeConstraint", "ConstraintsIntersection", "SingleValueConstraint") ModuleCompliance, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ModuleCompliance", "NotificationGroup") TimeTicks, ModuleIdentity, IpAddress, MibScalar, MibTable, MibTableRow, MibTableColumn, MibIdentifier, iso, Counter64, ObjectIdentity, Unsigned32, Bits, Counter32, Integer32, Gauge32, NotificationType = mibBuilder.importSymbols("SNMPv2-SMI", "TimeTicks", "ModuleIdentity", "IpAddress", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "MibIdentifier", "iso", "Counter64", "ObjectIdentity", "Unsigned32", "Bits", "Counter32", "Integer32", "Gauge32", "NotificationType") TextualConvention, DisplayString, RowStatus = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "DisplayString", "RowStatus") h3cMirrGroup = ModuleIdentity((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 68)) h3cMirrGroup.setRevisions(('2006-01-10 19:03',)) if mibBuilder.loadTexts: h3cMirrGroup.setLastUpdated('200601131403Z') if mibBuilder.loadTexts: h3cMirrGroup.setOrganization('Huawei 3Com Technologies Co., Ltd.') h3cMGInfoObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 68, 1)) h3cMGObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 68, 1, 1)) h3cMGTable = MibTable((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 68, 1, 1, 1), ) if mibBuilder.loadTexts: h3cMGTable.setStatus('current') h3cMGEntry = MibTableRow((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 68, 1, 1, 1, 1), ).setIndexNames((0, "A3COM-HUAWEI-MIRRORGROUP-MIB", "h3cMGID")) if mibBuilder.loadTexts: h3cMGEntry.setStatus('current') h3cMGID = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 68, 1, 1, 1, 1, 1), Integer32()) if mibBuilder.loadTexts: h3cMGID.setStatus('current') h3cMGType = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 68, 1, 1, 1, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("local", 1), ("remoteSource", 2), ("remoteDestination", 3)))).setMaxAccess("readcreate") if mibBuilder.loadTexts: h3cMGType.setStatus('current') h3cMGStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 68, 1, 1, 1, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("active", 1), ("inactive", 2)))).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cMGStatus.setStatus('current') h3cMGRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 68, 1, 1, 1, 1, 4), RowStatus()).setMaxAccess("readcreate") if mibBuilder.loadTexts: h3cMGRowStatus.setStatus('current') h3cMGMirrorIfObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 68, 1, 2)) h3cMGMirrorIfTable = MibTable((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 68, 1, 2, 1), ) if mibBuilder.loadTexts: h3cMGMirrorIfTable.setStatus('current') h3cMGMirrorIfEntry = MibTableRow((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 68, 1, 2, 1, 1), ).setIndexNames((0, "A3COM-HUAWEI-MIRRORGROUP-MIB", "h3cMGID"), (0, "A3COM-HUAWEI-MIRRORGROUP-MIB", "h3cMGMirrorIfIndex"), (0, "A3COM-HUAWEI-MIRRORGROUP-MIB", "h3cMGMirrorDirection")) if mibBuilder.loadTexts: h3cMGMirrorIfEntry.setStatus('current') h3cMGMirrorIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 68, 1, 2, 1, 1, 1), Integer32()) if mibBuilder.loadTexts: h3cMGMirrorIfIndex.setStatus('current') h3cMGMirrorDirection = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 68, 1, 2, 1, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("inbound", 1), ("outbound", 2), ("both", 3)))) if mibBuilder.loadTexts: h3cMGMirrorDirection.setStatus('current') h3cMGMirrorRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 68, 1, 2, 1, 1, 3), RowStatus()).setMaxAccess("readcreate") if mibBuilder.loadTexts: h3cMGMirrorRowStatus.setStatus('current') h3cMGMonitorIfObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 68, 1, 3)) h3cMGMonitorIfTable = MibTable((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 68, 1, 3, 1), ) if mibBuilder.loadTexts: h3cMGMonitorIfTable.setStatus('current') h3cMGMonitorIfEntry = MibTableRow((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 68, 1, 3, 1, 1), ).setIndexNames((0, "A3COM-HUAWEI-MIRRORGROUP-MIB", "h3cMGID"), (0, "A3COM-HUAWEI-MIRRORGROUP-MIB", "h3cMGMonitorIfIndex")) if mibBuilder.loadTexts: h3cMGMonitorIfEntry.setStatus('current') h3cMGMonitorIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 68, 1, 3, 1, 1, 1), Integer32()) if mibBuilder.loadTexts: h3cMGMonitorIfIndex.setStatus('current') h3cMGMonitorRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 68, 1, 3, 1, 1, 2), RowStatus()).setMaxAccess("readcreate") if mibBuilder.loadTexts: h3cMGMonitorRowStatus.setStatus('current') h3cMGReflectorIfObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 68, 1, 4)) h3cMGReflectorIfTable = MibTable((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 68, 1, 4, 1), ) if mibBuilder.loadTexts: h3cMGReflectorIfTable.setStatus('current') h3cMGReflectorIfEntry = MibTableRow((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 68, 1, 4, 1, 1), ).setIndexNames((0, "A3COM-HUAWEI-MIRRORGROUP-MIB", "h3cMGID"), (0, "A3COM-HUAWEI-MIRRORGROUP-MIB", "h3cMGReflectorIfIndex")) if mibBuilder.loadTexts: h3cMGReflectorIfEntry.setStatus('current') h3cMGReflectorIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 68, 1, 4, 1, 1, 1), Integer32()) if mibBuilder.loadTexts: h3cMGReflectorIfIndex.setStatus('current') h3cMGReflectorRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 68, 1, 4, 1, 1, 2), RowStatus()).setMaxAccess("readcreate") if mibBuilder.loadTexts: h3cMGReflectorRowStatus.setStatus('current') h3cMGRprobeVlanObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 68, 1, 5)) h3cMGRprobeVlanTable = MibTable((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 68, 1, 5, 1), ) if mibBuilder.loadTexts: h3cMGRprobeVlanTable.setStatus('current') h3cMGRprobeVlanEntry = MibTableRow((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 68, 1, 5, 1, 1), ).setIndexNames((0, "A3COM-HUAWEI-MIRRORGROUP-MIB", "h3cMGID"), (0, "A3COM-HUAWEI-MIRRORGROUP-MIB", "h3cMGRprobeVlanID")) if mibBuilder.loadTexts: h3cMGRprobeVlanEntry.setStatus('current') h3cMGRprobeVlanID = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 68, 1, 5, 1, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 4094))) if mibBuilder.loadTexts: h3cMGRprobeVlanID.setStatus('current') h3cMGRprobeVlanRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 68, 1, 5, 1, 1, 2), RowStatus()).setMaxAccess("readcreate") if mibBuilder.loadTexts: h3cMGRprobeVlanRowStatus.setStatus('current') mibBuilder.exportSymbols("A3COM-HUAWEI-MIRRORGROUP-MIB", PYSNMP_MODULE_ID=h3cMirrGroup, h3cMGMirrorRowStatus=h3cMGMirrorRowStatus, h3cMGMonitorIfEntry=h3cMGMonitorIfEntry, h3cMGReflectorIfEntry=h3cMGReflectorIfEntry, h3cMGStatus=h3cMGStatus, h3cMGMonitorIfObjects=h3cMGMonitorIfObjects, h3cMGRprobeVlanTable=h3cMGRprobeVlanTable, h3cMGEntry=h3cMGEntry, h3cMGMirrorIfIndex=h3cMGMirrorIfIndex, h3cMGRprobeVlanObjects=h3cMGRprobeVlanObjects, h3cMGRowStatus=h3cMGRowStatus, h3cMGReflectorIfTable=h3cMGReflectorIfTable, h3cMGReflectorRowStatus=h3cMGReflectorRowStatus, h3cMGTable=h3cMGTable, h3cMGReflectorIfIndex=h3cMGReflectorIfIndex, h3cMGMirrorIfObjects=h3cMGMirrorIfObjects, h3cMGReflectorIfObjects=h3cMGReflectorIfObjects, h3cMGMonitorIfTable=h3cMGMonitorIfTable, h3cMGMirrorIfTable=h3cMGMirrorIfTable, h3cMGType=h3cMGType, h3cMGRprobeVlanRowStatus=h3cMGRprobeVlanRowStatus, h3cMGMonitorIfIndex=h3cMGMonitorIfIndex, h3cMGMirrorDirection=h3cMGMirrorDirection, h3cMGObjects=h3cMGObjects, h3cMGRprobeVlanEntry=h3cMGRprobeVlanEntry, h3cMGID=h3cMGID, h3cMGMirrorIfEntry=h3cMGMirrorIfEntry, h3cMGInfoObjects=h3cMGInfoObjects, h3cMGRprobeVlanID=h3cMGRprobeVlanID, h3cMirrGroup=h3cMirrGroup, h3cMGMonitorRowStatus=h3cMGMonitorRowStatus)
0a58061500b7599271d8283323f62de5837f949c
c4c159a21d2f1ea0d7dfaa965aeff01c8ef70dce
/flask/flaskenv/Lib/site-packages/keras_applications/__init__.py
f55ee1563dfe72a1e4e57e1da0889e2100ce2a61
[]
no_license
AhsonAslam/webapi
54cf7466aac4685da1105f9fb84c686e38f92121
1b2bfa4614e7afdc57c9210b0674506ea70b20b5
refs/heads/master
2020-07-27T06:05:36.057953
2019-09-17T06:35:33
2019-09-17T06:35:33
208,895,450
0
0
null
null
null
null
UTF-8
Python
false
false
129
py
version https://git-lfs.github.com/spec/v1 oid sha256:fd8175358cf1d2bbbe0840de053501eb7f1fe237337da13b20799adfe278cfe5 size 1846
[ "github@cuba12345" ]
github@cuba12345