hexsha
stringlengths
40
40
size
int64
7
1.04M
ext
stringclasses
10 values
lang
stringclasses
1 value
max_stars_repo_path
stringlengths
4
247
max_stars_repo_name
stringlengths
4
125
max_stars_repo_head_hexsha
stringlengths
40
78
max_stars_repo_licenses
listlengths
1
10
max_stars_count
int64
1
368k
max_stars_repo_stars_event_min_datetime
stringlengths
24
24
max_stars_repo_stars_event_max_datetime
stringlengths
24
24
max_issues_repo_path
stringlengths
4
247
max_issues_repo_name
stringlengths
4
125
max_issues_repo_head_hexsha
stringlengths
40
78
max_issues_repo_licenses
listlengths
1
10
max_issues_count
int64
1
116k
max_issues_repo_issues_event_min_datetime
stringlengths
24
24
max_issues_repo_issues_event_max_datetime
stringlengths
24
24
max_forks_repo_path
stringlengths
4
247
max_forks_repo_name
stringlengths
4
125
max_forks_repo_head_hexsha
stringlengths
40
78
max_forks_repo_licenses
listlengths
1
10
max_forks_count
int64
1
105k
max_forks_repo_forks_event_min_datetime
stringlengths
24
24
max_forks_repo_forks_event_max_datetime
stringlengths
24
24
content
stringlengths
1
1.04M
avg_line_length
float64
1.77
618k
max_line_length
int64
1
1.02M
alphanum_fraction
float64
0
1
original_content
stringlengths
7
1.04M
filtered:remove_function_no_docstring
int64
-102
942k
filtered:remove_class_no_docstring
int64
-354
977k
filtered:remove_delete_markers
int64
0
60.1k
222f2b885bae826ffd49b963ae706336578e70ae
770
py
Python
test/AggregationTest.py
drbobdugan/smoss
3232ddfbb89450143a0fbca54c9be75730e3b3ec
[ "MIT" ]
null
null
null
test/AggregationTest.py
drbobdugan/smoss
3232ddfbb89450143a0fbca54c9be75730e3b3ec
[ "MIT" ]
3
2018-04-15T16:34:00.000Z
2018-04-15T16:48:43.000Z
test/AggregationTest.py
CSC400-S18/smoss
3232ddfbb89450143a0fbca54c9be75730e3b3ec
[ "MIT" ]
1
2019-02-21T02:27:40.000Z
2019-02-21T02:27:40.000Z
import unittest from Aggregation import Aggregation if __name__ == '__main__': unittest.main()
27.5
78
0.672727
import unittest from Aggregation import Aggregation class MyTestCase(unittest.TestCase): def setUp(self): self.aggregation = Aggregation("name", 0) #(Name, Data) def test_getName(self): self.assertEqual(self.aggregation.getName(), "name") def test_setName(self): self.aggregation.setName("newName") self.assertEqual(self.aggregation.getName(), "newName") def test_getData(self): self.assertEqual(self.aggregation.getData(), 0) def test_setData(self): self.aggregation.setData(100) self.assertEqual(self.aggregation.getData(), 100) def test_toString(self): self.assertEqual(self.aggregation.toString(), "name" + " \t" + str(0)) if __name__ == '__main__': unittest.main()
470
15
184
1f6db259e333de15840e73f5d1d44c55e1081bcd
4,737
py
Python
CV/HW10/HW10.py
r07922003/NTU
4414b656643bc0079c12617190fa2a519d2331f8
[ "MIT" ]
null
null
null
CV/HW10/HW10.py
r07922003/NTU
4414b656643bc0079c12617190fa2a519d2331f8
[ "MIT" ]
null
null
null
CV/HW10/HW10.py
r07922003/NTU
4414b656643bc0079c12617190fa2a519d2331f8
[ "MIT" ]
null
null
null
# coding: utf-8 from PIL import Image, ImageDraw import numpy as np lena = Image.open("lena.bmp") mask1 = np.array([[0 , 1 , 0], [1 ,-4 , 1], [0 , 1 , 0]]) mask2 = (1/3) * np.array([[1, 1, 1], [1,-8, 1], [1, 1, 1]]) minimum_mask = (1/3) * np.array([[ 2,-1, 2], [-1,-4,-1], [ 2,-1, 2]]) ''' gaussian_mask = np.array([[ 0, 0, 0, -1, -1, -2, -1, -1, 0, 0, 0], [ 0, 0, -2, -4, -8, -9, -8, -4, -2, 0, 0], [ 0,-2, -7,-15,-22,-23,-22,-15, -7,-2, 0], [-1,-4,-15,-24,-14, -1,-14,-24,-15,-4,-1], [-1,-8,-22,-14, 52,103, 52,-14,-22,-8,-1], [-2,-9,-23, -1,103,179,103, -1,-23,-9,-2], [-1,-8,-22,-14, 52,103, 52,-14,-22,-8,-1], [-1,-4,-15,-24,-14, -1,-14,-24,-15,-4,-1], [ 0,-2, -7,-15,-22,-23,-22,-15, -7,-2, 0], [ 0, 0, -2, -4, -8, -9, -8, -4, -2, 0, 0], [ 0, 0, 0, -1, -1, -2, -1, -1, 0, 0, 0]]) diff_gaussian = np.array([[ -1. -3. -4. -6. -7. -8. -7. -6. -4. -3. -1.] [ -3. -5. -8. -11. -13. -13. -13. -11. -8. -5. -3.] [ -4. -8. -12. -16. -17. -17. -17. -16. -12. -8. -4.] [ -6. -11. -16. -16. 0. 15. 0. -16. -16. -11. -6.] [ -7. -13. -17. 0. 85. 160. 85. 0. -17. -13. -7.] [ -8. -13. -17. 15. 160. 283. 160. 15. -17. -13. -8.] [ -7. -13. -17. 0. 85. 160. 85. 0. -17. -13. -7.] [ -6. -11. -16. -16. 0. 15. 0. -16. -16. -11. -6.] [ -4. -8. -12. -16. -17. -17. -17. -16. -12. -8. -4.] [ -3. -5. -8. -11. -13. -13. -13. -11. -8. -5. -3.] [ -1. -3. -4. -6. -7. -8. -7. -6. -4. -3. -1.]]) ''' gaussian_mask = np.zeros((11,11)) sigma = 1.4 for i in range(-5,6,1): for j in range(-5,6,1): tmp = -175 * (((i * i) + (j * j) - 2 * sigma * sigma) * np.exp(((i * i) + (j * j)) / (-2 * sigma * sigma)) / (sigma * sigma * sigma * sigma)) if tmp > 0: gaussian_mask[i+5,j+5] = int (tmp + 0.5) else: gaussian_mask[i+5,j+5] = int (tmp - 0.5) diff_gaussian = np.zeros((11,11)) sigma1 = 1 sigma2 = 3 for i in range(-5,6,1): for j in range(-5,6,1): tmp1 = ( 1/(2 * np.pi * sigma1 ** 2) ) * np.exp( (-0.5) * ((i**2) + (j**2)) / ((sigma1)**2 ) ) tmp2 = ( 1/(2 * np.pi * sigma2 ** 2) ) * np.exp( (-0.5) * ((i**2) + (j**2)) / ((sigma2)**2 ) ) diff_gaussian[i+5,j+5] = int ( (tmp1 - tmp2) * 2000.0 + 0.5 ) Laplace_Mask1 = Laplace(lena,18,mask1) Laplace_Mask2 = Laplace(lena,18,mask2) Minimum_variance_Laplace = Laplace(lena,20,minimum_mask) Laplace_Mask1.save("Laplace_Mask1.bmp") Laplace_Mask2.save("Laplace_Mask2.bmp") Minimum_variance_Laplace.save("Minimum_variance_Laplace.bmp") Laplace_of_Gaussuan = Gaussian(lena,5000,gaussian_mask) Laplace_of_Gaussuan.save("Laplace_of_Gaussuan.bmp") Difference_of_Gaussian = Gaussian(lena,70000,diff_gaussian) Difference_of_Gaussian.save("Difference_of_Gaussian.bmp")
41.920354
149
0.411231
# coding: utf-8 from PIL import Image, ImageDraw import numpy as np def Laplace(img,threshold,mask): pixel = img.load() img_new = Image.new(img.mode,img.size) array = np.zeros((img.width,img.height)) for i in range(1,img.width-1): for j in range(1,img.height-1): temp = 0 for x in range(-1,2): for y in range(-1,2): temp += pixel[i+x,j+y]*mask[x+1][y+1] array[i][j] = temp for i in range(img.width): for j in range(img.height): if array[i,j] < threshold: img_new.putpixel((i,j),255) else: img_new.putpixel((i,j),0) return img_new def Gaussian(img,threshold,mask): pixel = img.load() img_new = Image.new(img.mode,img.size) array = np.zeros((img.width,img.height)) for i in range(5,img.width-5): for j in range(5,img.height-5): temp = 0 for x in range(-5,6): for y in range(-5,6): temp += pixel[i+x,j+y]*mask[-x+5][-y+5] array[i][j] = temp for i in range(img.width): for j in range(img.height): if array[i,j] < threshold: img_new.putpixel((i,j),255) else: img_new.putpixel((i,j),0) return img_new lena = Image.open("lena.bmp") mask1 = np.array([[0 , 1 , 0], [1 ,-4 , 1], [0 , 1 , 0]]) mask2 = (1/3) * np.array([[1, 1, 1], [1,-8, 1], [1, 1, 1]]) minimum_mask = (1/3) * np.array([[ 2,-1, 2], [-1,-4,-1], [ 2,-1, 2]]) ''' gaussian_mask = np.array([[ 0, 0, 0, -1, -1, -2, -1, -1, 0, 0, 0], [ 0, 0, -2, -4, -8, -9, -8, -4, -2, 0, 0], [ 0,-2, -7,-15,-22,-23,-22,-15, -7,-2, 0], [-1,-4,-15,-24,-14, -1,-14,-24,-15,-4,-1], [-1,-8,-22,-14, 52,103, 52,-14,-22,-8,-1], [-2,-9,-23, -1,103,179,103, -1,-23,-9,-2], [-1,-8,-22,-14, 52,103, 52,-14,-22,-8,-1], [-1,-4,-15,-24,-14, -1,-14,-24,-15,-4,-1], [ 0,-2, -7,-15,-22,-23,-22,-15, -7,-2, 0], [ 0, 0, -2, -4, -8, -9, -8, -4, -2, 0, 0], [ 0, 0, 0, -1, -1, -2, -1, -1, 0, 0, 0]]) diff_gaussian = np.array([[ -1. -3. -4. -6. -7. -8. -7. -6. -4. -3. -1.] [ -3. -5. -8. -11. -13. -13. -13. -11. -8. -5. -3.] [ -4. -8. -12. -16. -17. -17. -17. -16. -12. -8. -4.] [ -6. -11. -16. -16. 0. 15. 0. -16. -16. -11. -6.] [ -7. -13. -17. 0. 85. 160. 85. 0. -17. -13. -7.] [ -8. -13. -17. 15. 160. 283. 160. 15. -17. -13. -8.] [ -7. -13. -17. 0. 85. 160. 85. 0. -17. -13. -7.] [ -6. -11. -16. -16. 0. 15. 0. -16. -16. -11. -6.] [ -4. -8. -12. -16. -17. -17. -17. -16. -12. -8. -4.] [ -3. -5. -8. -11. -13. -13. -13. -11. -8. -5. -3.] [ -1. -3. -4. -6. -7. -8. -7. -6. -4. -3. -1.]]) ''' gaussian_mask = np.zeros((11,11)) sigma = 1.4 for i in range(-5,6,1): for j in range(-5,6,1): tmp = -175 * (((i * i) + (j * j) - 2 * sigma * sigma) * np.exp(((i * i) + (j * j)) / (-2 * sigma * sigma)) / (sigma * sigma * sigma * sigma)) if tmp > 0: gaussian_mask[i+5,j+5] = int (tmp + 0.5) else: gaussian_mask[i+5,j+5] = int (tmp - 0.5) diff_gaussian = np.zeros((11,11)) sigma1 = 1 sigma2 = 3 for i in range(-5,6,1): for j in range(-5,6,1): tmp1 = ( 1/(2 * np.pi * sigma1 ** 2) ) * np.exp( (-0.5) * ((i**2) + (j**2)) / ((sigma1)**2 ) ) tmp2 = ( 1/(2 * np.pi * sigma2 ** 2) ) * np.exp( (-0.5) * ((i**2) + (j**2)) / ((sigma2)**2 ) ) diff_gaussian[i+5,j+5] = int ( (tmp1 - tmp2) * 2000.0 + 0.5 ) Laplace_Mask1 = Laplace(lena,18,mask1) Laplace_Mask2 = Laplace(lena,18,mask2) Minimum_variance_Laplace = Laplace(lena,20,minimum_mask) Laplace_Mask1.save("Laplace_Mask1.bmp") Laplace_Mask2.save("Laplace_Mask2.bmp") Minimum_variance_Laplace.save("Minimum_variance_Laplace.bmp") Laplace_of_Gaussuan = Gaussian(lena,5000,gaussian_mask) Laplace_of_Gaussuan.save("Laplace_of_Gaussuan.bmp") Difference_of_Gaussian = Gaussian(lena,70000,diff_gaussian) Difference_of_Gaussian.save("Difference_of_Gaussian.bmp")
1,232
0
50
eac790f835d536d512973a4f464d89228db15603
8,966
py
Python
Input/multi_texture.py
miladmolaee/nethub
7ba6bb66ca8c67139cd8c90d73f915ccf0d3e5ea
[ "MIT" ]
2
2021-07-15T08:24:46.000Z
2021-07-15T08:58:50.000Z
Input/multi_texture.py
miladmolaee/nethub
7ba6bb66ca8c67139cd8c90d73f915ccf0d3e5ea
[ "MIT" ]
null
null
null
Input/multi_texture.py
miladmolaee/nethub
7ba6bb66ca8c67139cd8c90d73f915ccf0d3e5ea
[ "MIT" ]
null
null
null
from Engine.network import Net
33.084871
84
0.443007
from Engine.network import Net class Multi_Texture: m_activations = [] m_neurons = [] run_number = 1 max_epoch = 2500 min_training_accuracy = 0.9 min_validation_accuracy = 0.9 min_test_accuracy = 0.9 max_training_loss = 5e-5 max_validation_loss = 5e-5 max_test_loss = 5e-5 input_dimension = 2 output_dimension = 1 test_split = 0.15 validation_split = 0.15 batch_split = 0.2 normalization_range = [-1, 1] multi_run = False plot = False check_result = False sound = False layer = [] layer_dim = 0 def make(self, scripts): self.set_constants(scripts) # self.size = get_number_of_networks(scripts) for i in range(len(scripts)): if scripts[i].__contains__('layer'): activations_name = [] activations = [] neurons = [] string = '' temp = '' for s in scripts[i]: if string == 'layer:n=': if s == ',': if temp.__contains__(':'): _temp = temp.split(':') start = int(_temp[0]) step = int(_temp[1]) end = int(_temp[2]) while start <= end: neurons.append(int(start)) start = start + step else: neurons.append(int(temp)) self.m_neurons.append(neurons) string = 'layer:' temp = '' else: temp = temp + s elif string == 'layer:activation={': if s == ',': activations_name.append(temp) temp = '' elif s == '}': activations_name.append(temp) temp = '' for name in activations_name: if name == Net.activations.relu.name: activations.append(Net.activations.relu) elif name == Net.activations.elu.name: activations.append(Net.activations.elu) elif name == Net.activations.selu.name: activations.append(Net.activations.selu) elif name == Net.activations.linear.name: activations.append(Net.activations.linear) elif name == Net.activations.tanh.name: activations.append(Net.activations.tanh) elif name == Net.activations.sigmoid.name: activations.append(Net.activations.sigmoid) elif name == Net.activations.hard_sigmoid.name: activations.append(Net.activations.hard_sigmoid) elif name == Net.activations.softmax.name: activations.append(Net.activations.softmax) elif name == Net.activations.softsign.name: activations.append(Net.activations.softsign) elif name == Net.activations.softplus.name: activations.append(Net.activations.softplus) elif name == Net.activations.exponential.name: activations.append(Net.activations.exponential) self.m_activations.append(activations) else: temp = temp + s else: string = string + s def set_constants(self, scripts): for i in range(len(scripts)): if scripts[i].__contains__('runnumber'): self.run_number = int(separate(scripts[i])) elif scripts[i].__contains__('maxepoch'): self.max_epoch = int(separate(scripts[i])) elif scripts[i].__contains__('multirun'): if separate(scripts[i]) == 'on': self.multi_run = True elif separate(scripts[i]) == 'off': self.multi_run = False elif scripts[i].__contains__('plot'): if separate(scripts[i]) == 'on': self.plot = True elif separate(scripts[i]) == 'off': self.plot = False elif scripts[i].__contains__('checkresult'): if separate(scripts[i]) == 'on': self.check_result = True elif separate(scripts[i]) == 'off': self.check_result = False elif scripts[i].__contains__('sound'): if separate(scripts[i]) == 'on': self.sound = True elif separate(scripts[i]) == 'off': self.sound = False elif scripts[i].__contains__('mintrainingaccuracy'): self.min_training_accuracy = float(separate(scripts[i])) elif scripts[i].__contains__('minvalidationaccuracy'): self.min_validation_accuracy = float(separate(scripts[i])) elif scripts[i].__contains__('mintestaccuracy'): self.min_test_accuracy = float(separate(scripts[i])) elif scripts[i].__contains__('maxtrainingloss'): self.max_training_loss = float(separate(scripts[i])) elif scripts[i].__contains__('maxvalidationloss'): self.max_validation_loss = float(separate(scripts[i])) elif scripts[i].__contains__('maxtestloss'): self.max_test_loss = float(separate(scripts[i])) elif scripts[i].__contains__('inputdimension'): self.input_dimension = int(separate(scripts[i])) elif scripts[i].__contains__('outputdimension'): self.output_dimension = int(separate(scripts[i])) elif scripts[i].__contains__('testsplit'): self.test_split = float(separate(scripts[i])) elif scripts[i].__contains__('validationsplit'): self.validation_split = float(separate(scripts[i])) elif scripts[i].__contains__('batchsplit'): self.batch_split = float(separate(scripts[i])) elif scripts[i].__contains__('normalization'): self.normalization_range = [] temp = '' for s in separate(scripts[i]): if not (s == '[' or s == ']' or s == ','): temp = temp + s if s == ',': self.normalization_range.append(float(temp)) temp = '' if s == ']': self.normalization_range.append(float(temp)) temp = '' def separate(string): my_str = '' bl = 0 for s in string: if not bl: if s == ':': bl = 1 else: my_str = my_str + s return my_str def get_number_of_networks(command): total = 1 for i in range(len(command)): if command[i].__contains__('layer'): num_of_acts = 0 num_of_neurons = 0 string = '' temp = '' for s in command[i]: if string == 'layer:n=': if s == ',': if temp.__contains__(':'): _temp = temp.split(':') start = int(_temp[0]) step = int(_temp[1]) end = int(_temp[2]) num_of_neurons = 0 while start <= end and end > 0: num_of_neurons = num_of_neurons + 1 start = start + step else: num_of_neurons = 1 string = 'layer:' else: temp = temp + s elif string == 'layer:activation={': if s == ',': num_of_acts = num_of_acts + 1 elif s == '}': num_of_acts = num_of_acts + 1 else: string = string + s total = total * num_of_neurons * num_of_acts return total
8,277
586
69
b4eafd640caac93dd636f0f796b99b6a750bf17c
3,519
py
Python
src/State.py
CURocketEngineering/firefly_chi
4a6bd3f4a5f0e98fd3fb70e7b121409e490c980b
[ "MIT" ]
2
2020-08-27T23:21:19.000Z
2021-03-27T17:46:36.000Z
src/State.py
CURocketEngineering/firefly_chi
4a6bd3f4a5f0e98fd3fb70e7b121409e490c980b
[ "MIT" ]
4
2020-05-31T21:21:55.000Z
2021-03-02T03:19:10.000Z
src/State.py
CURocketEngineering/firefly_chi
4a6bd3f4a5f0e98fd3fb70e7b121409e490c980b
[ "MIT" ]
null
null
null
""" State.py ======== Perform actions of the rocket and manage state. `hooks` is a dictionary mapping a hook string to a list of functions to thread when the hook occurs. """ import datetime from os import system from threading import Thread
30.868421
78
0.580563
""" State.py ======== Perform actions of the rocket and manage state. `hooks` is a dictionary mapping a hook string to a list of functions to thread when the hook occurs. """ import datetime from os import system from threading import Thread class State: def __init__(self, conf, data, hooks={}): self.hooks = hooks self.conf = conf self.data = data # Map of state to function self.actions = { "HALT": self.halt, # Rocket should not do anything "ARM": self.arm, # Rocket is ready to begin state system "UPWARD": self.upward, # Rocket is going up "APOGEE": self.apogee, # Rocket is at apogee "DOWNWARD": self.downward, # rocket is going down "EJECT": self.eject, # rocket is at main ejection altitude "RECOVER": self.recover, # rocket is in recovery state "SHUTDOWN": self.shutdown, "RESTART": self.restart, } self.activate_hook("halt_start") def act(self) -> str: """ Use the correct method for the correct state. """ self.conf.last_state = self.conf.state # Update last state self.conf.state = self.actions[self.conf.state]() # Perform action return self.conf.state # Return current state def activate_hook(self, hook_name : str) -> None: """ Activate a hook function. """ print(f"Activating hook '{hook_name}'") for function in self.hooks.get(hook_name, []): t = Thread(target=function, args=(self.conf,self.data)) t.start() def halt(self) -> str: """Do nothing. A halted rocket shouldn't do anything.""" return "HALT" def arm(self) -> str: """ Wait for launch. System is going up if it is 100 meters in the air and 8/10 of the last dp readings are negative. """ # Detect if system starts to go up distance_above_ground = self.data.to_dict()["sensors"]["alt"] if self.data.check_dp_lt_val(0) and distance_above_ground > 100: self.activate_hook("arm_end") self.activate_hook("upward_start") return "UPWARD" return "ARM" def upward(self): """Change state to Use air-stoppers if necessary.""" if self.data.check_dp_gt_val(0): self.activate_hook("upward_end") self.activate_hook("apogee_start") return "APOGEE" return "UPWARD" def apogee(self): """Eject parachute.""" self.activate_hook("apogee_end") self.activate_hook("downward_start") return "DOWNWARD" def downward(self): """Wait until correct altitude.""" if self.data.to_dict()["sensors"]["alt"] < self.conf.MAIN_ALTITUDE: self.activate_hook("wait_end") self.activate_hook("eject_start") return "EJECT" return "DOWNWARD" def eject(self): """Eject other parachute.""" self.activate_hook("eject_end") self.activate_hook("recover_start") return "RECOVER" def recover(self): """Do nothing.""" return "RECOVER" def restart(self): """Restart the system.""" system('reboot now') def shutdown(self): """Shutdown the system.""" system("shutdown -s") def __str__(self): return str(self.conf.state) def __repr__(self): return str(self)
801
2,450
23
cb5cc264838a049bb01efdf466c2192f20d6e36e
1,361
py
Python
red_light_detection/red_interval_extraction.py
nickchenchj/darknet
49e0dcfed005a8982e4fc80885f234e9cffee4c8
[ "BSD-3-Clause" ]
null
null
null
red_light_detection/red_interval_extraction.py
nickchenchj/darknet
49e0dcfed005a8982e4fc80885f234e9cffee4c8
[ "BSD-3-Clause" ]
null
null
null
red_light_detection/red_interval_extraction.py
nickchenchj/darknet
49e0dcfed005a8982e4fc80885f234e9cffee4c8
[ "BSD-3-Clause" ]
null
null
null
import sys if __name__ == '__main__': if len(sys.argv) < 5: print("Error: too few arguments") print("Usage: python3 %s <input-filename> <output-filename> <sample-size> <threshold>" % (sys.argv[0])) sys.exit() input_filename = sys.argv[1] output_filename = sys.argv[2] sample_size = int(sys.argv[3]) threshold = int(sys.argv[4]) with open(input_filename, 'r', encoding='utf-8') as file: data = list(map(int, file.readlines())) frame_start = 0 frame_end = 0 frame_start_is_set = False data_size = len(data) total = 0 for i in range(sample_size): total += data[i] if (total >= threshold): frame_start = 0 frame_start_is_set = True for i in range(data_size - sample_size): total -= data[i] total += data[i + sample_size] if (frame_start_is_set == False and total >= threshold): frame_start = i + 1 frame_start_is_set = True elif (frame_start_is_set == True and total < threshold): frame_end = i + sample_size break with open(output_filename, 'w', encoding='utf-8') as file: file.write('%d\n%d' % (frame_start, frame_end)) print('red light interval (frame_id):') print(' start: %d' % (frame_start)) print(' end: %d' % (frame_end))
29.586957
111
0.587068
import sys if __name__ == '__main__': if len(sys.argv) < 5: print("Error: too few arguments") print("Usage: python3 %s <input-filename> <output-filename> <sample-size> <threshold>" % (sys.argv[0])) sys.exit() input_filename = sys.argv[1] output_filename = sys.argv[2] sample_size = int(sys.argv[3]) threshold = int(sys.argv[4]) with open(input_filename, 'r', encoding='utf-8') as file: data = list(map(int, file.readlines())) frame_start = 0 frame_end = 0 frame_start_is_set = False data_size = len(data) total = 0 for i in range(sample_size): total += data[i] if (total >= threshold): frame_start = 0 frame_start_is_set = True for i in range(data_size - sample_size): total -= data[i] total += data[i + sample_size] if (frame_start_is_set == False and total >= threshold): frame_start = i + 1 frame_start_is_set = True elif (frame_start_is_set == True and total < threshold): frame_end = i + sample_size break with open(output_filename, 'w', encoding='utf-8') as file: file.write('%d\n%d' % (frame_start, frame_end)) print('red light interval (frame_id):') print(' start: %d' % (frame_start)) print(' end: %d' % (frame_end))
0
0
0
d9cc10ef963e540b44c33e4e5ec9838d481d7efb
1,617
py
Python
recorded_future/unit_test/test_lookup_vulnerability.py
killstrelok/insightconnect-plugins
911358925f4233ab273dbd8172e8b7b9188ebc01
[ "MIT" ]
null
null
null
recorded_future/unit_test/test_lookup_vulnerability.py
killstrelok/insightconnect-plugins
911358925f4233ab273dbd8172e8b7b9188ebc01
[ "MIT" ]
1
2021-02-23T23:57:37.000Z
2021-02-23T23:57:37.000Z
recorded_future/unit_test/test_lookup_vulnerability.py
killstrelok/insightconnect-plugins
911358925f4233ab273dbd8172e8b7b9188ebc01
[ "MIT" ]
null
null
null
import sys import os sys.path.append(os.path.abspath('../')) from unittest import TestCase from komand_recorded_future.connection.connection import Connection from komand_recorded_future.actions.lookup_vulnerability import LookupVulnerability import json import logging
35.933333
116
0.669759
import sys import os sys.path.append(os.path.abspath('../')) from unittest import TestCase from komand_recorded_future.connection.connection import Connection from komand_recorded_future.actions.lookup_vulnerability import LookupVulnerability import json import logging class TestLookupVulnerability(TestCase): def test_integration_lookup_vulnerability(self): log = logging.getLogger("Test") test_conn = Connection() test_action = LookupVulnerability() test_conn.logger = log test_action.logger = log try: with open("../tests/lookup_vulnerability.json") as file: test_json = json.loads(file.read()).get("body") connection_params = test_json.get("connection") action_params = test_json.get("input") except Exception as e: message = """ Could not find or read sample tests from /tests directory An exception here likely means you didn't fill out your samples correctly in the /tests directory Please use 'icon-plugin generate samples', and fill out the resulting test files in the /tests directory """ self.fail(message) test_conn.connect(connection_params) test_action.connection = test_conn results = test_action.run(action_params) # TODO: The following assert should be updated to look for data from your action # For example: self.assertEquals({"success": True}, results) self.assertIsNotNone(results) self.assertTrue("data" in results.keys())
1,277
19
49
1b03939b378717b4bea67bc3c3be919838f1e96f
2,049
py
Python
docs/02.AI_ML/code-1905/day04/demo07_vc2.py
mheanng/PythonNote
e3e5ede07968fab0a45f6ac4db96e62092c17026
[ "Apache-2.0" ]
2
2020-04-09T05:56:23.000Z
2021-03-25T18:42:36.000Z
docs/02.AI_ML/code-1905/day04/demo07_vc2.py
mheanng/PythonNote
e3e5ede07968fab0a45f6ac4db96e62092c17026
[ "Apache-2.0" ]
22
2020-04-09T06:09:14.000Z
2021-01-06T01:05:32.000Z
docs/02.AI_ML/code-1905/day04/demo07_vc2.py
mheanng/PythonNote
e3e5ede07968fab0a45f6ac4db96e62092c17026
[ "Apache-2.0" ]
6
2020-03-09T07:19:21.000Z
2021-01-05T23:23:42.000Z
""" demo06_vc.py 验证曲线 """ import numpy as np import sklearn.preprocessing as sp import sklearn.ensemble as se import sklearn.model_selection as ms import matplotlib.pyplot as mp # 读取文件 data = np.loadtxt('../ml_data/car.txt', delimiter=',', dtype='U20', converters={0:f, 1:f, 2:f, 3:f, 4:f, 5:f, 6:f}) # 整理训练集的输入与输出 data = data.T train_x, train_y = [], [] encoders = [] for col in range(len(data)): lbe = sp.LabelEncoder() if col < len(data)-1: # 不是最后一列 train_x.append(lbe.fit_transform(data[col])) else: train_y = lbe.fit_transform(data[col]) encoders.append(lbe) #保存每列的标签编码器 train_x = np.array(train_x).T print(train_x) # 交叉验证 训练模型 model = se.RandomForestClassifier(max_depth=9, n_estimators=140, random_state=7) # # 使用validation curve选择最优超参数 # train_scores, test_scores = \ # ms.validation_curve(model, train_x, # train_y, 'max_depth', # np.arange(5, 15), cv=5) # # 画图显示超参数取值与模型性能之间的关系 # x = np.arange(5, 15) # y = test_scores.mean(axis=1) # mp.figure('max_depth', facecolor='lightgray') # mp.title('max_depth', fontsize=20) # mp.xlabel('max_depth', fontsize=14) # mp.ylabel('F1 Score', fontsize=14) # mp.tick_params(labelsize=10) # mp.grid(linestyle=':') # mp.plot(x, y, 'o-', c='dodgerblue', label='Training') # mp.xticks(x) # mp.legend() # mp.show() model.fit(train_x, train_y) # 模型测试 data = [ ['high', 'med', '5more', '4', 'big', 'low', 'unacc'], ['high', 'high', '4', '4', 'med', 'med', 'acc'], ['low', 'low', '2', '4', 'small', 'high', 'good'], ['low', 'med', '3', '4', 'med', 'high', 'vgood']] # 在训练时需要把所有的LabelEncoder保存下来, # 在测试时,对测试数据的每一列使用相同的编码器进行编码, # 然后进行预测,得出预测结果 data = np.array(data).T test_x, test_y = [], [] for col in range(len(data)): encoder = encoders[col] if col<len(data)-1: test_x.append(encoder.transform(data[col])) else: test_y = encoder.transform(data[col]) test_x = np.array(test_x).T pred_test_y = model.predict(test_x) print(encoders[-1].inverse_transform(pred_test_y)) print(encoders[-1].inverse_transform(test_y))
25.296296
57
0.665691
""" demo06_vc.py 验证曲线 """ import numpy as np import sklearn.preprocessing as sp import sklearn.ensemble as se import sklearn.model_selection as ms import matplotlib.pyplot as mp def f(s): return str(s, encoding='utf-8') # 读取文件 data = np.loadtxt('../ml_data/car.txt', delimiter=',', dtype='U20', converters={0:f, 1:f, 2:f, 3:f, 4:f, 5:f, 6:f}) # 整理训练集的输入与输出 data = data.T train_x, train_y = [], [] encoders = [] for col in range(len(data)): lbe = sp.LabelEncoder() if col < len(data)-1: # 不是最后一列 train_x.append(lbe.fit_transform(data[col])) else: train_y = lbe.fit_transform(data[col]) encoders.append(lbe) #保存每列的标签编码器 train_x = np.array(train_x).T print(train_x) # 交叉验证 训练模型 model = se.RandomForestClassifier(max_depth=9, n_estimators=140, random_state=7) # # 使用validation curve选择最优超参数 # train_scores, test_scores = \ # ms.validation_curve(model, train_x, # train_y, 'max_depth', # np.arange(5, 15), cv=5) # # 画图显示超参数取值与模型性能之间的关系 # x = np.arange(5, 15) # y = test_scores.mean(axis=1) # mp.figure('max_depth', facecolor='lightgray') # mp.title('max_depth', fontsize=20) # mp.xlabel('max_depth', fontsize=14) # mp.ylabel('F1 Score', fontsize=14) # mp.tick_params(labelsize=10) # mp.grid(linestyle=':') # mp.plot(x, y, 'o-', c='dodgerblue', label='Training') # mp.xticks(x) # mp.legend() # mp.show() model.fit(train_x, train_y) # 模型测试 data = [ ['high', 'med', '5more', '4', 'big', 'low', 'unacc'], ['high', 'high', '4', '4', 'med', 'med', 'acc'], ['low', 'low', '2', '4', 'small', 'high', 'good'], ['low', 'med', '3', '4', 'med', 'high', 'vgood']] # 在训练时需要把所有的LabelEncoder保存下来, # 在测试时,对测试数据的每一列使用相同的编码器进行编码, # 然后进行预测,得出预测结果 data = np.array(data).T test_x, test_y = [], [] for col in range(len(data)): encoder = encoders[col] if col<len(data)-1: test_x.append(encoder.transform(data[col])) else: test_y = encoder.transform(data[col]) test_x = np.array(test_x).T pred_test_y = model.predict(test_x) print(encoders[-1].inverse_transform(pred_test_y)) print(encoders[-1].inverse_transform(test_y))
21
0
23
2ee8659e429532b6e304cef3ce924e4ac9f21fe3
7,111
py
Python
dataprep.py
qiulingxu/FeatureSpaceAttack
121538bbc298a1ee485cf085e39472690ac9ce48
[ "MIT" ]
9
2020-10-24T00:58:50.000Z
2022-01-26T16:44:33.000Z
dataprep.py
qqqlingx/FeatureSpaceAttack
121538bbc298a1ee485cf085e39472690ac9ce48
[ "MIT" ]
2
2021-05-23T12:18:32.000Z
2021-08-25T14:42:40.000Z
dataprep.py
qqqlingx/FeatureSpaceAttack
121538bbc298a1ee485cf085e39472690ac9ce48
[ "MIT" ]
null
null
null
import functools import numpy as np import settings from imagenetmod.interface import imagenet from cifar10 import cifar10_input
33.384977
89
0.557868
import functools import numpy as np import settings from imagenetmod.interface import imagenet from cifar10 import cifar10_input class datapairs(): def __init__(self, class_num, batch_size, stack_num=10): self.class_num = class_num self.batch_size = batch_size self.bucket = [[] for _ in range(self.class_num)] self.bucket_size = [0 for _ in range(self.class_num)] self.tot_pair = 0 self.index = 0 self.stack_num = stack_num self.loaded = 0 def add_data(self, x, y): if self.bucket_size[y] < self.stack_num: self.bucket[y].append(x) self.bucket_size[y] += 1 if self.bucket_size[y] == self.stack_num: self.loaded += 1 self.bucket[y] = np.stack(self.bucket[y]) def feed_pair(self, x_batch, y_batch): for i in range(self.batch_size): self.add_data(x_batch[i], y_batch[i]) if self.loaded == self.class_num: return False else: return True class datapair(): def __init__(self,class_num, batch_size): self.class_num=class_num self.batch_size=batch_size self.bucket=[ [] for _ in range(self.class_num)] self.bucket_size= [0 for _ in range(self.class_num)] self.tot_pair=0 self.index=0 def add_data(self,x,y): self.bucket_size[y]+=1 if self.bucket_size[y] % 2==0: self.tot_pair+=1 self.bucket[y].append(x) def feed_pair(self,x_batch,y_batch): for i in range(self.batch_size): self.add_data(x_batch[i],y_batch[i]) def get_pair(self): if self.tot_pair<self.batch_size: return None else: x1=[] y1=[] x2=[] y2=[] left=self.batch_size i = self.index # ensure random start of each class for _ in range(self.class_num): if left==0: break sz = self.bucket_size[i] if sz>=2: pairs=min(left,sz//2) else: i = (i+1) % self.class_num continue x1.extend(self.bucket[i][:pairs]) x2.extend(self.bucket[i][pairs:2*pairs]) y1.extend([i]*pairs) y2.extend([i]*pairs) self.bucket[i] = self.bucket[i][2*pairs:] self.bucket_size[i]-=2*pairs left-=pairs i= (i+1)%self.class_num #print(i) self.index = i self.tot_pair-=self.batch_size x1=np.stack(x1) x2=np.stack(x2) y1=np.stack(y1) y2=np.stack(y2) return x1,y1,x2,y2 def init_data(mode): global CLASS_NUM, BATCH_SIZE, inet, cifar_data, data_set, dp, config_name, raw_cifar assert mode in ["train","eval"] CLASS_NUM = settings.config["CLASS_NUM"] BATCH_SIZE = settings.config["BATCH_SIZE"] data_set = settings.config["data_set"] config_name = settings.config["config_name"] assert data_set in ["cifar10","svhn","imagenet"] data_set = data_set if data_set == "imagenet": if mode == "train": inet = imagenet(BATCH_SIZE, dataset="train") elif mode == "eval": inet = imagenet(BATCH_SIZE, dataset="val") elif data_set == "cifar10": raw_cifar = cifar10_input.CIFAR10Data("cifar10_data") if mode == "eval": cifar_data = raw_cifar.eval_data elif mode == "train": cifar_data = raw_cifar.train_data else: assert False, "Not implemented" dp = datapair(CLASS_NUM, BATCH_SIZE) def init_polygon_data(stack_num, fetch_embed): global _mean_all, _sigma_all mean_file = "polygon_mean_%s.npy" % config_name sigma_file = "polygon_sigma_%s.npy" % config_name if os.path.exists(mean_file) and os.path.exists(sigma_file): _mean_all = np.load(mean_file) _sigma_all = np.load(sigma_file) else: ## Populate polygon point dps = datapairs(CLASS_NUM, BATCH_SIZE, stack_num) f = True while f: x_batch, y_batch = get_data() f = dp.feed_pair(x_batch, y_batch) print("datapairs loading") polygon_arr = np.concatenate(dp.bucket) len_arr = polygon_arr.shape[0] _mean = [] _sigma = [] for i in range((len_arr - 1) // BATCH_SIZE + 1): # sess.run([stn.meanC, stn.sigmaC], feed_dict={ _meanC, _sigmaC = fetch_embed( polygon_arr[i*BATCH_SIZE:(i+1)*BATCH_SIZE]) _mean.append(_meanC) _sigma.append(_sigmaC) print("datapairs loaded") _mean_all = np.concatenate(_mean, axis=0) _sigma_all = np.concatenate(_sigma, axis=0) np.save(mean_file, _mean_all) np.save(sigma_file, _sigma_all) def popoulate_data(_meanC, _sigmaC, y_batch, include_self=True): res_mean = [] res_sigma = [] if include_self: real_num = INTERPOLATE_NUM - 1 for i in range(BATCH_SIZE): y = y_batch[i] meanCi = _meanC[i: i+1] meanC_pop = _mean_all[y*real_num:(y+1)*real_num] res_mean.append(np.concatenate([meanCi, meanC_pop])) sigmaCi = _sigmaC[i: i+1] sigmaC_pop = _sigma_all[y*real_num:(y+1)*real_num] res_sigma.append(np.concatenate([sigmaCi, sigmaC_pop])) else: real_num = INTERPOLATE_NUM for i in range(BATCH_SIZE): y = y_batch[i] meanC_pop = _mean_all[y*real_num:(y+1)*real_num] res_mean.append(meanC_pop) sigmaCi = _sigmaC[i: i+1] sigmaC_pop = _sigma_all[y*real_num:(y+1)*real_num] res_sigma.append(sigmaC_pop) return np.stack(res_mean), np.stack(res_sigma) def get_fetch_func(sess, content, pred): return functools.partial(_fetch_embed, sess=sess, content=content, pred=pred) def _fetch_embed(sess, content, pred ): _pred = sess.run(pred, feed_dict={content: content}) return _pred def _get_data(): if data_set =="cifar10": x_batch, y_batch = cifar_data.get_next_batch( batch_size=BATCH_SIZE, multiple_passes=True) elif data_set == "imagenet": x_batch, y_batch = inet.get_next_batch() return x_batch,y_batch def get_data(): return _get_data() def get_data_pair(): mode = settings.config["data_mode"] if mode == 1: ret_list = [] for _ in range(2): ret_list.extend(get_data()) return ret_list else: res = dp.get_pair() while res is None: x_batch, y_batch = get_data() dp.feed_pair(x_batch, y_batch) res = dp.get_pair() return res
6,525
-7
453
20aba656cffc937d4c4331116e4220baff9c76ba
1,313
py
Python
trivia/create_app.py
Xevion/trivia
5e7a659f8c4a7516a039ea9585d266be983b071d
[ "MIT" ]
null
null
null
trivia/create_app.py
Xevion/trivia
5e7a659f8c4a7516a039ea9585d266be983b071d
[ "MIT" ]
null
null
null
trivia/create_app.py
Xevion/trivia
5e7a659f8c4a7516a039ea9585d266be983b071d
[ "MIT" ]
null
null
null
from flask import Flask from flask_apscheduler import APScheduler from trivia.config import configs scheduler: APScheduler = None
29.177778
86
0.644326
from flask import Flask from flask_apscheduler import APScheduler from trivia.config import configs scheduler: APScheduler = None def create_app(env=None): app = Flask(__name__) if not env: env = app.config['ENV'] app.config.from_object(configs[env]) # Fixes poor whitespace rendering in templates app.jinja_env.trim_blocks = True app.jinja_env.lstrip_blocks = True with app.app_context(): # noinspection PyUnresolvedReferences from trivia import routes, api, utils # Setup a scheduler for automatically refreshing data global scheduler scheduler = APScheduler() scheduler.init_app(app) scheduler.start() # Add score file polling scheduler.add_job(id='polling', func=utils.refreshScores, trigger="interval", seconds=app.config['POLLING_INTERVAL']) if app.config['DEMO']: app.logger.info('Generating Demo Data...') # Generate initial Demo data utils.generateDemo() # Begin altering demo data regularly scheduler.add_job(id='altering', func=utils.alterDemo, trigger="interval", seconds=app.config['DEMO_ALTERATION_INTERVAL']) utils.refreshScores() return app
1,157
0
23
d169bdd391bd55defad7a541f6c8edfe9454a3fb
299
py
Python
ELAB04/04-06.py
tawanchaiii/01204111_63
edf1174f287f5174d93729d9b5c940c74d3b6553
[ "WTFPL" ]
null
null
null
ELAB04/04-06.py
tawanchaiii/01204111_63
edf1174f287f5174d93729d9b5c940c74d3b6553
[ "WTFPL" ]
null
null
null
ELAB04/04-06.py
tawanchaiii/01204111_63
edf1174f287f5174d93729d9b5c940c74d3b6553
[ "WTFPL" ]
null
null
null
t = int(input("Input: ")) for i in range(t) : ans = '' for j in range(i+1) : ans += str(cal(i,j)) + " " ###print(f"({i},{j} )",end=" ") print(ans)
21.357143
42
0.454849
def fac(n) : if n==0: return 1 else : return n * fac(n-1) def cal(a,b): return int (fac(a) / (fac(b)*fac(a-b))) t = int(input("Input: ")) for i in range(t) : ans = '' for j in range(i+1) : ans += str(cal(i,j)) + " " ###print(f"({i},{j} )",end=" ") print(ans)
87
0
46
12e9e185652313844f0d61cf6bee19810f22d361
7,581
py
Python
lib/net_util.py
asjchen/skyflow_pollution
d54bc2ae2ad3235631f1a337249535b11a6c29bd
[ "BSD-3-Clause" ]
3
2018-01-09T11:11:34.000Z
2021-05-23T16:09:17.000Z
lib/net_util.py
asjchen/skyflow_pollution
d54bc2ae2ad3235631f1a337249535b11a6c29bd
[ "BSD-3-Clause" ]
null
null
null
lib/net_util.py
asjchen/skyflow_pollution
d54bc2ae2ad3235631f1a337249535b11a6c29bd
[ "BSD-3-Clause" ]
3
2017-01-04T23:44:52.000Z
2017-01-05T09:51:19.000Z
""" Functions common to both neural networks """ import math import numpy as np import data_util import test_util import feed_forward_nn import elman_rnn from nn_globals import NetHyperparams from nn_globals import OUTPUT_DIM, NUM_VARS def stochastic_gradient_descent(network_setup, train_data, model, \ verbose=2, verbose_n=1): """ Performs stochastic gradient descent network_setup: info on loss function, hyperparams, and RNN vs FFNN train_data: dataset on which to train (in parsed form) model: neural net current model verbose: 0 to not print; 1 to print every inner iteration; 2 to print every verbose_n iterations verbose_n: used for verbose=2 printing """ # Compute average levels loss_func, loss_func_grad, possible_update, hyper = network_setup temp = [] for elem in zip(*train_data)[0]: if elem != None: temp.append(elem) temp_np = np.array(temp) output_dim = model['b2'].shape[0] data_len = float(len(temp)) divisor_vector = np.zeros((output_dim, 1)) divisor_vector.fill(data_len) average_levels = np.sum(temp_np, axis=0)[: output_dim] / divisor_vector # Main loop for SGD num_updates = 0 # used for step size train_inputs = [j[0] for j in train_data] train_outputs = [j[1] for j in train_data] for t in xrange(hyper.num_iterations): for input_data, correct_output_data in train_data: if input_data == None: model['h'] = [np.zeros((hyper.hidden_dim, 1))] continue num_updates += 1 eta = hyper.step_scale / (math.sqrt(num_updates)) for param in loss_func_grad: grad = loss_func_grad[param](input_data, \ correct_output_data, model, average_levels, hyper) model[param] -= eta * grad possible_update(model, input_data) if verbose == 1: print "Iteration ", t, ": W1 = ", model['W1'], " ; b1 = ", \ model['b1'], " ; W2 = ", model['W2'], " ; b2 = ", model['b2'] if verbose == 1 or verbose == 2 and t % verbose_n == 0: print "-------------------------------------------------------" print "ITERATION ", t, " COMPLETE" current_loss = loss_func(train_inputs, train_outputs, model, \ average_levels, possible_update, hyper) print "Current Loss: ", current_loss final_loss = loss_func(train_inputs, train_outputs, model, \ average_levels, possible_update, hyper) return (model, final_loss)
39.279793
85
0.669437
""" Functions common to both neural networks """ import math import numpy as np import data_util import test_util import feed_forward_nn import elman_rnn from nn_globals import NetHyperparams from nn_globals import OUTPUT_DIM, NUM_VARS def stochastic_gradient_descent(network_setup, train_data, model, \ verbose=2, verbose_n=1): """ Performs stochastic gradient descent network_setup: info on loss function, hyperparams, and RNN vs FFNN train_data: dataset on which to train (in parsed form) model: neural net current model verbose: 0 to not print; 1 to print every inner iteration; 2 to print every verbose_n iterations verbose_n: used for verbose=2 printing """ # Compute average levels loss_func, loss_func_grad, possible_update, hyper = network_setup temp = [] for elem in zip(*train_data)[0]: if elem != None: temp.append(elem) temp_np = np.array(temp) output_dim = model['b2'].shape[0] data_len = float(len(temp)) divisor_vector = np.zeros((output_dim, 1)) divisor_vector.fill(data_len) average_levels = np.sum(temp_np, axis=0)[: output_dim] / divisor_vector # Main loop for SGD num_updates = 0 # used for step size train_inputs = [j[0] for j in train_data] train_outputs = [j[1] for j in train_data] for t in xrange(hyper.num_iterations): for input_data, correct_output_data in train_data: if input_data == None: model['h'] = [np.zeros((hyper.hidden_dim, 1))] continue num_updates += 1 eta = hyper.step_scale / (math.sqrt(num_updates)) for param in loss_func_grad: grad = loss_func_grad[param](input_data, \ correct_output_data, model, average_levels, hyper) model[param] -= eta * grad possible_update(model, input_data) if verbose == 1: print "Iteration ", t, ": W1 = ", model['W1'], " ; b1 = ", \ model['b1'], " ; W2 = ", model['W2'], " ; b2 = ", model['b2'] if verbose == 1 or verbose == 2 and t % verbose_n == 0: print "-------------------------------------------------------" print "ITERATION ", t, " COMPLETE" current_loss = loss_func(train_inputs, train_outputs, model, \ average_levels, possible_update, hyper) print "Current Loss: ", current_loss final_loss = loss_func(train_inputs, train_outputs, model, \ average_levels, possible_update, hyper) return (model, final_loss) def run_neural_net(pollution_data_list, hyper, has_feedback): if not has_feedback: calculate_loss = feed_forward_nn.calculate_loss process_data_set = feed_forward_nn.process_data_set else: calculate_loss = elman_rnn.calculate_loss process_data_set = elman_rnn.process_data_set (input_vectors, output_vectors) = process_data_set( pollution_data_list, hyper.past_scope) train_data = zip(input_vectors, output_vectors) input_dim = NUM_VARS * hyper.past_scope W1 = np.random.randn(hyper.hidden_dim, input_dim) / np.sqrt(input_dim) b1 = np.zeros((hyper.hidden_dim, 1)) W2 = np.random.randn(OUTPUT_DIM, hyper.hidden_dim) / np.sqrt(hyper.hidden_dim) b2 = np.zeros((OUTPUT_DIM, 1)) model = {'W1': W1, 'b1': b1, 'W2': W2, 'b2': b2} if not has_feedback: loss_gradients = feed_forward_nn.get_loss_gradients() update = feed_forward_nn.none_func else: loss_gradients = elman_rnn.get_loss_gradients() update = elman_rnn.update hidden_dim = hyper.hidden_dim U = np.random.randn(hidden_dim, hidden_dim) / np.sqrt(hidden_dim) h = [np.zeros((hidden_dim, 1))] model.update({'U': U, 'h': h}) network_setup = (calculate_loss, loss_gradients, update, hyper) return stochastic_gradient_descent(network_setup, train_data, model) def test_module(pollution_dirs, hyper, has_feedback): # helper for training/testing neural net models pollution_dir_train, pollution_dir_test = pollution_dirs if not has_feedback: calculate_loss = feed_forward_nn.calculate_loss process_data_set = feed_forward_nn.process_data_set update = feed_forward_nn.none_func else: calculate_loss = elman_rnn.calculate_loss process_data_set = elman_rnn.process_data_set update = elman_rnn.update # TRAINING SET pollution_data_list_train = data_util.data_from_directory(pollution_dir_train) # TEST SET pollution_data_list_test = data_util.data_from_directory(pollution_dir_test) (model, loss) = run_neural_net(pollution_data_list_train, hyper, has_feedback) print 'PROCESSING TRAIN SET' (train_inputs, train_outputs) = process_data_set( pollution_data_list_train, hyper.past_scope) print 'PROCESSING TEST SET' (test_inputs, test_outputs) = process_data_set( pollution_data_list_test, hyper.past_scope) # Calculate average levels temp_train = [] for elem in train_inputs: if elem != None: temp_train.append(elem) temp_np_train = np.array(temp_train) data_len_train = float(len(temp_train)) average_levels_train = np.sum(temp_np_train, axis=0)[: OUTPUT_DIM] average_levels_train /= data_len_train print "######################## CALCULATING LOSS ########################" loss = calculate_loss(train_inputs, train_outputs, model, average_levels_train, \ update, hyper, print_loss_vector = True) print "TRAIN LOSS: ", loss (test_inputs, test_outputs) = process_data_set( pollution_data_list_test, hyper.past_scope) # Calculate average levels for test set temp_test = [] for elem in test_inputs: if elem != None: temp_test.append(elem) temp_np_test = np.array(temp_test) data_len_test = float(len(temp_test)) average_levels_test = np.sum(temp_np_test, axis=0)[: OUTPUT_DIM] average_levels_test /= data_len_test print "######################## CALCULATING LOSS ########################" loss = calculate_loss(test_inputs, test_outputs, model, average_levels_test, \ update, hyper, print_loss_vector = True) print "TEST LOSS: ", loss return model def train_nn(algo, pollution_dirs, hyper, pollutant): # helper for training a neural net pollution_dir_train, pollution_dir_test = pollution_dirs test_data_set = data_util.data_from_directory(pollution_dir_test) print 'READING DATA COMPLETE' has_feedback = (algo == 'elman') model = test_module(pollution_dirs, hyper, has_feedback) scopes = (hyper.past_scope, hyper.future_scope) test_util.evaluate_algorithm(scopes, algo, test_data_set, pollutant, \ hyper.norm, hyper=hyper, model=model) def parse_nn_input(args): # helper for parsing input to the neural net args.pollution_dir_test = data_util.remove_slash(args.pollution_dir_test) args.pollution_dir_train = data_util.remove_slash(args.pollution_dir_train) pollution_dirs = (args.pollution_dir_train, args.pollution_dir_test) reg_params = { 'W1': args.reg_w1, 'b1': args.reg_b1, 'W2': args.reg_w2, \ 'b2': args.reg_b2, 'U': args.reg_u } hyper = NetHyperparams(args.hidden_dim, args.activation, args.past_scope, \ reg_params, args.num_iterations, args.future_scope, args.norm, \ args.step_scale) train_nn(args.algo, pollution_dirs, hyper, args.chemical)
4,835
0
92
6c26d63d7ae8a7c7c7e69a1f99e9275446c1f3fb
955
py
Python
WEEKS/CD_Sata-Structures/_RESOURCES/pygorithm/pygorithm/strings/anagram.py
webdevhub42/Lambda
b04b84fb5b82fe7c8b12680149e25ae0d27a0960
[ "MIT" ]
4,736
2017-08-06T03:36:33.000Z
2022-03-31T07:32:55.000Z
WEEKS/CD_Sata-Structures/_RESOURCES/pygorithm/pygorithm/strings/anagram.py
webdevhub42/Lambda
b04b84fb5b82fe7c8b12680149e25ae0d27a0960
[ "MIT" ]
56
2017-08-06T16:34:49.000Z
2022-02-09T19:41:02.000Z
WEEKS/CD_Sata-Structures/_RESOURCES/pygorithm/pygorithm/strings/anagram.py
webdevhub42/Lambda
b04b84fb5b82fe7c8b12680149e25ae0d27a0960
[ "MIT" ]
658
2017-08-06T08:52:02.000Z
2022-03-15T12:09:08.000Z
""" Author: OMKAR PATHAK Created On: 17th August 2017 """ from collections import Counter import inspect def is_anagram(word, _list): """ANAGRAM An anagram is direct word switch or word play, the result of rearranging the letters of a word or phrase to produce a new word or phrase, using all the original letters exactly once we are taking a word and a list. We return the anagrams of that word from the given list and return the list of anagrams else return empty list. :param word: word :param _list: list of words :return: anagrams """ word = word.lower() anagrams = [] for words in _list: if word != words.lower(): if Counter(word) == Counter(words.lower()): anagrams.append(words) return anagrams def get_code(): """ returns the code for the is_anagram function :return: source code """ return inspect.getsource(is_anagram)
25.131579
55
0.659686
""" Author: OMKAR PATHAK Created On: 17th August 2017 """ from collections import Counter import inspect def is_anagram(word, _list): """ANAGRAM An anagram is direct word switch or word play, the result of rearranging the letters of a word or phrase to produce a new word or phrase, using all the original letters exactly once we are taking a word and a list. We return the anagrams of that word from the given list and return the list of anagrams else return empty list. :param word: word :param _list: list of words :return: anagrams """ word = word.lower() anagrams = [] for words in _list: if word != words.lower(): if Counter(word) == Counter(words.lower()): anagrams.append(words) return anagrams def get_code(): """ returns the code for the is_anagram function :return: source code """ return inspect.getsource(is_anagram)
0
0
0
69155fa92fa29e1f8e7e8803b79f8acd0d8c1a18
6,551
py
Python
scripts/update_package_cache.py
KenMacD/pipx
2ecc668acf472ad6956cc682499c077c1130d17e
[ "MIT" ]
3,573
2019-02-06T07:13:28.000Z
2021-05-27T02:34:20.000Z
scripts/update_package_cache.py
KenMacD/pipx
2ecc668acf472ad6956cc682499c077c1130d17e
[ "MIT" ]
533
2019-02-06T19:37:59.000Z
2021-05-27T04:05:30.000Z
scripts/update_package_cache.py
KenMacD/pipx
2ecc668acf472ad6956cc682499c077c1130d17e
[ "MIT" ]
187
2019-02-24T21:56:21.000Z
2021-05-21T15:46:13.000Z
#!/usr/bin/env python3 import argparse import re import subprocess import sys from pathlib import Path from typing import List from list_test_packages import create_test_packages_list from test_packages_support import get_platform_list_path, get_platform_packages_dir_path def process_command_line(argv: List[str]) -> argparse.Namespace: """Process command line invocation arguments and switches. Args: argv: list of arguments, or `None` from ``sys.argv[1:]``. Returns: argparse.Namespace: named attributes of arguments and switches """ # script_name = argv[0] argv = argv[1:] # initialize the parser object: parser = argparse.ArgumentParser( description="Check and update as needed the pipx tests package cache " "for use with the pipx tests local pypiserver." ) # specifying nargs= puts outputs of parser in list (even if nargs=1) # required arguments parser.add_argument( "package_list_dir", help="Directory where platform- and python-specific package lists are found for pipx tests.", ) parser.add_argument( "pipx_package_cache_dir", help="Directory to store the packages distribution files.", ) # switches/options: parser.add_argument( "-c", "--check-only", action="store_true", help="Only check to see if needed packages are in PACKAGES_DIR, do not " "download or delete files.", ) args = parser.parse_args(argv) return args if __name__ == "__main__": try: status = main(sys.argv) except KeyboardInterrupt: print("Stopped by Keyboard Interrupt", file=sys.stderr) status = 130 sys.exit(status)
33.423469
101
0.601893
#!/usr/bin/env python3 import argparse import re import subprocess import sys from pathlib import Path from typing import List from list_test_packages import create_test_packages_list from test_packages_support import get_platform_list_path, get_platform_packages_dir_path def process_command_line(argv: List[str]) -> argparse.Namespace: """Process command line invocation arguments and switches. Args: argv: list of arguments, or `None` from ``sys.argv[1:]``. Returns: argparse.Namespace: named attributes of arguments and switches """ # script_name = argv[0] argv = argv[1:] # initialize the parser object: parser = argparse.ArgumentParser( description="Check and update as needed the pipx tests package cache " "for use with the pipx tests local pypiserver." ) # specifying nargs= puts outputs of parser in list (even if nargs=1) # required arguments parser.add_argument( "package_list_dir", help="Directory where platform- and python-specific package lists are found for pipx tests.", ) parser.add_argument( "pipx_package_cache_dir", help="Directory to store the packages distribution files.", ) # switches/options: parser.add_argument( "-c", "--check-only", action="store_true", help="Only check to see if needed packages are in PACKAGES_DIR, do not " "download or delete files.", ) args = parser.parse_args(argv) return args def update_test_packages_cache( package_list_dir_path: Path, pipx_package_cache_path: Path, check_only: bool ) -> int: exit_code = 0 platform_package_list_path = get_platform_list_path(package_list_dir_path) packages_dir_path = get_platform_packages_dir_path(pipx_package_cache_path) packages_dir_path.mkdir(exist_ok=True) packages_dir_files = list(packages_dir_path.iterdir()) if not platform_package_list_path.exists(): print( f"WARNING. File {str(platform_package_list_path)}\n" " does not exist. Creating now...", file=sys.stderr, ) create_list_returncode = create_test_packages_list( package_list_dir_path, package_list_dir_path / "primary_packages.txt", verbose=False, ) if create_list_returncode == 0: print( f"File {str(platform_package_list_path)}\n" " successfully created. Please check this file in to the" " repository for future use.", file=sys.stderr, ) else: print( f"ERROR. Unable to create {str(platform_package_list_path)}\n" " Cannot continue.\n", file=sys.stderr, ) return 1 try: platform_package_list_fh = platform_package_list_path.open("r") except IOError: print( f"ERROR. File {str(platform_package_list_path)}\n" " is not readable. Cannot continue.\n", file=sys.stderr, ) return 1 else: platform_package_list_fh.close() print("Using the following file to specify needed package files:") print(f" {str(platform_package_list_path)}") print("Ensuring the following directory contains necessary package files:") print(f" {str(packages_dir_path)}") packages_dir_hits = [] packages_dir_missing = [] with platform_package_list_path.open("r") as platform_package_list_fh: for line in platform_package_list_fh: package_spec = line.strip() package_spec_re = re.search(r"^(.+)==(.+)$", package_spec) if not package_spec_re: print(f"ERROR: CANNOT PARSE {package_spec}", file=sys.stderr) exit_code = 1 continue package_name = package_spec_re.group(1) package_ver = package_spec_re.group(2) package_dist_patt = ( re.escape(package_name) + r"-" + re.escape(package_ver) + r"(.tar.gz|.zip|-)" ) matches = [] for output_dir_file in packages_dir_files: if re.search(package_dist_patt, output_dir_file.name): matches.append(output_dir_file) if len(matches) == 1: packages_dir_files.remove(matches[0]) packages_dir_hits.append(matches[0]) continue elif len(matches) > 1: print("ERROR: more than one match for {package_spec}.", file=sys.stderr) print(f" {matches}", file=sys.stderr) exit_code = 1 continue packages_dir_missing.append(package_spec) print(f"MISSING FILES: {len(packages_dir_missing)}") print(f"EXISTING (found) FILES: {len(packages_dir_hits)}") print(f"LEFTOVER (unused) FILES: {len(packages_dir_files)}") if check_only: return 0 if len(packages_dir_missing) == 0 else 1 else: for package_spec in packages_dir_missing: pip_download_process = subprocess.run( [ "pip", "download", "--no-deps", package_spec, "-d", str(packages_dir_path), ], stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True, ) if pip_download_process.returncode == 0: print(f"Successfully downloaded {package_spec}") else: print(f"ERROR downloading {package_spec}", file=sys.stderr) print(pip_download_process.stdout, file=sys.stderr) print(pip_download_process.stderr, file=sys.stderr) exit_code = 1 for unused_file in packages_dir_files: print(f"Deleting {unused_file}...") unused_file.unlink() return exit_code def main(argv: List[str]) -> int: args = process_command_line(argv) return update_test_packages_cache( Path(args.package_list_dir), Path(args.pipx_package_cache_dir), args.check_only ) if __name__ == "__main__": try: status = main(sys.argv) except KeyboardInterrupt: print("Stopped by Keyboard Interrupt", file=sys.stderr) status = 130 sys.exit(status)
4,771
0
46
7c5bb86893977616bf99379a741a3ca7f6af3003
12,981
py
Python
spirl/rl/components/sampler.py
kouroshHakha/fist
328c098789239fd892e17edefd799fc1957ab637
[ "BSD-3-Clause" ]
8
2021-10-14T03:14:23.000Z
2022-03-15T21:31:17.000Z
spirl/rl/components/sampler.py
kouroshHakha/fist
328c098789239fd892e17edefd799fc1957ab637
[ "BSD-3-Clause" ]
null
null
null
spirl/rl/components/sampler.py
kouroshHakha/fist
328c098789239fd892e17edefd799fc1957ab637
[ "BSD-3-Clause" ]
1
2021-09-13T20:42:28.000Z
2021-09-13T20:42:28.000Z
import numpy as np import contextlib from collections import deque from spirl.utils.general_utils import listdict2dictlist, AttrDict, ParamDict, obj2np from spirl.modules.variational_inference import MultivariateGaussian from spirl.rl.utils.reward_fcns import sparse_threshold class Sampler: """Collects rollouts from the environment using the given agent.""" def init(self, is_train): """Starts a new rollout. Render indicates whether output should contain image.""" with self._env.val_mode() if not is_train else contextlib.suppress(): with self._agent.val_mode() if not is_train else contextlib.suppress(): self._episode_reset() def sample_batch(self, batch_size, is_train=True, global_step=None): """Samples an experience batch of the required size.""" experience_batch = [] step = 0 with self._env.val_mode() if not is_train else contextlib.suppress(): with self._agent.val_mode() if not is_train else contextlib.suppress(): with self._agent.rollout_mode(): while step < batch_size: # perform one rollout step agent_output = self.sample_action(self._obs) if agent_output.action is None: self._episode_reset(global_step) continue agent_output = self._postprocess_agent_output(agent_output) obs, reward, done, info = self._env.step(agent_output.action) obs = self._postprocess_obs(obs) experience_batch.append(AttrDict( observation=self._obs, reward=reward, done=done, action=agent_output.action, observation_next=obs, )) # update stored observation self._obs = obs step += 1; self._episode_step += 1; self._episode_reward += reward # reset if episode ends if done or self._episode_step >= self._max_episode_len: if not done: # force done to be True for timeout experience_batch[-1].done = True self._episode_reset(global_step) return listdict2dictlist(experience_batch), step def sample_episode(self, is_train, render=False): """Samples one episode from the environment.""" self.init(is_train) episode, done = [], False with self._env.val_mode() if not is_train else contextlib.suppress(): with self._agent.val_mode() if not is_train else contextlib.suppress(): with self._agent.rollout_mode(): while not done and self._episode_step < self._max_episode_len: # perform one rollout step agent_output = self.sample_action(self._obs) if agent_output.action is None: break agent_output = self._postprocess_agent_output(agent_output) if render: render_obs = self._env.render() obs, reward, done, info = self._env.step(agent_output.action) obs = self._postprocess_obs(obs) episode.append(AttrDict( observation=self._obs, reward=reward, done=done, action=agent_output.action, observation_next=obs, info=obj2np(info), )) if render: episode[-1].update(AttrDict(image=render_obs)) # update stored observation self._obs = obs self._episode_step += 1 episode[-1].done = True # make sure episode is marked as done at final time step return listdict2dictlist(episode) def _episode_reset(self, global_step=None): """Resets sampler at the end of an episode.""" if global_step is not None and self._logger is not None: # logger is none in non-master threads self._logger.log_scalar_dict(self.get_episode_info(), prefix='train' if self._agent._is_train else 'val', step=global_step) self._episode_step, self._episode_reward = 0, 0. self._obs = self._postprocess_obs(self._reset_env()) self._agent.reset() def _postprocess_obs(self, obs): """Optionally post-process observation.""" return obs def _postprocess_agent_output(self, agent_output): """Optionally post-process / store agent output.""" return agent_output class HierarchicalSampler(Sampler): """Collects experience batches by rolling out a hierarchical agent. Aggregates low-level batches into HL batch.""" def sample_batch(self, batch_size, is_train=True, global_step=None, store_ll=True): """Samples the required number of high-level transitions. Number of LL transitions can be higher.""" hl_experience_batch, ll_experience_batch = [], [] env_steps, hl_step = 0, 0 with self._env.val_mode() if not is_train else contextlib.suppress(): with self._agent.val_mode() if not is_train else contextlib.suppress(): with self._agent.rollout_mode(): while hl_step < batch_size or len(ll_experience_batch) <= 1: # perform one rollout step agent_output = self.sample_action(self._obs) agent_output = self._postprocess_agent_output(agent_output) obs, reward, done, info = self._env.step(agent_output.action) obs = self._postprocess_obs(obs) # update last step's 'observation_next' with HL action if store_ll: if ll_experience_batch: ll_experience_batch[-1].observation_next = \ self._agent.make_ll_obs(ll_experience_batch[-1].observation_next, agent_output.hl_action) # store current step in ll_experience_batch ll_experience_batch.append(AttrDict( observation=self._agent.make_ll_obs(self._obs, agent_output.hl_action), reward=reward, done=done, action=agent_output.action, observation_next=obs, # this will get updated in the next step )) # store HL experience batch if this was HL action or episode is done if agent_output.is_hl_step or (done or self._episode_step >= self._max_episode_len-1): if self.last_hl_obs is not None and self.last_hl_action is not None: hl_experience_batch.append(AttrDict( observation=self.last_hl_obs, reward=self.reward_since_last_hl, done=done, action=self.last_hl_action, observation_next=obs, )) hl_step += 1 if hl_step % 1000 == 0: print("Sample step {}".format(hl_step)) self.last_hl_obs = self._obs self.last_hl_action = agent_output.hl_action self.reward_since_last_hl = 0 # update stored observation self._obs = obs env_steps += 1; self._episode_step += 1; self._episode_reward += reward self.reward_since_last_hl += reward # reset if episode ends if done or self._episode_step >= self._max_episode_len: if not done: # force done to be True for timeout ll_experience_batch[-1].done = True if hl_experience_batch: # can potentially be empty hl_experience_batch[-1].done = True self._episode_reset(global_step) return AttrDict( hl_batch=listdict2dictlist(hl_experience_batch), ll_batch=listdict2dictlist(ll_experience_batch[:-1]), # last element does not have updated obs_next! ), env_steps class ImageAugmentedSampler(Sampler): """Appends image rendering to raw observation.""" class MultiImageAugmentedSampler(Sampler): """Appends multiple past images to current observation.""" class ACImageAugmentedSampler(ImageAugmentedSampler): """Adds no-op renders to make sure agent-centric camera reaches agent."""
47.724265
125
0.579925
import numpy as np import contextlib from collections import deque from spirl.utils.general_utils import listdict2dictlist, AttrDict, ParamDict, obj2np from spirl.modules.variational_inference import MultivariateGaussian from spirl.rl.utils.reward_fcns import sparse_threshold class Sampler: """Collects rollouts from the environment using the given agent.""" def __init__(self, config, env, agent, logger, max_episode_len): self._hp = self._default_hparams().overwrite(config) self._env = env self._agent = agent self._logger = logger self._max_episode_len = max_episode_len self._obs = None self._episode_step, self._episode_reward = 0, 0 def _default_hparams(self): return ParamDict({}) def init(self, is_train): """Starts a new rollout. Render indicates whether output should contain image.""" with self._env.val_mode() if not is_train else contextlib.suppress(): with self._agent.val_mode() if not is_train else contextlib.suppress(): self._episode_reset() def sample_action(self, obs): return self._agent.act(obs) def sample_batch(self, batch_size, is_train=True, global_step=None): """Samples an experience batch of the required size.""" experience_batch = [] step = 0 with self._env.val_mode() if not is_train else contextlib.suppress(): with self._agent.val_mode() if not is_train else contextlib.suppress(): with self._agent.rollout_mode(): while step < batch_size: # perform one rollout step agent_output = self.sample_action(self._obs) if agent_output.action is None: self._episode_reset(global_step) continue agent_output = self._postprocess_agent_output(agent_output) obs, reward, done, info = self._env.step(agent_output.action) obs = self._postprocess_obs(obs) experience_batch.append(AttrDict( observation=self._obs, reward=reward, done=done, action=agent_output.action, observation_next=obs, )) # update stored observation self._obs = obs step += 1; self._episode_step += 1; self._episode_reward += reward # reset if episode ends if done or self._episode_step >= self._max_episode_len: if not done: # force done to be True for timeout experience_batch[-1].done = True self._episode_reset(global_step) return listdict2dictlist(experience_batch), step def sample_episode(self, is_train, render=False): """Samples one episode from the environment.""" self.init(is_train) episode, done = [], False with self._env.val_mode() if not is_train else contextlib.suppress(): with self._agent.val_mode() if not is_train else contextlib.suppress(): with self._agent.rollout_mode(): while not done and self._episode_step < self._max_episode_len: # perform one rollout step agent_output = self.sample_action(self._obs) if agent_output.action is None: break agent_output = self._postprocess_agent_output(agent_output) if render: render_obs = self._env.render() obs, reward, done, info = self._env.step(agent_output.action) obs = self._postprocess_obs(obs) episode.append(AttrDict( observation=self._obs, reward=reward, done=done, action=agent_output.action, observation_next=obs, info=obj2np(info), )) if render: episode[-1].update(AttrDict(image=render_obs)) # update stored observation self._obs = obs self._episode_step += 1 episode[-1].done = True # make sure episode is marked as done at final time step return listdict2dictlist(episode) def get_episode_info(self): episode_info = AttrDict(episode_reward=self._episode_reward, episode_length=self._episode_step,) if hasattr(self._env, "get_episode_info"): episode_info.update(self._env.get_episode_info()) return episode_info def _episode_reset(self, global_step=None): """Resets sampler at the end of an episode.""" if global_step is not None and self._logger is not None: # logger is none in non-master threads self._logger.log_scalar_dict(self.get_episode_info(), prefix='train' if self._agent._is_train else 'val', step=global_step) self._episode_step, self._episode_reward = 0, 0. self._obs = self._postprocess_obs(self._reset_env()) self._agent.reset() def _reset_env(self): return self._env.reset() def _postprocess_obs(self, obs): """Optionally post-process observation.""" return obs def _postprocess_agent_output(self, agent_output): """Optionally post-process / store agent output.""" return agent_output class HierarchicalSampler(Sampler): """Collects experience batches by rolling out a hierarchical agent. Aggregates low-level batches into HL batch.""" def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.last_hl_obs, self.last_hl_action = None, None # stores observation when last hl action was taken self.reward_since_last_hl = 0 # accumulates the reward since the last HL step for HL transition def sample_batch(self, batch_size, is_train=True, global_step=None, store_ll=True): """Samples the required number of high-level transitions. Number of LL transitions can be higher.""" hl_experience_batch, ll_experience_batch = [], [] env_steps, hl_step = 0, 0 with self._env.val_mode() if not is_train else contextlib.suppress(): with self._agent.val_mode() if not is_train else contextlib.suppress(): with self._agent.rollout_mode(): while hl_step < batch_size or len(ll_experience_batch) <= 1: # perform one rollout step agent_output = self.sample_action(self._obs) agent_output = self._postprocess_agent_output(agent_output) obs, reward, done, info = self._env.step(agent_output.action) obs = self._postprocess_obs(obs) # update last step's 'observation_next' with HL action if store_ll: if ll_experience_batch: ll_experience_batch[-1].observation_next = \ self._agent.make_ll_obs(ll_experience_batch[-1].observation_next, agent_output.hl_action) # store current step in ll_experience_batch ll_experience_batch.append(AttrDict( observation=self._agent.make_ll_obs(self._obs, agent_output.hl_action), reward=reward, done=done, action=agent_output.action, observation_next=obs, # this will get updated in the next step )) # store HL experience batch if this was HL action or episode is done if agent_output.is_hl_step or (done or self._episode_step >= self._max_episode_len-1): if self.last_hl_obs is not None and self.last_hl_action is not None: hl_experience_batch.append(AttrDict( observation=self.last_hl_obs, reward=self.reward_since_last_hl, done=done, action=self.last_hl_action, observation_next=obs, )) hl_step += 1 if hl_step % 1000 == 0: print("Sample step {}".format(hl_step)) self.last_hl_obs = self._obs self.last_hl_action = agent_output.hl_action self.reward_since_last_hl = 0 # update stored observation self._obs = obs env_steps += 1; self._episode_step += 1; self._episode_reward += reward self.reward_since_last_hl += reward # reset if episode ends if done or self._episode_step >= self._max_episode_len: if not done: # force done to be True for timeout ll_experience_batch[-1].done = True if hl_experience_batch: # can potentially be empty hl_experience_batch[-1].done = True self._episode_reset(global_step) return AttrDict( hl_batch=listdict2dictlist(hl_experience_batch), ll_batch=listdict2dictlist(ll_experience_batch[:-1]), # last element does not have updated obs_next! ), env_steps def _episode_reset(self, global_step=None): super()._episode_reset(global_step) self.last_hl_obs, self.last_hl_action = None, None self.reward_since_last_hl = 0 class ImageAugmentedSampler(Sampler): """Appends image rendering to raw observation.""" def _postprocess_obs(self, obs): img = self._env.render().transpose(2, 0, 1) * 2. - 1.0 return np.concatenate((obs, img.flatten())) class MultiImageAugmentedSampler(Sampler): """Appends multiple past images to current observation.""" def _episode_reset(self, global_step=None): self._past_frames = deque(maxlen=self._hp.n_frames) # build ring-buffer of past images super()._episode_reset(global_step) def _postprocess_obs(self, obs): img = self._env.render().transpose(2, 0, 1) * 2. - 1.0 if not self._past_frames: # initialize past frames with N copies of current frame [self._past_frames.append(img) for _ in range(self._hp.n_frames - 1)] self._past_frames.append(img) stacked_img = np.concatenate(list(self._past_frames), axis=0) return np.concatenate((obs, stacked_img.flatten())) class ACImageAugmentedSampler(ImageAugmentedSampler): """Adds no-op renders to make sure agent-centric camera reaches agent.""" def _reset_env(self): obs = super()._reset_env() for _ in range(100): # so that camera can "reach" agent self._env.render(mode='rgb_array') return obs class ACMultiImageAugmentedSampler(MultiImageAugmentedSampler, ACImageAugmentedSampler): def _reset_env(self): return ACImageAugmentedSampler._reset_env(self) class ImageAugmentedHierarchicalSampler(HierarchicalSampler, ImageAugmentedSampler): def _postprocess_obs(self, *args, **kwargs): return ImageAugmentedSampler._postprocess_obs(self, *args, **kwargs) class MultiImageAugmentedHierarchicalSampler(HierarchicalSampler, MultiImageAugmentedSampler): def _postprocess_obs(self, *args, **kwargs): return MultiImageAugmentedSampler._postprocess_obs(self, *args, **kwargs) def _episode_reset(self, *args, **kwargs): return MultiImageAugmentedSampler._episode_reset(self, *args, **kwargs) class ACImageAugmentedHierarchicalSampler(ImageAugmentedHierarchicalSampler, ACImageAugmentedSampler): def _reset_env(self): return ACImageAugmentedSampler._reset_env(self) class ACMultiImageAugmentedHierarchicalSampler(MultiImageAugmentedHierarchicalSampler, ACImageAugmentedHierarchicalSampler): def _reset_env(self): return ACImageAugmentedHierarchicalSampler._reset_env(self)
2,508
434
564
6714fbeb710fcef63d832311201eece32ab3f7e1
5,669
py
Python
airflow/dags/etl.py
Ayazdi/tweetbot
d9b3ddd77ba530d6a192fe53f65a4d9994c3a092
[ "MIT" ]
null
null
null
airflow/dags/etl.py
Ayazdi/tweetbot
d9b3ddd77ba530d6a192fe53f65a4d9994c3a092
[ "MIT" ]
null
null
null
airflow/dags/etl.py
Ayazdi/tweetbot
d9b3ddd77ba530d6a192fe53f65a4d9994c3a092
[ "MIT" ]
null
null
null
import time from datetime import datetime, timedelta import random import re import logging from config import SLACK_TOKEN import pandas as pd import slack from airflow import DAG from airflow.operators.python_operator import PythonOperator from pymongo import MongoClient from sqlalchemy import create_engine from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer from sklearn.feature_extraction.text import TfidfVectorizer from sklearn.svm import LinearSVC import pickle import os # defining path to read files for airflow AIRFLOW_HOME = os.getenv('AIRFLOW_HOME') # Creating connections CLIENT = MongoClient("mongodb") # Mongodb DB = CLIENT.mongodb DATABASE_UP = False # PostGres connections and table PG = create_engine('postgres://postgres:1234@postgresdb:5432/tweets') PG.execute('''CREATE TABLE IF NOT EXISTS kung_tweets ( id BIGSERIAL, username VARCHAR(128), text VARCHAR(2048), date_created TIMESTAMPTZ, followers INTEGER, friends INTEGER, negative NUMERIC, positive NUMERIC, neuteral NUMERIC ); ''') client = slack.WebClient(token=SLACK_TOKEN) # Slac # Loading models: # Sentiment analysis s = SentimentIntensityAnalyzer() # Sarcasm classifier tv = pickle.load(open(AIRFLOW_HOME + '/dags/vectorizer.sav', 'rb')) lsvc = pickle.load(open(AIRFLOW_HOME + '/dags/sarcasm_model.sav', 'rb')) # Creating python callables def extract(): """extract a random tweet from MongoDB""" tweets = list(DB.kung_tweets.find()) if tweets: t = random.choice(tweets) logging.critical("random tweet: " + t['text']) return t def transform(**context): """ Transform tweets Input: Tweets in JSON format from the extract function Cleans the text, analyzes the sentiment and extracts metadata return: A list with all metadata of the tweet """ extract_connection = context['task_instance'] tweet = extract_connection.xcom_pull(task_ids="extract") # getting the full text from the tweets if 'retweeted_status'in tweet and 'extended_tweet' in tweet['retweeted_status']: text = tweet['retweeted_status']['extended_tweet']["full_text"] elif 'retweeted_status'in tweet and 'text' in tweet['retweeted_status']: text = tweet['retweeted_status']["text"] elif "extended_tweet" in tweet: text = tweet['extended_tweet']["full_text"] else: text = tweet['text'] text = re.sub(r"'", ' ', text) text = re.sub(r'@\S+|https?://\S+', '', text) # removing @user and links username = tweet['user']['screen_name'] date = str(pd.to_datetime(tweet["created_at"])) followers = tweet['user']['followers_count'] friends = tweet['user']['friends_count'] sentiment = s.polarity_scores(text) neg = sentiment["neg"] pos = sentiment["pos"] neu = sentiment["neu"] logging.critical("sentiment" + str(sentiment)) results = [username, text, date, followers, friends, neg, pos, neu] return results def load(**context): """Loads metadata to PostGreSQL server""" exctract_connection = context["task_instance"] results = exctract_connection.xcom_pull(task_ids='transform') PG.execute(f"""INSERT INTO kung_tweets (username, text, date_created, followers, friends, negative, positive, neuteral) VALUES ('''{results[0]}''', '''{results[1]}''', '{results[2]}', {results[3]}, {results[4]}, {results[5]}, {results[6]}, {results[7]});""") logging.critical(f"{results[1]} written to PostGres") def predict_sarcasm(**context): """Classify the sarcasm of the tweet""" exctract_connection = context["task_instance"] results = exctract_connection.xcom_pull(task_ids='transform') text = results[1] text = tv.transform([text]).toarray() sarcasm = lsvc.predict(text) return sarcasm def slackbot(**context): """Posts a message on the Slack channel if the tweet was clasified as sarcastic""" exctract_connection = context["task_instance"] results = exctract_connection.xcom_pull(task_ids='transform') sarcasm = exctract_connection.xcom_pull(task_ids='predict_sarcasm') prev_tweet = '' if sarcasm == 1: tweet_result = results[1] # text if tweet_result != prev_tweet: prev_tweet = tweet_result response = client.chat_postMessage( channel='#kung_flu', text=f"Here is a sarcastic tweet about coronavirus: {tweet_result}") # delay for one minute time.sleep(60) # define default arguments default_args = { 'owner': 'Amirali', 'start_date': datetime(2020, 4, 1), # 'end_date': 'email': ['[email protected]'], 'email_on_failure': False, 'email_on_retry': False, "retries": 1, "retry_delay": timedelta(minutes=1) } # instantiate a DAG dag = DAG('etl', description='', catchup=False, schedule_interval=timedelta(minutes=1), default_args=default_args) # define task t1 = PythonOperator(task_id='extract', python_callable=extract, dag=dag) t2 = PythonOperator(task_id='transform', provide_context=True, python_callable=transform, dag=dag) t3 = PythonOperator(task_id='load', provide_context=True, python_callable=load, dag=dag) t4 = PythonOperator(task_id='predict_sarcasm', provide_context=True, python_callable=predict_sarcasm, dag=dag) t5 = PythonOperator(task_id='slackbot', provide_context=True, python_callable=slackbot, dag=dag) # setup dependencies t1 >> t2 >> t3 t2 >> t4 >> t5
33.946108
155
0.676133
import time from datetime import datetime, timedelta import random import re import logging from config import SLACK_TOKEN import pandas as pd import slack from airflow import DAG from airflow.operators.python_operator import PythonOperator from pymongo import MongoClient from sqlalchemy import create_engine from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer from sklearn.feature_extraction.text import TfidfVectorizer from sklearn.svm import LinearSVC import pickle import os # defining path to read files for airflow AIRFLOW_HOME = os.getenv('AIRFLOW_HOME') # Creating connections CLIENT = MongoClient("mongodb") # Mongodb DB = CLIENT.mongodb DATABASE_UP = False # PostGres connections and table PG = create_engine('postgres://postgres:1234@postgresdb:5432/tweets') PG.execute('''CREATE TABLE IF NOT EXISTS kung_tweets ( id BIGSERIAL, username VARCHAR(128), text VARCHAR(2048), date_created TIMESTAMPTZ, followers INTEGER, friends INTEGER, negative NUMERIC, positive NUMERIC, neuteral NUMERIC ); ''') client = slack.WebClient(token=SLACK_TOKEN) # Slac # Loading models: # Sentiment analysis s = SentimentIntensityAnalyzer() # Sarcasm classifier tv = pickle.load(open(AIRFLOW_HOME + '/dags/vectorizer.sav', 'rb')) lsvc = pickle.load(open(AIRFLOW_HOME + '/dags/sarcasm_model.sav', 'rb')) # Creating python callables def extract(): """extract a random tweet from MongoDB""" tweets = list(DB.kung_tweets.find()) if tweets: t = random.choice(tweets) logging.critical("random tweet: " + t['text']) return t def transform(**context): """ Transform tweets Input: Tweets in JSON format from the extract function Cleans the text, analyzes the sentiment and extracts metadata return: A list with all metadata of the tweet """ extract_connection = context['task_instance'] tweet = extract_connection.xcom_pull(task_ids="extract") # getting the full text from the tweets if 'retweeted_status'in tweet and 'extended_tweet' in tweet['retweeted_status']: text = tweet['retweeted_status']['extended_tweet']["full_text"] elif 'retweeted_status'in tweet and 'text' in tweet['retweeted_status']: text = tweet['retweeted_status']["text"] elif "extended_tweet" in tweet: text = tweet['extended_tweet']["full_text"] else: text = tweet['text'] text = re.sub(r"'", ' ', text) text = re.sub(r'@\S+|https?://\S+', '', text) # removing @user and links username = tweet['user']['screen_name'] date = str(pd.to_datetime(tweet["created_at"])) followers = tweet['user']['followers_count'] friends = tweet['user']['friends_count'] sentiment = s.polarity_scores(text) neg = sentiment["neg"] pos = sentiment["pos"] neu = sentiment["neu"] logging.critical("sentiment" + str(sentiment)) results = [username, text, date, followers, friends, neg, pos, neu] return results def load(**context): """Loads metadata to PostGreSQL server""" exctract_connection = context["task_instance"] results = exctract_connection.xcom_pull(task_ids='transform') PG.execute(f"""INSERT INTO kung_tweets (username, text, date_created, followers, friends, negative, positive, neuteral) VALUES ('''{results[0]}''', '''{results[1]}''', '{results[2]}', {results[3]}, {results[4]}, {results[5]}, {results[6]}, {results[7]});""") logging.critical(f"{results[1]} written to PostGres") def predict_sarcasm(**context): """Classify the sarcasm of the tweet""" exctract_connection = context["task_instance"] results = exctract_connection.xcom_pull(task_ids='transform') text = results[1] text = tv.transform([text]).toarray() sarcasm = lsvc.predict(text) return sarcasm def slackbot(**context): """Posts a message on the Slack channel if the tweet was clasified as sarcastic""" exctract_connection = context["task_instance"] results = exctract_connection.xcom_pull(task_ids='transform') sarcasm = exctract_connection.xcom_pull(task_ids='predict_sarcasm') prev_tweet = '' if sarcasm == 1: tweet_result = results[1] # text if tweet_result != prev_tweet: prev_tweet = tweet_result response = client.chat_postMessage( channel='#kung_flu', text=f"Here is a sarcastic tweet about coronavirus: {tweet_result}") # delay for one minute time.sleep(60) # define default arguments default_args = { 'owner': 'Amirali', 'start_date': datetime(2020, 4, 1), # 'end_date': 'email': ['[email protected]'], 'email_on_failure': False, 'email_on_retry': False, "retries": 1, "retry_delay": timedelta(minutes=1) } # instantiate a DAG dag = DAG('etl', description='', catchup=False, schedule_interval=timedelta(minutes=1), default_args=default_args) # define task t1 = PythonOperator(task_id='extract', python_callable=extract, dag=dag) t2 = PythonOperator(task_id='transform', provide_context=True, python_callable=transform, dag=dag) t3 = PythonOperator(task_id='load', provide_context=True, python_callable=load, dag=dag) t4 = PythonOperator(task_id='predict_sarcasm', provide_context=True, python_callable=predict_sarcasm, dag=dag) t5 = PythonOperator(task_id='slackbot', provide_context=True, python_callable=slackbot, dag=dag) # setup dependencies t1 >> t2 >> t3 t2 >> t4 >> t5
0
0
0
07e7e3e2137257e0b56dc2a7750cbb5cde4f42cd
114
py
Python
chapter09/example07.py
YordanIH/Intro_to_CS_w_Python
eebbb8efd7ef0d07be9bc45b6b1e8f20737ce01a
[ "MIT" ]
null
null
null
chapter09/example07.py
YordanIH/Intro_to_CS_w_Python
eebbb8efd7ef0d07be9bc45b6b1e8f20737ce01a
[ "MIT" ]
null
null
null
chapter09/example07.py
YordanIH/Intro_to_CS_w_Python
eebbb8efd7ef0d07be9bc45b6b1e8f20737ce01a
[ "MIT" ]
null
null
null
#looping over the generated range of numbers total = 0 for i in range(1, 101): total = total + i print(total)
19
44
0.692982
#looping over the generated range of numbers total = 0 for i in range(1, 101): total = total + i print(total)
0
0
0
0ea7768fd185301fdacd4b292ea08a02f037179e
21,031
py
Python
train_cloudcast.py
tianyu-z/Super-SloMo
55a278cc46b6edb731895548b5a5c26e9b3439ae
[ "MIT" ]
null
null
null
train_cloudcast.py
tianyu-z/Super-SloMo
55a278cc46b6edb731895548b5a5c26e9b3439ae
[ "MIT" ]
null
null
null
train_cloudcast.py
tianyu-z/Super-SloMo
55a278cc46b6edb731895548b5a5c26e9b3439ae
[ "MIT" ]
null
null
null
# [Super SloMo] ##High Quality Estimation of Multiple Intermediate Frames for Video Interpolation from comet_ml import Experiment, ExistingExperiment import argparse import torch import torchvision import torchvision.transforms as transforms import torch.optim as optim import torch.nn as nn import torch.nn.functional as F import model import dataloader_c as dataloader from math import log10 import datetime import numpy as np import warnings from pytorch_msssim import ssim, ms_ssim, SSIM, MS_SSIM # pip install pytorch-msssim from PIL import Image import torchvision.utils as vutils from utils import init_net, upload_images warnings.simplefilter("ignore", UserWarning) # from tensorboardX import SummaryWriter # For parsing commandline arguments parser = argparse.ArgumentParser() parser.add_argument( "--dataset_root", type=str, required=True, help="path to dataset folder containing train-test-validation folders", ) parser.add_argument( "--checkpoint_dir", type=str, required=True, help="path to folder for saving checkpoints", ) parser.add_argument( "--checkpoint", type=str, help="path of checkpoint for pretrained model" ) parser.add_argument( "--train_continue", action="store_true", help="resuming from checkpoint." ) parser.add_argument( "-it", "--init_type", default="", type=str, help="the name of an initialization method: normal | xavier | kaiming | orthogonal", ) parser.add_argument( "--epochs", type=int, default=200, help="number of epochs to train. Default: 200." ) parser.add_argument( "-tbs", "--train_batch_size", type=int, default=384, help="batch size for training. Default: 6.", ) parser.add_argument( "-nw", "--num_workers", default=4, type=int, help="number of CPU you get" ) parser.add_argument( "-vbs", "--validation_batch_size", type=int, default=384, help="batch size for validation. Default: 10.", ) parser.add_argument( "-ilr", "--init_learning_rate", type=float, default=0.0001, help="set initial learning rate. Default: 0.0001.", ) parser.add_argument( "--milestones", type=list, default=[100, 150], help="Set to epoch values where you want to decrease learning rate by a factor of 0.1. Default: [100, 150]", ) parser.add_argument( "--progress_iter", type=int, default=100, help="frequency of reporting progress and validation. N: after every N iterations. Default: 100.", ) parser.add_argument( "--logimagefreq", type=int, default=1, help="frequency of logging image.", ) parser.add_argument( "--checkpoint_epoch", type=int, default=5, help="checkpoint saving frequency. N: after every N epochs. Each checkpoint is roughly of size 151 MB.Default: 5.", ) parser.add_argument( "-wp", "--workspace", default="tianyu-z", type=str, help="comet-ml workspace" ) parser.add_argument( "-dh", "--data_h", default=128, type=int, help="H of the data shape" ) parser.add_argument( "-dw", "--data_w", default=128, type=int, help="W of the data shape" ) parser.add_argument( "-pn", "--projectname", default="super-slomo", type=str, help="comet-ml project name", ) parser.add_argument( "--nocomet", action="store_true", help="not using comet_ml logging." ) parser.add_argument( "--cometid", type=str, default="", help="the comet id to resume exps", ) parser.add_argument( "-rs", "--randomseed", type=int, default=2021, help="batch size for validation. Default: 10.", ) args = parser.parse_args() random_seed = args.randomseed np.random.seed(random_seed) torch.manual_seed(random_seed) if torch.cuda.device_count() > 1: torch.cuda.manual_seed_all(random_seed) else: torch.cuda.manual_seed(random_seed) torch.backends.cudnn.deterministic = True torch.backends.cudnn.benchmark = False ##[TensorboardX](https://github.com/lanpa/tensorboardX) ### For visualizing loss and interpolated frames # writer = SummaryWriter("log") ###Initialize flow computation and arbitrary-time flow interpolation CNNs. device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu") flowComp = model.UNet(6, 4) flowComp.to(device) if args.init_type != "": init_net(flowComp, args.init_type) print(args.init_type + " initializing flowComp done") ArbTimeFlowIntrp = model.UNet(20, 5) ArbTimeFlowIntrp.to(device) if args.init_type != "": init_net(ArbTimeFlowIntrp, args.init_type) print(args.init_type + " initializing ArbTimeFlowIntrp done") ### Initialization if args.train_continue: if not args.nocomet and args.cometid != "": comet_exp = ExistingExperiment(previous_experiment=args.cometid) elif not args.nocomet and args.cometid == "": comet_exp = Experiment(workspace=args.workspace, project_name=args.projectname) else: comet_exp = None dict1 = torch.load(args.checkpoint) ArbTimeFlowIntrp.load_state_dict(dict1["state_dictAT"]) flowComp.load_state_dict(dict1["state_dictFC"]) print("Pretrained model loaded!") else: # start logging info in comet-ml if not args.nocomet: comet_exp = Experiment(workspace=args.workspace, project_name=args.projectname) # comet_exp.log_parameters(flatten_opts(args)) else: comet_exp = None dict1 = {"loss": [], "valLoss": [], "valPSNR": [], "valSSIM": [], "epoch": -1} ###Initialze backward warpers for train and validation datasets trainFlowBackWarp = model.backWarp(128, 128, device) trainFlowBackWarp = trainFlowBackWarp.to(device) validationFlowBackWarp = model.backWarp(128, 128, device) validationFlowBackWarp = validationFlowBackWarp.to(device) ###Load Datasets # Channel wise mean calculated on adobe240-fps training dataset mean = [0.5, 0.5, 0.5] std = [1, 1, 1] normalize = transforms.Normalize(mean=mean, std=std) transform = transforms.Compose([transforms.ToTensor(), normalize]) trainset = dataloader.SuperSloMo( root=args.dataset_root + "/train", transform=transform, train=True ) trainloader = torch.utils.data.DataLoader( trainset, batch_size=args.train_batch_size, num_workers=args.num_workers, shuffle=True, ) validationset = dataloader.SuperSloMo( root=args.dataset_root + "/validation", transform=transform, randomCropSize=(128, 128), train=False, ) validationloader = torch.utils.data.DataLoader( validationset, batch_size=args.validation_batch_size, num_workers=args.num_workers, shuffle=False, ) print(trainset, validationset) ###Create transform to display image from tensor negmean = [x * -1 for x in mean] revNormalize = transforms.Normalize(mean=negmean, std=std) TP = transforms.Compose([revNormalize, transforms.ToPILImage()]) ###Utils ###Loss and Optimizer L1_lossFn = nn.L1Loss() MSE_LossFn = nn.MSELoss() params = list(ArbTimeFlowIntrp.parameters()) + list(flowComp.parameters()) optimizer = optim.Adam(params, lr=args.init_learning_rate) # scheduler to decrease learning rate by a factor of 10 at milestones. scheduler = optim.lr_scheduler.MultiStepLR( optimizer, milestones=args.milestones, gamma=0.1 ) ###Initializing VGG16 model for perceptual loss vgg16 = torchvision.models.vgg16(pretrained=True) vgg16_conv_4_3 = nn.Sequential(*list(vgg16.children())[0][:22]) vgg16_conv_4_3.to(device) if args.init_type != "": init_net(vgg16_conv_4_3, args.init_type) for param in vgg16_conv_4_3.parameters(): param.requires_grad = False ### Validation function # ### Training import time best_psnr = -1 best_ssim = -1 best_valloss = 9999 start = time.time() cLoss = dict1["loss"] valLoss = dict1["valLoss"] valPSNR = dict1["valPSNR"] valSSIM = dict1["valSSIM"] checkpoint_counter = int((dict1["epoch"] + 1) / args.checkpoint_epoch) ### Main training loop for epoch in range(dict1["epoch"] + 1, args.epochs): print("Epoch: ", epoch) # Append and reset cLoss.append([]) valLoss.append([]) valPSNR.append([]) valSSIM.append([]) iLoss = 0 if epoch > dict1["epoch"] + 1: # Increment scheduler count scheduler.step() # if epoch == dict1["epoch"] + 1: # # test if validate works # validate(epoch, True) for trainIndex, (trainData, trainFrameIndex) in enumerate(trainloader, 0): ## Getting the input and the target from the training set frame0, frameT, frame1 = trainData I0 = frame0.to(device) I1 = frame1.to(device) IFrame = frameT.to(device) optimizer.zero_grad() # Calculate flow between reference frames I0 and I1 flowOut = flowComp(torch.cat((I0, I1), dim=1)) # Extracting flows between I0 and I1 - F_0_1 and F_1_0 F_0_1 = flowOut[:, :2, :, :] F_1_0 = flowOut[:, 2:, :, :] fCoeff = model.getFlowCoeff(trainFrameIndex, device) # Calculate intermediate flows F_t_0 = fCoeff[0] * F_0_1 + fCoeff[1] * F_1_0 F_t_1 = fCoeff[2] * F_0_1 + fCoeff[3] * F_1_0 # Get intermediate frames from the intermediate flows g_I0_F_t_0 = trainFlowBackWarp(I0, F_t_0) g_I1_F_t_1 = trainFlowBackWarp(I1, F_t_1) # Calculate optical flow residuals and visibility maps intrpOut = ArbTimeFlowIntrp( torch.cat( (I0, I1, F_0_1, F_1_0, F_t_1, F_t_0, g_I1_F_t_1, g_I0_F_t_0), dim=1 ) ) # Extract optical flow residuals and visibility maps F_t_0_f = intrpOut[:, :2, :, :] + F_t_0 F_t_1_f = intrpOut[:, 2:4, :, :] + F_t_1 V_t_0 = torch.sigmoid(intrpOut[:, 4:5, :, :]) V_t_1 = 1 - V_t_0 # Get intermediate frames from the intermediate flows g_I0_F_t_0_f = trainFlowBackWarp(I0, F_t_0_f) g_I1_F_t_1_f = trainFlowBackWarp(I1, F_t_1_f) wCoeff = model.getWarpCoeff(trainFrameIndex, device) # Calculate final intermediate frame Ft_p = (wCoeff[0] * V_t_0 * g_I0_F_t_0_f + wCoeff[1] * V_t_1 * g_I1_F_t_1_f) / ( wCoeff[0] * V_t_0 + wCoeff[1] * V_t_1 ) # Loss recnLoss = L1_lossFn(Ft_p, IFrame) prcpLoss = MSE_LossFn(vgg16_conv_4_3(Ft_p), vgg16_conv_4_3(IFrame)) warpLoss = ( L1_lossFn(g_I0_F_t_0, IFrame) + L1_lossFn(g_I1_F_t_1, IFrame) + L1_lossFn(trainFlowBackWarp(I0, F_1_0), I1) + L1_lossFn(trainFlowBackWarp(I1, F_0_1), I0) ) loss_smooth_1_0 = torch.mean( torch.abs(F_1_0[:, :, :, :-1] - F_1_0[:, :, :, 1:]) ) + torch.mean(torch.abs(F_1_0[:, :, :-1, :] - F_1_0[:, :, 1:, :])) loss_smooth_0_1 = torch.mean( torch.abs(F_0_1[:, :, :, :-1] - F_0_1[:, :, :, 1:]) ) + torch.mean(torch.abs(F_0_1[:, :, :-1, :] - F_0_1[:, :, 1:, :])) loss_smooth = loss_smooth_1_0 + loss_smooth_0_1 # Total Loss - Coefficients 204 and 102 are used instead of 0.8 and 0.4 # since the loss in paper is calculated for input pixels in range 0-255 # and the input to our network is in range 0-1 loss = 204 * recnLoss + 102 * warpLoss + 0.005 * prcpLoss + loss_smooth # Backpropagate loss.backward() optimizer.step() iLoss += loss.item() # Validation and progress every `args.progress_iter` iterations # if (trainIndex % args.progress_iter) == args.progress_iter - 1: end = time.time() psnr, ssim_val, vLoss, valImg = validate(epoch, logimage=True) valPSNR[epoch].append(psnr) valSSIM[epoch].append(ssim_val) valLoss[epoch].append(vLoss) # Tensorboard itr = int(trainIndex + epoch * (len(trainloader))) # writer.add_scalars( # "Loss", # {"trainLoss": iLoss / args.progress_iter, "validationLoss": vLoss}, # itr, # ) # writer.add_scalar("PSNR", psnr, itr) # writer.add_image("Validation", valImg, itr) comet_exp.log_metrics( {"trainLoss": iLoss / args.progress_iter, "validationLoss": vLoss}, step=itr, epoch=epoch, ) comet_exp.log_metric("PSNR", psnr, step=itr, epoch=epoch) comet_exp.log_metric("SSIM", ssim_val, step=itr, epoch=epoch) # valImage = torch.movedim(valImg, 0, -1) # print(type(valImage)) # print(valImage.shape) # print(valImage.max()) # print(valImage.min()) # comet_exp.log_image( # valImage, # name="iter: " + str(iter) + ";epoch: " + str(epoch), # image_format="jpg", # step=itr, # ) ##### endVal = time.time() print( " Loss: %0.6f Iterations: %4d/%4d TrainExecTime: %0.1f ValLoss:%0.6f ValPSNR: %0.4f ValSSIM: %0.4f ValEvalTime: %0.2f LearningRate: %f" % ( iLoss / args.progress_iter, trainIndex, len(trainloader), end - start, vLoss, psnr, ssim_val, endVal - end, get_lr(optimizer), ) ) cLoss[epoch].append(iLoss / args.progress_iter) iLoss = 0 start = time.time() # Create checkpoint after every `args.checkpoint_epoch` epochs if (epoch % args.checkpoint_epoch) == args.checkpoint_epoch - 1: dict1 = { "Detail": "End to end Super SloMo.", "epoch": epoch, "timestamp": datetime.datetime.now(), "trainBatchSz": args.train_batch_size, "validationBatchSz": args.validation_batch_size, "learningRate": get_lr(optimizer), "loss": cLoss, "valLoss": valLoss, "valPSNR": valPSNR, "valSSIM": valSSIM, "state_dictFC": flowComp.state_dict(), "state_dictAT": ArbTimeFlowIntrp.state_dict(), } torch.save( dict1, args.checkpoint_dir + "/SuperSloMo" + str(checkpoint_counter) + ".ckpt", ) checkpoint_counter += 1 if psnr > best_psnr: best_psnr = psnr dict1 = { "Detail": "End to end Super SloMo.", "epoch": epoch, "timestamp": datetime.datetime.now(), "trainBatchSz": args.train_batch_size, "validationBatchSz": args.validation_batch_size, "learningRate": get_lr(optimizer), "loss": cLoss, "valLoss": valLoss, "valPSNR": valPSNR, "valSSIM": valSSIM, "state_dictFC": flowComp.state_dict(), "state_dictAT": ArbTimeFlowIntrp.state_dict(), } torch.save( dict1, args.checkpoint_dir + "/SuperSloMo" + "bestpsnr_epoch" + ".ckpt", ) print("New Best PSNR found and saved at " + str(epoch)) if vLoss < best_valloss: best_valloss = vLoss dict1 = { "Detail": "End to end Super SloMo.", "epoch": epoch, "timestamp": datetime.datetime.now(), "trainBatchSz": args.train_batch_size, "validationBatchSz": args.validation_batch_size, "learningRate": get_lr(optimizer), "loss": cLoss, "valLoss": valLoss, "valPSNR": valPSNR, "valSSIM": valSSIM, "state_dictFC": flowComp.state_dict(), "state_dictAT": ArbTimeFlowIntrp.state_dict(), } torch.save( dict1, args.checkpoint_dir + "/SuperSloMo" + "bestvalloss_epoch" + ".ckpt", ) print("New Best valloss found and saved at " + str(epoch)) if ssim_val > best_ssim: best_ssim = ssim_val dict1 = { "Detail": "End to end Super SloMo.", "epoch": epoch, "timestamp": datetime.datetime.now(), "trainBatchSz": args.train_batch_size, "validationBatchSz": args.validation_batch_size, "learningRate": get_lr(optimizer), "loss": cLoss, "valLoss": valLoss, "valPSNR": valPSNR, "valSSIM": valSSIM, "state_dictFC": flowComp.state_dict(), "state_dictAT": ArbTimeFlowIntrp.state_dict(), } torch.save( dict1, args.checkpoint_dir + "/SuperSloMo" + "bestssim_epoch" + ".ckpt", ) print("New Best SSIM found and saved at " + str(epoch))
31.578078
149
0.595787
# [Super SloMo] ##High Quality Estimation of Multiple Intermediate Frames for Video Interpolation from comet_ml import Experiment, ExistingExperiment import argparse import torch import torchvision import torchvision.transforms as transforms import torch.optim as optim import torch.nn as nn import torch.nn.functional as F import model import dataloader_c as dataloader from math import log10 import datetime import numpy as np import warnings from pytorch_msssim import ssim, ms_ssim, SSIM, MS_SSIM # pip install pytorch-msssim from PIL import Image import torchvision.utils as vutils from utils import init_net, upload_images warnings.simplefilter("ignore", UserWarning) # from tensorboardX import SummaryWriter # For parsing commandline arguments parser = argparse.ArgumentParser() parser.add_argument( "--dataset_root", type=str, required=True, help="path to dataset folder containing train-test-validation folders", ) parser.add_argument( "--checkpoint_dir", type=str, required=True, help="path to folder for saving checkpoints", ) parser.add_argument( "--checkpoint", type=str, help="path of checkpoint for pretrained model" ) parser.add_argument( "--train_continue", action="store_true", help="resuming from checkpoint." ) parser.add_argument( "-it", "--init_type", default="", type=str, help="the name of an initialization method: normal | xavier | kaiming | orthogonal", ) parser.add_argument( "--epochs", type=int, default=200, help="number of epochs to train. Default: 200." ) parser.add_argument( "-tbs", "--train_batch_size", type=int, default=384, help="batch size for training. Default: 6.", ) parser.add_argument( "-nw", "--num_workers", default=4, type=int, help="number of CPU you get" ) parser.add_argument( "-vbs", "--validation_batch_size", type=int, default=384, help="batch size for validation. Default: 10.", ) parser.add_argument( "-ilr", "--init_learning_rate", type=float, default=0.0001, help="set initial learning rate. Default: 0.0001.", ) parser.add_argument( "--milestones", type=list, default=[100, 150], help="Set to epoch values where you want to decrease learning rate by a factor of 0.1. Default: [100, 150]", ) parser.add_argument( "--progress_iter", type=int, default=100, help="frequency of reporting progress and validation. N: after every N iterations. Default: 100.", ) parser.add_argument( "--logimagefreq", type=int, default=1, help="frequency of logging image.", ) parser.add_argument( "--checkpoint_epoch", type=int, default=5, help="checkpoint saving frequency. N: after every N epochs. Each checkpoint is roughly of size 151 MB.Default: 5.", ) parser.add_argument( "-wp", "--workspace", default="tianyu-z", type=str, help="comet-ml workspace" ) parser.add_argument( "-dh", "--data_h", default=128, type=int, help="H of the data shape" ) parser.add_argument( "-dw", "--data_w", default=128, type=int, help="W of the data shape" ) parser.add_argument( "-pn", "--projectname", default="super-slomo", type=str, help="comet-ml project name", ) parser.add_argument( "--nocomet", action="store_true", help="not using comet_ml logging." ) parser.add_argument( "--cometid", type=str, default="", help="the comet id to resume exps", ) parser.add_argument( "-rs", "--randomseed", type=int, default=2021, help="batch size for validation. Default: 10.", ) args = parser.parse_args() random_seed = args.randomseed np.random.seed(random_seed) torch.manual_seed(random_seed) if torch.cuda.device_count() > 1: torch.cuda.manual_seed_all(random_seed) else: torch.cuda.manual_seed(random_seed) torch.backends.cudnn.deterministic = True torch.backends.cudnn.benchmark = False ##[TensorboardX](https://github.com/lanpa/tensorboardX) ### For visualizing loss and interpolated frames # writer = SummaryWriter("log") ###Initialize flow computation and arbitrary-time flow interpolation CNNs. device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu") flowComp = model.UNet(6, 4) flowComp.to(device) if args.init_type != "": init_net(flowComp, args.init_type) print(args.init_type + " initializing flowComp done") ArbTimeFlowIntrp = model.UNet(20, 5) ArbTimeFlowIntrp.to(device) if args.init_type != "": init_net(ArbTimeFlowIntrp, args.init_type) print(args.init_type + " initializing ArbTimeFlowIntrp done") ### Initialization if args.train_continue: if not args.nocomet and args.cometid != "": comet_exp = ExistingExperiment(previous_experiment=args.cometid) elif not args.nocomet and args.cometid == "": comet_exp = Experiment(workspace=args.workspace, project_name=args.projectname) else: comet_exp = None dict1 = torch.load(args.checkpoint) ArbTimeFlowIntrp.load_state_dict(dict1["state_dictAT"]) flowComp.load_state_dict(dict1["state_dictFC"]) print("Pretrained model loaded!") else: # start logging info in comet-ml if not args.nocomet: comet_exp = Experiment(workspace=args.workspace, project_name=args.projectname) # comet_exp.log_parameters(flatten_opts(args)) else: comet_exp = None dict1 = {"loss": [], "valLoss": [], "valPSNR": [], "valSSIM": [], "epoch": -1} ###Initialze backward warpers for train and validation datasets trainFlowBackWarp = model.backWarp(128, 128, device) trainFlowBackWarp = trainFlowBackWarp.to(device) validationFlowBackWarp = model.backWarp(128, 128, device) validationFlowBackWarp = validationFlowBackWarp.to(device) ###Load Datasets # Channel wise mean calculated on adobe240-fps training dataset mean = [0.5, 0.5, 0.5] std = [1, 1, 1] normalize = transforms.Normalize(mean=mean, std=std) transform = transforms.Compose([transforms.ToTensor(), normalize]) trainset = dataloader.SuperSloMo( root=args.dataset_root + "/train", transform=transform, train=True ) trainloader = torch.utils.data.DataLoader( trainset, batch_size=args.train_batch_size, num_workers=args.num_workers, shuffle=True, ) validationset = dataloader.SuperSloMo( root=args.dataset_root + "/validation", transform=transform, randomCropSize=(128, 128), train=False, ) validationloader = torch.utils.data.DataLoader( validationset, batch_size=args.validation_batch_size, num_workers=args.num_workers, shuffle=False, ) print(trainset, validationset) ###Create transform to display image from tensor negmean = [x * -1 for x in mean] revNormalize = transforms.Normalize(mean=negmean, std=std) TP = transforms.Compose([revNormalize, transforms.ToPILImage()]) ###Utils def get_lr(optimizer): for param_group in optimizer.param_groups: return param_group["lr"] ###Loss and Optimizer L1_lossFn = nn.L1Loss() MSE_LossFn = nn.MSELoss() params = list(ArbTimeFlowIntrp.parameters()) + list(flowComp.parameters()) optimizer = optim.Adam(params, lr=args.init_learning_rate) # scheduler to decrease learning rate by a factor of 10 at milestones. scheduler = optim.lr_scheduler.MultiStepLR( optimizer, milestones=args.milestones, gamma=0.1 ) ###Initializing VGG16 model for perceptual loss vgg16 = torchvision.models.vgg16(pretrained=True) vgg16_conv_4_3 = nn.Sequential(*list(vgg16.children())[0][:22]) vgg16_conv_4_3.to(device) if args.init_type != "": init_net(vgg16_conv_4_3, args.init_type) for param in vgg16_conv_4_3.parameters(): param.requires_grad = False ### Validation function # def validate(epoch, logimage=False): # For details see training. psnr = 0 ssim_val = 0 tloss = 0 flag = 1 valid_images = [] with torch.no_grad(): for validationIndex, (validationData, validationFrameIndex) in enumerate( validationloader, 0 ): frame0, frameT, frame1 = validationData I0 = frame0.to(device) I1 = frame1.to(device) IFrame = frameT.to(device) flowOut = flowComp(torch.cat((I0, I1), dim=1)) F_0_1 = flowOut[:, :2, :, :] F_1_0 = flowOut[:, 2:, :, :] fCoeff = model.getFlowCoeff(validationFrameIndex, device) F_t_0 = fCoeff[0] * F_0_1 + fCoeff[1] * F_1_0 F_t_1 = fCoeff[2] * F_0_1 + fCoeff[3] * F_1_0 g_I0_F_t_0 = validationFlowBackWarp(I0, F_t_0) g_I1_F_t_1 = validationFlowBackWarp(I1, F_t_1) intrpOut = ArbTimeFlowIntrp( torch.cat( (I0, I1, F_0_1, F_1_0, F_t_1, F_t_0, g_I1_F_t_1, g_I0_F_t_0), dim=1 ) ) F_t_0_f = intrpOut[:, :2, :, :] + F_t_0 F_t_1_f = intrpOut[:, 2:4, :, :] + F_t_1 V_t_0 = torch.sigmoid(intrpOut[:, 4:5, :, :]) V_t_1 = 1 - V_t_0 g_I0_F_t_0_f = validationFlowBackWarp(I0, F_t_0_f) g_I1_F_t_1_f = validationFlowBackWarp(I1, F_t_1_f) wCoeff = model.getWarpCoeff(validationFrameIndex, device) Ft_p = ( wCoeff[0] * V_t_0 * g_I0_F_t_0_f + wCoeff[1] * V_t_1 * g_I1_F_t_1_f ) / (wCoeff[0] * V_t_0 + wCoeff[1] * V_t_1) # For tensorboard if flag: retImg = torchvision.utils.make_grid( [ revNormalize(frame0[0]), revNormalize(frameT[0]), revNormalize(Ft_p.cpu()[0]), revNormalize(frame1[0]), ], padding=10, ) flag = 0 if logimage: if validationIndex % args.logimagefreq == 0: valid_images.append( 255.0 * frame0[0] .resize_(1, 1, args.data_h, args.data_w) .repeat(1, 3, 1, 1) ) valid_images.append( 255.0 * frameT[0] .resize_(1, 1, args.data_h, args.data_w) .repeat(1, 3, 1, 1) ) valid_images.append( 255.0 * frame1[0] .resize_(1, 1, args.data_h, args.data_w) .repeat(1, 3, 1, 1) ) valid_images.append( 255.0 * Ft_p.cpu()[0] .resize_(1, 1, args.data_h, args.data_w) .repeat(1, 3, 1, 1) ) # loss recnLoss = L1_lossFn(Ft_p, IFrame) prcpLoss = MSE_LossFn(vgg16_conv_4_3(Ft_p), vgg16_conv_4_3(IFrame)) warpLoss = ( L1_lossFn(g_I0_F_t_0, IFrame) + L1_lossFn(g_I1_F_t_1, IFrame) + L1_lossFn(validationFlowBackWarp(I0, F_1_0), I1) + L1_lossFn(validationFlowBackWarp(I1, F_0_1), I0) ) loss_smooth_1_0 = torch.mean( torch.abs(F_1_0[:, :, :, :-1] - F_1_0[:, :, :, 1:]) ) + torch.mean(torch.abs(F_1_0[:, :, :-1, :] - F_1_0[:, :, 1:, :])) loss_smooth_0_1 = torch.mean( torch.abs(F_0_1[:, :, :, :-1] - F_0_1[:, :, :, 1:]) ) + torch.mean(torch.abs(F_0_1[:, :, :-1, :] - F_0_1[:, :, 1:, :])) loss_smooth = loss_smooth_1_0 + loss_smooth_0_1 loss = 204 * recnLoss + 102 * warpLoss + 0.005 * prcpLoss + loss_smooth tloss += loss.item() # psnr MSE_val = MSE_LossFn(Ft_p, IFrame) psnr += 10 * log10(1 / MSE_val.item()) ssim_val += ssim(Ft_p, IFrame, data_range=1, size_average=True).item() if logimage: upload_images( valid_images, epoch, exp=comet_exp, im_per_row=4, rows_per_log=int(len(valid_images) / 4), ) return ( (psnr / len(validationloader)), (ssim_val / len(validationloader)), (tloss / len(validationloader)), retImg, ) ### Training import time best_psnr = -1 best_ssim = -1 best_valloss = 9999 start = time.time() cLoss = dict1["loss"] valLoss = dict1["valLoss"] valPSNR = dict1["valPSNR"] valSSIM = dict1["valSSIM"] checkpoint_counter = int((dict1["epoch"] + 1) / args.checkpoint_epoch) ### Main training loop for epoch in range(dict1["epoch"] + 1, args.epochs): print("Epoch: ", epoch) # Append and reset cLoss.append([]) valLoss.append([]) valPSNR.append([]) valSSIM.append([]) iLoss = 0 if epoch > dict1["epoch"] + 1: # Increment scheduler count scheduler.step() # if epoch == dict1["epoch"] + 1: # # test if validate works # validate(epoch, True) for trainIndex, (trainData, trainFrameIndex) in enumerate(trainloader, 0): ## Getting the input and the target from the training set frame0, frameT, frame1 = trainData I0 = frame0.to(device) I1 = frame1.to(device) IFrame = frameT.to(device) optimizer.zero_grad() # Calculate flow between reference frames I0 and I1 flowOut = flowComp(torch.cat((I0, I1), dim=1)) # Extracting flows between I0 and I1 - F_0_1 and F_1_0 F_0_1 = flowOut[:, :2, :, :] F_1_0 = flowOut[:, 2:, :, :] fCoeff = model.getFlowCoeff(trainFrameIndex, device) # Calculate intermediate flows F_t_0 = fCoeff[0] * F_0_1 + fCoeff[1] * F_1_0 F_t_1 = fCoeff[2] * F_0_1 + fCoeff[3] * F_1_0 # Get intermediate frames from the intermediate flows g_I0_F_t_0 = trainFlowBackWarp(I0, F_t_0) g_I1_F_t_1 = trainFlowBackWarp(I1, F_t_1) # Calculate optical flow residuals and visibility maps intrpOut = ArbTimeFlowIntrp( torch.cat( (I0, I1, F_0_1, F_1_0, F_t_1, F_t_0, g_I1_F_t_1, g_I0_F_t_0), dim=1 ) ) # Extract optical flow residuals and visibility maps F_t_0_f = intrpOut[:, :2, :, :] + F_t_0 F_t_1_f = intrpOut[:, 2:4, :, :] + F_t_1 V_t_0 = torch.sigmoid(intrpOut[:, 4:5, :, :]) V_t_1 = 1 - V_t_0 # Get intermediate frames from the intermediate flows g_I0_F_t_0_f = trainFlowBackWarp(I0, F_t_0_f) g_I1_F_t_1_f = trainFlowBackWarp(I1, F_t_1_f) wCoeff = model.getWarpCoeff(trainFrameIndex, device) # Calculate final intermediate frame Ft_p = (wCoeff[0] * V_t_0 * g_I0_F_t_0_f + wCoeff[1] * V_t_1 * g_I1_F_t_1_f) / ( wCoeff[0] * V_t_0 + wCoeff[1] * V_t_1 ) # Loss recnLoss = L1_lossFn(Ft_p, IFrame) prcpLoss = MSE_LossFn(vgg16_conv_4_3(Ft_p), vgg16_conv_4_3(IFrame)) warpLoss = ( L1_lossFn(g_I0_F_t_0, IFrame) + L1_lossFn(g_I1_F_t_1, IFrame) + L1_lossFn(trainFlowBackWarp(I0, F_1_0), I1) + L1_lossFn(trainFlowBackWarp(I1, F_0_1), I0) ) loss_smooth_1_0 = torch.mean( torch.abs(F_1_0[:, :, :, :-1] - F_1_0[:, :, :, 1:]) ) + torch.mean(torch.abs(F_1_0[:, :, :-1, :] - F_1_0[:, :, 1:, :])) loss_smooth_0_1 = torch.mean( torch.abs(F_0_1[:, :, :, :-1] - F_0_1[:, :, :, 1:]) ) + torch.mean(torch.abs(F_0_1[:, :, :-1, :] - F_0_1[:, :, 1:, :])) loss_smooth = loss_smooth_1_0 + loss_smooth_0_1 # Total Loss - Coefficients 204 and 102 are used instead of 0.8 and 0.4 # since the loss in paper is calculated for input pixels in range 0-255 # and the input to our network is in range 0-1 loss = 204 * recnLoss + 102 * warpLoss + 0.005 * prcpLoss + loss_smooth # Backpropagate loss.backward() optimizer.step() iLoss += loss.item() # Validation and progress every `args.progress_iter` iterations # if (trainIndex % args.progress_iter) == args.progress_iter - 1: end = time.time() psnr, ssim_val, vLoss, valImg = validate(epoch, logimage=True) valPSNR[epoch].append(psnr) valSSIM[epoch].append(ssim_val) valLoss[epoch].append(vLoss) # Tensorboard itr = int(trainIndex + epoch * (len(trainloader))) # writer.add_scalars( # "Loss", # {"trainLoss": iLoss / args.progress_iter, "validationLoss": vLoss}, # itr, # ) # writer.add_scalar("PSNR", psnr, itr) # writer.add_image("Validation", valImg, itr) comet_exp.log_metrics( {"trainLoss": iLoss / args.progress_iter, "validationLoss": vLoss}, step=itr, epoch=epoch, ) comet_exp.log_metric("PSNR", psnr, step=itr, epoch=epoch) comet_exp.log_metric("SSIM", ssim_val, step=itr, epoch=epoch) # valImage = torch.movedim(valImg, 0, -1) # print(type(valImage)) # print(valImage.shape) # print(valImage.max()) # print(valImage.min()) # comet_exp.log_image( # valImage, # name="iter: " + str(iter) + ";epoch: " + str(epoch), # image_format="jpg", # step=itr, # ) ##### endVal = time.time() print( " Loss: %0.6f Iterations: %4d/%4d TrainExecTime: %0.1f ValLoss:%0.6f ValPSNR: %0.4f ValSSIM: %0.4f ValEvalTime: %0.2f LearningRate: %f" % ( iLoss / args.progress_iter, trainIndex, len(trainloader), end - start, vLoss, psnr, ssim_val, endVal - end, get_lr(optimizer), ) ) cLoss[epoch].append(iLoss / args.progress_iter) iLoss = 0 start = time.time() # Create checkpoint after every `args.checkpoint_epoch` epochs if (epoch % args.checkpoint_epoch) == args.checkpoint_epoch - 1: dict1 = { "Detail": "End to end Super SloMo.", "epoch": epoch, "timestamp": datetime.datetime.now(), "trainBatchSz": args.train_batch_size, "validationBatchSz": args.validation_batch_size, "learningRate": get_lr(optimizer), "loss": cLoss, "valLoss": valLoss, "valPSNR": valPSNR, "valSSIM": valSSIM, "state_dictFC": flowComp.state_dict(), "state_dictAT": ArbTimeFlowIntrp.state_dict(), } torch.save( dict1, args.checkpoint_dir + "/SuperSloMo" + str(checkpoint_counter) + ".ckpt", ) checkpoint_counter += 1 if psnr > best_psnr: best_psnr = psnr dict1 = { "Detail": "End to end Super SloMo.", "epoch": epoch, "timestamp": datetime.datetime.now(), "trainBatchSz": args.train_batch_size, "validationBatchSz": args.validation_batch_size, "learningRate": get_lr(optimizer), "loss": cLoss, "valLoss": valLoss, "valPSNR": valPSNR, "valSSIM": valSSIM, "state_dictFC": flowComp.state_dict(), "state_dictAT": ArbTimeFlowIntrp.state_dict(), } torch.save( dict1, args.checkpoint_dir + "/SuperSloMo" + "bestpsnr_epoch" + ".ckpt", ) print("New Best PSNR found and saved at " + str(epoch)) if vLoss < best_valloss: best_valloss = vLoss dict1 = { "Detail": "End to end Super SloMo.", "epoch": epoch, "timestamp": datetime.datetime.now(), "trainBatchSz": args.train_batch_size, "validationBatchSz": args.validation_batch_size, "learningRate": get_lr(optimizer), "loss": cLoss, "valLoss": valLoss, "valPSNR": valPSNR, "valSSIM": valSSIM, "state_dictFC": flowComp.state_dict(), "state_dictAT": ArbTimeFlowIntrp.state_dict(), } torch.save( dict1, args.checkpoint_dir + "/SuperSloMo" + "bestvalloss_epoch" + ".ckpt", ) print("New Best valloss found and saved at " + str(epoch)) if ssim_val > best_ssim: best_ssim = ssim_val dict1 = { "Detail": "End to end Super SloMo.", "epoch": epoch, "timestamp": datetime.datetime.now(), "trainBatchSz": args.train_batch_size, "validationBatchSz": args.validation_batch_size, "learningRate": get_lr(optimizer), "loss": cLoss, "valLoss": valLoss, "valPSNR": valPSNR, "valSSIM": valSSIM, "state_dictFC": flowComp.state_dict(), "state_dictAT": ArbTimeFlowIntrp.state_dict(), } torch.save( dict1, args.checkpoint_dir + "/SuperSloMo" + "bestssim_epoch" + ".ckpt", ) print("New Best SSIM found and saved at " + str(epoch))
4,748
0
46
dd5c591d8629070d56f3f787c2b2d5d71c6c3c42
448
py
Python
test/test_tokenize/case2.py
xupingmao/subpy
c956f151ed1ebd2faeaf1565352b59ca5a8fa0b4
[ "MIT" ]
6
2015-10-11T15:06:54.000Z
2016-07-03T06:06:52.000Z
test/test_tokenize/case2.py
xupingmao/snake
c956f151ed1ebd2faeaf1565352b59ca5a8fa0b4
[ "MIT" ]
7
2015-08-03T12:01:21.000Z
2016-04-24T09:00:09.000Z
test/test_tokenize/case2.py
xupingmao/snake
c956f151ed1ebd2faeaf1565352b59ca5a8fa0b4
[ "MIT" ]
2
2016-04-18T14:51:25.000Z
2016-04-18T15:07:09.000Z
# -*- coding:utf-8 -*- # @author xupingmao # @since 2022/04/10 15:06:25 # @modified 2022/04/10 15:10:04 # @filename case2.py input_text = """ def foo(bar): return bar * 5 """ output = [ "nl", "nl", "def", "def", "name", "foo", "(", "(", "name", "bar", ")", ")", ":", ":", "nl", "nl", "indent", 4, "return", "return", "name", "bar", "*", "*", "number", 5, "nl", "nl", "dedent", 4, ]
15.448276
31
0.419643
# -*- coding:utf-8 -*- # @author xupingmao # @since 2022/04/10 15:06:25 # @modified 2022/04/10 15:10:04 # @filename case2.py input_text = """ def foo(bar): return bar * 5 """ output = [ "nl", "nl", "def", "def", "name", "foo", "(", "(", "name", "bar", ")", ")", ":", ":", "nl", "nl", "indent", 4, "return", "return", "name", "bar", "*", "*", "number", 5, "nl", "nl", "dedent", 4, ]
0
0
0
6efc3b3f2991661bf76fd6544abf0ea9b3f3a66e
153
py
Python
hadTopTools/__init__.py
mdkdrnevich/DeepHadTopTagger
560b51b98e0d9a3a78a0986408ad4d2a30f9960f
[ "MIT" ]
3
2018-04-14T18:07:00.000Z
2020-07-15T13:21:49.000Z
hadTopTools/__init__.py
mdkdrnevich/DeepHadTopTagger
560b51b98e0d9a3a78a0986408ad4d2a30f9960f
[ "MIT" ]
null
null
null
hadTopTools/__init__.py
mdkdrnevich/DeepHadTopTagger
560b51b98e0d9a3a78a0986408ad4d2a30f9960f
[ "MIT" ]
null
null
null
import matplotlib as mpl mpl.use("Agg") from .utils import CollisionDataset, AutoencoderDataset, train, test, plot_curves from . import nn_classes as nn
30.6
81
0.803922
import matplotlib as mpl mpl.use("Agg") from .utils import CollisionDataset, AutoencoderDataset, train, test, plot_curves from . import nn_classes as nn
0
0
0
3636d7aab0b716744fe8b791609bf4d2625e4679
4,760
py
Python
survey_system_files/views.py
CompSci17/Survey-System
b30ddb3c4dc6d65504bbef58bb1600becc4bb6f5
[ "MIT" ]
1
2020-10-19T15:27:54.000Z
2020-10-19T15:27:54.000Z
survey_system_files/views.py
CompSci17/Survey-System
b30ddb3c4dc6d65504bbef58bb1600becc4bb6f5
[ "MIT" ]
1
2020-07-14T15:03:02.000Z
2020-07-14T15:03:02.000Z
survey_system_files/views.py
CompSci17/Survey-System
b30ddb3c4dc6d65504bbef58bb1600becc4bb6f5
[ "MIT" ]
null
null
null
import uuid import hashlib from django.shortcuts import render from django.http import HttpResponseRedirect, HttpResponse from .models import Survey, Question, Answers from .forms import SurveyForm from .results import Results # Create your views here.
29.02439
197
0.65021
import uuid import hashlib from django.shortcuts import render from django.http import HttpResponseRedirect, HttpResponse from .models import Survey, Question, Answers from .forms import SurveyForm from .results import Results # Create your views here. def survey_list( request, *args, **kwargs ): # Get a list of all the surveys survey_list = Survey.objects.filter( published = True ) template_name = "survey_list.html" context = { "survey_list": survey_list, "page_title": "Surveys" } return render( request, template_name, context ) def survey_detail( request, pk, *args, **kwargs ): # Get the survey we're working with survey = Survey.objects.get( pk = pk, published = True ) # Get all the questions for the survey questions = Question.objects.filter( survey__exact = survey ).order_by( "order" ) template_name = "survey_detail.html" #Get the survey form form = SurveyForm( request.POST or None, questions=questions ) if survey.single_vote and request.COOKIES.has_key( "survey_" + hashlib.sha256( str( survey.pk ) ).hexdigest() ): # If the survey only allows 1 vote and the user has voted, load the thank you template template_name = "thanks.html" else: # if this is a POST request we need to process the form data if request.method == 'POST': if form.is_valid(): # If form is valid, process the input answers = [] for question in questions: # For every question, process the answer and save it to the Answers model answer = Answers( ) answer.survey = survey answer.question = question answers = form.cleaned_data[ str( question.pk ) ] if type( answers ) is list: # If the input has multiple answers, concatenate them into a comma separated list for individualAnswer in answers: answer.text = answer.text + individualAnswer + ", " answer.text = answer.text[:-2] else: answer.text = answers answer.session_id = uuid.uuid1( ) answer.save() template_name = "thanks.html" context = { "survey" : survey, "page_title": survey.title, "form": form, } # Create blank response response = HttpResponse() # Fill the response with the template render response = render( request, template_name, context ) if request.method == 'POST' and form.is_valid() and survey.single_vote: # If form is submitted, the form is valid and the survey only allows 1 vote: # set a cookie to identify the user has voted response.set_cookie( "survey_" + hashlib.sha256( str( survey.pk ) ).hexdigest(), hashlib.sha256( str( survey.pk ) + ( survey.title ) ).hexdigest() , max_age = 30 * 24 * 60 * 60, httponly = True ) # Return the rendered response return response def survey_results( request, pk, *args, **kwargs ): survey = Survey.objects.get( pk = pk, published = True ) questions = Question.objects.filter( survey__exact = survey ) template_name = "survey_results.html" results = Results( ) answers = results.render_results( questions, survey ) output = '' charts = [] chart_ids = "" for input_type, answer, input_id in answers: if input_type == "text" or input_type == "textarea": question = Question.objects.get( pk = input_id ) if "email" not in question.text: output += """ <table> <tr> <th> %s </th> </tr> """ % ( question.text ) for indiv_answer in answer: output += """ <tr> <td> %s </td> </tr> """ % ( indiv_answer ) output += """ </table> """ elif input_type == "order_of_importance": question = Question.objects.get( pk = input_id ) choices = results.get_choices( question.choices ) counter = [] max_score = 0 output += "<h2>" + question.text + "</h2>" for choice in choices: answer_score = 0 for column in xrange( 1, len( choices ) + 1 ): answer_score += ( len( choices ) + 1 - column ) * int( answer[ column ][ choice.strip().replace( ",", "" ) ] ) max_score = answer_score if answer_score > max_score else max_score counter.append( ( choice.strip().replace( ",", "" ), answer_score ) ) counter = sorted( counter, key=lambda answer: answer[1], reverse = True ) for answer, score in counter: output += str( answer ) + '<br /> <meter value="' + str( score ) + '" min="0" max="' + str( max_score ) + '" >' + str( score ) + '</meter> <br /><br />' else: charts.append( answer ) chart_ids += "container_" + str( input_id ) + "," output += " \n <div id='container_" + str( input_id ) + "'> Chart </div>" context = { "page_title": survey.title + " Results", "answers": answers, "output": output, "charts": charts, "chart_ids": chart_ids, } return render( request, template_name, context )
4,434
0
69
9d7b4fe660aa92ee6eb5bbd020297c0ee9cb4dd1
2,873
py
Python
src/mnist/train.py
iden-kalemaj/SIDP
ee6da502cc6c0f42042b54d6329b3bd8c67fb991
[ "Apache-2.0" ]
10
2020-06-22T22:11:43.000Z
2021-11-10T12:25:53.000Z
src/mnist/train.py
iden-kalemaj/SIDP
ee6da502cc6c0f42042b54d6329b3bd8c67fb991
[ "Apache-2.0" ]
2
2020-12-10T09:25:59.000Z
2021-12-27T09:33:36.000Z
src/mnist/train.py
iden-kalemaj/SIDP
ee6da502cc6c0f42042b54d6329b3bd8c67fb991
[ "Apache-2.0" ]
3
2020-07-11T05:45:06.000Z
2022-03-03T21:08:56.000Z
import torch from torchvision import datasets from torch.utils.data import DataLoader, RandomSampler import torchvision.transforms as transforms from tqdm import tqdm from .dataset import data_loaders, axi_loader
31.571429
107
0.649147
import torch from torchvision import datasets from torch.utils.data import DataLoader, RandomSampler import torchvision.transforms as transforms from tqdm import tqdm from .dataset import data_loaders, axi_loader def train(model, criterion, optimizer, device, train_loader, clip, noise_multiplier, batch_size, axi_x): model.train() for x, y in tqdm(train_loader): _lr = optimizer.param_groups[0]['lr'] std_params = _lr * clip * noise_multiplier / batch_size x = torch.cat([x.to(device), axi_x], dim=0) y = y.to(device) optimizer.zero_grad() output = model.forward(x, std_params)[:batch_size] losses = criterion(output, y) saved_var = dict() for tensor_name, tensor in model.named_parameters(): saved_var[tensor_name] = torch.zeros_like(tensor) for j in losses: j.backward(retain_graph=True) torch.nn.utils.clip_grad_norm_(model.parameters(), clip) for tensor_name, tensor in model.named_parameters(): new_grad = tensor.grad saved_var[tensor_name].add_(new_grad) optimizer.zero_grad() for tensor_name, tensor in model.named_parameters(): tensor.grad = saved_var[tensor_name] / losses.shape[0] optimizer.step() def evaluate_accuracy(model, data_loader, device, axi_x): model.eval() correct = 0 total = 0. with torch.no_grad(): for x, y in data_loader: _batch_size = x.shape[0] x = torch.cat([x.to(device), axi_x], dim=0) output = model(x, 0)[:_batch_size] pred = output.max(1, keepdim=True)[1] # get the index of the max log-probability correct += pred.eq(y.to(device).view_as(pred)).sum().item() total += _batch_size accuracy = correct / total return accuracy def main(noise_multiplier, clip, lr, batch_size, epochs, normalization_type, device): from .model import LeNet5 if device is None: device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu") model = LeNet5(normalization_type) model = model.to(device) criterion = torch.nn.CrossEntropyLoss(reduction='none') optimizer = torch.optim.SGD(model.parameters(), lr=lr, momentum=0.9) scheduler_lr = torch.optim.lr_scheduler.ExponentialLR(optimizer, gamma=.9, last_epoch=-1) train_loader, test_loader = data_loaders(batch_size) axi_x = axi_loader(30).to(device) for epoch in range(epochs): train(model, criterion, optimizer, device, train_loader, clip, noise_multiplier, batch_size, axi_x) scheduler_lr.step() test_accuracy = evaluate_accuracy(model, test_loader, device, axi_x) print('epoch', epoch) print('valid accuracy ', test_accuracy) print('---------------------')
2,575
0
69
eac66d468a7e07323da015ce90324eb30ccacdcf
17,976
py
Python
pysql.py
morfat/PySQL
a887977ec7fc17e34c03027f044c40539d12e046
[ "MIT" ]
null
null
null
pysql.py
morfat/PySQL
a887977ec7fc17e34c03027f044c40539d12e046
[ "MIT" ]
null
null
null
pysql.py
morfat/PySQL
a887977ec7fc17e34c03027f044c40539d12e046
[ "MIT" ]
1
2020-09-14T17:32:59.000Z
2020-09-14T17:32:59.000Z
import MySQLdb from urllib import parse class PySQL: """ For making Mariadb / Mysql db queries """ FILTER_COMMANDS = { "$eq":" = %s ", "$in":" IN (%s) ", "$nin":" NOT IN (%s) ", "$neq":" != %s ", "$lt":" < %s ", "$lte":" <= %s ", "$gt":" > %s ", "$gte":" >= %s ", "$contains":" LIKE %s ",#like %var% "$ncontains":" NOT LIKE %s ",# "$null":" IS NULL ", #if 1 else "IS NOT NULL" if 0 "$sw":" LIKE %s ",#starts with . like %var "$ew":" LIKE %s "# endswith like var% } def execute(self,sql,params=None,many=None,dict_cursor=True): #runs the db query . can also be used to run raw queries directly """ by default returns cursor object """ if dict_cursor: self.cursor = self._mysqldb_connection.cursor(MySQLdb.cursors.DictCursor) else: self.cursor = self._mysqldb_connection.cursor() if many: self.cursor.executemany(sql,params) else: self.cursor.execute(sql,params) return self.cursor #PySQL specific method begin from here def __make_table_column(self,column,table_name=None): """Example Input: => Output: users.id => users.id name => users.name """ if '.' in column: return column return "{}.{}".format(table_name,column) if table_name else "{}.{}".format(self.table_name,column) def fields(self,columns): #sets columns to select """ Example: ['id','name'] """ self.columns = columns return self def filter(self,filter_data): """ Filters Requests #example full including or { "name":{"$contains":"mosoti"}, "age":{"$lte":30}, "msisdn":"2541234567", "$or":[{ "name":{"$contains":"mogaka"}}, {"age":31} ], #this evaluates to => .. OR name like '%mogaka%' OR age=31 "$xor":[{ "name":{"$contains":"mogaka"}}, {"age":31} ] # this evalautes to =>... AND ( name like '%mogaka%' OR age=31 ) } """ #reset vals /parameters so that we begin here if filter_data: filter_q_l = self.__filter_query(filter_data) filters_qls = ''.join(filter_q_l).strip() if filters_qls.startswith("AND"): filters_qls = filters_qls[3:] elif filters_qls.startswith("OR"): filters_qls = filters_qls[2:] self.__set_where(filters_qls) return self def __get_order_by_text(self,val): """ Receives string e.g -id or name """ if val.startswith('-'): return "{} DESC".format(self.__make_table_column(val[1:])) else: return "{} ASC".format(self.__make_table_column(val)) def order_by(self,order_by_fields): """Expects list of fields e.g ['-id','name'] where - is DESC""" order_by_sql = ','.join([self.__get_order_by_text(v) for v in order_by_fields]) if self.order_by_sql: self.order_by_sql = self.order_by_sql + ' , ' + order_by_sql else: self.order_by_sql = " ORDER BY " + order_by_sql return self def group_by(self,group_by_fields): """ Expects fields in list ['id','name'] ... """ group_by_sql = ','.join([self.__make_table_column(v) for v in group_by_fields]) if self.group_by_sql: self.group_by_sql = self.group_by_sql + group_by_sql else: self.group_by_sql = " GROUP BY " + group_by_sql return self def __make_join(self,join_type,table_name,condition_data,related_fields): """ makes join sql based on type of join and tables """ on_sql = [] for k,v in condition_data.items(): on_sql.append("{} = {} ".format(self.__make_table_column(k),self.__make_table_column(v,table_name))) on_sql_str = ' ON {} ' .format(' AND '.join(on_sql)) join_type_sql = '{} {} '.format(join_type,table_name) self.join_sql = self.join_sql + join_type_sql + on_sql_str #append the columns to select based on related fields if related_fields: self.columns.extend([self.__make_table_column(c,table_name) for c in related_fields]) def inner_join(self,table_name,condition,related_fields=None): """ e.g Orders,{"id":"customer_id"}, ['quantity'] This will result to : .... Orders.quantity, .... INNER JOIN Orders ON Customers.id = Orders.customer_id """ self.__make_join('INNER JOIN',table_name,condition,related_fields) return self def right_join(self,table_name,condition,related_fields=None): """ e.g Orders,{"id":"customer_id"}, ['quantity'] This will result to : .... Orders.quantity, .... RIGHT JOIN Orders ON Customers.id = Orders.customer_id """ self.__make_join('RIGHT JOIN',table_name,condition,related_fields) return self def left_join(self,table_name,condition,related_fields=None): """ e.g Orders,{"id":"customer_id"}, ['quantity'] This will result to : .... Orders.quantity, .... LEFT JOIN Orders ON Customers.id = Orders.customer_id """ self.__make_join('LEFT JOIN',table_name,condition,related_fields) return self def update(self,new_data,limit=None): """ set this new data as new details Returns cursor object """ col_set = ','.join([" {} = %s ".format(k) for k,v in new_data.items()]) filter_params = self.query_params self.query_params = [] update_params = [v for k,v in new_data.items()] update_params.extend(filter_params) #we start with update thn filter self.__build_query_params(update_params) self.sql = "UPDATE {} SET {} ".format(self.table_name,col_set) self.__make_sql(self.where_sql) self.__limit(limit) print(self.query_params) print (self.sql) return self.execute(self.sql,self.query_params) def delete(self,limit=None): """ Delete with given limit """ self.sql = "DELETE FROM {} ".format(self.table_name) self.__make_sql(self.where_sql) self.__limit(limit) print (self.sql) return self.execute(self.sql,self.query_params) def insert(self,data): """ Creates records to db table . Expects a dict of key abd values pair """ columns = [] params = [] for k,v in data.items(): columns.append(k) params.append(v) column_placeholders = ','.join(["%s" for v in columns]) columns = ','.join([v for v in columns]) self.query_params = params self.sql = "INSERT INTO {}({}) VALUES({})".format(self.table_name,columns,column_placeholders) print (self.sql) print (self.query_params) return self.execute(self.sql,self.query_params).lastrowid
28.807692
139
0.547063
import MySQLdb from urllib import parse class PySQL: """ For making Mariadb / Mysql db queries """ FILTER_COMMANDS = { "$eq":" = %s ", "$in":" IN (%s) ", "$nin":" NOT IN (%s) ", "$neq":" != %s ", "$lt":" < %s ", "$lte":" <= %s ", "$gt":" > %s ", "$gte":" >= %s ", "$contains":" LIKE %s ",#like %var% "$ncontains":" NOT LIKE %s ",# "$null":" IS NULL ", #if 1 else "IS NOT NULL" if 0 "$sw":" LIKE %s ",#starts with . like %var "$ew":" LIKE %s "# endswith like var% } def __init__(self,user,password,db,host,port): self._mysqldb_connection = MySQLdb.connect(user=user,passwd=password,db=db,host=host,port=port) def commit(self): return self._mysqldb_connection.commit() def rollback(self): return self._mysqldb_connection.rollback() def close(self): return self._mysqldb_connection.close() def execute(self,sql,params=None,many=None,dict_cursor=True): #runs the db query . can also be used to run raw queries directly """ by default returns cursor object """ if dict_cursor: self.cursor = self._mysqldb_connection.cursor(MySQLdb.cursors.DictCursor) else: self.cursor = self._mysqldb_connection.cursor() if many: self.cursor.executemany(sql,params) else: self.cursor.execute(sql,params) return self.cursor #PySQL specific method begin from here def __getattr__(self,item): self.table_name = item self.columns = ['*'] #columns selected for display of records self.query_params = [] #for db filtering . parameters entered. self.sql = '' self.where_sql = '' self.join_sql = '' self.order_by_sql = '' self.group_by_sql = '' self.limit_sql = '' self.cursor = None return self def __make_table_column(self,column,table_name=None): """Example Input: => Output: users.id => users.id name => users.name """ if '.' in column: return column return "{}.{}".format(table_name,column) if table_name else "{}.{}".format(self.table_name,column) def get_columns(self): return ','.join([self.__make_table_column(c) for c in self.columns]) def fields(self,columns): #sets columns to select """ Example: ['id','name'] """ self.columns = columns return self def fetch(self,limit=None): if not self.cursor: self.__make_select_sql(limit=limit) print (self.sql) print (self.query_params) self.cursor = self.execute(self.sql,self.query_params) results = self.cursor.fetchall() self.cursor.close() return results def fetch_one(self): if not self.cursor: self.__make_select_sql(limit=None) self.cursor = self.execute(self.sql,self.query_params) result = self.cursor.fetchone() self.cursor.close() return result def __set_where(self,where_sql): if self.where_sql: #check if where starts with AND or OR where_sql = where_sql.strip() if where_sql.startswith('OR') or where_sql.startswith("AND"): self.where_sql = self.where_sql + " " + where_sql else: self.where_sql = self.where_sql + " AND " + where_sql else: self.where_sql = " WHERE {} ".format(where_sql) def __make_sql(self,sql): if sql: self.sql = self.sql + sql def __make_select_sql(self,limit): self.sql = "SELECT {} FROM {} ".format(self.get_columns(),self.table_name) self.__make_sql(self.join_sql) self.__make_sql(self.where_sql) self.__make_sql(self.group_by_sql) self.__make_sql(self.order_by_sql) self.__limit(limit) def __make_filter(self,k,v): #check if val is dict col = k filter_v = None #the filter value e.g name like '%mosoti%' param = v print ("Param: ",param, "column:",col) if isinstance(param,dict): filter_v , param = [(k,v) for k,v in param.items()][0] else: filter_v = "$eq" if filter_v == "$null": if v.get(filter_v) is False: filter_v = " IS NOT NULL " else: filter_v = " IS NULL " param = None elif filter_v == "$in": filter_v = " IN ({}) ".format(','.join(['%s' for i in param])) elif filter_v == "$nin": filter_v = " NOT IN ({}) ".format(','.join(['%s' for i in param])) else: if filter_v == '$contains' or filter_v == "$ncontains": param = '%{}%'.format(str(param)) elif filter_v == "$sw": param = '{}%'.format(str(param)) elif filter_v == "$ew": param = '%{}'.format(str(param)) filter_v = self.FILTER_COMMANDS.get(filter_v) return (param,filter_v,) def __make_or_query_filter(self,data_list): qs_l =[] for d in data_list: for ok,ov in d.items(): param,filter_v = self.__make_filter(ok,ov) self.__build_query_params(param) q = self.__make_table_column(ok) + filter_v qs_l.append(q) query = ' OR '.join(qs_l) return query def __build_query_params(self,param): #appends params to existinig if param: if isinstance(param,list): for p in param: self.query_params.append(p) else: self.query_params.append(param) def __filter_query(self,filter_data): #make filters filter_q_l = [] for k,v in filter_data.items(): if k == '$or': #make for or qs_l =self.__make_or_query_filter(filter_data.get('$or')) query = " OR " + qs_l filter_q_l.append(query) elif k == '$xor': #make for or qs_l = self.__make_or_query_filter(filter_data.get('$xor')) query = " AND ( " + qs_l + " )" filter_q_l.append(query) else: param,filter_v = self.__make_filter(k,v) self.__build_query_params(param) q = self.__make_table_column(k) + filter_v if len(filter_q_l) == 0: q = q else: q = " AND " + q filter_q_l.append(q) return filter_q_l def filter(self,filter_data): """ Filters Requests #example full including or { "name":{"$contains":"mosoti"}, "age":{"$lte":30}, "msisdn":"2541234567", "$or":[{ "name":{"$contains":"mogaka"}}, {"age":31} ], #this evaluates to => .. OR name like '%mogaka%' OR age=31 "$xor":[{ "name":{"$contains":"mogaka"}}, {"age":31} ] # this evalautes to =>... AND ( name like '%mogaka%' OR age=31 ) } """ #reset vals /parameters so that we begin here if filter_data: filter_q_l = self.__filter_query(filter_data) filters_qls = ''.join(filter_q_l).strip() if filters_qls.startswith("AND"): filters_qls = filters_qls[3:] elif filters_qls.startswith("OR"): filters_qls = filters_qls[2:] self.__set_where(filters_qls) return self def fetch_paginated(self,paginator_obj): #receives paginator object order_by = paginator_obj.get_order_by() filter_data = paginator_obj.get_filter_data() page_size = paginator_obj.page_size self.filter(filter_data) self.order_by(order_by) results = self.fetch(limit = page_size) pagination_data = paginator_obj.get_pagination_data(results) return {"results":results,"pagination":pagination_data} def __limit(self,limit): if limit: self.__build_query_params(limit) self.__make_sql(' LIMIT %s ') def __get_order_by_text(self,val): """ Receives string e.g -id or name """ if val.startswith('-'): return "{} DESC".format(self.__make_table_column(val[1:])) else: return "{} ASC".format(self.__make_table_column(val)) def order_by(self,order_by_fields): """Expects list of fields e.g ['-id','name'] where - is DESC""" order_by_sql = ','.join([self.__get_order_by_text(v) for v in order_by_fields]) if self.order_by_sql: self.order_by_sql = self.order_by_sql + ' , ' + order_by_sql else: self.order_by_sql = " ORDER BY " + order_by_sql return self def group_by(self,group_by_fields): """ Expects fields in list ['id','name'] ... """ group_by_sql = ','.join([self.__make_table_column(v) for v in group_by_fields]) if self.group_by_sql: self.group_by_sql = self.group_by_sql + group_by_sql else: self.group_by_sql = " GROUP BY " + group_by_sql return self def __make_join(self,join_type,table_name,condition_data,related_fields): """ makes join sql based on type of join and tables """ on_sql = [] for k,v in condition_data.items(): on_sql.append("{} = {} ".format(self.__make_table_column(k),self.__make_table_column(v,table_name))) on_sql_str = ' ON {} ' .format(' AND '.join(on_sql)) join_type_sql = '{} {} '.format(join_type,table_name) self.join_sql = self.join_sql + join_type_sql + on_sql_str #append the columns to select based on related fields if related_fields: self.columns.extend([self.__make_table_column(c,table_name) for c in related_fields]) def inner_join(self,table_name,condition,related_fields=None): """ e.g Orders,{"id":"customer_id"}, ['quantity'] This will result to : .... Orders.quantity, .... INNER JOIN Orders ON Customers.id = Orders.customer_id """ self.__make_join('INNER JOIN',table_name,condition,related_fields) return self def right_join(self,table_name,condition,related_fields=None): """ e.g Orders,{"id":"customer_id"}, ['quantity'] This will result to : .... Orders.quantity, .... RIGHT JOIN Orders ON Customers.id = Orders.customer_id """ self.__make_join('RIGHT JOIN',table_name,condition,related_fields) return self def left_join(self,table_name,condition,related_fields=None): """ e.g Orders,{"id":"customer_id"}, ['quantity'] This will result to : .... Orders.quantity, .... LEFT JOIN Orders ON Customers.id = Orders.customer_id """ self.__make_join('LEFT JOIN',table_name,condition,related_fields) return self def update(self,new_data,limit=None): """ set this new data as new details Returns cursor object """ col_set = ','.join([" {} = %s ".format(k) for k,v in new_data.items()]) filter_params = self.query_params self.query_params = [] update_params = [v for k,v in new_data.items()] update_params.extend(filter_params) #we start with update thn filter self.__build_query_params(update_params) self.sql = "UPDATE {} SET {} ".format(self.table_name,col_set) self.__make_sql(self.where_sql) self.__limit(limit) print(self.query_params) print (self.sql) return self.execute(self.sql,self.query_params) def delete(self,limit=None): """ Delete with given limit """ self.sql = "DELETE FROM {} ".format(self.table_name) self.__make_sql(self.where_sql) self.__limit(limit) print (self.sql) return self.execute(self.sql,self.query_params) def insert(self,data): """ Creates records to db table . Expects a dict of key abd values pair """ columns = [] params = [] for k,v in data.items(): columns.append(k) params.append(v) column_placeholders = ','.join(["%s" for v in columns]) columns = ','.join([v for v in columns]) self.query_params = params self.sql = "INSERT INTO {}({}) VALUES({})".format(self.table_name,columns,column_placeholders) print (self.sql) print (self.query_params) return self.execute(self.sql,self.query_params).lastrowid class Paginator: def __init__(self,max_page_size=None,url=None,page_number=None,page_size=None,last_seen=None,last_seen_field_name=None,direction=None): self.page_number = int(page_number) if page_number else 1 self.max_page_size = max_page_size if max_page_size else 1000 if page_size: if int(page_size) > self.max_page_size: self.page_size = self.max_page_size else: self.page_size = int(page_size) else: self.page_size = 25 self.last_seen_field_name = last_seen_field_name if last_seen_field_name else 'id' self.direction = direction self.last_seen = last_seen self.url = url self._where_clause = '' self._params = [] def get_order_by(self): order_by = [] if self.page_number == 1 or self.direction == 'next': order_by = ["-{}".format(self.last_seen_field_name)] #order descending elif self.direction == 'prev': order_by = ["{}".format(self.last_seen_field_name)] #order ascending return order_by def get_filter_data(self): filter_data = None if self.page_number == 1: filter_data = {} elif self.direction == 'prev': filter_data = { "{}".format(self.last_seen_field_name):{"$gt":"%s"%(self.last_seen)} } elif self.direction == 'next': filter_data = { "{}".format(self.last_seen_field_name):{"$lt":"%s"%(self.last_seen)} } return filter_data def get_next_link(self,results_list): page = self.page_number + 1 url = self.url if len(results_list) < self.page_size: return None if self.direction == 'prev' and page != 2: last_seen_dict = results_list[:-1][0] else: last_seen_dict = results_list[-1:][0] url=self.replace_query_param(url, 'page', page) url=self.replace_query_param(url, 'dir', 'next') url=self.replace_query_param(url, 'last_seen', last_seen_dict.get(self.last_seen_field_name)) return url def get_previous_link(self,results_list): page=self.page_number - 1 url=self.url if page == 0: return None elif len(results_list) == 0: #return home link url=self.remove_query_param(url, 'page') url=self.remove_query_param(url, 'dir') url=self.remove_query_param(url, 'last_seen') return url if self.direction == 'next' : last_seen_dict = results_list[:-1][0] else: last_seen_dict = results_list[-1:][0] #last_seen_dict = results_list[-1:][0] url=self.replace_query_param(url, 'page', page) url=self.replace_query_param(url, 'dir', 'prev') url=self.replace_query_param(url, 'last_seen', last_seen_dict.get(self.last_seen_field_name)) return url def replace_query_param(self,url, key, val): """ Given a URL and a key/val pair, set or replace an item in the query parameters of the URL, and return the new URL. """ (scheme, netloc, path, query, fragment) = parse.urlsplit(url) query_dict = parse.parse_qs(query, keep_blank_values=True) query_dict[str(key)] = [val] query = parse.urlencode(sorted(list(query_dict.items())), doseq=True) return parse.urlunsplit((scheme, netloc, path, query, fragment)) def remove_query_param(self,url, key): """ Given a URL and a key/val pair, remove an item in the query parameters of the URL, and return the new URL. """ (scheme, netloc, path, query, fragment) = parse.urlsplit(url) query_dict = parse.parse_qs(query, keep_blank_values=True) query_dict.pop(key, None) query = parse.urlencode(sorted(list(query_dict.items())), doseq=True) return parse.urlunsplit((scheme, netloc, path, query, fragment)) def get_pagination_data(self,results_list): return {'page_size':self.page_size, 'next_url': self.get_next_link(results_list), 'previous_url': self.get_previous_link(results_list) }
8,828
1,230
490
a9c9d9ad9a74e5fe13167144fcd090943b6c7714
2,297
py
Python
main/General_Circuit/Meta_Reporter.py
user-ccarr/ECIF
b858c22b9c2959efbc52ab93f21eac94663598ad
[ "BSD-3-Clause" ]
null
null
null
main/General_Circuit/Meta_Reporter.py
user-ccarr/ECIF
b858c22b9c2959efbc52ab93f21eac94663598ad
[ "BSD-3-Clause" ]
null
null
null
main/General_Circuit/Meta_Reporter.py
user-ccarr/ECIF
b858c22b9c2959efbc52ab93f21eac94663598ad
[ "BSD-3-Clause" ]
null
null
null
import yaml import sys def meta_report(meta_data_loc="Experiment_Data.yml"): """ Reads meta data from file called "Experiment_Data.yml" and adds a report Parameters ---------- meta_data_loc : str the path to file that contains experiment meta data Returns ------- config_data : none """ try: with open(meta_data_loc, "r") as stream: meta_data = yaml.safe_load(stream) report_message = report_writer(meta_data) f = open("Experiment_Info.txt","w" ) f.write(report_message) f.close() except FileNotFoundError: sys.exit("File containing meta data, {}, not found. Exiting...".format(meta_data_loc)) def report_writer(md): """ Reads meta data into function and makes txt message report. ---------- md : dict Contains meta data from experiment file Returns ------- message : string The text output for the report """ s_name = md["sample_meta_data"]["sample_name"] s_date = md["sample_meta_data"]["sample_date"] s_surface = md["sample_meta_data"]["sample_surface_area"] imp_mode = md["experiment_meta_data"]["impedance_mode"] meas_volt = md["experiment_meta_data"]["measurement_voltage"] vs = md["experiment_meta_data"]["vs"] pert_v = md["experiment_meta_data"]["pertubation_voltage"] sf = md["experiment_meta_data"]["starting_frequency"] ef = md["experiment_meta_data"]["ending_frequency"] ppi = md["experiment_meta_data"]["points_per_interval"] ig = md["experiment_meta_data"]["interval_group"] spacing = md["experiment_meta_data"]["spacing"] intro_line = "Report for "+str(s_name)+" experiment conducted on "+str(s_date)+".\n\n" imp_line = "A "+str(imp_mode)+" measurement was made with a "+str(pert_v)+"mV pertubation voltage at "+str(meas_volt)+"V vs. "+str(vs)+".\n\n" range_line = "Experiment conducted from "+str(sf)+"Hz to "+str(ef)+"Hz with "+str(ppi)+ " points "+str(ig)+" using "+str(spacing)+" spacing.\n\n" surface_line = "Sample has a surface area of "+str(s_surface)+"cm^2." message = intro_line+imp_line+range_line+surface_line return message
40.298246
150
0.627775
import yaml import sys def meta_report(meta_data_loc="Experiment_Data.yml"): """ Reads meta data from file called "Experiment_Data.yml" and adds a report Parameters ---------- meta_data_loc : str the path to file that contains experiment meta data Returns ------- config_data : none """ try: with open(meta_data_loc, "r") as stream: meta_data = yaml.safe_load(stream) report_message = report_writer(meta_data) f = open("Experiment_Info.txt","w" ) f.write(report_message) f.close() except FileNotFoundError: sys.exit("File containing meta data, {}, not found. Exiting...".format(meta_data_loc)) def report_writer(md): """ Reads meta data into function and makes txt message report. ---------- md : dict Contains meta data from experiment file Returns ------- message : string The text output for the report """ s_name = md["sample_meta_data"]["sample_name"] s_date = md["sample_meta_data"]["sample_date"] s_surface = md["sample_meta_data"]["sample_surface_area"] imp_mode = md["experiment_meta_data"]["impedance_mode"] meas_volt = md["experiment_meta_data"]["measurement_voltage"] vs = md["experiment_meta_data"]["vs"] pert_v = md["experiment_meta_data"]["pertubation_voltage"] sf = md["experiment_meta_data"]["starting_frequency"] ef = md["experiment_meta_data"]["ending_frequency"] ppi = md["experiment_meta_data"]["points_per_interval"] ig = md["experiment_meta_data"]["interval_group"] spacing = md["experiment_meta_data"]["spacing"] intro_line = "Report for "+str(s_name)+" experiment conducted on "+str(s_date)+".\n\n" imp_line = "A "+str(imp_mode)+" measurement was made with a "+str(pert_v)+"mV pertubation voltage at "+str(meas_volt)+"V vs. "+str(vs)+".\n\n" range_line = "Experiment conducted from "+str(sf)+"Hz to "+str(ef)+"Hz with "+str(ppi)+ " points "+str(ig)+" using "+str(spacing)+" spacing.\n\n" surface_line = "Sample has a surface area of "+str(s_surface)+"cm^2." message = intro_line+imp_line+range_line+surface_line return message
0
0
0
c741e0fabfcf222376d9c9ed9b7269d024ada2be
33,048
py
Python
src/nunavut/lang/__init__.py
DNedic/nunavut
61232b31b82ba1b6a3b0bf82392975399a541137
[ "MIT", "BSD-3-Clause" ]
24
2019-05-14T19:31:49.000Z
2021-11-20T09:39:48.000Z
src/nunavut/lang/__init__.py
DNedic/nunavut
61232b31b82ba1b6a3b0bf82392975399a541137
[ "MIT", "BSD-3-Clause" ]
163
2019-05-14T06:03:01.000Z
2022-03-31T18:21:15.000Z
src/nunavut/lang/__init__.py
DNedic/nunavut
61232b31b82ba1b6a3b0bf82392975399a541137
[ "MIT", "BSD-3-Clause" ]
12
2019-11-24T06:21:43.000Z
2022-02-23T13:42:51.000Z
# # Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. # Copyright (C) 2018-2020 UAVCAN Development Team <uavcan.org> # This software is distributed under the terms of the MIT License. # """Language-specific support in nunavut. This package contains modules that provide specific support for generating source for various languages using templates. """ import abc import functools import importlib import logging import pathlib import types import typing import pydsdl from ..dependencies import Dependencies, DependencyBuilder from .._utilities import YesNoDefault, iter_package_resources from ._config import LanguageConfig, VersionReader logger = logging.getLogger(__name__) class LanguageLoader: """ Factory class that loads language meta-data and concrete :class:`nunavut.lang.Language` objects. :param additional_config_files: A list of paths to additional configuration files to load as configuration. These will override any values found in the :file:`nunavut.lang.properties.yaml` file and files appearing later in this list will override value found in earlier entries. .. invisible-code-block: python from nunavut.lang import LanguageLoader subject = LanguageLoader() c_reserved_identifiers = subject.config.get_config_value('nunavut.lang.c','reserved_identifiers') assert len(c_reserved_identifiers) > 0 """ @classmethod @classmethod @property def config(self) -> LanguageConfig: """ Meta-data about all languages merged from the Nunavut internal defaults and any additional configuration files provided to this class's constructor. """ if self._config is None: self._config = self._load_config(*self._additional_config_files) return self._config def load_language( self, language_name: str, omit_serialization_support: bool, language_options: typing.Optional[typing.Mapping[str, typing.Any]] = None, ) -> "Language": """ :param str language_name: The name of the language used by the :mod:`nunavut.lang` module. :param LanguageConfig config: The parser to load language properties into. :param bool omit_serialization_support: The value to set for the :func:`omit_serialization_support` property for this language. :param typing.Optional[typing.Mapping[str, typing.Any]] language_options: Opaque arguments passed through to the target :class:`nunavut.lang.Language` object. :return: A new object that extends :class:`nunavut.lang.Language`. :rtype: nunavut.lang.Language .. invisible-code-block: python from nunavut.lang import LanguageLoader .. code-block:: python lang_c = LanguageLoader().load_language('c', True) assert lang_c.name == 'c' .. invisible-code-block: python # let's go ahead and load the rest of our known, internally supported languages just to raise # test failures right here at the wellspring. lang_cpp = LanguageLoader().load_language('py', True) assert lang_cpp.name == 'py' lang_js = LanguageLoader().load_language('js', True) assert lang_js.name == 'js' """ ln_module = self.load_language_module(language_name) try: language_type = typing.cast(typing.Type["Language"], getattr(ln_module, "Language")) except AttributeError: logging.debug( "Unable to find a Language object in nunavut.lang.{}. Using a Generic language object".format( language_name ) ) language_type = _GenericLanguage if language_type == Language: # the language module just imported the base class so let's go ahead and use _GenericLanguage language_type = _GenericLanguage return language_type(ln_module, self.config, omit_serialization_support, language_options) class Language(metaclass=abc.ABCMeta): """ Facilities for generating source code for a specific language. Concrete Language classes must be implemented by the language support package below lang and should be instantiated using :class:`nunavut.lang.LanguageLoader`. :param str language_name: The name of the language used by the :mod:`nunavut.lang` module. :param LanguageConfig config: The parser to load language properties into. :param bool omit_serialization_support: The value to set for the :func:`omit_serialization_support` property for this language. :param typing.Optional[typing.Mapping[str, typing.Any]] language_options: Opaque arguments passed through to the target :class:`nunavut.lang.Language` object. .. invisible-code-block: python from nunavut.lang import Language, _GenericLanguage from unittest.mock import MagicMock mock_config = MagicMock() mock_module = MagicMock() mock_module.__name__ = 'foo' try: my_lang = _GenericLanguage(mock_module, mock_config, True) # module must be within 'nunavut' assert False except RuntimeError: pass mock_module.__name__ = 'nunavut.foo' try: my_lang = _GenericLanguage(mock_module, mock_config, True) # module must be within 'nunavut.lang' assert False except RuntimeError: pass mock_module.__name__ = 'not.nunavut.foo' try: my_lang = _GenericLanguage(mock_module, mock_config, True) # module must be within 'nunavut.lang' assert False except RuntimeError: pass mock_module.__name__ = 'nunavut.lang.foo' my_lang = _GenericLanguage(mock_module, mock_config, True) assert my_lang.name == 'foo' """ @classmethod def default_filter_id_for_target(cls, instance: typing.Any) -> str: """ The default transformation of any object into a string. :param any instance: Any object or data that either has a name property or can be converted to a string. :return: Either ``str(instance.name)`` if the instance has a name property or just ``str(instance)`` """ if hasattr(instance, "name"): return str(instance.name) else: return str(instance) def __getattr__(self, name: str) -> typing.Any: """ Any attribute access to a Language object will return the regular properties and any globals defined for the language. Because of this do not extend properties on this object in a way that will clash with the globals it defines (e.g. typename_ or valuetoken_ should not be used as the start of attribute names). """ try: return self.get_globals()[name] except KeyError as e: raise AttributeError(e) def get_support_module(self) -> typing.Tuple[str, typing.Tuple[int, int, int], typing.Optional["types.ModuleType"]]: """ Returns the module object for the language support files. :return: A tuple of module name, x.y.z module version, and the module object itself. .. invisible-code-block: python from nunavut.lang import Language, _GenericLanguage from unittest.mock import MagicMock mock_config = MagicMock() mock_module = MagicMock() mock_module.__name__ = 'nunavut.lang.cpp' my_lang = _GenericLanguage(mock_module, mock_config, True) my_lang._section = "nunavut.lang.cpp" module_name, support_version, _ = my_lang.get_support_module() assert module_name == "nunavut.lang.cpp.support" assert support_version[0] == 1 """ module_name = "{}.support".format(self._section) try: module = importlib.import_module(module_name) version_tuple = VersionReader.read_version(module) return (module_name, version_tuple, module) except (ImportError, ValueError): # No serialization support for this language logger.info("No serialization support for selected target. Cannot retrieve module.") return (module_name, (0, 0, 0), None) @functools.lru_cache() @abc.abstractmethod def get_includes(self, dep_types: Dependencies) -> typing.List[str]: """ Get a list of include paths that are specific to this language and the options set for it. :param Dependencies dep_types: A description of the dependencies includes are needed for. :return: A list of include file paths. The list may be empty if no includes were needed. """ pass def filter_id(self, instance: typing.Any, id_type: str = "any") -> str: """ Produces a valid identifier in the language for a given object. The encoding may not be reversible. :param any instance: Any object or data that either has a name property or can be converted to a string. :param str id_type: A type of identifier. This is different for each language. For example, for C this value can be 'typedef', 'macro', 'function', or 'enum'. Use 'any' to apply stropping rules for all identifier types to the instance. :return: A token that is a valid identifier in the language, is not a reserved keyword, and is transformed in a deterministic manner based on the provided instance. """ return self.default_filter_id_for_target(instance) def filter_short_reference_name( self, t: pydsdl.CompositeType, stropping: YesNoDefault = YesNoDefault.DEFAULT, id_type: str = "any" ) -> str: """ Provides a string that is a shorted version of the full reference name omitting any namespace parts of the type. :param pydsdl.CompositeType t: The DSDL type to get the reference name for. :param YesNoDefault stropping: If DEFAULT then the stropping value configured for the target language is used else this overrides that value. :param str id_type: A type of identifier. This is different for each language. For example, for C this value can be 'typedef', 'macro', 'function', or 'enum'. Use 'any' to apply stropping rules for all identifier types to the instance. """ short_name = "{short}_{major}_{minor}".format(short=t.short_name, major=t.version.major, minor=t.version.minor) if YesNoDefault.test_truth(stropping, self.enable_stropping): return self.filter_id(short_name, id_type) else: return short_name def get_config_value(self, key: str, default_value: typing.Optional[str] = None) -> str: """ Get an optional language property from the language configuration. :param str key: The config value to retrieve. :param default_value: The value to return if the key was not in the configuration. If provided this method will not raise. :type default_value: typing.Optional[str] :return: Either the value from the config or the default_value if provided. :rtype: str :raises: KeyError if the section or the key in the section does not exist and a default_value was not provided. """ return self._config.get_config_value(self._section, key, default_value) def get_config_value_as_bool(self, key: str, default_value: bool = False) -> bool: """ Get an optional language property from the language configuration returning a boolean. :param str key: The config value to retrieve. :param bool default_value: The value to use if no value existed. :return: The config value as either True or False. :rtype: bool """ return self._config.get_config_value_as_bool(self._section, key, default_value) def get_config_value_as_dict( self, key: str, default_value: typing.Optional[typing.Dict] = None ) -> typing.Dict[str, typing.Any]: """ Get a language property parsing it as a map with string keys. .. invisible-code-block: python from nunavut.lang import LanguageConfig, LanguageLoader, Language, _GenericLanguage config = LanguageConfig() config.add_section('nunavut.lang.c') config.set('nunavut.lang.c', 'foo', {'one': 1}) lang_c = _GenericLanguage(LanguageLoader.load_language_module('c'), config, True) assert lang_c.get_config_value_as_dict('foo')['one'] == 1 assert lang_c.get_config_value_as_dict('bar', {'one': 2})['one'] == 2 :param str key: The config value to retrieve. :param default_value: The value to return if the key was not in the configuration. If provided this method will not raise a KeyError nor a TypeError. :type default_value: typing.Optional[typing.Mapping[str, typing.Any]] :return: Either the value from the config or the default_value if provided. :rtype: typing.Mapping[str, typing.Any] :raises: KeyError if the key does not exist and a default_value was not provided. :raises: TypeError if the value exists but is not a dict and a default_value was not provided. """ return self._config.get_config_value_as_dict(self._section, key, default_value) def get_config_value_as_list( self, key: str, default_value: typing.Optional[typing.List] = None ) -> typing.List[typing.Any]: """ Get a language property parsing it as a map with string keys. :param str key: The config value to retrieve. :param default_value: The value to return if the key was not in the configuration. If provided this method will not raise a KeyError nor a TypeError. :type default_value: typing.Optional[typing.List[typing.Any]] :return: Either the value from the config or the default_value if provided. :rtype: typing.List[typing.Any] :raises: KeyError if the key does not exist and a default_value was not provided. :raises: TypeError if the value exists but is not a dict and a default_value was not provided. """ return self._config.get_config_value_as_list(self._section, key, default_value) @property def extension(self) -> str: """ The extension to use for files generated in this language. """ return self._config.get_config_value(self._section, "extension", "get") @property def namespace_output_stem(self) -> typing.Optional[str]: """ The name of a namespace file for this language. """ try: return self._config.get_config_value(self._section, "namespace_file_stem") except KeyError: return None @property def name(self) -> str: """ The name of the language used by the :mod:`nunavut.lang` module. """ return self._language_name @property def support_namespace(self) -> typing.List[str]: """ The hierarchical namespace used by the support software. The property is a dot separated string when specified in configuration. This property returns that value split into namespace components with the first identifier being the first index in the array, etc. .. invisible-code-block: python from nunavut.lang import Language config = { 'nunavut.lang.cpp': { 'support_namespace': 'foo.bar' } } lctx = configurable_language_context_factory(config, 'cpp') lang_cpp = lctx.get_target_language() assert len(lang_cpp.support_namespace) == 2 assert lang_cpp.support_namespace[0] == 'foo' assert lang_cpp.support_namespace[1] == 'bar' """ namespace_str = self._config.get_config_value(self._section, "support_namespace", default_value="") return namespace_str.split(".") @property def enable_stropping(self) -> bool: """ Whether or not to strop identifiers for this language. """ return self._config.get_config_value_as_bool(self._section, "enable_stropping") @property def has_standard_namespace_files(self) -> bool: """ Whether or not the language defines special namespace files as part of its core standard (e.g. python's __init__). """ return self._config.get_config_value_as_bool(self._section, "has_standard_namespace_files") @property def stable_support(self) -> bool: """ Whether support for this language is designated 'stable', and not experimental. """ return self._config.get_config_value_as_bool(self._section, "stable_support") @property def omit_serialization_support(self) -> bool: """ If True then generators should not include serialization routines, types, or support libraries for this language. """ return self._omit_serialization_support @property def support_files(self) -> typing.Generator[pathlib.Path, None, None]: """ Iterates over non-templated supporting files embedded within the Nunavut distribution. .. invisible-code-block: python from nunavut.lang import Language, _GenericLanguage from unittest.mock import MagicMock mock_config = MagicMock() mock_module = MagicMock() mock_module.__name__ = 'nunavut.lang.foo' my_lang = _GenericLanguage(mock_module, mock_config, True) my_lang._section = "nunavut.lang.not_a_language_really_not_a_language" for support_file in my_lang.support_files: # if the module doesn't exist it shouldn't have any support files. assert False """ _, _, module = self.get_support_module() if module is not None: # All language support modules must provide a list_support_files method # to allow the copy generator access to the packaged support files. list_support_files = getattr( module, "list_support_files" ) # type: typing.Callable[[], typing.Generator[pathlib.Path, None, None]] return list_support_files() else: # No serialization support for this language return list_support_files() def get_option( self, option_key: str, default_value: typing.Union[typing.Mapping[str, typing.Any], str, None] = None ) -> typing.Union[typing.Mapping[str, typing.Any], str, None]: """ Get a language option for this language. .. invisible-code-block: python config = { 'nunavut.lang.cpp': { 'options': {'target_endianness': 'little'} } } lctx = configurable_language_context_factory(config, 'cpp') lang_cpp = lctx.get_target_language() .. code-block:: python # Values can come from defaults... assert lang_cpp.get_option('target_endianness') == 'little' # ... or can come from a sane default. assert lang_cpp.get_option('foobar', 'sane_default') == 'sane_default' :return: Either the value provided to the :class:`Language` instance, the value from properties.yaml, or the :code:`default_value`. """ try: return self._language_options[option_key] # type: ignore except KeyError: return default_value def get_templates_package_name(self) -> str: """ The name of the nunavut python package containing filters, types, and configuration for this language. """ return self._section def get_named_types(self) -> typing.Mapping[str, str]: """ Get a map of named types to the type name to emit for this language. """ return self._config.get_config_value_as_dict(self._section, "named_types", default_value={}) def get_named_values(self) -> typing.Mapping[str, str]: """ Get a map of named values to the token to emit for this language. """ return self._config.get_config_value_as_dict(self._section, "named_values", default_value={}) def get_globals(self) -> typing.Mapping[str, typing.Any]: """ Get all values for this language that should be available in a global context. :return: A mapping of global names to global values. """ if self._globals is None: globals_map = dict() # type: typing.Dict[str, typing.Any] for key, value in self.get_named_types().items(): globals_map["typename_{}".format(key)] = value for key, value in self.get_named_values().items(): globals_map["valuetoken_{}".format(key)] = value self._globals = globals_map return self._globals def get_options(self) -> typing.Mapping[str, typing.Any]: """ Get all language options for this Language. :return: A mapping of option names to option values. """ return self._language_options class _GenericLanguage(Language): """ Language type used when the language support within Nunavut does not define a language-specific subclass. Do not use this. Use :class:`nunavut.lang.LanguageLoader` which will create the proper object type based on inspection of the Nunavut internals. """ class LanguageContext: """ Context object containing the current target language (if any) and used to access :class:`Language` objects. :param str target_language: If provided a :class:`Language` object will be created to hold the target language set for this context. If None then there is no target language. :param str extension: The extension to use for generated file types or None to use a default based on the target_language. :param str namespace_output_stem: The filename stem to give to Namespace output files if emitted or None to use a default based on a target_language. :param additional_config_files: A list of paths to additional files to load as configuration. These will override any values found in the :file:`nunavut.lang.properties.yaml` file and files appearing later in this list will override value found in earlier entries. :type additional_config_files: typing.List[pathlib.Path] :param bool omit_serialization_support_for_target: If True then generators should not include serialization routines, types, or support libraries for the target language. :param typing.Optional[typing.Mapping[str, typing.Any]] language_options: Opaque arguments passed through to the target :class:`nunavut.lang.Language` object. :param bool include_experimental_languages: If True, expose languages with experimental (non-stable) support. :raises ValueError: If extension is None and no target language was provided. :raises KeyError: If the target language is not known. """ def get_language(self, key_or_module_name: str) -> Language: """ Get a :class:`Language` object for a given language identifier. :param str key_or_module_name: Either one of the Nunavut mnemonics for a supported language or the ``__name__`` of one of the ``nunavut.lang.[language]`` python modules. :return: A :class:`Language` object cached by this context. :rtype: Language """ if key_or_module_name is None or len(key_or_module_name) == 0: raise ValueError("key argument is required.") key = key_or_module_name[13:] if key_or_module_name.startswith("nunavut.lang.") else key_or_module_name return self.get_supported_languages()[key] def get_supported_language_names(self) -> typing.Iterable[str]: """Get a list of target languages supported by Nunavut. :return: An iterable of strings which are languages with special support within Nunavut templates. """ return [s[13:] for s in self._config.sections() if s.startswith("nunavut.lang.")] def get_output_extension(self) -> str: """ Gets the output extension to use regardless of a target language being available or not. :return: A file extension name with a leading dot. """ if self._extension is not None: return self._extension elif self._target_language is not None: return self._target_language.extension else: raise RuntimeError( "No extension was provided and no target language was set. Cannot determine the extension to use." ) def get_default_namespace_output_stem(self) -> typing.Optional[str]: """ The filename stem to give to Namespace output files if emitted or None if there was none specified and there is no target language. :return: A file name stem or None """ return self._namespace_output_stem def get_target_language(self) -> typing.Optional[Language]: """ Returns the target language configured on this object or None if no target language was specified. """ return self._target_language def filter_id_for_target(self, instance: typing.Any, id_type: str = "any") -> str: """ A filter that will transform a given string or pydsdl identifier into a valid identifier in the target language. A default transformation is applied if no target language is set. :param any instance: Any object or data that either has a name property or can be converted to a string. :param str id_type: A type of identifier. This is different for each language. Use 'any' to apply stropping rules for all identifier types to the instance. :return: A token that is a valid identifier in the target language, is not a reserved keyword, and is transformed in a deterministic manner based on the provided instance. """ if self._target_language is not None: return self._target_language.filter_id(instance, id_type) else: return Language.default_filter_id_for_target(instance) def get_supported_languages(self) -> typing.Dict[str, Language]: """ Returns a collection of available language support objects. """ return self._languages @property
43.656539
120
0.645576
# # Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. # Copyright (C) 2018-2020 UAVCAN Development Team <uavcan.org> # This software is distributed under the terms of the MIT License. # """Language-specific support in nunavut. This package contains modules that provide specific support for generating source for various languages using templates. """ import abc import functools import importlib import logging import pathlib import types import typing import pydsdl from ..dependencies import Dependencies, DependencyBuilder from .._utilities import YesNoDefault, iter_package_resources from ._config import LanguageConfig, VersionReader logger = logging.getLogger(__name__) class LanguageLoader: """ Factory class that loads language meta-data and concrete :class:`nunavut.lang.Language` objects. :param additional_config_files: A list of paths to additional configuration files to load as configuration. These will override any values found in the :file:`nunavut.lang.properties.yaml` file and files appearing later in this list will override value found in earlier entries. .. invisible-code-block: python from nunavut.lang import LanguageLoader subject = LanguageLoader() c_reserved_identifiers = subject.config.get_config_value('nunavut.lang.c','reserved_identifiers') assert len(c_reserved_identifiers) > 0 """ @classmethod def load_language_module(cls, language_name: str) -> "types.ModuleType": module_name = "nunavut.lang.{}".format(language_name) return importlib.import_module(module_name) @classmethod def _load_config(cls, *additional_config_files: pathlib.Path) -> LanguageConfig: parser = LanguageConfig() for resource in iter_package_resources(__name__, ".yaml"): ini_string = resource.read_text() parser.read_string(ini_string) for additional_path in additional_config_files: with open(str(additional_path), "r") as additional_file: parser.read_file(additional_file) return parser def __init__(self, *additional_config_files: pathlib.Path): self._config = None # type: typing.Optional[LanguageConfig] self._additional_config_files = additional_config_files @property def config(self) -> LanguageConfig: """ Meta-data about all languages merged from the Nunavut internal defaults and any additional configuration files provided to this class's constructor. """ if self._config is None: self._config = self._load_config(*self._additional_config_files) return self._config def load_language( self, language_name: str, omit_serialization_support: bool, language_options: typing.Optional[typing.Mapping[str, typing.Any]] = None, ) -> "Language": """ :param str language_name: The name of the language used by the :mod:`nunavut.lang` module. :param LanguageConfig config: The parser to load language properties into. :param bool omit_serialization_support: The value to set for the :func:`omit_serialization_support` property for this language. :param typing.Optional[typing.Mapping[str, typing.Any]] language_options: Opaque arguments passed through to the target :class:`nunavut.lang.Language` object. :return: A new object that extends :class:`nunavut.lang.Language`. :rtype: nunavut.lang.Language .. invisible-code-block: python from nunavut.lang import LanguageLoader .. code-block:: python lang_c = LanguageLoader().load_language('c', True) assert lang_c.name == 'c' .. invisible-code-block: python # let's go ahead and load the rest of our known, internally supported languages just to raise # test failures right here at the wellspring. lang_cpp = LanguageLoader().load_language('py', True) assert lang_cpp.name == 'py' lang_js = LanguageLoader().load_language('js', True) assert lang_js.name == 'js' """ ln_module = self.load_language_module(language_name) try: language_type = typing.cast(typing.Type["Language"], getattr(ln_module, "Language")) except AttributeError: logging.debug( "Unable to find a Language object in nunavut.lang.{}. Using a Generic language object".format( language_name ) ) language_type = _GenericLanguage if language_type == Language: # the language module just imported the base class so let's go ahead and use _GenericLanguage language_type = _GenericLanguage return language_type(ln_module, self.config, omit_serialization_support, language_options) class Language(metaclass=abc.ABCMeta): """ Facilities for generating source code for a specific language. Concrete Language classes must be implemented by the language support package below lang and should be instantiated using :class:`nunavut.lang.LanguageLoader`. :param str language_name: The name of the language used by the :mod:`nunavut.lang` module. :param LanguageConfig config: The parser to load language properties into. :param bool omit_serialization_support: The value to set for the :func:`omit_serialization_support` property for this language. :param typing.Optional[typing.Mapping[str, typing.Any]] language_options: Opaque arguments passed through to the target :class:`nunavut.lang.Language` object. .. invisible-code-block: python from nunavut.lang import Language, _GenericLanguage from unittest.mock import MagicMock mock_config = MagicMock() mock_module = MagicMock() mock_module.__name__ = 'foo' try: my_lang = _GenericLanguage(mock_module, mock_config, True) # module must be within 'nunavut' assert False except RuntimeError: pass mock_module.__name__ = 'nunavut.foo' try: my_lang = _GenericLanguage(mock_module, mock_config, True) # module must be within 'nunavut.lang' assert False except RuntimeError: pass mock_module.__name__ = 'not.nunavut.foo' try: my_lang = _GenericLanguage(mock_module, mock_config, True) # module must be within 'nunavut.lang' assert False except RuntimeError: pass mock_module.__name__ = 'nunavut.lang.foo' my_lang = _GenericLanguage(mock_module, mock_config, True) assert my_lang.name == 'foo' """ @classmethod def default_filter_id_for_target(cls, instance: typing.Any) -> str: """ The default transformation of any object into a string. :param any instance: Any object or data that either has a name property or can be converted to a string. :return: Either ``str(instance.name)`` if the instance has a name property or just ``str(instance)`` """ if hasattr(instance, "name"): return str(instance.name) else: return str(instance) def __init__( self, language_module: "types.ModuleType", config: LanguageConfig, omit_serialization_support: bool, language_options: typing.Optional[typing.Mapping[str, typing.Any]] = None, ): self._globals = None # type: typing.Optional[typing.Mapping[str, typing.Any]] self._section = language_module.__name__ name_parts = self._section.split(".") if len(name_parts) != 3 or name_parts[0] != "nunavut" or name_parts[1] != "lang": raise RuntimeError("unknown module provided to Language class.") self._language_name = name_parts[2] self._config = config self._omit_serialization_support = omit_serialization_support self._language_options = config.get_config_value_as_dict(self._section, "options", dict()) if language_options is not None: self._language_options.update(language_options) self._filters = dict() # type: typing.Dict[str, typing.Callable] self._tests = dict() # type: typing.Dict[str, typing.Callable] self._uses = dict() # type: typing.Dict[str, typing.Callable] def __getattr__(self, name: str) -> typing.Any: """ Any attribute access to a Language object will return the regular properties and any globals defined for the language. Because of this do not extend properties on this object in a way that will clash with the globals it defines (e.g. typename_ or valuetoken_ should not be used as the start of attribute names). """ try: return self.get_globals()[name] except KeyError as e: raise AttributeError(e) def get_support_module(self) -> typing.Tuple[str, typing.Tuple[int, int, int], typing.Optional["types.ModuleType"]]: """ Returns the module object for the language support files. :return: A tuple of module name, x.y.z module version, and the module object itself. .. invisible-code-block: python from nunavut.lang import Language, _GenericLanguage from unittest.mock import MagicMock mock_config = MagicMock() mock_module = MagicMock() mock_module.__name__ = 'nunavut.lang.cpp' my_lang = _GenericLanguage(mock_module, mock_config, True) my_lang._section = "nunavut.lang.cpp" module_name, support_version, _ = my_lang.get_support_module() assert module_name == "nunavut.lang.cpp.support" assert support_version[0] == 1 """ module_name = "{}.support".format(self._section) try: module = importlib.import_module(module_name) version_tuple = VersionReader.read_version(module) return (module_name, version_tuple, module) except (ImportError, ValueError): # No serialization support for this language logger.info("No serialization support for selected target. Cannot retrieve module.") return (module_name, (0, 0, 0), None) @functools.lru_cache() def get_dependency_builder(self, for_type: pydsdl.Any) -> DependencyBuilder: return DependencyBuilder(for_type) @abc.abstractmethod def get_includes(self, dep_types: Dependencies) -> typing.List[str]: """ Get a list of include paths that are specific to this language and the options set for it. :param Dependencies dep_types: A description of the dependencies includes are needed for. :return: A list of include file paths. The list may be empty if no includes were needed. """ pass def filter_id(self, instance: typing.Any, id_type: str = "any") -> str: """ Produces a valid identifier in the language for a given object. The encoding may not be reversible. :param any instance: Any object or data that either has a name property or can be converted to a string. :param str id_type: A type of identifier. This is different for each language. For example, for C this value can be 'typedef', 'macro', 'function', or 'enum'. Use 'any' to apply stropping rules for all identifier types to the instance. :return: A token that is a valid identifier in the language, is not a reserved keyword, and is transformed in a deterministic manner based on the provided instance. """ return self.default_filter_id_for_target(instance) def filter_short_reference_name( self, t: pydsdl.CompositeType, stropping: YesNoDefault = YesNoDefault.DEFAULT, id_type: str = "any" ) -> str: """ Provides a string that is a shorted version of the full reference name omitting any namespace parts of the type. :param pydsdl.CompositeType t: The DSDL type to get the reference name for. :param YesNoDefault stropping: If DEFAULT then the stropping value configured for the target language is used else this overrides that value. :param str id_type: A type of identifier. This is different for each language. For example, for C this value can be 'typedef', 'macro', 'function', or 'enum'. Use 'any' to apply stropping rules for all identifier types to the instance. """ short_name = "{short}_{major}_{minor}".format(short=t.short_name, major=t.version.major, minor=t.version.minor) if YesNoDefault.test_truth(stropping, self.enable_stropping): return self.filter_id(short_name, id_type) else: return short_name def get_config_value(self, key: str, default_value: typing.Optional[str] = None) -> str: """ Get an optional language property from the language configuration. :param str key: The config value to retrieve. :param default_value: The value to return if the key was not in the configuration. If provided this method will not raise. :type default_value: typing.Optional[str] :return: Either the value from the config or the default_value if provided. :rtype: str :raises: KeyError if the section or the key in the section does not exist and a default_value was not provided. """ return self._config.get_config_value(self._section, key, default_value) def get_config_value_as_bool(self, key: str, default_value: bool = False) -> bool: """ Get an optional language property from the language configuration returning a boolean. :param str key: The config value to retrieve. :param bool default_value: The value to use if no value existed. :return: The config value as either True or False. :rtype: bool """ return self._config.get_config_value_as_bool(self._section, key, default_value) def get_config_value_as_dict( self, key: str, default_value: typing.Optional[typing.Dict] = None ) -> typing.Dict[str, typing.Any]: """ Get a language property parsing it as a map with string keys. .. invisible-code-block: python from nunavut.lang import LanguageConfig, LanguageLoader, Language, _GenericLanguage config = LanguageConfig() config.add_section('nunavut.lang.c') config.set('nunavut.lang.c', 'foo', {'one': 1}) lang_c = _GenericLanguage(LanguageLoader.load_language_module('c'), config, True) assert lang_c.get_config_value_as_dict('foo')['one'] == 1 assert lang_c.get_config_value_as_dict('bar', {'one': 2})['one'] == 2 :param str key: The config value to retrieve. :param default_value: The value to return if the key was not in the configuration. If provided this method will not raise a KeyError nor a TypeError. :type default_value: typing.Optional[typing.Mapping[str, typing.Any]] :return: Either the value from the config or the default_value if provided. :rtype: typing.Mapping[str, typing.Any] :raises: KeyError if the key does not exist and a default_value was not provided. :raises: TypeError if the value exists but is not a dict and a default_value was not provided. """ return self._config.get_config_value_as_dict(self._section, key, default_value) def get_config_value_as_list( self, key: str, default_value: typing.Optional[typing.List] = None ) -> typing.List[typing.Any]: """ Get a language property parsing it as a map with string keys. :param str key: The config value to retrieve. :param default_value: The value to return if the key was not in the configuration. If provided this method will not raise a KeyError nor a TypeError. :type default_value: typing.Optional[typing.List[typing.Any]] :return: Either the value from the config or the default_value if provided. :rtype: typing.List[typing.Any] :raises: KeyError if the key does not exist and a default_value was not provided. :raises: TypeError if the value exists but is not a dict and a default_value was not provided. """ return self._config.get_config_value_as_list(self._section, key, default_value) @property def extension(self) -> str: """ The extension to use for files generated in this language. """ return self._config.get_config_value(self._section, "extension", "get") @property def namespace_output_stem(self) -> typing.Optional[str]: """ The name of a namespace file for this language. """ try: return self._config.get_config_value(self._section, "namespace_file_stem") except KeyError: return None @property def name(self) -> str: """ The name of the language used by the :mod:`nunavut.lang` module. """ return self._language_name @property def support_namespace(self) -> typing.List[str]: """ The hierarchical namespace used by the support software. The property is a dot separated string when specified in configuration. This property returns that value split into namespace components with the first identifier being the first index in the array, etc. .. invisible-code-block: python from nunavut.lang import Language config = { 'nunavut.lang.cpp': { 'support_namespace': 'foo.bar' } } lctx = configurable_language_context_factory(config, 'cpp') lang_cpp = lctx.get_target_language() assert len(lang_cpp.support_namespace) == 2 assert lang_cpp.support_namespace[0] == 'foo' assert lang_cpp.support_namespace[1] == 'bar' """ namespace_str = self._config.get_config_value(self._section, "support_namespace", default_value="") return namespace_str.split(".") @property def enable_stropping(self) -> bool: """ Whether or not to strop identifiers for this language. """ return self._config.get_config_value_as_bool(self._section, "enable_stropping") @property def has_standard_namespace_files(self) -> bool: """ Whether or not the language defines special namespace files as part of its core standard (e.g. python's __init__). """ return self._config.get_config_value_as_bool(self._section, "has_standard_namespace_files") @property def stable_support(self) -> bool: """ Whether support for this language is designated 'stable', and not experimental. """ return self._config.get_config_value_as_bool(self._section, "stable_support") @property def omit_serialization_support(self) -> bool: """ If True then generators should not include serialization routines, types, or support libraries for this language. """ return self._omit_serialization_support @property def support_files(self) -> typing.Generator[pathlib.Path, None, None]: """ Iterates over non-templated supporting files embedded within the Nunavut distribution. .. invisible-code-block: python from nunavut.lang import Language, _GenericLanguage from unittest.mock import MagicMock mock_config = MagicMock() mock_module = MagicMock() mock_module.__name__ = 'nunavut.lang.foo' my_lang = _GenericLanguage(mock_module, mock_config, True) my_lang._section = "nunavut.lang.not_a_language_really_not_a_language" for support_file in my_lang.support_files: # if the module doesn't exist it shouldn't have any support files. assert False """ _, _, module = self.get_support_module() if module is not None: # All language support modules must provide a list_support_files method # to allow the copy generator access to the packaged support files. list_support_files = getattr( module, "list_support_files" ) # type: typing.Callable[[], typing.Generator[pathlib.Path, None, None]] return list_support_files() else: # No serialization support for this language def list_support_files() -> typing.Generator[pathlib.Path, None, None]: # This makes both MyPy and sonarqube happy. return typing.cast(typing.Generator[pathlib.Path, None, None], iter(())) return list_support_files() def get_option( self, option_key: str, default_value: typing.Union[typing.Mapping[str, typing.Any], str, None] = None ) -> typing.Union[typing.Mapping[str, typing.Any], str, None]: """ Get a language option for this language. .. invisible-code-block: python config = { 'nunavut.lang.cpp': { 'options': {'target_endianness': 'little'} } } lctx = configurable_language_context_factory(config, 'cpp') lang_cpp = lctx.get_target_language() .. code-block:: python # Values can come from defaults... assert lang_cpp.get_option('target_endianness') == 'little' # ... or can come from a sane default. assert lang_cpp.get_option('foobar', 'sane_default') == 'sane_default' :return: Either the value provided to the :class:`Language` instance, the value from properties.yaml, or the :code:`default_value`. """ try: return self._language_options[option_key] # type: ignore except KeyError: return default_value def get_templates_package_name(self) -> str: """ The name of the nunavut python package containing filters, types, and configuration for this language. """ return self._section def get_named_types(self) -> typing.Mapping[str, str]: """ Get a map of named types to the type name to emit for this language. """ return self._config.get_config_value_as_dict(self._section, "named_types", default_value={}) def get_named_values(self) -> typing.Mapping[str, str]: """ Get a map of named values to the token to emit for this language. """ return self._config.get_config_value_as_dict(self._section, "named_values", default_value={}) def get_globals(self) -> typing.Mapping[str, typing.Any]: """ Get all values for this language that should be available in a global context. :return: A mapping of global names to global values. """ if self._globals is None: globals_map = dict() # type: typing.Dict[str, typing.Any] for key, value in self.get_named_types().items(): globals_map["typename_{}".format(key)] = value for key, value in self.get_named_values().items(): globals_map["valuetoken_{}".format(key)] = value self._globals = globals_map return self._globals def get_options(self) -> typing.Mapping[str, typing.Any]: """ Get all language options for this Language. :return: A mapping of option names to option values. """ return self._language_options class _GenericLanguage(Language): """ Language type used when the language support within Nunavut does not define a language-specific subclass. Do not use this. Use :class:`nunavut.lang.LanguageLoader` which will create the proper object type based on inspection of the Nunavut internals. """ def get_includes(self, dep_types: Dependencies) -> typing.List[str]: return [] class LanguageContext: """ Context object containing the current target language (if any) and used to access :class:`Language` objects. :param str target_language: If provided a :class:`Language` object will be created to hold the target language set for this context. If None then there is no target language. :param str extension: The extension to use for generated file types or None to use a default based on the target_language. :param str namespace_output_stem: The filename stem to give to Namespace output files if emitted or None to use a default based on a target_language. :param additional_config_files: A list of paths to additional files to load as configuration. These will override any values found in the :file:`nunavut.lang.properties.yaml` file and files appearing later in this list will override value found in earlier entries. :type additional_config_files: typing.List[pathlib.Path] :param bool omit_serialization_support_for_target: If True then generators should not include serialization routines, types, or support libraries for the target language. :param typing.Optional[typing.Mapping[str, typing.Any]] language_options: Opaque arguments passed through to the target :class:`nunavut.lang.Language` object. :param bool include_experimental_languages: If True, expose languages with experimental (non-stable) support. :raises ValueError: If extension is None and no target language was provided. :raises KeyError: If the target language is not known. """ def __init__( self, target_language: typing.Optional[str] = None, extension: typing.Optional[str] = None, namespace_output_stem: typing.Optional[str] = None, additional_config_files: typing.List[pathlib.Path] = [], omit_serialization_support_for_target: bool = True, language_options: typing.Optional[typing.Mapping[str, typing.Any]] = None, include_experimental_languages: bool = True, ): self._extension = extension self._namespace_output_stem = namespace_output_stem self._ln_loader = LanguageLoader(*additional_config_files) self._config = self._ln_loader.config self._languages = dict() # type: typing.Dict[str, Language] # create target language, if there is one. self._target_language = None if target_language is not None: try: self._target_language = self._ln_loader.load_language( target_language, omit_serialization_support_for_target, language_options=language_options ) except ImportError: raise KeyError("{} is not a supported language".format(target_language)) if not (self._target_language.stable_support or include_experimental_languages): raise ValueError( "{} support is only experimental, but experimental language support is not enabled".format( target_language ) ) if namespace_output_stem is None: self._namespace_output_stem = self._target_language.namespace_output_stem target_language_section_name = "nunavut.lang.{}".format(target_language) if self._namespace_output_stem is not None: self._config.set(target_language_section_name, "namespace_file_stem", self._namespace_output_stem) if extension is not None: self._config.set(target_language_section_name, "extension", extension) self._languages[target_language] = self._target_language # create remaining languages remaining_languages = set(self.get_supported_language_names()) - set((target_language,)) self._populate_languages(remaining_languages, include_experimental_languages) def _populate_languages(self, language_names: typing.Iterable[str], include_experimental: bool) -> None: for language_name in language_names: try: lang = self._ln_loader.load_language(language_name, False) if lang.stable_support or include_experimental: self._languages[language_name] = lang except ImportError: raise KeyError("{} is not a supported language".format(language_name)) def get_language(self, key_or_module_name: str) -> Language: """ Get a :class:`Language` object for a given language identifier. :param str key_or_module_name: Either one of the Nunavut mnemonics for a supported language or the ``__name__`` of one of the ``nunavut.lang.[language]`` python modules. :return: A :class:`Language` object cached by this context. :rtype: Language """ if key_or_module_name is None or len(key_or_module_name) == 0: raise ValueError("key argument is required.") key = key_or_module_name[13:] if key_or_module_name.startswith("nunavut.lang.") else key_or_module_name return self.get_supported_languages()[key] def get_supported_language_names(self) -> typing.Iterable[str]: """Get a list of target languages supported by Nunavut. :return: An iterable of strings which are languages with special support within Nunavut templates. """ return [s[13:] for s in self._config.sections() if s.startswith("nunavut.lang.")] def get_output_extension(self) -> str: """ Gets the output extension to use regardless of a target language being available or not. :return: A file extension name with a leading dot. """ if self._extension is not None: return self._extension elif self._target_language is not None: return self._target_language.extension else: raise RuntimeError( "No extension was provided and no target language was set. Cannot determine the extension to use." ) def get_default_namespace_output_stem(self) -> typing.Optional[str]: """ The filename stem to give to Namespace output files if emitted or None if there was none specified and there is no target language. :return: A file name stem or None """ return self._namespace_output_stem def get_target_language(self) -> typing.Optional[Language]: """ Returns the target language configured on this object or None if no target language was specified. """ return self._target_language def filter_id_for_target(self, instance: typing.Any, id_type: str = "any") -> str: """ A filter that will transform a given string or pydsdl identifier into a valid identifier in the target language. A default transformation is applied if no target language is set. :param any instance: Any object or data that either has a name property or can be converted to a string. :param str id_type: A type of identifier. This is different for each language. Use 'any' to apply stropping rules for all identifier types to the instance. :return: A token that is a valid identifier in the target language, is not a reserved keyword, and is transformed in a deterministic manner based on the provided instance. """ if self._target_language is not None: return self._target_language.filter_id(instance, id_type) else: return Language.default_filter_id_for_target(instance) def get_supported_languages(self) -> typing.Dict[str, Language]: """ Returns a collection of available language support objects. """ return self._languages @property def config(self) -> LanguageConfig: return self._config
5,081
0
273
3121ed78f11108b68e6bcfba53bebde2323837e6
10,692
py
Python
test/cal_accuracy.py
goroyabu/etnet
9d8e65fd9e8263eb9e84ac903e07638edba292b4
[ "MIT" ]
null
null
null
test/cal_accuracy.py
goroyabu/etnet
9d8e65fd9e8263eb9e84ac903e07638edba292b4
[ "MIT" ]
null
null
null
test/cal_accuracy.py
goroyabu/etnet
9d8e65fd9e8263eb9e84ac903e07638edba292b4
[ "MIT" ]
null
null
null
#!/usr/bin/env python3 import os import argparse import time import torch import torch.nn as nn import torch.optim as optim from torch.utils.data import DataLoader import numpy from ROOT import TFile, TH1D, TH2D, TCanvas from ROOT import gROOT, gPad, gStyle import ROOT from etnet.dataset import EtrackDataset from etnet.neuralnet import EtrackNet if __name__ == "__main__": parser = usage() args = parser.parse_args() for file in args.file: main(file, args) # main()
31.447059
129
0.601104
#!/usr/bin/env python3 import os import argparse import time import torch import torch.nn as nn import torch.optim as optim from torch.utils.data import DataLoader import numpy from ROOT import TFile, TH1D, TH2D, TCanvas from ROOT import gROOT, gPad, gStyle import ROOT from etnet.dataset import EtrackDataset from etnet.neuralnet import EtrackNet def usage(): parser = argparse.ArgumentParser( description="Accuracy", formatter_class=argparse.ArgumentDefaultsHelpFormatter, add_help=False, usage="%(prog)s [options] FILE ...", ) parser.add_argument( "file", metavar="FILE", type=str, nargs="+", help=".pth file name" ) parser.add_argument("--noutput", metavar="N", type=int, default=-1, help="") parser.add_argument("--csv", metavar="DATA", type=str, help="csv file") parser.add_argument( "--outdir", type=str, default="ana", help="directory name to output" ) parser.add_argument("--use-gpu", action="store_true", help="enable GPU") parser.add_argument("--cuda", type=str, default='"cuda:0"', help="name of cuda") parser.add_argument( "-h", "--help", action="help", help="show this help message and exit" ) return parser def estimation(model_path, outfilename, data_path, args): testdata = EtrackDataset(data_path=data_path, train=False) nevents = len(testdata) if args.noutput > 0 and args.noutput < nevents: nevents = args.noutput print("Input:", data_path, "is loaded") print("Number of test data :", nevents) net = EtrackNet(train=False) if args.use_gpu: net = net.to(args.cuda) net.load_state_dict(torch.load(model_path)) outfile = TFile(outfilename, "recreate") print(f"Output: {outfilename} is created") # th2_diff_pos = TH2D( # "th2_diff_pos", "diff_pos;#Delta Pixel;Counts", 128, -4, 4, 128, -4, 4 # ) th2_diff_pos = TH2D( "th2_diff_pos", "Distance True and Estimation;RelativeX [-1,1];RelativeY", EtrackDataset.N_PIXELS_1D*10, -1, 1, EtrackDataset.N_PIXELS_1D*10, -1, 1 ) th1_diff_phi = TH1D( "th1_diff_phi", "diff_phi;#Delta Phi (deg.)", EtrackDataset.N_LABELS_PHI*10, -180, 180 ) th1_diff_phi_nice = th1_diff_phi.Clone() th1_diff_phi_nice.SetNameTitle("th1_diff_phi_nice", "diff_phi_nice") # diff_cos_beta = ROOT.TH1D("diff_cos_beta", "diff_cos_beta;#Delta cos #beta;Counts", 128, -1, 1) # diff_phi_2d = ROOT.TH2D("diff_phi_2d", "diff_phi_2d;#Delta Phi (deg.);cos #beta;Counts", 128, -180, 180, 6, 0, 1) # diff_cos_beta_2d = ROOT.TH2D("diff_cos_beta_2d", "diff_cos_beta_2d;#Delta cos #beta;cos #beta;Counts", 128, -1, 1, 6, 0, 1) # corr_cos_beta_numpixnonzero = ROOT.TH2D( "corr_cos_beta_numpixnonzero",\ # "corr_cos_beta_numpixnonzero;cos #beta;NumPixNonZero;Counts", 1, 0, 1, 64, 0, 64) th1_maxlike_phi = TH1D( "th1_maxlike_phi", "Likelihood Map of Phi", EtrackDataset.N_LABELS_PHI, -0.5, EtrackDataset.N_LABELS_PHI - 0.5, ) th1_dist_like_phi = TH1D( "th1_dist_like_phi", "Distribution of Likelihood of Phi", 100, 0.0, 1.0 ) th2_dphi_vs_maxlike = TH2D( "th2_dphi_vs_maxlike", ";#Delta#phi[deg];Maximum of Likelihood Map", 128, -180.0, 180.0, 10, 0.0, 1.0, ) th2_dphi_vs_prom_like = TH2D( "th2_dphi_vs_prom_like", ";#Delta#phi[deg];Dev(Maximum Likelihood)/#sigma", 128, -180.0, 180.0, 20, -0.25, 10.0 - 0.25, ) th2_dphi_vs_rms_of_map = TH2D( "th2_dphi_vs_rms_of_map", ";#Delta#phi[deg];RMS of Likelihood Map", 128, -180.0, 180.0, 20, -0.25, 10.0 - 0.25, ) true_pos_map = TH2D( "true_pos_map", "true_pos_map;X;Y", EtrackDataset.N_PIXELS_1D, 0, 1, EtrackDataset.N_PIXELS_1D, 0, 1, ) est_pos_map = TH2D( "est_pos_map", "est_pos_map;X;Y", EtrackDataset.N_PIXELS_1D, 0, 1, EtrackDataset.N_PIXELS_1D, 0, 1, ) true_phi_map = TH1D( "true_phi_map", "true_phi_map;Phi (deg.);Counts", EtrackDataset.N_LABELS_PHI, -180, 180, ) est_phi_map = TH1D( "est_phi_map", "est_phi_map;Phi (deg.);Counts", EtrackDataset.N_LABELS_PHI, -180, 180, ) # true_cos_beta_map = ROOT.TH1D( "true_cos_beta_map", "true_cos_beta_map;cos #beta;Counts", 1, 0, 1 ) # est_cos_beta_map = ROOT.TH1D( "est_cos_beta_map", "est_cos_beta_map;cos #beta;Counts", 1, 0, 1 ) th2_image = TH2D("th2_image", "th2_image", 32, -0.5, 32 - 0.5, 32, -0.5, 32 - 0.5) gROOT.ProcessLine("gErrorIgnoreLevel = kFatal;") c = TCanvas("c", "c", 800, 400) c.Divide(2, 1) gStyle.SetOptStat("miren") pdfname = outfilename.replace(".root", ".pdf") with torch.no_grad(): for ievent in range(nevents): if ievent % 10 == 0: print(f"\r{ievent}/{nevents}", end="") image, label = testdata[ievent] inputs = ( torch.tensor(image) .view(-1, 1, EtrackDataset.N_PIXELS_1D, EtrackDataset.N_PIXELS_1D) .float() ) if args.use_gpu: inputs = inputs.to(args.cuda) true_phi_deg = testdata.getPhi(ievent) true_ini_pos_x, true_ini_pos_y = testdata.getIniPos(ievent) # true_cos_beta = testdata.getCosBeta(ievent) outputs = net(inputs) outputs_numpy = outputs.to("cpu").detach().numpy().copy() pos_map, phi_map = EtrackDataset.split(outputs_numpy[0]) pos_map = pos_map.reshape(EtrackDataset.N_PIXELS_SHAPE) phi_map = phi_map.reshape(EtrackDataset.N_LABELS_SHAPE) max_likeli_pos = numpy.max(pos_map) max_likeli_phi = numpy.max(phi_map) max_prob_pos_idx = numpy.unravel_index(numpy.argmax(pos_map), pos_map.shape) max_prob_phi_idx = numpy.unravel_index(numpy.argmax(phi_map), phi_map.shape) # max_prob_phi_cos_beta_idx = numpy.unravel_index(numpy.argmax(phi_cos_beta_map), phi_cos_beta_map.shape) max_prob_pos = pos_map[max_prob_pos_idx] max_prob_phi = phi_map[max_prob_phi_idx] # max_prob_phi_cos_beta = phi_cos_beta_map[max_prob_phi_cos_beta_idx] est_ini_pos_x = EtrackDataset.index_to_pos(max_prob_pos_idx[1]) est_ini_pos_y = EtrackDataset.index_to_pos(max_prob_pos_idx[0]) est_phi_deg = EtrackDataset.index_to_phi_deg(max_prob_phi_idx[0]) diff_pos_x = est_ini_pos_x - true_ini_pos_x diff_pos_y = est_ini_pos_y - true_ini_pos_y diff_phi = est_phi_deg - true_phi_deg th2_diff_pos.Fill(diff_pos_x, diff_pos_y) th1_diff_phi.Fill(diff_phi) th2_dphi_vs_maxlike.Fill(diff_phi, max_likeli_phi) # diff_cos_beta.Fill( est_cos_beta - true_cos_beta) # diff_phi_2d.Fill( est_phi_deg - true_phi_deg, true_cos_beta) # diff_cos_beta_2d.Fill( est_cos_beta - true_cos_beta, true_cos_beta) th1_maxlike_phi.Reset() th1_dist_like_phi.Reset() for index in range(len(phi_map)): likeli = phi_map[index] th1_maxlike_phi.Fill(index, likeli) th1_dist_like_phi.Fill(likeli) rms = th1_dist_like_phi.GetRMS() mean = th1_dist_like_phi.GetMean() div = abs(max_likeli_phi - mean) rms_of_map = th1_maxlike_phi.GetRMS() th1_maxlike_phi.SetTitle(f"Likelihood Map of Phi: dx/rms={div/rms:6.3f}") th1_dist_like_phi.SetTitle( f"Distribution of Likelihood of Phi: dx/rms={div:5.3f}/{rms:5.3f}" ) th2_dphi_vs_prom_like.Fill(diff_phi, div / rms) th2_dphi_vs_rms_of_map.Fill(diff_phi, rms_of_map) if div <= 4 * rms: th1_diff_phi_nice.Fill(diff_phi) th2_image.Reset() n_filled = 0 for i in range(32): if numpy.all(image[0][i] == 0.0): continue for j in range(32): if image[0][i][j] == 0.0: continue th2_image.Fill(i, j, image[0][i][j]) n_filled += 1 if n_filled < 5 and ievent != nevents - 1 and ievent != 0: continue c.cd(1) th1_maxlike_phi.Draw("hist") gStyle.SetOptStat("miren") c.cd(2) th2_image.Draw("colz") th2_image.GetXaxis().SetRangeUser(10, 25) th2_image.GetYaxis().SetRangeUser(10, 25) # th1_dist_like_phi.Draw( 'hist' ) if ievent == 0 and 1 < nevents: c.SaveAs(pdfname + "(") elif ievent == nevents - 1 and 1 < nevents: c.SaveAs(pdfname + ")") else: c.SaveAs(pdfname) true_pos_map.Fill(true_ini_pos_x, true_ini_pos_y) est_pos_map.Fill(est_ini_pos_x, est_ini_pos_y) true_phi_map.Fill(true_phi_deg) est_phi_map.Fill(est_phi_deg) # true_cos_beta_map.Fill(true_cos_beta) # est_cos_beta_map.Fill(est_cos_beta) # corr_cos_beta_numpixnonzero.Fill(est_cos_beta, testdata.getNumNonZeroPix(ievent)) print("\r") outfile.cd() th2_diff_pos.Write() th1_diff_phi.Write() th1_diff_phi_nice.Write() th2_dphi_vs_maxlike.Write() th2_dphi_vs_prom_like.Write() th2_dphi_vs_rms_of_map.Write() # diff_cos_beta.Write() # diff_phi_2d.Write() # diff_cos_beta_2d.Write() true_pos_map.Write() est_pos_map.Write() true_phi_map.Write() est_phi_map.Write() # true_cos_beta_map.Write() # est_cos_beta_map.Write() # corr_cos_beta_numpixnonzero.Write() outfile.Close() def main(input_file_name, args): base = os.path.basename(input_file_name) name, ext = os.path.splitext(base) if ext != ".pth": print("Input file is not .pth file") return output_file_name = f"{args.outdir}/acc_{name}.root" os.makedirs(args.outdir, exist_ok=True) estimation(input_file_name, output_file_name, args.csv, args) if __name__ == "__main__": parser = usage() args = parser.parse_args() for file in args.file: main(file, args) # main()
10,120
0
69
86a8487288d3f453a3a245387200f20ccee0ea4b
3,825
py
Python
keras_frcnn/FixedBatchNormalization.py
nikhilraj1997/keras-frcnn
13978cbf8b9c816a1b55f927d560163329f43f3c
[ "Apache-2.0" ]
null
null
null
keras_frcnn/FixedBatchNormalization.py
nikhilraj1997/keras-frcnn
13978cbf8b9c816a1b55f927d560163329f43f3c
[ "Apache-2.0" ]
null
null
null
keras_frcnn/FixedBatchNormalization.py
nikhilraj1997/keras-frcnn
13978cbf8b9c816a1b55f927d560163329f43f3c
[ "Apache-2.0" ]
null
null
null
import tensorflow as tf from tensorflow.keras.layers import Layer, InputSpec from tensorflow.keras import initializers, regularizers import tensorflow.keras.backend as K
45.535714
111
0.589804
import tensorflow as tf from tensorflow.keras.layers import Layer, InputSpec from tensorflow.keras import initializers, regularizers import tensorflow.keras.backend as K class FixedBatchNormalization(Layer): def __init__(self, epsilon=1e-3, axis=-1, weights=None, beta_init='zero', gamma_init='one', gamma_regularizer=None, beta_regularizer=None, **kwargs): self.supports_masking = True self.beta_init = initializers.get(beta_init) self.gamma_init = initializers.get(gamma_init) self.epsilon = epsilon self.axis = axis self.gamma_regularizer = regularizers.get(gamma_regularizer) self.beta_regularizer = regularizers.get(beta_regularizer) self.initial_weights = weights super(FixedBatchNormalization, self).__init__(**kwargs) def build(self, input_shape): self.input_spec = [InputSpec(shape=input_shape)] shape = (input_shape[self.axis],) self.gamma = self.add_weight(shape=shape, initializer=self.gamma_init, regularizer=self.gamma_regularizer, name='{}_gamma'.format(self.name), trainable=False) self.beta = self.add_weight(shape=shape, initializer=self.beta_init, regularizer=self.beta_regularizer, name='{}_beta'.format(self.name), trainable=False) self.running_mean = self.add_weight(shape=shape, initializer='zero', name='{}_running_mean'.format(self.name), trainable=False) self.running_std = self.add_weight(shape=shape, initializer='one', name='{}_running_std'.format(self.name), trainable=False) if self.initial_weights is not None: self.set_weights(self.initial_weights) del self.initial_weights self.built = True def call(self, x, mask=None): assert self.built, 'Layer must be built before being called' input_shape = K.int_shape(x) reduction_axes = list(range(len(input_shape))) del reduction_axes[self.axis] broadcast_shape = [1] * len(input_shape) broadcast_shape[self.axis] = input_shape[self.axis] if sorted(reduction_axes) == range(K.ndim(x))[:-1]: x_normed = K.batch_normalization( x, self.running_mean, self.running_std, self.beta, self.gamma, epsilon=self.epsilon) else: # need broadcasting broadcast_running_mean = K.reshape(self.running_mean, broadcast_shape) broadcast_running_std = K.reshape(self.running_std, broadcast_shape) broadcast_beta = K.reshape(self.beta, broadcast_shape) broadcast_gamma = K.reshape(self.gamma, broadcast_shape) x_normed = K.batch_normalization( x, broadcast_running_mean, broadcast_running_std, broadcast_beta, broadcast_gamma, epsilon=self.epsilon) return x_normed def get_config(self): config = {'epsilon': self.epsilon, 'axis': self.axis, 'gamma_regularizer': self.gamma_regularizer.get_config() if self.gamma_regularizer else None, 'beta_regularizer': self.beta_regularizer.get_config() if self.beta_regularizer else None} base_config = super(FixedBatchNormalization, self).get_config() return dict(list(base_config.items()) + list(config.items()))
3,508
16
131
8b79540aa0e5c98c7cc1c464554ec367c707f147
89,543
py
Python
pyvdk/types/objects.py
UT1C/pyVDK
168177c4006acc7f57be36f189bee8101e10253d
[ "MIT" ]
16
2020-11-24T18:27:59.000Z
2021-05-14T19:25:44.000Z
pyvdk/types/objects.py
UT1C/pyVDK
168177c4006acc7f57be36f189bee8101e10253d
[ "MIT" ]
1
2021-04-21T14:35:55.000Z
2021-06-26T04:18:44.000Z
pyvdk/types/objects.py
UT1C/pyVDK
168177c4006acc7f57be36f189bee8101e10253d
[ "MIT" ]
2
2020-12-03T16:56:31.000Z
2020-12-19T16:28:58.000Z
# -*- coding: utf-8 -*- # import enum import json from typing import Any, Callable, Dict, List, Optional, Union from pydantic import Json from .abc import Model [v.update_forward_refs() for v in globals().values() if hasattr(v, "update_forward_refs")]
21.289349
90
0.676837
# -*- coding: utf-8 -*- # import enum import json from typing import Any, Callable, Dict, List, Optional, Union from pydantic import Json from .abc import Model class AccountAccountCounters(Model): app_requests: int events: int faves: int friends: int friends_suggestions: int friends_recommendations: int gifts: int groups: int menu_discover_badge: int messages: int memories: int notes: int notifications: int photos: int sdk: int class AccountInfo(Model): wishlists_ae_promo_banner_show: "BaseBoolInt" twofa_required: "BaseBoolInt" country: str https_required: "BaseBoolInt" intro: "BaseBoolInt" show_vk_apps_intro: bool mini_apps_ads_slot_id: int qr_promotion: int link_redirects: Dict[Any, Any] lang: int no_wall_replies: "BaseBoolInt" own_posts_default: "BaseBoolInt" subscriptions: List[int] class AccountNameRequest(Model): first_name: str id: int last_name: str status: "AccountNameRequestStatus" lang: str link_href: str link_label: str class AccountNameRequestStatus(enum.Enum): SUCCESS = "success" PROCESSING = "processing" DECLINED = "declined" WAS_ACCEPTED = "was_accepted" WAS_DECLINED = "was_declined" DECLINED_WITH_LINK = "declined_with_link" RESPONSE = "response" RESPONSE_WITH_LINK = "response_with_link" class AccountOffer(Model): description: str id: int img: str instruction: str instruction_html: str price: int short_description: str tag: str title: str currency_amount: float link_id: int link_type: str class AccountPushConversations(Model): count: int items: List['AccountPushConversationsItem'] class AccountPushConversationsItem(Model): disabled_until: int peer_id: int sound: "BaseBoolInt" class AccountPushParams(Model): msg: List['AccountPushParamsMode'] chat: List['AccountPushParamsMode'] like: List['AccountPushParamsSettings'] repost: List['AccountPushParamsSettings'] comment: List['AccountPushParamsSettings'] mention: List['AccountPushParamsSettings'] reply: List['AccountPushParamsOnoff'] new_post: List['AccountPushParamsOnoff'] wall_post: List['AccountPushParamsOnoff'] wall_publish: List['AccountPushParamsOnoff'] friend: List['AccountPushParamsOnoff'] friend_found: List['AccountPushParamsOnoff'] friend_accepted: List['AccountPushParamsOnoff'] group_invite: List['AccountPushParamsOnoff'] group_accepted: List['AccountPushParamsOnoff'] birthday: List['AccountPushParamsOnoff'] event_soon: List['AccountPushParamsOnoff'] app_request: List['AccountPushParamsOnoff'] sdk_open: List['AccountPushParamsOnoff'] class AccountPushParamsMode(enum.Enum): ON = "on" OFF = "off" NO_SOUND = "no_sound" NO_TEXT = "no_text" class AccountPushParamsOnoff(enum.Enum): ON = "on" OFF = "off" class AccountPushParamsSettings(enum.Enum): ON = "on" OFF = "off" FR_OF_FR = "fr_of_fr" class AccountPushSettings(Model): disabled: "BaseBoolInt" disabled_until: int settings: "AccountPushParams" conversations: "AccountPushConversations" class AccountUserSettings(Model): ... class AccountUserSettingsInterest(Model): title: str value: str class AccountUserSettingsInterests(Model): activities: "AccountUserSettingsInterest" interests: "AccountUserSettingsInterest" music: "AccountUserSettingsInterest" tv: "AccountUserSettingsInterest" movies: "AccountUserSettingsInterest" books: "AccountUserSettingsInterest" games: "AccountUserSettingsInterest" quotes: "AccountUserSettingsInterest" about: "AccountUserSettingsInterest" class AddressesFields(enum.Enum): ID = "id" TITLE = "title" ADDRESS = "address" ADDITIONAL_ADDRESS = "additional_address" COUNTRY_ID = "country_id" CITY_ID = "city_id" METRO_STATION_ID = "metro_station_id" LATITUDE = "latitude" LONGITUDE = "longitude" DISTANCE = "distance" WORK_INFO_STATUS = "work_info_status" TIMETABLE = "timetable" PHONE = "phone" TIME_OFFSET = "time_offset" class AdsAccessRole(enum.Enum): ADMIN = "admin" MANAGER = "manager" REPORTS = "reports" class AdsAccesses(Model): client_id: str role: "AdsAccessRole" class AdsAccount(Model): access_role: "AdsAccessRole" account_id: int account_status: "BaseBoolInt" account_type: "AdsAccountType" account_name: str class AdsAccountType(enum.Enum): GENERAL = "general" AGENCY = "agency" class AdsAd(Model): ad_format: int ad_platform: Optional[Union[int, str]] = None all_limit: int approved: "AdsAdApproved" campaign_id: int category1_id: Optional[int] = None category2_id: Optional[int] = None cost_type: "AdsAdCostType" cpc: Optional[int] = None cpm: Optional[int] = None cpa: Optional[int] = None ocpm: Optional[int] = None autobidding_max_cost: Optional[int] = None disclaimer_medical: Optional["BaseBoolInt"] = None disclaimer_specialist: Optional["BaseBoolInt"] = None disclaimer_supplements: Optional["BaseBoolInt"] = None id: int impressions_limit: Optional[int] = None impressions_limited: Optional["BaseBoolInt"] = None name: str status: "AdsAdStatus" video: Optional["BaseBoolInt"] = None class AdsAdApproved(enum.Enum): NOT_MODERATED = 0 PENDING_MODERATION = 1 APPROVED = 2 REJECTED = 3 class AdsAdCostType(enum.Enum): PER_CLICKS = 0 PER_IMPRESSIONS = 1 PER_ACTIONS = 2 PER_IMPRESSIONS_OPTIMIZED = 3 class AdsAdLayout(Model): ad_format: int campaign_id: int cost_type: "AdsAdCostType" description: str id: int image_src: str image_src_2x: Optional[str] = None link_domain: Optional[str] = None link_url: str preview_link: Optional[Union[int, str]] = None title: str video: Optional["BaseBoolInt"] = None class AdsAdStatus(enum.Enum): STOPPED = 0 STARTED = 1 DELETED = 2 class AdsCampaign(Model): all_limit: str day_limit: str id: int name: str start_time: int status: "AdsCampaignStatus" stop_time: int type: "AdsCampaignType" class AdsCampaignStatus(enum.Enum): STOPPED = 0 STARTED = 1 DELETED = 2 class AdsCampaignType(enum.Enum): NORMAL = "normal" VK_APPS_MANAGED = "vk_apps_managed" MOBILE_APPS = "mobile_apps" PROMOTED_POSTS = "promoted_posts" class AdsCategory(Model): id: int name: str subcategories: Optional[List['BaseObjectWithName']] = None class AdsClient(Model): all_limit: str day_limit: str id: int name: str class AdsCriteria(Model): age_from: int age_to: int apps: str apps_not: str birthday: int cities: str cities_not: str country: int districts: str groups: str interest_categories: str interests: str paying: "BaseBoolInt" positions: str religions: str retargeting_groups: str retargeting_groups_not: str school_from: int school_to: int schools: str sex: "AdsCriteriaSex" stations: str statuses: str streets: str travellers: "BasePropertyExists" uni_from: int uni_to: int user_browsers: str user_devices: str user_os: str class AdsCriteriaSex(enum.Enum): ANY = 0 MALE = 1 FEMALE = 2 class AdsDemoStats(Model): id: int stats: "AdsDemostatsFormat" type: "AdsObjectType" class AdsDemostatsFormat(Model): age: List['AdsStatsAge'] cities: List['AdsStatsCities'] day: str month: str overall: int sex: List['AdsStatsSex'] sex_age: List['AdsStatsSexAge'] class AdsFloodStats(Model): left: int refresh: int class AdsLinkStatus(Model): description: str redirect_url: str status: str class AdsLookalikeRequest(Model): id: int create_time: int update_time: int scheduled_delete_time: Optional[int] = None status: str source_type: str source_retargeting_group_id: Optional[int] = None source_name: Optional[str] = None audience_count: Optional[int] = None save_audience_levels: Optional[List['AdsLookalikeRequestSaveAudienceLevel']] = None class AdsLookalikeRequestSaveAudienceLevel(Model): level: int audience_count: int class AdsMusician(Model): id: int name: str class AdsObjectType(enum.Enum): AD = "ad" CAMPAIGN = "campaign" CLIENT = "client" OFFICE = "office" class AdsParagraphs(Model): paragraph: str class AdsPromotedPostReach(Model): hide: int id: int join_group: int links: int reach_subscribers: int reach_total: int report: int to_group: int unsubscribe: int video_views_100p: Optional[int] = None video_views_25p: Optional[int] = None video_views_3s: Optional[int] = None video_views_50p: Optional[int] = None video_views_75p: Optional[int] = None video_views_start: Optional[int] = None class AdsRejectReason(Model): comment: str rules: List['AdsRules'] class AdsRules(Model): paragraphs: List['AdsParagraphs'] title: str class AdsStats(Model): id: int stats: "AdsStatsFormat" type: "AdsObjectType" views_times: "AdsStatsViewsTimes" class AdsStatsAge(Model): clicks_rate: float impressions_rate: float value: str class AdsStatsCities(Model): clicks_rate: float impressions_rate: float name: str value: int class AdsStatsFormat(Model): clicks: int day: str impressions: int join_rate: int month: str overall: int reach: int spent: int video_clicks_site: int video_views: int video_views_full: int video_views_half: int class AdsStatsSex(Model): clicks_rate: float impressions_rate: float value: "AdsStatsSexValue" class AdsStatsSexAge(Model): clicks_rate: float impressions_rate: float value: str class AdsStatsSexValue(enum.Enum): FEMALE = 'f' MALE = 'm' class AdsStatsViewsTimes(Model): views_ads_times_1: int views_ads_times_2: int views_ads_times_3: int views_ads_times_4: int views_ads_times_5: str views_ads_times_6: int views_ads_times_7: int views_ads_times_8: int views_ads_times_9: int views_ads_times_10: int views_ads_times_11_plus: int class AdsTargSettings(Model): ... class AdsTargStats(Model): audience_count: int recommended_cpc: Optional[float] = None recommended_cpm: Optional[float] = None recommended_cpc_50: Optional[float] = None recommended_cpm_50: Optional[float] = None recommended_cpc_70: Optional[float] = None recommended_cpm_70: Optional[float] = None recommended_cpc_90: Optional[float] = None recommended_cpm_90: Optional[float] = None class AdsTargSuggestions(Model): id: int name: str class AdsTargSuggestionsCities(Model): id: int name: str parent: str class AdsTargSuggestionsRegions(Model): id: int name: str type: str class AdsTargSuggestionsSchools(Model): desc: str id: int name: str parent: str type: "AdsTargSuggestionsSchoolsType" class AdsTargSuggestionsSchoolsType(enum.Enum): SCHOOL = "school" UNIVERSITY = "university" FACULTY = "faculty" CHAIR = "chair" class AdsTargetGroup(Model): audience_count: int domain: str id: int lifetime: int name: str pixel: str class AdsUsers(Model): accesses: List['AdsAccesses'] user_id: int class AppsApp(Model): ... class AppsAppLeaderboardType(enum.Enum): NOT_SUPPORTED = 0 LEVELS = 1 POINTS = 2 class AppsAppMin(Model): type: "AppsAppType" id: int title: str author_owner_id: Optional[int] = None is_installed: Optional[bool] = None icon_139: Optional[str] = None icon_150: Optional[str] = None icon_278: Optional[str] = None icon_576: Optional[str] = None background_loader_color: Optional[str] = None loader_icon: Optional[str] = None icon_75: Optional[str] = None class AppsAppType(enum.Enum): APP = "app" GAME = "game" SITE = "site" STANDALONE = "standalone" VK_APP = "vk_app" COMMUNITY_APP = "community_app" HTML5_GAME = "html5_game" MINI_APP = "mini_app" class AppsLeaderboard(Model): level: Optional[int] = None points: Optional[int] = None score: Optional[int] = None user_id: int class AppsScope(Model): name: str title: Optional[str] = None class AudioAudio(Model): artist: str id: int title: str url: Optional[str] = None duration: int date: Optional[int] = None album_id: Optional[int] = None genre_id: Optional[int] = None performer: Optional[str] = None class BaseBoolInt(enum.Enum): NO = 0 YES = 1 class BaseCity(Model): id: int title: str class BaseCommentsInfo(Model): can_post: "BaseBoolInt" count: int groups_can_post: bool class BaseCountry(Model): id: int title: str class BaseCropPhoto(Model): photo: "PhotosPhoto" crop: "BaseCropPhotoCrop" rect: "BaseCropPhotoRect" class BaseCropPhotoCrop(Model): x: float y: float x2: float y2: float class BaseCropPhotoRect(Model): x: float y: float x2: float y2: float class BaseError(Model): error_code: int error_msg: str error_text: str request_params: List['BaseRequestParam'] class BaseGeo(Model): coordinates: "BaseGeoCoordinates" place: "BasePlace" showmap: int type: str class BaseGeoCoordinates(Model): latitude: float longitude: float class BaseGradientPoint(Model): color: str position: float class BaseImage(Model): id: Optional[str] = None height: int url: str width: int class BaseLikes(Model): count: int user_likes: "BaseBoolInt" class BaseLikesInfo(Model): can_like: "BaseBoolInt" can_publish: Optional["BaseBoolInt"] = None count: int user_likes: int class BaseLink(Model): application: Optional["BaseLinkApplication"] = None button: Optional["BaseLinkButton"] = None caption: Optional[str] = None description: Optional[str] = None id: Optional[str] = None is_favorite: Optional[bool] = None photo: Optional["PhotosPhoto"] = None preview_page: Optional[str] = None preview_url: Optional[str] = None product: Optional["BaseLinkProduct"] = None rating: Optional["BaseLinkRating"] = None title: Optional[str] = None url: str target_object: Optional["LinkTargetObject"] = None is_external: Optional[bool] = None video: Optional["VideoVideo"] = None class BaseLinkApplication(Model): app_id: float store: "BaseLinkApplicationStore" class BaseLinkApplicationStore(Model): id: float name: str class BaseLinkButton(Model): action: "BaseLinkButtonAction" title: str block_id: str section_id: str owner_id: int icon: str style: "BaseLinkButtonStyle" class BaseLinkButtonAction(Model): type: "BaseLinkButtonActionType" url: str consume_reason: str class BaseLinkButtonActionType(enum.Enum): OPEN_URL = 'open_url' class BaseLinkButtonStyle(Model): ... class BaseLinkProduct(Model): price: "MarketPrice" merchant: Optional[str] = None orders_count: Optional[int] = None class BaseLinkRating(Model): reviews_count: int stars: float class BaseMessageError(Model): code: int description: str class BaseObject(Model): id: int title: str class BaseObjectCount(Model): count: int class BaseObjectWithName(Model): id: int name: str class BasePlace(Model): address: str checkins: int city: str country: str created: int icon: str id: int latitude: float longitude: float title: str type: str class BasePropertyExists(enum.Enum): PROPERTY_EXISTS = 1 class BaseRepostsInfo(Model): count: int user_reposted: int class BaseRequestParam(Model): key: str value: str class BaseSex(enum.Enum): UNKNOWN = 0 FEMALE = 1 MALE = 2 class BaseSticker(Model): sticker_id: int product_id: int images: List['BaseImage'] images_with_background: List['BaseImage'] animation_url: str animations: List['BaseStickerAnimation'] is_allowed: bool class BaseStickerAnimation(Model): type: str url: str class BaseUploadServer(Model): upload_url: str class BaseUserGroupFields(enum.Enum): ABOUT = "about" ACTION_BUTTON = "action_button" ACTIVITIES = "activities" ACTIVITY = "activity" ADDRESSES = "addresses" ADMIN_LEVEL = "admin_level" AGE_LIMITS = "age_limits" AUTHOR_ID = "author_id" BAN_INFO = "ban_info" BDATE = "bdate" BLACKLISTED = "blacklisted" BLACKLISTED_BY_ME = "blacklisted_by_me" BOOKS = "books" CAN_CREATE_TOPIC = "can_create_topic" CAN_MESSAGE = "can_message" CAN_POST = "can_post" CAN_SEE_ALL_POSTS = "can_see_all_posts" CAN_SEE_AUDIO = "can_see_audio" CAN_SEND_FRIEND_REQUEST = "can_send_friend_request" CAN_UPLOAD_VIDEO = "can_upload_video" CAN_WRITE_PRIVATE_MESSAGE = "can_write_private_message" CAREER = "career" CITY = "city" COMMON_COUNT = "common_count" CONNECTIONS = "connections" CONTACTS = "contacts" COUNTERS = "counters" COUNTRY = "country" COVER = "cover" CROP_PHOTO = "crop_photo" DEACTIVATED = "deactivated" DESCRIPTION = "description" DOMAIN = "domain" EDUCATION = "education" EXPORTS = "exports" FINISH_DATE = "finish_date" FIXED_POST = "fixed_post" FOLLOWERS_COUNT = "followers_count" FRIEND_STATUS = "friend_status" GAMES = "games" HAS_MARKET_APP = "has_market_app" HAS_MOBILE = "has_mobile" HAS_PHOTO = "has_photo" HOME_TOWN = "home_town" ID = "id" INTERESTS = "interests" IS_ADMIN = "is_admin" IS_CLOSED = "is_closed" IS_FAVORITE = "is_favorite" IS_FRIEND = "is_friend" IS_HIDDEN_FROM_FEED = "is_hidden_from_feed" IS_MEMBER = "is_member" IS_MESSAGES_BLOCKED = "is_messages_blocked" CAN_SEND_NOTIFY = "can_send_notify" IS_SUBSCRIBED = "is_subscribed" LAST_SEEN = "last_seen" LINKS = "links" LISTS = "lists" MAIDEN_NAME = "maiden_name" MAIN_ALBUM_ID = "main_album_id" MAIN_SECTION = "main_section" MARKET = "market" MEMBER_STATUS = "member_status" MEMBERS_COUNT = "members_count" MILITARY = "military" MOVIES = "movies" MUSIC = "music" NAME = "name" NICKNAME = "nickname" OCCUPATION = "occupation" ONLINE = "online" ONLINE_STATUS = "online_status" PERSONAL = "personal" PHONE = "phone" PHOTO_100 = "photo_100" PHOTO_200 = "photo_200" PHOTO_200_ORIG = "photo_200_orig" PHOTO_400_ORIG = "photo_400_orig" PHOTO_50 = "photo_50" PHOTO_ID = "photo_id" PHOTO_MAX = "photo_max" PHOTO_MAX_ORIG = "photo_max_orig" QUOTES = "quotes" RELATION = "relation" RELATIVES = "relatives" SCHOOLS = "schools" SCREEN_NAME = "screen_name" SEX = "sex" SITE = "site" START_DATE = "start_date" STATUS = "status" TIMEZONE = "timezone" TRENDING = "trending" TV = "tv" TYPE = "type" UNIVERSITIES = "universities" VERIFIED = "verified" WALL_COMMENTS = "wall_comments" WIKI_PAGE = "wiki_page" VK_ADMIN_STATUS = "vk_admin_status" class BaseUserId(Model): user_id: int class BoardDefaultOrder(enum.Enum): DESC_UPDATED = 1 DESC_CREATED = 2 ASC_UPDATED = -1 ASC_CREATED = -2 class BoardTopic(Model): comments: int created: int created_by: int id: int is_closed: "BaseBoolInt" is_fixed: "BaseBoolInt" title: str updated: int updated_by: int class BoardTopicComment(Model): attachments: Optional[List['WallCommentAttachment']] = None date: int from_id: int id: int real_offset: Optional[int] = None text: str can_edit: Optional["BaseBoolInt"] = None likes: Optional["BaseLikesInfo"] = None class BoardTopicPoll(Model): answer_id: int answers: List['PollsAnswer'] created: int is_closed: Optional["BaseBoolInt"] = None owner_id: int poll_id: int question: str votes: str class CallbackBoardPostDelete(Model): topic_owner_id: int topic_id: int id: int class CallbackConfirmationMessage(Model): type: "CallbackMessageType" group_id: int secret: str class CallbackGroupChangePhoto(Model): user_id: int photo: "PhotosPhoto" class CallbackGroupChangeSettings(Model): user_id: int self: "BaseBoolInt" class CallbackGroupJoin(Model): user_id: int join_type: "CallbackGroupJoinType" class CallbackGroupJoinType(enum.Enum): JOIN = "join" UNSURE = "unsure" ACCEPTED = "accepted" APPROVED = "approved" REQUEST = "request" class CallbackGroupLeave(Model): user_id: int self: "BaseBoolInt" class CallbackGroupMarket(enum.Enum): DISABLED = 0 OPEN = 1 class CallbackGroupOfficerRole(enum.Enum): NONE = 0 MODERATOR = 1 EDITOR = 2 ADMINISTRATOR = 3 class CallbackGroupOfficersEdit(Model): admin_id: int user_id: int level_old: "CallbackGroupOfficerRole" level_new: "CallbackGroupOfficerRole" class CallbackGroupSettingsChanges(Model): title: str description: str access: "GroupsGroupIsClosed" screen_name: str public_category: int public_subcategory: int age_limits: "GroupsGroupFullAgeLimits" website: str enable_status_default: "GroupsGroupWall" enable_audio: "GroupsGroupAudio" enable_video: "GroupsGroupVideo" enable_photo: "GroupsGroupPhotos" enable_market: "CallbackGroupMarket" class CallbackLikeAddRemove(Model): liker_id: int object_type: str object_owner_id: int object_id: int post_id: int thread_reply_id: Optional[int] = None class CallbackMarketComment(Model): id: int from_id: int date: int text: Optional[str] = None market_owner_od: Optional[int] = None photo_id: Optional[int] = None class CallbackMarketCommentDelete(Model): owner_id: int id: int user_id: int item_id: int class CallbackMessageAllow(Model): user_id: int key: str class CallbackMessageBase(Model): type: "CallbackMessageType" object: Dict[Any, Any] group_id: int class CallbackMessageDeny(Model): user_id: int class CallbackMessageType(enum.Enum): CONFIRMATION = "confirmation" GROUP_CHANGE_PHOTO = "group_change_photo" GROUP_CHANGE_SETTINGS = "group_change_settings" GROUP_OFFICERS_EDIT = "group_officers_edit" LEAD_FORMS_NEW = "lead_forms_new" MARKET_COMMENT_DELETE = "market_comment_delete" MARKET_COMMENT_EDIT = "market_comment_edit" MARKET_COMMENT_RESTORE = "market_comment_restore" MESSAGE_ALLOW = "message_allow" MESSAGE_DENY = "message_deny" MESSAGE_READ = "message_read" MESSAGE_REPLY = "message_reply" MESSAGE_TYPING_STATE = "message_typing_state" MESSAGES_EDIT = "messages_edit" PHOTO_COMMENT_DELETE = "photo_comment_delete" PHOTO_COMMENT_EDIT = "photo_comment_edit" PHOTO_COMMENT_RESTORE = "photo_comment_restore" POLL_VOTE_NEW = "poll_vote_new" USER_BLOCK = "user_block" USER_UNBLOCK = "user_unblock" VIDEO_COMMENT_DELETE = "video_comment_delete" VIDEO_COMMENT_EDIT = "video_comment_edit" VIDEO_COMMENT_RESTORE = "video_comment_restore" WALL_REPLY_DELETE = "wall_reply_delete" WALL_REPLY_RESTORE = "wall_reply_restore" WALL_REPOST = "wall_repost" class CallbackPhotoComment(Model): id: int from_id: int date: int text: str photo_owner_od: int class CallbackPhotoCommentDelete(Model): id: int owner_id: int user_id: int photo_id: int class CallbackPollVoteNew(Model): owner_id: int poll_id: int option_id: int user_id: int class CallbackQrScan(Model): user_id: int data: str type: str subtype: str reread: bool class CallbackUserBlock(Model): admin_id: int user_id: int unblock_date: int reason: int comment: Optional[str] = None class CallbackUserUnblock(Model): admin_id: int user_id: int by_end_date: int class CallbackVideoComment(Model): id: int from_id: int date: int text: str video_owner_od: int class CallbackVideoCommentDelete(Model): id: int owner_id: int user_id: int video_id: int class CallbackWallCommentDelete(Model): owner_id: int id: int user_id: int post_id: int class CommentThread(Model): can_post: Optional[bool] = None count: int groups_can_post: Optional[bool] = None items: Optional[List['WallWallComment']] = None show_reply_button: Optional[bool] = None class DatabaseCity(Model): ... class DatabaseFaculty(Model): id: int title: str class DatabaseRegion(Model): id: int title: str class DatabaseSchool(Model): id: int title: str class DatabaseStation(Model): city_id: Optional[int] = None color: Optional[str] = None id: int name: str class DatabaseUniversity(Model): id: int title: str class DocsDoc(Model): id: int owner_id: int title: str size: int ext: str url: Optional[str] = None date: int type: int preview: Optional["DocsDocPreview"] = None is_licensed: Optional["BaseBoolInt"] = None access_key: Optional[str] = None tags: Optional[List[str]] = None class DocsDocAttachmentType(enum.Enum): DOC = "doc" GRAFFITI = "graffiti" AUDIO_MESSAGE = "audio_message" class DocsDocPreview(Model): audio_msg: "DocsDocPreviewAudioMsg" graffiti: "DocsDocPreviewGraffiti" photo: "DocsDocPreviewPhoto" video: "DocsDocPreviewVideo" class DocsDocPreviewAudioMsg(Model): duration: int link_mp3: str link_ogg: str waveform: List[int] class DocsDocPreviewGraffiti(Model): src: str width: int height: int class DocsDocPreviewPhoto(Model): sizes: List['DocsDocPreviewPhotoSizes'] class DocsDocPreviewPhotoSizes(Model): src: str width: int height: int type: "PhotosPhotoSizesType" class DocsDocPreviewVideo(Model): src: str width: int height: int file_size: int class DocsDocTypes(Model): id: int name: str count: int class DocsDocUploadResponse(Model): file: str class EventsEventAttach(Model): address: Optional[str] = None button_text: str friends: List[int] id: int is_favorite: bool member_status: Optional["GroupsGroupFullMemberStatus"] = None text: str time: Optional[int] = None class FaveBookmark(Model): added_date: int link: Optional["BaseLink"] = None post: Optional["WallWallpostFull"] = None product: Optional["MarketMarketItem"] = None seen: bool tags: List['FaveTag'] type: "FaveBookmarkType" video: Optional["VideoVideo"] = None class FaveBookmarkType(enum.Enum): POST = "post" VIDEO = "video" PRODUCT = "product" ARTICLE = "article" LINK = "link" class FavePage(Model): description: str group: Optional["GroupsGroupFull"] = None tags: List['FaveTag'] type: "FavePageType" updated_date: Optional[int] = None user: Optional["UsersUserFull"] = None class FavePageType(enum.Enum): USER = "user" GROUP = "group" HINTS = "hints" class FaveTag(Model): id: int name: str class FriendsFriendExtendedStatus(Model): ... class FriendsFriendStatus(Model): friend_status: "FriendsFriendStatusStatus" sign: Optional[str] = None user_id: int class FriendsFriendStatusStatus(enum.Enum): NOT_A_FRIEND = 0 OUTCOMING_REQUEST = 1 INCOMING_REQUEST = 2 IS_FRIEND = 3 class FriendsFriendsList(Model): id: int name: str class FriendsMutualFriend(Model): common_count: int common_friends: List[int] id: int class FriendsRequests(Model): from_: str mutual: "FriendsRequestsMutual" user_id: int class FriendsRequestsMutual(Model): count: int users: List[int] class FriendsRequestsXtrMessage(Model): from_: str message: str mutual: "FriendsRequestsMutual" user_id: int class FriendsUserXtrLists(Model): ... class FriendsUserXtrPhone(Model): ... class GiftsGift(Model): date: int from_id: int gift: "GiftsLayout" gift_hash: str id: int message: str privacy: "GiftsGiftPrivacy" class GiftsGiftPrivacy(enum.Enum): NAME_AND_MESSAGE_FOR_ALL = 0 NAME_FOR_ALL = 1 NAME_AND_MESSAGE_FOR_RECIPIENT_ONLY = 2 class GiftsLayout(Model): id: int thumb_512: str thumb_256: str thumb_48: str thumb_96: str stickers_product_id: int build_id: str keywords: str class GroupsAddress(Model): additional_address: Optional[str] = None address: Optional[str] = None city_id: Optional[int] = None country_id: Optional[int] = None distance: Optional[int] = None id: int latitude: Optional[float] = None longitude: Optional[float] = None metro_station_id: Optional[int] = None phone: Optional[str] = None time_offset: Optional[int] = None timetable: Optional["GroupsAddressTimetable"] = None title: Optional[str] = None work_info_status: Optional["GroupsAddressWorkInfoStatus"] = None class GroupsAddressTimetable(Model): fri: "GroupsAddressTimetableDay" mon: "GroupsAddressTimetableDay" sat: "GroupsAddressTimetableDay" sun: "GroupsAddressTimetableDay" thu: "GroupsAddressTimetableDay" tue: "GroupsAddressTimetableDay" wed: "GroupsAddressTimetableDay" class GroupsAddressTimetableDay(Model): break_close_time: Optional[int] = None break_open_time: Optional[int] = None close_time: int open_time: int class GroupsAddressWorkInfoStatus(enum.Enum): NO_INFORMATION = "no_information" TEMPORARILY_CLOSED = "temporarily_closed" ALWAYS_OPENED = "always_opened" TIMETABLE = "timetable" FOREVER_CLOSED = "forever_closed" class GroupsAddressesInfo(Model): is_enabled: bool main_address_id: Optional[int] = None class GroupsBanInfo(Model): admin_id: int comment: str comment_visible: bool is_closed: bool date: int end_date: int reason: "GroupsBanInfoReason" class GroupsBanInfoReason(enum.Enum): OTHER = 0 SPAM = 1 VERBAL_ABUSE = 2 STRONG_LANGUAGE = 3 FLOOD = 4 class GroupsBannedItem(Model): ... class GroupsCallbackServer(Model): id: int title: str creator_id: int url: str secret_key: str status: str class GroupsCallbackSettings(Model): api_version: str events: "GroupsLongPollEvents" class GroupsContactsItem(Model): desc: str email: str phone: str user_id: int class GroupsCountersGroup(Model): addresses: int albums: int audios: int audio_playlists: int docs: int market: int photos: int topics: int videos: int class GroupsCover(Model): enabled: "BaseBoolInt" images: Optional[List['BaseImage']] = None class GroupsFields(enum.Enum): MARKET = "market" MEMBER_STATUS = "member_status" IS_FAVORITE = "is_favorite" IS_SUBSCRIBED = "is_subscribed" CITY = "city" COUNTRY = "country" VERIFIED = "verified" DESCRIPTION = "description" WIKI_PAGE = "wiki_page" MEMBERS_COUNT = "members_count" COUNTERS = "counters" COVER = "cover" CAN_POST = "can_post" CAN_SEE_ALL_POSTS = "can_see_all_posts" ACTIVITY = "activity" FIXED_POST = "fixed_post" CAN_CREATE_TOPIC = "can_create_topic" CAN_UPLOAD_VIDEO = "can_upload_video" HAS_PHOTO = "has_photo" STATUS = "status" MAIN_ALBUM_ID = "main_album_id" LINKS = "links" CONTACTS = "contacts" SITE = "site" MAIN_SECTION = "main_section" TRENDING = "trending" CAN_MESSAGE = "can_message" IS_MARKET_CART_ENABLED = "is_market_cart_enabled" IS_MESSAGES_BLOCKED = "is_messages_blocked" CAN_SEND_NOTIFY = "can_send_notify" ONLINE_STATUS = "online_status" START_DATE = "start_date" FINISH_DATE = "finish_date" AGE_LIMITS = "age_limits" BAN_INFO = "ban_info" ACTION_BUTTON = "action_button" AUTHOR_ID = "author_id" PHONE = "phone" HAS_MARKET_APP = "has_market_app" ADDRESSES = "addresses" LIVE_COVERS = "live_covers" IS_ADULT = "is_adult" CAN_SUBSCRIBE_POSTS = "can_subscribe_posts" WARNING_NOTIFICATION = "warning_notification" MSG_PUSH_ALLOWED = "msg_push_allowed" STORIES_ARCHIVE_COUNT = "stories_archive_count" VIDEO_LIVE_LEVEL = "video_live_level" VIDEO_LIVE_COUNT = "video_live_count" CLIPS_COUNT = "clips_count" class GroupsFilter(enum.Enum): ADMIN = "admin" EDITOR = "editor" MODER = "moder" ADVERTISER = "advertiser" GROUPS = "groups" PUBLICS = "publics" EVENTS = "events" HAS_ADDRESSES = "has_addresses" class GroupsGroup(Model): admin_level: "GroupsGroupAdminLevel" deactivated: str finish_date: int id: int is_admin: "BaseBoolInt" is_advertiser: "BaseBoolInt" is_closed: "GroupsGroupIsClosed" is_member: "BaseBoolInt" name: str photo_100: str photo_200: str photo_50: str screen_name: str start_date: int type: "GroupsGroupType" class GroupsGroupAccess(enum.Enum): OPEN = 0 CLOSED = 1 PRIVATE = 2 class GroupsGroupAdminLevel(enum.Enum): MODERATOR = 1 EDITOR = 2 ADMINISTRATOR = 3 class GroupsGroupAgeLimits(enum.Enum): UNLIMITED = 1 _16_PLUS = 2 _18_PLUS = 3 class GroupsGroupAttach(Model): id: int text: str status: str size: int is_favorite: bool class GroupsGroupAudio(enum.Enum): DISABLED = 0 OPEN = 1 LIMITED = 2 class GroupsGroupBanInfo(Model): comment: str end_date: int reason: "GroupsBanInfoReason" class GroupsGroupCategory(Model): id: int name: str subcategories: Optional[List['BaseObjectWithName']] = None class GroupsGroupCategoryFull(Model): id: int name: str page_count: int page_previews: List['GroupsGroup'] subcategories: Optional[List['GroupsGroupCategory']] = None class GroupsGroupCategoryType(Model): id: int name: str class GroupsGroupDocs(enum.Enum): DISABLED = 0 OPEN = 1 LIMITED = 2 class GroupsGroupFull(Model): ... class GroupsGroupFullAgeLimits(enum.Enum): NO = 1 OVER_16 = 2 OVER_18 = 3 class GroupsGroupFullMainSection(enum.Enum): ABSENT = 0 PHOTOS = 1 TOPICS = 2 AUDIO = 3 VIDEO = 4 MARKET = 5 class GroupsGroupFullMemberStatus(enum.Enum): NOT_A_MEMBER = 0 MEMBER = 1 NOT_SURE = 2 DECLINED = 3 HAS_SENT_A_REQUEST = 4 INVITED = 5 class GroupsGroupIsClosed(enum.Enum): OPEN = 0 CLOSED = 1 PRIVATE = 2 class GroupsGroupLink(Model): name: str desc: str edit_title: "BaseBoolInt" id: int image_processing: "BaseBoolInt" url: str class GroupsGroupMarketCurrency(enum.Enum): RUSSIAN_RUBLES = 643 UKRAINIAN_HRYVNIA = 980 KAZAKH_TENGE = 398 EURO = 978 US_DOLLARS = 840 class GroupsGroupPhotos(enum.Enum): DISABLED = 0 OPEN = 1 LIMITED = 2 class GroupsGroupPublicCategoryList(Model): id: int name: str subcategories: List['GroupsGroupCategoryType'] class GroupsGroupRole(enum.Enum): MODERATOR = "moderator" EDITOR = "editor" ADMINISTRATOR = "administrator" ADVERTISER = "advertiser" class GroupsGroupSubject(enum.Enum): AUTO = 1 ACTIVITY_HOLIDAYS = 2 BUSINESS = 3 PETS = 4 HEALTH = 5 DATING_AND_COMMUNICATION = 6 GAMES = 7 IT = 8 CINEMA = 9 BEAUTY_AND_FASHION = 10 COOKING = 11 ART_AND_CULTURE = 12 LITERATURE = 13 MOBILE_SERVICES_AND_INTERNET = 14 MUSIC = 15 SCIENCE_AND_TECHNOLOGY = 16 REAL_ESTATE = 17 NEWS_AND_MEDIA = 18 SECURITY = 19 EDUCATION = 20 HOME_AND_RENOVATIONS = 21 POLITICS = 22 FOOD = 23 INDUSTRY = 24 TRAVEL = 25 WORK = 26 ENTERTAINMENT = 27 RELIGION = 28 FAMILY = 29 SPORTS = 30 INSURANCE = 31 TELEVISION = 32 GOODS_AND_SERVICES = 33 HOBBIES = 34 FINANCE = 35 PHOTO = 36 ESOTERICS = 37 ELECTRONICS_AND_APPLIANCES = 38 EROTIC = 39 HUMOR = 40 SOCIETY_HUMANITIES = 41 DESIGN_AND_GRAPHICS = 42 class GroupsGroupTopics(enum.Enum): DISABLED = 0 OPEN = 1 LIMITED = 2 class GroupsGroupType(enum.Enum): GROUP = "group" PAGE = "page" EVENT = "event" class GroupsGroupVideo(enum.Enum): DISABLED = 0 OPEN = 1 LIMITED = 2 class GroupsGroupWall(enum.Enum): DISABLED = 0 OPEN = 1 LIMITED = 2 CLOSED = 3 class GroupsGroupWiki(enum.Enum): DISABLED = 0 OPEN = 1 LIMITED = 2 class GroupsGroupXtrInvitedBy(Model): admin_level: "GroupsGroupXtrInvitedByAdminLevel" id: int invited_by: int is_admin: "BaseBoolInt" is_advertiser: "BaseBoolInt" is_closed: "BaseBoolInt" is_member: "BaseBoolInt" name: str photo_100: str photo_200: str photo_50: str screen_name: str type: "GroupsGroupXtrInvitedByType" class GroupsGroupXtrInvitedByAdminLevel(enum.Enum): MODERATOR = 1 EDITOR = 2 ADMINISTRATOR = 3 class GroupsGroupXtrInvitedByType(enum.Enum): GROUP = "group" PAGE = "page" EVENT = "event" class GroupsGroupsArray(Model): count: int items: List[int] class GroupsLinksItem(Model): desc: str edit_title: "BaseBoolInt" id: int name: str photo_100: str photo_50: str url: str class GroupsLiveCovers(Model): is_enabled: bool is_scalable: Optional[bool] = None story_ids: Optional[List[str]] = None class GroupsLongPollEvents(Model): audio_new: "BaseBoolInt" board_post_delete: "BaseBoolInt" board_post_edit: "BaseBoolInt" board_post_new: "BaseBoolInt" board_post_restore: "BaseBoolInt" group_change_photo: "BaseBoolInt" group_change_settings: "BaseBoolInt" group_join: "BaseBoolInt" group_leave: "BaseBoolInt" group_officers_edit: "BaseBoolInt" lead_forms_new: Optional["BaseBoolInt"] = None market_comment_delete: "BaseBoolInt" market_comment_edit: "BaseBoolInt" market_comment_new: "BaseBoolInt" market_comment_restore: "BaseBoolInt" message_allow: "BaseBoolInt" message_deny: "BaseBoolInt" message_new: "BaseBoolInt" message_read: "BaseBoolInt" message_reply: "BaseBoolInt" message_typing_state: "BaseBoolInt" message_edit: "BaseBoolInt" photo_comment_delete: "BaseBoolInt" photo_comment_edit: "BaseBoolInt" photo_comment_new: "BaseBoolInt" photo_comment_restore: "BaseBoolInt" photo_new: "BaseBoolInt" poll_vote_new: "BaseBoolInt" user_block: "BaseBoolInt" user_unblock: "BaseBoolInt" video_comment_delete: "BaseBoolInt" video_comment_edit: "BaseBoolInt" video_comment_new: "BaseBoolInt" video_comment_restore: "BaseBoolInt" video_new: "BaseBoolInt" wall_post_new: "BaseBoolInt" wall_reply_delete: "BaseBoolInt" wall_reply_edit: "BaseBoolInt" wall_reply_new: "BaseBoolInt" wall_reply_restore: "BaseBoolInt" wall_repost: "BaseBoolInt" class GroupsLongPollServer(Model): key: str server: str ts: str class GroupsLongPollSettings(Model): api_version: Optional[str] = None events: "GroupsLongPollEvents" is_enabled: bool class GroupsMarketInfo(Model): contact_id: int currency: "MarketCurrency" currency_text: str enabled: "BaseBoolInt" main_album_id: int price_max: str price_min: str class GroupsMemberRole(Model): id: int permissions: List['GroupsMemberRolePermission'] role: "GroupsMemberRoleStatus" class GroupsMemberRolePermission(enum.Enum): ADS = "ads" class GroupsMemberRoleStatus(enum.Enum): MODERATOR = "moderator" EDITOR = "editor" ADMINISTRATOR = "administrator" CREATOR = "creator" class GroupsMemberStatus(Model): member: "BaseBoolInt" user_id: int class GroupsMemberStatusFull(Model): can_invite: Optional["BaseBoolInt"] = None can_recall: Optional["BaseBoolInt"] = None invitation: Optional["BaseBoolInt"] = None member: "BaseBoolInt" request: Optional["BaseBoolInt"] = None user_id: int class GroupsOnlineStatus(Model): minutes: Optional[int] = None status: "GroupsOnlineStatusType" class GroupsOnlineStatusType(enum.Enum): NONE = "none" ONLINE = "online" ANSWER_MARK = "answer_mark" class GroupsOwnerXtrBanInfo(Model): ban_info: "GroupsBanInfo" group: "GroupsGroup" profile: "UsersUser" type: "GroupsOwnerXtrBanInfoType" class GroupsOwnerXtrBanInfoType(enum.Enum): GROUP = "group" PROFILE = "profile" class GroupsRoleOptions(enum.Enum): MODERATOR = "moderator" EDITOR = "editor" ADMINISTRATOR = "administrator" CREATOR = "creator" class GroupsSettingsTwitter(Model): status: str name: Optional[str] = None class GroupsSubjectItem(Model): id: int name: str class GroupsTokenPermissionSetting(Model): name: str setting: int class GroupsUserXtrRole(Model): ... class LeadsChecked(Model): reason: str result: "LeadsCheckedResult" sid: str start_link: str class LeadsCheckedResult(enum.Enum): TRUE = "true" FALSE = "false" class LeadsComplete(Model): cost: int limit: int spent: int success: int test_mode: "BaseBoolInt" class LeadsEntry(Model): aid: int comment: str date: int sid: str start_date: int status: int test_mode: "BaseBoolInt" uid: int class LeadsLead(Model): completed: int cost: int days: "LeadsLeadDays" impressions: int limit: int spent: int started: int class LeadsLeadDays(Model): completed: int impressions: int spent: int started: int class LeadsStart(Model): test_mode: "BaseBoolInt" vk_sid: str class LikesType(enum.Enum): POST = "post" COMMENT = "comment" PHOTO = "photo" AUDIO = "audio" VIDEO = "video" NOTE = "note" MARKET = "market" PHOTO_COMMENT = "photo_comment" VIDEO_COMMENT = "video_comment" TOPIC_COMMENT = "topic_comment" MARKET_COMMENT = "market_comment" SITEPAGE = "sitepage" class LinkTargetObject(Model): type: str owner_id: int item_id: int class MarketCurrency(Model): id: int name: str class MarketMarketAlbum(Model): count: int id: int owner_id: int photo: Optional["PhotosPhoto"] = None title: str updated_time: int class MarketMarketCategory(Model): id: int name: str section: "MarketSection" class MarketMarketItem(Model): access_key: Optional[str] = None availability: "MarketMarketItemAvailability" button_title: Optional[str] = None category: "MarketMarketCategory" date: Optional[int] = None description: str external_id: Optional[str] = None id: int is_favorite: Optional[bool] = None owner_id: int price: "MarketPrice" thumb_photo: str title: str url: Optional[str] = None variants_grouping_id: Optional[int] = None is_main_variant: Optional[bool] = None class MarketMarketItemAvailability(enum.Enum): AVAILABLE = 0 REMOVED = 1 UNAVAILABLE = 2 class MarketMarketItemFull(Model): ... class MarketPrice(Model): amount: str currency: "MarketCurrency" discount_rate: int old_amount: str text: str class MarketSection(Model): id: int name: str class MediaRestriction(Model): text: Optional[str] = None title: str button: Optional["VideoRestrictionButton"] = None always_shown: Optional["BaseBoolInt"] = None blur: Optional["BaseBoolInt"] = None can_play: Optional["BaseBoolInt"] = None can_preview: Optional["BaseBoolInt"] = None card_icon: Optional[List['BaseImage']] = None list_icon: Optional[List['BaseImage']] = None class MessageChatPreview(Model): admin_id: int joined: bool local_id: int members: List[int] members_count: int title: str class MessagesAudioMessage(Model): access_key: Optional[str] = None duration: int id: int link_mp3: str link_ogg: str owner_id: int waveform: List[int] class MessagesChat(Model): admin_id: int id: int kicked: Optional["BaseBoolInt"] = None left: Optional["BaseBoolInt"] = None photo_100: Optional[str] = None photo_200: Optional[str] = None photo_50: Optional[str] = None push_settings: Optional["MessagesChatPushSettings"] = None title: Optional[str] = None type: str users: List[int] is_default_photo: Optional[bool] = None class MessagesChatFull(Model): admin_id: int id: int kicked: Optional["BaseBoolInt"] = None left: Optional["BaseBoolInt"] = None photo_100: Optional[str] = None photo_200: Optional[str] = None photo_50: Optional[str] = None push_settings: Optional["MessagesChatPushSettings"] = None title: Optional[str] = None type: str users: List['MessagesUserXtrInvitedBy'] class MessagesChatPushSettings(Model): disabled_until: int sound: "BaseBoolInt" class MessagesChatRestrictions(Model): admins_promote_users: bool only_admins_edit_info: bool only_admins_edit_pin: bool only_admins_invite: bool only_admins_kick: bool class MessagesConversation(Model): peer: "MessagesConversationPeer" last_message_id: int in_read: int out_read: int unread_count: Optional[int] = None is_marked_unread: Optional[bool] = None important: Optional[bool] = None unanswered: Optional[bool] = None special_service_type: Optional[str] = None message_request_data: Optional["MessagesMessageRequestData"] = None mentions: Optional[List[int]] = None current_keyboard: Optional["MessagesKeyboard"] = None class MessagesConversationMember(Model): can_kick: Optional[bool] = None invited_by: Optional[int] = None is_admin: Optional[bool] = None is_owner: Optional[bool] = None is_message_request: Optional[bool] = None join_date: Optional[int] = None request_date: Optional[int] = None member_id: int class MessagesConversationPeer(Model): id: int local_id: Optional[int] = None type: "MessagesConversationPeerType" class MessagesConversationPeerType(enum.Enum): CHAT = "chat" EMAIL = "email" USER = "user" GROUP = "group" class MessagesConversationWithMessage(Model): conversation: "MessagesConversation" last_message: "MessagesMessage" class MessagesForeignMessage(Model): attachments: Optional[List['MessagesMessageAttachment']] = None conversation_message_id: Optional[int] = None date: int from_id: int fwd_messages: Optional[List['MessagesForeignMessage']] = None geo: Optional["BaseGeo"] = None id: Optional[int] = None peer_id: Optional[int] = None reply_message: Optional["MessagesForeignMessage"] = None text: str update_time: Optional[int] = None was_listened: Optional[bool] = None payload: Optional[str] = None class MessagesGraffiti(Model): access_key: Optional[str] = None height: int id: int owner_id: int url: str width: int class MessagesHistoryAttachment(Model): attachment: "MessagesHistoryMessageAttachment" message_id: int from_id: int class MessagesHistoryMessageAttachment(Model): audio: Optional["AudioAudio"] = None audio_message: Optional["MessagesAudioMessage"] = None doc: Optional["DocsDoc"] = None graffiti: Optional["MessagesGraffiti"] = None link: Optional["BaseLink"] = None market: Optional["BaseLink"] = None photo: Optional["PhotosPhoto"] = None share: Optional["BaseLink"] = None type: "MessagesHistoryMessageAttachmentType" video: Optional["VideoVideo"] = None wall: Optional["BaseLink"] = None class MessagesHistoryMessageAttachmentType(enum.Enum): PHOTO = "photo" VIDEO = "video" AUDIO = "audio" DOC = "doc" LINK = "link" MARKET = "market" WALL = "wall" SHARE = "share" GRAFFITI = "graffiti" AUDIO_MESSAGE = "audio_message" class MessagesKeyboard(Model): author_id: Optional[int] = None buttons: List[list] one_time: bool inline: Optional[bool] = None class MessagesKeyboardButton(Model): action: "MessagesKeyboardButtonAction" color: Optional[str] = None class MessagesKeyboardButtonAction(Model): app_id: Optional[int] = None hash: Optional[str] = None label: Optional[str] = None link: Optional[str] = None owner_id: Optional[int] = None payload: Optional[str] = None type: "MessagesTemplateActionTypeNames" class MessagesLastActivity(Model): online: "BaseBoolInt" time: int class MessagesLongpollMessages(Model): count: int items: List['MessagesMessage'] class MessagesLongpollParams(Model): key: str pts: int server: str ts: str class MessagesMessage(Model): action: Optional["MessagesMessageAction"] = None admin_author_id: Optional[int] = None attachments: Optional[List['MessagesMessageAttachment']] = None conversation_message_id: Optional[int] = None date: int deleted: Optional["BaseBoolInt"] = None from_id: int fwd_messages: Optional[List['MessagesForeignMessage']] = None geo: Optional["BaseGeo"] = None id: int important: Optional[bool] = None is_hidden: Optional[bool] = None is_cropped: Optional[bool] = None keyboard: Optional["MessagesKeyboard"] = None members_count: Optional[int] = None out: "BaseBoolInt" payload: Optional[Json] = None peer_id: int random_id: Optional[int] = None ref: Optional[str] = None ref_source: Optional[str] = None reply_message: Optional["MessagesForeignMessage"] = None text: str update_time: Optional[int] = None was_listened: Optional[bool] = None pinned_at: Optional[int] = None class MessagesMessageAction(Model): conversation_message_id: Optional[int] = None email: Optional[str] = None member_id: Optional[int] = None message: Optional[str] = None photo: Optional["MessagesMessageActionPhoto"] = None text: Optional[str] = None type: "MessagesMessageActionStatus" class MessagesMessageActionPhoto(Model): photo_100: str photo_200: str photo_50: str class MessagesMessageActionStatus(enum.Enum): CHAT_PHOTO_UPDATE = "chat_photo_update" CHAT_PHOTO_REMOVE = "chat_photo_remove" CHAT_CREATE = "chat_create" CHAT_TITLE_UPDATE = "chat_title_update" CHAT_INVITE_USER = "chat_invite_user" CHAT_KICK_USER = "chat_kick_user" CHAT_PIN_MESSAGE = "chat_pin_message" CHAT_UNPIN_MESSAGE = "chat_unpin_message" CHAT_INVITE_USER_BY_LINK = "chat_invite_user_by_link" class MessagesMessageAttachment(Model): audio: Optional["AudioAudio"] = None audio_message: Optional["MessagesAudioMessage"] = None doc: Optional["DocsDoc"] = None gift: Optional["GiftsLayout"] = None graffiti: Optional["MessagesGraffiti"] = None link: Optional["BaseLink"] = None market: Optional["MarketMarketItem"] = None market_market_album: Optional["MarketMarketAlbum"] = None photo: Optional["PhotosPhoto"] = None sticker: Optional["BaseSticker"] = None story: Optional["StoriesStory"] = None type: "MessagesMessageAttachmentType" video: Optional["VideoVideo"] = None wall: Optional["WallWallpostFull"] = None wall_reply: Optional["WallWallComment"] = None class MessagesMessageAttachmentType(enum.Enum): PHOTO = "photo" AUDIO = "audio" VIDEO = "video" DOC = "doc" LINK = "link" MARKET = "market" MARKET_ALBUM = "market_album" GIFT = "gift" STICKER = "sticker" WALL = "wall" WALL_REPLY = "wall_reply" ARTICLE = "article" GRAFFITI = "graffiti" AUDIO_MESSAGE = "audio_message" class MessagesMessageRequestData(Model): status: str inviter_id: int request_date: int class MessagesPinnedMessage(Model): attachments: Optional[List['MessagesMessageAttachment']] = None conversation_message_id: Optional[int] = None date: int from_id: int fwd_messages: Optional[List['MessagesForeignMessage']] = None geo: Optional["BaseGeo"] = None id: int peer_id: int reply_message: Optional["MessagesForeignMessage"] = None text: str keyboard: Optional["MessagesKeyboard"] = None class MessagesTemplateActionTypeNames(enum.Enum): TEXT = "text" START = "start" LOCATION = "location" VKPAY = "vkpay" OPEN_APP = "open_app" OPEN_PHOTO = "open_photo" OPEN_LINK = "open_link" class MessagesUserXtrInvitedBy(Model): ... class NewsfeedCommentsFilters(enum.Enum): POST = "post" PHOTO = "photo" VIDEO = "video" TOPIC = "topic" NOTE = "note" class NewsfeedEventActivity(Model): address: Optional[str] = None button_text: str friends: List[int] member_status: "GroupsGroupFullMemberStatus" text: str time: Optional[int] = None class NewsfeedFilters(enum.Enum): POST = "post" PHOTO = "photo" PHOTO_TAG = "photo_tag" WALL_PHOTO = "wall_photo" FRIEND = "friend" RECOMMENDED_GROUPS = "recommended_groups" NOTE = "note" AUDIO = "audio" VIDEO = "video" AUDIO_PLAYLIST = "audio_playlist" CLIP = "clip" class NewsfeedIgnoreItemType(enum.Enum): POST_ON_THE_WALL = 'wall' TAG_ON_A_PHOTO = 'tag' PROFILE_PHOTO = 'profilephoto' VIDEO = 'video' PHOTO = 'photo' AUDIO = 'audio' class NewsfeedItemAudio(Model): ... class NewsfeedItemAudioAudio(Model): count: int items: List['AudioAudio'] class NewsfeedItemBase(Model): type: "NewsfeedNewsfeedItemType" source_id: int date: int class NewsfeedItemDigest(Model): ... class NewsfeedItemFriend(Model): ... class NewsfeedItemFriendFriends(Model): count: int items: List['BaseUserId'] class NewsfeedItemHolidayRecommendationsBlockHeader(Model): title: str subtitle: str image: List['BaseImage'] action: "BaseLinkButtonAction" class NewsfeedItemNote(Model): ... class NewsfeedItemNoteNotes(Model): count: int items: List['NewsfeedNewsfeedNote'] class NewsfeedItemPhoto(Model): ... class NewsfeedItemPhotoPhotos(Model): count: int items: List['NewsfeedNewsfeedPhoto'] class NewsfeedItemPhotoTag(Model): ... class NewsfeedItemPhotoTagPhotoTags(Model): count: int items: List['NewsfeedNewsfeedPhoto'] class NewsfeedItemPromoButton(Model): ... class NewsfeedItemPromoButtonAction(Model): url: str type: str target: str class NewsfeedItemPromoButtonImage(Model): width: int height: int url: str class NewsfeedItemTopic(Model): ... class NewsfeedItemVideo(Model): ... class NewsfeedItemVideoVideo(Model): count: int items: List['VideoVideo'] class NewsfeedItemWallpost(Model): ... class NewsfeedItemWallpostFeedback(Model): type: "NewsfeedItemWallpostFeedbackType" question: str answers: Optional[List['NewsfeedItemWallpostFeedbackAnswer']] = None stars_count: Optional[int] = None gratitude: Optional[str] = None class NewsfeedItemWallpostFeedbackAnswer(Model): title: str id: str class NewsfeedItemWallpostFeedbackType(enum.Enum): BUTTONS = "buttons" STARS = "stars" class NewsfeedItemWallpostType(enum.Enum): POST = "post" COPY = "copy" REPLY = "reply" class NewsfeedList(Model): id: int title: str class NewsfeedListFull(Model): ... class NewsfeedNewsfeedItem(Model): ... class NewsfeedNewsfeedItemType(enum.Enum): POST = "post" PHOTO = "photo" PHOTO_TAG = "photo_tag" WALL_PHOTO = "wall_photo" FRIEND = "friend" NOTE = "note" AUDIO = "audio" VIDEO = "video" TOPIC = "topic" DIGEST = "digest" STORIES = "stories" TAGS_SUGGESTIONS = "tags_suggestions" class NewsfeedNewsfeedNote(Model): comments: int id: int owner_id: int title: str class NewsfeedNewsfeedPhoto(Model): ... class NotesNote(Model): read_comments: Optional[int] = None can_comment: Optional["BaseBoolInt"] = None comments: int date: int id: int owner_id: int text: Optional[str] = None text_wiki: Optional[str] = None title: str view_url: str class NotesNoteComment(Model): date: int id: int message: str nid: int oid: int reply_to: Optional[int] = None uid: int class NotificationsFeedback(Model): attachments: List['WallWallpostAttachment'] from_id: int geo: "BaseGeo" id: int likes: "BaseLikesInfo" text: str to_id: int class NotificationsNotification(Model): date: int feedback: "NotificationsFeedback" parent: "NotificationsNotificationParent" reply: "NotificationsReply" type: str class NotificationsNotificationItem(Model): ... class NotificationsNotificationParent(Model): ... class NotificationsNotificationsComment(Model): date: int id: int owner_id: int photo: "PhotosPhoto" post: "WallWallpost" text: str topic: "BoardTopic" video: "VideoVideo" class NotificationsReply(Model): date: int id: int text: int class NotificationsSendMessageError(Model): code: int description: str class NotificationsSendMessageItem(Model): user_id: int status: bool error: "NotificationsSendMessageError" class OauthError(Model): error: str error_description: str redirect_uri: Optional[str] = None class OrdersAmount(Model): amounts: List['OrdersAmountItem'] currency: str class OrdersAmountItem(Model): amount: int description: str votes: str class OrdersOrder(Model): amount: int app_order_id: int cancel_transaction_id: int date: int id: int item: str receiver_id: int status: str transaction_id: int user_id: int class OrdersSubscription(Model): cancel_reason: Optional[str] = None create_time: int id: int item_id: str next_bill_time: Optional[int] = None pending_cancel: Optional[bool] = None period: int period_start_time: int price: int status: str test_mode: Optional[bool] = None trial_expire_time: Optional[int] = None update_time: int class OwnerState(Model): state: int description: str class PagesPrivacySettings(enum.Enum): COMMUNITY_MANAGERS_ONLY = 0 COMMUNITY_MEMBERS_ONLY = 1 EVERYONE = 2 class PagesWikipage(Model): creator_id: Optional[int] = None creator_name: Optional[int] = None editor_id: Optional[int] = None editor_name: Optional[str] = None group_id: int id: int title: str views: int who_can_edit: "PagesPrivacySettings" who_can_view: "PagesPrivacySettings" class PagesWikipageFull(Model): created: int creator_id: Optional[int] = None current_user_can_edit: Optional["BaseBoolInt"] = None current_user_can_edit_access: Optional["BaseBoolInt"] = None edited: int editor_id: Optional[int] = None group_id: int html: Optional[str] = None id: int source: Optional[str] = None title: str view_url: str views: int who_can_edit: "PagesPrivacySettings" who_can_view: "PagesPrivacySettings" class PagesWikipageHistory(Model): id: int length: int date: int editor_id: int editor_name: str class PhotosCommentXtrPid(Model): attachments: Optional[List['WallCommentAttachment']] = None date: int from_id: int id: int likes: Optional["BaseLikesInfo"] = None pid: int reply_to_comment: Optional[int] = None reply_to_user: Optional[int] = None text: str parents_stack: Optional[List[int]] = None thread: Optional["CommentThread"] = None class PhotosImage(Model): height: int type: "PhotosImageType" url: str width: int class PhotosImageType(enum.Enum): S = "s" M = "m" X = "x" L = "l" O = "o" P = "p" Q = "q" R = "r" Y = "y" Z = "z" W = "w" class PhotosMarketAlbumUploadResponse(Model): gid: int hash: str photo: str server: int class PhotosMarketUploadResponse(Model): crop_data: str crop_hash: str group_id: int hash: str photo: str server: int class PhotosMessageUploadResponse(Model): hash: str photo: str server: int class PhotosOwnerUploadResponse(Model): hash: str photo: str server: int class PhotosPhoto(Model): access_key: Optional[str] = None album_id: int date: int height: Optional[int] = None id: int images: Optional[List['PhotosImage']] = None lat: Optional[float] = None long: Optional[float] = None owner_id: int photo_256: Optional[str] = None can_comment: Optional["BaseBoolInt"] = None place: Optional[str] = None post_id: Optional[int] = None sizes: Optional[List['PhotosPhotoSizes']] = None text: Optional[str] = None user_id: Optional[int] = None width: Optional[int] = None has_tags: bool restrictions: Optional["MediaRestriction"] = None class PhotosPhotoAlbum(Model): created: int description: Optional[str] = None id: int owner_id: int size: int thumb: Optional["PhotosPhoto"] = None title: str updated: int class PhotosPhotoAlbumFull(Model): can_upload: Optional["BaseBoolInt"] = None comments_disabled: Optional["BaseBoolInt"] = None created: int description: Optional[str] = None id: int owner_id: int size: int sizes: Optional[List['PhotosPhotoSizes']] = None thumb_id: Optional[int] = None thumb_is_last: Optional["BaseBoolInt"] = None thumb_src: Optional[str] = None title: str updated: int upload_by_admins_only: Optional["BaseBoolInt"] = None class PhotosPhotoFull(Model): access_key: Optional[str] = None album_id: int can_comment: Optional["BaseBoolInt"] = None comments: Optional["BaseObjectCount"] = None date: int height: Optional[int] = None id: int images: Optional[List['PhotosImage']] = None lat: Optional[float] = None likes: Optional["BaseLikes"] = None long: Optional[float] = None owner_id: int post_id: Optional[int] = None reposts: Optional["BaseObjectCount"] = None tags: Optional["BaseObjectCount"] = None text: Optional[str] = None user_id: Optional[int] = None width: Optional[int] = None class PhotosPhotoFullXtrRealOffset(Model): access_key: Optional[str] = None album_id: int can_comment: Optional["BaseBoolInt"] = None comments: Optional["BaseObjectCount"] = None date: int height: Optional[int] = None hidden: Optional["BasePropertyExists"] = None id: int lat: Optional[float] = None likes: Optional["BaseLikes"] = None long: Optional[float] = None owner_id: int photo_1280: Optional[str] = None photo_130: Optional[str] = None photo_2560: Optional[str] = None photo_604: Optional[str] = None photo_75: Optional[str] = None photo_807: Optional[str] = None post_id: Optional[int] = None real_offset: Optional[int] = None reposts: Optional["BaseObjectCount"] = None sizes: Optional[List['PhotosPhotoSizes']] = None tags: Optional["BaseObjectCount"] = None text: Optional[str] = None user_id: Optional[int] = None width: Optional[int] = None class PhotosPhotoSizes(Model): height: int url: str src: Optional[str] = None type: "PhotosPhotoSizesType" width: int class PhotosPhotoSizesType(enum.Enum): S = "s" M = "m" X = "x" O = "o" P = "p" Q = "q" R = "r" K = "k" L = "l" Y = "y" Z = "z" C = "c" W = "w" class PhotosPhotoTag(Model): date: int id: int placer_id: int tagged_name: str user_id: int viewed: "BaseBoolInt" x: float x2: float y: float y2: float class PhotosPhotoUpload(Model): album_id: int upload_url: str fallback_upload_url: Optional[str] = None user_id: int group_id: Optional[int] = None class PhotosPhotoUploadResponse(Model): aid: int hash: str photos_list: str server: int class PhotosPhotoXtrRealOffset(Model): access_key: Optional[str] = None album_id: int date: int height: Optional[int] = None hidden: Optional["BasePropertyExists"] = None id: int lat: Optional[float] = None long: Optional[float] = None owner_id: int photo_1280: Optional[str] = None photo_130: Optional[str] = None photo_2560: Optional[str] = None photo_604: Optional[str] = None photo_75: Optional[str] = None photo_807: Optional[str] = None post_id: Optional[int] = None real_offset: Optional[int] = None sizes: Optional[List['PhotosPhotoSizes']] = None text: Optional[str] = None user_id: Optional[int] = None width: Optional[int] = None class PhotosPhotoXtrTagInfo(Model): access_key: Optional[str] = None album_id: int date: int height: Optional[int] = None id: int lat: Optional[float] = None long: Optional[float] = None owner_id: int photo_1280: Optional[str] = None photo_130: Optional[str] = None photo_2560: Optional[str] = None photo_604: Optional[str] = None photo_75: Optional[str] = None photo_807: Optional[str] = None placer_id: Optional[int] = None post_id: Optional[int] = None sizes: Optional[List['PhotosPhotoSizes']] = None tag_created: Optional[int] = None tag_id: Optional[int] = None text: Optional[str] = None user_id: Optional[int] = None width: Optional[int] = None class PhotosTagsSuggestionItem(Model): title: str type: str buttons: List['PhotosTagsSuggestionItemButton'] photo: "PhotosPhoto" tags: List['PhotosPhotoTag'] class PhotosTagsSuggestionItemButton(Model): title: str action: str style: str class PhotosWallUploadResponse(Model): hash: str photo: str server: int class PollsAnswer(Model): id: int rate: float text: str votes: int class PollsBackground(Model): angle: int color: str height: int id: int name: str images: List['BaseImage'] points: List['BaseGradientPoint'] type: str width: int class PollsFriend(Model): id: int class PollsPoll(Model): anonymous: "PollsPollAnonymous" friends: Optional[List['PollsFriend']] = None multiple: bool answer_id: Optional[int] = None end_date: int answer_ids: Optional[List[int]] = None closed: bool is_board: bool can_edit: bool can_vote: bool can_report: bool can_share: bool photo: Optional["PollsBackground"] = None answers: List['PollsAnswer'] created: int id: int owner_id: int author_id: Optional[int] = None question: str background: Optional["PollsBackground"] = None votes: int disable_unvote: bool class PollsPollAnonymous(Model): ... class PollsVoters(Model): answer_id: int users: "PollsVotersUsers" class PollsVotersUsers(Model): count: int items: List[int] class PrettycardsPrettycard(Model): button: Optional[str] = None button_text: Optional[str] = None card_id: str images: Optional[List['BaseImage']] = None link_url: str photo: str price: Optional[str] = None price_old: Optional[str] = None title: str class SearchHint(Model): app: Optional["AppsApp"] = None description: str global_: Optional["BaseBoolInt"] = None group: Optional["GroupsGroup"] = None profile: Optional["UsersUserMin"] = None section: "SearchHintSection" type: "SearchHintType" class SearchHintSection(enum.Enum): GROUPS = "groups" EVENTS = "events" PUBLICS = "publics" CORRESPONDENTS = "correspondents" PEOPLE = "people" FRIENDS = "friends" MUTUAL_FRIENDS = "mutual_friends" class SearchHintType(enum.Enum): GROUP = "group" PROFILE = "profile" VK_APP = "vk_app" APP = "app" HTML5_GAME = "html5_game" class SecureLevel(Model): level: int uid: int class SecureSmsNotification(Model): app_id: str date: str id: str message: str user_id: str class SecureTokenChecked(Model): date: int expire: int success: int user_id: int class SecureTransaction(Model): date: int id: int uid_from: int uid_to: int votes: int class StatsActivity(Model): comments: int copies: int hidden: int likes: int subscribed: int unsubscribed: int class StatsCity(Model): count: int name: str value: int class StatsCountry(Model): code: str count: int name: str value: int class StatsPeriod(Model): activity: "StatsActivity" period_from: int period_to: int reach: "StatsReach" visitors: "StatsViews" class StatsReach(Model): age: List['StatsSexAge'] cities: List['StatsCity'] countries: List['StatsCountry'] mobile_reach: int reach: int reach_subscribers: int sex: List['StatsSexAge'] sex_age: List['StatsSexAge'] class StatsSexAge(Model): count: Optional[int] = None value: str reach: Optional[int] = None reach_subscribers: Optional[int] = None count_subscribers: Optional[int] = None class StatsViews(Model): age: List['StatsSexAge'] cities: List['StatsCity'] countries: List['StatsCountry'] mobile_views: int sex: List['StatsSexAge'] sex_age: List['StatsSexAge'] views: int visitors: int class StatsWallpostStat(Model): post_id: int hide: int join_group: int links: int reach_subscribers: int reach_subscribers_count: int reach_total: int reach_total_count: int reach_viral: int reach_ads: int report: int to_group: int unsubscribe: int sex_age: List['StatsSexAge'] class StatusStatus(Model): text: str audio: Optional["AudioAudio"] = None class StorageValue(Model): key: str value: str class StoriesClickableArea(Model): x: int y: int class StoriesClickableSticker(Model): clickable_area: List['StoriesClickableArea'] id: int hashtag: Optional[str] = None link_object: Optional["BaseLink"] = None mention: Optional[str] = None tooltip_text: Optional[str] = None owner_id: Optional[int] = None story_id: Optional[int] = None question: Optional[str] = None question_button: Optional[str] = None place_id: Optional[int] = None market_item: Optional["MarketMarketItem"] = None audio: Optional["AudioAudio"] = None audio_start_time: Optional[int] = None style: Optional[str] = None type: str subtype: Optional[str] = None post_owner_id: Optional[int] = None post_id: Optional[int] = None poll: Optional["PollsPoll"] = None color: Optional[str] = None sticker_id: Optional[int] = None sticker_pack_id: Optional[int] = None app: Optional["AppsAppMin"] = None app_context: Optional[str] = None has_new_interactions: Optional[bool] = None is_broadcast_notify_allowed: Optional[bool] = None class StoriesClickableStickers(Model): clickable_stickers: List['StoriesClickableSticker'] original_height: int original_width: int class StoriesFeedItem(Model): type: str stories: Optional[List['StoriesStory']] = None grouped: Optional[List['StoriesFeedItem']] = None app: Optional["AppsAppMin"] = None promo_data: Optional["StoriesPromoBlock"] = None class StoriesPromoBlock(Model): name: str photo_50: str photo_100: str not_animated: bool class StoriesReplies(Model): count: int new: Optional[int] = None class StoriesStatLine(Model): name: str counter: Optional[int] = None is_unavailable: Optional[bool] = None class StoriesStory(Model): access_key: Optional[str] = None can_comment: Optional["BaseBoolInt"] = None can_reply: Optional["BaseBoolInt"] = None can_see: Optional["BaseBoolInt"] = None can_like: Optional[bool] = None can_share: Optional["BaseBoolInt"] = None can_hide: Optional["BaseBoolInt"] = None date: Optional[int] = None expires_at: Optional[int] = None id: int is_deleted: Optional[bool] = None is_expired: Optional[bool] = None link: Optional["StoriesStoryLink"] = None owner_id: int parent_story: Optional["StoriesStory"] = None parent_story_access_key: Optional[str] = None parent_story_id: Optional[int] = None parent_story_owner_id: Optional[int] = None photo: Optional["PhotosPhoto"] = None replies: Optional["StoriesReplies"] = None seen: Optional["BaseBoolInt"] = None type: Optional["StoriesStoryType"] = None clickable_stickers: Optional["StoriesClickableStickers"] = None video: Optional["VideoVideo"] = None views: Optional[int] = None can_ask: Optional["BaseBoolInt"] = None can_ask_anonymous: Optional["BaseBoolInt"] = None narratives_count: Optional[int] = None first_narrative_title: Optional[str] = None birthday_wish_user_id: Optional[int] = None class StoriesStoryLink(Model): text: str url: str class StoriesStoryStats(Model): answer: "StoriesStoryStatsStat" bans: "StoriesStoryStatsStat" open_link: "StoriesStoryStatsStat" replies: "StoriesStoryStatsStat" shares: "StoriesStoryStatsStat" subscribers: "StoriesStoryStatsStat" views: "StoriesStoryStatsStat" likes: "StoriesStoryStatsStat" class StoriesStoryStatsStat(Model): count: Optional[int] = None state: "StoriesStoryStatsState" class StoriesStoryStatsState(enum.Enum): ON = "on" OFF = "off" HIDDEN = "hidden" class StoriesStoryType(enum.Enum): PHOTO = "photo" VIDEO = "video" LIVE_ACTIVE = "live_active" LIVE_FINISHED = "live_finished" class StoriesUploadLinkText(enum.Enum): TO_STORE = "to_store" VOTE = "vote" MORE = "more" BOOK = "book" ORDER = "order" ENROLL = "enroll" FILL = "fill" SIGNUP = "signup" BUY = "buy" TICKET = "ticket" WRITE = "write" OPEN = "open" LEARN_MORE = "learn_more" VIEW = "view" GO_TO = "go_to" CONTACT = "contact" WATCH = "watch" PLAY = "play" INSTALL = "install" READ = "read" CALENDAR = "calendar" class StoriesViewersItem(Model): is_liked: bool user_id: int user: Optional["UsersUserFull"] = None class UsersCareer(Model): city_id: int company: str country_id: int from_: int group_id: int id: int position: str until: int class UsersExports(Model): facebook: int livejournal: int twitter: int class UsersFields(enum.Enum): PHOTO_ID = "photo_id" VERIFIED = "verified" SEX = "sex" BDATE = "bdate" CITY = "city" COUNTRY = "country" HOME_TOWN = "home_town" HAS_PHOTO = "has_photo" PHOTO_50 = "photo_50" PHOTO_100 = "photo_100" PHOTO_200_ORIG = "photo_200_orig" PHOTO_200 = "photo_200" PHOTO_400_ORIG = "photo_400_orig" PHOTO_MAX = "photo_max" PHOTO_MAX_ORIG = "photo_max_orig" ONLINE = "online" LISTS = "lists" DOMAIN = "domain" HAS_MOBILE = "has_mobile" CONTACTS = "contacts" SITE = "site" EDUCATION = "education" UNIVERSITIES = "universities" SCHOOLS = "schools" STATUS = "status" LAST_SEEN = "last_seen" FOLLOWERS_COUNT = "followers_count" COUNTERS = "counters" COMMON_COUNT = "common_count" OCCUPATION = "occupation" NICKNAME = "nickname" RELATIVES = "relatives" RELATION = "relation" PERSONAL = "personal" CONNECTIONS = "connections" EXPORTS = "exports" WALL_COMMENTS = "wall_comments" ACTIVITIES = "activities" INTERESTS = "interests" MUSIC = "music" MOVIES = "movies" TV = "tv" BOOKS = "books" GAMES = "games" ABOUT = "about" QUOTES = "quotes" CAN_POST = "can_post" CAN_SEE_ALL_POSTS = "can_see_all_posts" CAN_SEE_AUDIO = "can_see_audio" CAN_WRITE_PRIVATE_MESSAGE = "can_write_private_message" CAN_SEND_FRIEND_REQUEST = "can_send_friend_request" IS_FAVORITE = "is_favorite" IS_HIDDEN_FROM_FEED = "is_hidden_from_feed" TIMEZONE = "timezone" SCREEN_NAME = "screen_name" MAIDEN_NAME = "maiden_name" CROP_PHOTO = "crop_photo" IS_FRIEND = "is_friend" FRIEND_STATUS = "friend_status" CAREER = "career" MILITARY = "military" BLACKLISTED = "blacklisted" BLACKLISTED_BY_ME = "blacklisted_by_me" CAN_SUBSCRIBE_POSTS = "can_subscribe_posts" DESCRIPTIONS = "descriptions" TRENDING = "trending" MUTUAL = "mutual" FRIENDSHIP_WEEKS = "friendship_weeks" CAN_INVITE_TO_CHATS = "can_invite_to_chats" STORIES_ARCHIVE_COUNT = "stories_archive_count" VIDEO_LIVE_LEVEL = "video_live_level" VIDEO_LIVE_COUNT = "video_live_count" CLIPS_COUNT = "clips_count" class UsersLastSeen(Model): platform: int time: int class UsersMilitary(Model): country_id: int from_: Optional[int] = None id: Optional[int] = None unit: str unit_id: int until: Optional[int] = None class UsersOccupation(Model): id: int name: str type: str class UsersOnlineInfo(Model): visible: bool last_seen: Optional[int] = None is_online: Optional[bool] = None app_id: Optional[int] = None is_mobile: Optional[bool] = None status: Optional[str] = None class UsersPersonal(Model): alcohol: int inspired_by: str langs: List[str] life_main: int people_main: int political: int religion: str religion_id: int smoking: int class UsersRelative(Model): birth_date: Optional[str] = None id: Optional[int] = None name: Optional[str] = None type: str class UsersSchool(Model): city: int class_: str country: int id: str name: str type: int type_str: str year_from: int year_graduated: int year_to: int class UsersSubscriptionsItem(Model): ... class UsersUniversity(Model): chair: int chair_name: str city: int country: int education_form: str education_status: str faculty: int faculty_name: str graduation: int id: int name: str class UsersUser(Model): ... class UsersUserConnections(Model): skype: str facebook: str facebook_name: Optional[str] = None twitter: str livejournal: Optional[str] = None instagram: str class UsersUserCounters(Model): albums: int audios: int followers: int friends: int gifts: int groups: int notes: int online_friends: int pages: int photos: int subscriptions: int user_photos: int user_videos: int videos: int class UsersUserFull(Model): ... class UsersUserMin(Model): deactivated: Optional[str] = None first_name: str hidden: Optional[int] = None id: int last_name: str can_access_closed: Optional[bool] = None is_closed: Optional[bool] = None class UsersUserRelation(enum.Enum): NOT_SPECIFIED = 0 SINGLE = 1 IN_A_RELATIONSHIP = 2 ENGAGED = 3 MARRIED = 4 COMPLICATED = 5 ACTIVELY_SEARCHING = 6 IN_LOVE = 7 IN_A_CIVIL_UNION = 8 class UsersUserSettingsXtr(Model): connections: Optional["UsersUserConnections"] = None bdate: Optional[str] = None bdate_visibility: Optional[int] = None city: Optional["BaseCity"] = None country: Optional["BaseCountry"] = None first_name: Optional[str] = None home_town: str last_name: Optional[str] = None maiden_name: Optional[str] = None name_request: Optional["AccountNameRequest"] = None personal: Optional["UsersPersonal"] = None phone: Optional[str] = None relation: Optional["UsersUserRelation"] = None relation_partner: Optional["UsersUserMin"] = None relation_pending: Optional["BaseBoolInt"] = None relation_requests: Optional[List['UsersUserMin']] = None screen_name: Optional[str] = None sex: Optional["BaseSex"] = None status: str status_audio: Optional["AudioAudio"] = None interests: Optional["AccountUserSettingsInterests"] = None languages: Optional[List[str]] = None class UsersUserType(enum.Enum): PROFILE = "profile" class UsersUserXtrCounters(Model): ... class UsersUserXtrType(Model): ... class UsersUsersArray(Model): count: int items: List[int] class UtilsDomainResolved(Model): object_id: int group_id: int type: "UtilsDomainResolvedType" class UtilsDomainResolvedType(enum.Enum): USER = "user" GROUP = "group" APPLICATION = "application" PAGE = "page" class UtilsLastShortenedLink(Model): access_key: str key: str short_url: str timestamp: int url: str views: int class UtilsLinkChecked(Model): link: str status: "UtilsLinkCheckedStatus" class UtilsLinkCheckedStatus(enum.Enum): NOT_BANNED = "not_banned" BANNED = "banned" PROCESSING = "processing" class UtilsLinkStats(Model): key: str stats: List['UtilsStats'] class UtilsLinkStatsExtended(Model): key: str stats: List['UtilsStatsExtended'] class UtilsShortLink(Model): access_key: str key: str short_url: str url: str class UtilsStats(Model): timestamp: int views: int class UtilsStatsCity(Model): city_id: int views: int class UtilsStatsCountry(Model): country_id: int views: int class UtilsStatsExtended(Model): cities: List['UtilsStatsCity'] countries: List['UtilsStatsCountry'] sex_age: List['UtilsStatsSexAge'] timestamp: int views: int class UtilsStatsSexAge(Model): age_range: str female: int male: int class VideoLiveSettings(Model): can_rewind: "BaseBoolInt" is_endless: "BaseBoolInt" max_duration: int class VideoRestrictionButton(Model): action: str title: str class VideoSaveResult(Model): access_key: str description: str owner_id: int title: str upload_url: str video_id: int class VideoVideo(Model): ... class VideoVideoAlbumFull(Model): count: int id: Optional[int] = None image: Optional[List['VideoVideoImage']] = None image_blur: Optional["BasePropertyExists"] = None is_system: Optional["BasePropertyExists"] = None owner_id: int title: str updated_time: int class VideoVideoFiles(Model): external: str mp4_240: str mp4_360: str mp4_480: str mp4_720: str mp4_1080: str flv_320: str class VideoVideoFull(Model): ... class VideoVideoImage(Model): ... class WallAppPost(Model): id: int name: str photo_130: str photo_604: str class WallAttachedNote(Model): comments: int date: int id: int owner_id: int read_comments: int title: str view_url: str class WallCarouselBase(Model): carousel_offset: int class WallCommentAttachment(Model): audio: Optional["AudioAudio"] = None doc: Optional["DocsDoc"] = None link: Optional["BaseLink"] = None market: Optional["MarketMarketItem"] = None market_market_album: Optional["MarketMarketAlbum"] = None note: Optional["WallAttachedNote"] = None page: Optional["PagesWikipageFull"] = None photo: Optional["PhotosPhoto"] = None sticker: Optional["BaseSticker"] = None type: "WallCommentAttachmentType" video: Optional["VideoVideo"] = None class WallCommentAttachmentType(enum.Enum): PHOTO = "photo" AUDIO = "audio" VIDEO = "video" DOC = "doc" LINK = "link" NOTE = "note" PAGE = "page" MARKET_MARKET_ALBUM = "market_market_album" MARKET = "market" STICKER = "sticker" class WallGeo(Model): coordinates: str place: "BasePlace" showmap: int type: str class WallGraffiti(Model): id: int owner_id: int photo_200: str photo_586: str class WallPostCopyright(Model): id: Optional[int] = None link: str name: str type: str class WallPostSource(Model): data: str platform: str type: "WallPostSourceType" url: str class WallPostSourceType(enum.Enum): VK = "vk" WIDGET = "widget" API = "api" RSS = "rss" SMS = "sms" class WallPostType(enum.Enum): POST = "post" COPY = "copy" REPLY = "reply" POSTPONE = "postpone" SUGGEST = "suggest" class WallPostedPhoto(Model): id: int owner_id: int photo_130: str photo_604: str class WallViews(Model): count: int class WallWallComment(Model): attachments: Optional[List['WallCommentAttachment']] = None date: int from_id: int id: int likes: Optional["BaseLikesInfo"] = None real_offset: Optional[int] = None reply_to_comment: Optional[int] = None reply_to_user: Optional[int] = None text: str thread: Optional["CommentThread"] = None post_id: Optional[int] = None owner_id: Optional[int] = None parents_stack: Optional[List[int]] = None deleted: Optional[bool] = None class WallWallpost(Model): access_key: str attachments: List['WallWallpostAttachment'] copyright: "WallPostCopyright" date: int edited: int from_id: int geo: "WallGeo" id: int is_archived: bool is_favorite: bool likes: "BaseLikesInfo" owner_id: int post_source: "WallPostSource" post_type: "WallPostType" reposts: "BaseRepostsInfo" signer_id: int text: str views: "WallViews" class WallWallpostAttachment(Model): access_key: Optional[str] = None album: Optional["PhotosPhotoAlbum"] = None app: Optional["WallAppPost"] = None audio: Optional["AudioAudio"] = None doc: Optional["DocsDoc"] = None event: Optional["EventsEventAttach"] = None group: Optional["GroupsGroupAttach"] = None graffiti: Optional["WallGraffiti"] = None link: Optional["BaseLink"] = None market: Optional["MarketMarketItem"] = None market_album: Optional["MarketMarketAlbum"] = None note: Optional["WallAttachedNote"] = None page: Optional["PagesWikipageFull"] = None photo: Optional["PhotosPhoto"] = None photos_list: Optional[List[str]] = None poll: Optional["PollsPoll"] = None posted_photo: Optional["WallPostedPhoto"] = None type: "WallWallpostAttachmentType" video: Optional["VideoVideo"] = None class WallWallpostAttachmentType(enum.Enum): PHOTO = "photo" POSTED_PHOTO = "posted_photo" AUDIO = "audio" VIDEO = "video" DOC = "doc" LINK = "link" GRAFFITI = "graffiti" NOTE = "note" APP = "app" POLL = "poll" PAGE = "page" ALBUM = "album" PHOTOS_LIST = "photos_list" MARKET_MARKET_ALBUM = "market_market_album" MARKET = "market" EVENT = "event" class WallWallpostFull(Model): ... class WallWallpostToId(Model): attachments: List['WallWallpostAttachment'] comments: "BaseCommentsInfo" copy_owner_id: int copy_post_id: int date: int from_id: int geo: "WallGeo" id: int is_favorite: bool likes: "BaseLikesInfo" post_id: int post_source: "WallPostSource" post_type: "WallPostType" reposts: "BaseRepostsInfo" signer_id: int text: str to_id: int class WidgetsCommentMedia(Model): item_id: int owner_id: int thumb_src: str type: "WidgetsCommentMediaType" class WidgetsCommentMediaType(enum.Enum): AUDIO = "audio" PHOTO = "photo" VIDEO = "video" class WidgetsCommentReplies(Model): can_post: "BaseBoolInt" count: int replies: List['WidgetsCommentRepliesItem'] class WidgetsCommentRepliesItem(Model): cid: int date: int likes: "WidgetsWidgetLikes" text: str uid: int user: "UsersUserFull" class WidgetsWidgetComment(Model): attachments: Optional[List['WallCommentAttachment']] = None can_delete: Optional["BaseBoolInt"] = None comments: Optional["WidgetsCommentReplies"] = None date: int from_id: int id: int likes: Optional["BaseLikesInfo"] = None media: Optional["WidgetsCommentMedia"] = None post_source: Optional["WallPostSource"] = None post_type: int reposts: Optional["BaseRepostsInfo"] = None text: str to_id: int user: Optional["UsersUserFull"] = None class WidgetsWidgetLikes(Model): count: int class WidgetsWidgetPage(Model): comments: "BaseObjectCount" date: int description: str id: int likes: "BaseObjectCount" page_id: str photo: str title: str url: str [v.update_forward_refs() for v in globals().values() if hasattr(v, "update_forward_refs")]
0
77,911
10,902
e0a03231ac695e3b52250875b13d9576ddc71fd0
248
py
Python
info.py
PapaDoraemon/marina-AI
9f9281b5decf889a55d6c1bdbfe3a62adadd47f9
[ "Apache-2.0" ]
1
2020-09-04T12:42:54.000Z
2020-09-04T12:42:54.000Z
info.py
PapaDoraemon/marina-AI
9f9281b5decf889a55d6c1bdbfe3a62adadd47f9
[ "Apache-2.0" ]
null
null
null
info.py
PapaDoraemon/marina-AI
9f9281b5decf889a55d6c1bdbfe3a62adadd47f9
[ "Apache-2.0" ]
null
null
null
import json
15.5
106
0.620968
import json def get_info(host): headers = { 'User-Agent': 'MARINA 2.0' } shodan_data = requests.get("http://192.168.0.3/marina-shodan.php?ip={}".format(host), headers=headers) return json.loads(shodan_data.text)
205
0
23
79ebda0ce039164287373a53487e4e2f1bccc2b6
3,649
py
Python
project/pro2-typing_test/utils.py
zltshadow/CS61A-2019-summer
0f5dd0be5f51927364aec1bc974526837328b695
[ "MIT" ]
3
2021-11-21T06:09:39.000Z
2022-03-12T08:05:27.000Z
project/pro2-typing_test/utils.py
zltshadow/CS61A-2019-summer
0f5dd0be5f51927364aec1bc974526837328b695
[ "MIT" ]
null
null
null
project/pro2-typing_test/utils.py
zltshadow/CS61A-2019-summer
0f5dd0be5f51927364aec1bc974526837328b695
[ "MIT" ]
null
null
null
from math import sqrt import string ############################################################################################ # Important: Read over the information in the "Appendix: Utility Functions" in the Project # # Project Specification in order to better understand how to use the functions below. # ############################################################################################ ############################### # Submitting design questions # ############################### passphrase = '814716d640bad70cbb9c76c72f2810e06f588a1bc1039d2510acab2d' def check_passphrase(p): """ You do not need to understand this code. This will only be used to ensure you have entered the correct passphrase. """ import hashlib return hashlib.sha224(p.encode('utf-8')).hexdigest() ################# # Reading files # ################# def close(file): """Closes the file object passed in. """ file.close() def readable(file): """Return True if this file can be read from. """ return file.readable() def readline(file): """ Return the first unread line from this file, or the empty string if all lines are read. """ return file.readline() def readlines(file): """ Return all unread lines in a list. """ return file.readlines() ############################ # String utility functions # ############################ def lower(s): """Return a copy of string s with all letters converted to lowercase.""" return s.lower() def split(s, sep=None): """ Returns a list of words contained in s, which are sequences of characters separated by a string sep. By default, this splits on whitespace (spaces, tabs, etc.) but by defining a different sep, you can split on arbitrary characters. """ return s.split(sep) def strip(s, chars=None): """ Return a version of s with characters in chars removed from the start and end. By default, removes whitespace characters. """ return s.strip(chars) ######################################### # Functions relating to keyboard layout # ######################################### KEY_LAYOUT = [["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"], ["a", "s", "d", "f", "g", "h", "j", "k", "l"], ["z", "x", "c", "v", "b", "n", "m"]] def distance(p1, p2): """Return the Euclidean distance between two points The Euclidean distance between two points, (x1, y1) and (x2, y2) is the square root of (x1 - x2) ** 2 + (y1 - y2) ** 2 >>> distance((0, 1), (1, 1)) 1 >>> distance((1, 1), (1, 1)) 0 >>> round(distance((4, 0), (0, 4)), 3) 5.657 """ return sqrt((p1[0] - p2[0])**2 + (p1[1] - p2[1])**2) def get_key_distances(): """Return a new dictionary mapping key pairs to distances. Each key of the dictionary is a tuple of two letters as strings, and each value is the euclidean distance between the two letters on a standard QWERTY keyboard normalized such that the greatest distance is 2.0 The scaling is constant, so a pair of keys that are twice as far have a distance value that is twice as great >>> distances = get_key_distances() >>> distances["a", "a"] 0.0 >>> distances["a", "d"] # 2.0 / 9 2.0 >>> distances["d", "a"] 2.0 """ key_distance = {} for i in range(len(KEY_LAYOUT)): for j in range(len(KEY_LAYOUT[i])): compute_pairwise_distances(i, j, key_distance) max_value = max(key_distance.values()) return {key : value * 2 / max_value for key, value in key_distance.items()}
26.635036
92
0.585366
from math import sqrt import string ############################################################################################ # Important: Read over the information in the "Appendix: Utility Functions" in the Project # # Project Specification in order to better understand how to use the functions below. # ############################################################################################ ############################### # Submitting design questions # ############################### passphrase = '814716d640bad70cbb9c76c72f2810e06f588a1bc1039d2510acab2d' def check_passphrase(p): """ You do not need to understand this code. This will only be used to ensure you have entered the correct passphrase. """ import hashlib return hashlib.sha224(p.encode('utf-8')).hexdigest() ################# # Reading files # ################# def close(file): """Closes the file object passed in. """ file.close() def readable(file): """Return True if this file can be read from. """ return file.readable() def readline(file): """ Return the first unread line from this file, or the empty string if all lines are read. """ return file.readline() def readlines(file): """ Return all unread lines in a list. """ return file.readlines() ############################ # String utility functions # ############################ def lower(s): """Return a copy of string s with all letters converted to lowercase.""" return s.lower() def split(s, sep=None): """ Returns a list of words contained in s, which are sequences of characters separated by a string sep. By default, this splits on whitespace (spaces, tabs, etc.) but by defining a different sep, you can split on arbitrary characters. """ return s.split(sep) def strip(s, chars=None): """ Return a version of s with characters in chars removed from the start and end. By default, removes whitespace characters. """ return s.strip(chars) ######################################### # Functions relating to keyboard layout # ######################################### KEY_LAYOUT = [["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"], ["a", "s", "d", "f", "g", "h", "j", "k", "l"], ["z", "x", "c", "v", "b", "n", "m"]] def distance(p1, p2): """Return the Euclidean distance between two points The Euclidean distance between two points, (x1, y1) and (x2, y2) is the square root of (x1 - x2) ** 2 + (y1 - y2) ** 2 >>> distance((0, 1), (1, 1)) 1 >>> distance((1, 1), (1, 1)) 0 >>> round(distance((4, 0), (0, 4)), 3) 5.657 """ return sqrt((p1[0] - p2[0])**2 + (p1[1] - p2[1])**2) def get_key_distances(): """Return a new dictionary mapping key pairs to distances. Each key of the dictionary is a tuple of two letters as strings, and each value is the euclidean distance between the two letters on a standard QWERTY keyboard normalized such that the greatest distance is 2.0 The scaling is constant, so a pair of keys that are twice as far have a distance value that is twice as great >>> distances = get_key_distances() >>> distances["a", "a"] 0.0 >>> distances["a", "d"] # 2.0 / 9 2.0 >>> distances["d", "a"] 2.0 """ key_distance = {} def compute_pairwise_distances(i, j, d): for x in range(len(KEY_LAYOUT)): for y in range(len(KEY_LAYOUT[x])): l1 = KEY_LAYOUT[i][j] l2 = KEY_LAYOUT[x][y] d[l1, l2] = distance((i, j), (x, y)) for i in range(len(KEY_LAYOUT)): for j in range(len(KEY_LAYOUT[i])): compute_pairwise_distances(i, j, key_distance) max_value = max(key_distance.values()) return {key : value * 2 / max_value for key, value in key_distance.items()}
186
0
24
de57dabc2f021eb3cff5c6361aadded8586e7845
1,632
py
Python
aws_sam/fargateIR/tests/integration/test_full.py
andrewkrug/fargate-ir
9c5c49c34f435a8eb9123d686643890957724f25
[ "Apache-2.0" ]
11
2019-12-05T17:56:34.000Z
2022-02-25T10:24:30.000Z
aws_sam/fargateIR/tests/integration/test_full.py
andrewkrug/fargate-ir
9c5c49c34f435a8eb9123d686643890957724f25
[ "Apache-2.0" ]
2
2019-12-05T16:42:53.000Z
2019-12-05T17:38:31.000Z
aws_sam/fargateIR/tests/integration/test_full.py
andrewkrug/fargate-ir
9c5c49c34f435a8eb9123d686643890957724f25
[ "Apache-2.0" ]
2
2019-12-06T03:18:10.000Z
2019-12-27T15:27:53.000Z
import os from lambda_handler import handle # Use an event structure that follows GuardDuty Schema 2.0 to simulate a ticketing system integration. EVENT_FIXTURE = { "detail-type": "GuardDuty Finding", "source": "aws.guardduty", "detail": { "schemaVersion": "2.0", "accountId": "874153891031", "region": "us-west-2", "partition": "aws", "id": "b2b7236dda0e4eff8aa17738d9ad18c5", "type": "Custom:UserReport/WebsiteDefacement", "resource": { "resourceType": "FargateContainer", "instanceDetails": { "tags": [ {"Key": "app", "Value": "fluffykittenwww"}, {"Key": "risk", "Value": "maximum"}, ], }, }, "severity": 10, "createdAt": "2019-11-07T17:13:53.948Z", "updatedAt": "2019-11-09T17:41:09.360Z", "title": "A user has reported a defacement of fluffykitten securities main www site.", "description": "All images on the site have been replaced with dogs instead of fluffy cats.", "detail": {}, }, }
30.792453
102
0.586397
import os from lambda_handler import handle # Use an event structure that follows GuardDuty Schema 2.0 to simulate a ticketing system integration. EVENT_FIXTURE = { "detail-type": "GuardDuty Finding", "source": "aws.guardduty", "detail": { "schemaVersion": "2.0", "accountId": "874153891031", "region": "us-west-2", "partition": "aws", "id": "b2b7236dda0e4eff8aa17738d9ad18c5", "type": "Custom:UserReport/WebsiteDefacement", "resource": { "resourceType": "FargateContainer", "instanceDetails": { "tags": [ {"Key": "app", "Value": "fluffykittenwww"}, {"Key": "risk", "Value": "maximum"}, ], }, }, "severity": 10, "createdAt": "2019-11-07T17:13:53.948Z", "updatedAt": "2019-11-09T17:41:09.360Z", "title": "A user has reported a defacement of fluffykitten securities main www site.", "description": "All images on the site have been replaced with dogs instead of fluffy cats.", "detail": {}, }, } def test_phases(): os.environ["SLACK_CHANNEL"] = "alert-triage" event = EVENT_FIXTURE notify = handle.notify(event, context={}) event = notify detect = handle.detect(event, context={}) event = detect protect = handle.protect(event, context={}) event = protect assert protect["detail"]["remediation"]["risk"] == "MAXIMUM" assert notify is not None assert detect is not None assert protect is not None handle.maximum_respond(event, context={})
476
0
23
ced0e92053dfc14cd64b84707b6b59c2d18deccc
340
py
Python
setup.py
rmatsum836/pyfooty
621fe06b4517223aab875cb60a88ee5825506c21
[ "MIT" ]
1
2020-11-08T23:50:26.000Z
2020-11-08T23:50:26.000Z
setup.py
rmatsum836/pyfooty
621fe06b4517223aab875cb60a88ee5825506c21
[ "MIT" ]
2
2021-01-05T00:29:54.000Z
2021-01-05T00:56:16.000Z
setup.py
rmatsum836/pyfooty
621fe06b4517223aab875cb60a88ee5825506c21
[ "MIT" ]
null
null
null
from setuptools import setup setup(name='pyfooty', version='0.0', description='Parse the fbref website with python', url='https://github.com/rmatsum836/pyfooty', author='Ray Matsumoto', author_email='[email protected]', license='MIT', packages=['pyfooty'], zip_safe=False)
28.333333
58
0.617647
from setuptools import setup setup(name='pyfooty', version='0.0', description='Parse the fbref website with python', url='https://github.com/rmatsum836/pyfooty', author='Ray Matsumoto', author_email='[email protected]', license='MIT', packages=['pyfooty'], zip_safe=False)
0
0
0
6b680c1b1fcbc411b748a75b07e98af22697f813
19,783
py
Python
compflow/fortran.py
jb753/compflow
7ede6cb860a2573a1ab5e7e40b1591c3e72c3783
[ "MIT" ]
null
null
null
compflow/fortran.py
jb753/compflow
7ede6cb860a2573a1ab5e7e40b1591c3e72c3783
[ "MIT" ]
1
2022-03-04T12:10:26.000Z
2022-03-14T22:57:56.000Z
compflow/fortran.py
jb753/compflow
7ede6cb860a2573a1ab5e7e40b1591c3e72c3783
[ "MIT" ]
null
null
null
"""This module wraps the fortran backend.""" import numpy as np import compflow_fort_from_Ma as fort_from_Ma import compflow_fort_der_from_Ma as fort_der_from_Ma import compflow_fort_to_Ma as fort_to_Ma def _restore_shape(func, args): """Call a function and restore output to same shape as first argument.""" shape = np.shape(args[0]) if shape == (): return(func(*args)[0]) elif len(shape) == 1: return(func(*args)) else: return(func(*args).reshape(shape, order='F')) # Functions from Ma def To_T_from_Ma(Ma, ga): r"""Stagnation temperature ratio as function of Mach number. .. math:: \frac{T_0}{T} = 1 + \frac{\gamma - 1}{2} \Ma^2 Parameters ---------- Ma : array Mach number, :math:`\Ma`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- To_T : array Stagnation temperature ratio, :math:`T_0/T`. """ return _restore_shape(fort_from_Ma.to_t, (Ma,ga)) def Po_P_from_Ma(Ma,ga): r"""Stagnation pressure ratio as function of Mach number. .. math:: \frac{p_0}{p} = \left(1 + \frac{\gamma - 1}{2} \Ma^2 \right) ^\tfrac{\gamma}{\gamma - 1} Parameters ---------- Ma : array Mach number, :math:`\Ma`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- Po_P : array Stagnation pressure ratio, :math:`p_0/p`. """ return _restore_shape(fort_from_Ma.po_p, (Ma,ga)) def rhoo_rho_from_Ma(Ma,ga): r"""Stagnation density ratio as function of Mach number. .. math:: \frac{\rho_0}{\rho} = \left(1 + \frac{\gamma - 1}{2} \Ma^2 \right) ^\tfrac{1}{\gamma - 1} Parameters ---------- Ma : array Mach number, :math:`\Ma`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- rhoo_rho : array Stagnation density ratio, :math:`\rho_0/\rho`. """ return _restore_shape(fort_from_Ma.rhoo_rho, (Ma,ga)) def V_cpTo_from_Ma(Ma,ga): r"""Normalised velocity as function of Mach number. .. math:: \frac{V}{\sqrt{c_p T_0}} = \sqrt{\gamma -1}\, \Ma \left(1 + \frac{\gamma - 1}{2} \Ma^2 \right)^{-\tfrac{1}{2}} Parameters ---------- Ma : array Mach number, :math:`\Ma`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- V_cpTo : array Normalised velocity, :math:`V/\sqrt{c_p T_0}`. """ return _restore_shape(fort_from_Ma.v_cpto, (Ma,ga)) def mcpTo_APo_from_Ma(Ma,ga): r"""Normalised mass flow as function of Mach number. .. math:: \frac{\dot{m}\sqrt{c_p T_0}}{A p_0} = \frac{\gamma}{\sqrt{\gamma -1}}\, \Ma \left(1 + \frac{\gamma - 1}{2} \Ma^2 \right) ^{-\tfrac{1}{2}\tfrac{\gamma + 1}{\gamma - 1}} Parameters ---------- Ma : array Mach number, :math:`\Ma`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- mcpTo_APo : array Normalised mass flow, :math:`{\dot{m}\sqrt{c_p T_0}}/{A p_0}`. """ return _restore_shape(fort_from_Ma.mcpto_apo, (Ma,ga)) def mcpTo_AP_from_Ma(Ma,ga): r"""Static normalised mass flow as function of Mach number. .. math:: \frac{\dot{m}\sqrt{c_p T_0}}{A p} = \frac{\gamma}{\sqrt{\gamma -1}}\, \Ma \left(1 + \frac{\gamma - 1}{2} \Ma^2 \right) ^{\tfrac{1}{2}} Parameters ---------- Ma : array Mach number, :math:`\Ma`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- mcpTo_AP : array Static pressure variant of normalised mass flow, :math:`{\dot{m}\sqrt{c_p T_0}}/{A p}`. """ return _restore_shape(fort_from_Ma.mcpto_ap, (Ma,ga)) def A_Acrit_from_Ma(Ma,ga): r"""Ratio of area to choking area as function of Mach number. .. math:: \frac{A}{A_*} = \frac{1}{\Ma}\left[\frac{2}{\gamma +1} \left(1 + \frac{\gamma - 1}{2} \Ma^2 \right)\right] ^{\tfrac{1}{2}\tfrac{\gamma + 1}{\gamma - 1}} Parameters ---------- Ma : array Mach number, :math:`\Ma`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- A_Acrit : array Ratio of area to choking area, :math:`A/A_*`. """ return _restore_shape(fort_from_Ma.a_acrit, (Ma,ga)) def Mash_from_Ma(Ma,ga): r"""Post-shock Mach number as function of Mach number. .. math:: \Ma_\mathrm{sh} = \left(\frac{1 + \frac{\gamma - 1}{2} \Ma^2} {\gamma \Ma^2 - \frac{\gamma - 1}{2}} \right)^{\tfrac{1}{2}} Parameters ---------- Ma : array Mach number, :math:`\Ma`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- Mash : array Post-shock Mach number, :math:`\Ma_\mathrm{sh}`. """ return _restore_shape(fort_from_Ma.mash, (Ma,ga)) def Posh_Po_from_Ma(Ma,ga): r"""Shock stagnation pressure ratio as function of Mach number. .. math:: \frac{p_{0\mathrm{sh}}}{p_0} = \left( \frac{\frac{\gamma + 1}{2}\Ma^2}{1 + \frac{\gamma - 1}{2} \Ma^2} \right)^{\tfrac{\gamma}{\gamma-1}} \left( \frac{2 \gamma }{\gamma + 1} \Ma^2 - \frac{\gamma - 1}{\gamma + 1} \right)^{\tfrac{-1}{\gamma -1}} Parameters ---------- Ma : array Mach number, :math:`\Ma`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- Posh_Po : array Shock stagnation pressure ratio, :math:`p_{0\mathrm{sh}}/p_0`. """ return _restore_shape(fort_from_Ma.posh_po, (Ma,ga)) # Inversions to Ma def Ma_from_To_T(To_T, ga): r"""Mach number as function of stagnation temperature ratio. The inverse of :func:`compflow.To_T_from_Ma`, which permits a direct analytical solution. .. math:: \Ma = \sqrt{\frac{2}{\gamma - 1} \left[\frac{T_0}{T} - 1\right]} Returns `NaN` if input data is not physically possible, where :math:`{T_0}/{T}<1`. Parameters ---------- To_T : array Stagnation temperature ratio, :math:`T_0/T`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- Ma : array Mach number, :math:`\Ma`. """ return _restore_shape(fort_to_Ma.to_t, (To_T, ga)) def Ma_from_Po_P(Po_P, ga): r"""Mach number as function of stagnation pressure ratio. The inverse of :func:`compflow.Po_P_from_Ma`, which permits a direct analytical solution. .. math:: \Ma = \sqrt{ \frac{2}{\gamma - 1}\left[\left(\frac{p_0}{p}\right) ^\tfrac{\gamma - 1}{\gamma} - 1\right]} Returns `NaN` if input data is not physically possible, where :math:`{p_0}/{p}<1`. Parameters ---------- Po_P : array Stagnation pressure ratio, :math:`p_0/p`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- Ma : array Mach number, :math:`\Ma`. """ return _restore_shape(fort_to_Ma.po_p, (Po_P, ga)) def Ma_from_rhoo_rho(rhoo_rho, ga): r"""Mach number as function of stagnation density ratio. The inverse of :func:`compflow.rhoo_rho_from_Ma`, which permits a direct analytical solution. .. math:: \Ma = \sqrt{ \frac{2}{\gamma - 1}\left[\left(\frac{\rho_0}{\rho}\right) ^{\gamma - 1} - 1\right]} Returns `NaN` if input data is not physically possible, where :math:`{\rho_0}/{\rho}<1`. Parameters ---------- rhoo_rho : array Stagnation density ratio, :math:`\rho_0/\rho`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- Ma : array Mach number, :math:`\Ma`. """ return _restore_shape(fort_to_Ma.rhoo_rho, (rhoo_rho, ga)) def Ma_from_V_cpTo(V_cpTo, ga): r"""Mach number as function of normalised velocity. Inverse of :func:`compflow.V_cpTo_from_Ma`, which permits a direct analytical solution. .. math:: \Ma = \sqrt{\frac{1}{\gamma-1}\left[ \frac{\left(\frac{V}{\sqrt{c_p T_0}}\right)^2} {1 - \frac{1}{2}\left(\frac{V}{\sqrt{c_p T_0}}\right)^2} \right]} Returns `NaN` if input data is not physically possible, where :math:`V/\sqrt{c_pT_0} < 0` or :math:`V/\sqrt{c_pT_0} > \sqrt{2}`. Parameters ---------- V_cpTo : array Normalised velocity, :math:`V/\sqrt{c_p T_0}`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- Ma : array Mach number, :math:`\Ma`. """ return _restore_shape(fort_to_Ma.v_cpto, (V_cpTo, ga)) def Ma_from_mcpTo_APo(mcpTo_APo, ga, sup=False): r"""Mach number as function of normalised mass flow. The inverse of :func:`compflow.mcpTo_APo_from_Ma`, which at a given value of :math:`{\dot{m}\sqrt{c_p T_0}}/{A p_0}` must be solved iteratively for :math:`\Ma` using Newton's method. .. math:: \frac{\dot{m}\sqrt{c_p T_0}}{A p_0} = \frac{\gamma}{\sqrt{\gamma -1}}\, \Ma \left(1 + \frac{\gamma - 1}{2} \Ma^2 \right) ^{-\tfrac{1}{2}\tfrac{\gamma + 1}{\gamma - 1}} For each :math:`{\dot{m}\sqrt{c_p T_0}}/{A p_0}`, there are two possible values of :math:`\Ma`. Return the subsonic solution with :math:`\Ma\le 1` by default; the supersonic solution with :math:`\Ma>`` is retrived by setting the parameter `sup=True`. Returns `NaN` if input data is not physically possible, where :math:`{\dot{m}\sqrt{c_p T_0}}/{A p_0} < 0`. The normalised mass flow reaches a maximum at the sonic velocity :math:`\Ma=1`. Input data above the maximum value correspond to choking --- also return `NaN` in this case. Parameters ---------- mcpTo_APo : array Normalised mass flow, :math:`{\dot{m}\sqrt{c_p T_0}}/{A p_0}`. ga : float Ratio of specific heats, :math:`\gamma`. sup : bool, default False If true, return the supersonic solution, otherwise the subsonic solution. Returns ------- Ma : array Mach number, :math:`\Ma`. """ return _restore_shape(fort_to_Ma.mcpto_apo, (mcpTo_APo, ga, sup)) def Ma_from_mcpTo_AP(mcpTo_AP, ga): r"""Mach number as function of static normalised mass flow. The inverse of :func:`compflow.mcpTo_AP_from_Ma`, which at a given value of :math:`{\dot{m}\sqrt{c_p T_0}}/{A p}` must be solved iteratively for :math:`\Ma` using Newton's method. .. math:: \frac{\dot{m}\sqrt{c_p T_0}}{A p} = \frac{\gamma}{\sqrt{\gamma -1}}\, \Ma \left(1 + \frac{\gamma - 1}{2} \Ma^2 \right) ^{\tfrac{1}{2}} Returns `NaN` if input data is not physically possible, where :math:`{\dot{m}\sqrt{c_p T_0}}/{A p} < 0`. Parameters ---------- mcpTo_AP : array Static normalised mass flow, :math:`{\dot{m}\sqrt{c_p T_0}}/{A p}`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- Ma : array Mach number, :math:`\Ma`. """ return _restore_shape(fort_to_Ma.mcpto_ap, (mcpTo_AP, ga)) def Ma_from_A_Acrit(A_Acrit, ga): r"""Mach number as function of area to choking area ratio. The inverse of :func:`compflow.A_Acrit_from_Ma`, which at a given value of :math:`A/A_*` must be solved iteratively for :math:`\Ma` using Newton's method. .. math:: \frac{A}{A_*} = \frac{1}{\Ma}\left[ \frac{2}{\gamma +1} \left(1 + \frac{\gamma - 1}{2} \Ma^2 \right) \right]^{\tfrac{1}{2}\tfrac{\gamma + 1}{\gamma - 1}} Returns `NaN` if input data is not physically possible, where :math:`A/A_* < 1`. Parameters ---------- A_Acrit : array Ratio of area to choking area, :math:`A/A_*`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- Ma : array Mach number, :math:`\Ma`. """ return _restore_shape(fort_to_Ma.a_acrit, (A_Acrit, ga)) def Ma_from_Mash(Mash, ga): r"""Mach number as function of post-shock Mach number. The inverse of :func:`compflow.Mash_from_Ma`, which at a given value of :math:`\Ma_\mathrm{sh}` must be solved iteratively for :math:`\Ma` using Newton's method. .. math:: \Ma_\mathrm{sh} = \left( \frac{1 + \frac{\gamma - 1}{2} \Ma^2} {\gamma \Ma^2 - \frac{\gamma - 1}{2}} \right)^{\tfrac{1}{2}} Returns `NaN` if input data is not physically possible, where :math:`\Ma_\mathrm{sh}>1` or :math:`\Ma_\mathrm{sh}<0`. Parameters ---------- Mash : array Post-shock Mach number, :math:`\Ma_\mathrm{sh}`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- Ma : array Mach number, :math:`\Ma`. """ return _restore_shape(fort_to_Ma.mash, (Mash, ga)) def Ma_from_Posh_Po(Posh_Po, ga): r"""Mach number as function of shock stagnation pressure ratio. The inverse of :func:`compflow.Posh_Po_from_Ma`, which at a given value of :math:`p_{0\mathrm{sh}}/p_0` must be solved iteratively for :math:`\Ma` using Newton's method. .. math:: \frac{p_{0\mathrm{sh}}}{p_0} = \left(\frac{\frac{\gamma+1}{2}\Ma^2}{1+\frac{\gamma-1}{2}\Ma^2}\right) ^{\tfrac{\gamma}{\gamma-1}} \left(\frac{2\gamma}{\gamma+1}\Ma^2-\frac{\gamma-1}{\gamma+1}\right) ^{\tfrac{-1}{\gamma -1}} Returns `NaN` if input data is not physically possible, where :math:`p_{0\mathrm{sh}}/p_0 > 1` or :math:`p_{0\mathrm{sh}}/p_0 < 0`. Parameters ---------- Posh_Po : array Shock stagnation pressure ratio, :math:`p_{0\mathrm{sh}}/p_0`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- Ma : array Mach number, :math:`\Ma`. """ return _restore_shape(fort_to_Ma.posh_po, (Posh_Po, ga)) # Derivatives from Ma def der_To_T_from_Ma(Ma, ga): r"""Derivative of stagnation temperature ratio by Mach number. The derivative of :func:`compflow.To_T_from_Ma` with respect to Mach number. .. math:: \frac{\D}{\D\Ma}\left(\frac{T_0}{T}\right) = \left(\gamma - 1\right)\Ma Parameters ---------- Ma : array Mach number, :math:`\Ma`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- der_To_T : array Derivative of stagnation temperature ratio, :math:`\DMa(T_0/T)`. """ return _restore_shape(fort_der_from_Ma.to_t, (Ma,ga)) def der_Po_P_from_Ma(Ma, ga): r"""Derivative of stagnation pressure ratio by Mach number. The derivative of :func:`compflow.Po_P_from_Ma` with respect to Mach number. .. math:: \DMa\left(\frac{p_0}{p}\right) = \gamma \Ma \left(1 + \frac{\gamma - 1}{2} \Ma^2 \right) ^\tfrac{1}{\gamma - 1} Parameters ---------- Ma : array Mach number, :math:`\Ma`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- der_Po_P : array Derivative of stagnation pressure ratio, :math:`\DMa(p_0/p)`. """ return _restore_shape(fort_der_from_Ma.po_p, (Ma,ga)) def der_rhoo_rho_from_Ma(Ma,ga): r"""Derivative of stagnation density ratio by Mach number. The derivative of :func:`compflow.rhoo_rho_from_Ma` with respect to Mach number. .. math:: \DMa\left(\frac{\rho_0}{\rho}\right) = \Ma\left(1 + \frac{\gamma - 1}{2} \Ma^2 \right) ^\tfrac{-1}{\gamma - 1} Parameters ---------- Ma : array Mach number, :math:`\Ma`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- der_rhoo_rho : array Derivative of stagnation density ratio, :math:`\DMa(\rho_0/\rho)`. """ return _restore_shape(fort_der_from_Ma.rhoo_rho, (Ma,ga)) def der_V_cpTo_from_Ma(Ma, ga): r"""Derivative of normalised velocity by Mach number. The derivative of :func:`compflow.V_cpTo_from_Ma` with respect to Mach number. .. math:: \DMa\left(\frac{V}{\sqrt{c_p T_0}}\right) = {\sqrt{\gamma -1}} \left(1 + \frac{\gamma - 1}{2} \Ma^2 \right)^{-\tfrac{3}{2}} Parameters ---------- Ma : array Mach number, :math:`\Ma`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- der_V_cpTo : array Derivative of normalised velocity, :math:`\DMa(V/\sqrt{c_p T_0})`. """ return _restore_shape(fort_der_from_Ma.v_cpto, (Ma,ga)) def der_mcpTo_APo_from_Ma(Ma, ga): r"""Derivative of normalised mass flow by Mach number. The derivative of :func:`compflow.mcpTo_APo_from_Ma` with respect to Mach number. .. math:: \DMa\left(\frac{\dot{m}\sqrt{c_p T_0}}{A p_0} \right)= \frac{\gamma}{\sqrt{\gamma -1}} \left(1 - \frac{\frac{\gamma + 1}{2} \Ma^2} {1 + \frac{\gamma - 1}{2} \Ma^2 } \right) \left(1 + \frac{\gamma - 1}{2} \Ma^2 \right) ^{-\tfrac{1}{2}\tfrac{\gamma + 1}{\gamma - 1}} Parameters ---------- Ma : array Mach number, :math:`\Ma`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- der_mcpTo_APo : array Derivative of normalised mass flow, :math:`\DMa({\dot{m}\sqrt{c_pT_0}}/{Ap_0})`. """ return _restore_shape(fort_der_from_Ma.mcpto_apo, (Ma,ga)) def der_mcpTo_AP_from_Ma(Ma, ga): r"""Derivative of static normalised mass flow by Mach number. The derivative of :func:`compflow.mcpTo_AP_from_Ma` with respect to Mach number. .. math:: \DMa\left(\frac{\dot{m}\sqrt{c_p T_0}}{A p} \right)= \frac{\gamma}{\sqrt{\gamma -1}} \Big(1 + (\gamma - 1) \Ma^2 \Big) \left(1 + \frac{\gamma - 1}{2} \Ma^2 \right)^{-\tfrac{1}{2}} Parameters ---------- Ma : array Mach number, :math:`\Ma`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- der_mcpTo_AP : array Derivative of static pressure variant of normalised mass flow, :math:`\DMa({\dot{m}\sqrt{c_p T_0}}/{A p})`. """ return _restore_shape(fort_der_from_Ma.mcpto_ap, (Ma,ga)) def der_A_Acrit_from_Ma(Ma, ga): r"""Derivative of choking area ratio by Mach number. The derivative of :func:`compflow.A_Acrit_from_Ma` with respect to Mach number. Parameters ---------- Ma : array Mach number, :math:`\Ma`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- der_A_Acrit : array Derivative of ratio of area to choking area, :math:`\DMa(A/A_*)`. """ return _restore_shape(fort_der_from_Ma.a_acrit, (Ma,ga)) def der_Mash_from_Ma(Ma, ga): r"""Derivative of post-shock Mach number by Mach number. The derivative of :func:`compflow.Mash_from_Ma` with respect to Mach number. Parameters ---------- Ma : array Mach number, :math:`\Ma`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- der_Mash : array Derivative of post-shock Mach number, :math:`\DMa(\Ma_\mathrm{sh})`. """ return _restore_shape(fort_der_from_Ma.mash, (Ma,ga)) def der_Posh_Po_from_Ma(Ma, ga): r"""Derivative of shock pressure ratio by Mach number. The derivative of :func:`compflow.Posh_Po_from_Ma` with respect to Mach number. Parameters ---------- Ma : array Mach number, :math:`\Ma`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- der_Posh_Po : array Derivative of shock stagnation pressure ratio, :math:`\DMa(p_{0\mathrm{sh}}/p_0)`. """ return _restore_shape(fort_der_from_Ma.posh_po, (Ma,ga))
27.211829
115
0.577769
"""This module wraps the fortran backend.""" import numpy as np import compflow_fort_from_Ma as fort_from_Ma import compflow_fort_der_from_Ma as fort_der_from_Ma import compflow_fort_to_Ma as fort_to_Ma def _restore_shape(func, args): """Call a function and restore output to same shape as first argument.""" shape = np.shape(args[0]) if shape == (): return(func(*args)[0]) elif len(shape) == 1: return(func(*args)) else: return(func(*args).reshape(shape, order='F')) # Functions from Ma def To_T_from_Ma(Ma, ga): r"""Stagnation temperature ratio as function of Mach number. .. math:: \frac{T_0}{T} = 1 + \frac{\gamma - 1}{2} \Ma^2 Parameters ---------- Ma : array Mach number, :math:`\Ma`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- To_T : array Stagnation temperature ratio, :math:`T_0/T`. """ return _restore_shape(fort_from_Ma.to_t, (Ma,ga)) def Po_P_from_Ma(Ma,ga): r"""Stagnation pressure ratio as function of Mach number. .. math:: \frac{p_0}{p} = \left(1 + \frac{\gamma - 1}{2} \Ma^2 \right) ^\tfrac{\gamma}{\gamma - 1} Parameters ---------- Ma : array Mach number, :math:`\Ma`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- Po_P : array Stagnation pressure ratio, :math:`p_0/p`. """ return _restore_shape(fort_from_Ma.po_p, (Ma,ga)) def rhoo_rho_from_Ma(Ma,ga): r"""Stagnation density ratio as function of Mach number. .. math:: \frac{\rho_0}{\rho} = \left(1 + \frac{\gamma - 1}{2} \Ma^2 \right) ^\tfrac{1}{\gamma - 1} Parameters ---------- Ma : array Mach number, :math:`\Ma`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- rhoo_rho : array Stagnation density ratio, :math:`\rho_0/\rho`. """ return _restore_shape(fort_from_Ma.rhoo_rho, (Ma,ga)) def V_cpTo_from_Ma(Ma,ga): r"""Normalised velocity as function of Mach number. .. math:: \frac{V}{\sqrt{c_p T_0}} = \sqrt{\gamma -1}\, \Ma \left(1 + \frac{\gamma - 1}{2} \Ma^2 \right)^{-\tfrac{1}{2}} Parameters ---------- Ma : array Mach number, :math:`\Ma`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- V_cpTo : array Normalised velocity, :math:`V/\sqrt{c_p T_0}`. """ return _restore_shape(fort_from_Ma.v_cpto, (Ma,ga)) def mcpTo_APo_from_Ma(Ma,ga): r"""Normalised mass flow as function of Mach number. .. math:: \frac{\dot{m}\sqrt{c_p T_0}}{A p_0} = \frac{\gamma}{\sqrt{\gamma -1}}\, \Ma \left(1 + \frac{\gamma - 1}{2} \Ma^2 \right) ^{-\tfrac{1}{2}\tfrac{\gamma + 1}{\gamma - 1}} Parameters ---------- Ma : array Mach number, :math:`\Ma`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- mcpTo_APo : array Normalised mass flow, :math:`{\dot{m}\sqrt{c_p T_0}}/{A p_0}`. """ return _restore_shape(fort_from_Ma.mcpto_apo, (Ma,ga)) def mcpTo_AP_from_Ma(Ma,ga): r"""Static normalised mass flow as function of Mach number. .. math:: \frac{\dot{m}\sqrt{c_p T_0}}{A p} = \frac{\gamma}{\sqrt{\gamma -1}}\, \Ma \left(1 + \frac{\gamma - 1}{2} \Ma^2 \right) ^{\tfrac{1}{2}} Parameters ---------- Ma : array Mach number, :math:`\Ma`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- mcpTo_AP : array Static pressure variant of normalised mass flow, :math:`{\dot{m}\sqrt{c_p T_0}}/{A p}`. """ return _restore_shape(fort_from_Ma.mcpto_ap, (Ma,ga)) def A_Acrit_from_Ma(Ma,ga): r"""Ratio of area to choking area as function of Mach number. .. math:: \frac{A}{A_*} = \frac{1}{\Ma}\left[\frac{2}{\gamma +1} \left(1 + \frac{\gamma - 1}{2} \Ma^2 \right)\right] ^{\tfrac{1}{2}\tfrac{\gamma + 1}{\gamma - 1}} Parameters ---------- Ma : array Mach number, :math:`\Ma`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- A_Acrit : array Ratio of area to choking area, :math:`A/A_*`. """ return _restore_shape(fort_from_Ma.a_acrit, (Ma,ga)) def Mash_from_Ma(Ma,ga): r"""Post-shock Mach number as function of Mach number. .. math:: \Ma_\mathrm{sh} = \left(\frac{1 + \frac{\gamma - 1}{2} \Ma^2} {\gamma \Ma^2 - \frac{\gamma - 1}{2}} \right)^{\tfrac{1}{2}} Parameters ---------- Ma : array Mach number, :math:`\Ma`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- Mash : array Post-shock Mach number, :math:`\Ma_\mathrm{sh}`. """ return _restore_shape(fort_from_Ma.mash, (Ma,ga)) def Posh_Po_from_Ma(Ma,ga): r"""Shock stagnation pressure ratio as function of Mach number. .. math:: \frac{p_{0\mathrm{sh}}}{p_0} = \left( \frac{\frac{\gamma + 1}{2}\Ma^2}{1 + \frac{\gamma - 1}{2} \Ma^2} \right)^{\tfrac{\gamma}{\gamma-1}} \left( \frac{2 \gamma }{\gamma + 1} \Ma^2 - \frac{\gamma - 1}{\gamma + 1} \right)^{\tfrac{-1}{\gamma -1}} Parameters ---------- Ma : array Mach number, :math:`\Ma`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- Posh_Po : array Shock stagnation pressure ratio, :math:`p_{0\mathrm{sh}}/p_0`. """ return _restore_shape(fort_from_Ma.posh_po, (Ma,ga)) # Inversions to Ma def Ma_from_To_T(To_T, ga): r"""Mach number as function of stagnation temperature ratio. The inverse of :func:`compflow.To_T_from_Ma`, which permits a direct analytical solution. .. math:: \Ma = \sqrt{\frac{2}{\gamma - 1} \left[\frac{T_0}{T} - 1\right]} Returns `NaN` if input data is not physically possible, where :math:`{T_0}/{T}<1`. Parameters ---------- To_T : array Stagnation temperature ratio, :math:`T_0/T`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- Ma : array Mach number, :math:`\Ma`. """ return _restore_shape(fort_to_Ma.to_t, (To_T, ga)) def Ma_from_Po_P(Po_P, ga): r"""Mach number as function of stagnation pressure ratio. The inverse of :func:`compflow.Po_P_from_Ma`, which permits a direct analytical solution. .. math:: \Ma = \sqrt{ \frac{2}{\gamma - 1}\left[\left(\frac{p_0}{p}\right) ^\tfrac{\gamma - 1}{\gamma} - 1\right]} Returns `NaN` if input data is not physically possible, where :math:`{p_0}/{p}<1`. Parameters ---------- Po_P : array Stagnation pressure ratio, :math:`p_0/p`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- Ma : array Mach number, :math:`\Ma`. """ return _restore_shape(fort_to_Ma.po_p, (Po_P, ga)) def Ma_from_rhoo_rho(rhoo_rho, ga): r"""Mach number as function of stagnation density ratio. The inverse of :func:`compflow.rhoo_rho_from_Ma`, which permits a direct analytical solution. .. math:: \Ma = \sqrt{ \frac{2}{\gamma - 1}\left[\left(\frac{\rho_0}{\rho}\right) ^{\gamma - 1} - 1\right]} Returns `NaN` if input data is not physically possible, where :math:`{\rho_0}/{\rho}<1`. Parameters ---------- rhoo_rho : array Stagnation density ratio, :math:`\rho_0/\rho`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- Ma : array Mach number, :math:`\Ma`. """ return _restore_shape(fort_to_Ma.rhoo_rho, (rhoo_rho, ga)) def Ma_from_V_cpTo(V_cpTo, ga): r"""Mach number as function of normalised velocity. Inverse of :func:`compflow.V_cpTo_from_Ma`, which permits a direct analytical solution. .. math:: \Ma = \sqrt{\frac{1}{\gamma-1}\left[ \frac{\left(\frac{V}{\sqrt{c_p T_0}}\right)^2} {1 - \frac{1}{2}\left(\frac{V}{\sqrt{c_p T_0}}\right)^2} \right]} Returns `NaN` if input data is not physically possible, where :math:`V/\sqrt{c_pT_0} < 0` or :math:`V/\sqrt{c_pT_0} > \sqrt{2}`. Parameters ---------- V_cpTo : array Normalised velocity, :math:`V/\sqrt{c_p T_0}`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- Ma : array Mach number, :math:`\Ma`. """ return _restore_shape(fort_to_Ma.v_cpto, (V_cpTo, ga)) def Ma_from_mcpTo_APo(mcpTo_APo, ga, sup=False): r"""Mach number as function of normalised mass flow. The inverse of :func:`compflow.mcpTo_APo_from_Ma`, which at a given value of :math:`{\dot{m}\sqrt{c_p T_0}}/{A p_0}` must be solved iteratively for :math:`\Ma` using Newton's method. .. math:: \frac{\dot{m}\sqrt{c_p T_0}}{A p_0} = \frac{\gamma}{\sqrt{\gamma -1}}\, \Ma \left(1 + \frac{\gamma - 1}{2} \Ma^2 \right) ^{-\tfrac{1}{2}\tfrac{\gamma + 1}{\gamma - 1}} For each :math:`{\dot{m}\sqrt{c_p T_0}}/{A p_0}`, there are two possible values of :math:`\Ma`. Return the subsonic solution with :math:`\Ma\le 1` by default; the supersonic solution with :math:`\Ma>`` is retrived by setting the parameter `sup=True`. Returns `NaN` if input data is not physically possible, where :math:`{\dot{m}\sqrt{c_p T_0}}/{A p_0} < 0`. The normalised mass flow reaches a maximum at the sonic velocity :math:`\Ma=1`. Input data above the maximum value correspond to choking --- also return `NaN` in this case. Parameters ---------- mcpTo_APo : array Normalised mass flow, :math:`{\dot{m}\sqrt{c_p T_0}}/{A p_0}`. ga : float Ratio of specific heats, :math:`\gamma`. sup : bool, default False If true, return the supersonic solution, otherwise the subsonic solution. Returns ------- Ma : array Mach number, :math:`\Ma`. """ return _restore_shape(fort_to_Ma.mcpto_apo, (mcpTo_APo, ga, sup)) def Ma_from_mcpTo_AP(mcpTo_AP, ga): r"""Mach number as function of static normalised mass flow. The inverse of :func:`compflow.mcpTo_AP_from_Ma`, which at a given value of :math:`{\dot{m}\sqrt{c_p T_0}}/{A p}` must be solved iteratively for :math:`\Ma` using Newton's method. .. math:: \frac{\dot{m}\sqrt{c_p T_0}}{A p} = \frac{\gamma}{\sqrt{\gamma -1}}\, \Ma \left(1 + \frac{\gamma - 1}{2} \Ma^2 \right) ^{\tfrac{1}{2}} Returns `NaN` if input data is not physically possible, where :math:`{\dot{m}\sqrt{c_p T_0}}/{A p} < 0`. Parameters ---------- mcpTo_AP : array Static normalised mass flow, :math:`{\dot{m}\sqrt{c_p T_0}}/{A p}`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- Ma : array Mach number, :math:`\Ma`. """ return _restore_shape(fort_to_Ma.mcpto_ap, (mcpTo_AP, ga)) def Ma_from_A_Acrit(A_Acrit, ga): r"""Mach number as function of area to choking area ratio. The inverse of :func:`compflow.A_Acrit_from_Ma`, which at a given value of :math:`A/A_*` must be solved iteratively for :math:`\Ma` using Newton's method. .. math:: \frac{A}{A_*} = \frac{1}{\Ma}\left[ \frac{2}{\gamma +1} \left(1 + \frac{\gamma - 1}{2} \Ma^2 \right) \right]^{\tfrac{1}{2}\tfrac{\gamma + 1}{\gamma - 1}} Returns `NaN` if input data is not physically possible, where :math:`A/A_* < 1`. Parameters ---------- A_Acrit : array Ratio of area to choking area, :math:`A/A_*`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- Ma : array Mach number, :math:`\Ma`. """ return _restore_shape(fort_to_Ma.a_acrit, (A_Acrit, ga)) def Ma_from_Mash(Mash, ga): r"""Mach number as function of post-shock Mach number. The inverse of :func:`compflow.Mash_from_Ma`, which at a given value of :math:`\Ma_\mathrm{sh}` must be solved iteratively for :math:`\Ma` using Newton's method. .. math:: \Ma_\mathrm{sh} = \left( \frac{1 + \frac{\gamma - 1}{2} \Ma^2} {\gamma \Ma^2 - \frac{\gamma - 1}{2}} \right)^{\tfrac{1}{2}} Returns `NaN` if input data is not physically possible, where :math:`\Ma_\mathrm{sh}>1` or :math:`\Ma_\mathrm{sh}<0`. Parameters ---------- Mash : array Post-shock Mach number, :math:`\Ma_\mathrm{sh}`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- Ma : array Mach number, :math:`\Ma`. """ return _restore_shape(fort_to_Ma.mash, (Mash, ga)) def Ma_from_Posh_Po(Posh_Po, ga): r"""Mach number as function of shock stagnation pressure ratio. The inverse of :func:`compflow.Posh_Po_from_Ma`, which at a given value of :math:`p_{0\mathrm{sh}}/p_0` must be solved iteratively for :math:`\Ma` using Newton's method. .. math:: \frac{p_{0\mathrm{sh}}}{p_0} = \left(\frac{\frac{\gamma+1}{2}\Ma^2}{1+\frac{\gamma-1}{2}\Ma^2}\right) ^{\tfrac{\gamma}{\gamma-1}} \left(\frac{2\gamma}{\gamma+1}\Ma^2-\frac{\gamma-1}{\gamma+1}\right) ^{\tfrac{-1}{\gamma -1}} Returns `NaN` if input data is not physically possible, where :math:`p_{0\mathrm{sh}}/p_0 > 1` or :math:`p_{0\mathrm{sh}}/p_0 < 0`. Parameters ---------- Posh_Po : array Shock stagnation pressure ratio, :math:`p_{0\mathrm{sh}}/p_0`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- Ma : array Mach number, :math:`\Ma`. """ return _restore_shape(fort_to_Ma.posh_po, (Posh_Po, ga)) # Derivatives from Ma def der_To_T_from_Ma(Ma, ga): r"""Derivative of stagnation temperature ratio by Mach number. The derivative of :func:`compflow.To_T_from_Ma` with respect to Mach number. .. math:: \frac{\D}{\D\Ma}\left(\frac{T_0}{T}\right) = \left(\gamma - 1\right)\Ma Parameters ---------- Ma : array Mach number, :math:`\Ma`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- der_To_T : array Derivative of stagnation temperature ratio, :math:`\DMa(T_0/T)`. """ return _restore_shape(fort_der_from_Ma.to_t, (Ma,ga)) def der_Po_P_from_Ma(Ma, ga): r"""Derivative of stagnation pressure ratio by Mach number. The derivative of :func:`compflow.Po_P_from_Ma` with respect to Mach number. .. math:: \DMa\left(\frac{p_0}{p}\right) = \gamma \Ma \left(1 + \frac{\gamma - 1}{2} \Ma^2 \right) ^\tfrac{1}{\gamma - 1} Parameters ---------- Ma : array Mach number, :math:`\Ma`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- der_Po_P : array Derivative of stagnation pressure ratio, :math:`\DMa(p_0/p)`. """ return _restore_shape(fort_der_from_Ma.po_p, (Ma,ga)) def der_rhoo_rho_from_Ma(Ma,ga): r"""Derivative of stagnation density ratio by Mach number. The derivative of :func:`compflow.rhoo_rho_from_Ma` with respect to Mach number. .. math:: \DMa\left(\frac{\rho_0}{\rho}\right) = \Ma\left(1 + \frac{\gamma - 1}{2} \Ma^2 \right) ^\tfrac{-1}{\gamma - 1} Parameters ---------- Ma : array Mach number, :math:`\Ma`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- der_rhoo_rho : array Derivative of stagnation density ratio, :math:`\DMa(\rho_0/\rho)`. """ return _restore_shape(fort_der_from_Ma.rhoo_rho, (Ma,ga)) def der_V_cpTo_from_Ma(Ma, ga): r"""Derivative of normalised velocity by Mach number. The derivative of :func:`compflow.V_cpTo_from_Ma` with respect to Mach number. .. math:: \DMa\left(\frac{V}{\sqrt{c_p T_0}}\right) = {\sqrt{\gamma -1}} \left(1 + \frac{\gamma - 1}{2} \Ma^2 \right)^{-\tfrac{3}{2}} Parameters ---------- Ma : array Mach number, :math:`\Ma`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- der_V_cpTo : array Derivative of normalised velocity, :math:`\DMa(V/\sqrt{c_p T_0})`. """ return _restore_shape(fort_der_from_Ma.v_cpto, (Ma,ga)) def der_mcpTo_APo_from_Ma(Ma, ga): r"""Derivative of normalised mass flow by Mach number. The derivative of :func:`compflow.mcpTo_APo_from_Ma` with respect to Mach number. .. math:: \DMa\left(\frac{\dot{m}\sqrt{c_p T_0}}{A p_0} \right)= \frac{\gamma}{\sqrt{\gamma -1}} \left(1 - \frac{\frac{\gamma + 1}{2} \Ma^2} {1 + \frac{\gamma - 1}{2} \Ma^2 } \right) \left(1 + \frac{\gamma - 1}{2} \Ma^2 \right) ^{-\tfrac{1}{2}\tfrac{\gamma + 1}{\gamma - 1}} Parameters ---------- Ma : array Mach number, :math:`\Ma`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- der_mcpTo_APo : array Derivative of normalised mass flow, :math:`\DMa({\dot{m}\sqrt{c_pT_0}}/{Ap_0})`. """ return _restore_shape(fort_der_from_Ma.mcpto_apo, (Ma,ga)) def der_mcpTo_AP_from_Ma(Ma, ga): r"""Derivative of static normalised mass flow by Mach number. The derivative of :func:`compflow.mcpTo_AP_from_Ma` with respect to Mach number. .. math:: \DMa\left(\frac{\dot{m}\sqrt{c_p T_0}}{A p} \right)= \frac{\gamma}{\sqrt{\gamma -1}} \Big(1 + (\gamma - 1) \Ma^2 \Big) \left(1 + \frac{\gamma - 1}{2} \Ma^2 \right)^{-\tfrac{1}{2}} Parameters ---------- Ma : array Mach number, :math:`\Ma`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- der_mcpTo_AP : array Derivative of static pressure variant of normalised mass flow, :math:`\DMa({\dot{m}\sqrt{c_p T_0}}/{A p})`. """ return _restore_shape(fort_der_from_Ma.mcpto_ap, (Ma,ga)) def der_A_Acrit_from_Ma(Ma, ga): r"""Derivative of choking area ratio by Mach number. The derivative of :func:`compflow.A_Acrit_from_Ma` with respect to Mach number. Parameters ---------- Ma : array Mach number, :math:`\Ma`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- der_A_Acrit : array Derivative of ratio of area to choking area, :math:`\DMa(A/A_*)`. """ return _restore_shape(fort_der_from_Ma.a_acrit, (Ma,ga)) def der_Mash_from_Ma(Ma, ga): r"""Derivative of post-shock Mach number by Mach number. The derivative of :func:`compflow.Mash_from_Ma` with respect to Mach number. Parameters ---------- Ma : array Mach number, :math:`\Ma`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- der_Mash : array Derivative of post-shock Mach number, :math:`\DMa(\Ma_\mathrm{sh})`. """ return _restore_shape(fort_der_from_Ma.mash, (Ma,ga)) def der_Posh_Po_from_Ma(Ma, ga): r"""Derivative of shock pressure ratio by Mach number. The derivative of :func:`compflow.Posh_Po_from_Ma` with respect to Mach number. Parameters ---------- Ma : array Mach number, :math:`\Ma`. ga : float Ratio of specific heats, :math:`\gamma`. Returns ------- der_Posh_Po : array Derivative of shock stagnation pressure ratio, :math:`\DMa(p_{0\mathrm{sh}}/p_0)`. """ return _restore_shape(fort_der_from_Ma.posh_po, (Ma,ga))
0
0
0
ed0b665e5274119fc4253441bc0c65ee3ffef274
7,378
py
Python
userbot/plugins/ping.py
aksr-aashish/FIREXUSERBOT
dff0b7bf028cb27779626ce523402346cc990402
[ "MIT" ]
null
null
null
userbot/plugins/ping.py
aksr-aashish/FIREXUSERBOT
dff0b7bf028cb27779626ce523402346cc990402
[ "MIT" ]
1
2022-01-09T11:35:06.000Z
2022-01-09T11:35:06.000Z
userbot/plugins/ping.py
aksr-aashish/FIREXUSERBOT
dff0b7bf028cb27779626ce523402346cc990402
[ "MIT" ]
null
null
null
import asyncio import datetime import os from .. import ALIVE_NAME from ..cmdhelp import CmdHelp from ..utils import admin_cmd, edit_or_reply, sudo_cmd from . import * DEFAULTUSER = str(ALIVE_NAME) if ALIVE_NAME else "eviral User" eviral = borg.uid eviral_IMG = os.environ.get( "PING_PIC", "https://te.legra.ph/file/a59da36828333262c9848.jpg" ) start = datetime.datetime.now() end = datetime.datetime.now() ms = (end - start).microseconds / 1000 @bot.on(admin_cmd(pattern=f"hbping$", outgoing=True)) @bot.on(sudo_cmd(pattern='hbping$', allow_sudo=True)) @bot.on(admin_cmd(pattern="ping$", outgoing=True)) @bot.on(sudo_cmd(pattern="ping$", allow_sudo=True)) CmdHelp("ping").add_command( "ping", None, "Shows you the ping speed of server" ).add_command( "hbping", None, "Shows you the ping speed of server with an animation" ).add_type( "Official" ).add()
82.898876
410
0.197343
import asyncio import datetime import os from .. import ALIVE_NAME from ..cmdhelp import CmdHelp from ..utils import admin_cmd, edit_or_reply, sudo_cmd from . import * DEFAULTUSER = str(ALIVE_NAME) if ALIVE_NAME else "eviral User" eviral = borg.uid eviral_IMG = os.environ.get( "PING_PIC", "https://te.legra.ph/file/a59da36828333262c9848.jpg" ) start = datetime.datetime.now() end = datetime.datetime.now() ms = (end - start).microseconds / 1000 @bot.on(admin_cmd(pattern=f"hbping$", outgoing=True)) @bot.on(sudo_cmd(pattern='hbping$', allow_sudo=True)) async def _(event): if event.fwd_from: return animation_interval = 0.2 animation_ttl = range(26) await edit_or_reply(event, "ping....") animation_chars = [ "⬛⬛⬛⬛⬛⬛⬛⬛⬛", "⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛", "⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛", "⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ ", "⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ ", "⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛⬛‎📶‎📶⬛⬛", "⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛⬛‎📶‎📶⬛⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛", "⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛⬛‎📶‎📶⬛⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶⬛⬛⬛⬛⬛‎📶⬛", "⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛⬛‎📶‎📶⬛⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶⬛⬛⬛⬛⬛‎📶⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛", "⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛⬛‎📶‎📶⬛⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶⬛⬛⬛⬛⬛‎📶⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛‎📶⬛⬛⬛⬛⬛‎📶⬛", "⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛⬛‎📶‎📶⬛⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶⬛⬛⬛⬛⬛‎📶⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛‎📶⬛⬛⬛⬛⬛‎📶⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛", "⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛⬛‎📶‎📶⬛⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶⬛⬛⬛⬛⬛‎📶⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛‎📶⬛⬛⬛⬛⬛‎📶⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛", "⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛⬛‎📶‎📶⬛⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶⬛⬛⬛⬛⬛‎📶⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛‎📶⬛⬛⬛⬛⬛‎📶⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛⬛⬛⬛⬛⬛‎📶⬛⬛", "⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛⬛‎📶‎📶⬛⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶⬛⬛⬛⬛⬛‎📶⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛‎📶⬛⬛⬛⬛⬛‎📶⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛⬛⬛⬛⬛⬛‎📶⬛⬛ \n⬛⬛⬛⬛⬛‎📶⬛⬛⬛", "⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛⬛‎📶‎📶⬛⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶⬛⬛⬛⬛⬛‎📶⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛‎📶⬛⬛⬛⬛⬛‎📶⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛⬛⬛⬛⬛⬛‎📶⬛⬛ \n⬛⬛⬛⬛⬛‎📶⬛⬛⬛ \n⬛⬛⬛⬛‎📶⬛⬛⬛⬛", "⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛⬛‎📶‎📶⬛⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶⬛⬛⬛⬛⬛‎📶⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛‎📶⬛⬛⬛⬛⬛‎📶⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛⬛⬛⬛⬛⬛‎📶⬛⬛ \n⬛⬛⬛⬛⬛‎📶⬛⬛⬛ \n⬛⬛⬛⬛‎📶⬛⬛⬛⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛", "⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛⬛‎📶‎📶⬛⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶⬛⬛⬛⬛⬛‎📶⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛‎📶⬛⬛⬛⬛⬛‎📶⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛⬛⬛⬛⬛⬛‎📶⬛⬛ \n⬛⬛⬛⬛⬛‎📶⬛⬛⬛ \n⬛⬛⬛⬛‎📶⬛⬛⬛⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛", "⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛⬛‎📶‎📶⬛⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶⬛⬛⬛⬛⬛‎📶⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛‎📶⬛⬛⬛⬛⬛‎📶⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛⬛⬛⬛⬛⬛‎📶⬛⬛ \n⬛⬛⬛⬛⬛‎📶⬛⬛⬛ \n⬛⬛⬛⬛‎📶⬛⬛⬛⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛⬛‎📶‎📶‎📶‎📶‎📶⬛⬛", "⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛⬛‎📶‎📶⬛⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶⬛⬛⬛⬛⬛‎📶⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛‎📶⬛⬛⬛⬛⬛‎📶⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛⬛⬛⬛⬛⬛‎📶⬛⬛ \n⬛⬛⬛⬛⬛‎📶⬛⬛⬛ \n⬛⬛⬛⬛‎📶⬛⬛⬛⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛⬛‎📶‎📶‎📶‎📶‎📶⬛⬛ \n⬛‎📶⬛⬛⬛⬛⬛‎📶⬛", "⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛⬛‎📶‎📶⬛⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶⬛⬛⬛⬛⬛‎📶⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛‎📶⬛⬛⬛⬛⬛‎📶⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛⬛⬛⬛⬛⬛‎📶⬛⬛ \n⬛⬛⬛⬛⬛‎📶⬛⬛⬛ \n⬛⬛⬛⬛‎📶⬛⬛⬛⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛⬛‎📶‎📶‎📶‎📶‎📶⬛⬛ \n⬛‎📶⬛⬛⬛⬛⬛‎📶⬛ \n⬛‎📶⬛⬛⬛⬛⬛‎📶⬛", "⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛⬛‎📶‎📶⬛⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶⬛⬛⬛⬛⬛‎📶⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛‎📶⬛⬛⬛⬛⬛‎📶⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛⬛⬛⬛⬛⬛‎📶⬛⬛ \n⬛⬛⬛⬛⬛‎📶⬛⬛⬛ \n⬛⬛⬛⬛‎📶⬛⬛⬛⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛⬛‎📶‎📶‎📶‎📶‎📶⬛⬛ \n⬛‎📶⬛⬛⬛⬛⬛‎📶⬛ \n⬛‎📶⬛⬛⬛⬛⬛‎📶⬛ \n⬛‎📶⬛‎📶⬛⬛⬛‎📶⬛", "⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛⬛‎📶‎📶⬛⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶⬛⬛⬛⬛⬛‎📶⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛‎📶⬛⬛⬛⬛⬛‎📶⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛⬛⬛⬛⬛⬛‎📶⬛⬛ \n⬛⬛⬛⬛⬛‎📶⬛⬛⬛ \n⬛⬛⬛⬛‎📶⬛⬛⬛⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛⬛‎📶‎📶‎📶‎📶‎📶⬛⬛ \n⬛‎📶⬛⬛⬛⬛⬛‎📶⬛ \n⬛‎📶⬛⬛⬛⬛⬛‎📶⬛ \n⬛‎📶⬛‎📶⬛⬛⬛‎📶⬛ \n⬛⬛‎📶‎📶⬛⬛‎📶⬛⬛", "⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛⬛‎📶‎📶⬛⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶⬛⬛⬛⬛⬛‎📶⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛‎📶⬛⬛⬛⬛⬛‎📶⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛⬛⬛⬛⬛⬛‎📶⬛⬛ \n⬛⬛⬛⬛⬛‎📶⬛⬛⬛ \n⬛⬛⬛⬛‎📶⬛⬛⬛⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛⬛‎📶‎📶‎📶‎📶‎📶⬛⬛ \n⬛‎📶⬛⬛⬛⬛⬛‎📶⬛ \n⬛‎📶⬛⬛⬛⬛⬛‎📶⬛ \n⬛‎📶⬛‎📶⬛⬛⬛‎📶⬛ \n⬛⬛‎📶‎📶⬛⬛‎📶⬛⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛", "⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛⬛‎📶‎📶⬛⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶⬛⬛⬛⬛⬛‎📶⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛‎📶⬛⬛⬛⬛⬛‎📶⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛⬛⬛⬛⬛⬛‎📶⬛⬛ \n⬛⬛⬛⬛⬛‎📶⬛⬛⬛ \n⬛⬛⬛⬛‎📶⬛⬛⬛⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛⬛‎📶‎📶‎📶‎📶‎📶⬛⬛ \n⬛‎📶⬛⬛⬛⬛⬛‎📶⬛ \n⬛‎📶⬛⬛⬛⬛⬛‎📶⬛ \n⬛‎📶⬛‎📶⬛⬛⬛‎📶⬛ \n⬛⬛‎📶‎📶⬛⬛‎📶⬛⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶⬛‎📶‎📶‎📶‎📶‎📶⬛", "⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛⬛‎📶‎📶⬛⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶⬛⬛⬛⬛⬛‎📶⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛‎📶⬛⬛⬛⬛⬛‎📶⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛⬛⬛⬛⬛⬛‎📶⬛⬛ \n⬛⬛⬛⬛⬛‎📶⬛⬛⬛ \n⬛⬛⬛⬛‎📶⬛⬛⬛⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛⬛‎📶‎📶‎📶‎📶‎📶⬛⬛ \n⬛‎📶⬛⬛⬛⬛⬛‎📶⬛ \n⬛‎📶⬛⬛⬛⬛⬛‎📶⬛ \n⬛‎📶⬛‎📶⬛⬛⬛‎📶⬛ \n⬛⬛‎📶‎📶⬛⬛‎📶⬛⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶⬛‎📶‎📶‎📶‎📶‎📶⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛", "⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛‎📶⬛⬛‎📶⬛ \n⬛⬛⬛⬛⬛‎📶‎📶⬛⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶⬛⬛⬛⬛⬛‎📶⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛‎📶⬛⬛⬛⬛⬛‎📶⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛⬛⬛⬛⬛⬛‎📶⬛⬛ \n⬛⬛⬛⬛⬛‎📶⬛⬛⬛ \n⬛⬛⬛⬛‎📶⬛⬛⬛⬛ \n⬛‎📶‎📶‎📶‎📶‎📶‎📶‎📶⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛⬛‎📶‎📶‎📶‎📶‎📶⬛⬛ \n⬛‎📶⬛⬛⬛⬛⬛‎📶⬛ \n⬛‎📶⬛⬛⬛⬛⬛‎📶⬛ \n⬛‎📶⬛‎📶⬛⬛⬛‎📶⬛ \n⬛⬛‎📶‎📶⬛⬛‎📶⬛⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n⬛‎📶⬛‎📶‎📶‎📶‎📶‎📶⬛ \n⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n \n My 🇵 🇮 🇳 🇬 Is : Calculating...", ] for i in animation_ttl: await asyncio.sleep(animation_interval) await event.edit(animation_chars[i % 26]) await edit_or_reply( event, "‎‎‎‎‎‎‎‎‎⬛⬛⬛⬛⬛⬛⬛⬛⬛\n⬛📶📶📶📶📶📶📶⬛\n⬛⬛⬛⬛📶⬛⬛📶⬛\n⬛⬛⬛⬛📶⬛⬛📶⬛\n⬛⬛⬛⬛📶⬛⬛📶⬛\n⬛⬛⬛⬛⬛📶📶⬛⬛\n⬛⬛⬛⬛⬛⬛⬛⬛⬛\n⬛⬛📶📶📶📶📶⬛⬛\n⬛📶⬛⬛⬛⬛⬛📶⬛\n⬛📶⬛⬛⬛⬛⬛📶⬛\n⬛📶⬛⬛⬛⬛⬛📶⬛\n⬛⬛📶📶📶📶📶⬛⬛\n⬛⬛⬛⬛⬛⬛⬛⬛⬛\n⬛📶📶📶📶📶📶📶⬛\n⬛⬛⬛⬛⬛⬛📶⬛⬛\n⬛⬛⬛⬛⬛📶⬛⬛⬛\n⬛⬛⬛⬛📶⬛⬛⬛⬛\n⬛📶📶📶📶📶📶📶⬛\n⬛⬛⬛⬛⬛⬛⬛⬛⬛\n⬛⬛📶📶📶📶📶⬛⬛\n⬛📶⬛⬛⬛⬛⬛📶⬛\n⬛📶⬛⬛⬛⬛⬛📶⬛\n⬛📶⬛📶⬛⬛⬛📶⬛\n⬛⬛📶📶⬛⬛📶⬛⬛\n⬛⬛⬛⬛⬛⬛⬛⬛⬛\n⬛📶⬛📶📶📶📶📶⬛\n⬛⬛⬛⬛⬛⬛⬛⬛⬛ \n‎‎‎‎‎‎‎‎‎ \n \n My 🇵 🇮 🇳 🇬 Is : {} ms".format( ms ), ) @bot.on(admin_cmd(pattern="ping$", outgoing=True)) @bot.on(sudo_cmd(pattern="ping$", allow_sudo=True)) async def _(event): if event.fwd_from: return event = await edit_or_reply(event, "**(❛ ᑭσɳց ❜!**") if eviral_IMG: eviral_caption = ( f"**💞Pong💞**\n\n 🔸️ {ms}\n 🔹️ **𝙼𝚢** **𝙼𝚊𝚜𝚝𝚎𝚛** ~『{eviral_mention}』" ) await event.client.send_file(event.chat_id, eviral_IMG, caption=eviral_caption) await event.delete() CmdHelp("ping").add_command( "ping", None, "Shows you the ping speed of server" ).add_command( "hbping", None, "Shows you the ping speed of server with an animation" ).add_type( "Official" ).add()
16,123
0
44
ee73b60e03568dfaebc7bf0d67bd3f2349a997e1
965
py
Python
collate_info.py
justincely/hstcos_dark_data
a42042ae7babc73c7feb5058186ea4fa42e9c0be
[ "BSD-3-Clause" ]
null
null
null
collate_info.py
justincely/hstcos_dark_data
a42042ae7babc73c7feb5058186ea4fa42e9c0be
[ "BSD-3-Clause" ]
null
null
null
collate_info.py
justincely/hstcos_dark_data
a42042ae7babc73c7feb5058186ea4fa42e9c0be
[ "BSD-3-Clause" ]
null
null
null
import glob import json from copy import deepcopy import numpy as np from astropy.table import Table from astropy.time import Time from cos_monitoring import dark from cos_monitoring.dark import solar import pdb solar.get_solar_data("./") data = Table.read('solar_flux.txt', format='ascii') all_info = [] for item in glob.glob("new/*_corrtag_c.fits") + glob.glob('out/*_corrtag_?.fits'): print(item) for item in dark.pull_orbital_info(item, step=700): try: darkrate = item['dark'] except KeyError: continue t = Time(item['date'], format='decimalyear').mjd index = np.argmin(abs(data['col1'] - t)) item['fsol'] = float(data['col2'][index]) print(item) #if darkrate < 2e-6: # continue all_info.append(deepcopy(item)) with open('./orbital_info.json', 'w') as out: json.dump(all_info, out, sort_keys=False, indent=4, separators=(',', ': '))
20.978261
82
0.634197
import glob import json from copy import deepcopy import numpy as np from astropy.table import Table from astropy.time import Time from cos_monitoring import dark from cos_monitoring.dark import solar import pdb solar.get_solar_data("./") data = Table.read('solar_flux.txt', format='ascii') all_info = [] for item in glob.glob("new/*_corrtag_c.fits") + glob.glob('out/*_corrtag_?.fits'): print(item) for item in dark.pull_orbital_info(item, step=700): try: darkrate = item['dark'] except KeyError: continue t = Time(item['date'], format='decimalyear').mjd index = np.argmin(abs(data['col1'] - t)) item['fsol'] = float(data['col2'][index]) print(item) #if darkrate < 2e-6: # continue all_info.append(deepcopy(item)) with open('./orbital_info.json', 'w') as out: json.dump(all_info, out, sort_keys=False, indent=4, separators=(',', ': '))
0
0
0
c7607658161aabf0b09b3024ff70cf6f856fe8d3
2,225
py
Python
noisysystem_temp/Analysis/PositivePhiAnalysis.py
Tom271/InteractingParticleSystems
1cfc8b228077c2465e71d82cc288d713d3755392
[ "MIT" ]
1
2019-10-22T19:48:22.000Z
2019-10-22T19:48:22.000Z
noisysystem_temp/Analysis/PositivePhiAnalysis.py
Tom271/InteractingParticleSystems
1cfc8b228077c2465e71d82cc288d713d3755392
[ "MIT" ]
1
2019-10-22T21:32:19.000Z
2019-10-22T21:32:19.000Z
noisysystem_temp/Analysis/PositivePhiAnalysis.py
Tom271/InteractingParticleSystems
1cfc8b228077c2465e71d82cc288d713d3755392
[ "MIT" ]
1
2019-10-22T19:49:38.000Z
2019-10-22T19:49:38.000Z
from matplotlib import rc import matplotlib.pyplot as plt import os import seaborn as sns from particle.plotting import ( plot_averaged_convergence_from_clusters, plot_averaged_avg_vel, plot_avg_vel, ) sns.set(style="white", context="talk") search_parameters = { # "particle_count": 480, # "G": "Smooth", # "scaling": "Local", "phi": "Bump", # # "initial_dist_x": "one_cluster", "initial_dist_v": "pos_const_near_0", "T_end": 2000.0, # "dt": 0.01, # "D": 1.0, # "option": "numba", } if os.name == "nt": rc("text", usetex=True) # I only have TeX on Windows :( os.chdir("D:/InteractingParticleSystems/noisysystem_temp") elif os.name == "posix": os.chdir("/Volumes/Extreme SSD/InteractingParticleSystems/noisysystem_temp") yaml_path = "Experiments/positive_phi_no_of_clusters_high_noise_bump" fn = "_switch_" logged = False include_traj = True fig, [ax1, ax2] = plt.subplots(1, 2, figsize=(15, 5), sharex=True) ax2 = plot_avg_vel(ax2, search_parameters, logx=logged, exp_yaml=yaml_path) ax2 = plot_averaged_avg_vel(ax2, search_parameters, logx=logged, exp_yaml=yaml_path) ax1 = plot_averaged_convergence_from_clusters( ax1, search_parameters, yaml_path, logx=logged ) ax1.plot([0, search_parameters["T_end"]], [7.5, 7.5], "k--", alpha=0.2) ax2.set(xlabel="Time", ylabel=r"$M^N(t) $") # ax2.legend() # fig.savefig(f"img/PositivePhiClusters{fn}logged.jpg", dpi=300) # plt.tight_layout() plt.subplots_adjust(left=0.07, right=0.97, bottom=0.15, top=0.9, wspace=0.23) plt.show() # logged = False # fig, [ax1, ax2] = plt.subplots(1, 2, figsize=(14, 5), sharex=True) # ax2 = plot_avg_vel(ax2, search_parameters, logx=logged, exp_yaml=yaml_path) # ax2 = plot_averaged_avg_vel(ax2, search_parameters, logx=logged, exp_yaml=yaml_path) # # ax1 = plot_averaged_convergence_from_clusters( # ax1, search_parameters, yaml_path, logx=logged # ) # # ax1.plot([0, search_parameters["T_end"]], [7.5, 7.5], "k--", alpha=0.2) # ax2.set(xlabel="Time", ylabel=r"$M^N(t) $") # # ax2.legend() # fig.savefig(f"img/PositivePhiClusters{fn}linear.jpg", dpi=300) # # plt.tight_layout() # plt.subplots_adjust(left=0.07, right=0.97, bottom=0.15, top=0.9, wspace=0.23) # plt.show()
33.208955
86
0.698876
from matplotlib import rc import matplotlib.pyplot as plt import os import seaborn as sns from particle.plotting import ( plot_averaged_convergence_from_clusters, plot_averaged_avg_vel, plot_avg_vel, ) sns.set(style="white", context="talk") search_parameters = { # "particle_count": 480, # "G": "Smooth", # "scaling": "Local", "phi": "Bump", # # "initial_dist_x": "one_cluster", "initial_dist_v": "pos_const_near_0", "T_end": 2000.0, # "dt": 0.01, # "D": 1.0, # "option": "numba", } if os.name == "nt": rc("text", usetex=True) # I only have TeX on Windows :( os.chdir("D:/InteractingParticleSystems/noisysystem_temp") elif os.name == "posix": os.chdir("/Volumes/Extreme SSD/InteractingParticleSystems/noisysystem_temp") yaml_path = "Experiments/positive_phi_no_of_clusters_high_noise_bump" fn = "_switch_" logged = False include_traj = True fig, [ax1, ax2] = plt.subplots(1, 2, figsize=(15, 5), sharex=True) ax2 = plot_avg_vel(ax2, search_parameters, logx=logged, exp_yaml=yaml_path) ax2 = plot_averaged_avg_vel(ax2, search_parameters, logx=logged, exp_yaml=yaml_path) ax1 = plot_averaged_convergence_from_clusters( ax1, search_parameters, yaml_path, logx=logged ) ax1.plot([0, search_parameters["T_end"]], [7.5, 7.5], "k--", alpha=0.2) ax2.set(xlabel="Time", ylabel=r"$M^N(t) $") # ax2.legend() # fig.savefig(f"img/PositivePhiClusters{fn}logged.jpg", dpi=300) # plt.tight_layout() plt.subplots_adjust(left=0.07, right=0.97, bottom=0.15, top=0.9, wspace=0.23) plt.show() # logged = False # fig, [ax1, ax2] = plt.subplots(1, 2, figsize=(14, 5), sharex=True) # ax2 = plot_avg_vel(ax2, search_parameters, logx=logged, exp_yaml=yaml_path) # ax2 = plot_averaged_avg_vel(ax2, search_parameters, logx=logged, exp_yaml=yaml_path) # # ax1 = plot_averaged_convergence_from_clusters( # ax1, search_parameters, yaml_path, logx=logged # ) # # ax1.plot([0, search_parameters["T_end"]], [7.5, 7.5], "k--", alpha=0.2) # ax2.set(xlabel="Time", ylabel=r"$M^N(t) $") # # ax2.legend() # fig.savefig(f"img/PositivePhiClusters{fn}linear.jpg", dpi=300) # # plt.tight_layout() # plt.subplots_adjust(left=0.07, right=0.97, bottom=0.15, top=0.9, wspace=0.23) # plt.show()
0
0
0
d3eb3879f29d5a988281b193f192ff03806bb576
8,310
py
Python
codemetrics/vega.py
Wonshtrum/codemetrics
ae82a742aeedc7fc1edf39a817edb3d41ea3887d
[ "MIT" ]
6
2019-08-07T09:11:35.000Z
2021-06-22T10:58:33.000Z
codemetrics/vega.py
Wonshtrum/codemetrics
ae82a742aeedc7fc1edf39a817edb3d41ea3887d
[ "MIT" ]
11
2019-09-25T22:04:44.000Z
2022-03-23T03:06:05.000Z
codemetrics/vega.py
Wonshtrum/codemetrics
ae82a742aeedc7fc1edf39a817edb3d41ea3887d
[ "MIT" ]
4
2019-02-23T15:25:35.000Z
2021-06-22T12:11:20.000Z
#!/usr/bin/env python # -*- coding: utf-8 -*- import json import os import typing import pandas as pd from . import internals def build_hierarchy( data: pd.DataFrame, get_parent=os.path.dirname, root: str = "", max_iter: int = 100, col_name: typing.Optional[str] = None, ) -> pd.DataFrame: """Build a hierarchy from a data set and a get_parent relationship. The output frame adds 2 columns in front: id and parent. Both are numerical where the parent id identifies the id of the parent as returned by the get_parent function. The id of the root element is set to 0 and the parent is set to np.nan. Args: data: data containing the leaves of the tree. get_parent: function returning the parent of an element. root: expected root of the hierarchy. max_iter: maximum number of iterations. col_name: name of the column to use as input (default to column 0). Returns: pandas.DataFrame with the columns id, parent and col_name. The parent value identifies the id of the parent in the hierarchy where the id 0 is the root. The columns other than col_name are discarded. """ assert data.ndim == 2, "DataFrame-like object expected" if not col_name: col_name = data.columns[0] parent = get_parent.__name__ df = data[[col_name]] frames = [] seen = {root} root_actually_seen = False count = 0 for _ in range(max_iter): df.loc[:, parent] = df[col_name].apply(get_parent) if root in df[parent].values: root_actually_seen = True df["id"] = range(count, count + len(df)) count += len(df) frames.append(df) df = ( df.loc[~df[parent].isin(seen), [parent]] .drop_duplicates() .rename(columns={parent: col_name}) ) seen.update(df[col_name]) if len(df) == 0: frames.append( pd.DataFrame(data={"id": [count], col_name: [root], parent: [None]}) ) break if not root_actually_seen: msg = f"cannot find root {root} in input frame" internals.log.error(msg) raise ValueError(msg) df = pd.concat(frames, sort=False).drop_duplicates() df["id"] = len(df) - df["id"] - 1 assert col_name is not None y_name = col_name + "_y" merged = pd.merge(df, df, left_on=col_name, right_on=parent, how="right")[ [y_name, "id_y", "id_x"] ].rename(columns={y_name: col_name, "id_y": "id", "id_x": "parent"}) return ( merged[["id", "parent", col_name]].sort_values(by="id").reset_index(drop=True) ) def _vis_generic( df: pd.DataFrame, size_column: str, color_column: str, colorscheme: str, height: int = 300, width: int = 400, ) -> dict: """Factors common parts of vis_xxx functions. Internal. See vis_hot_spots or vis_ages for documentation. """ if len(df) <= 0: raise ValueError("dataframe is empty") if size_column not in df.columns: raise ValueError(f"{size_column} not found in columns") if color_column not in df.columns: raise ValueError(f"{color_column} not found in columns") hierarchy = build_hierarchy(df[["path"]], root="") hierarchy = ( pd.merge(hierarchy, df, left_on="path", right_on="path", how="left") .rename(columns={size_column: "size", color_column: "intensity"}) .sort_values(by="id") ) hierarchy.loc[:, ["size", "intensity"]] = hierarchy[["size", "intensity"]].fillna(0) json_values = hierarchy.to_json(orient="records") signal = ( "datum.path + " f"(datum.intensity ? ', ' + datum.intensity + ' {color_column}' : '') + " f"(datum.size ? ', ' + datum.size + ' {size_column}' : '')" ) desc: typing.Dict[str, typing.Any] = { "$schema": "https://vega.github.io/schema/vega/v4.json", "width": width, "height": height, "padding": 5, "autosize": "none", "data": [ { "name": "tree", # 'values': ..., "transform": [ {"type": "stratify", "key": "id", "parentKey": "parent"}, { "type": "pack", "field": "size", "sort": {"field": "value", "order": "descending"}, "size": [{"signal": "width"}, {"signal": "height"}], }, ], } ], "scales": [ { "name": "color", "type": "linear", "domain": {"data": "tree", "field": "intensity"}, "range": {"scheme": colorscheme}, "domainMin": 0, } ], "marks": [ { "type": "symbol", "from": {"data": "tree"}, "encode": { "enter": { "shape": {"value": "circle"}, "fill": {"scale": "color", "field": "intensity"}, "tooltip": {"signal": signal}, }, "update": { "x": {"field": "x"}, "y": {"field": "y"}, "size": {"signal": "4 * datum.r * datum.r"}, "stroke": {"value": "white"}, "strokeWidth": {"value": 0.5}, }, "hover": { "stroke": {"value": "black"}, "strokeWidth": {"value": 2}, }, }, } ], } desc["data"][0]["values"] = json.loads(json_values) return desc def vis_hot_spots( df: pd.DataFrame, height: int = 300, width: int = 400, size_column: str = "lines", color_column: str = "changes", colorscheme: str = "yelloworangered", ) -> dict: """Convert get_hot_spots output to a json vega dict. Args: df: input data returned by :func:`codemetrics.get_hot_spots` height: vertical size of the figure. width: horizontal size of the figure. size_column: column that drives the size of the circles. color_column: column that drives the color intensity of the circles. colorscheme: color scheme. See https://vega.github.io/vega/docs/schemes/ Returns: Vega description suitable to be use with Altair. Example:: import codemetrics as cm from altair.vega.v4 import Vega hspots = cm.get_hot_spots(loc_df, log_df) desc = cm.vega.vis_hot_spots(hspots) Vega(desc) # display the visualization inline in you notebook. See also: `Vega circle pack example`_ .. _Vega circle pack example: https://vega.github.io/editor/#/examples/vega/circle-packing """ return _vis_generic( df, size_column=size_column, color_column=color_column, colorscheme=colorscheme, width=width, height=height, ) def vis_ages( df: pd.DataFrame, height: int = 300, width: int = 400, colorscheme: str = "greenblue", ) -> dict: """Convert get_ages output to a json vega dict. Args: df: input data returned by :func:`codemetrics.get_ages` height: vertical size of the figure. width: horizontal size of the figure. colorscheme: color scheme. See https://vega.github.io/vega/docs/schemes/ Returns: Vega description suitable to be use with Altair. Example:: import codemetrics as cm from altair.vega.v4 import Vega ages = cm.get_ages(loc_df, log_df) desc = cm.vega.vis_ages(ages) Vega(desc) # display the visualization inline in you notebook. See also: `Vega circle pack example`_ .. _Vega circle pack example: https://vega.github.io/editor/#/examples/vega/circle-packing """ df["days"] = df["age"].astype("int32") df = df.rename(columns={"code": "loc"}) return _vis_generic( df, size_column="loc", color_column="days", colorscheme=colorscheme, width=width, height=height, )
31.83908
94
0.541637
#!/usr/bin/env python # -*- coding: utf-8 -*- import json import os import typing import pandas as pd from . import internals def build_hierarchy( data: pd.DataFrame, get_parent=os.path.dirname, root: str = "", max_iter: int = 100, col_name: typing.Optional[str] = None, ) -> pd.DataFrame: """Build a hierarchy from a data set and a get_parent relationship. The output frame adds 2 columns in front: id and parent. Both are numerical where the parent id identifies the id of the parent as returned by the get_parent function. The id of the root element is set to 0 and the parent is set to np.nan. Args: data: data containing the leaves of the tree. get_parent: function returning the parent of an element. root: expected root of the hierarchy. max_iter: maximum number of iterations. col_name: name of the column to use as input (default to column 0). Returns: pandas.DataFrame with the columns id, parent and col_name. The parent value identifies the id of the parent in the hierarchy where the id 0 is the root. The columns other than col_name are discarded. """ assert data.ndim == 2, "DataFrame-like object expected" if not col_name: col_name = data.columns[0] parent = get_parent.__name__ df = data[[col_name]] frames = [] seen = {root} root_actually_seen = False count = 0 for _ in range(max_iter): df.loc[:, parent] = df[col_name].apply(get_parent) if root in df[parent].values: root_actually_seen = True df["id"] = range(count, count + len(df)) count += len(df) frames.append(df) df = ( df.loc[~df[parent].isin(seen), [parent]] .drop_duplicates() .rename(columns={parent: col_name}) ) seen.update(df[col_name]) if len(df) == 0: frames.append( pd.DataFrame(data={"id": [count], col_name: [root], parent: [None]}) ) break if not root_actually_seen: msg = f"cannot find root {root} in input frame" internals.log.error(msg) raise ValueError(msg) df = pd.concat(frames, sort=False).drop_duplicates() df["id"] = len(df) - df["id"] - 1 assert col_name is not None y_name = col_name + "_y" merged = pd.merge(df, df, left_on=col_name, right_on=parent, how="right")[ [y_name, "id_y", "id_x"] ].rename(columns={y_name: col_name, "id_y": "id", "id_x": "parent"}) return ( merged[["id", "parent", col_name]].sort_values(by="id").reset_index(drop=True) ) def _vis_generic( df: pd.DataFrame, size_column: str, color_column: str, colorscheme: str, height: int = 300, width: int = 400, ) -> dict: """Factors common parts of vis_xxx functions. Internal. See vis_hot_spots or vis_ages for documentation. """ if len(df) <= 0: raise ValueError("dataframe is empty") if size_column not in df.columns: raise ValueError(f"{size_column} not found in columns") if color_column not in df.columns: raise ValueError(f"{color_column} not found in columns") hierarchy = build_hierarchy(df[["path"]], root="") hierarchy = ( pd.merge(hierarchy, df, left_on="path", right_on="path", how="left") .rename(columns={size_column: "size", color_column: "intensity"}) .sort_values(by="id") ) hierarchy.loc[:, ["size", "intensity"]] = hierarchy[["size", "intensity"]].fillna(0) json_values = hierarchy.to_json(orient="records") signal = ( "datum.path + " f"(datum.intensity ? ', ' + datum.intensity + ' {color_column}' : '') + " f"(datum.size ? ', ' + datum.size + ' {size_column}' : '')" ) desc: typing.Dict[str, typing.Any] = { "$schema": "https://vega.github.io/schema/vega/v4.json", "width": width, "height": height, "padding": 5, "autosize": "none", "data": [ { "name": "tree", # 'values': ..., "transform": [ {"type": "stratify", "key": "id", "parentKey": "parent"}, { "type": "pack", "field": "size", "sort": {"field": "value", "order": "descending"}, "size": [{"signal": "width"}, {"signal": "height"}], }, ], } ], "scales": [ { "name": "color", "type": "linear", "domain": {"data": "tree", "field": "intensity"}, "range": {"scheme": colorscheme}, "domainMin": 0, } ], "marks": [ { "type": "symbol", "from": {"data": "tree"}, "encode": { "enter": { "shape": {"value": "circle"}, "fill": {"scale": "color", "field": "intensity"}, "tooltip": {"signal": signal}, }, "update": { "x": {"field": "x"}, "y": {"field": "y"}, "size": {"signal": "4 * datum.r * datum.r"}, "stroke": {"value": "white"}, "strokeWidth": {"value": 0.5}, }, "hover": { "stroke": {"value": "black"}, "strokeWidth": {"value": 2}, }, }, } ], } desc["data"][0]["values"] = json.loads(json_values) return desc def vis_hot_spots( df: pd.DataFrame, height: int = 300, width: int = 400, size_column: str = "lines", color_column: str = "changes", colorscheme: str = "yelloworangered", ) -> dict: """Convert get_hot_spots output to a json vega dict. Args: df: input data returned by :func:`codemetrics.get_hot_spots` height: vertical size of the figure. width: horizontal size of the figure. size_column: column that drives the size of the circles. color_column: column that drives the color intensity of the circles. colorscheme: color scheme. See https://vega.github.io/vega/docs/schemes/ Returns: Vega description suitable to be use with Altair. Example:: import codemetrics as cm from altair.vega.v4 import Vega hspots = cm.get_hot_spots(loc_df, log_df) desc = cm.vega.vis_hot_spots(hspots) Vega(desc) # display the visualization inline in you notebook. See also: `Vega circle pack example`_ .. _Vega circle pack example: https://vega.github.io/editor/#/examples/vega/circle-packing """ return _vis_generic( df, size_column=size_column, color_column=color_column, colorscheme=colorscheme, width=width, height=height, ) def vis_ages( df: pd.DataFrame, height: int = 300, width: int = 400, colorscheme: str = "greenblue", ) -> dict: """Convert get_ages output to a json vega dict. Args: df: input data returned by :func:`codemetrics.get_ages` height: vertical size of the figure. width: horizontal size of the figure. colorscheme: color scheme. See https://vega.github.io/vega/docs/schemes/ Returns: Vega description suitable to be use with Altair. Example:: import codemetrics as cm from altair.vega.v4 import Vega ages = cm.get_ages(loc_df, log_df) desc = cm.vega.vis_ages(ages) Vega(desc) # display the visualization inline in you notebook. See also: `Vega circle pack example`_ .. _Vega circle pack example: https://vega.github.io/editor/#/examples/vega/circle-packing """ df["days"] = df["age"].astype("int32") df = df.rename(columns={"code": "loc"}) return _vis_generic( df, size_column="loc", color_column="days", colorscheme=colorscheme, width=width, height=height, )
0
0
0
565de340dea6258a5a31b85b0559d11b832043c5
1,414
py
Python
master/Alarm_dialog.py
chingchan1996/Distributed-Resource-Monitoring-System
d85a74616307bf5ba7ae5b363512c1fd487143a5
[ "Apache-2.0" ]
null
null
null
master/Alarm_dialog.py
chingchan1996/Distributed-Resource-Monitoring-System
d85a74616307bf5ba7ae5b363512c1fd487143a5
[ "Apache-2.0" ]
null
null
null
master/Alarm_dialog.py
chingchan1996/Distributed-Resource-Monitoring-System
d85a74616307bf5ba7ae5b363512c1fd487143a5
[ "Apache-2.0" ]
null
null
null
from Alarm_dialog_ui import Alarm_Ui_Dialog from PyQt5 import QtCore, QtWidgets, QtGui import threading import sys if __name__ == '__main__': app = QtWidgets.QApplication(sys.argv) form = AlarmDialog("Slave3", "CPU overloading", "CPU usage > 95%", "50%", "2017/11/25 12:00") form.setWindowTitle('Alarm') form.show() sys.exit(app.exec_())
36.25641
104
0.662659
from Alarm_dialog_ui import Alarm_Ui_Dialog from PyQt5 import QtCore, QtWidgets, QtGui import threading import sys class AlarmDialog(QtWidgets.QMainWindow): def __init__(self, hostname, problem, threshold, current, time): QtWidgets.QWidget.__init__(self) self.ui = Alarm_Ui_Dialog() self.ui.setupUi(self) self.ui.tx_hostname.setText(hostname) self.ui.tx_problem.setText(problem) self.ui.tx_threshold.setText(threshold) self.ui.tx_currentstatus.setText(current) self.ui.tx_timestamp.setText(time) class AlarmGuiThread(threading.Thread): def __init__(self, hostname, problem, threshold, current, time): threading.Thread.__init__(self) self.hostname = hostname self.problem = problem self.threshold = threshold self.current_status = current self.time = time def run(self): app = QtWidgets.QApplication(sys.argv) form = AlarmDialog(self.hostname, self.problem, self.threshold, self.current_status, self.time) form.setWindowTitle('Alarm window') form.show() app.exec_() if __name__ == '__main__': app = QtWidgets.QApplication(sys.argv) form = AlarmDialog("Slave3", "CPU overloading", "CPU usage > 95%", "50%", "2017/11/25 12:00") form.setWindowTitle('Alarm') form.show() sys.exit(app.exec_())
875
38
133
927d226a221c8200e40efd7d6c8599a8cd204230
2,725
py
Python
zaqar/storage/sqlalchemy/migration/alembic_migrations/versions/001_liberty.py
mail2nsrajesh/zaqar
a68a03a228732050b33c2a7f35d1caa9f3467718
[ "Apache-2.0" ]
97
2015-01-02T09:35:23.000Z
2022-03-25T00:38:45.000Z
zaqar/storage/sqlalchemy/migration/alembic_migrations/versions/001_liberty.py
mail2nsrajesh/zaqar
a68a03a228732050b33c2a7f35d1caa9f3467718
[ "Apache-2.0" ]
5
2019-08-14T06:46:03.000Z
2021-12-13T20:01:25.000Z
zaqar/storage/sqlalchemy/migration/alembic_migrations/versions/001_liberty.py
mail2nsrajesh/zaqar
a68a03a228732050b33c2a7f35d1caa9f3467718
[ "Apache-2.0" ]
44
2015-01-28T03:01:28.000Z
2021-05-13T18:55:19.000Z
# Copyright 2016 OpenStack Foundation. # # 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. """Liberty release Revision ID: 001 Revises: None Create Date: 2015-09-13 20:46:25.783444 """ # revision identifiers, used by Alembic. revision = '001' down_revision = None from alembic import op import sqlalchemy as sa MYSQL_ENGINE = 'InnoDB' MYSQL_CHARSET = 'utf8'
37.328767
71
0.540917
# Copyright 2016 OpenStack Foundation. # # 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. """Liberty release Revision ID: 001 Revises: None Create Date: 2015-09-13 20:46:25.783444 """ # revision identifiers, used by Alembic. revision = '001' down_revision = None from alembic import op import sqlalchemy as sa MYSQL_ENGINE = 'InnoDB' MYSQL_CHARSET = 'utf8' def upgrade(): op.create_table('Queues', sa.Column('id', sa.INTEGER, primary_key=True), sa.Column('project', sa.String(64)), sa.Column('name', sa.String(64)), sa.Column('metadata', sa.LargeBinary), sa.UniqueConstraint('project', 'name')) op.create_table('PoolGroup', sa.Column('name', sa.String(64), primary_key=True)) op.create_table('Pools', sa.Column('name', sa.String(64), primary_key=True), sa.Column('group', sa.String(64), sa.ForeignKey('PoolGroup.name', ondelete='CASCADE'), nullable=True), sa.Column('uri', sa.String(255), unique=True, nullable=False), sa.Column('weight', sa.INTEGER, nullable=False), sa.Column('options', sa.Text())) op.create_table('Flavors', sa.Column('name', sa.String(64), primary_key=True), sa.Column('project', sa.String(64)), sa.Column('pool_group', sa.String(64), sa.ForeignKey('PoolGroup.name', ondelete='CASCADE'), nullable=False), sa.Column('capabilities', sa.Text())) op.create_table('Catalogue', sa.Column('pool', sa.String(64), sa.ForeignKey('Pools.name', ondelete='CASCADE')), sa.Column('project', sa.String(64)), sa.Column('queue', sa.String(64), nullable=False), sa.UniqueConstraint('project', 'queue'))
1,842
0
23
8c996016d532556f72b8858fadfdec8cbc13fd3b
1,188
py
Python
article/models.py
hexa-yagnenok/myblog
ebba71516ce2ebb6b05fcb8c889a54924b9284c9
[ "MIT" ]
null
null
null
article/models.py
hexa-yagnenok/myblog
ebba71516ce2ebb6b05fcb8c889a54924b9284c9
[ "MIT" ]
null
null
null
article/models.py
hexa-yagnenok/myblog
ebba71516ce2ebb6b05fcb8c889a54924b9284c9
[ "MIT" ]
null
null
null
from django.db import models from ckeditor.fields import RichTextField # Create your models here.
47.52
112
0.768519
from django.db import models from ckeditor.fields import RichTextField # Create your models here. class Article(models.Model): author=models.ForeignKey("auth.User",on_delete=models.CASCADE) title = models.CharField(max_length=50,verbose_name= "Title") content=RichTextField(verbose_name="Content") created_date=models.DateTimeField(auto_now_add=True,verbose_name="Oluşturulma tarihi") article_image=models.FileField(blank=True,null=True,verbose_name="Image") def __str__(self): return self.title class Meta: ordering=['-created_date'] class Comment(models.Model): article = models.ForeignKey(Article,on_delete=models.CASCADE,verbose_name="Article",related_name="comments") comment_author=models.ForeignKey("auth.User",on_delete=models.CASCADE) comment_title=models.CharField(max_length=50,verbose_name="Comment") comment_content=models.CharField(max_length=200,verbose_name="Comment") comment_date=models.DateTimeField(auto_now_add=True,verbose_name="Created Date") def __str__(self): return self.comment_content # admin panelinde contentle gözükmesini sağlar class Meta: ordering=['-comment_date']
106
943
45
2ee0c3e1ef08b9ecf5b43f9f4cd90918f39395df
5,971
py
Python
lib/util.py
jhkennedy/processflow
c404bd3ad043fd6ae18d4f24d735777574faa660
[ "MIT" ]
null
null
null
lib/util.py
jhkennedy/processflow
c404bd3ad043fd6ae18d4f24d735777574faa660
[ "MIT" ]
null
null
null
lib/util.py
jhkennedy/processflow
c404bd3ad043fd6ae18d4f24d735777574faa660
[ "MIT" ]
null
null
null
import logging import sys import traceback import re import os import socket import jinja2 import json from shutil import rmtree from time import sleep from datetime import datetime from string import Formatter from lib.jobstatus import ReverseMap, JobStatus from mailer import Mailer from models import DataFile def print_line(line, event_list, ignore_text=False): """ Prints a message to either the console, the event_list, or the current event Parameters: line (str): The message to print event_list (EventList): the event list ignore_text (bool): should this be printed to the console if in text mode """ logging.info(line) if not ignore_text: now = datetime.now() timestr = '{hour}:{min}:{sec}'.format( hour=now.strftime('%H'), min=now.strftime('%M'), sec=now.strftime('%S')) msg = '{time}: {line}'.format( time=timestr, line=line) print msg sys.stdout.flush() def get_climo_output_files(input_path, start_year, end_year): """ Return a list of ncclimo climatologies from start_year to end_year Parameters: input_path (str): the directory to look in start_year (int): the first year of climos to add to the list end_year (int): the last year Returns: file_list (list(str)): A list of the climo files in the directory """ if not os.path.exists(input_path): return None contents = [s for s in os.listdir(input_path) if not os.path.isdir(s)] pattern = r'_{start:04d}\d\d_{end:04d}\d\d_climo\.nc'.format( start=start_year, end=end_year) return [x for x in contents if re.search(pattern=pattern, string=x)] def get_ts_output_files(input_path, var_list, start_year, end_year): """ Return a list of ncclimo timeseries files from a list of variables, start_year to end_year Parameters: input_path (str): the directory to look in var_list (list): a list of strings of variable names start_year (int): the first year of climos to add to the list end_year (int): the last year Returns: ts_list (list): A list of the ts files """ if not os.path.exists(input_path): return None contents = [s for s in os.listdir(input_path) if not os.path.isdir(s)] ts_list = list() for var in var_list: pattern = r'{var}_{start:04d}01_{end:04d}12\.nc'.format( var=var, start=start_year, end=end_year) for item in contents: if re.search(pattern, item): ts_list.append(item) break return ts_list def print_debug(e): """ Print an exceptions relavent information """ print '1', e.__doc__ print '2', sys.exc_info() print '3', sys.exc_info()[0] print '4', sys.exc_info()[1] print '5', traceback.tb_lineno(sys.exc_info()[2]) _, _, tb = sys.exc_info() print '6', traceback.print_tb(tb) def format_debug(e): """ Return a string of an exceptions relavent information """ _, _, tb = sys.exc_info() return """ 1: {doc} 2: {exec_info} 3: {exec_0} 4: {exec_1} 5: {lineno} 6: {stack} """.format( doc=e.__doc__, exec_info=sys.exc_info(), exec_0=sys.exc_info()[0], exec_1=sys.exc_info()[1], lineno=traceback.tb_lineno(sys.exc_info()[2]), stack=traceback.print_tb(tb)) def print_message(message, status='error'): """ Prints a message with either a green + or a red - Parameters: message (str): the message to print status (str): th""" if status == 'error': print colors.FAIL + '[-] ' + colors.ENDC + colors.BOLD + str(message) + colors.ENDC elif status == 'ok': print colors.OKGREEN + '[+] ' + colors.ENDC + str(message) def render(variables, input_path, output_path): """ Renders the jinja2 template from the input_path into the output_path using the variables from variables """ tail, head = os.path.split(input_path) template_path = os.path.abspath(tail) loader = jinja2.FileSystemLoader(searchpath=template_path) env = jinja2.Environment(loader=loader) template = env.get_template(head) outstr = template.render(variables) with open(output_path, 'a') as outfile: outfile.write(outstr) def create_symlink_dir(src_dir, src_list, dst): """ Create a directory, and fill it with symlinks to all the items in src_list Parameters: src_dir (str): the path to the source directory src_list (list): a list of strings of filenames dst (str): the path to the directory that should hold the symlinks """ if not src_list: return if not os.path.exists(dst): os.makedirs(dst) for src_file in src_list: if not src_file: continue source = os.path.join(src_dir, src_file) destination = os.path.join(dst, src_file) if os.path.lexists(destination): continue try: os.symlink(source, destination) except Exception as e: msg = format_debug(e) logging.error(msg)
30.156566
94
0.624016
import logging import sys import traceback import re import os import socket import jinja2 import json from shutil import rmtree from time import sleep from datetime import datetime from string import Formatter from lib.jobstatus import ReverseMap, JobStatus from mailer import Mailer from models import DataFile def print_line(line, event_list, ignore_text=False): """ Prints a message to either the console, the event_list, or the current event Parameters: line (str): The message to print event_list (EventList): the event list ignore_text (bool): should this be printed to the console if in text mode """ logging.info(line) if not ignore_text: now = datetime.now() timestr = '{hour}:{min}:{sec}'.format( hour=now.strftime('%H'), min=now.strftime('%M'), sec=now.strftime('%S')) msg = '{time}: {line}'.format( time=timestr, line=line) print msg sys.stdout.flush() def get_climo_output_files(input_path, start_year, end_year): """ Return a list of ncclimo climatologies from start_year to end_year Parameters: input_path (str): the directory to look in start_year (int): the first year of climos to add to the list end_year (int): the last year Returns: file_list (list(str)): A list of the climo files in the directory """ if not os.path.exists(input_path): return None contents = [s for s in os.listdir(input_path) if not os.path.isdir(s)] pattern = r'_{start:04d}\d\d_{end:04d}\d\d_climo\.nc'.format( start=start_year, end=end_year) return [x for x in contents if re.search(pattern=pattern, string=x)] def get_ts_output_files(input_path, var_list, start_year, end_year): """ Return a list of ncclimo timeseries files from a list of variables, start_year to end_year Parameters: input_path (str): the directory to look in var_list (list): a list of strings of variable names start_year (int): the first year of climos to add to the list end_year (int): the last year Returns: ts_list (list): A list of the ts files """ if not os.path.exists(input_path): return None contents = [s for s in os.listdir(input_path) if not os.path.isdir(s)] ts_list = list() for var in var_list: pattern = r'{var}_{start:04d}01_{end:04d}12\.nc'.format( var=var, start=start_year, end=end_year) for item in contents: if re.search(pattern, item): ts_list.append(item) break return ts_list def get_data_output_files(input_path, case, start_year, end_year): if not os.path.exists(input_path): return None contents = [s for s in os.listdir(input_path) if not os.path.isdir(s)] contents.sort() data_list = list() for year in range(start_year, end_year + 1): for month in range(1, 13): pattern = r'%s.*\.%04d-%02d.nc' % (case, year, month) for item in contents: if re.match(pattern, item): data_list.append(item) break return data_list def print_debug(e): """ Print an exceptions relavent information """ print '1', e.__doc__ print '2', sys.exc_info() print '3', sys.exc_info()[0] print '4', sys.exc_info()[1] print '5', traceback.tb_lineno(sys.exc_info()[2]) _, _, tb = sys.exc_info() print '6', traceback.print_tb(tb) def format_debug(e): """ Return a string of an exceptions relavent information """ _, _, tb = sys.exc_info() return """ 1: {doc} 2: {exec_info} 3: {exec_0} 4: {exec_1} 5: {lineno} 6: {stack} """.format( doc=e.__doc__, exec_info=sys.exc_info(), exec_0=sys.exc_info()[0], exec_1=sys.exc_info()[1], lineno=traceback.tb_lineno(sys.exc_info()[2]), stack=traceback.print_tb(tb)) class colors: HEADER = '\033[95m' OKBLUE = '\033[94m' OKGREEN = '\033[92m' WARNING = '\033[93m' FAIL = '\033[91m' ENDC = '\033[0m' BOLD = '\033[1m' UNDERLINE = '\033[4m' def print_message(message, status='error'): """ Prints a message with either a green + or a red - Parameters: message (str): the message to print status (str): th""" if status == 'error': print colors.FAIL + '[-] ' + colors.ENDC + colors.BOLD + str(message) + colors.ENDC elif status == 'ok': print colors.OKGREEN + '[+] ' + colors.ENDC + str(message) def render(variables, input_path, output_path): """ Renders the jinja2 template from the input_path into the output_path using the variables from variables """ tail, head = os.path.split(input_path) template_path = os.path.abspath(tail) loader = jinja2.FileSystemLoader(searchpath=template_path) env = jinja2.Environment(loader=loader) template = env.get_template(head) outstr = template.render(variables) with open(output_path, 'a') as outfile: outfile.write(outstr) def create_symlink_dir(src_dir, src_list, dst): """ Create a directory, and fill it with symlinks to all the items in src_list Parameters: src_dir (str): the path to the source directory src_list (list): a list of strings of filenames dst (str): the path to the directory that should hold the symlinks """ if not src_list: return if not os.path.exists(dst): os.makedirs(dst) for src_file in src_list: if not src_file: continue source = os.path.join(src_dir, src_file) destination = os.path.join(dst, src_file) if os.path.lexists(destination): continue try: os.symlink(source, destination) except Exception as e: msg = format_debug(e) logging.error(msg)
540
180
46
1030cc86d52100b1ce19fd96943c5c044fb57a72
8,258
py
Python
cogs/share.py
StefDuda01/Bot
3ffc318a52534e45e111875fb4e5fe2df3b35ce8
[ "MIT" ]
null
null
null
cogs/share.py
StefDuda01/Bot
3ffc318a52534e45e111875fb4e5fe2df3b35ce8
[ "MIT" ]
null
null
null
cogs/share.py
StefDuda01/Bot
3ffc318a52534e45e111875fb4e5fe2df3b35ce8
[ "MIT" ]
null
null
null
import discord from discord.ext import commands from discord.gateway import DiscordWebSocket import requests, os import json import subprocess import io import random import dotenv import aiomysql
33.844262
93
0.53875
import discord from discord.ext import commands from discord.gateway import DiscordWebSocket import requests, os import json import subprocess import io import random import dotenv import aiomysql class Share(commands.Cog): def __init__(self, bot): self.bot = bot self.staff_chat = self.bot.get_channel(int(os.environ["STAFF_CHAT"])) dotenv.load_dotenv(".env") self.host = os.getenv("DB_HOST") self.port = os.getenv("DB_PORT") self.db = os.getenv("DB_NAME") self.user = os.getenv("DB_USER") self.password = os.getenv("DB_PASSWORD") self.connection = bot.connection self.conection = None @commands.command() async def settings(self, ctx, key, value): f = open("settings.json", "r") jsonf = json.loads(f.read()) f.close() jsonf[key] = value f = open("settings.json", "w") f.write(json.dumps(jsonf)) await ctx.send("updated settings") @commands.command( name="share", alias=["send", "sendfile", "sendfiles", "upload", "uploadfile"], description="Upload a file", ) async def share(self, ctx): if len(ctx.message.attachments) == 0: await ctx.send("Please attach a file to share.") return file = ctx.message.attachments[0] c = self.bot.get_channel(int(838728591238758411)) cur = await self.connection.cursor() await cur.execute( f"INSERT into files (name, url) VALUES ('{file.filename}', '{file.url}')" ) await self.connection.commit() await ctx.send(f"File {file.filename} has been saved in our database!") await self.staff_chat.send( f"{ctx.author.mention} has shared a file: {file.filename}." ) @commands.command( name="download", alias=["get", "getfile", "getfiles"], description="Download a file", ) async def download(self, ctx, filename): cur = await self.connection.cursor() try: await cur.execute("SELECT * from files where name = '" + filename + "'") r = await cur.fetchall() await ctx.author.send(r[0][1]) except: await ctx.send("File not found. Try with a different file") await self.staff_chat.send( f"{ctx.author.mention} has attempted to download a file that does not exist." ) return await self.staff_chat.send( f"{ctx.author.mention} has downloaded **{filename}**." ) await ctx.send("File sent in DMs!") @commands.command() async def randomize(self, ctx, presence: int = None): if presence: await self.bot.change_presence( activity=discord.Game( name=[ "Copyrush 2022", "Games at school", "Destroy the school", "Fake the test", "CopyRush 2022 at school", "Copyrush 2022 in DAD", "#LaScuolaèDAD", "#DADistheway", "DAD > *", "Mario Kart con i banchi a rotelle", ][presence] ) ) return await ctx.send(":white_check_mark:") await ctx.send(":white_check_mark:") await self.bot.change_presence( activity=discord.Game( name=random.choice( [ "Copyrush 2022", "Games at school", "Destroy the school", "Fake the test", "CopyRush 2022 at school", "Copyrush 2022 in DAD", "#LaScuolaèDAD", "#DADistheway", "DAD > *", "Mario Kart con i banchi a rotelle", ] ) ) ) @commands.command( name="list", alias=["listfiles", "getfiles"], description="List all files stored with us", ) async def list(self, ctx): cur = await self.connection.cursor() await cur.execute("SELECT * from files") r = await cur.fetchall() total = "" for a in r: total += a[0] + "\n" emb = discord.Embed( title="Files", description=total, color=discord.Color.blue() ) await ctx.send(embed=emb) @commands.command(name="staff", alias=["team", "staffteam"]) async def staff(self, ctx): desc = "Here is a list of staff members:\n" for member in ( self.bot.get_guild(838727867428765766).get_role(884453174839230464).members ): desc += f"{member.mention}\n" emb = discord.Embed(title="Staff", description=desc) await ctx.send(embed=emb) @commands.command(alias=["del", "remove", "rm"], descriiption="Delete a file") async def delete(self, ctx, filename): # await ctx.defer(complete_hidden=True) if ( not ctx.author in self.bot.get_guild(838727867428765766) .get_role(884453174839230464) .members ): await ctx.send( 'You are not a staff member of "Il Baracchino Della Scuola".' ) return c = self.bot.get_channel(int(838728591238758411)) cur = await self.bot.connection.cursor() await cur.execute("DELETE FROM files WHERE name = '" + filename + "'") await ctx.send(f"File {filename} has been deleted.") await c.send( f"File {filename} no longer exists. Say thanks to {ctx.author.mention}!" ) await self.staff_chat.send( f"{ctx.author.mention} has deleted a file: {filename}." ) @commands.command( name="presence", alias=["status"], description="Change the bot's presence" ) async def presence(self, ctx, *, text): if ( not ctx.author in self.bot.get_guild(838727867428765766) .get_role(884453174839230464) .members ): await ctx.send( 'You are not a staff member of "Il Baracchino Della Scuola".' ) return await self.staff_chat.send( f"{ctx.author.mention} has changed the bot's presence to: {text}." ) await self.bot.change_presence(activity=discord.Game(name=text)) await ctx.send("Presence changed to " + text + ".") @commands.command(alias=["reboot"], description="Reboot the bot") async def restart(self, ctx): if ( not ctx.author in self.bot.get_guild(838727867428765766) .get_role(884453174839230464) .members ): await ctx.send( 'You are not a staff member of "Il Baracchino Della Scuola".' ) return await ctx.send("Restarting...") await self.staff_chat.send(f"{ctx.author.mention} has restarted the bot.") subprocess.call("python3 main.py", shell=True) self.bot.close() @commands.command(name="rename", alias=["ren"], description="Rename a file") async def rename(self, ctx, filename, newname): if ( not ctx.author in self.bot.get_guild(838727867428765766) .get_role(884453174839230464) .members ): await ctx.send( 'You are not a staff member of "Il Baracchino Della Scuola".' ) return c = self.bot.get_channel(int(838728591238758411)) cur = await self.bot.connection.cursor() await cur.execute(f"UPDATE files SET name='{newname}' where name='{filename}'") await c.send(f"Now you can download {filename} with .download {newname}") await ctx.send(f"File {filename} has been renamed to {newname}.") await c.send(f"{ctx.author.mention} renamed {filename} to {newname}.") def setup(bot): bot.add_cog(Share(bot))
6,811
1,204
46
f4aa9a6ca0730f8fd955fa36c1c422547825b170
3,519
py
Python
lino/utils/mldbc/fields.py
NewRGB/lino
43799e42107169ff173d3b8bc0324d5773471499
[ "BSD-2-Clause" ]
1
2019-11-13T19:38:50.000Z
2019-11-13T19:38:50.000Z
lino/utils/mldbc/fields.py
NewRGB/lino
43799e42107169ff173d3b8bc0324d5773471499
[ "BSD-2-Clause" ]
null
null
null
lino/utils/mldbc/fields.py
NewRGB/lino
43799e42107169ff173d3b8bc0324d5773471499
[ "BSD-2-Clause" ]
null
null
null
# -*- coding: UTF-8 -*- # Copyright 2012-2017 Rumma & Ko Ltd # License: BSD (see file COPYING for details) """Defines the babel field classes (:class:`BabelCharField` and :class:`BabelTextField`) and the :class:`LanguageField` class. **Babel fields** are fields which "generate" in the Django model a series of normal CharFields (or TextFields), one for each :attr:`lino.core.site.Site.language`. Example:: class Foo(models.Model): name = BabelCharField(_("Foo"), max_length=200) .. autosummary:: """ from __future__ import unicode_literals import six import logging logger = logging.getLogger(__name__) from django.conf import settings from django.db import models from django.utils.translation import ugettext_lazy as _ from django.utils.text import format_lazy from lino.core.fields import RichTextField LANGUAGE_CODE_MAX_LENGTH = 5 def contribute_to_class(field, cls, fieldclass, **kw): "Used by both :class:`BabelCharField` and :class:`BabelTextField` " if cls._meta.abstract: return kw.update(blank=True) if "__fake__" in repr(cls): # Used to test if we're creating a migration, in that case we don't want to add new fields, # As they're already detected during site startup. return for lang in settings.SITE.BABEL_LANGS: kw.update(verbose_name=format_lazy(u"{}{}", field.verbose_name, ' (' + lang.django_code + ')')) newfield = fieldclass(**kw) #~ newfield._lino_babel_field = True # used by dbtools.get_data_elems newfield._lino_babel_field = field.name newfield._babel_language = lang cls.add_to_class(six.text_type(field.name + '_' + lang.name), newfield) # we must convert the field name to six.text_type because lang.name is a newstr, and Django can raise a # TypeError: unorderable types: str() and <type 'str'> # when a model contains both Babelfields and fields with plain Py2 str names. class BabelCharField(models.CharField): """Define a variable number of `CharField` database fields, one for each language of your :attr:`lino.core.site.Site.languages`. See :ref:`mldbc`. """ class BabelTextField(RichTextField): """ Define a variable number of clones of the "master" field, one for each language . See :ref:`mldbc`. """ class LanguageField(models.CharField): """A field that lets the user select a language from the available :attr:`lino.core.site.Site.languages`. See also :meth:`lino.core.model.Model.get_print_language`. """
31.419643
111
0.674339
# -*- coding: UTF-8 -*- # Copyright 2012-2017 Rumma & Ko Ltd # License: BSD (see file COPYING for details) """Defines the babel field classes (:class:`BabelCharField` and :class:`BabelTextField`) and the :class:`LanguageField` class. **Babel fields** are fields which "generate" in the Django model a series of normal CharFields (or TextFields), one for each :attr:`lino.core.site.Site.language`. Example:: class Foo(models.Model): name = BabelCharField(_("Foo"), max_length=200) .. autosummary:: """ from __future__ import unicode_literals import six import logging logger = logging.getLogger(__name__) from django.conf import settings from django.db import models from django.utils.translation import ugettext_lazy as _ from django.utils.text import format_lazy from lino.core.fields import RichTextField LANGUAGE_CODE_MAX_LENGTH = 5 def contribute_to_class(field, cls, fieldclass, **kw): "Used by both :class:`BabelCharField` and :class:`BabelTextField` " if cls._meta.abstract: return kw.update(blank=True) if "__fake__" in repr(cls): # Used to test if we're creating a migration, in that case we don't want to add new fields, # As they're already detected during site startup. return for lang in settings.SITE.BABEL_LANGS: kw.update(verbose_name=format_lazy(u"{}{}", field.verbose_name, ' (' + lang.django_code + ')')) newfield = fieldclass(**kw) #~ newfield._lino_babel_field = True # used by dbtools.get_data_elems newfield._lino_babel_field = field.name newfield._babel_language = lang cls.add_to_class(six.text_type(field.name + '_' + lang.name), newfield) # we must convert the field name to six.text_type because lang.name is a newstr, and Django can raise a # TypeError: unorderable types: str() and <type 'str'> # when a model contains both Babelfields and fields with plain Py2 str names. class BabelCharField(models.CharField): """Define a variable number of `CharField` database fields, one for each language of your :attr:`lino.core.site.Site.languages`. See :ref:`mldbc`. """ def contribute_to_class(self, cls, name): super(BabelCharField, self).contribute_to_class(cls, name) contribute_to_class(self, cls, models.CharField, max_length=self.max_length) class BabelTextField(RichTextField): """ Define a variable number of clones of the "master" field, one for each language . See :ref:`mldbc`. """ def contribute_to_class(self, cls, name): super(BabelTextField, self).contribute_to_class(cls, name) contribute_to_class(self, cls, RichTextField, format=self.textfield_format) class LanguageField(models.CharField): """A field that lets the user select a language from the available :attr:`lino.core.site.Site.languages`. See also :meth:`lino.core.model.Model.get_print_language`. """ def __init__(self, *args, **kw): defaults = dict( verbose_name=_("Language"), # choices=list(settings.SITE.LANGUAGE_CHOICES), choices=settings.SITE.LANGUAGE_CHOICES, blank=True, # default=settings.SITE.get_default_language, #~ default=get_language, max_length=LANGUAGE_CODE_MAX_LENGTH, ) defaults.update(kw) models.CharField.__init__(self, *args, **defaults)
852
0
81
9adec4e977a6a1862dcf1dc6a136a4af18c39044
1,100
py
Python
2016/day02/day02-pt2.py
mcbor/advent_of_code_2016
14453b970d3e0f031ae6a66f2028652b6ed870dd
[ "MIT" ]
1
2016-12-17T10:53:22.000Z
2016-12-17T10:53:22.000Z
2016/day02/day02-pt2.py
mcbor/adventofcode
14453b970d3e0f031ae6a66f2028652b6ed870dd
[ "MIT" ]
null
null
null
2016/day02/day02-pt2.py
mcbor/adventofcode
14453b970d3e0f031ae6a66f2028652b6ed870dd
[ "MIT" ]
null
null
null
#!/usr/bin/env python3 # Advent of Code 2016 - Day 2, Part Two import sys from turtle import Vec2D keypad = [[None, None, '1', None, None], [None, '2', '3', '4', None], [ '5', '6', '7', '8', '9'], [None, 'A', 'B', 'C', None], [None, None, 'D', None, None]] moves = { 'U' : Vec2D(-1, 0), 'D' : Vec2D(+1, 0), 'L' : Vec2D( 0, -1), 'R' : Vec2D( 0, +1) } if __name__ == '__main__': sys.exit(main(sys.argv))
26.829268
67
0.48
#!/usr/bin/env python3 # Advent of Code 2016 - Day 2, Part Two import sys from turtle import Vec2D keypad = [[None, None, '1', None, None], [None, '2', '3', '4', None], [ '5', '6', '7', '8', '9'], [None, 'A', 'B', 'C', None], [None, None, 'D', None, None]] moves = { 'U' : Vec2D(-1, 0), 'D' : Vec2D(+1, 0), 'L' : Vec2D( 0, -1), 'R' : Vec2D( 0, +1) } def in_bounds(v): return all(0 <= d <= 4 for d in v) and vec2digit(v) is not None def vec2digit(v): return keypad[v[0]][v[1]] def main(argv): if len(sys.argv) < 2: print("Usage: {} puzzle.txt".format(argv[0])) return(1) position = Vec2D(2, 0) with open(argv[1]) as f: for line in f: for move in line.strip(): new_position = position + moves[move] if in_bounds(new_position): position = new_position print(str(vec2digit(position)), end='') print() return 0 if __name__ == '__main__': sys.exit(main(sys.argv))
518
0
77
49fab2ca3160ce1caa8610ee409dddbe3785c054
91
py
Python
tests/data/directive/conf.py
t4ngo/sphinxcontrib-multilatex
cb63e0ef5d3059aa9db892abfd550a60a1e650a1
[ "Apache-2.0" ]
1
2016-09-10T10:16:03.000Z
2016-09-10T10:16:03.000Z
tests/data/directive/conf.py
t4ngo/sphinxcontrib-multilatex
cb63e0ef5d3059aa9db892abfd550a60a1e650a1
[ "Apache-2.0" ]
null
null
null
tests/data/directive/conf.py
t4ngo/sphinxcontrib-multilatex
cb63e0ef5d3059aa9db892abfd550a60a1e650a1
[ "Apache-2.0" ]
null
null
null
source_suffix = ".txt" master_doc = "index" extensions = ["sphinxcontrib.multilatex"]
18.2
42
0.703297
source_suffix = ".txt" master_doc = "index" extensions = ["sphinxcontrib.multilatex"]
0
0
0
c70fb720099cd2599c5ecd57955fdb2d15a4cf94
2,282
py
Python
src/magento2/language-csv-fixer.py
jeremycurny/devops-py
eea36ff2bcd97affaae929a67ed289fe9e462ff0
[ "MIT" ]
null
null
null
src/magento2/language-csv-fixer.py
jeremycurny/devops-py
eea36ff2bcd97affaae929a67ed289fe9e462ff0
[ "MIT" ]
null
null
null
src/magento2/language-csv-fixer.py
jeremycurny/devops-py
eea36ff2bcd97affaae929a67ed289fe9e462ff0
[ "MIT" ]
null
null
null
#!/usr/bin/env python import csv, json, operator, os, sys import xml.etree.ElementTree as ET composerJsonPath = 'composer.json' languageXmlPath = 'language.xml' if not os.path.exists(composerJsonPath): # File does not exists print "File " + composerJsonPath + " not found" sys.exit(1) if not os.path.exists(languageXmlPath): # File does not exists print "File " + languageXmlPath + " not found" sys.exit(1) file = open(composerJsonPath, "r") composerJsonContent = file.read() file.close() composerTypeData = json.loads(composerJsonContent)['type'] if composerTypeData != "magento2-language": # It's not a language package print "This is not a language package, type: " + composerTypeData sys.exit(1) xml = ET.parse(languageXmlPath) languageCode = xml.getroot().find('code').text languageCsvPath = languageCode + '.csv' if not os.path.exists(languageCsvPath): # File does not exists print "File " + languageCsvPath + " not found" sys.exit(1) cleanData = [] with open(languageCsvPath) as f: rawData = csv.reader(f, delimiter=',') for rawRow in rawData: if len(rawRow) == 0: # Empty line continue; if rawRow[0][:1] == "#": # Commented line continue; if len(rawRow) < 4: # Wtf is this print "Incorrect line: \"" + ','.join(rawRow) + "\"" print "At least 4 columns are expected" sys.exit(1) if (rawRow[2] not in ["module", "theme"]): # 3rd column incorrect print "Incorrect line: \"" + ','.join(rawRow) + "\"" print "3rd column has to be \"module\" or \"theme\", current value: " + rawRow[2] sys.exit(1) cleanData.append(rawRow) f.close() cleanData = sorted(cleanData, key=operator.itemgetter(2,3,0,1)) with open(languageCsvPath, 'wb') as f: currentPackage = "" writer = csv.writer(f, lineterminator='\n') for row in cleanData: rowPackage = row[2].capitalize() + " " + row[3] if rowPackage != currentPackage: if currentPackage != "": writer.writerow([]) currentPackage = rowPackage writer.writerow(["## " + currentPackage + " ##"]) writer.writerow(row) f.close()
30.026316
93
0.608677
#!/usr/bin/env python import csv, json, operator, os, sys import xml.etree.ElementTree as ET composerJsonPath = 'composer.json' languageXmlPath = 'language.xml' if not os.path.exists(composerJsonPath): # File does not exists print "File " + composerJsonPath + " not found" sys.exit(1) if not os.path.exists(languageXmlPath): # File does not exists print "File " + languageXmlPath + " not found" sys.exit(1) file = open(composerJsonPath, "r") composerJsonContent = file.read() file.close() composerTypeData = json.loads(composerJsonContent)['type'] if composerTypeData != "magento2-language": # It's not a language package print "This is not a language package, type: " + composerTypeData sys.exit(1) xml = ET.parse(languageXmlPath) languageCode = xml.getroot().find('code').text languageCsvPath = languageCode + '.csv' if not os.path.exists(languageCsvPath): # File does not exists print "File " + languageCsvPath + " not found" sys.exit(1) cleanData = [] with open(languageCsvPath) as f: rawData = csv.reader(f, delimiter=',') for rawRow in rawData: if len(rawRow) == 0: # Empty line continue; if rawRow[0][:1] == "#": # Commented line continue; if len(rawRow) < 4: # Wtf is this print "Incorrect line: \"" + ','.join(rawRow) + "\"" print "At least 4 columns are expected" sys.exit(1) if (rawRow[2] not in ["module", "theme"]): # 3rd column incorrect print "Incorrect line: \"" + ','.join(rawRow) + "\"" print "3rd column has to be \"module\" or \"theme\", current value: " + rawRow[2] sys.exit(1) cleanData.append(rawRow) f.close() cleanData = sorted(cleanData, key=operator.itemgetter(2,3,0,1)) with open(languageCsvPath, 'wb') as f: currentPackage = "" writer = csv.writer(f, lineterminator='\n') for row in cleanData: rowPackage = row[2].capitalize() + " " + row[3] if rowPackage != currentPackage: if currentPackage != "": writer.writerow([]) currentPackage = rowPackage writer.writerow(["## " + currentPackage + " ##"]) writer.writerow(row) f.close()
0
0
0
44c2d4091b0b65c4e713d3fb92c8d2106838080c
1,340
py
Python
mopy/impl/dvonn/action.py
TylerSandman/mopy
df66bb728f6dacee8ee6267a8802a4b71a04fd43
[ "MIT" ]
null
null
null
mopy/impl/dvonn/action.py
TylerSandman/mopy
df66bb728f6dacee8ee6267a8802a4b71a04fd43
[ "MIT" ]
null
null
null
mopy/impl/dvonn/action.py
TylerSandman/mopy
df66bb728f6dacee8ee6267a8802a4b71a04fd43
[ "MIT" ]
null
null
null
"""This module contains a representation of an action in the game Dvonn.""" from mopy.action import Action from enum import Enum
31.904762
79
0.567164
"""This module contains a representation of an action in the game Dvonn.""" from mopy.action import Action from enum import Enum class DvonnAction(Action): class Type(Enum): PLACE = 1 MOVE = 2 def __init__(self, type_, end, start=None): """ Create an action representing placing or moving a ring. Args: type_ (Type): Which action to take. end (Tuple(int, int)): The final grid position of the ring or ring stack to be placed or moved. start (Tuple(int, int)): The grid position of the ring to be moved during this action. Only to be used during MOVE actions. Defaults to None. """ self.type = type_ self.end = end self.start = start def __eq__(self, other): eq_type = self.type == other.type eq_end = self.end == other.end eq_start = self.start == other.start return (eq_type and eq_end and eq_start) def __hash__(self): return hash((self.type, self.end, self.start)) def __repr__(self): if self.type == DvonnAction.Type.PLACE: return self.type.name + " at " + str(self.end) return self.type.name + " " + str(self.start) + " to " + str(self.end)
423
757
24
2f6fc55efb4642bc95fccfcc575e39d053da1f03
1,069
py
Python
data/transcoder_evaluation_gfg/python/COUNT_NUMBERS_CAN_CONSTRUCTED_USING_TWO_NUMBERS.py
mxl1n/CodeGen
e5101dd5c5e9c3720c70c80f78b18f13e118335a
[ "MIT" ]
241
2021-07-20T08:35:20.000Z
2022-03-31T02:39:08.000Z
data/transcoder_evaluation_gfg/python/COUNT_NUMBERS_CAN_CONSTRUCTED_USING_TWO_NUMBERS.py
mxl1n/CodeGen
e5101dd5c5e9c3720c70c80f78b18f13e118335a
[ "MIT" ]
49
2021-07-22T23:18:42.000Z
2022-03-24T09:15:26.000Z
data/transcoder_evaluation_gfg/python/COUNT_NUMBERS_CAN_CONSTRUCTED_USING_TWO_NUMBERS.py
mxl1n/CodeGen
e5101dd5c5e9c3720c70c80f78b18f13e118335a
[ "MIT" ]
71
2021-07-21T05:17:52.000Z
2022-03-29T23:49:28.000Z
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # #TOFILL if __name__ == '__main__': param = [ (23,16,16,), (56,95,6,), (30,63,1,), (51,89,46,), (21,99,38,), (69,63,50,), (12,69,73,), (44,52,9,), (99,65,10,), (46,58,37,) ] n_success = 0 for i, parameters_set in enumerate(param): if f_filled(*parameters_set) == f_gold(*parameters_set): n_success+=1 print("#Results: %i, %i" % (n_success, len(param)))
24.860465
64
0.466791
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( n , x , y ) : arr = [ False for i in range ( n + 2 ) ] if ( x <= n ) : arr [ x ] = True if ( y <= n ) : arr [ y ] = True result = 0 for i in range ( min ( x , y ) , n + 1 ) : if ( arr [ i ] ) : if ( i + x <= n ) : arr [ i + x ] = True if ( i + y <= n ) : arr [ i + y ] = True result = result + 1 return result #TOFILL if __name__ == '__main__': param = [ (23,16,16,), (56,95,6,), (30,63,1,), (51,89,46,), (21,99,38,), (69,63,50,), (12,69,73,), (44,52,9,), (99,65,10,), (46,58,37,) ] n_success = 0 for i, parameters_set in enumerate(param): if f_filled(*parameters_set) == f_gold(*parameters_set): n_success+=1 print("#Results: %i, %i" % (n_success, len(param)))
417
0
22
cb2b2350e7afa94fce2f50c53e2912e1644d082c
559
py
Python
python/005/005.py
seaneshbaugh/rosetta-euler
14f24dfc347e7d9a4c9c0f090acf2811aa65f453
[ "MIT" ]
36
2015-01-24T08:11:52.000Z
2021-03-21T00:32:00.000Z
python/005/005.py
seaneshbaugh/rosetta-euler
14f24dfc347e7d9a4c9c0f090acf2811aa65f453
[ "MIT" ]
null
null
null
python/005/005.py
seaneshbaugh/rosetta-euler
14f24dfc347e7d9a4c9c0f090acf2811aa65f453
[ "MIT" ]
4
2015-01-24T08:17:42.000Z
2022-01-11T16:10:56.000Z
from operator import mul from functools import reduce print(reduce(mul, reduce(overlap, [prime_factors(x) for x in range(1, 21)])))
15.108108
77
0.509839
from operator import mul from functools import reduce def prime_factors(n): found = False v = 2 i = 2 while i < n -1 and found == False: if n % i == 0: found = True v = i i += 1 if found: factors = [v] + prime_factors(n // v) else: factors = [n] return factors def overlap(a, b): for n in b: if n in a: a.remove(n) result = sorted(a + b) return result print(reduce(mul, reduce(overlap, [prime_factors(x) for x in range(1, 21)])))
380
0
46
ca7c7edf7ff446e57c190dc6666d3e16fbd106a2
792
py
Python
docker-min/mkimage/just-bash.py
robnagler/container-play
8f112a1bdaf14d9be0a62a548a08a34f03c193f6
[ "Apache-2.0" ]
null
null
null
docker-min/mkimage/just-bash.py
robnagler/container-play
8f112a1bdaf14d9be0a62a548a08a34f03c193f6
[ "Apache-2.0" ]
null
null
null
docker-min/mkimage/just-bash.py
robnagler/container-play
8f112a1bdaf14d9be0a62a548a08a34f03c193f6
[ "Apache-2.0" ]
null
null
null
#!/usr/bin/env python # ./mkimage.sh --tag m1 m1.py from __future__ import absolute_import, division, print_function import os import shutil import subprocess import sys files=[ '/usr/bin/bash', '/usr/bin/ls', ] os.chdir(sys.argv[1]) os.umask(0o22) for d in ( 'etc', 'tmp', 'var/tmp', 'usr/bin', 'usr/lib', 'usr/lib64', 'usr/sbin', ): os.makedirs(d, mode=0o777) for s in ('bin', 'lib', 'lib64', 'sbin'): os.symlink('usr/' + s, s) libs=set() for p in files: _copy(p) try: for l in subprocess.check_output(['ldd', p]).split(): if l.startswith('/'): libs.add(l) except Exception as e: print(e) for l in libs: _copy(l)
16.851064
64
0.565657
#!/usr/bin/env python # ./mkimage.sh --tag m1 m1.py from __future__ import absolute_import, division, print_function import os import shutil import subprocess import sys files=[ '/usr/bin/bash', '/usr/bin/ls', ] os.chdir(sys.argv[1]) os.umask(0o22) for d in ( 'etc', 'tmp', 'var/tmp', 'usr/bin', 'usr/lib', 'usr/lib64', 'usr/sbin', ): os.makedirs(d, mode=0o777) for s in ('bin', 'lib', 'lib64', 'sbin'): os.symlink('usr/' + s, s) def _copy(fn): shutil.copy2(fn, fn.lstrip('/')) return fn libs=set() for p in files: _copy(p) try: for l in subprocess.check_output(['ldd', p]).split(): if l.startswith('/'): libs.add(l) except Exception as e: print(e) for l in libs: _copy(l)
44
0
23
d9bda7d97a3a63c0a34725e21d88e1e13fa70eeb
2,610
py
Python
ch07/bagging.py
stoneflyop1/py_machine_learning
18fd635d312f957ca4fcc23d856a1bcd4cf95f48
[ "MIT" ]
null
null
null
ch07/bagging.py
stoneflyop1/py_machine_learning
18fd635d312f957ca4fcc23d856a1bcd4cf95f48
[ "MIT" ]
null
null
null
ch07/bagging.py
stoneflyop1/py_machine_learning
18fd635d312f957ca4fcc23d856a1bcd4cf95f48
[ "MIT" ]
null
null
null
import pandas as pd df_wine = pd.read_csv('../data/wine.data', header=None) df_wine.columns = [ 'Class label', 'Alcohol', 'Malic acid', 'Ash', 'Alcalinity of ash', 'Magnesium', 'TOtal phenols', 'Flavanoids', 'Nonflavanoid phenols', 'Proanthocyanins', 'Color intensity', 'Hue', 'OD280/OD315 of diluted wines', 'Proline' ] df_wine = df_wine[df_wine['Class label'] != 1] y = df_wine['Class label'].values X = df_wine[['Alcohol', 'Hue']].values from sklearn.preprocessing import LabelEncoder from sklearn.model_selection import train_test_split le = LabelEncoder() y = le.fit_transform(y) X_train, X_test, y_train, y_test = train_test_split( X, y, test_size=0.40, random_state=1 ) from sklearn.ensemble import BaggingClassifier from sklearn.tree import DecisionTreeClassifier tree = DecisionTreeClassifier(criterion="entropy", max_depth=None, random_state=1) bag = BaggingClassifier( base_estimator=tree, n_estimators=500, max_samples=1.0, max_features=1.0, bootstrap=True, bootstrap_features=False, n_jobs=1, random_state=1 ) from sklearn.metrics import accuracy_score tree = tree.fit(X_train, y_train) y_train_pred = tree.predict(X_train) y_test_pred = tree.predict(X_test) tree_train = accuracy_score(y_train, y_train_pred) tree_test = accuracy_score(y_test, y_test_pred) print('Decision tree train/test accuracies %.3f/%.3f' % (tree_train, tree_test)) bag = bag.fit(X_train, y_train) y_train_pred = bag.predict(X_train) y_test_pred = bag.predict(X_test) bag_train = accuracy_score(y_train, y_train_pred) bag_test = accuracy_score(y_test, y_test_pred) print('Bagging train/test accuracies %.3f/%.3f' % (bag_train, bag_test)) import numpy as np x_min = X_train[:, 0].min() - 1 x_max = X_train[:, 0].max() + 1 y_min = X_train[:, 1].min() - 1 y_max = X_train[:, 1].max() + 1 xx, yy = np.meshgrid(np.arange(x_min, x_max, 0.1), np.arange(y_min, y_max, 0.1)) import matplotlib.pyplot as plt f, axarr = plt.subplots( nrows=1, ncols=2, sharex='col', sharey='row', figsize=(8,3) ) for idx, clf, tt in zip([0, 1], [tree, bag], ['Decision Tree', 'Bagging']): clf.fit(X_train, y_train) Z = clf.predict(np.c_[xx.ravel(), yy.ravel()]) Z = Z.reshape(xx.shape) axarr[idx].contourf(xx, yy, Z, alpha=0.3) axarr[idx].scatter( X_train[y_train==0, 0], X_train[y_train==0, 1], c='blue', marker='^' ) axarr[idx].scatter( X_train[y_train==1, 0], X_train[y_train==1, 1], c='red', marker='o' ) axarr[idx].set_title(tt) axarr[0].set_ylabel('Alcohol', fontsize=12) plt.text( 10.2, -0.7, s='Hue', ha='center', va='center', fontsize=12 ) plt.show()
37.285714
82
0.702682
import pandas as pd df_wine = pd.read_csv('../data/wine.data', header=None) df_wine.columns = [ 'Class label', 'Alcohol', 'Malic acid', 'Ash', 'Alcalinity of ash', 'Magnesium', 'TOtal phenols', 'Flavanoids', 'Nonflavanoid phenols', 'Proanthocyanins', 'Color intensity', 'Hue', 'OD280/OD315 of diluted wines', 'Proline' ] df_wine = df_wine[df_wine['Class label'] != 1] y = df_wine['Class label'].values X = df_wine[['Alcohol', 'Hue']].values from sklearn.preprocessing import LabelEncoder from sklearn.model_selection import train_test_split le = LabelEncoder() y = le.fit_transform(y) X_train, X_test, y_train, y_test = train_test_split( X, y, test_size=0.40, random_state=1 ) from sklearn.ensemble import BaggingClassifier from sklearn.tree import DecisionTreeClassifier tree = DecisionTreeClassifier(criterion="entropy", max_depth=None, random_state=1) bag = BaggingClassifier( base_estimator=tree, n_estimators=500, max_samples=1.0, max_features=1.0, bootstrap=True, bootstrap_features=False, n_jobs=1, random_state=1 ) from sklearn.metrics import accuracy_score tree = tree.fit(X_train, y_train) y_train_pred = tree.predict(X_train) y_test_pred = tree.predict(X_test) tree_train = accuracy_score(y_train, y_train_pred) tree_test = accuracy_score(y_test, y_test_pred) print('Decision tree train/test accuracies %.3f/%.3f' % (tree_train, tree_test)) bag = bag.fit(X_train, y_train) y_train_pred = bag.predict(X_train) y_test_pred = bag.predict(X_test) bag_train = accuracy_score(y_train, y_train_pred) bag_test = accuracy_score(y_test, y_test_pred) print('Bagging train/test accuracies %.3f/%.3f' % (bag_train, bag_test)) import numpy as np x_min = X_train[:, 0].min() - 1 x_max = X_train[:, 0].max() + 1 y_min = X_train[:, 1].min() - 1 y_max = X_train[:, 1].max() + 1 xx, yy = np.meshgrid(np.arange(x_min, x_max, 0.1), np.arange(y_min, y_max, 0.1)) import matplotlib.pyplot as plt f, axarr = plt.subplots( nrows=1, ncols=2, sharex='col', sharey='row', figsize=(8,3) ) for idx, clf, tt in zip([0, 1], [tree, bag], ['Decision Tree', 'Bagging']): clf.fit(X_train, y_train) Z = clf.predict(np.c_[xx.ravel(), yy.ravel()]) Z = Z.reshape(xx.shape) axarr[idx].contourf(xx, yy, Z, alpha=0.3) axarr[idx].scatter( X_train[y_train==0, 0], X_train[y_train==0, 1], c='blue', marker='^' ) axarr[idx].scatter( X_train[y_train==1, 0], X_train[y_train==1, 1], c='red', marker='o' ) axarr[idx].set_title(tt) axarr[0].set_ylabel('Alcohol', fontsize=12) plt.text( 10.2, -0.7, s='Hue', ha='center', va='center', fontsize=12 ) plt.show()
0
0
0
44ca70b70e43421fd03a35b311c2fb12bc1b0a12
251
py
Python
scraping/views.py
stepacool/work4sharingPy
c6ffdb3ac8a2956181c290bc4617e3cb11e13dba
[ "MIT" ]
null
null
null
scraping/views.py
stepacool/work4sharingPy
c6ffdb3ac8a2956181c290bc4617e3cb11e13dba
[ "MIT" ]
5
2021-03-19T01:48:51.000Z
2021-09-22T18:52:20.000Z
scraping/views.py
stepacool/work4sharingPy
c6ffdb3ac8a2956181c290bc4617e3cb11e13dba
[ "MIT" ]
2
2020-04-16T20:23:11.000Z
2020-04-18T12:35:46.000Z
from django.shortcuts import render # Create your views here. from rest_framework.generics import CreateAPIView from scraping.serializers import EmployeeSerializer
22.818182
51
0.844622
from django.shortcuts import render # Create your views here. from rest_framework.generics import CreateAPIView from scraping.serializers import EmployeeSerializer class CreateEmployeeView(CreateAPIView): serializer_class = EmployeeSerializer
0
61
23
1e70df7c2ef9bce6a79c55efd4279997fce505e9
7,610
py
Python
src/test_verbindung_ms&r.py
technikamateur/robolab
1509c0c558f5c5d9a6cf944a21e79b07486853a0
[ "MIT" ]
null
null
null
src/test_verbindung_ms&r.py
technikamateur/robolab
1509c0c558f5c5d9a6cf944a21e79b07486853a0
[ "MIT" ]
null
null
null
src/test_verbindung_ms&r.py
technikamateur/robolab
1509c0c558f5c5d9a6cf944a21e79b07486853a0
[ "MIT" ]
null
null
null
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Mar 18 11:15:09 2019 @author: panyongyi """ #!/usr/bin/env python3 # Suggestion: Do not import the ev3dev.ev3 module in this file import json import paho.mqtt.client as mqtt import uuid import time from planet import Planet, Direction class Communication: """ Class to hold the MQTT client Feel free to add functions, change the constructor and the example send_message() to satisfy your requirements and thereby solve the task according to the specifications """ def __init__(self, mqtt_client): """ Initializes communication module, connect to server, subscribe, etc. """ # THESE TWO VARIABLES MUST NOT BE CHANGED self.client = mqtt_client self.client.on_message = self.on_message # ADD YOUR VARIABLES HERE # Basic configuration of MQTT # Wichtig? self.client.on_message = self.on_message_excepthandler self.client.username_pw_set('118', password='LQR2AabmwY') # Your group credentials self.client.connect('mothership.inf.tu-dresden.de', port=8883) self.client.subscribe('explorer/118', qos=1) # Subscribe to topic explorer/xxx # self.send_ready() # Start listening to incoming messages self.client.loop_start() #self.timer() self.planet = Planet() #Parameter: self.data = None self.topic = "explorer/118" self.planet_Chan = None self.aktX = None self.aktY = None self.direc = None # this is a helper method that catches errors and prints them # it is necessary because on_message is called by paho-mqtt in a different thread and exceptions # are not handled in that thread # # you don't need to change this method at all # THIS FUNCTIONS SIGNATURE MUST NOT BE CHANGED def on_message(self, client, data, message): """ Handles the callback if any message arrived """ print('Got message with topic "{}":'.format(message.topic)) data = json.loads(message.payload.decode('utf-8')) print(json.dumps(data, indent=2)) print('\n') self.data = data self.typ_Entsch() #self.timer() #Timer: jede 2 Sekunden warten: client = mqtt.Client(client_id=str(uuid.uuid4()), # client_id has to be unique among ALL users clean_session=False, protocol=mqtt.MQTTv31) com = Communication(client) com.send_ready() com.timer() #com.send_test() #com.timer() com.pruefDaten() com.timer() com.pruefDaten2() com.timer() com.pruefDaten3() com.timer() com.pruefDaten4() com.timer() com.pruefDaten5() com.timer() node = {(17,38):[(Direction.NORTH, -2), (Direction.WEST, -2), (Direction.EAST, -1)]} com.pathSelect(node) com.timer() ''' t0 = time.time() while (time.time()-t0) < 2: pass print("neue Message kommt!") com.pruefDaten() while (time.time()-t0) < 2: pass print("neue Message kommt!") '''
31.708333
236
0.595795
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Mar 18 11:15:09 2019 @author: panyongyi """ #!/usr/bin/env python3 # Suggestion: Do not import the ev3dev.ev3 module in this file import json import paho.mqtt.client as mqtt import uuid import time from planet import Planet, Direction class Communication: """ Class to hold the MQTT client Feel free to add functions, change the constructor and the example send_message() to satisfy your requirements and thereby solve the task according to the specifications """ def __init__(self, mqtt_client): """ Initializes communication module, connect to server, subscribe, etc. """ # THESE TWO VARIABLES MUST NOT BE CHANGED self.client = mqtt_client self.client.on_message = self.on_message # ADD YOUR VARIABLES HERE # Basic configuration of MQTT # Wichtig? self.client.on_message = self.on_message_excepthandler self.client.username_pw_set('118', password='LQR2AabmwY') # Your group credentials self.client.connect('mothership.inf.tu-dresden.de', port=8883) self.client.subscribe('explorer/118', qos=1) # Subscribe to topic explorer/xxx # self.send_ready() # Start listening to incoming messages self.client.loop_start() #self.timer() self.planet = Planet() #Parameter: self.data = None self.topic = "explorer/118" self.planet_Chan = None self.aktX = None self.aktY = None self.direc = None # this is a helper method that catches errors and prints them # it is necessary because on_message is called by paho-mqtt in a different thread and exceptions # are not handled in that thread # # you don't need to change this method at all def on_message_excepthandler(self, client, data, message): try: self.on_message(client, data, message) except: import traceback traceback.print_exc() raise # THIS FUNCTIONS SIGNATURE MUST NOT BE CHANGED def on_message(self, client, data, message): """ Handles the callback if any message arrived """ print('Got message with topic "{}":'.format(message.topic)) data = json.loads(message.payload.decode('utf-8')) print(json.dumps(data, indent=2)) print('\n') self.data = data self.typ_Entsch() #self.timer() #Timer: jede 2 Sekunden warten: def timer(self): t0 = time.time() while (time.time()-t0) < 2: pass print("neue Message kommt!") def typ_Entsch(self): #Test #print("schon in typ_Epntsch") von = self.data["from"] nach = self.data["type"] if von == "server" and nach == "planet": payload = self.data["payload"] planetName = payload["planetName"] self.planet_Chan = 'planet/'+planetName+'-118' self.client.subscribe(self.planet_Chan, qos=1) self.aktX = payload["startX"] self.aktY = payload["startY"] print(self.aktX, self.aktY) elif von == "server" and nach == "pathSelect": self.serverPath() elif von == "server" and nach == "path": self.set_korrePos() def send_ready(self): erk = '{"from": "client", "type": "ready"}' self.client.publish("explorer/118", erk, qos=1) def send_test(self): mess = '{"from": "client", "type": "testplanet", "payload": {"planetName":"Hawkeye"}}' self.client.publish("explorer/118", mess, qos=1) def set_korrePos(self): korre_pos = self.data["payload"] startX = int(korre_pos["startX"]) startY = int(korre_pos["startY"]) startDir = korre_pos["startDirection"] endX = int(korre_pos["endX"]) endY = int(korre_pos["endY"]) endDir = korre_pos["endDirection"] weight = int(korre_pos["pathWeight"]) self.aktX = endX self.aktY = endY self.direc = endDir self.planet.add_path(((startX, startY), startDir), ((endX, endY), endDir), weight) return [(endX, endY), endDir] def pruefDaten(self): self.pathStat = "free" print(self.planet_Chan) pruef = '{"from":"client", "type":"path", "payload": {"startX": '+str(13)+', "startY": '+str(37)+', "startDirection": "N", "endX": '+str(13)+', "endY": '+str(38)+', "endDirection": "S", "pathStatus": "'+str(self.pathStat)+'"} }' self.client.publish(self.planet_Chan, pruef, qos=1) def pruefDaten2(self): self.pathStat = "free" print(self.planet_Chan) pruef = '{"from":"client", "type":"path", "payload": {"startX": '+str(13)+', "startY": '+str(38)+', "startDirection": "N", "endX": '+str(14)+', "endY": '+str(39)+', "endDirection": "W", "pathStatus": "'+str(self.pathStat)+'"} }' self.client.publish(self.planet_Chan, pruef, qos=1) def pruefDaten3(self): self.pathStat = "free" print(self.planet_Chan) pruef = '{"from":"client", "type":"path", "payload": {"startX": '+str(14)+', "startY": '+str(39)+', "startDirection": "S", "endX": '+str(15)+', "endY": '+str(37)+', "endDirection": "W", "pathStatus": "'+str(self.pathStat)+'"} }' self.client.publish(self.planet_Chan, pruef, qos=1) def pruefDaten4(self): self.pathStat = "free" print(self.planet_Chan) pruef = '{"from":"client", "type":"path", "payload": {"startX": '+str(15)+', "startY": '+str(37)+', "startDirection": "E", "endX": '+str(17)+', "endY": '+str(37)+', "endDirection": "W", "pathStatus": "'+str(self.pathStat)+'"} }' self.client.publish(self.planet_Chan, pruef, qos=1) def pruefDaten5(self): self.pathStat = "free" print(self.planet_Chan) pruef = '{"from":"client", "type":"path", "payload": {"startX": '+str(17)+', "startY": '+str(37)+', "startDirection": "N", "endX": '+str(17)+', "endY": '+str(38)+', "endDirection": "W", "pathStatus": "'+str(self.pathStat)+'"} }' self.client.publish(self.planet_Chan, pruef, qos=1) def pathSelect(self, node): result = self.planet.unknown_paths(node) startX = result[0][0] startY = result[0][1] startDir = result[1].value self.aktX = startX self.aktY = startY self.direc = startDir select = '{"from":"client", "type":"pathSelect", "payload": {"startX": '+str(startX)+', "startY": '+str(startY)+', "startDirection": "'+str(startDir)+'"} }' self.client.publish(self.planet_Chan, select, qos=1) return self.direc def serverPath(self): path_server = self.data["payload"] startDir = path_server["startDirection"] self.direc = startDir return Direction(startDir) client = mqtt.Client(client_id=str(uuid.uuid4()), # client_id has to be unique among ALL users clean_session=False, protocol=mqtt.MQTTv31) com = Communication(client) com.send_ready() com.timer() #com.send_test() #com.timer() com.pruefDaten() com.timer() com.pruefDaten2() com.timer() com.pruefDaten3() com.timer() com.pruefDaten4() com.timer() com.pruefDaten5() com.timer() node = {(17,38):[(Direction.NORTH, -2), (Direction.WEST, -2), (Direction.EAST, -1)]} com.pathSelect(node) com.timer() ''' t0 = time.time() while (time.time()-t0) < 2: pass print("neue Message kommt!") com.pruefDaten() while (time.time()-t0) < 2: pass print("neue Message kommt!") '''
4,228
0
349
d7fa780746f7314c474e988e5736d6c252c9a458
500
py
Python
biblio/migrations/0003_book_isbn.py
DanicoSantos/librhes
616ed1444d47c50dfbd6ecda0d32ee216d2044cb
[ "MIT" ]
null
null
null
biblio/migrations/0003_book_isbn.py
DanicoSantos/librhes
616ed1444d47c50dfbd6ecda0d32ee216d2044cb
[ "MIT" ]
null
null
null
biblio/migrations/0003_book_isbn.py
DanicoSantos/librhes
616ed1444d47c50dfbd6ecda0d32ee216d2044cb
[ "MIT" ]
null
null
null
# Generated by Django 3.2.7 on 2021-09-09 18:23 from django.db import migrations, models
26.315789
167
0.628
# Generated by Django 3.2.7 on 2021-09-09 18:23 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('biblio', '0002_rename_isbn_book_genre'), ] operations = [ migrations.AddField( model_name='book', name='isbn', field=models.CharField(default='', help_text='13 Character <a href="https://www.isbn-international.org/content/what-isbn">ISBN number</a>', max_length=13), ), ]
0
386
23
7d614047f48da2ec532109926d3175e03253eb47
2,276
py
Python
pytorch-frontend/caffe2/python/operator_test/channel_backprop_stats_op_test.py
AndreasKaratzas/stonne
2915fcc46cc94196303d81abbd1d79a56d6dd4a9
[ "MIT" ]
40
2021-06-01T07:37:59.000Z
2022-03-25T01:42:09.000Z
pytorch-frontend/caffe2/python/operator_test/channel_backprop_stats_op_test.py
AndreasKaratzas/stonne
2915fcc46cc94196303d81abbd1d79a56d6dd4a9
[ "MIT" ]
14
2021-06-01T11:52:46.000Z
2022-03-25T02:13:08.000Z
pytorch-frontend/caffe2/python/operator_test/channel_backprop_stats_op_test.py
AndreasKaratzas/stonne
2915fcc46cc94196303d81abbd1d79a56d6dd4a9
[ "MIT" ]
7
2021-07-20T19:34:26.000Z
2022-03-13T21:07:36.000Z
from __future__ import absolute_import from __future__ import division from __future__ import print_function from __future__ import unicode_literals from caffe2.python import core import caffe2.python.hypothesis_test_util as hu from hypothesis import given, settings import caffe2.python.serialized_test.serialized_test_util as serial import hypothesis.strategies as st import numpy as np import unittest if __name__ == "__main__": unittest.main()
36.126984
79
0.59007
from __future__ import absolute_import from __future__ import division from __future__ import print_function from __future__ import unicode_literals from caffe2.python import core import caffe2.python.hypothesis_test_util as hu from hypothesis import given, settings import caffe2.python.serialized_test.serialized_test_util as serial import hypothesis.strategies as st import numpy as np import unittest class TestChannelBackpropStats(serial.SerializedTestCase): @given( size=st.integers(7, 10), inputChannels=st.integers(1, 10), batchSize=st.integers(1, 3), **hu.gcs ) @settings(deadline=10000) def testChannelBackpropStats(self, size, inputChannels, batchSize, gc, dc): op = core.CreateOperator( "ChannelBackpropStats", ["X", "mean", "invStdDev", "outputGrad"], ["scaleGrad", "biasGrad"], ) def referenceChannelBackpropStatsTest(X, mean, invStdDev, outputGrad): scaleGrad = np.zeros(inputChannels) biasGrad = np.zeros(inputChannels) for n in range(batchSize): for c in range(inputChannels): for h in range(size): for w in range(size): biasGrad[c] += outputGrad[n, c, h, w] scaleGrad[c] += ( X[n, c, h, w] - mean[c] ) * invStdDev[c] * outputGrad[n, c, h, w] return scaleGrad, biasGrad X = np.random.rand(batchSize, inputChannels, size, size)\ .astype(np.float32) - 0.5 sums = np.sum(X, axis=(0, 2, 3), keepdims=False) numPixels = size * size * batchSize mean = sums / numPixels sumsq = np.sum(X**2, axis=(0, 2, 3), keepdims=False) var = ((sumsq - (sums * sums) / numPixels) / numPixels).astype(np.float32) invStdDev = 1 / np.sqrt(var) outputGrad = np.random.rand(batchSize, inputChannels, size, size)\ .astype(np.float32) - 0.5 self.assertReferenceChecks( gc, op, [X, mean, invStdDev, outputGrad], referenceChannelBackpropStatsTest ) if __name__ == "__main__": unittest.main()
1,557
240
23
4835b82cff8e79a73e117d4f3ed005f2366de7c5
16,367
py
Python
gear_builder_gui/manifest.py
joshicola/fw-gear-building-gui
924aa742479f6f0983509106e8d63a3fc267eaa3
[ "Apache-2.0" ]
null
null
null
gear_builder_gui/manifest.py
joshicola/fw-gear-building-gui
924aa742479f6f0983509106e8d63a3fc267eaa3
[ "Apache-2.0" ]
null
null
null
gear_builder_gui/manifest.py
joshicola/fw-gear-building-gui
924aa742479f6f0983509106e8d63a3fc267eaa3
[ "Apache-2.0" ]
null
null
null
import copy import json import os from pathlib import Path import pystache from PyQt5 import QtCore, QtGui, QtWidgets from gear_builder_gui.config_dialog import config_dialog from gear_builder_gui.input_dialog import input_dialog class Manifest: """ A class to manage the manifest of a gear TODO: Include the flywheel gear toolkit manifest class """ def __init__(self, main_window): """ Initialize manifest. Args: main_window (GearBuilderGUI): The instantiated main window. """ self.main_window = main_window self.ui = main_window.ui # Initialize "input" Section self.ui.cmbo_inputs.currentIndexChanged.connect(self.update_tooltip) self.ui.btn_input_add.clicked.connect(self.add_input) self.ui.btn_input_edit.clicked.connect(self.edit_input) self.ui.btn_input_delete.clicked.connect(self.delete_input) # Initialize "config" Section self.ui.cmbo_config.currentIndexChanged.connect(self.update_tooltip) self.ui.btn_config_add.clicked.connect(self.add_config) self.ui.btn_config_edit.clicked.connect(self.edit_config) self.ui.btn_config_delete.clicked.connect(self.delete_config) # Disable edit/delete buttons on default: self.ui.btn_input_edit.setEnabled(False) self.ui.btn_input_delete.setEnabled(False) self.ui.btn_config_edit.setEnabled(False) self.ui.btn_config_delete.setEnabled(False) # Save/load functionality self.ui.btn_load_manifest.clicked.connect(self.load_manifest_from_file) self.ui.btn_save_manifest.clicked.connect(self.save_manifest) # connect to docker "maintainer" and validators self.ui.txt_maintainer.textChanged.connect(self.update_maintainers) self.init_validators() # initialize a manifest object self.manifest = main_window.gear_def["manifest"] def update_maintainers(self): """ Coordinate the maintainer text across Dockerfile and manifest. """ if self.ui.txt_maintainer.text() is not self.ui.txt_maintainer_2.text(): self.ui.txt_maintainer_2.setText(self.ui.txt_maintainer.text()) # Add functionality to the input add/edit/deleted buttons def add_input(self): """ Add input to the input combo box through input dialog """ dialog = input_dialog() name, data = dialog.get_data() if name is not None: self.ui.cmbo_inputs.addItem(name, userData=data) self.ui.btn_input_edit.setEnabled(True) self.ui.btn_input_delete.setEnabled(True) def edit_input(self): """ Edit input through input dialog """ obj = self.ui.cmbo_inputs name = obj.currentText() data = obj.currentData() dialog = input_dialog() name_upd, data = dialog.get_data(cbo_val=(name, data)) if name_upd is not None: i = obj.findText(name) obj.setItemText(i, name_upd) obj.setItemData(i, data) def delete_input(self): """ Delete selected input object from the input combo """ i = self.ui.cmbo_inputs.currentIndex() self.ui.cmbo_inputs.removeItem(i) if self.ui.cmbo_inputs.count() == 0: self.ui.btn_input_edit.setEnabled(False) self.ui.btn_input_delete.setEnabled(False) def update_tooltip(self): """ Update tooltip of config/input combo box item. """ sender = self.main_window.sender() if "inputs" in sender.objectName(): cbo_obj = self.ui.cmbo_inputs elif "config" in sender.objectName(): cbo_obj = self.ui.cmbo_config else: cbo_obj = None if cbo_obj: cbo_name = cbo_obj.currentText() cbo_data = cbo_obj.currentData() tool_tip_text = "" for k, v in cbo_data.items(): tool_tip_text += k + ": " + str(v) + "\n" cbo_obj.setToolTip(tool_tip_text) def add_config(self): """ Add a config object to the config combo box through the config dialog. """ dialog = config_dialog() name, data = dialog.get_data() if name is not None: self.ui.cmbo_config.addItem(name, userData=data) self.ui.btn_config_edit.setEnabled(True) self.ui.btn_config_delete.setEnabled(True) def edit_config(self): """ Edit selected config object through the config dialog. """ obj = self.ui.cmbo_config name = obj.currentText() data = obj.currentData() dialog = config_dialog() name_upd, data = dialog.get_data(cbo_val=(name, data)) if name_upd is not None: i = obj.findText(name) obj.setItemText(i, name_upd) obj.setItemData(i, data) def delete_config(self): """ Delete selected config object from the config combo """ i = self.ui.cmbo_config.currentIndex() self.ui.cmbo_config.removeItem(i) if self.ui.cmbo_config.count() == 0: self.ui.btn_config_edit.setEnabled(False) self.ui.btn_config_delete.setEnabled(False) def _update_manifest_from_form(self): """ Update the manifest dictionary from the contents of the manifest tab. This will perserve any items in the self.manifest dictionary not referenced by the form. TODO: I want to implement a _update_form_from_manifest function. """ manifest = {} # Required keys all manifests have keys = [ "name", "label", "description", "author", "maintainer", "license", "url", "source", "cite", "version", ] for key in keys: text_obj = eval("self.ui.txt_" + key) text_type = type(eval("self.ui.txt_" + key)) if text_type == QtWidgets.QPlainTextEdit: text_value = text_obj.toPlainText() elif text_type == QtWidgets.QComboBox: text_value = text_obj.currentText() else: text_value = text_obj.text() manifest[key] = text_value # Build Custom section custom = {} custom["docker-image"] = ( "flywheel/" + manifest["name"] + ":" + manifest["version"] ) gear_builder = {} # gear category on radio button if self.ui.rdo_analysis.isChecked(): gear_builder["category"] = "analysis" else: gear_builder["category"] = "converter" gear_builder["image"] = custom["docker-image"] custom["gear-builder"] = gear_builder # if "suite" if self.ui.chk_flywheel.isChecked(): flywheel = {} flywheel["suite"] = self.ui.txt_suite.text() custom["flywheel"] = flywheel manifest["custom"] = custom # Build inputs section # Each input item consists of the text (key) of a combo box and # specifically constructed data (a dictionary). inputs = {} cbo_obj = self.ui.cmbo_inputs for i in range(cbo_obj.count()): inputs[cbo_obj.itemText(i)] = cbo_obj.itemData(i) manifest["inputs"] = inputs # Build config section # Each config item consists of the text (key) of a combo box and # specifically constructed data (a dictionary). config = {} cbo_obj = self.ui.cmbo_config for i in range(cbo_obj.count()): config[cbo_obj.itemText(i)] = cbo_obj.itemData(i) manifest["config"] = config # The command manifest["command"] = "/flywheel/v0/run.py" # Using an "update" here instead of a total replace preserves items that may # have been loaded. self.manifest.update(manifest) def load_manifest_from_file(self): """ Load manifest from file. """ manifest_file = QtWidgets.QFileDialog.getOpenFileName( self.main_window, "Select manifest.json to load.", filter="manifest.json" ) # TODO: Should I warn about replacement of all manifest values? if len(manifest_file[0]) > 0: with open(manifest_file[0], "r") as manifest_raw: manifest = json.load(manifest_raw) self.manifest.clear() self.manifest.update(manifest) self._update_form_from_manifest() def _update_form_from_manifest(self): """ Update form values from stored manifest. """ # NOTE: This would be a good place to warn if the loaded manifest was invalid # Required manifest keys: keys = [ "name", "label", "description", "author", "maintainer", "license", "url", "source", "cite", "version", ] try: for key in keys: text_obj = eval("self.ui.txt_" + key) text_type = type(eval("self.ui.txt_" + key)) if self.manifest.get(key): text_value = self.manifest[key] else: text_value = "" if text_type == QtWidgets.QPlainTextEdit: text_value = text_obj.setPlainText(text_value) elif text_type == QtWidgets.QComboBox: index = text_obj.findText(text_value) if index: text_obj.setCurrentIndex(index) else: text_obj.setText(text_value) # load custom fields custom = self.manifest["custom"] self.ui.rdo_analysis.setChecked( custom["gear-builder"]["category"] == "analysis" ) if custom.get("flywheel"): self.ui.chk_flywheel.setChecked(True) self.ui.txt_suite.setText(custom["flywheel"]["suite"]) # load inputs section inputs = self.manifest["inputs"] cbo_obj = self.ui.cmbo_inputs cbo_obj.clear() for name, data in inputs.items(): cbo_obj.addItem(name, userData=data) if cbo_obj.count() > 0: self.ui.btn_input_edit.setEnabled(True) self.ui.btn_input_delete.setEnabled(True) # load configs section config = self.manifest["config"] cbo_obj = self.ui.cmbo_config cbo_obj.clear() for name, data in config.items(): cbo_obj.addItem(name, userData=data) if cbo_obj.count() > 0: self.ui.btn_config_edit.setEnabled(True) self.ui.btn_config_delete.setEnabled(True) except Exception as e: print(e) def save_manifest(self): """ Select destination to save manifest.json file. """ directory = str( QtWidgets.QFileDialog.getExistingDirectory( self.main_window, "Select Folder to save manifest.json." ) ) if len(directory) > 0: self.save(directory) def save(self, directory): """ Save self.manifest dictionary to manifest.json file in the indicated directory. Args: directory (str): Path to directory. """ directory = Path(directory) self._update_manifest_from_form() json.dump(self.manifest, open(directory / "manifest.json", "w"), indent=2) def save_draft_readme(self, directory, readme_template=None): """ Saves draft of README.md to indicated directory. Args: directory (str): Path to directory. readme_template (str, optional): Path to the mustache template to use. Defaults to None. """ # make a copy to modify for formatting README.md local_manifest = copy.deepcopy(self.manifest) directory = Path(directory) if not readme_template: source_dir = self.main_window.root_dir / "default_templates" readme_template = source_dir / "README.md.mu" renderer = pystache.Renderer() # Check for non-zero number of inputs if len(local_manifest["inputs"].keys()) > 0: local_manifest["has_inputs"] = True local_manifest["inputs_list"] = [] for inp, val in local_manifest["inputs"].items(): val["name"] = inp local_manifest["inputs_list"].append(val) # Check for a non-zero number of configs if len(local_manifest["config"].keys()) > 0: local_manifest["has_configs"] = True local_manifest["config_list"] = [] for conf, val in local_manifest["config"].items(): val["name"] = conf if "default" in val.keys(): val["default_val"] = {"val": val["default"]} local_manifest["config_list"].append(val) template_output = renderer.render_path( readme_template, {"manifest": local_manifest} ) with open(directory / "README.md", "w") as fp: fp.write(template_output) def _check_description_text_length(self): """ Constrains the length of the QPlainTextEdit txt_description member. The maxLength is initialized below from the manifest schema. The QPlainTextEdit object does not have an automatic length constraint. """ obj = self.ui.txt_description if len(obj.toPlainText()) > obj.maxLength: obj.textCursor().deletePreviousChar() def init_validators(self): """ Initializes the field validators to the manifest schema. TODO: Use a local copy of the manifest schema instead of downloading. """ # spec_url = ( # "https://gitlab.com/flywheel-io/public/" # "gears/-/raw/master/spec/manifest.schema.json" # ) # request = requests.get(spec_url) # url = urllib.request.urlopen(spec_url) with open( self.main_window.root_dir / "gear_builder_gui/resources/manifest.schema.json", "r", ) as fp: gear_spec = json.load(fp) keys = [ "name", "label", "description", "author", "maintainer", "license", "url", "source", "cite", "version", ] for key in keys: gear_spec_item = gear_spec["properties"][key] if key == "license": text_obj = self.ui.txt_license text_obj.addItems(gear_spec["properties"]["license"]["enum"]) text_obj.setCurrentIndex(text_obj.__len__() - 1) else: text_obj = eval("self.ui.txt_" + key) text_type = type(eval("self.ui.txt_" + key)) if "maxLength" in gear_spec_item.keys(): text_obj.maxLength = gear_spec_item["maxLength"] if "pattern" in gear_spec_item.keys(): rx = QtCore.QRegExp(gear_spec_item["pattern"]) val = QtGui.QRegExpValidator(rx, self.main_window) text_obj.setValidator(val) elif key == "version": rx = QtCore.QRegExp( "^((([0-9]+)\\.([0-9]+)\\.([0-9]+)" "(?:-_([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?)" "(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?)$" ) val = QtGui.QRegExpValidator(rx, self.main_window) text_obj.setValidator(val) if text_type == QtWidgets.QPlainTextEdit: text_obj.textChanged.connect(self._check_description_text_length) if "description" in gear_spec_item.keys(): text_obj.whatsThis = gear_spec_item["description"] text_obj.setToolTip(gear_spec_item["description"])
35.197849
87
0.569194
import copy import json import os from pathlib import Path import pystache from PyQt5 import QtCore, QtGui, QtWidgets from gear_builder_gui.config_dialog import config_dialog from gear_builder_gui.input_dialog import input_dialog class Manifest: """ A class to manage the manifest of a gear TODO: Include the flywheel gear toolkit manifest class """ def __init__(self, main_window): """ Initialize manifest. Args: main_window (GearBuilderGUI): The instantiated main window. """ self.main_window = main_window self.ui = main_window.ui # Initialize "input" Section self.ui.cmbo_inputs.currentIndexChanged.connect(self.update_tooltip) self.ui.btn_input_add.clicked.connect(self.add_input) self.ui.btn_input_edit.clicked.connect(self.edit_input) self.ui.btn_input_delete.clicked.connect(self.delete_input) # Initialize "config" Section self.ui.cmbo_config.currentIndexChanged.connect(self.update_tooltip) self.ui.btn_config_add.clicked.connect(self.add_config) self.ui.btn_config_edit.clicked.connect(self.edit_config) self.ui.btn_config_delete.clicked.connect(self.delete_config) # Disable edit/delete buttons on default: self.ui.btn_input_edit.setEnabled(False) self.ui.btn_input_delete.setEnabled(False) self.ui.btn_config_edit.setEnabled(False) self.ui.btn_config_delete.setEnabled(False) # Save/load functionality self.ui.btn_load_manifest.clicked.connect(self.load_manifest_from_file) self.ui.btn_save_manifest.clicked.connect(self.save_manifest) # connect to docker "maintainer" and validators self.ui.txt_maintainer.textChanged.connect(self.update_maintainers) self.init_validators() # initialize a manifest object self.manifest = main_window.gear_def["manifest"] def update_maintainers(self): """ Coordinate the maintainer text across Dockerfile and manifest. """ if self.ui.txt_maintainer.text() is not self.ui.txt_maintainer_2.text(): self.ui.txt_maintainer_2.setText(self.ui.txt_maintainer.text()) # Add functionality to the input add/edit/deleted buttons def add_input(self): """ Add input to the input combo box through input dialog """ dialog = input_dialog() name, data = dialog.get_data() if name is not None: self.ui.cmbo_inputs.addItem(name, userData=data) self.ui.btn_input_edit.setEnabled(True) self.ui.btn_input_delete.setEnabled(True) def edit_input(self): """ Edit input through input dialog """ obj = self.ui.cmbo_inputs name = obj.currentText() data = obj.currentData() dialog = input_dialog() name_upd, data = dialog.get_data(cbo_val=(name, data)) if name_upd is not None: i = obj.findText(name) obj.setItemText(i, name_upd) obj.setItemData(i, data) def delete_input(self): """ Delete selected input object from the input combo """ i = self.ui.cmbo_inputs.currentIndex() self.ui.cmbo_inputs.removeItem(i) if self.ui.cmbo_inputs.count() == 0: self.ui.btn_input_edit.setEnabled(False) self.ui.btn_input_delete.setEnabled(False) def update_tooltip(self): """ Update tooltip of config/input combo box item. """ sender = self.main_window.sender() if "inputs" in sender.objectName(): cbo_obj = self.ui.cmbo_inputs elif "config" in sender.objectName(): cbo_obj = self.ui.cmbo_config else: cbo_obj = None if cbo_obj: cbo_name = cbo_obj.currentText() cbo_data = cbo_obj.currentData() tool_tip_text = "" for k, v in cbo_data.items(): tool_tip_text += k + ": " + str(v) + "\n" cbo_obj.setToolTip(tool_tip_text) def add_config(self): """ Add a config object to the config combo box through the config dialog. """ dialog = config_dialog() name, data = dialog.get_data() if name is not None: self.ui.cmbo_config.addItem(name, userData=data) self.ui.btn_config_edit.setEnabled(True) self.ui.btn_config_delete.setEnabled(True) def edit_config(self): """ Edit selected config object through the config dialog. """ obj = self.ui.cmbo_config name = obj.currentText() data = obj.currentData() dialog = config_dialog() name_upd, data = dialog.get_data(cbo_val=(name, data)) if name_upd is not None: i = obj.findText(name) obj.setItemText(i, name_upd) obj.setItemData(i, data) def delete_config(self): """ Delete selected config object from the config combo """ i = self.ui.cmbo_config.currentIndex() self.ui.cmbo_config.removeItem(i) if self.ui.cmbo_config.count() == 0: self.ui.btn_config_edit.setEnabled(False) self.ui.btn_config_delete.setEnabled(False) def _update_manifest_from_form(self): """ Update the manifest dictionary from the contents of the manifest tab. This will perserve any items in the self.manifest dictionary not referenced by the form. TODO: I want to implement a _update_form_from_manifest function. """ manifest = {} # Required keys all manifests have keys = [ "name", "label", "description", "author", "maintainer", "license", "url", "source", "cite", "version", ] for key in keys: text_obj = eval("self.ui.txt_" + key) text_type = type(eval("self.ui.txt_" + key)) if text_type == QtWidgets.QPlainTextEdit: text_value = text_obj.toPlainText() elif text_type == QtWidgets.QComboBox: text_value = text_obj.currentText() else: text_value = text_obj.text() manifest[key] = text_value # Build Custom section custom = {} custom["docker-image"] = ( "flywheel/" + manifest["name"] + ":" + manifest["version"] ) gear_builder = {} # gear category on radio button if self.ui.rdo_analysis.isChecked(): gear_builder["category"] = "analysis" else: gear_builder["category"] = "converter" gear_builder["image"] = custom["docker-image"] custom["gear-builder"] = gear_builder # if "suite" if self.ui.chk_flywheel.isChecked(): flywheel = {} flywheel["suite"] = self.ui.txt_suite.text() custom["flywheel"] = flywheel manifest["custom"] = custom # Build inputs section # Each input item consists of the text (key) of a combo box and # specifically constructed data (a dictionary). inputs = {} cbo_obj = self.ui.cmbo_inputs for i in range(cbo_obj.count()): inputs[cbo_obj.itemText(i)] = cbo_obj.itemData(i) manifest["inputs"] = inputs # Build config section # Each config item consists of the text (key) of a combo box and # specifically constructed data (a dictionary). config = {} cbo_obj = self.ui.cmbo_config for i in range(cbo_obj.count()): config[cbo_obj.itemText(i)] = cbo_obj.itemData(i) manifest["config"] = config # The command manifest["command"] = "/flywheel/v0/run.py" # Using an "update" here instead of a total replace preserves items that may # have been loaded. self.manifest.update(manifest) def load_manifest_from_file(self): """ Load manifest from file. """ manifest_file = QtWidgets.QFileDialog.getOpenFileName( self.main_window, "Select manifest.json to load.", filter="manifest.json" ) # TODO: Should I warn about replacement of all manifest values? if len(manifest_file[0]) > 0: with open(manifest_file[0], "r") as manifest_raw: manifest = json.load(manifest_raw) self.manifest.clear() self.manifest.update(manifest) self._update_form_from_manifest() def _update_form_from_manifest(self): """ Update form values from stored manifest. """ # NOTE: This would be a good place to warn if the loaded manifest was invalid # Required manifest keys: keys = [ "name", "label", "description", "author", "maintainer", "license", "url", "source", "cite", "version", ] try: for key in keys: text_obj = eval("self.ui.txt_" + key) text_type = type(eval("self.ui.txt_" + key)) if self.manifest.get(key): text_value = self.manifest[key] else: text_value = "" if text_type == QtWidgets.QPlainTextEdit: text_value = text_obj.setPlainText(text_value) elif text_type == QtWidgets.QComboBox: index = text_obj.findText(text_value) if index: text_obj.setCurrentIndex(index) else: text_obj.setText(text_value) # load custom fields custom = self.manifest["custom"] self.ui.rdo_analysis.setChecked( custom["gear-builder"]["category"] == "analysis" ) if custom.get("flywheel"): self.ui.chk_flywheel.setChecked(True) self.ui.txt_suite.setText(custom["flywheel"]["suite"]) # load inputs section inputs = self.manifest["inputs"] cbo_obj = self.ui.cmbo_inputs cbo_obj.clear() for name, data in inputs.items(): cbo_obj.addItem(name, userData=data) if cbo_obj.count() > 0: self.ui.btn_input_edit.setEnabled(True) self.ui.btn_input_delete.setEnabled(True) # load configs section config = self.manifest["config"] cbo_obj = self.ui.cmbo_config cbo_obj.clear() for name, data in config.items(): cbo_obj.addItem(name, userData=data) if cbo_obj.count() > 0: self.ui.btn_config_edit.setEnabled(True) self.ui.btn_config_delete.setEnabled(True) except Exception as e: print(e) def save_manifest(self): """ Select destination to save manifest.json file. """ directory = str( QtWidgets.QFileDialog.getExistingDirectory( self.main_window, "Select Folder to save manifest.json." ) ) if len(directory) > 0: self.save(directory) def save(self, directory): """ Save self.manifest dictionary to manifest.json file in the indicated directory. Args: directory (str): Path to directory. """ directory = Path(directory) self._update_manifest_from_form() json.dump(self.manifest, open(directory / "manifest.json", "w"), indent=2) def save_draft_readme(self, directory, readme_template=None): """ Saves draft of README.md to indicated directory. Args: directory (str): Path to directory. readme_template (str, optional): Path to the mustache template to use. Defaults to None. """ # make a copy to modify for formatting README.md local_manifest = copy.deepcopy(self.manifest) directory = Path(directory) if not readme_template: source_dir = self.main_window.root_dir / "default_templates" readme_template = source_dir / "README.md.mu" renderer = pystache.Renderer() # Check for non-zero number of inputs if len(local_manifest["inputs"].keys()) > 0: local_manifest["has_inputs"] = True local_manifest["inputs_list"] = [] for inp, val in local_manifest["inputs"].items(): val["name"] = inp local_manifest["inputs_list"].append(val) # Check for a non-zero number of configs if len(local_manifest["config"].keys()) > 0: local_manifest["has_configs"] = True local_manifest["config_list"] = [] for conf, val in local_manifest["config"].items(): val["name"] = conf if "default" in val.keys(): val["default_val"] = {"val": val["default"]} local_manifest["config_list"].append(val) template_output = renderer.render_path( readme_template, {"manifest": local_manifest} ) with open(directory / "README.md", "w") as fp: fp.write(template_output) def _check_description_text_length(self): """ Constrains the length of the QPlainTextEdit txt_description member. The maxLength is initialized below from the manifest schema. The QPlainTextEdit object does not have an automatic length constraint. """ obj = self.ui.txt_description if len(obj.toPlainText()) > obj.maxLength: obj.textCursor().deletePreviousChar() def init_validators(self): """ Initializes the field validators to the manifest schema. TODO: Use a local copy of the manifest schema instead of downloading. """ # spec_url = ( # "https://gitlab.com/flywheel-io/public/" # "gears/-/raw/master/spec/manifest.schema.json" # ) # request = requests.get(spec_url) # url = urllib.request.urlopen(spec_url) with open( self.main_window.root_dir / "gear_builder_gui/resources/manifest.schema.json", "r", ) as fp: gear_spec = json.load(fp) keys = [ "name", "label", "description", "author", "maintainer", "license", "url", "source", "cite", "version", ] for key in keys: gear_spec_item = gear_spec["properties"][key] if key == "license": text_obj = self.ui.txt_license text_obj.addItems(gear_spec["properties"]["license"]["enum"]) text_obj.setCurrentIndex(text_obj.__len__() - 1) else: text_obj = eval("self.ui.txt_" + key) text_type = type(eval("self.ui.txt_" + key)) if "maxLength" in gear_spec_item.keys(): text_obj.maxLength = gear_spec_item["maxLength"] if "pattern" in gear_spec_item.keys(): rx = QtCore.QRegExp(gear_spec_item["pattern"]) val = QtGui.QRegExpValidator(rx, self.main_window) text_obj.setValidator(val) elif key == "version": rx = QtCore.QRegExp( "^((([0-9]+)\\.([0-9]+)\\.([0-9]+)" "(?:-_([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?)" "(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?)$" ) val = QtGui.QRegExpValidator(rx, self.main_window) text_obj.setValidator(val) if text_type == QtWidgets.QPlainTextEdit: text_obj.textChanged.connect(self._check_description_text_length) if "description" in gear_spec_item.keys(): text_obj.whatsThis = gear_spec_item["description"] text_obj.setToolTip(gear_spec_item["description"])
0
0
0
47fcdec47eb87ee97751e3275df1278d4abe7646
6,012
py
Python
spycial/erf.py
person142/spycial
d017048c8c09ee0714f438cb75c2e221e068baee
[ "BSD-3-Clause" ]
6
2019-04-04T21:53:40.000Z
2020-02-10T17:16:40.000Z
spycial/erf.py
person142/special
d017048c8c09ee0714f438cb75c2e221e068baee
[ "BSD-3-Clause" ]
null
null
null
spycial/erf.py
person142/special
d017048c8c09ee0714f438cb75c2e221e068baee
[ "BSD-3-Clause" ]
1
2019-09-14T15:09:21.000Z
2019-09-14T15:09:21.000Z
"""Code adapted from Boost, which is: (C) Copyright John Maddock 2006. Use, modification and distribution are subject to the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) """ from numba import njit, vectorize import numpy as np from . import settings from .evalpoly import _devalpoly P1 = np.array([ -0.000322780120964605683831, -0.00772758345802133288487, -0.0509990735146777432841, -0.338165134459360935041, 0.0834305892146531832907 ]) Q1 = np.array([ 0.000370900071787748000569, 0.00858571925074406212772, 0.0875222600142252549554, 0.455004033050794024546, 1.0 ]) P2 = np.array([ 0.00180424538297014223957, 0.0195049001251218801359, 0.0888900368967884466578, 0.191003695796775433986, 0.178114665841120341155, -0.098090592216281240205 ]) Q2 = np.array([ 0.337511472483094676155e-5, 0.0113385233577001411017, 0.12385097467900864233, 0.578052804889902404909, 1.42628004845511324508, 1.84759070983002217845, 1.0 ]) P3 = np.array([ 0.000235839115596880717416, 0.00323962406290842133584, 0.0175679436311802092299, 0.04394818964209516296, 0.0386540375035707201728, -0.0243500476207698441272 ]) Q3 = np.array([ 0.00410369723978904575884, 0.0563921837420478160373, 0.325732924782444448493, 0.982403709157920235114, 1.53991494948552447182, 1.0 ]) P4 = np.array([ 0.113212406648847561139e-4, 0.000250269961544794627958, 0.00212825620914618649141, 0.00840807615555585383007, 0.0137384425896355332126, 0.00295276716530971662634 ]) Q4 = np.array([ 0.000479411269521714493907, 0.0105982906484876531489, 0.0958492726301061423444, 0.442597659481563127003, 1.04217814166938418171, 1.0 ]) P5 = np.array([ -2.8175401114513378771, -3.22729451764143718517, -2.5518551727311523996, -0.687717681153649930619, -0.212652252872804219852, 0.0175389834052493308818, 0.00628057170626964891937 ]) Q5 = np.array([ 5.48409182238641741584, 13.5064170191802889145, 22.9367376522880577224, 15.930646027911794143, 11.0567237927800161565, 2.79257750980575282228, 1.0 ]) @njit('float64(float64, bool_)', cache=settings.CACHE) def _erf_erfc(x, invert): """Compute erf if invert is False and erfc if invert is True.""" if x < 0: if not invert: return -_erf_erfc(-x, False) elif x < -0.5: return 2.0 - _erf_erfc(-x, True); else: return 1.0 + _erf_erfc(-x, False) if x < 0.5: # We're going to calculate erf if x < 1e-10: # Single term of the Taylor series res = 1.128379167095512573896159*x else: # - Maximum deviation found: 1.561e-17 # - Expected error term: 1.561e-17 # - Maximum relative change in control points: 1.155e-04 # - Max error found at double precision: 2.961182e-17 Y = np.float32(1.044948577880859375) xx = x*x res = x*(Y + _devalpoly(P1, xx)/_devalpoly(Q1, xx)) elif (invert and x < 28) or (not invert and x < 5.8): # We'll be calculating erfc: invert = not invert if x < 1.5: # Maximum deviation found: 3.702e-17 # Expected error term: 3.702e-17 # Maximum relative change in control points: 2.845e-04 # Max error found at double precision: 4.841816e-17 Y = np.float32(0.405935764312744140625) res = Y + _devalpoly(P2, x - 0.5)/_devalpoly(Q2, x - 0.5) res *= np.exp(-x*x)/x elif x < 2.5: # Maximum deviation found: 3.909e-18 # Expected error term: 3.909e-18 # Maximum relative change in control points: 9.886e-05 # Max error found at double precision: 6.599585e-18 Y = np.float32(0.50672817230224609375) res = Y + _devalpoly(P3, x - 1.5)/_devalpoly(Q3, x - 1.5) res *= np.exp(-x*x)/x elif x < 4.5: # Maximum deviation found: 1.512e-17 # Expected error term: 1.512e-17 # Maximum relative change in control points: 2.222e-04 # Max error found at double precision: 2.062515e-17 Y = np.float32(0.5405750274658203125) res = Y + _devalpoly(P4, x - 3.5)/_devalpoly(Q4, x - 3.5) res *= np.exp(-x*x)/x else: # Maximum deviation found: 2.860e-17 # Expected error term: 2.859e-17 # Maximum relative change in control points: 1.357e-05 # Max error found at double precision: 2.997958e-17 Y = np.float32(0.5579090118408203125) res = Y + _devalpoly(P5, 1.0/x)/_devalpoly(Q5, 1.0/x) res *= np.exp(-x*x)/x else: # Any value of x larger than 28 will underflow to zero result = 0.0 invert = not invert if invert: res = 1.0 - res return res @njit('float64(float64)', cache=settings.CACHE) @njit('float64(float64)', cache=settings.CACHE) @vectorize(['float64(float64)'], nopython=True, cache=settings.CACHE) def erf(x): """Error function. Parameters ---------- x : array-like Points on the real line out : ndarray, optional Output array for the values of `erf` at `x` Returns ------- ndarray Values of `erf` at `x` """ return _erf(x) @vectorize(['float64(float64)'], nopython=True, cache=settings.CACHE) def erfc(x): """Complementary error function. Parameters ---------- x : array-like Points on the real line out : ndarray, optional Output array for the values of `erfc` at `x` Returns ------- ndarray Values of `erf` at `x` """ return _erfc(x)
26.72
69
0.618596
"""Code adapted from Boost, which is: (C) Copyright John Maddock 2006. Use, modification and distribution are subject to the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) """ from numba import njit, vectorize import numpy as np from . import settings from .evalpoly import _devalpoly P1 = np.array([ -0.000322780120964605683831, -0.00772758345802133288487, -0.0509990735146777432841, -0.338165134459360935041, 0.0834305892146531832907 ]) Q1 = np.array([ 0.000370900071787748000569, 0.00858571925074406212772, 0.0875222600142252549554, 0.455004033050794024546, 1.0 ]) P2 = np.array([ 0.00180424538297014223957, 0.0195049001251218801359, 0.0888900368967884466578, 0.191003695796775433986, 0.178114665841120341155, -0.098090592216281240205 ]) Q2 = np.array([ 0.337511472483094676155e-5, 0.0113385233577001411017, 0.12385097467900864233, 0.578052804889902404909, 1.42628004845511324508, 1.84759070983002217845, 1.0 ]) P3 = np.array([ 0.000235839115596880717416, 0.00323962406290842133584, 0.0175679436311802092299, 0.04394818964209516296, 0.0386540375035707201728, -0.0243500476207698441272 ]) Q3 = np.array([ 0.00410369723978904575884, 0.0563921837420478160373, 0.325732924782444448493, 0.982403709157920235114, 1.53991494948552447182, 1.0 ]) P4 = np.array([ 0.113212406648847561139e-4, 0.000250269961544794627958, 0.00212825620914618649141, 0.00840807615555585383007, 0.0137384425896355332126, 0.00295276716530971662634 ]) Q4 = np.array([ 0.000479411269521714493907, 0.0105982906484876531489, 0.0958492726301061423444, 0.442597659481563127003, 1.04217814166938418171, 1.0 ]) P5 = np.array([ -2.8175401114513378771, -3.22729451764143718517, -2.5518551727311523996, -0.687717681153649930619, -0.212652252872804219852, 0.0175389834052493308818, 0.00628057170626964891937 ]) Q5 = np.array([ 5.48409182238641741584, 13.5064170191802889145, 22.9367376522880577224, 15.930646027911794143, 11.0567237927800161565, 2.79257750980575282228, 1.0 ]) @njit('float64(float64, bool_)', cache=settings.CACHE) def _erf_erfc(x, invert): """Compute erf if invert is False and erfc if invert is True.""" if x < 0: if not invert: return -_erf_erfc(-x, False) elif x < -0.5: return 2.0 - _erf_erfc(-x, True); else: return 1.0 + _erf_erfc(-x, False) if x < 0.5: # We're going to calculate erf if x < 1e-10: # Single term of the Taylor series res = 1.128379167095512573896159*x else: # - Maximum deviation found: 1.561e-17 # - Expected error term: 1.561e-17 # - Maximum relative change in control points: 1.155e-04 # - Max error found at double precision: 2.961182e-17 Y = np.float32(1.044948577880859375) xx = x*x res = x*(Y + _devalpoly(P1, xx)/_devalpoly(Q1, xx)) elif (invert and x < 28) or (not invert and x < 5.8): # We'll be calculating erfc: invert = not invert if x < 1.5: # Maximum deviation found: 3.702e-17 # Expected error term: 3.702e-17 # Maximum relative change in control points: 2.845e-04 # Max error found at double precision: 4.841816e-17 Y = np.float32(0.405935764312744140625) res = Y + _devalpoly(P2, x - 0.5)/_devalpoly(Q2, x - 0.5) res *= np.exp(-x*x)/x elif x < 2.5: # Maximum deviation found: 3.909e-18 # Expected error term: 3.909e-18 # Maximum relative change in control points: 9.886e-05 # Max error found at double precision: 6.599585e-18 Y = np.float32(0.50672817230224609375) res = Y + _devalpoly(P3, x - 1.5)/_devalpoly(Q3, x - 1.5) res *= np.exp(-x*x)/x elif x < 4.5: # Maximum deviation found: 1.512e-17 # Expected error term: 1.512e-17 # Maximum relative change in control points: 2.222e-04 # Max error found at double precision: 2.062515e-17 Y = np.float32(0.5405750274658203125) res = Y + _devalpoly(P4, x - 3.5)/_devalpoly(Q4, x - 3.5) res *= np.exp(-x*x)/x else: # Maximum deviation found: 2.860e-17 # Expected error term: 2.859e-17 # Maximum relative change in control points: 1.357e-05 # Max error found at double precision: 2.997958e-17 Y = np.float32(0.5579090118408203125) res = Y + _devalpoly(P5, 1.0/x)/_devalpoly(Q5, 1.0/x) res *= np.exp(-x*x)/x else: # Any value of x larger than 28 will underflow to zero result = 0.0 invert = not invert if invert: res = 1.0 - res return res @njit('float64(float64)', cache=settings.CACHE) def _erf(x): return _erf_erfc(x, False) @njit('float64(float64)', cache=settings.CACHE) def _erfc(x): return _erf_erfc(x, True) @vectorize(['float64(float64)'], nopython=True, cache=settings.CACHE) def erf(x): """Error function. Parameters ---------- x : array-like Points on the real line out : ndarray, optional Output array for the values of `erf` at `x` Returns ------- ndarray Values of `erf` at `x` """ return _erf(x) @vectorize(['float64(float64)'], nopython=True, cache=settings.CACHE) def erfc(x): """Complementary error function. Parameters ---------- x : array-like Points on the real line out : ndarray, optional Output array for the values of `erfc` at `x` Returns ------- ndarray Values of `erf` at `x` """ return _erfc(x)
44
0
44
729b980ba4203cd8152efa3abec70e7a6d8e8e89
2,499
py
Python
adsa/demo.py
jtkorhonen/droplet-shape-solver
a88422d0505cb5b0b52419758b4e7c1c6910ecfe
[ "MIT" ]
null
null
null
adsa/demo.py
jtkorhonen/droplet-shape-solver
a88422d0505cb5b0b52419758b4e7c1c6910ecfe
[ "MIT" ]
null
null
null
adsa/demo.py
jtkorhonen/droplet-shape-solver
a88422d0505cb5b0b52419758b4e7c1c6910ecfe
[ "MIT" ]
null
null
null
# -*- coding: utf-8 -*- """A simulation and visualization demonstration. This module runs a simple demonstration of the capabilities of the adsa simulations and analysis. """ import logging from pathlib import Path import csv from .solver import simulate_droplet_shape from .analysis import calculate_volume from .visualisation import plot_drop, plot_drop_3d from matplotlib import pyplot as plt
34.708333
95
0.585034
# -*- coding: utf-8 -*- """A simulation and visualization demonstration. This module runs a simple demonstration of the capabilities of the adsa simulations and analysis. """ import logging from pathlib import Path import csv from .solver import simulate_droplet_shape from .analysis import calculate_volume from .visualisation import plot_drop, plot_drop_3d from matplotlib import pyplot as plt def run_demo(args): logging.info("Running demonstration.") logging.info(f"args={args}") R0 = args.R0 ca = args.ca logging.info(f"R0={R0}, ca={ca}") y = simulate_droplet_shape(R0, ca) logging.debug(f"y.y={y.y}, y.y.shape={y.y.shape}") x = y.y[0] z = y.y[1] vol = calculate_volume(x, z) logging.info(f"Droplet volume: {vol}.") fig = None if args.type == '3d': fig = plot_drop_3d(x, z, style=args.style, show=(not args.noshow)) elif args.type == '2d': fig = plot_drop(x, z, ca=ca, style=args.style, show=(not args.noshow)) if fig is not None and args.save: filepath = Path(args.save) if (filepath.exists()): logging.error(f"Will not overwrite existing file: {filepath}") else: logging.info(f"Saving plot output to {filepath}") fig.savefig(filepath) def run_sweep(args): logging.info("Running sweep.") logging.info(f"args={args}") with open(args.results, 'w') as results_file: logging.info(f"Opened {results_file} for writing results.") writer = csv.DictWriter(results_file, delimiter=',', fieldnames=["R0", "CA", "Volume"]) writer.writeheader() for R0 in args.R0: for ca in args.ca: y = simulate_droplet_shape(R0, ca) x = y.y[0] z = y.y[1] vol = calculate_volume(x, z) logging.info(f"CA={ca} deg; R0={R0*1000} mm; Vol={vol*1e6} µL") writer.writerow({'R0': R0*1000, 'CA': ca, 'Volume': vol*1e6}) fig = plot_drop(x, z, ca=ca, style=args.style, show=False) for ext in args.filetypes: filepath = Path(args.filename.format(ca=ca, R0=1000*R0, ext=ext)) if (filepath.exists()): logging.error(f"Will not overwrite existing file: {filepath}") else: logging.info(f"Saving plot output to {filepath}") fig.savefig(filepath) plt.close(fig)
2,055
0
46
31be368eb110b35254e54ddbccc580822d685138
14,497
py
Python
tools/run.py
stamp711/DBx1000
928912dd7e005ce5a63ad94fdcde412ab893e678
[ "ISC" ]
null
null
null
tools/run.py
stamp711/DBx1000
928912dd7e005ce5a63ad94fdcde412ab893e678
[ "ISC" ]
null
null
null
tools/run.py
stamp711/DBx1000
928912dd7e005ce5a63ad94fdcde412ab893e678
[ "ISC" ]
null
null
null
from condor_scheduler import * from basic_scheduler import * from helper import * #scheduler = CondorScheduler() scheduler = BasicScheduler() app_flags = {} trials = ['', '_1', '_2'] trials = [''] #thds = [4, 8] #, 16, 20, 24, 28, 32] thds = [8, 16, 32] thds = [4, 8, 16, 20, 24, 28, 32] thds = [16] thds = [4, 8, 16, 24, 32] num_logger = 4 benchmarks = ['TPCC'] benchmarks = ['YCSB', 'TPCC'] benchmarks = ['YCSB'] algorithms = ['S'] algorithms = ['B', 'P', 'S'] algorithms = ['P', 'B'] algorithms = ['B'] algorithms = ['P'] algorithms = ['P', 'B'] algorithms = ['S', 'P', 'B', 'NO'] types = ['D'] # data logging and command logging types = ['C'] # data logging and command logging types = ['D', 'C'] # data logging and command logging configs = [] for bench in benchmarks: for alg in algorithms: if alg == 'NO': configs += ['%s_%s' % (alg, bench)] else: for t in types: if alg == 'B' and t == 'C': continue configs += ['%s%s_%s' % (alg, t, bench)] """ app_flags = {} ########################## ### test ########################## # logging for config in configs: thd = 16 num_logger = 4 executable = "./rundb_%s" % config logger = num_logger if config[0] == 'P' else 1 app_flags['LOG_RECOVER'] = 0 app_flags['REQ_PER_QUERY'] = 2 app_flags['READ_PERC'] = 0.5 app_flags['MAX_TXNS_PER_THREAD'] = 10000 app_flags['THREAD_CNT'] = thd app_flags['NUM_LOGGER'] = logger app_flags['LOG_NO_FLUSH'] = 0 app_flags['SYNTH_TABLE_SIZE'] = 1024 app_flags['NUM_WH'] = 1 output_dir = "results/test/%s/thd%d_L%s" % (config, thd, logger) add_dbms_job(app_flags, executable, output_dir) # recovery for config in configs: thd = 16 num_logger = 4 executable = "./rundb_%s" % config logger = num_logger if config[0] == 'P' else 1 app_flags['LOG_RECOVER'] = 1 app_flags['REQ_PER_QUERY'] = 2 app_flags['READ_PERC'] = 0.5 app_flags['MAX_TXNS_PER_THREAD'] = 10000 app_flags['THREAD_CNT'] = thd app_flags['NUM_LOGGER'] = logger app_flags['LOG_NO_FLUSH'] = 0 app_flags['SYNTH_TABLE_SIZE'] = 1024 app_flags['NUM_WH'] = 1 app_flags['LOG_PARALLEL_NUM_BUCKETS'] = 10000 output_dir = "results/test/%s_rec/thd%d_L%s" % (config, thd, logger) add_dbms_job(app_flags, executable, output_dir) ########################## ########################## ######################### """ """ app_flags = {} ########################## # Logging Performance ########################## for trial in trials: for config in configs: for thd in thds: executable = "./rundb_%s" % config logger = num_logger if config[0] == 'S' or config[0] == 'N': logger = 1 if 'TPCC' in config: app_flags['NUM_WH'] = 16 else : # YCSB app_flags['REQ_PER_QUERY'] = 2 app_flags['READ_PERC'] = 0.5 app_flags['MAX_TXNS_PER_THREAD'] = 1000000 app_flags['THREAD_CNT'] = thd app_flags['NUM_LOGGER'] = logger app_flags['LOG_NO_FLUSH'] = 0 output_dir = "results/%s/thd%d_L%s%s" % (config, thd, logger, trial) add_dbms_job(app_flags, executable, output_dir) """ """ app_flags = {} ########################## # RAMDisk Logging Performance ########################## for trial in trials: for config in configs: for thd in thds: executable = "./rundb_%s" % config logger = num_logger if config[0] == 'S' or config[0] == 'N': logger = 1 if 'TPCC' in config: app_flags['NUM_WH'] = 16 else : # YCSB app_flags['REQ_PER_QUERY'] = 2 app_flags['READ_PERC'] = 0.5 app_flags['MAX_TXNS_PER_THREAD'] = 1000000 app_flags['THREAD_CNT'] = thd app_flags['NUM_LOGGER'] = logger app_flags['LOG_NO_FLUSH'] = 1 output_dir = "results/%s_ramdisk/thd%d_L%s%s" % (config, thd, logger, trial) add_dbms_job(app_flags, executable, output_dir) """ """ # Batch logging with different epoch length for trial in trials: config = 'BD_YCSB' executable = "./rundb_%s" % config thd = 4 #for epoch in [10, 20, 40, 80, 160]: for epoch in [5]: logger = num_logger app_flags['REQ_PER_QUERY'] = 2 app_flags['READ_PERC'] = 0.5 app_flags['MAX_TXNS_PER_THREAD'] = 400000 if config[1] == 'D' else 1000000 app_flags['THREAD_CNT'] = thd app_flags['NUM_LOGGER'] = logger app_flags['EPOCH_PERIOD'] = epoch app_flags['LOG_NO_FLUSH'] = 0 output_dir = "results/%s/thd%d_L%s_E%d%s" % (config, thd, logger, epoch, trial) add_dbms_job(app_flags, executable, output_dir) """ """ ########################## # Generate Log Files ########################## app_flags = {} for config in configs: thd = 16 if 'NO' in config: continue executable = "./rundb_%s" % config logger = 1 if config[0] == 'S' else num_logger if 'TPCC' in config: app_flags['NUM_WH'] = 16 else : # YCSB app_flags['REQ_PER_QUERY'] = 2 app_flags['READ_PERC'] = 0.5 app_flags['MAX_TXNS_PER_THREAD'] = 1000000 app_flags['THREAD_CNT'] = thd app_flags['NUM_LOGGER'] = logger app_flags['LOG_NO_FLUSH'] = 0 app_flags['LOG_RECOVER'] = 0 app_flags['LOG_BUFFER_SIZE'] = 1048576 * 50 app_flags['LOG_CHUNK_SIZE'] = 1048576 * 10 output_dir = "results/%s_gen/thd%d_L%s" % (config, thd, logger) add_dbms_job(app_flags, executable, output_dir) # recover performance app_flags = {} for trial in trials: app_flags = {} for bench in benchmarks : #['YCSB', 'TPCC']: for alg in algorithms: if alg == 'NO': continue logger = 1 if alg == 'S' else num_logger for t in types: if alg == 'B' and t == 'C': continue config = '%s%s_%s' % (alg, t, bench) executable = "./rundb_%s" % config for thd in thds: if bench == 'TPCC': app_flags['NUM_WH'] = 16 app_flags['LOG_PARALLEL_REC_NUM_POOLS'] = 4 else: app_flags['LOG_PARALLEL_REC_NUM_POOLS'] = thd app_flags['THREAD_CNT'] = thd app_flags['LOG_RECOVER'] = 1 app_flags['NUM_LOGGER'] = logger app_flags['LOG_PARALLEL_NUM_BUCKETS'] = 10000000 output_dir = "results/%s_rec/thd%d_L%s%s" % \ (config, thd, logger, trial) add_dbms_job(app_flags, executable, output_dir) """ ############################## # sweep # of warehouse ############################## app_flags = {} bench = 'TPCC' #configs = ['SD', 'SC', 'PD', 'PC', 'BD'] configs = ['NO'] #SD', 'SC', 'PD', 'PC', 'BD'] configs = ['%s_TPCC' % x for x in configs] for wh in [1, 4, 8, 16, 32]: #logging performance for config in configs: thd = 32 executable = "./rundb_%s" % config logger = num_logger if config[0] == 'S' or config[0] == 'N': logger = 1 app_flags['NUM_WH'] = wh app_flags['MAX_TXNS_PER_THREAD'] = 1000000 app_flags['THREAD_CNT'] = thd app_flags['NUM_LOGGER'] = logger app_flags['LOG_NO_FLUSH'] = 0 output_dir = "results/%s/thd%d_L%s_wh%d" % (config, thd, logger, wh) add_dbms_job(app_flags, executable, output_dir) """ # recovery performance. generate logs. for wh in [1, 4, 8, 16, 32]: app_flags = {} # generate logs. for config in configs: thd = 16 executable = "./rundb_%s" % config logger = num_logger if config[0] == 'S' or config[0] == 'N': logger = 1 if 'TPCC' in config: app_flags['NUM_WH'] = wh app_flags['MAX_TXNS_PER_THREAD'] = 1000000 app_flags['THREAD_CNT'] = thd app_flags['NUM_LOGGER'] = logger app_flags['LOG_NO_FLUSH'] = 0 output_dir = "results/%s_gen/thd%d_L%s_wh%d" % (config, thd, logger, wh) add_dbms_job(app_flags, executable, output_dir) # recover performance app_flags = {} for config in configs: if 'NO' in config: continue if config[0] == 'B' and config[1] == 'C': continue logger = 1 if config[0] == 'S' else num_logger executable = "./rundb_%s" % config thd = 32 app_flags['NUM_WH'] = wh app_flags['LOG_PARALLEL_REC_NUM_POOLS'] = 4 app_flags['THREAD_CNT'] = thd app_flags['LOG_RECOVER'] = 1 app_flags['NUM_LOGGER'] = logger app_flags['LOG_PARALLEL_NUM_BUCKETS'] = 10000000 output_dir = "results/%s_rec/thd%d_L%s_wh%d" % \ (config, thd, logger, wh) add_dbms_job(app_flags, executable, output_dir) """ """ ############################## # sweep number of queries in YCSB ############################## bench = 'YCSB' configs = ['SD', 'SC', 'PD', 'PC', 'BD'] configs = ['%s_%s' % (x, bench) for x in configs] app_flags = {} for queries in [1, 2, 4, 8]: #logging performance for config in configs: thd = 32 executable = "./rundb_%s" % config logger = num_logger if config[0] == 'S' or config[0] == 'N': logger = 1 app_flags['REQ_PER_QUERY'] = queries app_flags['READ_PERC'] = 0.5 app_flags['MAX_TXNS_PER_THREAD'] = 1000000 app_flags['THREAD_CNT'] = thd app_flags['NUM_LOGGER'] = logger app_flags['LOG_NO_FLUSH'] = 0 output_dir = "results/%s/thd%d_L%s_q%d" % (config, thd, logger, queries) add_dbms_job(app_flags, executable, output_dir) # recovery performance. generate logs. for queries in [1, 2, 4, 8]: app_flags = {} # generate logs. for config in configs: thd = 16 executable = "./rundb_%s" % config logger = num_logger if config[0] == 'S' or config[0] == 'N': logger = 1 app_flags['REQ_PER_QUERY'] = queries app_flags['READ_PERC'] = 0.5 app_flags['MAX_TXNS_PER_THREAD'] = 1000000 app_flags['THREAD_CNT'] = thd app_flags['NUM_LOGGER'] = logger app_flags['LOG_NO_FLUSH'] = 0 output_dir = "results/%s_gen/thd%d_L%s_q%d" % (config, thd, logger, queries) add_dbms_job(app_flags, executable, output_dir) # recover performance app_flags = {} for config in configs: if 'NO' in config: continue if config[0] == 'B' and config[1] == 'C': continue logger = 1 if config[0] == 'S' else num_logger executable = "./rundb_%s" % config thd = 32 app_flags['REQ_PER_QUERY'] = queries app_flags['READ_PERC'] = 0.5 app_flags['LOG_PARALLEL_REC_NUM_POOLS'] = thd app_flags['THREAD_CNT'] = thd app_flags['LOG_RECOVER'] = 1 app_flags['NUM_LOGGER'] = logger app_flags['LOG_PARALLEL_NUM_BUCKETS'] = 10000000 output_dir = "results/%s_rec/thd%d_L%s_q%d" % \ (config, thd, logger, queries) add_dbms_job(app_flags, executable, output_dir) ############################## # sweep contention level ############################## app_flags = {} bench = 'YCSB' configs = ['SD', 'SC', 'PD', 'PC', 'BD'] configs = ['%s_%s' % (x, bench) for x in configs] for theta in [0, 0.6, 0.8, 0.9]: #logging performance for config in configs: thd = 32 executable = "./rundb_%s" % config logger = num_logger if config[0] == 'S' or config[0] == 'N': logger = 1 app_flags['REQ_PER_QUERY'] = 2 app_flags['READ_PERC'] = 0.5 app_flags['ZIPF_THETA'] = theta app_flags['MAX_TXNS_PER_THREAD'] = 1000000 app_flags['THREAD_CNT'] = thd app_flags['NUM_LOGGER'] = logger app_flags['LOG_NO_FLUSH'] = 0 output_dir = "results/%s/thd%d_L%s_z%s" % (config, thd, logger, theta) add_dbms_job(app_flags, executable, output_dir) # recovery performance. generate logs. for theta in [0, 0.6, 0.8, 0.9]: app_flags = {} # generate logs. for config in configs: thd = 16 executable = "./rundb_%s" % config logger = num_logger if config[0] == 'S' or config[0] == 'N': logger = 1 app_flags['REQ_PER_QUERY'] = 2 app_flags['READ_PERC'] = 0.5 app_flags['ZIPF_THETA'] = theta app_flags['MAX_TXNS_PER_THREAD'] = 1000000 app_flags['THREAD_CNT'] = thd app_flags['NUM_LOGGER'] = logger app_flags['LOG_NO_FLUSH'] = 0 output_dir = "results/%s_gen/thd%d_L%s_z%s" % (config, thd, logger, theta) add_dbms_job(app_flags, executable, output_dir) # recover performance app_flags = {} for config in configs: if 'NO' in config: continue if config[0] == 'B' and config[1] == 'C': continue logger = 1 if config[0] == 'S' else num_logger executable = "./rundb_%s" % config thd = 32 app_flags['REQ_PER_QUERY'] = 2 app_flags['READ_PERC'] = 0.5 app_flags['ZIPF_THETA'] = theta app_flags['LOG_PARALLEL_REC_NUM_POOLS'] = thd app_flags['THREAD_CNT'] = thd app_flags['LOG_RECOVER'] = 1 app_flags['NUM_LOGGER'] = logger app_flags['LOG_PARALLEL_NUM_BUCKETS'] = 10000000 output_dir = "results/%s_rec/thd%d_L%s_z%s" % (config, thd, logger, theta) add_dbms_job(app_flags, executable, output_dir) """ """ ################################## # sweep the number of loggers ################################## app_flags = {} bench = 'YCSB' configs = ['PD', 'PC', 'BD'] configs = ['%s_%s' % (x, bench) for x in configs] for logger in [1, 2]: #logging performance for config in configs: thd = 32 executable = "./rundb_%s" % config if config[0] == 'S' or config[0] == 'N': logger = 1 app_flags['REQ_PER_QUERY'] = 2 app_flags['READ_PERC'] = 0.5 app_flags['ZIPF_THETA'] = 0.6 app_flags['MAX_TXNS_PER_THREAD'] = 1000000 app_flags['THREAD_CNT'] = thd app_flags['NUM_LOGGER'] = logger app_flags['LOG_NO_FLUSH'] = 0 output_dir = "results/%s/thd%d_L%s" % (config, thd, logger) add_dbms_job(app_flags, executable, output_dir) # recovery performance. generate logs. for num_logger in [1, 2]: app_flags = {} # generate logs. for config in configs: thd = 16 executable = "./rundb_%s" % config logger = num_logger if config[0] == 'S' or config[0] == 'N': logger = 1 app_flags['REQ_PER_QUERY'] = 2 app_flags['READ_PERC'] = 0.5 app_flags['ZIPF_THETA'] = 0.6 app_flags['MAX_TXNS_PER_THREAD'] = 1000000 app_flags['THREAD_CNT'] = thd app_flags['NUM_LOGGER'] = logger app_flags['LOG_NO_FLUSH'] = 0 output_dir = "results/%s_gen/thd%d_L%s" % (config, thd, logger) add_dbms_job(app_flags, executable, output_dir) # recover performance app_flags = {} for config in configs: if 'NO' in config: continue if config[0] == 'B' and config[1] == 'C': continue logger = 1 if config[0] == 'S' else num_logger executable = "./rundb_%s" % config thd = 32 app_flags['REQ_PER_QUERY'] = 2 app_flags['READ_PERC'] = 0.5 app_flags['ZIPF_THETA'] = 0.6 app_flags['LOG_PARALLEL_REC_NUM_POOLS'] = thd app_flags['THREAD_CNT'] = thd app_flags['LOG_RECOVER'] = 1 app_flags['NUM_LOGGER'] = logger app_flags['LOG_PARALLEL_NUM_BUCKETS'] = 10000000 output_dir = "results/%s_rec/thd%d_L%s" % (config, thd, logger) add_dbms_job(app_flags, executable, output_dir) """ scheduler.generateSubmitFile()
29.346154
82
0.631579
from condor_scheduler import * from basic_scheduler import * from helper import * #scheduler = CondorScheduler() scheduler = BasicScheduler() def add_dbms_job(app_flags = {}, executable = "./rundb", output_dir = "results/"): app_args = " " for key in app_flags.keys(): if key in args_mapping.keys(): app_args += args_mapping[key] + str(app_flags[key]) + " " else : app_args += "--%s=%s " % (key, app_flags[key]) app_args += "-o %s/output " % output_dir command = executable + app_args command = "numactl -i all " + command scheduler.addJob(command, output_dir) app_flags = {} trials = ['', '_1', '_2'] trials = [''] #thds = [4, 8] #, 16, 20, 24, 28, 32] thds = [8, 16, 32] thds = [4, 8, 16, 20, 24, 28, 32] thds = [16] thds = [4, 8, 16, 24, 32] num_logger = 4 benchmarks = ['TPCC'] benchmarks = ['YCSB', 'TPCC'] benchmarks = ['YCSB'] algorithms = ['S'] algorithms = ['B', 'P', 'S'] algorithms = ['P', 'B'] algorithms = ['B'] algorithms = ['P'] algorithms = ['P', 'B'] algorithms = ['S', 'P', 'B', 'NO'] types = ['D'] # data logging and command logging types = ['C'] # data logging and command logging types = ['D', 'C'] # data logging and command logging configs = [] for bench in benchmarks: for alg in algorithms: if alg == 'NO': configs += ['%s_%s' % (alg, bench)] else: for t in types: if alg == 'B' and t == 'C': continue configs += ['%s%s_%s' % (alg, t, bench)] """ app_flags = {} ########################## ### test ########################## # logging for config in configs: thd = 16 num_logger = 4 executable = "./rundb_%s" % config logger = num_logger if config[0] == 'P' else 1 app_flags['LOG_RECOVER'] = 0 app_flags['REQ_PER_QUERY'] = 2 app_flags['READ_PERC'] = 0.5 app_flags['MAX_TXNS_PER_THREAD'] = 10000 app_flags['THREAD_CNT'] = thd app_flags['NUM_LOGGER'] = logger app_flags['LOG_NO_FLUSH'] = 0 app_flags['SYNTH_TABLE_SIZE'] = 1024 app_flags['NUM_WH'] = 1 output_dir = "results/test/%s/thd%d_L%s" % (config, thd, logger) add_dbms_job(app_flags, executable, output_dir) # recovery for config in configs: thd = 16 num_logger = 4 executable = "./rundb_%s" % config logger = num_logger if config[0] == 'P' else 1 app_flags['LOG_RECOVER'] = 1 app_flags['REQ_PER_QUERY'] = 2 app_flags['READ_PERC'] = 0.5 app_flags['MAX_TXNS_PER_THREAD'] = 10000 app_flags['THREAD_CNT'] = thd app_flags['NUM_LOGGER'] = logger app_flags['LOG_NO_FLUSH'] = 0 app_flags['SYNTH_TABLE_SIZE'] = 1024 app_flags['NUM_WH'] = 1 app_flags['LOG_PARALLEL_NUM_BUCKETS'] = 10000 output_dir = "results/test/%s_rec/thd%d_L%s" % (config, thd, logger) add_dbms_job(app_flags, executable, output_dir) ########################## ########################## ######################### """ """ app_flags = {} ########################## # Logging Performance ########################## for trial in trials: for config in configs: for thd in thds: executable = "./rundb_%s" % config logger = num_logger if config[0] == 'S' or config[0] == 'N': logger = 1 if 'TPCC' in config: app_flags['NUM_WH'] = 16 else : # YCSB app_flags['REQ_PER_QUERY'] = 2 app_flags['READ_PERC'] = 0.5 app_flags['MAX_TXNS_PER_THREAD'] = 1000000 app_flags['THREAD_CNT'] = thd app_flags['NUM_LOGGER'] = logger app_flags['LOG_NO_FLUSH'] = 0 output_dir = "results/%s/thd%d_L%s%s" % (config, thd, logger, trial) add_dbms_job(app_flags, executable, output_dir) """ """ app_flags = {} ########################## # RAMDisk Logging Performance ########################## for trial in trials: for config in configs: for thd in thds: executable = "./rundb_%s" % config logger = num_logger if config[0] == 'S' or config[0] == 'N': logger = 1 if 'TPCC' in config: app_flags['NUM_WH'] = 16 else : # YCSB app_flags['REQ_PER_QUERY'] = 2 app_flags['READ_PERC'] = 0.5 app_flags['MAX_TXNS_PER_THREAD'] = 1000000 app_flags['THREAD_CNT'] = thd app_flags['NUM_LOGGER'] = logger app_flags['LOG_NO_FLUSH'] = 1 output_dir = "results/%s_ramdisk/thd%d_L%s%s" % (config, thd, logger, trial) add_dbms_job(app_flags, executable, output_dir) """ """ # Batch logging with different epoch length for trial in trials: config = 'BD_YCSB' executable = "./rundb_%s" % config thd = 4 #for epoch in [10, 20, 40, 80, 160]: for epoch in [5]: logger = num_logger app_flags['REQ_PER_QUERY'] = 2 app_flags['READ_PERC'] = 0.5 app_flags['MAX_TXNS_PER_THREAD'] = 400000 if config[1] == 'D' else 1000000 app_flags['THREAD_CNT'] = thd app_flags['NUM_LOGGER'] = logger app_flags['EPOCH_PERIOD'] = epoch app_flags['LOG_NO_FLUSH'] = 0 output_dir = "results/%s/thd%d_L%s_E%d%s" % (config, thd, logger, epoch, trial) add_dbms_job(app_flags, executable, output_dir) """ """ ########################## # Generate Log Files ########################## app_flags = {} for config in configs: thd = 16 if 'NO' in config: continue executable = "./rundb_%s" % config logger = 1 if config[0] == 'S' else num_logger if 'TPCC' in config: app_flags['NUM_WH'] = 16 else : # YCSB app_flags['REQ_PER_QUERY'] = 2 app_flags['READ_PERC'] = 0.5 app_flags['MAX_TXNS_PER_THREAD'] = 1000000 app_flags['THREAD_CNT'] = thd app_flags['NUM_LOGGER'] = logger app_flags['LOG_NO_FLUSH'] = 0 app_flags['LOG_RECOVER'] = 0 app_flags['LOG_BUFFER_SIZE'] = 1048576 * 50 app_flags['LOG_CHUNK_SIZE'] = 1048576 * 10 output_dir = "results/%s_gen/thd%d_L%s" % (config, thd, logger) add_dbms_job(app_flags, executable, output_dir) # recover performance app_flags = {} for trial in trials: app_flags = {} for bench in benchmarks : #['YCSB', 'TPCC']: for alg in algorithms: if alg == 'NO': continue logger = 1 if alg == 'S' else num_logger for t in types: if alg == 'B' and t == 'C': continue config = '%s%s_%s' % (alg, t, bench) executable = "./rundb_%s" % config for thd in thds: if bench == 'TPCC': app_flags['NUM_WH'] = 16 app_flags['LOG_PARALLEL_REC_NUM_POOLS'] = 4 else: app_flags['LOG_PARALLEL_REC_NUM_POOLS'] = thd app_flags['THREAD_CNT'] = thd app_flags['LOG_RECOVER'] = 1 app_flags['NUM_LOGGER'] = logger app_flags['LOG_PARALLEL_NUM_BUCKETS'] = 10000000 output_dir = "results/%s_rec/thd%d_L%s%s" % \ (config, thd, logger, trial) add_dbms_job(app_flags, executable, output_dir) """ ############################## # sweep # of warehouse ############################## app_flags = {} bench = 'TPCC' #configs = ['SD', 'SC', 'PD', 'PC', 'BD'] configs = ['NO'] #SD', 'SC', 'PD', 'PC', 'BD'] configs = ['%s_TPCC' % x for x in configs] for wh in [1, 4, 8, 16, 32]: #logging performance for config in configs: thd = 32 executable = "./rundb_%s" % config logger = num_logger if config[0] == 'S' or config[0] == 'N': logger = 1 app_flags['NUM_WH'] = wh app_flags['MAX_TXNS_PER_THREAD'] = 1000000 app_flags['THREAD_CNT'] = thd app_flags['NUM_LOGGER'] = logger app_flags['LOG_NO_FLUSH'] = 0 output_dir = "results/%s/thd%d_L%s_wh%d" % (config, thd, logger, wh) add_dbms_job(app_flags, executable, output_dir) """ # recovery performance. generate logs. for wh in [1, 4, 8, 16, 32]: app_flags = {} # generate logs. for config in configs: thd = 16 executable = "./rundb_%s" % config logger = num_logger if config[0] == 'S' or config[0] == 'N': logger = 1 if 'TPCC' in config: app_flags['NUM_WH'] = wh app_flags['MAX_TXNS_PER_THREAD'] = 1000000 app_flags['THREAD_CNT'] = thd app_flags['NUM_LOGGER'] = logger app_flags['LOG_NO_FLUSH'] = 0 output_dir = "results/%s_gen/thd%d_L%s_wh%d" % (config, thd, logger, wh) add_dbms_job(app_flags, executable, output_dir) # recover performance app_flags = {} for config in configs: if 'NO' in config: continue if config[0] == 'B' and config[1] == 'C': continue logger = 1 if config[0] == 'S' else num_logger executable = "./rundb_%s" % config thd = 32 app_flags['NUM_WH'] = wh app_flags['LOG_PARALLEL_REC_NUM_POOLS'] = 4 app_flags['THREAD_CNT'] = thd app_flags['LOG_RECOVER'] = 1 app_flags['NUM_LOGGER'] = logger app_flags['LOG_PARALLEL_NUM_BUCKETS'] = 10000000 output_dir = "results/%s_rec/thd%d_L%s_wh%d" % \ (config, thd, logger, wh) add_dbms_job(app_flags, executable, output_dir) """ """ ############################## # sweep number of queries in YCSB ############################## bench = 'YCSB' configs = ['SD', 'SC', 'PD', 'PC', 'BD'] configs = ['%s_%s' % (x, bench) for x in configs] app_flags = {} for queries in [1, 2, 4, 8]: #logging performance for config in configs: thd = 32 executable = "./rundb_%s" % config logger = num_logger if config[0] == 'S' or config[0] == 'N': logger = 1 app_flags['REQ_PER_QUERY'] = queries app_flags['READ_PERC'] = 0.5 app_flags['MAX_TXNS_PER_THREAD'] = 1000000 app_flags['THREAD_CNT'] = thd app_flags['NUM_LOGGER'] = logger app_flags['LOG_NO_FLUSH'] = 0 output_dir = "results/%s/thd%d_L%s_q%d" % (config, thd, logger, queries) add_dbms_job(app_flags, executable, output_dir) # recovery performance. generate logs. for queries in [1, 2, 4, 8]: app_flags = {} # generate logs. for config in configs: thd = 16 executable = "./rundb_%s" % config logger = num_logger if config[0] == 'S' or config[0] == 'N': logger = 1 app_flags['REQ_PER_QUERY'] = queries app_flags['READ_PERC'] = 0.5 app_flags['MAX_TXNS_PER_THREAD'] = 1000000 app_flags['THREAD_CNT'] = thd app_flags['NUM_LOGGER'] = logger app_flags['LOG_NO_FLUSH'] = 0 output_dir = "results/%s_gen/thd%d_L%s_q%d" % (config, thd, logger, queries) add_dbms_job(app_flags, executable, output_dir) # recover performance app_flags = {} for config in configs: if 'NO' in config: continue if config[0] == 'B' and config[1] == 'C': continue logger = 1 if config[0] == 'S' else num_logger executable = "./rundb_%s" % config thd = 32 app_flags['REQ_PER_QUERY'] = queries app_flags['READ_PERC'] = 0.5 app_flags['LOG_PARALLEL_REC_NUM_POOLS'] = thd app_flags['THREAD_CNT'] = thd app_flags['LOG_RECOVER'] = 1 app_flags['NUM_LOGGER'] = logger app_flags['LOG_PARALLEL_NUM_BUCKETS'] = 10000000 output_dir = "results/%s_rec/thd%d_L%s_q%d" % \ (config, thd, logger, queries) add_dbms_job(app_flags, executable, output_dir) ############################## # sweep contention level ############################## app_flags = {} bench = 'YCSB' configs = ['SD', 'SC', 'PD', 'PC', 'BD'] configs = ['%s_%s' % (x, bench) for x in configs] for theta in [0, 0.6, 0.8, 0.9]: #logging performance for config in configs: thd = 32 executable = "./rundb_%s" % config logger = num_logger if config[0] == 'S' or config[0] == 'N': logger = 1 app_flags['REQ_PER_QUERY'] = 2 app_flags['READ_PERC'] = 0.5 app_flags['ZIPF_THETA'] = theta app_flags['MAX_TXNS_PER_THREAD'] = 1000000 app_flags['THREAD_CNT'] = thd app_flags['NUM_LOGGER'] = logger app_flags['LOG_NO_FLUSH'] = 0 output_dir = "results/%s/thd%d_L%s_z%s" % (config, thd, logger, theta) add_dbms_job(app_flags, executable, output_dir) # recovery performance. generate logs. for theta in [0, 0.6, 0.8, 0.9]: app_flags = {} # generate logs. for config in configs: thd = 16 executable = "./rundb_%s" % config logger = num_logger if config[0] == 'S' or config[0] == 'N': logger = 1 app_flags['REQ_PER_QUERY'] = 2 app_flags['READ_PERC'] = 0.5 app_flags['ZIPF_THETA'] = theta app_flags['MAX_TXNS_PER_THREAD'] = 1000000 app_flags['THREAD_CNT'] = thd app_flags['NUM_LOGGER'] = logger app_flags['LOG_NO_FLUSH'] = 0 output_dir = "results/%s_gen/thd%d_L%s_z%s" % (config, thd, logger, theta) add_dbms_job(app_flags, executable, output_dir) # recover performance app_flags = {} for config in configs: if 'NO' in config: continue if config[0] == 'B' and config[1] == 'C': continue logger = 1 if config[0] == 'S' else num_logger executable = "./rundb_%s" % config thd = 32 app_flags['REQ_PER_QUERY'] = 2 app_flags['READ_PERC'] = 0.5 app_flags['ZIPF_THETA'] = theta app_flags['LOG_PARALLEL_REC_NUM_POOLS'] = thd app_flags['THREAD_CNT'] = thd app_flags['LOG_RECOVER'] = 1 app_flags['NUM_LOGGER'] = logger app_flags['LOG_PARALLEL_NUM_BUCKETS'] = 10000000 output_dir = "results/%s_rec/thd%d_L%s_z%s" % (config, thd, logger, theta) add_dbms_job(app_flags, executable, output_dir) """ """ ################################## # sweep the number of loggers ################################## app_flags = {} bench = 'YCSB' configs = ['PD', 'PC', 'BD'] configs = ['%s_%s' % (x, bench) for x in configs] for logger in [1, 2]: #logging performance for config in configs: thd = 32 executable = "./rundb_%s" % config if config[0] == 'S' or config[0] == 'N': logger = 1 app_flags['REQ_PER_QUERY'] = 2 app_flags['READ_PERC'] = 0.5 app_flags['ZIPF_THETA'] = 0.6 app_flags['MAX_TXNS_PER_THREAD'] = 1000000 app_flags['THREAD_CNT'] = thd app_flags['NUM_LOGGER'] = logger app_flags['LOG_NO_FLUSH'] = 0 output_dir = "results/%s/thd%d_L%s" % (config, thd, logger) add_dbms_job(app_flags, executable, output_dir) # recovery performance. generate logs. for num_logger in [1, 2]: app_flags = {} # generate logs. for config in configs: thd = 16 executable = "./rundb_%s" % config logger = num_logger if config[0] == 'S' or config[0] == 'N': logger = 1 app_flags['REQ_PER_QUERY'] = 2 app_flags['READ_PERC'] = 0.5 app_flags['ZIPF_THETA'] = 0.6 app_flags['MAX_TXNS_PER_THREAD'] = 1000000 app_flags['THREAD_CNT'] = thd app_flags['NUM_LOGGER'] = logger app_flags['LOG_NO_FLUSH'] = 0 output_dir = "results/%s_gen/thd%d_L%s" % (config, thd, logger) add_dbms_job(app_flags, executable, output_dir) # recover performance app_flags = {} for config in configs: if 'NO' in config: continue if config[0] == 'B' and config[1] == 'C': continue logger = 1 if config[0] == 'S' else num_logger executable = "./rundb_%s" % config thd = 32 app_flags['REQ_PER_QUERY'] = 2 app_flags['READ_PERC'] = 0.5 app_flags['ZIPF_THETA'] = 0.6 app_flags['LOG_PARALLEL_REC_NUM_POOLS'] = thd app_flags['THREAD_CNT'] = thd app_flags['LOG_RECOVER'] = 1 app_flags['NUM_LOGGER'] = logger app_flags['LOG_PARALLEL_NUM_BUCKETS'] = 10000000 output_dir = "results/%s_rec/thd%d_L%s" % (config, thd, logger) add_dbms_job(app_flags, executable, output_dir) """ scheduler.generateSubmitFile()
414
0
23
56e2f739f22e14fa46944fddc6d4bb6c6f1226be
152
py
Python
compiled/construct/opaque_with_param.py
smarek/ci_targets
c5edee7b0901fd8e7f75f85245ea4209b38e0cb3
[ "MIT" ]
4
2017-04-08T12:55:11.000Z
2020-12-05T21:09:31.000Z
compiled/construct/opaque_with_param.py
smarek/ci_targets
c5edee7b0901fd8e7f75f85245ea4209b38e0cb3
[ "MIT" ]
7
2018-04-23T01:30:33.000Z
2020-10-30T23:56:14.000Z
compiled/construct/opaque_with_param.py
smarek/ci_targets
c5edee7b0901fd8e7f75f85245ea4209b38e0cb3
[ "MIT" ]
6
2017-04-08T11:41:14.000Z
2020-10-30T22:47:31.000Z
from construct import * from construct.lib import * opaque_with_param = Struct( 'one' / LazyBound(lambda: params_def), ) _schema = opaque_with_param
16.888889
39
0.763158
from construct import * from construct.lib import * opaque_with_param = Struct( 'one' / LazyBound(lambda: params_def), ) _schema = opaque_with_param
0
0
0
85b9d73931a1a3a5f2a12915b8b01497ab128c23
521,619
py
Python
sympy/integrals/rubi/rules/inverse_hyperbolic.py
STALKER2010/sympy-bleeding-edge
81233029a9a30866747f6da2c0e9604d1681d474
[ "BSD-3-Clause" ]
2
2018-12-05T02:30:43.000Z
2020-11-14T01:43:15.000Z
sympy/integrals/rubi/rules/inverse_hyperbolic.py
STALKER2010/sympy-bleeding-edge
81233029a9a30866747f6da2c0e9604d1681d474
[ "BSD-3-Clause" ]
1
2017-10-23T06:56:43.000Z
2017-10-23T06:56:43.000Z
sympy/integrals/rubi/rules/inverse_hyperbolic.py
STALKER2010/sympy-bleeding-edge
81233029a9a30866747f6da2c0e9604d1681d474
[ "BSD-3-Clause" ]
1
2020-10-02T15:05:03.000Z
2020-10-02T15:05:03.000Z
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 from sympy.integrals.rubi.utility_function import (Int, 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) from sympy import Integral, S, sqrt from sympy.integrals.rubi.symbol import WC from sympy.core.symbol import symbols, Symbol from sympy.functions import (log, sin, cos, tan, cot, csc, sec, sqrt, erf, exp, log) 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) 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']] _UseGamma = False
185.563501
6,553
0.591269
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 from sympy.integrals.rubi.utility_function import (Int, 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) from sympy import Integral, S, sqrt from sympy.integrals.rubi.symbol import WC from sympy.core.symbol import symbols, Symbol from sympy.functions import (log, sin, cos, tan, cot, csc, sec, sqrt, erf, exp, log) 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) 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']] _UseGamma = False def inverse_hyperbolic(rubi): pattern1 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(0)))) rule1 = ReplacementRule(pattern1, lambda x, b, c, a, n : -b*c*n*Int(x*(a + b*asinh(c*x))**(n + S(-1))/sqrt(c**S(2)*x**S(2) + S(1)), x) + x*(a + b*asinh(c*x))**n) rubi.add(rule1) pattern2 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(0)))) rule2 = ReplacementRule(pattern2, lambda x, b, c, a, n : -b*c*n*Int(x*(a + b*acosh(c*x))**(n + S(-1))/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), x) + x*(a + b*acosh(c*x))**n) rubi.add(rule2) pattern3 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Less(n, S(-1)))) rule3 = ReplacementRule(pattern3, lambda x, b, c, a, n : -c*Int(x*(a + b*asinh(c*x))**(n + S(1))/sqrt(c**S(2)*x**S(2) + S(1)), x)/(b*(n + S(1))) + (a + b*asinh(c*x))**(n + S(1))*sqrt(c**S(2)*x**S(2) + S(1))/(b*c*(n + S(1)))) rubi.add(rule3) pattern4 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Less(n, S(-1)))) rule4 = ReplacementRule(pattern4, lambda x, b, c, a, n : -c*Int(x*(a + b*acosh(c*x))**(n + S(1))/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), x)/(b*(n + S(1))) + (a + b*acosh(c*x))**(n + S(1))*sqrt(c*x + S(-1))*sqrt(c*x + S(1))/(b*c*(n + S(1)))) rubi.add(rule4) pattern5 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda n, x: FreeQ(n, x))) rule5 = ReplacementRule(pattern5, lambda x, b, c, a, n : Subst(Int(x**n*Cosh(a/b - x/b), x), x, a + b*asinh(c*x))/(b*c)) rubi.add(rule5) pattern6 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda n, x: FreeQ(n, x))) rule6 = ReplacementRule(pattern6, lambda x, b, c, a, n : -Subst(Int(x**n*sinh(a/b - x/b), x), x, a + b*acosh(c*x))/(b*c)) rubi.add(rule6) pattern7 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1))/x_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda n: PositiveIntegerQ(n))) rule7 = ReplacementRule(pattern7, lambda x, b, c, a, n : Subst(Int((a + b*x)**n/tanh(x), x), x, asinh(c*x))) rubi.add(rule7) pattern8 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1))/x_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda n: PositiveIntegerQ(n))) rule8 = ReplacementRule(pattern8, lambda x, b, c, a, n : Subst(Int((a + b*x)**n/coth(x), x), x, acosh(c*x))) rubi.add(rule8) pattern9 = Pattern(Integral((x_*WC('d', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n: PositiveIntegerQ(n)), CustomConstraint(lambda m: NonzeroQ(m + S(1)))) rule9 = ReplacementRule(pattern9, lambda x, b, m, c, a, d, n : -b*c*n*Int((d*x)**(m + S(1))*(a + b*asinh(c*x))**(n + S(-1))/sqrt(c**S(2)*x**S(2) + S(1)), x)/(d*(m + S(1))) + (d*x)**(m + S(1))*(a + b*asinh(c*x))**n/(d*(m + S(1)))) rubi.add(rule9) pattern10 = Pattern(Integral((x_*WC('d', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n: PositiveIntegerQ(n)), CustomConstraint(lambda m: NonzeroQ(m + S(1)))) rule10 = ReplacementRule(pattern10, lambda x, b, m, c, a, d, n : -b*c*n*Int((d*x)**(m + S(1))*(a + b*acosh(c*x))**(n + S(-1))/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), x)/(d*(m + S(1))) + (d*x)**(m + S(1))*(a + b*acosh(c*x))**n/(d*(m + S(1)))) rubi.add(rule10) pattern11 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda m: PositiveIntegerQ(m)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(0)))) rule11 = ReplacementRule(pattern11, lambda x, b, m, c, a, n : -b*c*n*Int(x**(m + S(1))*(a + b*asinh(c*x))**(n + S(-1))/sqrt(c**S(2)*x**S(2) + S(1)), x)/(m + S(1)) + x**(m + S(1))*(a + b*asinh(c*x))**n/(m + S(1))) rubi.add(rule11) pattern12 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda m: PositiveIntegerQ(m)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(0)))) rule12 = ReplacementRule(pattern12, lambda x, b, m, c, a, n : -b*c*n*Int(x**(m + S(1))*(a + b*acosh(c*x))**(n + S(-1))/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), x)/(m + S(1)) + x**(m + S(1))*(a + b*acosh(c*x))**n/(m + S(1))) rubi.add(rule12) pattern13 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda m: PositiveIntegerQ(m)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Inequality(S(-2), LessEqual, n, Less, S(-1)))) rule13 = ReplacementRule(pattern13, lambda x, b, m, c, a, n : -c**(-m + S(-1))*Subst(Int(ExpandTrigReduce((a + b*x)**(n + S(1)), (m + (m + S(1))*sinh(x)**S(2))*sinh(x)**(m + S(-1)), x), x), x, asinh(c*x))/(b*(n + S(1))) + x**m*(a + b*asinh(c*x))**(n + S(1))*sqrt(c**S(2)*x**S(2) + S(1))/(b*c*(n + S(1)))) rubi.add(rule13) pattern14 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda m: PositiveIntegerQ(m)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Inequality(S(-2), LessEqual, n, Less, S(-1)))) rule14 = ReplacementRule(pattern14, lambda x, b, m, c, a, n : c**(-m + S(-1))*Subst(Int(ExpandTrigReduce((a + b*x)**(n + S(1))*(m - (m + S(1))*Cosh(x)**S(2))*Cosh(x)**(m + S(-1)), x), x), x, acosh(c*x))/(b*(n + S(1))) + x**m*(a + b*acosh(c*x))**(n + S(1))*sqrt(c*x + S(-1))*sqrt(c*x + S(1))/(b*c*(n + S(1)))) rubi.add(rule14) pattern15 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda m: PositiveIntegerQ(m)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Less(n, S(-2)))) rule15 = ReplacementRule(pattern15, lambda x, b, m, c, a, n : -c*(m + S(1))*Int(x**(m + S(1))*(a + b*asinh(c*x))**(n + S(1))/sqrt(c**S(2)*x**S(2) + S(1)), x)/(b*(n + S(1))) - m*Int(x**(m + S(-1))*(a + b*asinh(c*x))**(n + S(1))/sqrt(c**S(2)*x**S(2) + S(1)), x)/(b*c*(n + S(1))) + x**m*(a + b*asinh(c*x))**(n + S(1))*sqrt(c**S(2)*x**S(2) + S(1))/(b*c*(n + S(1)))) rubi.add(rule15) pattern16 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda m: PositiveIntegerQ(m)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Less(n, S(-2)))) rule16 = ReplacementRule(pattern16, lambda x, b, m, c, a, n : -c*(m + S(1))*Int(x**(m + S(1))*(a + b*acosh(c*x))**(n + S(1))/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), x)/(b*(n + S(1))) + m*Int(x**(m + S(-1))*(a + b*acosh(c*x))**(n + S(1))/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), x)/(b*c*(n + S(1))) + x**m*(a + b*acosh(c*x))**(n + S(1))*sqrt(c*x + S(-1))*sqrt(c*x + S(1))/(b*c*(n + S(1)))) rubi.add(rule16) pattern17 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda m: PositiveIntegerQ(m))) rule17 = ReplacementRule(pattern17, lambda x, b, m, c, a, n : c**(-m + S(-1))*Subst(Int((a + b*x)**n*Cosh(x)*sinh(x)**m, x), x, asinh(c*x))) rubi.add(rule17) pattern18 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda m: PositiveIntegerQ(m))) rule18 = ReplacementRule(pattern18, lambda x, b, m, c, a, n : c**(-m + S(-1))*Subst(Int((a + b*x)**n*Cosh(x)**m*sinh(x), x), x, acosh(c*x))) rubi.add(rule18) pattern19 = Pattern(Integral((x_*WC('d', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n, x: FreeQ(n, x))) rule19 = ReplacementRule(pattern19, lambda x, b, m, c, a, d, n : Int((d*x)**m*(a + b*asinh(c*x))**n, x)) rubi.add(rule19) pattern20 = Pattern(Integral((x_*WC('d', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n, x: FreeQ(n, x))) rule20 = ReplacementRule(pattern20, lambda x, b, m, c, a, d, n : Int((d*x)**m*(a + b*acosh(c*x))**n, x)) rubi.add(rule20) pattern21 = Pattern(Integral(S(1)/(sqrt(d_ + x_**S(2)*WC('e', S(1)))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda d: PositiveQ(d))) rule21 = ReplacementRule(pattern21, lambda x, b, c, a, d, e : log(a + b*asinh(c*x))/(b*c*sqrt(d))) rubi.add(rule21) pattern22 = Pattern(Integral(S(1)/(sqrt(d1_ + x_*WC('e1', S(1)))*sqrt(d2_ + x_*WC('e2', S(1)))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda d1: PositiveQ(d1)), CustomConstraint(lambda d2: NegativeQ(d2))) rule22 = ReplacementRule(pattern22, lambda e2, e1, d1, x, b, c, a, d2 : log(a + b*acosh(c*x))/(b*c*sqrt(-d1*d2))) rubi.add(rule22) pattern23 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda d: PositiveQ(d)), CustomConstraint(lambda n: NonzeroQ(n + S(1)))) rule23 = ReplacementRule(pattern23, lambda x, b, c, a, d, e, n : (a + b*asinh(c*x))**(n + S(1))/(b*c*sqrt(d)*(n + S(1)))) rubi.add(rule23) pattern24 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1))/(sqrt(d1_ + x_*WC('e1', S(1)))*sqrt(d2_ + x_*WC('e2', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda d1: PositiveQ(d1)), CustomConstraint(lambda d2: NegativeQ(d2)), CustomConstraint(lambda n: NonzeroQ(n + S(1)))) rule24 = ReplacementRule(pattern24, lambda e2, e1, d1, x, b, c, a, d2, n : (a + b*acosh(c*x))**(n + S(1))/(b*c*sqrt(-d1*d2)*(n + S(1)))) rubi.add(rule24) pattern25 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda d: Not(PositiveQ(d)))) rule25 = ReplacementRule(pattern25, lambda x, b, c, a, d, e, n : sqrt(c**S(2)*x**S(2) + S(1))*Int((a + b*asinh(c*x))**n/sqrt(c**S(2)*x**S(2) + S(1)), x)/sqrt(d + e*x**S(2))) rubi.add(rule25) pattern26 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1))/(sqrt(d1_ + x_*WC('e1', S(1)))*sqrt(d2_ + x_*WC('e2', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda d2, d1: Not(NegativeQ(d2) & PositiveQ(d1)))) rule26 = ReplacementRule(pattern26, lambda e2, e1, d1, x, b, c, a, d2, n : sqrt(c*x + S(-1))*sqrt(c*x + S(1))*Int((a + b*acosh(c*x))**n/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), x)/(sqrt(d1 + e1*x)*sqrt(d2 + e2*x))) rubi.add(rule26) pattern27 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda p: PositiveIntegerQ(p)), ) def With27(p, x, b, c, a, d, e): u = IntHide((d + e*x**S(2))**p, x) return -b*c*Int(SimplifyIntegrand(u/sqrt(c**S(2)*x**S(2) + S(1)), x), x) + Dist(a + b*asinh(c*x), u, x) rule27 = ReplacementRule(pattern27, lambda p, x, b, c, a, d, e : With27(p, x, b, c, a, d, e)) rubi.add(rule27) pattern28 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda p: PositiveIntegerQ(p)), ) def With28(p, x, b, c, a, d, e): u = IntHide((d + e*x**S(2))**p, x) return -b*c*Int(SimplifyIntegrand(u/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), x), x) + Dist(a + b*acosh(c*x), u, x) rule28 = ReplacementRule(pattern28, lambda p, x, b, c, a, d, e : With28(p, x, b, c, a, d, e)) rubi.add(rule28) pattern29 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda p, n: RationalQ(n, p)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda p: Greater(p, S(0))), CustomConstraint(lambda p: IntegerQ(p))) rule29 = ReplacementRule(pattern29, lambda p, x, b, c, a, d, e, n : -b*c*n*(-d)**p*Int(x*(a + b*acosh(c*x))**(n + S(-1))*(c*x + S(-1))**(p + S(-1)/2)*(c*x + S(1))**(p + S(-1)/2), x)/(S(2)*p + S(1)) + S(2)*d*p*Int((a + b*acosh(c*x))**n*(d + e*x**S(2))**(p + S(-1)), x)/(S(2)*p + S(1)) + x*(a + b*acosh(c*x))**n*(d + e*x**S(2))**p/(S(2)*p + S(1))) rubi.add(rule29) pattern30 = Pattern(Integral(sqrt(d_ + x_**S(2)*WC('e', S(1)))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(0)))) rule30 = ReplacementRule(pattern30, lambda x, b, c, a, d, e, n : -b*c*n*sqrt(d + e*x**S(2))*Int(x*(a + b*asinh(c*x))**(n + S(-1)), x)/(S(2)*sqrt(c**S(2)*x**S(2) + S(1))) + x*(a + b*asinh(c*x))**n*sqrt(d + e*x**S(2))/S(2) + sqrt(d + e*x**S(2))*Int((a + b*asinh(c*x))**n/sqrt(c**S(2)*x**S(2) + S(1)), x)/(S(2)*sqrt(c**S(2)*x**S(2) + S(1)))) rubi.add(rule30) pattern31 = Pattern(Integral(sqrt(d1_ + x_*WC('e1', S(1)))*sqrt(d2_ + x_*WC('e2', S(1)))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(0)))) rule31 = ReplacementRule(pattern31, lambda e2, e1, d1, x, b, c, a, d2, n : -b*c*n*sqrt(d1 + e1*x)*sqrt(d2 + e2*x)*Int(x*(a + b*acosh(c*x))**(n + S(-1)), x)/(S(2)*sqrt(c*x + S(-1))*sqrt(c*x + S(1))) + x*(a + b*acosh(c*x))**n*sqrt(d1 + e1*x)*sqrt(d2 + e2*x)/S(2) - sqrt(d1 + e1*x)*sqrt(d2 + e2*x)*Int((a + b*acosh(c*x))**n/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), x)/(S(2)*sqrt(c*x + S(-1))*sqrt(c*x + S(1)))) rubi.add(rule31) pattern32 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda p, n: RationalQ(n, p)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda p: Greater(p, S(0)))) rule32 = ReplacementRule(pattern32, lambda p, x, b, c, a, d, e, n : -b*c*d**IntPart(p)*n*(d + e*x**S(2))**FracPart(p)*(c**S(2)*x**S(2) + S(1))**(-FracPart(p))*Int(x*(a + b*asinh(c*x))**(n + S(-1))*(c**S(2)*x**S(2) + S(1))**(p + S(-1)/2), x)/(S(2)*p + S(1)) + S(2)*d*p*Int((a + b*asinh(c*x))**n*(d + e*x**S(2))**(p + S(-1)), x)/(S(2)*p + S(1)) + x*(a + b*asinh(c*x))**n*(d + e*x**S(2))**p/(S(2)*p + S(1))) rubi.add(rule32) pattern33 = Pattern(Integral((d1_ + x_*WC('e1', S(1)))**WC('p', S(1))*(d2_ + x_*WC('e2', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda p, n: RationalQ(n, p)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda p: Greater(p, S(0))), CustomConstraint(lambda p: IntegerQ(p + S(-1)/2))) rule33 = ReplacementRule(pattern33, lambda p, e2, e1, d1, x, b, c, a, d2, n : -b*c*n*(-d1*d2)**(p + S(-1)/2)*sqrt(d1 + e1*x)*sqrt(d2 + e2*x)*Int(x*(a + b*acosh(c*x))**(n + S(-1))*(c**S(2)*x**S(2) + S(-1))**(p + S(-1)/2), x)/((S(2)*p + S(1))*sqrt(c*x + S(-1))*sqrt(c*x + S(1))) + S(2)*d1*d2*p*Int((a + b*acosh(c*x))**n*(d1 + e1*x)**(p + S(-1))*(d2 + e2*x)**(p + S(-1)), x)/(S(2)*p + S(1)) + x*(a + b*acosh(c*x))**n*(d1 + e1*x)**p*(d2 + e2*x)**p/(S(2)*p + S(1))) rubi.add(rule33) pattern34 = Pattern(Integral((d1_ + x_*WC('e1', S(1)))**WC('p', S(1))*(d2_ + x_*WC('e2', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda p, n: RationalQ(n, p)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda p: Greater(p, S(0)))) rule34 = ReplacementRule(pattern34, lambda p, e2, e1, d1, x, b, c, a, d2, n : -b*c*n*(-d1*d2)**IntPart(p)*(d1 + e1*x)**FracPart(p)*(d2 + e2*x)**FracPart(p)*(c*x + S(-1))**(-FracPart(p))*(c*x + S(1))**(-FracPart(p))*Int(x*(a + b*acosh(c*x))**(n + S(-1))*(c*x + S(-1))**(p + S(-1)/2)*(c*x + S(1))**(p + S(-1)/2), x)/(S(2)*p + S(1)) + S(2)*d1*d2*p*Int((a + b*acosh(c*x))**n*(d1 + e1*x)**(p + S(-1))*(d2 + e2*x)**(p + S(-1)), x)/(S(2)*p + S(1)) + x*(a + b*acosh(c*x))**n*(d1 + e1*x)**p*(d2 + e2*x)**p/(S(2)*p + S(1))) rubi.add(rule34) pattern35 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1)))**(S(3)/2), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(0)))) rule35 = ReplacementRule(pattern35, lambda x, b, c, a, d, e, n : -b*c*n*sqrt(c**S(2)*x**S(2) + S(1))*Int(x*(a + b*asinh(c*x))**(n + S(-1))/(c**S(2)*x**S(2) + S(1)), x)/(d*sqrt(d + e*x**S(2))) + x*(a + b*asinh(c*x))**n/(d*sqrt(d + e*x**S(2)))) rubi.add(rule35) pattern36 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1))/((d1_ + x_*WC('e1', S(1)))**(S(3)/2)*(d2_ + x_*WC('e2', S(1)))**(S(3)/2)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(0)))) rule36 = ReplacementRule(pattern36, lambda e2, e1, d1, x, b, c, a, d2, n : b*c*n*sqrt(c*x + S(-1))*sqrt(c*x + S(1))*Int(x*(a + b*acosh(c*x))**(n + S(-1))/(-c**S(2)*x**S(2) + S(1)), x)/(d1*d2*sqrt(d1 + e1*x)*sqrt(d2 + e2*x)) + x*(a + b*acosh(c*x))**n/(d1*d2*sqrt(d1 + e1*x)*sqrt(d2 + e2*x))) rubi.add(rule36) pattern37 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda p, n: RationalQ(n, p)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda p: Less(p, S(-1))), CustomConstraint(lambda p: IntegerQ(p))) rule37 = ReplacementRule(pattern37, lambda p, x, b, c, a, d, e, n : -b*c*n*(-d)**p*Int(x*(a + b*acosh(c*x))**(n + S(-1))*(c*x + S(-1))**(p + S(1)/2)*(c*x + S(1))**(p + S(1)/2), x)/(S(2)*p + S(2)) - x*(a + b*acosh(c*x))**n*(d + e*x**S(2))**(p + S(1))/(S(2)*d*(p + S(1))) + (S(2)*p + S(3))*Int((a + b*acosh(c*x))**n*(d + e*x**S(2))**(p + S(1)), x)/(S(2)*d*(p + S(1)))) rubi.add(rule37) pattern38 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda p, n: RationalQ(n, p)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda p: Less(p, S(-1))), CustomConstraint(lambda p: Unequal(p, S(-3)/2))) rule38 = ReplacementRule(pattern38, lambda p, x, b, c, a, d, e, n : b*c*d**IntPart(p)*n*(d + e*x**S(2))**FracPart(p)*(c**S(2)*x**S(2) + S(1))**(-FracPart(p))*Int(x*(a + b*asinh(c*x))**(n + S(-1))*(c**S(2)*x**S(2) + S(1))**(p + S(1)/2), x)/(S(2)*(p + S(1))) - x*(a + b*asinh(c*x))**n*(d + e*x**S(2))**(p + S(1))/(S(2)*d*(p + S(1))) + (S(2)*p + S(3))*Int((a + b*asinh(c*x))**n*(d + e*x**S(2))**(p + S(1)), x)/(S(2)*d*(p + S(1)))) rubi.add(rule38) pattern39 = Pattern(Integral((d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda p, n: RationalQ(n, p)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda p: Less(p, S(-1))), CustomConstraint(lambda p: Unequal(p, S(-3)/2)), CustomConstraint(lambda p: IntegerQ(p + S(1)/2))) rule39 = ReplacementRule(pattern39, lambda p, e2, e1, d1, x, b, c, a, d2, n : -b*c*n*(-d1*d2)**(p + S(1)/2)*sqrt(c*x + S(-1))*sqrt(c*x + S(1))*Int(x*(a + b*acosh(c*x))**(n + S(-1))*(c**S(2)*x**S(2) + S(-1))**(p + S(1)/2), x)/(S(2)*sqrt(d1 + e1*x)*sqrt(d2 + e2*x)*(p + S(1))) - x*(a + b*acosh(c*x))**n*(d1 + e1*x)**(p + S(1))*(d2 + e2*x)**(p + S(1))/(S(2)*d1*d2*(p + S(1))) + (S(2)*p + S(3))*Int((a + b*acosh(c*x))**n*(d1 + e1*x)**(p + S(1))*(d2 + e2*x)**(p + S(1)), x)/(S(2)*d1*d2*(p + S(1)))) rubi.add(rule39) pattern40 = Pattern(Integral((d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda p, n: RationalQ(n, p)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda p: Less(p, S(-1))), CustomConstraint(lambda p: Unequal(p, S(-3)/2))) rule40 = ReplacementRule(pattern40, lambda p, e2, e1, d1, x, b, c, a, d2, n : -b*c*n*(-d1*d2)**IntPart(p)*(d1 + e1*x)**FracPart(p)*(d2 + e2*x)**FracPart(p)*(c*x + S(-1))**(-FracPart(p))*(c*x + S(1))**(-FracPart(p))*Int(x*(a + b*acosh(c*x))**(n + S(-1))*(c*x + S(-1))**(p + S(1)/2)*(c*x + S(1))**(p + S(1)/2), x)/(S(2)*(p + S(1))) - x*(a + b*acosh(c*x))**n*(d1 + e1*x)**(p + S(1))*(d2 + e2*x)**(p + S(1))/(S(2)*d1*d2*(p + S(1))) + (S(2)*p + S(3))*Int((a + b*acosh(c*x))**n*(d1 + e1*x)**(p + S(1))*(d2 + e2*x)**(p + S(1)), x)/(S(2)*d1*d2*(p + S(1)))) rubi.add(rule40) pattern41 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda n: PositiveIntegerQ(n))) rule41 = ReplacementRule(pattern41, lambda x, b, c, a, d, e, n : Subst(Int((a + b*x)**n*sech(x), x), x, asinh(c*x))/(c*d)) rubi.add(rule41) pattern42 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: PositiveIntegerQ(n))) rule42 = ReplacementRule(pattern42, lambda x, b, c, a, d, e, n : -Subst(Int((a + b*x)**n*csch(x), x), x, acosh(c*x))/(c*d)) rubi.add(rule42) pattern43 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Less(n, S(-1))), CustomConstraint(lambda p: IntegerQ(p))) rule43 = ReplacementRule(pattern43, lambda p, x, b, c, a, d, e, n : -c*(-d)**p*(S(2)*p + S(1))*Int(x*(a + b*acosh(c*x))**(n + S(1))*(c*x + S(-1))**(p + S(-1)/2)*(c*x + S(1))**(p + S(-1)/2), x)/(b*(n + S(1))) + (-d)**p*(a + b*acosh(c*x))**(n + S(1))*(c*x + S(-1))**(p + S(1)/2)*(c*x + S(1))**(p + S(1)/2)/(b*c*(n + S(1)))) rubi.add(rule43) pattern44 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Less(n, S(-1)))) rule44 = ReplacementRule(pattern44, lambda p, x, b, c, a, d, e, n : -c*d**IntPart(p)*(d + e*x**S(2))**FracPart(p)*(S(2)*p + S(1))*(c**S(2)*x**S(2) + S(1))**(-FracPart(p))*Int(x*(a + b*asinh(c*x))**(n + S(1))*(c**S(2)*x**S(2) + S(1))**(p + S(-1)/2), x)/(b*(n + S(1))) + (a + b*asinh(c*x))**(n + S(1))*(d + e*x**S(2))**p*sqrt(c**S(2)*x**S(2) + S(1))/(b*c*(n + S(1)))) rubi.add(rule44) pattern45 = Pattern(Integral((d1_ + x_*WC('e1', S(1)))**WC('p', S(1))*(d2_ + x_*WC('e2', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Less(n, S(-1))), CustomConstraint(lambda p: IntegerQ(p + S(-1)/2))) rule45 = ReplacementRule(pattern45, lambda p, e2, e1, d1, x, b, c, a, d2, n : -c*(-d1*d2)**(p + S(-1)/2)*sqrt(d1 + e1*x)*sqrt(d2 + e2*x)*(S(2)*p + S(1))*Int(x*(a + b*acosh(c*x))**(n + S(1))*(c**S(2)*x**S(2) + S(-1))**(p + S(-1)/2), x)/(b*(n + S(1))*sqrt(c*x + S(-1))*sqrt(c*x + S(1))) + (a + b*acosh(c*x))**(n + S(1))*(d1 + e1*x)**p*(d2 + e2*x)**p*sqrt(c*x + S(-1))*sqrt(c*x + S(1))/(b*c*(n + S(1)))) rubi.add(rule45) pattern46 = Pattern(Integral((d1_ + x_*WC('e1', S(1)))**WC('p', S(1))*(d2_ + x_*WC('e2', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Less(n, S(-1)))) rule46 = ReplacementRule(pattern46, lambda p, e2, e1, d1, x, b, c, a, d2, n : -c*(-d1*d2)**IntPart(p)*(d1 + e1*x)**FracPart(p)*(d2 + e2*x)**FracPart(p)*(S(2)*p + S(1))*(c*x + S(-1))**(-FracPart(p))*(c*x + S(1))**(-FracPart(p))*Int(x*(a + b*acosh(c*x))**(n + S(1))*(c*x + S(-1))**(p + S(-1)/2)*(c*x + S(1))**(p + S(-1)/2), x)/(b*(n + S(1))) + (a + b*acosh(c*x))**(n + S(1))*(d1 + e1*x)**p*(d2 + e2*x)**p*sqrt(c*x + S(-1))*sqrt(c*x + S(1))/(b*c*(n + S(1)))) rubi.add(rule46) pattern47 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda p: PositiveIntegerQ(S(2)*p)), CustomConstraint(lambda d, p: IntegerQ(p) | PositiveQ(d))) rule47 = ReplacementRule(pattern47, lambda p, x, b, c, a, d, e, n : d**p*Subst(Int((a + b*x)**n*Cosh(x)**(S(2)*p + S(1)), x), x, asinh(c*x))/c) rubi.add(rule47) pattern48 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda p: PositiveIntegerQ(p))) rule48 = ReplacementRule(pattern48, lambda p, x, b, c, a, d, e, n : (-d)**p*Subst(Int((a + b*x)**n*sinh(x)**(S(2)*p + S(1)), x), x, acosh(c*x))/c) rubi.add(rule48) pattern49 = Pattern(Integral((d1_ + x_*WC('e1', S(1)))**WC('p', S(1))*(d2_ + x_*WC('e2', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda p: PositiveIntegerQ(p + S(1)/2)), CustomConstraint(lambda d2, d1: NegativeQ(d2) & PositiveQ(d1))) rule49 = ReplacementRule(pattern49, lambda p, e2, e1, d1, x, b, c, a, d2, n : (-d1*d2)**p*Subst(Int((a + b*x)**n*sinh(x)**(S(2)*p + S(1)), x), x, acosh(c*x))/c) rubi.add(rule49) pattern50 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda p: PositiveIntegerQ(S(2)*p)), CustomConstraint(lambda d, p: Not(IntegerQ(p) | PositiveQ(d)))) rule50 = ReplacementRule(pattern50, lambda p, x, b, c, a, d, e, n : d**(p + S(-1)/2)*sqrt(d + e*x**S(2))*Int((a + b*asinh(c*x))**n*(c**S(2)*x**S(2) + S(1))**p, x)/sqrt(c**S(2)*x**S(2) + S(1))) rubi.add(rule50) pattern51 = Pattern(Integral((d1_ + x_*WC('e1', S(1)))**WC('p', S(1))*(d2_ + x_*WC('e2', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda p: PositiveIntegerQ(S(2)*p)), CustomConstraint(lambda d2, d1: Not(NegativeQ(d2) & PositiveQ(d1)))) rule51 = ReplacementRule(pattern51, lambda p, e2, e1, d1, x, b, c, a, d2, n : (-d1*d2)**(p + S(-1)/2)*sqrt(d1 + e1*x)*sqrt(d2 + e2*x)*Int((a + b*acosh(c*x))**n*(c*x + S(-1))**p*(c*x + S(1))**p, x)/(sqrt(c*x + S(-1))*sqrt(c*x + S(1)))) rubi.add(rule51) pattern52 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, d, e: NonzeroQ(-c**S(2)*d + e)), CustomConstraint(lambda p: PositiveIntegerQ(p) | NegativeIntegerQ(p + S(1)/2)), ) def With52(p, x, b, c, a, d, e): u = IntHide((d + e*x**S(2))**p, x) return -b*c*Int(SimplifyIntegrand(u/sqrt(c**S(2)*x**S(2) + S(1)), x), x) + Dist(a + b*asinh(c*x), u, x) rule52 = ReplacementRule(pattern52, lambda p, x, b, c, a, d, e : With52(p, x, b, c, a, d, e)) rubi.add(rule52) pattern53 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: NonzeroQ(c**S(2)*d + e)), CustomConstraint(lambda p: PositiveIntegerQ(p) | NegativeIntegerQ(p + S(1)/2)), ) def With53(p, x, b, c, a, d, e): u = IntHide((d + e*x**S(2))**p, x) return -b*c*Int(SimplifyIntegrand(u/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), x), x) + Dist(a + b*acosh(c*x), u, x) rule53 = ReplacementRule(pattern53, lambda p, x, b, c, a, d, e : With53(p, x, b, c, a, d, e)) rubi.add(rule53) pattern54 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, d, e: NonzeroQ(-c**S(2)*d + e)), CustomConstraint(lambda p: IntegerQ(p)), CustomConstraint(lambda p, n: PositiveIntegerQ(n) | Greater(p, S(0)))) rule54 = ReplacementRule(pattern54, lambda p, x, b, c, a, d, e, n : Int(ExpandIntegrand((a + b*asinh(c*x))**n, (d + e*x**S(2))**p, x), x)) rubi.add(rule54) pattern55 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, e, d: NonzeroQ(c**S(2)*d + e)), CustomConstraint(lambda p: IntegerQ(p)), CustomConstraint(lambda p, n: PositiveIntegerQ(n) | Greater(p, S(0)))) rule55 = ReplacementRule(pattern55, lambda p, x, b, c, a, d, e, n : Int(ExpandIntegrand((a + b*acosh(c*x))**n, (d + e*x**S(2))**p, x), x)) rubi.add(rule55) pattern56 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x))) rule56 = ReplacementRule(pattern56, lambda p, x, b, c, a, d, e, n : Int((a + b*asinh(c*x))**n*(d + e*x**S(2))**p, x)) rubi.add(rule56) pattern57 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda p: IntegerQ(p))) rule57 = ReplacementRule(pattern57, lambda p, x, b, c, a, d, e, n : Int((a + b*acosh(c*x))**n*(d + e*x**S(2))**p, x)) rubi.add(rule57) pattern58 = Pattern(Integral((d1_ + x_*WC('e1', S(1)))**WC('p', S(1))*(d2_ + x_*WC('e2', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x))) rule58 = ReplacementRule(pattern58, lambda p, e2, e1, d1, x, b, c, a, d2, n : Int((a + b*acosh(c*x))**n*(d1 + e1*x)**p*(d2 + e2*x)**p, x)) rubi.add(rule58) pattern59 = Pattern(Integral((d_ + x_*WC('e', S(1)))**p_*(f_ + x_*WC('g', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda g, x: FreeQ(g, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda g, f, d, e: ZeroQ(d*g + e*f)), CustomConstraint(lambda g, c, f: ZeroQ(c**S(2)*f**S(2) + g**S(2))), CustomConstraint(lambda p: Not(IntegerQ(p)))) rule59 = ReplacementRule(pattern59, lambda p, x, b, g, c, f, a, d, e, n : (d + e*x)**FracPart(p)*(f + g*x)**FracPart(p)*(d*f + e*g*x**S(2))**(-FracPart(p))*Int((a + b*asinh(c*x))**n*(d*f + e*g*x**S(2))**p, x)) rubi.add(rule59) pattern60 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda p: Not(IntegerQ(p)))) rule60 = ReplacementRule(pattern60, lambda p, x, b, c, a, d, e, n : (-d)**IntPart(p)*(d + e*x**S(2))**FracPart(p)*(c*x + S(-1))**(-FracPart(p))*(c*x + S(1))**(-FracPart(p))*Int((a + b*acosh(c*x))**n*(c*x + S(-1))**p*(c*x + S(1))**p, x)) rubi.add(rule60) pattern61 = Pattern(Integral(x_*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda n: PositiveIntegerQ(n))) rule61 = ReplacementRule(pattern61, lambda x, b, c, a, d, e, n : Subst(Int((a + b*x)**n*tanh(x), x), x, asinh(c*x))/e) rubi.add(rule61) pattern62 = Pattern(Integral(x_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: PositiveIntegerQ(n))) rule62 = ReplacementRule(pattern62, lambda x, b, c, a, d, e, n : Subst(Int((a + b*x)**n*coth(x), x), x, acosh(c*x))/e) rubi.add(rule62) pattern63 = Pattern(Integral(x_*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda p: NonzeroQ(p + S(1))), CustomConstraint(lambda p: IntegerQ(p))) rule63 = ReplacementRule(pattern63, lambda p, x, b, c, a, d, e, n : -b*n*(-d)**p*Int((a + b*acosh(c*x))**(n + S(-1))*(c*x + S(-1))**(p + S(1)/2)*(c*x + S(1))**(p + S(1)/2), x)/(S(2)*c*(p + S(1))) + (a + b*acosh(c*x))**n*(d + e*x**S(2))**(p + S(1))/(S(2)*e*(p + S(1)))) rubi.add(rule63) pattern64 = Pattern(Integral(x_*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda p: NonzeroQ(p + S(1)))) rule64 = ReplacementRule(pattern64, lambda p, x, b, c, a, d, e, n : -b*d**IntPart(p)*n*(d + e*x**S(2))**FracPart(p)*(c**S(2)*x**S(2) + S(1))**(-FracPart(p))*Int((a + b*asinh(c*x))**(n + S(-1))*(c**S(2)*x**S(2) + S(1))**(p + S(1)/2), x)/(S(2)*c*(p + S(1))) + (a + b*asinh(c*x))**n*(d + e*x**S(2))**(p + S(1))/(S(2)*e*(p + S(1)))) rubi.add(rule64) pattern65 = Pattern(Integral(x_*(d1_ + x_*WC('e1', S(1)))**WC('p', S(1))*(d2_ + x_*WC('e2', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda p: NonzeroQ(p + S(1))), CustomConstraint(lambda p: IntegerQ(p + S(1)/2))) rule65 = ReplacementRule(pattern65, lambda p, e2, e1, d1, x, b, c, a, d2, n : -b*n*(-d1*d2)**IntPart(p)*(d1 + e1*x)**FracPart(p)*(d2 + e2*x)**FracPart(p)*(c*x + S(-1))**(-FracPart(p))*(c*x + S(1))**(-FracPart(p))*Int((a + b*acosh(c*x))**(n + S(-1))*(c**S(2)*x**S(2) + S(-1))**(p + S(1)/2), x)/(S(2)*c*(p + S(1))) + (a + b*acosh(c*x))**n*(d1 + e1*x)**(p + S(1))*(d2 + e2*x)**(p + S(1))/(S(2)*e1*e2*(p + S(1)))) rubi.add(rule65) pattern66 = Pattern(Integral(x_*(d1_ + x_*WC('e1', S(1)))**WC('p', S(1))*(d2_ + x_*WC('e2', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda p: NonzeroQ(p + S(1)))) rule66 = ReplacementRule(pattern66, lambda p, e2, e1, d1, x, b, c, a, d2, n : -b*n*(-d1*d2)**IntPart(p)*(d1 + e1*x)**FracPart(p)*(d2 + e2*x)**FracPart(p)*(c*x + S(-1))**(-FracPart(p))*(c*x + S(1))**(-FracPart(p))*Int((a + b*acosh(c*x))**(n + S(-1))*(c*x + S(-1))**(p + S(1)/2)*(c*x + S(1))**(p + S(1)/2), x)/(S(2)*c*(p + S(1))) + (a + b*acosh(c*x))**n*(d1 + e1*x)**(p + S(1))*(d2 + e2*x)**(p + S(1))/(S(2)*e1*e2*(p + S(1)))) rubi.add(rule66) pattern67 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1))/(x_*(d_ + x_**S(2)*WC('e', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda n: PositiveIntegerQ(n))) rule67 = ReplacementRule(pattern67, lambda x, b, c, a, d, e, n : Subst(Int((a + b*x)**n/(Cosh(x)*sinh(x)), x), x, asinh(c*x))/d) rubi.add(rule67) pattern68 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1))/(x_*(d_ + x_**S(2)*WC('e', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: PositiveIntegerQ(n))) rule68 = ReplacementRule(pattern68, lambda x, b, c, a, d, e, n : -Subst(Int((a + b*x)**n/(Cosh(x)*sinh(x)), x), x, acosh(c*x))/d) rubi.add(rule68) pattern69 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda p, m: ZeroQ(m + S(2)*p + S(3))), CustomConstraint(lambda m: NonzeroQ(m + S(1))), CustomConstraint(lambda p: IntegerQ(p))) rule69 = ReplacementRule(pattern69, lambda p, x, b, m, c, f, a, d, e, n : b*c*n*(-d)**p*Int((f*x)**(m + S(1))*(a + b*acosh(c*x))**(n + S(-1))*(c*x + S(-1))**(p + S(1)/2)*(c*x + S(1))**(p + S(1)/2), x)/(f*(m + S(1))) + (f*x)**(m + S(1))*(a + b*acosh(c*x))**n*(d + e*x**S(2))**(p + S(1))/(d*f*(m + S(1)))) rubi.add(rule69) pattern70 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda p, m: ZeroQ(m + S(2)*p + S(3))), CustomConstraint(lambda m: NonzeroQ(m + S(1)))) rule70 = ReplacementRule(pattern70, lambda p, x, b, m, c, f, a, d, e, n : -b*c*d**IntPart(p)*n*(d + e*x**S(2))**FracPart(p)*(c**S(2)*x**S(2) + S(1))**(-FracPart(p))*Int((f*x)**(m + S(1))*(a + b*asinh(c*x))**(n + S(-1))*(c**S(2)*x**S(2) + S(1))**(p + S(1)/2), x)/(f*(m + S(1))) + (f*x)**(m + S(1))*(a + b*asinh(c*x))**n*(d + e*x**S(2))**(p + S(1))/(d*f*(m + S(1)))) rubi.add(rule70) pattern71 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d1_ + x_*WC('e1', S(1)))**WC('p', S(1))*(d2_ + x_*WC('e2', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda p, m: ZeroQ(m + S(2)*p + S(3))), CustomConstraint(lambda m: NonzeroQ(m + S(1))), CustomConstraint(lambda p: IntegerQ(p + S(1)/2))) rule71 = ReplacementRule(pattern71, lambda p, e2, e1, d1, x, b, m, c, f, a, d2, n : b*c*n*(-d1*d2)**IntPart(p)*(d1 + e1*x)**FracPart(p)*(d2 + e2*x)**FracPart(p)*(c*x + S(-1))**(-FracPart(p))*(c*x + S(1))**(-FracPart(p))*Int((f*x)**(m + S(1))*(a + b*acosh(c*x))**(n + S(-1))*(c**S(2)*x**S(2) + S(-1))**(p + S(1)/2), x)/(f*(m + S(1))) + (f*x)**(m + S(1))*(a + b*acosh(c*x))**n*(d1 + e1*x)**(p + S(1))*(d2 + e2*x)**(p + S(1))/(d1*d2*f*(m + S(1)))) rubi.add(rule71) pattern72 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d1_ + x_*WC('e1', S(1)))**WC('p', S(1))*(d2_ + x_*WC('e2', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda p, m: ZeroQ(m + S(2)*p + S(3))), CustomConstraint(lambda m: NonzeroQ(m + S(1)))) rule72 = ReplacementRule(pattern72, lambda p, e2, e1, d1, x, b, m, c, f, a, d2, n : b*c*n*(-d1*d2)**IntPart(p)*(d1 + e1*x)**FracPart(p)*(d2 + e2*x)**FracPart(p)*(c*x + S(-1))**(-FracPart(p))*(c*x + S(1))**(-FracPart(p))*Int((f*x)**(m + S(1))*(a + b*acosh(c*x))**(n + S(-1))*(c*x + S(-1))**(p + S(1)/2)*(c*x + S(1))**(p + S(1)/2), x)/(f*(m + S(1))) + (f*x)**(m + S(1))*(a + b*acosh(c*x))**n*(d1 + e1*x)**(p + S(1))*(d2 + e2*x)**(p + S(1))/(d1*d2*f*(m + S(1)))) rubi.add(rule72) pattern73 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))/x_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda p: PositiveIntegerQ(p))) rule73 = ReplacementRule(pattern73, lambda p, x, b, c, a, d, e : -b*c*d**p*Int((c**S(2)*x**S(2) + S(1))**(p + S(-1)/2), x)/(S(2)*p) + d*Int((a + b*asinh(c*x))*(d + e*x**S(2))**(p + S(-1))/x, x) + (a + b*asinh(c*x))*(d + e*x**S(2))**p/(S(2)*p)) rubi.add(rule73) pattern74 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))/x_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda p: PositiveIntegerQ(p))) rule74 = ReplacementRule(pattern74, lambda p, x, b, c, a, d, e : -b*c*(-d)**p*Int((c*x + S(-1))**(p + S(-1)/2)*(c*x + S(1))**(p + S(-1)/2), x)/(S(2)*p) + d*Int((a + b*acosh(c*x))*(d + e*x**S(2))**(p + S(-1))/x, x) + (a + b*acosh(c*x))*(d + e*x**S(2))**p/(S(2)*p)) rubi.add(rule74) pattern75 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda p: PositiveIntegerQ(p)), CustomConstraint(lambda m: NegativeIntegerQ(m/S(2) + S(1)/2))) rule75 = ReplacementRule(pattern75, lambda p, x, b, m, c, f, a, d, e : -b*c*d**p*Int((f*x)**(m + S(1))*(c**S(2)*x**S(2) + S(1))**(p + S(-1)/2), x)/(f*(m + S(1))) - S(2)*e*p*Int((f*x)**(m + S(2))*(a + b*asinh(c*x))*(d + e*x**S(2))**(p + S(-1)), x)/(f**S(2)*(m + S(1))) + (f*x)**(m + S(1))*(a + b*asinh(c*x))*(d + e*x**S(2))**p/(f*(m + S(1)))) rubi.add(rule75) pattern76 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda p: PositiveIntegerQ(p)), CustomConstraint(lambda m: NegativeIntegerQ(m/S(2) + S(1)/2))) rule76 = ReplacementRule(pattern76, lambda p, x, b, m, c, f, a, d, e : -b*c*(-d)**p*Int((f*x)**(m + S(1))*(c*x + S(-1))**(p + S(-1)/2)*(c*x + S(1))**(p + S(-1)/2), x)/(f*(m + S(1))) - S(2)*e*p*Int((f*x)**(m + S(2))*(a + b*acosh(c*x))*(d + e*x**S(2))**(p + S(-1)), x)/(f**S(2)*(m + S(1))) + (f*x)**(m + S(1))*(a + b*acosh(c*x))*(d + e*x**S(2))**p/(f*(m + S(1)))) rubi.add(rule76) pattern77 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda p: PositiveIntegerQ(p)), ) def With77(p, x, b, m, c, f, a, d, e): u = IntHide((f*x)**m*(d + e*x**S(2))**p, x) return -b*c*Int(SimplifyIntegrand(u/sqrt(c**S(2)*x**S(2) + S(1)), x), x) + Dist(a + b*asinh(c*x), u, x) rule77 = ReplacementRule(pattern77, lambda p, x, b, m, c, f, a, d, e : With77(p, x, b, m, c, f, a, d, e)) rubi.add(rule77) pattern78 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda p: PositiveIntegerQ(p)), ) def With78(p, x, b, m, c, f, a, d, e): u = IntHide((f*x)**m*(d + e*x**S(2))**p, x) return -b*c*Int(SimplifyIntegrand(u/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), x), x) + Dist(a + b*acosh(c*x), u, x) rule78 = ReplacementRule(pattern78, lambda p, x, b, m, c, f, a, d, e : With78(p, x, b, m, c, f, a, d, e)) rubi.add(rule78) pattern79 = Pattern(Integral(x_**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda p: IntegerQ(p + S(-1)/2)), CustomConstraint(lambda p, m: PositiveIntegerQ(m/S(2) + S(1)/2) | NegativeIntegerQ(m/S(2) + p + S(3)/2)), CustomConstraint(lambda p: Unequal(p, S(-1)/2)), CustomConstraint(lambda d: PositiveQ(d)), ) def With79(p, x, b, m, c, a, d, e): u = IntHide(x**m*(c**S(2)*x**S(2) + S(1))**p, x) return -b*c*d**p*Int(SimplifyIntegrand(u/sqrt(c**S(2)*x**S(2) + S(1)), x), x) + Dist(d**p*(a + b*asinh(c*x)), u, x) rule79 = ReplacementRule(pattern79, lambda p, x, b, m, c, a, d, e : With79(p, x, b, m, c, a, d, e)) rubi.add(rule79) pattern80 = Pattern(Integral(x_**m_*(d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda p: IntegerQ(p + S(-1)/2)), CustomConstraint(lambda p, m: PositiveIntegerQ(m/S(2) + S(1)/2) | NegativeIntegerQ(m/S(2) + p + S(3)/2)), CustomConstraint(lambda p: Unequal(p, S(-1)/2)), CustomConstraint(lambda d1: PositiveQ(d1)), CustomConstraint(lambda d2: NegativeQ(d2)), ) def With80(p, e2, e1, d1, x, b, m, c, a, d2): u = IntHide(x**m*(c*x + S(-1))**p*(c*x + S(1))**p, x) return -b*c*(-d1*d2)**p*Int(SimplifyIntegrand(u/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), x), x) + Dist((-d1*d2)**p*(a + b*acosh(c*x)), u, x) rule80 = ReplacementRule(pattern80, lambda p, e2, e1, d1, x, b, m, c, a, d2 : With80(p, e2, e1, d1, x, b, m, c, a, d2)) rubi.add(rule80) pattern81 = Pattern(Integral(x_**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda p: PositiveIntegerQ(p + S(1)/2)), CustomConstraint(lambda p, m: PositiveIntegerQ(m/S(2) + S(1)/2) | NegativeIntegerQ(m/S(2) + p + S(3)/2)), ) def With81(p, x, b, m, c, a, d, e): u = IntHide(x**m*(c**S(2)*x**S(2) + S(1))**p, x) return -b*c*d**(p + S(-1)/2)*sqrt(d + e*x**S(2))*Int(SimplifyIntegrand(u/sqrt(c**S(2)*x**S(2) + S(1)), x), x)/sqrt(c**S(2)*x**S(2) + S(1)) + (a + b*asinh(c*x))*Int(x**m*(d + e*x**S(2))**p, x) rule81 = ReplacementRule(pattern81, lambda p, x, b, m, c, a, d, e : With81(p, x, b, m, c, a, d, e)) rubi.add(rule81) pattern82 = Pattern(Integral(x_**m_*(d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda p: PositiveIntegerQ(p + S(1)/2)), CustomConstraint(lambda p, m: PositiveIntegerQ(m/S(2) + S(1)/2) | NegativeIntegerQ(m/S(2) + p + S(3)/2)), ) def With82(p, e2, e1, d1, x, b, m, c, a, d2): u = IntHide(x**m*(c*x + S(-1))**p*(c*x + S(1))**p, x) return -b*c*(-d1*d2)**(p + S(-1)/2)*sqrt(d1 + e1*x)*sqrt(d2 + e2*x)*Int(SimplifyIntegrand(u/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), x), x)/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))) + (a + b*acosh(c*x))*Int(x**m*(d1 + e1*x)**p*(d2 + e2*x)**p, x) rule82 = ReplacementRule(pattern82, lambda p, e2, e1, d1, x, b, m, c, a, d2 : With82(p, e2, e1, d1, x, b, m, c, a, d2)) rubi.add(rule82) pattern83 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n, p, m: RationalQ(m, n, p)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda p: Greater(p, S(0))), CustomConstraint(lambda m: Less(m, S(-1))), CustomConstraint(lambda p: IntegerQ(p))) rule83 = ReplacementRule(pattern83, lambda p, x, b, m, c, f, a, d, e, n : -b*c*n*(-d)**p*Int((f*x)**(m + S(1))*(a + b*acosh(c*x))**(n + S(-1))*(c*x + S(-1))**(p + S(-1)/2)*(c*x + S(1))**(p + S(-1)/2), x)/(f*(m + S(1))) - S(2)*e*p*Int((f*x)**(m + S(2))*(a + b*acosh(c*x))**n*(d + e*x**S(2))**(p + S(-1)), x)/(f**S(2)*(m + S(1))) + (f*x)**(m + S(1))*(a + b*acosh(c*x))**n*(d + e*x**S(2))**p/(f*(m + S(1)))) rubi.add(rule83) pattern84 = Pattern(Integral((x_*WC('f', S(1)))**m_*sqrt(d_ + x_**S(2)*WC('e', S(1)))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda n, m: RationalQ(m, n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda m: Less(m, S(-1)))) rule84 = ReplacementRule(pattern84, lambda x, b, m, c, f, a, d, e, n : -b*c*n*sqrt(d + e*x**S(2))*Int((f*x)**(m + S(1))*(a + b*asinh(c*x))**(n + S(-1)), x)/(f*(m + S(1))*sqrt(c**S(2)*x**S(2) + S(1))) - c**S(2)*sqrt(d + e*x**S(2))*Int((f*x)**(m + S(2))*(a + b*asinh(c*x))**n/sqrt(c**S(2)*x**S(2) + S(1)), x)/(f**S(2)*(m + S(1))*sqrt(c**S(2)*x**S(2) + S(1))) + (f*x)**(m + S(1))*(a + b*asinh(c*x))**n*sqrt(d + e*x**S(2))/(f*(m + S(1)))) rubi.add(rule84) pattern85 = Pattern(Integral((x_*WC('f', S(1)))**m_*sqrt(d1_ + x_*WC('e1', S(1)))*sqrt(d2_ + x_*WC('e2', S(1)))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda n, m: RationalQ(m, n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda m: Less(m, S(-1)))) rule85 = ReplacementRule(pattern85, lambda e2, e1, d1, x, b, m, c, f, a, d2, n : -b*c*n*sqrt(d1 + e1*x)*sqrt(d2 + e2*x)*Int((f*x)**(m + S(1))*(a + b*acosh(c*x))**(n + S(-1)), x)/(f*(m + S(1))*sqrt(c*x + S(-1))*sqrt(c*x + S(1))) - c**S(2)*sqrt(d1 + e1*x)*sqrt(d2 + e2*x)*Int((f*x)**(m + S(2))*(a + b*acosh(c*x))**n/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), x)/(f**S(2)*(m + S(1))*sqrt(c*x + S(-1))*sqrt(c*x + S(1))) + (f*x)**(m + S(1))*(a + b*acosh(c*x))**n*sqrt(d1 + e1*x)*sqrt(d2 + e2*x)/(f*(m + S(1)))) rubi.add(rule85) pattern86 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda n, p, m: RationalQ(m, n, p)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda p: Greater(p, S(0))), CustomConstraint(lambda m: Less(m, S(-1)))) rule86 = ReplacementRule(pattern86, lambda p, x, b, m, c, f, a, d, e, n : -b*c*d**IntPart(p)*n*(d + e*x**S(2))**FracPart(p)*(c**S(2)*x**S(2) + S(1))**(-FracPart(p))*Int((f*x)**(m + S(1))*(a + b*asinh(c*x))**(n + S(-1))*(c**S(2)*x**S(2) + S(1))**(p + S(-1)/2), x)/(f*(m + S(1))) - S(2)*e*p*Int((f*x)**(m + S(2))*(a + b*asinh(c*x))**n*(d + e*x**S(2))**(p + S(-1)), x)/(f**S(2)*(m + S(1))) + (f*x)**(m + S(1))*(a + b*asinh(c*x))**n*(d + e*x**S(2))**p/(f*(m + S(1)))) rubi.add(rule86) pattern87 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda n, p, m: RationalQ(m, n, p)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda p: Greater(p, S(0))), CustomConstraint(lambda m: Less(m, S(-1))), CustomConstraint(lambda p: IntegerQ(p + S(-1)/2))) rule87 = ReplacementRule(pattern87, lambda p, e2, e1, d1, x, b, m, c, f, a, d2, n : -b*c*n*(-d1*d2)**(p + S(-1)/2)*sqrt(d1 + e1*x)*sqrt(d2 + e2*x)*Int((f*x)**(m + S(1))*(a + b*acosh(c*x))**(n + S(-1))*(c**S(2)*x**S(2) + S(-1))**(p + S(-1)/2), x)/(f*(m + S(1))*sqrt(c*x + S(-1))*sqrt(c*x + S(1))) - S(2)*e1*e2*p*Int((f*x)**(m + S(2))*(a + b*acosh(c*x))**n*(d1 + e1*x)**(p + S(-1))*(d2 + e2*x)**(p + S(-1)), x)/(f**S(2)*(m + S(1))) + (f*x)**(m + S(1))*(a + b*acosh(c*x))**n*(d1 + e1*x)**p*(d2 + e2*x)**p/(f*(m + S(1)))) rubi.add(rule87) pattern88 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda p, n: RationalQ(n, p)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda p: Greater(p, S(0))), CustomConstraint(lambda m: Not(RationalQ(m) & Less(m, S(-1)))), CustomConstraint(lambda p: IntegerQ(p)), CustomConstraint(lambda n, m: RationalQ(m) | ZeroQ(n + S(-1)))) rule88 = ReplacementRule(pattern88, lambda p, x, b, m, c, f, a, d, e, n : -b*c*n*(-d)**p*Int((f*x)**(m + S(1))*(a + b*acosh(c*x))**(n + S(-1))*(c*x + S(-1))**(p + S(-1)/2)*(c*x + S(1))**(p + S(-1)/2), x)/(f*(m + S(2)*p + S(1))) + S(2)*d*p*Int((f*x)**m*(a + b*acosh(c*x))**n*(d + e*x**S(2))**(p + S(-1)), x)/(m + S(2)*p + S(1)) + (f*x)**(m + S(1))*(a + b*acosh(c*x))**n*(d + e*x**S(2))**p/(f*(m + S(2)*p + S(1)))) rubi.add(rule88) pattern89 = Pattern(Integral((x_*WC('f', S(1)))**m_*sqrt(d_ + x_**S(2)*WC('e', S(1)))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda m: Not(RationalQ(m) & Less(m, S(-1)))), CustomConstraint(lambda n, m: RationalQ(m) | ZeroQ(n + S(-1)))) rule89 = ReplacementRule(pattern89, lambda x, b, m, c, f, a, d, e, n : -b*c*n*sqrt(d + e*x**S(2))*Int((f*x)**(m + S(1))*(a + b*asinh(c*x))**(n + S(-1)), x)/(f*(m + S(2))*sqrt(c**S(2)*x**S(2) + S(1))) + sqrt(d + e*x**S(2))*Int((f*x)**m*(a + b*asinh(c*x))**n/sqrt(c**S(2)*x**S(2) + S(1)), x)/((m + S(2))*sqrt(c**S(2)*x**S(2) + S(1))) + (f*x)**(m + S(1))*(a + b*asinh(c*x))**n*sqrt(d + e*x**S(2))/(f*(m + S(2)))) rubi.add(rule89) pattern90 = Pattern(Integral((x_*WC('f', S(1)))**m_*sqrt(d1_ + x_*WC('e1', S(1)))*sqrt(d2_ + x_*WC('e2', S(1)))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda m: Not(RationalQ(m) & Less(m, S(-1)))), CustomConstraint(lambda n, m: RationalQ(m) | ZeroQ(n + S(-1)))) rule90 = ReplacementRule(pattern90, lambda e2, e1, d1, x, b, m, c, f, a, d2, n : -b*c*n*sqrt(d1 + e1*x)*sqrt(d2 + e2*x)*Int((f*x)**(m + S(1))*(a + b*acosh(c*x))**(n + S(-1)), x)/(f*(m + S(2))*sqrt(c*x + S(-1))*sqrt(c*x + S(1))) - sqrt(d1 + e1*x)*sqrt(d2 + e2*x)*Int((f*x)**m*(a + b*acosh(c*x))**n/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), x)/((m + S(2))*sqrt(c*x + S(-1))*sqrt(c*x + S(1))) + (f*x)**(m + S(1))*(a + b*acosh(c*x))**n*sqrt(d1 + e1*x)*sqrt(d2 + e2*x)/(f*(m + S(2)))) rubi.add(rule90) pattern91 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda p, n: RationalQ(n, p)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda p: Greater(p, S(0))), CustomConstraint(lambda m: Not(RationalQ(m) & Less(m, S(-1)))), CustomConstraint(lambda n, m: RationalQ(m) | ZeroQ(n + S(-1)))) rule91 = ReplacementRule(pattern91, lambda p, x, b, m, c, f, a, d, e, n : -b*c*d**IntPart(p)*n*(d + e*x**S(2))**FracPart(p)*(c**S(2)*x**S(2) + S(1))**(-FracPart(p))*Int((f*x)**(m + S(1))*(a + b*asinh(c*x))**(n + S(-1))*(c**S(2)*x**S(2) + S(1))**(p + S(-1)/2), x)/(f*(m + S(2)*p + S(1))) + S(2)*d*p*Int((f*x)**m*(a + b*asinh(c*x))**n*(d + e*x**S(2))**(p + S(-1)), x)/(m + S(2)*p + S(1)) + (f*x)**(m + S(1))*(a + b*asinh(c*x))**n*(d + e*x**S(2))**p/(f*(m + S(2)*p + S(1)))) rubi.add(rule91) pattern92 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda p, n: RationalQ(n, p)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda p: Greater(p, S(0))), CustomConstraint(lambda m: Not(RationalQ(m) & Less(m, S(-1)))), CustomConstraint(lambda p: IntegerQ(p + S(-1)/2)), CustomConstraint(lambda n, m: RationalQ(m) | ZeroQ(n + S(-1)))) rule92 = ReplacementRule(pattern92, lambda p, e2, e1, d1, x, b, m, c, f, a, d2, n : -b*c*n*(-d1*d2)**(p + S(-1)/2)*sqrt(d1 + e1*x)*sqrt(d2 + e2*x)*Int((f*x)**(m + S(1))*(a + b*acosh(c*x))**(n + S(-1))*(c**S(2)*x**S(2) + S(-1))**(p + S(-1)/2), x)/(f*sqrt(c*x + S(-1))*sqrt(c*x + S(1))*(m + S(2)*p + S(1))) + S(2)*d1*d2*p*Int((f*x)**m*(a + b*acosh(c*x))**n*(d1 + e1*x)**(p + S(-1))*(d2 + e2*x)**(p + S(-1)), x)/(m + S(2)*p + S(1)) + (f*x)**(m + S(1))*(a + b*acosh(c*x))**n*(d1 + e1*x)**p*(d2 + e2*x)**p/(f*(m + S(2)*p + S(1)))) rubi.add(rule92) pattern93 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n, m: RationalQ(m, n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda m: Less(m, S(-1))), CustomConstraint(lambda m: IntegerQ(m)), CustomConstraint(lambda p: IntegerQ(p))) rule93 = ReplacementRule(pattern93, lambda p, x, b, m, c, f, a, d, e, n : b*c*n*(-d)**p*Int((f*x)**(m + S(1))*(a + b*acosh(c*x))**(n + S(-1))*(c*x + S(-1))**(p + S(1)/2)*(c*x + S(1))**(p + S(1)/2), x)/(f*(m + S(1))) + c**S(2)*(m + S(2)*p + S(3))*Int((f*x)**(m + S(2))*(a + b*acosh(c*x))**n*(d + e*x**S(2))**p, x)/(f**S(2)*(m + S(1))) + (f*x)**(m + S(1))*(a + b*acosh(c*x))**n*(d + e*x**S(2))**(p + S(1))/(d*f*(m + S(1)))) rubi.add(rule93) pattern94 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda n, m: RationalQ(m, n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda m: Less(m, S(-1))), CustomConstraint(lambda m: IntegerQ(m))) rule94 = ReplacementRule(pattern94, lambda p, x, b, m, c, f, a, d, e, n : -b*c*d**IntPart(p)*n*(d + e*x**S(2))**FracPart(p)*(c**S(2)*x**S(2) + S(1))**(-FracPart(p))*Int((f*x)**(m + S(1))*(a + b*asinh(c*x))**(n + S(-1))*(c**S(2)*x**S(2) + S(1))**(p + S(1)/2), x)/(f*(m + S(1))) - c**S(2)*(m + S(2)*p + S(3))*Int((f*x)**(m + S(2))*(a + b*asinh(c*x))**n*(d + e*x**S(2))**p, x)/(f**S(2)*(m + S(1))) + (f*x)**(m + S(1))*(a + b*asinh(c*x))**n*(d + e*x**S(2))**(p + S(1))/(d*f*(m + S(1)))) rubi.add(rule94) pattern95 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda n, m: RationalQ(m, n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda m: Less(m, S(-1))), CustomConstraint(lambda m: IntegerQ(m)), CustomConstraint(lambda p: IntegerQ(p + S(1)/2))) rule95 = ReplacementRule(pattern95, lambda p, e2, e1, d1, x, b, m, c, f, a, d2, n : b*c*n*(-d1*d2)**IntPart(p)*(d1 + e1*x)**FracPart(p)*(d2 + e2*x)**FracPart(p)*(c*x + S(-1))**(-FracPart(p))*(c*x + S(1))**(-FracPart(p))*Int((f*x)**(m + S(1))*(a + b*acosh(c*x))**(n + S(-1))*(c**S(2)*x**S(2) + S(-1))**(p + S(1)/2), x)/(f*(m + S(1))) + c**S(2)*(m + S(2)*p + S(3))*Int((f*x)**(m + S(2))*(a + b*acosh(c*x))**n*(d1 + e1*x)**p*(d2 + e2*x)**p, x)/(f**S(2)*(m + S(1))) + (f*x)**(m + S(1))*(a + b*acosh(c*x))**n*(d1 + e1*x)**(p + S(1))*(d2 + e2*x)**(p + S(1))/(d1*d2*f*(m + S(1)))) rubi.add(rule95) pattern96 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda n, m: RationalQ(m, n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda m: Less(m, S(-1))), CustomConstraint(lambda m: IntegerQ(m))) rule96 = ReplacementRule(pattern96, lambda p, e2, e1, d1, x, b, m, c, f, a, d2, n : b*c*n*(-d1*d2)**IntPart(p)*(d1 + e1*x)**FracPart(p)*(d2 + e2*x)**FracPart(p)*(c*x + S(-1))**(-FracPart(p))*(c*x + S(1))**(-FracPart(p))*Int((f*x)**(m + S(1))*(a + b*acosh(c*x))**(n + S(-1))*(c*x + S(-1))**(p + S(1)/2)*(c*x + S(1))**(p + S(1)/2), x)/(f*(m + S(1))) + c**S(2)*(m + S(2)*p + S(3))*Int((f*x)**(m + S(2))*(a + b*acosh(c*x))**n*(d1 + e1*x)**p*(d2 + e2*x)**p, x)/(f**S(2)*(m + S(1))) + (f*x)**(m + S(1))*(a + b*acosh(c*x))**n*(d1 + e1*x)**(p + S(1))*(d2 + e2*x)**(p + S(1))/(d1*d2*f*(m + S(1)))) rubi.add(rule96) pattern97 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n, m: RationalQ(m, n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda p: Less(p, S(-1))), CustomConstraint(lambda m: Greater(m, S(1))), CustomConstraint(lambda p: IntegerQ(p))) rule97 = ReplacementRule(pattern97, lambda p, x, b, m, c, f, a, d, e, n : -b*f*n*(-d)**p*Int((f*x)**(m + S(-1))*(a + b*acosh(c*x))**(n + S(-1))*(c*x + S(-1))**(p + S(1)/2)*(c*x + S(1))**(p + S(1)/2), x)/(S(2)*c*(p + S(1))) - f**S(2)*(m + S(-1))*Int((f*x)**(m + S(-2))*(a + b*acosh(c*x))**n*(d + e*x**S(2))**(p + S(1)), x)/(S(2)*e*(p + S(1))) + f*(f*x)**(m + S(-1))*(a + b*acosh(c*x))**n*(d + e*x**S(2))**(p + S(1))/(S(2)*e*(p + S(1)))) rubi.add(rule97) pattern98 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda n, p, m: RationalQ(m, n, p)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda p: Less(p, S(-1))), CustomConstraint(lambda m: Greater(m, S(1)))) rule98 = ReplacementRule(pattern98, lambda p, x, b, m, c, f, a, d, e, n : -b*d**IntPart(p)*f*n*(d + e*x**S(2))**FracPart(p)*(c**S(2)*x**S(2) + S(1))**(-FracPart(p))*Int((f*x)**(m + S(-1))*(a + b*asinh(c*x))**(n + S(-1))*(c**S(2)*x**S(2) + S(1))**(p + S(1)/2), x)/(S(2)*c*(p + S(1))) - f**S(2)*(m + S(-1))*Int((f*x)**(m + S(-2))*(a + b*asinh(c*x))**n*(d + e*x**S(2))**(p + S(1)), x)/(S(2)*e*(p + S(1))) + f*(f*x)**(m + S(-1))*(a + b*asinh(c*x))**n*(d + e*x**S(2))**(p + S(1))/(S(2)*e*(p + S(1)))) rubi.add(rule98) pattern99 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda n, p, m: RationalQ(m, n, p)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda p: Less(p, S(-1))), CustomConstraint(lambda m: Greater(m, S(1))), CustomConstraint(lambda p: IntegerQ(p + S(1)/2))) rule99 = ReplacementRule(pattern99, lambda p, e2, e1, d1, x, b, m, c, f, a, d2, n : -b*f*n*(-d1*d2)**IntPart(p)*(d1 + e1*x)**FracPart(p)*(d2 + e2*x)**FracPart(p)*(c*x + S(-1))**(-FracPart(p))*(c*x + S(1))**(-FracPart(p))*Int((f*x)**(m + S(-1))*(a + b*acosh(c*x))**(n + S(-1))*(c**S(2)*x**S(2) + S(-1))**(p + S(1)/2), x)/(S(2)*c*(p + S(1))) - f**S(2)*(m + S(-1))*Int((f*x)**(m + S(-2))*(a + b*acosh(c*x))**n*(d1 + e1*x)**(p + S(1))*(d2 + e2*x)**(p + S(1)), x)/(S(2)*e1*e2*(p + S(1))) + f*(f*x)**(m + S(-1))*(a + b*acosh(c*x))**n*(d1 + e1*x)**(p + S(1))*(d2 + e2*x)**(p + S(1))/(S(2)*e1*e2*(p + S(1)))) rubi.add(rule99) pattern100 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda n, p, m: RationalQ(m, n, p)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda p: Less(p, S(-1))), CustomConstraint(lambda p: Not(IntegerQ(p))), CustomConstraint(lambda m: Greater(m, S(1)))) rule100 = ReplacementRule(pattern100, lambda p, e2, e1, d1, x, b, m, c, f, a, d2, n : -b*f*n*(-d1*d2)**IntPart(p)*(d1 + e1*x)**FracPart(p)*(d2 + e2*x)**FracPart(p)*(c*x + S(-1))**(-FracPart(p))*(c*x + S(1))**(-FracPart(p))*Int((f*x)**(m + S(-1))*(a + b*acosh(c*x))**(n + S(-1))*(c*x + S(-1))**(p + S(1)/2)*(c*x + S(1))**(p + S(1)/2), x)/(S(2)*c*(p + S(1))) - f**S(2)*(m + S(-1))*Int((f*x)**(m + S(-2))*(a + b*acosh(c*x))**n*(d1 + e1*x)**(p + S(1))*(d2 + e2*x)**(p + S(1)), x)/(S(2)*e1*e2*(p + S(1))) + f*(f*x)**(m + S(-1))*(a + b*acosh(c*x))**n*(d1 + e1*x)**(p + S(1))*(d2 + e2*x)**(p + S(1))/(S(2)*e1*e2*(p + S(1)))) rubi.add(rule100) pattern101 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda p, n: RationalQ(n, p)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda p: Less(p, S(-1))), CustomConstraint(lambda m: Not(RationalQ(m) & Greater(m, S(1)))), CustomConstraint(lambda p: IntegerQ(p))) rule101 = ReplacementRule(pattern101, lambda p, x, b, m, c, f, a, d, e, n : -b*c*n*(-d)**p*Int((f*x)**(m + S(1))*(a + b*acosh(c*x))**(n + S(-1))*(c*x + S(-1))**(p + S(1)/2)*(c*x + S(1))**(p + S(1)/2), x)/(S(2)*f*(p + S(1))) + (m + S(2)*p + S(3))*Int((f*x)**m*(a + b*acosh(c*x))**n*(d + e*x**S(2))**(p + S(1)), x)/(S(2)*d*(p + S(1))) - (f*x)**(m + S(1))*(a + b*acosh(c*x))**n*(d + e*x**S(2))**(p + S(1))/(S(2)*d*f*(p + S(1)))) rubi.add(rule101) pattern102 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda p, n: RationalQ(n, p)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda p: Less(p, S(-1))), CustomConstraint(lambda m: Not(RationalQ(m) & Greater(m, S(1)))), CustomConstraint(lambda n, p, m: IntegerQ(m) | IntegerQ(p) | Equal(n, S(1)))) rule102 = ReplacementRule(pattern102, lambda p, x, b, m, c, f, a, d, e, n : b*c*d**IntPart(p)*n*(d + e*x**S(2))**FracPart(p)*(c**S(2)*x**S(2) + S(1))**(-FracPart(p))*Int((f*x)**(m + S(1))*(a + b*asinh(c*x))**(n + S(-1))*(c**S(2)*x**S(2) + S(1))**(p + S(1)/2), x)/(S(2)*f*(p + S(1))) + (m + S(2)*p + S(3))*Int((f*x)**m*(a + b*asinh(c*x))**n*(d + e*x**S(2))**(p + S(1)), x)/(S(2)*d*(p + S(1))) - (f*x)**(m + S(1))*(a + b*asinh(c*x))**n*(d + e*x**S(2))**(p + S(1))/(S(2)*d*f*(p + S(1)))) rubi.add(rule102) pattern103 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda p, n: RationalQ(n, p)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda p: Less(p, S(-1))), CustomConstraint(lambda m: Not(RationalQ(m) & Greater(m, S(1)))), CustomConstraint(lambda n, m: IntegerQ(m) | Equal(n, S(1))), CustomConstraint(lambda p: IntegerQ(p + S(1)/2))) rule103 = ReplacementRule(pattern103, lambda p, e2, e1, d1, x, b, m, c, f, a, d2, n : -b*c*n*(-d1*d2)**IntPart(p)*(d1 + e1*x)**FracPart(p)*(d2 + e2*x)**FracPart(p)*(c*x + S(-1))**(-FracPart(p))*(c*x + S(1))**(-FracPart(p))*Int((f*x)**(m + S(1))*(a + b*acosh(c*x))**(n + S(-1))*(c**S(2)*x**S(2) + S(-1))**(p + S(1)/2), x)/(S(2)*f*(p + S(1))) + (m + S(2)*p + S(3))*Int((f*x)**m*(a + b*acosh(c*x))**n*(d1 + e1*x)**(p + S(1))*(d2 + e2*x)**(p + S(1)), x)/(S(2)*d1*d2*(p + S(1))) - (f*x)**(m + S(1))*(a + b*acosh(c*x))**n*(d1 + e1*x)**(p + S(1))*(d2 + e2*x)**(p + S(1))/(S(2)*d1*d2*f*(p + S(1)))) rubi.add(rule103) pattern104 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda p, n: RationalQ(n, p)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda p: Less(p, S(-1))), CustomConstraint(lambda m: Not(RationalQ(m) & Greater(m, S(1)))), CustomConstraint(lambda n, p, m: IntegerQ(m) | IntegerQ(p) | Equal(n, S(1)))) rule104 = ReplacementRule(pattern104, lambda p, e2, e1, d1, x, b, m, c, f, a, d2, n : -b*c*n*(-d1*d2)**IntPart(p)*(d1 + e1*x)**FracPart(p)*(d2 + e2*x)**FracPart(p)*(c*x + S(-1))**(-FracPart(p))*(c*x + S(1))**(-FracPart(p))*Int((f*x)**(m + S(1))*(a + b*acosh(c*x))**(n + S(-1))*(c*x + S(-1))**(p + S(1)/2)*(c*x + S(1))**(p + S(1)/2), x)/(S(2)*f*(p + S(1))) + (m + S(2)*p + S(3))*Int((f*x)**m*(a + b*acosh(c*x))**n*(d1 + e1*x)**(p + S(1))*(d2 + e2*x)**(p + S(1)), x)/(S(2)*d1*d2*(p + S(1))) - (f*x)**(m + S(1))*(a + b*acosh(c*x))**n*(d1 + e1*x)**(p + S(1))*(d2 + e2*x)**(p + S(1))/(S(2)*d1*d2*f*(p + S(1)))) rubi.add(rule104) pattern105 = Pattern(Integral((x_*WC('f', S(1)))**m_*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda n, m: RationalQ(m, n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda m: Greater(m, S(1))), CustomConstraint(lambda m: IntegerQ(m))) rule105 = ReplacementRule(pattern105, lambda x, b, m, c, f, a, d, e, n : -b*f*n*sqrt(c**S(2)*x**S(2) + S(1))*Int((f*x)**(m + S(-1))*(a + b*asinh(c*x))**(n + S(-1)), x)/(c*m*sqrt(d + e*x**S(2))) + f*(f*x)**(m + S(-1))*(a + b*asinh(c*x))**n*sqrt(d + e*x**S(2))/(e*m) - f**S(2)*(m + S(-1))*Int((f*x)**(m + S(-2))*(a + b*asinh(c*x))**n/sqrt(d + e*x**S(2)), x)/(c**S(2)*m)) rubi.add(rule105) pattern106 = Pattern(Integral((x_*WC('f', S(1)))**m_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1))/(sqrt(d1_ + x_*WC('e1', S(1)))*sqrt(d2_ + x_*WC('e2', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda n, m: RationalQ(m, n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda m: Greater(m, S(1))), CustomConstraint(lambda m: IntegerQ(m))) rule106 = ReplacementRule(pattern106, lambda e2, e1, d1, x, b, m, c, f, a, d2, n : b*f*n*sqrt(d1 + e1*x)*sqrt(d2 + e2*x)*Int((f*x)**(m + S(-1))*(a + b*acosh(c*x))**(n + S(-1)), x)/(c*d1*d2*m*sqrt(c*x + S(-1))*sqrt(c*x + S(1))) + f*(f*x)**(m + S(-1))*(a + b*acosh(c*x))**n*sqrt(d1 + e1*x)*sqrt(d2 + e2*x)/(e1*e2*m) + f**S(2)*(m + S(-1))*Int((f*x)**(m + S(-2))*(a + b*acosh(c*x))**n/(sqrt(d1 + e1*x)*sqrt(d2 + e2*x)), x)/(c**S(2)*m)) rubi.add(rule106) pattern107 = Pattern(Integral(x_**m_*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda d: PositiveQ(d)), CustomConstraint(lambda n: PositiveIntegerQ(n)), CustomConstraint(lambda m: IntegerQ(m))) rule107 = ReplacementRule(pattern107, lambda x, b, m, c, a, d, e, n : c**(-m + S(-1))*Subst(Int((a + b*x)**n*sinh(x)**m, x), x, asinh(c*x))/sqrt(d)) rubi.add(rule107) pattern108 = Pattern(Integral(x_**m_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1))/(sqrt(d1_ + x_*WC('e1', S(1)))*sqrt(d2_ + x_*WC('e2', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda n: PositiveIntegerQ(n)), CustomConstraint(lambda d1: PositiveQ(d1)), CustomConstraint(lambda d2: NegativeQ(d2)), CustomConstraint(lambda m: IntegerQ(m))) rule108 = ReplacementRule(pattern108, lambda e2, e1, d1, x, b, m, c, a, d2, n : c**(-m + S(-1))*Subst(Int((a + b*x)**n*Cosh(x)**m, x), x, acosh(c*x))/sqrt(-d1*d2)) rubi.add(rule108) pattern109 = Pattern(Integral((x_*WC('f', S(1)))**m_*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda d: PositiveQ(d)), CustomConstraint(lambda m: Not(IntegerQ(m)))) rule109 = ReplacementRule(pattern109, lambda x, b, m, c, f, a, d, e : -b*c*(f*x)**(m + S(2))*HypergeometricPFQ(List(S(1), m/S(2) + S(1), m/S(2) + S(1)), List(m/S(2) + S(3)/2, m/S(2) + S(2)), -c**S(2)*x**S(2))/(sqrt(d)*f**S(2)*(m + S(1))*(m + S(2))) + (f*x)**(m + S(1))*(a + b*asinh(c*x))*Hypergeometric2F1(S(1)/2, m/S(2) + S(1)/2, m/S(2) + S(3)/2, -c**S(2)*x**S(2))/(sqrt(d)*f*(m + S(1)))) rubi.add(rule109) pattern110 = Pattern(Integral((x_*WC('f', S(1)))**m_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))/(sqrt(d1_ + x_*WC('e1', S(1)))*sqrt(d2_ + x_*WC('e2', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda d1: PositiveQ(d1)), CustomConstraint(lambda d2: NegativeQ(d2)), CustomConstraint(lambda m: Not(IntegerQ(m)))) rule110 = ReplacementRule(pattern110, lambda e2, e1, d1, x, b, m, c, f, a, d2 : b*c*(f*x)**(m + S(2))*HypergeometricPFQ(List(S(1), m/S(2) + S(1), m/S(2) + S(1)), List(m/S(2) + S(3)/2, m/S(2) + S(2)), c**S(2)*x**S(2))/(f**S(2)*sqrt(-d1*d2)*(m + S(1))*(m + S(2))) + (f*x)**(m + S(1))*(a + b*acosh(c*x))*sqrt(-c**S(2)*x**S(2) + S(1))*Hypergeometric2F1(S(1)/2, m/S(2) + S(1)/2, m/S(2) + S(3)/2, c**S(2)*x**S(2))/(f*sqrt(d1 + e1*x)*sqrt(d2 + e2*x)*(m + S(1)))) rubi.add(rule110) pattern111 = Pattern(Integral((x_*WC('f', S(1)))**m_*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda d: Not(PositiveQ(d))), CustomConstraint(lambda n, m: IntegerQ(m) | Equal(n, S(1)))) rule111 = ReplacementRule(pattern111, lambda x, b, m, c, f, a, d, e, n : sqrt(c**S(2)*x**S(2) + S(1))*Int((f*x)**m*(a + b*asinh(c*x))**n/sqrt(c**S(2)*x**S(2) + S(1)), x)/sqrt(d + e*x**S(2))) rubi.add(rule111) pattern112 = Pattern(Integral((x_*WC('f', S(1)))**m_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1))/(sqrt(d1_ + x_*WC('e1', S(1)))*sqrt(d2_ + x_*WC('e2', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda d2, d1: Not(NegativeQ(d2) & PositiveQ(d1))), CustomConstraint(lambda n, m: IntegerQ(m) | Equal(n, S(1)))) rule112 = ReplacementRule(pattern112, lambda e2, e1, d1, x, b, m, c, f, a, d2, n : sqrt(c*x + S(-1))*sqrt(c*x + S(1))*Int((f*x)**m*(a + b*acosh(c*x))**n/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), x)/(sqrt(d1 + e1*x)*sqrt(d2 + e2*x))) rubi.add(rule112) pattern113 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n, m: RationalQ(m, n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda m: Greater(m, S(1))), CustomConstraint(lambda p, m: NonzeroQ(m + S(2)*p + S(1))), CustomConstraint(lambda p: IntegerQ(p)), CustomConstraint(lambda m: IntegerQ(m))) rule113 = ReplacementRule(pattern113, lambda p, x, b, m, c, f, a, d, e, n : -b*f*n*(-d)**p*Int((f*x)**(m + S(-1))*(a + b*acosh(c*x))**(n + S(-1))*(c*x + S(-1))**(p + S(1)/2)*(c*x + S(1))**(p + S(1)/2), x)/(c*(m + S(2)*p + S(1))) + f*(f*x)**(m + S(-1))*(a + b*acosh(c*x))**n*(d + e*x**S(2))**(p + S(1))/(e*(m + S(2)*p + S(1))) + f**S(2)*(m + S(-1))*Int((f*x)**(m + S(-2))*(a + b*acosh(c*x))**n*(d + e*x**S(2))**p, x)/(c**S(2)*(m + S(2)*p + S(1)))) rubi.add(rule113) pattern114 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda n, m: RationalQ(m, n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda m: Greater(m, S(1))), CustomConstraint(lambda p, m: NonzeroQ(m + S(2)*p + S(1))), CustomConstraint(lambda m: IntegerQ(m))) rule114 = ReplacementRule(pattern114, lambda p, x, b, m, c, f, a, d, e, n : -b*d**IntPart(p)*f*n*(d + e*x**S(2))**FracPart(p)*(c**S(2)*x**S(2) + S(1))**(-FracPart(p))*Int((f*x)**(m + S(-1))*(a + b*asinh(c*x))**(n + S(-1))*(c**S(2)*x**S(2) + S(1))**(p + S(1)/2), x)/(c*(m + S(2)*p + S(1))) + f*(f*x)**(m + S(-1))*(a + b*asinh(c*x))**n*(d + e*x**S(2))**(p + S(1))/(e*(m + S(2)*p + S(1))) - f**S(2)*(m + S(-1))*Int((f*x)**(m + S(-2))*(a + b*asinh(c*x))**n*(d + e*x**S(2))**p, x)/(c**S(2)*(m + S(2)*p + S(1)))) rubi.add(rule114) pattern115 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda n, m: RationalQ(m, n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda m: Greater(m, S(1))), CustomConstraint(lambda p, m: NonzeroQ(m + S(2)*p + S(1))), CustomConstraint(lambda m: IntegerQ(m)), CustomConstraint(lambda p: IntegerQ(p + S(1)/2))) rule115 = ReplacementRule(pattern115, lambda p, e2, e1, d1, x, b, m, c, f, a, d2, n : -b*f*n*(-d1*d2)**IntPart(p)*(d1 + e1*x)**FracPart(p)*(d2 + e2*x)**FracPart(p)*(c*x + S(-1))**(-FracPart(p))*(c*x + S(1))**(-FracPart(p))*Int((f*x)**(m + S(-1))*(a + b*acosh(c*x))**(n + S(-1))*(c**S(2)*x**S(2) + S(-1))**(p + S(1)/2), x)/(c*(m + S(2)*p + S(1))) + f*(f*x)**(m + S(-1))*(a + b*acosh(c*x))**n*(d1 + e1*x)**(p + S(1))*(d2 + e2*x)**(p + S(1))/(e1*e2*(m + S(2)*p + S(1))) + f**S(2)*(m + S(-1))*Int((f*x)**(m + S(-2))*(a + b*acosh(c*x))**n*(d1 + e1*x)**p*(d2 + e2*x)**p, x)/(c**S(2)*(m + S(2)*p + S(1)))) rubi.add(rule115) pattern116 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda n, m: RationalQ(m, n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda m: Greater(m, S(1))), CustomConstraint(lambda p, m: NonzeroQ(m + S(2)*p + S(1))), CustomConstraint(lambda m: IntegerQ(m))) rule116 = ReplacementRule(pattern116, lambda p, e2, e1, d1, x, b, m, c, f, a, d2, n : -b*f*n*(-d1*d2)**IntPart(p)*(d1 + e1*x)**FracPart(p)*(d2 + e2*x)**FracPart(p)*(c*x + S(-1))**(-FracPart(p))*(c*x + S(1))**(-FracPart(p))*Int((f*x)**(m + S(-1))*(a + b*acosh(c*x))**(n + S(-1))*(c*x + S(-1))**(p + S(1)/2)*(c*x + S(1))**(p + S(1)/2), x)/(c*(m + S(2)*p + S(1))) + f*(f*x)**(m + S(-1))*(a + b*acosh(c*x))**n*(d1 + e1*x)**(p + S(1))*(d2 + e2*x)**(p + S(1))/(e1*e2*(m + S(2)*p + S(1))) + f**S(2)*(m + S(-1))*Int((f*x)**(m + S(-2))*(a + b*acosh(c*x))**n*(d1 + e1*x)**p*(d2 + e2*x)**p, x)/(c**S(2)*(m + S(2)*p + S(1)))) rubi.add(rule116) pattern117 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Less(n, S(-1))), CustomConstraint(lambda p, m: ZeroQ(m + S(2)*p + S(1))), CustomConstraint(lambda p: IntegerQ(p))) rule117 = ReplacementRule(pattern117, lambda p, x, m, b, c, f, a, d, e, n : f*m*(-d)**p*Int((f*x)**(m + S(-1))*(a + b*acosh(c*x))**(n + S(1))*(c*x + S(-1))**(p + S(-1)/2)*(c*x + S(1))**(p + S(-1)/2), x)/(b*c*(n + S(1))) + (f*x)**m*(a + b*acosh(c*x))**(n + S(1))*(d + e*x**S(2))**p*sqrt(c*x + S(-1))*sqrt(c*x + S(1))/(b*c*(n + S(1)))) rubi.add(rule117) pattern118 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Less(n, S(-1))), CustomConstraint(lambda p, m: ZeroQ(m + S(2)*p + S(1)))) rule118 = ReplacementRule(pattern118, lambda p, x, m, b, c, f, a, d, e, n : -d**IntPart(p)*f*m*(d + e*x**S(2))**FracPart(p)*(c**S(2)*x**S(2) + S(1))**(-FracPart(p))*Int((f*x)**(m + S(-1))*(a + b*asinh(c*x))**(n + S(1))*(c**S(2)*x**S(2) + S(1))**(p + S(-1)/2), x)/(b*c*(n + S(1))) + (f*x)**m*(a + b*asinh(c*x))**(n + S(1))*(d + e*x**S(2))**p*sqrt(c**S(2)*x**S(2) + S(1))/(b*c*(n + S(1)))) rubi.add(rule118) pattern119 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d1_ + x_*WC('e1', S(1)))**WC('p', S(1))*(d2_ + x_*WC('e2', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Less(n, S(-1))), CustomConstraint(lambda p, m: ZeroQ(m + S(2)*p + S(1))), CustomConstraint(lambda p: IntegerQ(p + S(-1)/2))) rule119 = ReplacementRule(pattern119, lambda p, e2, e1, d1, x, m, b, c, f, a, d2, n : f*m*(-d1*d2)**IntPart(p)*(d1 + e1*x)**FracPart(p)*(d2 + e2*x)**FracPart(p)*(c*x + S(-1))**(-FracPart(p))*(c*x + S(1))**(-FracPart(p))*Int((f*x)**(m + S(-1))*(a + b*acosh(c*x))**(n + S(1))*(c**S(2)*x**S(2) + S(-1))**(p + S(-1)/2), x)/(b*c*(n + S(1))) + (f*x)**m*(a + b*acosh(c*x))**(n + S(1))*(d1 + e1*x)**p*(d2 + e2*x)**p*sqrt(c*x + S(-1))*sqrt(c*x + S(1))/(b*c*(n + S(1)))) rubi.add(rule119) pattern120 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d1_ + x_*WC('e1', S(1)))**WC('p', S(1))*(d2_ + x_*WC('e2', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Less(n, S(-1))), CustomConstraint(lambda p, m: ZeroQ(m + S(2)*p + S(1)))) rule120 = ReplacementRule(pattern120, lambda p, e2, e1, d1, x, m, b, c, f, a, d2, n : f*m*(-d1*d2)**IntPart(p)*(d1 + e1*x)**FracPart(p)*(d2 + e2*x)**FracPart(p)*(c*x + S(-1))**(-FracPart(p))*(c*x + S(1))**(-FracPart(p))*Int((f*x)**(m + S(-1))*(a + b*acosh(c*x))**(n + S(1))*(c*x + S(-1))**(p + S(-1)/2)*(c*x + S(1))**(p + S(-1)/2), x)/(b*c*(n + S(1))) + (f*x)**m*(a + b*acosh(c*x))**(n + S(1))*(d1 + e1*x)**p*(d2 + e2*x)**p*sqrt(c*x + S(-1))*sqrt(c*x + S(1))/(b*c*(n + S(1)))) rubi.add(rule120) pattern121 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**n_/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Less(n, S(-1))), CustomConstraint(lambda d: PositiveQ(d))) rule121 = ReplacementRule(pattern121, lambda x, m, b, c, f, a, d, e, n : -f*m*Int((f*x)**(m + S(-1))*(a + b*asinh(c*x))**(n + S(1)), x)/(b*c*sqrt(d)*(n + S(1))) + (f*x)**m*(a + b*asinh(c*x))**(n + S(1))/(b*c*sqrt(d)*(n + S(1)))) rubi.add(rule121) pattern122 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**n_/(sqrt(d1_ + x_*WC('e1', S(1)))*sqrt(d2_ + x_*WC('e2', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Less(n, S(-1))), CustomConstraint(lambda d1: PositiveQ(d1)), CustomConstraint(lambda d2: NegativeQ(d2))) rule122 = ReplacementRule(pattern122, lambda e2, e1, d1, x, m, b, c, f, a, d2, n : -f*m*Int((f*x)**(m + S(-1))*(a + b*acosh(c*x))**(n + S(1)), x)/(b*c*sqrt(-d1*d2)*(n + S(1))) + (f*x)**m*(a + b*acosh(c*x))**(n + S(1))/(b*c*sqrt(-d1*d2)*(n + S(1)))) rubi.add(rule122) pattern123 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**n_/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Less(n, S(-1))), CustomConstraint(lambda d: Not(PositiveQ(d)))) rule123 = ReplacementRule(pattern123, lambda x, m, b, c, f, a, d, e, n : sqrt(c**S(2)*x**S(2) + S(1))*Int((f*x)**m*(a + b*asinh(c*x))**n/sqrt(c**S(2)*x**S(2) + S(1)), x)/sqrt(d + e*x**S(2))) rubi.add(rule123) pattern124 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**n_/(sqrt(d1_ + x_*WC('e1', S(1)))*sqrt(d2_ + x_*WC('e2', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Less(n, S(-1))), CustomConstraint(lambda d2, d1: Not(NegativeQ(d2) & PositiveQ(d1)))) rule124 = ReplacementRule(pattern124, lambda e2, e1, d1, x, m, b, c, f, a, d2, n : sqrt(c*x + S(-1))*sqrt(c*x + S(1))*Int((f*x)**m*(a + b*acosh(c*x))**n/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), x)/(sqrt(d1 + e1*x)*sqrt(d2 + e2*x))) rubi.add(rule124) pattern125 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Less(n, S(-1))), CustomConstraint(lambda m: IntegerQ(m)), CustomConstraint(lambda m: Greater(m, S(-3))), CustomConstraint(lambda p: PositiveIntegerQ(p))) rule125 = ReplacementRule(pattern125, lambda p, x, m, b, c, f, a, d, e, n : -c*(-d)**p*(m + S(2)*p + S(1))*Int((f*x)**(m + S(1))*(a + b*acosh(c*x))**(n + S(1))*(c*x + S(-1))**(p + S(-1)/2)*(c*x + S(1))**(p + S(-1)/2), x)/(b*f*(n + S(1))) + f*m*(-d)**p*Int((f*x)**(m + S(-1))*(a + b*acosh(c*x))**(n + S(1))*(c*x + S(-1))**(p + S(-1)/2)*(c*x + S(1))**(p + S(-1)/2), x)/(b*c*(n + S(1))) + (f*x)**m*(a + b*acosh(c*x))**(n + S(1))*(d + e*x**S(2))**p*sqrt(c*x + S(-1))*sqrt(c*x + S(1))/(b*c*(n + S(1)))) rubi.add(rule125) pattern126 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Less(n, S(-1))), CustomConstraint(lambda m: IntegerQ(m)), CustomConstraint(lambda m: Greater(m, S(-3))), CustomConstraint(lambda p: PositiveIntegerQ(S(2)*p))) rule126 = ReplacementRule(pattern126, lambda p, x, m, b, c, f, a, d, e, n : -c*d**IntPart(p)*(d + e*x**S(2))**FracPart(p)*(c**S(2)*x**S(2) + S(1))**(-FracPart(p))*(m + S(2)*p + S(1))*Int((f*x)**(m + S(1))*(a + b*asinh(c*x))**(n + S(1))*(c**S(2)*x**S(2) + S(1))**(p + S(-1)/2), x)/(b*f*(n + S(1))) - d**IntPart(p)*f*m*(d + e*x**S(2))**FracPart(p)*(c**S(2)*x**S(2) + S(1))**(-FracPart(p))*Int((f*x)**(m + S(-1))*(a + b*asinh(c*x))**(n + S(1))*(c**S(2)*x**S(2) + S(1))**(p + S(-1)/2), x)/(b*c*(n + S(1))) + (f*x)**m*(a + b*asinh(c*x))**(n + S(1))*(d + e*x**S(2))**p*sqrt(c**S(2)*x**S(2) + S(1))/(b*c*(n + S(1)))) rubi.add(rule126) pattern127 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d1_ + x_*WC('e1', S(1)))**WC('p', S(1))*(d2_ + x_*WC('e2', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Less(n, S(-1))), CustomConstraint(lambda m: IntegerQ(m)), CustomConstraint(lambda m: Greater(m, S(-3))), CustomConstraint(lambda p: PositiveIntegerQ(p + S(1)/2))) rule127 = ReplacementRule(pattern127, lambda p, e2, e1, d1, x, m, b, c, f, a, d2, n : -c*(-d1*d2)**IntPart(p)*(d1 + e1*x)**FracPart(p)*(d2 + e2*x)**FracPart(p)*(c*x + S(-1))**(-FracPart(p))*(c*x + S(1))**(-FracPart(p))*(m + S(2)*p + S(1))*Int((f*x)**(m + S(1))*(a + b*acosh(c*x))**(n + S(1))*(c**S(2)*x**S(2) + S(-1))**(p + S(-1)/2), x)/(b*f*(n + S(1))) + f*m*(-d1*d2)**IntPart(p)*(d1 + e1*x)**FracPart(p)*(d2 + e2*x)**FracPart(p)*(c*x + S(-1))**(-FracPart(p))*(c*x + S(1))**(-FracPart(p))*Int((f*x)**(m + S(-1))*(a + b*acosh(c*x))**(n + S(1))*(c**S(2)*x**S(2) + S(-1))**(p + S(-1)/2), x)/(b*c*(n + S(1))) + (f*x)**m*(a + b*acosh(c*x))**(n + S(1))*(d1 + e1*x)**p*(d2 + e2*x)**p*sqrt(c*x + S(-1))*sqrt(c*x + S(1))/(b*c*(n + S(1)))) rubi.add(rule127) pattern128 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda p: IntegerQ(S(2)*p)), CustomConstraint(lambda p: Greater(p, S(-1))), CustomConstraint(lambda m: PositiveIntegerQ(m)), CustomConstraint(lambda d, p: IntegerQ(p) | PositiveQ(d))) rule128 = ReplacementRule(pattern128, lambda p, x, b, m, c, a, d, e, n : c**(-m + S(-1))*d**p*Subst(Int((a + b*x)**n*Cosh(x)**(S(2)*p + S(1))*sinh(x)**m, x), x, asinh(c*x))) rubi.add(rule128) pattern129 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda p: PositiveIntegerQ(p)), CustomConstraint(lambda m: PositiveIntegerQ(m))) rule129 = ReplacementRule(pattern129, lambda p, x, b, m, c, a, d, e, n : c**(-m + S(-1))*(-d)**p*Subst(Int((a + b*x)**n*Cosh(x)**m*sinh(x)**(S(2)*p + S(1)), x), x, acosh(c*x))) rubi.add(rule129) pattern130 = Pattern(Integral(x_**WC('m', S(1))*(d1_ + x_*WC('e1', S(1)))**WC('p', S(1))*(d2_ + x_*WC('e2', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda p: IntegerQ(p + S(1)/2)), CustomConstraint(lambda p: Greater(p, S(-1))), CustomConstraint(lambda m: PositiveIntegerQ(m)), CustomConstraint(lambda d2, d1: NegativeQ(d2) & PositiveQ(d1))) rule130 = ReplacementRule(pattern130, lambda p, e2, e1, d1, x, b, m, c, a, d2, n : c**(-m + S(-1))*(-d1*d2)**p*Subst(Int((a + b*x)**n*Cosh(x)**m*sinh(x)**(S(2)*p + S(1)), x), x, acosh(c*x))) rubi.add(rule130) pattern131 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda p: IntegerQ(S(2)*p)), CustomConstraint(lambda p: Greater(p, S(-1))), CustomConstraint(lambda m: PositiveIntegerQ(m)), CustomConstraint(lambda d, p: Not(IntegerQ(p) | PositiveQ(d)))) rule131 = ReplacementRule(pattern131, lambda p, x, b, m, c, a, d, e, n : d**IntPart(p)*(d + e*x**S(2))**FracPart(p)*(c**S(2)*x**S(2) + S(1))**(-FracPart(p))*Int(x**m*(a + b*asinh(c*x))**n*(c**S(2)*x**S(2) + S(1))**p, x)) rubi.add(rule131) pattern132 = Pattern(Integral(x_**WC('m', S(1))*(d1_ + x_*WC('e1', S(1)))**WC('p', S(1))*(d2_ + x_*WC('e2', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda p: IntegerQ(S(2)*p)), CustomConstraint(lambda p: Greater(p, S(-1))), CustomConstraint(lambda m: PositiveIntegerQ(m)), CustomConstraint(lambda d2, p, d1: Not(IntegerQ(p) | (NegativeQ(d2) & PositiveQ(d1))))) rule132 = ReplacementRule(pattern132, lambda p, e2, e1, d1, x, b, m, c, a, d2, n : (-d1*d2)**IntPart(p)*(d1 + e1*x)**FracPart(p)*(d2 + e2*x)**FracPart(p)*(c*x + S(-1))**(-FracPart(p))*(c*x + S(1))**(-FracPart(p))*Int(x**m*(a + b*acosh(c*x))**n*(c*x + S(-1))**p*(c*x + S(1))**p, x)) rubi.add(rule132) pattern133 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda d: PositiveQ(d)), CustomConstraint(lambda p: PositiveIntegerQ(p + S(1)/2)), CustomConstraint(lambda m: Not(PositiveIntegerQ(m/S(2) + S(1)/2))), CustomConstraint(lambda m: IntegerQ(m)), CustomConstraint(lambda m: Less(S(-3), m, S(0)))) rule133 = ReplacementRule(pattern133, lambda p, x, b, m, c, f, a, d, e, n : Int(ExpandIntegrand((a + b*asinh(c*x))**n/sqrt(d + e*x**S(2)), (f*x)**m*(d + e*x**S(2))**(p + S(1)/2), x), x)) rubi.add(rule133) pattern134 = Pattern(Integral((x_*WC('f', S(1)))**m_*(d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda d1: PositiveQ(d1)), CustomConstraint(lambda d2: NegativeQ(d2)), CustomConstraint(lambda p: PositiveIntegerQ(p + S(1)/2)), CustomConstraint(lambda m: Not(PositiveIntegerQ(m/S(2) + S(1)/2))), CustomConstraint(lambda m: IntegerQ(m)), CustomConstraint(lambda m: Less(S(-3), m, S(0)))) rule134 = ReplacementRule(pattern134, lambda p, e2, e1, d1, x, b, m, c, f, a, d2, n : Int(ExpandIntegrand((a + b*acosh(c*x))**n/(sqrt(d1 + e1*x)*sqrt(d2 + e2*x)), (f*x)**m*(d1 + e1*x)**(p + S(1)/2)*(d2 + e2*x)**(p + S(1)/2), x), x)) rubi.add(rule134) pattern135 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda c, e, d: NonzeroQ(c**S(2)*d + e)), CustomConstraint(lambda m: NonzeroQ(m + S(1))), CustomConstraint(lambda m: NonzeroQ(m + S(3)))) rule135 = ReplacementRule(pattern135, lambda x, m, b, c, f, a, d, e : -b*c*Int((f*x)**(m + S(1))*(d*(m + S(3)) + e*x**S(2)*(m + S(1)))/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), x)/(f*(m + S(1))*(m + S(3))) + d*(f*x)**(m + S(1))*(a + b*acosh(c*x))/(f*(m + S(1))) + e*(f*x)**(m + S(3))*(a + b*acosh(c*x))/(f**S(3)*(m + S(3)))) rubi.add(rule135) pattern136 = Pattern(Integral(x_*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, d, e: NonzeroQ(-c**S(2)*d + e)), CustomConstraint(lambda p: NonzeroQ(p + S(1)))) rule136 = ReplacementRule(pattern136, lambda p, x, b, c, a, d, e : -b*c*Int((d + e*x**S(2))**(p + S(1))/sqrt(c**S(2)*x**S(2) + S(1)), x)/(S(2)*e*(p + S(1))) + (a + b*asinh(c*x))*(d + e*x**S(2))**(p + S(1))/(S(2)*e*(p + S(1)))) rubi.add(rule136) pattern137 = Pattern(Integral(x_*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, e, d: NonzeroQ(c**S(2)*d + e)), CustomConstraint(lambda p: NonzeroQ(p + S(1)))) rule137 = ReplacementRule(pattern137, lambda p, x, b, c, a, d, e : -b*c*Int((d + e*x**S(2))**(p + S(1))/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), x)/(S(2)*e*(p + S(1))) + (a + b*acosh(c*x))*(d + e*x**S(2))**(p + S(1))/(S(2)*e*(p + S(1)))) rubi.add(rule137) pattern138 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda c, d, e: NonzeroQ(-c**S(2)*d + e)), CustomConstraint(lambda p: IntegerQ(p)), CustomConstraint(lambda p, m: Greater(p, S(0)) | (LessEqual(m + p, S(0)) & PositiveIntegerQ(m/S(2) + S(-1)/2))), ) def With138(p, x, m, b, c, f, a, d, e): u = IntHide((f*x)**m*(d + e*x**S(2))**p, x) return -b*c*Int(SimplifyIntegrand(u/sqrt(c**S(2)*x**S(2) + S(1)), x), x) + Dist(a + b*asinh(c*x), u, x) rule138 = ReplacementRule(pattern138, lambda p, x, m, b, c, f, a, d, e : With138(p, x, m, b, c, f, a, d, e)) rubi.add(rule138) pattern139 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda c, e, d: NonzeroQ(c**S(2)*d + e)), CustomConstraint(lambda p: IntegerQ(p)), CustomConstraint(lambda p, m: Greater(p, S(0)) | (LessEqual(m + p, S(0)) & PositiveIntegerQ(m/S(2) + S(-1)/2))), ) def With139(p, x, m, b, c, f, a, d, e): u = IntHide((f*x)**m*(d + e*x**S(2))**p, x) return -b*c*Int(SimplifyIntegrand(u/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), x), x) + Dist(a + b*acosh(c*x), u, x) rule139 = ReplacementRule(pattern139, lambda p, x, m, b, c, f, a, d, e : With139(p, x, m, b, c, f, a, d, e)) rubi.add(rule139) pattern140 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda c, d, e: NonzeroQ(-c**S(2)*d + e)), CustomConstraint(lambda n: PositiveIntegerQ(n)), CustomConstraint(lambda p: IntegerQ(p)), CustomConstraint(lambda m: IntegerQ(m))) rule140 = ReplacementRule(pattern140, lambda p, x, b, m, c, f, a, d, e, n : Int(ExpandIntegrand((a + b*asinh(c*x))**n, (f*x)**m*(d + e*x**S(2))**p, x), x)) rubi.add(rule140) pattern141 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda c, e, d: NonzeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: PositiveIntegerQ(n)), CustomConstraint(lambda p: IntegerQ(p)), CustomConstraint(lambda m: IntegerQ(m))) rule141 = ReplacementRule(pattern141, lambda p, x, b, m, c, f, a, d, e, n : Int(ExpandIntegrand((a + b*acosh(c*x))**n, (f*x)**m*(d + e*x**S(2))**p, x), x)) rubi.add(rule141) pattern142 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x))) rule142 = ReplacementRule(pattern142, lambda p, x, b, m, c, f, a, d, e, n : Int((f*x)**m*(a + b*asinh(c*x))**n*(d + e*x**S(2))**p, x)) rubi.add(rule142) pattern143 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda p: IntegerQ(p))) rule143 = ReplacementRule(pattern143, lambda p, x, b, m, c, f, a, d, e, n : Int((f*x)**m*(a + b*acosh(c*x))**n*(d + e*x**S(2))**p, x)) rubi.add(rule143) pattern144 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d1_ + x_*WC('e1', S(1)))**WC('p', S(1))*(d2_ + x_*WC('e2', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x))) rule144 = ReplacementRule(pattern144, lambda p, e2, e1, d1, x, b, m, c, f, a, d2, n : Int((f*x)**m*(a + b*acosh(c*x))**n*(d1 + e1*x)**p*(d2 + e2*x)**p, x)) rubi.add(rule144) pattern145 = Pattern(Integral((x_*WC('h', S(1)))**WC('m', S(1))*(d_ + x_*WC('e', S(1)))**p_*(f_ + x_*WC('g', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda g, x: FreeQ(g, x)), CustomConstraint(lambda h, x: FreeQ(h, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda g, f, d, e: ZeroQ(d*g + e*f)), CustomConstraint(lambda g, c, f: ZeroQ(c**S(2)*f**S(2) + g**S(2))), CustomConstraint(lambda p: Not(IntegerQ(p)))) rule145 = ReplacementRule(pattern145, lambda p, h, x, b, m, g, c, f, a, d, e, n : (d + e*x)**FracPart(p)*(f + g*x)**FracPart(p)*(d*f + e*g*x**S(2))**(-FracPart(p))*Int((h*x)**m*(a + b*asinh(c*x))**n*(d*f + e*g*x**S(2))**p, x)) rubi.add(rule145) pattern146 = Pattern(Integral((x_*WC('f', S(1)))**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda p: Not(IntegerQ(p)))) rule146 = ReplacementRule(pattern146, lambda p, x, b, m, c, f, a, d, e, n : (-d)**IntPart(p)*(d + e*x**S(2))**FracPart(p)*(c*x + S(-1))**(-FracPart(p))*(c*x + S(1))**(-FracPart(p))*Int((f*x)**m*(a + b*acosh(c*x))**n*(c*x + S(-1))**p*(c*x + S(1))**p, x)) rubi.add(rule146) pattern147 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1))/(x_*WC('e', S(1)) + WC('d', S(0))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n: PositiveIntegerQ(n))) rule147 = ReplacementRule(pattern147, lambda x, b, c, a, d, e, n : Subst(Int((a + b*x)**n*Cosh(x)/(c*d + e*sinh(x)), x), x, asinh(c*x))) rubi.add(rule147) pattern148 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1))/(x_*WC('e', S(1)) + WC('d', S(0))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n: PositiveIntegerQ(n))) rule148 = ReplacementRule(pattern148, lambda x, b, c, a, d, e, n : Subst(Int((a + b*x)**n*sinh(x)/(c*d + e*Cosh(x)), x), x, acosh(c*x))) rubi.add(rule148) pattern149 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n: PositiveIntegerQ(n)), CustomConstraint(lambda m: NonzeroQ(m + S(1)))) rule149 = ReplacementRule(pattern149, lambda x, b, m, c, a, d, e, n : -b*c*n*Int((a + b*asinh(c*x))**(n + S(-1))*(d + e*x)**(m + S(1))/sqrt(c**S(2)*x**S(2) + S(1)), x)/(e*(m + S(1))) + (a + b*asinh(c*x))**n*(d + e*x)**(m + S(1))/(e*(m + S(1)))) rubi.add(rule149) pattern150 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n: PositiveIntegerQ(n)), CustomConstraint(lambda m: NonzeroQ(m + S(1)))) rule150 = ReplacementRule(pattern150, lambda x, b, m, c, a, d, e, n : -b*c*n*Int((a + b*acosh(c*x))**(n + S(-1))*(d + e*x)**(m + S(1))/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), x)/(e*(m + S(1))) + (a + b*acosh(c*x))**n*(d + e*x)**(m + S(1))/(e*(m + S(1)))) rubi.add(rule150) pattern151 = Pattern(Integral((d_ + x_*WC('e', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda m: PositiveIntegerQ(m)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Less(n, S(-1)))) rule151 = ReplacementRule(pattern151, lambda x, b, m, c, a, d, e, n : Int(ExpandIntegrand((a + b*asinh(c*x))**n*(d + e*x)**m, x), x)) rubi.add(rule151) pattern152 = Pattern(Integral((d_ + x_*WC('e', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda m: PositiveIntegerQ(m)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Less(n, S(-1)))) rule152 = ReplacementRule(pattern152, lambda x, b, m, c, a, d, e, n : Int(ExpandIntegrand((a + b*acosh(c*x))**n*(d + e*x)**m, x), x)) rubi.add(rule152) pattern153 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda m: PositiveIntegerQ(m))) rule153 = ReplacementRule(pattern153, lambda x, b, m, c, a, d, e, n : c**(-m + S(-1))*Subst(Int((a + b*x)**n*(c*d + e*sinh(x))**m*Cosh(x), x), x, asinh(c*x))) rubi.add(rule153) pattern154 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda m: PositiveIntegerQ(m))) rule154 = ReplacementRule(pattern154, lambda x, b, m, c, a, d, e, n : c**(-m + S(-1))*Subst(Int((a + b*x)**n*(c*d + e*Cosh(x))**m*sinh(x), x), x, acosh(c*x))) rubi.add(rule154) pattern155 = Pattern(Integral(Px_*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda x, Px: PolynomialQ(Px, x)), ) def With155(Px, x, b, c, a): u = IntHide(Px, x) return -b*c*Int(SimplifyIntegrand(u/sqrt(c**S(2)*x**S(2) + S(1)), x), x) + Dist(a + b*asinh(c*x), u, x) rule155 = ReplacementRule(pattern155, lambda Px, x, b, c, a : With155(Px, x, b, c, a)) rubi.add(rule155) pattern156 = Pattern(Integral(Px_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda x, Px: PolynomialQ(Px, x)), ) def With156(Px, x, b, c, a): u = IntHide(Px, x) return -b*c*sqrt(-c**S(2)*x**S(2) + S(1))*Int(SimplifyIntegrand(u/sqrt(-c**S(2)*x**S(2) + S(1)), x), x)/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))) + Dist(a + b*acosh(c*x), u, x) rule156 = ReplacementRule(pattern156, lambda Px, x, b, c, a : With156(Px, x, b, c, a)) rubi.add(rule156) pattern157 = Pattern(Integral(Px_*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda x, Px: PolynomialQ(Px, x))) rule157 = ReplacementRule(pattern157, lambda Px, x, b, c, a, n : Int(ExpandIntegrand(Px*(a + b*asinh(c*x))**n, x), x)) rubi.add(rule157) pattern158 = Pattern(Integral(Px_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda x, Px: PolynomialQ(Px, x))) rule158 = ReplacementRule(pattern158, lambda Px, x, b, c, a, n : Int(ExpandIntegrand(Px*(a + b*acosh(c*x))**n, x), x)) rubi.add(rule158) pattern159 = Pattern(Integral(Px_*(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda x, Px: PolynomialQ(Px, x)), ) def With159(Px, x, b, m, c, a, d, e): u = IntHide(Px*(d + e*x)**m, x) return -b*c*Int(SimplifyIntegrand(u/sqrt(c**S(2)*x**S(2) + S(1)), x), x) + Dist(a + b*asinh(c*x), u, x) rule159 = ReplacementRule(pattern159, lambda Px, x, b, m, c, a, d, e : With159(Px, x, b, m, c, a, d, e)) rubi.add(rule159) pattern160 = Pattern(Integral(Px_*(x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda x, Px: PolynomialQ(Px, x)), ) def With160(Px, x, b, m, c, a, d, e): u = IntHide(Px*(d + e*x)**m, x) return -b*c*sqrt(-c**S(2)*x**S(2) + S(1))*Int(SimplifyIntegrand(u/sqrt(-c**S(2)*x**S(2) + S(1)), x), x)/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))) + Dist(a + b*acosh(c*x), u, x) rule160 = ReplacementRule(pattern160, lambda Px, x, b, m, c, a, d, e : With160(Px, x, b, m, c, a, d, e)) rubi.add(rule160) pattern161 = Pattern(Integral((d_ + x_*WC('e', S(1)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda g, x: FreeQ(g, x)), CustomConstraint(lambda p, n: PositiveIntegerQ(n, p)), CustomConstraint(lambda m: NegativeIntegerQ(m)), CustomConstraint(lambda p, m: Less(m + p + S(1), S(0))), ) def With161(p, x, b, m, g, c, f, a, d, e, n): u = IntHide((d + e*x)**m*(f + g*x)**p, x) return -b*c*n*Int(SimplifyIntegrand(u*(a + b*asinh(c*x))**(n + S(-1))/sqrt(c**S(2)*x**S(2) + S(1)), x), x) + Dist((a + b*asinh(c*x))**n, u, x) rule161 = ReplacementRule(pattern161, lambda p, x, b, m, g, c, f, a, d, e, n : With161(p, x, b, m, g, c, f, a, d, e, n)) rubi.add(rule161) pattern162 = Pattern(Integral((d_ + x_*WC('e', S(1)))**m_*(x_*WC('g', S(1)) + WC('f', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda g, x: FreeQ(g, x)), CustomConstraint(lambda p, n: PositiveIntegerQ(n, p)), CustomConstraint(lambda m: NegativeIntegerQ(m)), CustomConstraint(lambda p, m: Less(m + p + S(1), S(0))), ) def With162(p, x, b, m, g, c, f, a, d, e, n): u = IntHide((d + e*x)**m*(f + g*x)**p, x) return -b*c*n*Int(SimplifyIntegrand(u*(a + b*acosh(c*x))**(n + S(-1))/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), x), x) + Dist((a + b*acosh(c*x))**n, u, x) rule162 = ReplacementRule(pattern162, lambda p, x, b, m, g, c, f, a, d, e, n : With162(p, x, b, m, g, c, f, a, d, e, n)) rubi.add(rule162) pattern163 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**n_*(x_**S(2)*WC('h', S(1)) + x_*WC('g', S(1)) + WC('f', S(0)))**WC('p', S(1))/(d_ + x_*WC('e', S(1)))**S(2), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda g, x: FreeQ(g, x)), CustomConstraint(lambda h, x: FreeQ(h, x)), CustomConstraint(lambda p, n: PositiveIntegerQ(n, p)), CustomConstraint(lambda g, d, e, h: ZeroQ(-S(2)*d*h + e*g)), ) def With163(p, h, x, b, g, c, f, a, d, e, n): u = IntHide((f + g*x + h*x**S(2))**p/(d + e*x)**S(2), x) return -b*c*n*Int(SimplifyIntegrand(u*(a + b*asinh(c*x))**(n + S(-1))/sqrt(c**S(2)*x**S(2) + S(1)), x), x) + Dist((a + b*asinh(c*x))**n, u, x) rule163 = ReplacementRule(pattern163, lambda p, h, x, b, g, c, f, a, d, e, n : With163(p, h, x, b, g, c, f, a, d, e, n)) rubi.add(rule163) pattern164 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**n_*(x_**S(2)*WC('h', S(1)) + x_*WC('g', S(1)) + WC('f', S(0)))**WC('p', S(1))/(d_ + x_*WC('e', S(1)))**S(2), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda g, x: FreeQ(g, x)), CustomConstraint(lambda h, x: FreeQ(h, x)), CustomConstraint(lambda p, n: PositiveIntegerQ(n, p)), CustomConstraint(lambda g, d, e, h: ZeroQ(-S(2)*d*h + e*g)), ) def With164(p, h, x, b, g, c, f, a, d, e, n): u = IntHide((f + g*x + h*x**S(2))**p/(d + e*x)**S(2), x) return -b*c*n*Int(SimplifyIntegrand(u*(a + b*acosh(c*x))**(n + S(-1))/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), x), x) + Dist((a + b*acosh(c*x))**n, u, x) rule164 = ReplacementRule(pattern164, lambda p, h, x, b, g, c, f, a, d, e, n : With164(p, h, x, b, g, c, f, a, d, e, n)) rubi.add(rule164) pattern165 = Pattern(Integral(Px_*(d_ + x_*WC('e', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda x, Px: PolynomialQ(Px, x)), CustomConstraint(lambda n: PositiveIntegerQ(n)), CustomConstraint(lambda m: IntegerQ(m))) rule165 = ReplacementRule(pattern165, lambda Px, x, b, m, c, a, d, e, n : Int(ExpandIntegrand(Px*(a + b*asinh(c*x))**n*(d + e*x)**m, x), x)) rubi.add(rule165) pattern166 = Pattern(Integral(Px_*(d_ + x_*WC('e', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda x, Px: PolynomialQ(Px, x)), CustomConstraint(lambda n: PositiveIntegerQ(n)), CustomConstraint(lambda m: IntegerQ(m))) rule166 = ReplacementRule(pattern166, lambda Px, x, b, m, c, a, d, e, n : Int(ExpandIntegrand(Px*(a + b*acosh(c*x))**n*(d + e*x)**m, x), x)) rubi.add(rule166) pattern167 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda g, x: FreeQ(g, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda m: IntegerQ(m)), CustomConstraint(lambda p: NegativeIntegerQ(p + S(1)/2)), CustomConstraint(lambda d: PositiveQ(d)), CustomConstraint(lambda m: Greater(m, S(0))), CustomConstraint(lambda p, m: Greater(m, S(3)) | Less(m, -S(2)*p + S(-1))), ) def With167(p, x, b, m, g, c, f, a, d, e): u = IntHide((d + e*x**S(2))**p*(f + g*x)**m, x) return -b*c*Int(Dist(1/sqrt(c**S(2)*x**S(2) + S(1)), u, x), x) + Dist(a + b*asinh(c*x), u, x) rule167 = ReplacementRule(pattern167, lambda p, x, b, m, g, c, f, a, d, e : With167(p, x, b, m, g, c, f, a, d, e)) rubi.add(rule167) pattern168 = Pattern(Integral((d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_*(f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda g, x: FreeQ(g, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda m: IntegerQ(m)), CustomConstraint(lambda p: NegativeIntegerQ(p + S(1)/2)), CustomConstraint(lambda d1: PositiveQ(d1)), CustomConstraint(lambda d2: NegativeQ(d2)), CustomConstraint(lambda m: Greater(m, S(0))), CustomConstraint(lambda p, m: Greater(m, S(3)) | Less(m, -S(2)*p + S(-1))), ) def With168(p, e2, e1, d1, x, b, m, g, c, f, a, d2): u = IntHide((d1 + e1*x)**p*(d2 + e2*x)**p*(f + g*x)**m, x) return -b*c*Int(Dist(S(1)/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), u, x), x) + Dist(a + b*acosh(c*x), u, x) rule168 = ReplacementRule(pattern168, lambda p, e2, e1, d1, x, b, m, g, c, f, a, d2 : With168(p, e2, e1, d1, x, b, m, g, c, f, a, d2)) rubi.add(rule168) pattern169 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda g, x: FreeQ(g, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda m: IntegerQ(m)), CustomConstraint(lambda p: IntegerQ(p + S(1)/2)), CustomConstraint(lambda d: PositiveQ(d)), CustomConstraint(lambda n: PositiveIntegerQ(n)), CustomConstraint(lambda m: Greater(m, S(0))), CustomConstraint(lambda p, n, m: Equal(m, S(1)) | Greater(p, S(0)) | (Equal(m, S(2)) & Less(p, S(-2))) | (Equal(n, S(1)) & Greater(p, S(-1))))) rule169 = ReplacementRule(pattern169, lambda p, x, b, m, g, c, f, a, d, e, n : Int(ExpandIntegrand((a + b*asinh(c*x))**n*(d + e*x**S(2))**p, (f + g*x)**m, x), x)) rubi.add(rule169) pattern170 = Pattern(Integral((d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_*(f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda g, x: FreeQ(g, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda m: IntegerQ(m)), CustomConstraint(lambda p: IntegerQ(p + S(1)/2)), CustomConstraint(lambda d1: PositiveQ(d1)), CustomConstraint(lambda d2: NegativeQ(d2)), CustomConstraint(lambda n: PositiveIntegerQ(n)), CustomConstraint(lambda m: Greater(m, S(0))), CustomConstraint(lambda p, n, m: Equal(m, S(1)) | Greater(p, S(0)) | (Equal(m, S(2)) & Less(p, S(-2))) | (Equal(n, S(1)) & Greater(p, S(-1))))) rule170 = ReplacementRule(pattern170, lambda p, e2, e1, d1, x, b, m, g, c, f, a, d2, n : Int(ExpandIntegrand((a + b*acosh(c*x))**n*(d1 + e1*x)**p*(d2 + e2*x)**p, (f + g*x)**m, x), x)) rubi.add(rule170) pattern171 = Pattern(Integral(sqrt(d_ + x_**S(2)*WC('e', S(1)))*(x_*WC('g', S(1)) + WC('f', S(0)))**m_*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda g, x: FreeQ(g, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda m: IntegerQ(m)), CustomConstraint(lambda d: PositiveQ(d)), CustomConstraint(lambda n: PositiveIntegerQ(n)), CustomConstraint(lambda m: Less(m, S(0)))) rule171 = ReplacementRule(pattern171, lambda x, b, m, g, c, f, a, d, e, n : (a + b*asinh(c*x))**(n + S(1))*(d + e*x**S(2))*(f + g*x)**m/(b*c*sqrt(d)*(n + S(1))) - Int((a + b*asinh(c*x))**(n + S(1))*(f + g*x)**(m + S(-1))*(d*g*m + S(2)*e*f*x + e*g*x**S(2)*(m + S(2))), x)/(b*c*sqrt(d)*(n + S(1)))) rubi.add(rule171) pattern172 = Pattern(Integral(sqrt(d1_ + x_*WC('e1', S(1)))*sqrt(d2_ + x_*WC('e2', S(1)))*(f_ + x_*WC('g', S(1)))**m_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda g, x: FreeQ(g, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda m: IntegerQ(m)), CustomConstraint(lambda d1: PositiveQ(d1)), CustomConstraint(lambda d2: NegativeQ(d2)), CustomConstraint(lambda n: PositiveIntegerQ(n)), CustomConstraint(lambda m: Less(m, S(0)))) rule172 = ReplacementRule(pattern172, lambda e2, e1, d1, x, b, m, g, c, f, a, d2, n : (a + b*acosh(c*x))**(n + S(1))*(f + g*x)**m*(d1*d2 + e1*e2*x**S(2))/(b*c*sqrt(-d1*d2)*(n + S(1))) - Int((a + b*acosh(c*x))**(n + S(1))*(f + g*x)**(m + S(-1))*(d1*d2*g*m + S(2)*e1*e2*f*x + e1*e2*g*x**S(2)*(m + S(2))), x)/(b*c*sqrt(-d1*d2)*(n + S(1)))) rubi.add(rule172) pattern173 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda g, x: FreeQ(g, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda m: IntegerQ(m)), CustomConstraint(lambda p: PositiveIntegerQ(p + S(1)/2)), CustomConstraint(lambda d: PositiveQ(d)), CustomConstraint(lambda n: PositiveIntegerQ(n))) rule173 = ReplacementRule(pattern173, lambda p, x, b, m, g, c, f, a, d, e, n : Int(ExpandIntegrand((a + b*asinh(c*x))**n*sqrt(d + e*x**S(2)), (d + e*x**S(2))**(p + S(-1)/2)*(f + g*x)**m, x), x)) rubi.add(rule173) pattern174 = Pattern(Integral((d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_*(f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda g, x: FreeQ(g, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda m: IntegerQ(m)), CustomConstraint(lambda p: PositiveIntegerQ(p + S(1)/2)), CustomConstraint(lambda d1: PositiveQ(d1)), CustomConstraint(lambda d2: NegativeQ(d2)), CustomConstraint(lambda n: PositiveIntegerQ(n))) rule174 = ReplacementRule(pattern174, lambda p, e2, e1, d1, x, b, m, g, c, f, a, d2, n : Int(ExpandIntegrand((a + b*acosh(c*x))**n*sqrt(d1 + e1*x)*sqrt(d2 + e2*x), (d1 + e1*x)**(p + S(-1)/2)*(d2 + e2*x)**(p + S(-1)/2)*(f + g*x)**m, x), x)) rubi.add(rule174) pattern175 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda g, x: FreeQ(g, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda m: IntegerQ(m)), CustomConstraint(lambda p: PositiveIntegerQ(p + S(-1)/2)), CustomConstraint(lambda d: PositiveQ(d)), CustomConstraint(lambda n: PositiveIntegerQ(n)), CustomConstraint(lambda m: Less(m, S(0)))) rule175 = ReplacementRule(pattern175, lambda p, x, b, m, g, c, f, a, d, e, n : (a + b*asinh(c*x))**(n + S(1))*(d + e*x**S(2))**(p + S(1)/2)*(f + g*x)**m/(b*c*sqrt(d)*(n + S(1))) - Int(ExpandIntegrand((a + b*asinh(c*x))**(n + S(1))*(f + g*x)**(m + S(-1)), (d + e*x**S(2))**(p + S(-1)/2)*(d*g*m + e*f*x*(S(2)*p + S(1)) + e*g*x**S(2)*(m + S(2)*p + S(1))), x), x)/(b*c*sqrt(d)*(n + S(1)))) rubi.add(rule175) pattern176 = Pattern(Integral((d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_*(f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda g, x: FreeQ(g, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda m: IntegerQ(m)), CustomConstraint(lambda p: PositiveIntegerQ(p + S(-1)/2)), CustomConstraint(lambda d1: PositiveQ(d1)), CustomConstraint(lambda d2: NegativeQ(d2)), CustomConstraint(lambda n: PositiveIntegerQ(n)), CustomConstraint(lambda m: Less(m, S(0)))) rule176 = ReplacementRule(pattern176, lambda p, e2, e1, d1, x, b, m, g, c, f, a, d2, n : (a + b*acosh(c*x))**(n + S(1))*(d1 + e1*x)**(p + S(1)/2)*(d2 + e2*x)**(p + S(1)/2)*(f + g*x)**m/(b*c*sqrt(-d1*d2)*(n + S(1))) - Int(ExpandIntegrand((a + b*acosh(c*x))**(n + S(1))*(f + g*x)**(m + S(-1)), (d1 + e1*x)**(p + S(-1)/2)*(d2 + e2*x)**(p + S(-1)/2)*(d1*d2*g*m + e1*e2*f*x*(S(2)*p + S(1)) + e1*e2*g*x**S(2)*(m + S(2)*p + S(1))), x), x)/(b*c*sqrt(-d1*d2)*(n + S(1)))) rubi.add(rule176) pattern177 = Pattern(Integral((f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**n_/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda g, x: FreeQ(g, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda m: IntegerQ(m)), CustomConstraint(lambda d: PositiveQ(d)), CustomConstraint(lambda m: Greater(m, S(0))), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Less(n, S(-1)))) rule177 = ReplacementRule(pattern177, lambda x, b, m, g, c, f, a, d, e, n : -g*m*Int((a + b*asinh(c*x))**(n + S(1))*(f + g*x)**(m + S(-1)), x)/(b*c*sqrt(d)*(n + S(1))) + (a + b*asinh(c*x))**(n + S(1))*(f + g*x)**m/(b*c*sqrt(d)*(n + S(1)))) rubi.add(rule177) pattern178 = Pattern(Integral((f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**n_/(sqrt(d1_ + x_*WC('e1', S(1)))*sqrt(d2_ + x_*WC('e2', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda g, x: FreeQ(g, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda m: IntegerQ(m)), CustomConstraint(lambda d1: PositiveQ(d1)), CustomConstraint(lambda d2: NegativeQ(d2)), CustomConstraint(lambda m: Greater(m, S(0))), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Less(n, S(-1)))) rule178 = ReplacementRule(pattern178, lambda e2, e1, d1, x, b, m, g, c, f, a, d2, n : -g*m*Int((a + b*acosh(c*x))**(n + S(1))*(f + g*x)**(m + S(-1)), x)/(b*c*sqrt(-d1*d2)*(n + S(1))) + (a + b*acosh(c*x))**(n + S(1))*(f + g*x)**m/(b*c*sqrt(-d1*d2)*(n + S(1)))) rubi.add(rule178) pattern179 = Pattern(Integral((f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda g, x: FreeQ(g, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda m: IntegerQ(m)), CustomConstraint(lambda d: PositiveQ(d)), CustomConstraint(lambda n, m: PositiveIntegerQ(n) | Greater(m, S(0)))) rule179 = ReplacementRule(pattern179, lambda x, b, m, g, c, f, a, d, e, n : c**(-m + S(-1))*Subst(Int((a + b*x)**n*(c*f + g*sinh(x))**m, x), x, asinh(c*x))/sqrt(d)) rubi.add(rule179) pattern180 = Pattern(Integral((f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1))/(sqrt(d1_ + x_*WC('e1', S(1)))*sqrt(d2_ + x_*WC('e2', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda g, x: FreeQ(g, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda m: IntegerQ(m)), CustomConstraint(lambda d1: PositiveQ(d1)), CustomConstraint(lambda d2: NegativeQ(d2)), CustomConstraint(lambda n, m: PositiveIntegerQ(n) | Greater(m, S(0)))) rule180 = ReplacementRule(pattern180, lambda e2, e1, d1, x, b, m, g, c, f, a, d2, n : c**(-m + S(-1))*Subst(Int((a + b*x)**n*(c*f + g*Cosh(x))**m, x), x, acosh(c*x))/sqrt(-d1*d2)) rubi.add(rule180) pattern181 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda g, x: FreeQ(g, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda m: IntegerQ(m)), CustomConstraint(lambda p: NegativeIntegerQ(p + S(1)/2)), CustomConstraint(lambda d: PositiveQ(d)), CustomConstraint(lambda n: PositiveIntegerQ(n))) rule181 = ReplacementRule(pattern181, lambda p, x, b, m, g, c, f, a, d, e, n : Int(ExpandIntegrand((a + b*asinh(c*x))**n/sqrt(d + e*x**S(2)), (d + e*x**S(2))**(p + S(1)/2)*(f + g*x)**m, x), x)) rubi.add(rule181) pattern182 = Pattern(Integral((d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_*(f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda g, x: FreeQ(g, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda m: IntegerQ(m)), CustomConstraint(lambda p: NegativeIntegerQ(p + S(1)/2)), CustomConstraint(lambda d1: PositiveQ(d1)), CustomConstraint(lambda d2: NegativeQ(d2)), CustomConstraint(lambda n: PositiveIntegerQ(n))) rule182 = ReplacementRule(pattern182, lambda p, e2, e1, d1, x, b, m, g, c, f, a, d2, n : Int(ExpandIntegrand((a + b*acosh(c*x))**n/(sqrt(d1 + e1*x)*sqrt(d2 + e2*x)), (d1 + e1*x)**(p + S(1)/2)*(d2 + e2*x)**(p + S(1)/2)*(f + g*x)**m, x), x)) rubi.add(rule182) pattern183 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda g, x: FreeQ(g, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda m: IntegerQ(m)), CustomConstraint(lambda p: IntegerQ(p + S(-1)/2)), CustomConstraint(lambda d: Not(PositiveQ(d)))) rule183 = ReplacementRule(pattern183, lambda p, x, b, m, g, c, f, a, d, e, n : d**IntPart(p)*(d + e*x**S(2))**FracPart(p)*(c**S(2)*x**S(2) + S(1))**(-FracPart(p))*Int((a + b*asinh(c*x))**n*(f + g*x)**m*(c**S(2)*x**S(2) + S(1))**p, x)) rubi.add(rule183) pattern184 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda g, x: FreeQ(g, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda m: IntegerQ(m)), CustomConstraint(lambda p: IntegerQ(p + S(-1)/2))) rule184 = ReplacementRule(pattern184, lambda p, x, b, m, g, c, f, a, d, e, n : (-d)**IntPart(p)*(d + e*x**S(2))**FracPart(p)*(c*x + S(-1))**(-FracPart(p))*(c*x + S(1))**(-FracPart(p))*Int((a + b*acosh(c*x))**n*(f + g*x)**m*(c*x + S(-1))**p*(c*x + S(1))**p, x)) rubi.add(rule184) pattern185 = Pattern(Integral((d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_*(f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda g, x: FreeQ(g, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda m: IntegerQ(m)), CustomConstraint(lambda p: IntegerQ(p + S(-1)/2)), CustomConstraint(lambda d2, d1: Not(NegativeQ(d2) & PositiveQ(d1)))) rule185 = ReplacementRule(pattern185, lambda p, e2, e1, d1, x, b, m, g, c, f, a, d2, n : (-d1*d2)**IntPart(p)*(d1 + e1*x)**FracPart(p)*(d2 + e2*x)**FracPart(p)*(-c**S(2)*x**S(2) + S(1))**(-FracPart(p))*Int((a + b*acosh(c*x))**n*(f + g*x)**m*(c*x + S(-1))**p*(c*x + S(1))**p, x)) rubi.add(rule185) pattern186 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1))*log((x_*WC('g', S(1)) + WC('f', S(0)))**WC('m', S(1))*WC('h', S(1)))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda g, x: FreeQ(g, x)), CustomConstraint(lambda h, x: FreeQ(h, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda d: PositiveQ(d)), CustomConstraint(lambda n: PositiveIntegerQ(n))) rule186 = ReplacementRule(pattern186, lambda h, x, m, b, g, f, c, a, d, e, n : -g*m*Int((a + b*asinh(c*x))**(n + S(1))/(f + g*x), x)/(b*c*sqrt(d)*(n + S(1))) + (a + b*asinh(c*x))**(n + S(1))*log(h*(f + g*x)**m)/(b*c*sqrt(d)*(n + S(1)))) rubi.add(rule186) pattern187 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1))*log((x_*WC('g', S(1)) + WC('f', S(0)))**WC('m', S(1))*WC('h', S(1)))/(sqrt(d1_ + x_*WC('e1', S(1)))*sqrt(d2_ + x_*WC('e2', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda g, x: FreeQ(g, x)), CustomConstraint(lambda h, x: FreeQ(h, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda d1: PositiveQ(d1)), CustomConstraint(lambda d2: NegativeQ(d2)), CustomConstraint(lambda n: PositiveIntegerQ(n))) rule187 = ReplacementRule(pattern187, lambda e2, h, e1, x, d1, m, b, g, f, c, a, d2, n : -g*m*Int((a + b*acosh(c*x))**(n + S(1))/(f + g*x), x)/(b*c*sqrt(-d1*d2)*(n + S(1))) + (a + b*acosh(c*x))**(n + S(1))*log(h*(f + g*x)**m)/(b*c*sqrt(-d1*d2)*(n + S(1)))) rubi.add(rule187) pattern188 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1))*log((x_*WC('g', S(1)) + WC('f', S(0)))**WC('m', S(1))*WC('h', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda g, x: FreeQ(g, x)), CustomConstraint(lambda h, x: FreeQ(h, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda p: IntegerQ(p + S(-1)/2)), CustomConstraint(lambda d: Not(PositiveQ(d)))) rule188 = ReplacementRule(pattern188, lambda p, h, x, m, b, g, f, c, a, d, e, n : d**IntPart(p)*(d + e*x**S(2))**FracPart(p)*(c**S(2)*x**S(2) + S(1))**(-FracPart(p))*Int((a + b*asinh(c*x))**n*(c**S(2)*x**S(2) + S(1))**p*log(h*(f + g*x)**m), x)) rubi.add(rule188) pattern189 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1))*log((x_*WC('g', S(1)) + WC('f', S(0)))**WC('m', S(1))*WC('h', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda g, x: FreeQ(g, x)), CustomConstraint(lambda h, x: FreeQ(h, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda p: IntegerQ(p + S(-1)/2))) rule189 = ReplacementRule(pattern189, lambda p, h, x, m, b, g, f, c, a, d, e, n : (-d)**IntPart(p)*(d + e*x**S(2))**FracPart(p)*(c*x + S(-1))**(-FracPart(p))*(c*x + S(1))**(-FracPart(p))*Int((a + b*acosh(c*x))**n*(c*x + S(-1))**p*(c*x + S(1))**p*log(h*(f + g*x)**m), x)) rubi.add(rule189) pattern190 = Pattern(Integral((d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1))*log((x_*WC('g', S(1)) + WC('f', S(0)))**WC('m', S(1))*WC('h', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda g, x: FreeQ(g, x)), CustomConstraint(lambda h, x: FreeQ(h, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda p: IntegerQ(p + S(-1)/2)), CustomConstraint(lambda d2, d1: Not(NegativeQ(d2) & PositiveQ(d1)))) rule190 = ReplacementRule(pattern190, lambda p, e2, h, e1, x, d1, m, b, g, f, c, a, d2, n : (-d1*d2)**IntPart(p)*(d1 + e1*x)**FracPart(p)*(d2 + e2*x)**FracPart(p)*(c*x + S(-1))**(-FracPart(p))*(c*x + S(1))**(-FracPart(p))*Int((a + b*acosh(c*x))**n*(c*x + S(-1))**p*(c*x + S(1))**p*log(h*(f + g*x)**m), x)) rubi.add(rule190) pattern191 = Pattern(Integral((d_ + x_*WC('e', S(1)))**m_*(f_ + x_*WC('g', S(1)))**m_*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda g, x: FreeQ(g, x)), CustomConstraint(lambda m: NegativeIntegerQ(m + S(1)/2)), ) def With191(x, b, m, g, c, f, a, d, e): u = IntHide((d + e*x)**m*(f + g*x)**m, x) return -b*c*Int(Dist(1/sqrt(c**S(2)*x**S(2) + S(1)), u, x), x) + Dist(a + b*asinh(c*x), u, x) rule191 = ReplacementRule(pattern191, lambda x, b, m, g, c, f, a, d, e : With191(x, b, m, g, c, f, a, d, e)) rubi.add(rule191) pattern192 = Pattern(Integral((d_ + x_*WC('e', S(1)))**m_*(f_ + x_*WC('g', S(1)))**m_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda g, x: FreeQ(g, x)), CustomConstraint(lambda m: NegativeIntegerQ(m + S(1)/2)), ) def With192(x, b, m, g, c, f, a, d, e): u = IntHide((d + e*x)**m*(f + g*x)**m, x) return -b*c*Int(Dist(S(1)/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), u, x), x) + Dist(a + b*acosh(c*x), u, x) rule192 = ReplacementRule(pattern192, lambda x, b, m, g, c, f, a, d, e : With192(x, b, m, g, c, f, a, d, e)) rubi.add(rule192) pattern193 = Pattern(Integral((d_ + x_*WC('e', S(1)))**WC('m', S(1))*(f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda g, x: FreeQ(g, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda m: IntegerQ(m))) rule193 = ReplacementRule(pattern193, lambda x, b, m, g, c, f, a, d, e, n : Int(ExpandIntegrand((a + b*asinh(c*x))**n, (d + e*x)**m*(f + g*x)**m, x), x)) rubi.add(rule193) pattern194 = Pattern(Integral((d_ + x_*WC('e', S(1)))**WC('m', S(1))*(f_ + x_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda g, x: FreeQ(g, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda m: IntegerQ(m))) rule194 = ReplacementRule(pattern194, lambda x, b, m, g, c, f, a, d, e, n : Int(ExpandIntegrand((a + b*acosh(c*x))**n, (d + e*x)**m*(f + g*x)**m, x), x)) rubi.add(rule194) pattern195 = Pattern(Integral(u_*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda a, v, x, b, c: InverseFunctionFreeQ(v, x))) def With195(x, b, c, a, u): v = IntHide(u, x) return -b*c*Int(SimplifyIntegrand(v/sqrt(c**S(2)*x**S(2) + S(1)), x), x) + Dist(a + b*asinh(c*x), v, x) rule195 = ReplacementRule(pattern195, lambda x, b, c, a, u : With195(x, b, c, a, u)) rubi.add(rule195) pattern196 = Pattern(Integral(u_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda a, v, x, b, c: InverseFunctionFreeQ(v, x))) def With196(x, b, c, a, u): v = IntHide(u, x) return -b*c*sqrt(-c**S(2)*x**S(2) + S(1))*Int(SimplifyIntegrand(v/sqrt(-c**S(2)*x**S(2) + S(1)), x), x)/(sqrt(c*x + S(-1))*sqrt(c*x + S(1))) + Dist(a + b*acosh(c*x), v, x) rule196 = ReplacementRule(pattern196, lambda x, b, c, a, u : With196(x, b, c, a, u)) rubi.add(rule196) pattern197 = Pattern(Integral(Px_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda x, Px: PolynomialQ(Px, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda p: IntegerQ(p + S(-1)/2)), CustomConstraint(lambda x, u: SumQ(u))) def With197(Px, p, x, b, c, a, d, e, n): u = ExpandIntegrand(Px*(a + b*asinh(c*x))**n*(d + e*x**S(2))**p, x) return Int(u, x) rule197 = ReplacementRule(pattern197, lambda Px, p, x, b, c, a, d, e, n : With197(Px, p, x, b, c, a, d, e, n)) rubi.add(rule197) pattern198 = Pattern(Integral(Px_*(d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda x, Px: PolynomialQ(Px, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda p: IntegerQ(p + S(-1)/2)), CustomConstraint(lambda x, u: SumQ(u))) def With198(Px, p, e2, e1, d1, x, b, c, a, d2, n): u = ExpandIntegrand(Px*(a + b*acosh(c*x))**n*(d1 + e1*x)**p*(d2 + e2*x)**p, x) return Int(u, x) rule198 = ReplacementRule(pattern198, lambda Px, p, e2, e1, d1, x, b, c, a, d2, n : With198(Px, p, e2, e1, d1, x, b, c, a, d2, n)) rubi.add(rule198) pattern199 = Pattern(Integral((f_ + (d_ + x_**S(2)*WC('e', S(1)))**p_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1))*WC('Px', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda g, x: FreeQ(g, x)), CustomConstraint(lambda x, Px: PolynomialQ(Px, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda p: PositiveIntegerQ(p + S(1)/2)), CustomConstraint(lambda n, m: IntegersQ(m, n)), CustomConstraint(lambda x, u: SumQ(u))) def With199(Px, p, x, b, m, g, c, f, a, d, e, n): u = ExpandIntegrand(Px*(a + b*asinh(c*x))**n*(f + g*(d + e*x**S(2))**p)**m, x) return Int(u, x) rule199 = ReplacementRule(pattern199, lambda Px, p, x, b, m, g, c, f, a, d, e, n : With199(Px, p, x, b, m, g, c, f, a, d, e, n)) rubi.add(rule199) pattern200 = Pattern(Integral((f_ + (d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_*WC('g', S(1)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1))*WC('Px', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda g, x: FreeQ(g, x)), CustomConstraint(lambda x, Px: PolynomialQ(Px, x)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda p: PositiveIntegerQ(p + S(1)/2)), CustomConstraint(lambda n, m: IntegersQ(m, n)), CustomConstraint(lambda x, u: SumQ(u))) def With200(Px, p, e2, e1, d1, x, b, m, g, c, f, a, d2, n): u = ExpandIntegrand(Px*(a + b*acosh(c*x))**n*(f + g*(d1 + e1*x)**p*(d2 + e2*x)**p)**m, x) return Int(u, x) rule200 = ReplacementRule(pattern200, lambda Px, p, e2, e1, d1, x, b, m, g, c, f, a, d2, n : With200(Px, p, e2, e1, d1, x, b, m, g, c, f, a, d2, n)) rubi.add(rule200) pattern201 = Pattern(Integral(RFx_*asinh(x_*WC('c', S(1)))**WC('n', S(1)), x_), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda RFx, x: RationalFunctionQ(RFx, x)), CustomConstraint(lambda n: PositiveIntegerQ(n)), CustomConstraint(lambda x, u: SumQ(u))) def With201(RFx, c, n, x): u = ExpandIntegrand(asinh(c*x)**n, RFx, x) return Int(u, x) rule201 = ReplacementRule(pattern201, lambda RFx, c, n, x : With201(RFx, c, n, x)) rubi.add(rule201) pattern202 = Pattern(Integral(RFx_*acosh(x_*WC('c', S(1)))**WC('n', S(1)), x_), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda RFx, x: RationalFunctionQ(RFx, x)), CustomConstraint(lambda n: PositiveIntegerQ(n)), CustomConstraint(lambda x, u: SumQ(u))) def With202(RFx, c, n, x): u = ExpandIntegrand(acosh(c*x)**n, RFx, x) return Int(u, x) rule202 = ReplacementRule(pattern202, lambda RFx, c, n, x : With202(RFx, c, n, x)) rubi.add(rule202) pattern203 = Pattern(Integral(RFx_*(a_ + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda RFx, x: RationalFunctionQ(RFx, x)), CustomConstraint(lambda n: PositiveIntegerQ(n))) rule203 = ReplacementRule(pattern203, lambda RFx, x, b, c, a, n : Int(ExpandIntegrand(RFx*(a + b*asinh(c*x))**n, x), x)) rubi.add(rule203) pattern204 = Pattern(Integral(RFx_*(a_ + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda RFx, x: RationalFunctionQ(RFx, x)), CustomConstraint(lambda n: PositiveIntegerQ(n))) rule204 = ReplacementRule(pattern204, lambda RFx, x, b, c, a, n : Int(ExpandIntegrand(RFx*(a + b*acosh(c*x))**n, x), x)) rubi.add(rule204) pattern205 = Pattern(Integral(RFx_*(d_ + x_**S(2)*WC('e', S(1)))**p_*asinh(x_*WC('c', S(1)))**WC('n', S(1)), x_), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda RFx, x: RationalFunctionQ(RFx, x)), CustomConstraint(lambda n: PositiveIntegerQ(n)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda p: IntegerQ(p + S(-1)/2)), CustomConstraint(lambda x, u: SumQ(u))) def With205(RFx, p, x, c, d, e, n): u = ExpandIntegrand((d + e*x**S(2))**p*asinh(c*x)**n, RFx, x) return Int(u, x) rule205 = ReplacementRule(pattern205, lambda RFx, p, x, c, d, e, n : With205(RFx, p, x, c, d, e, n)) rubi.add(rule205) pattern206 = Pattern(Integral(RFx_*(d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_*acosh(x_*WC('c', S(1)))**WC('n', S(1)), x_), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda RFx, x: RationalFunctionQ(RFx, x)), CustomConstraint(lambda n: PositiveIntegerQ(n)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda p: IntegerQ(p + S(-1)/2)), CustomConstraint(lambda x, u: SumQ(u))) def With206(RFx, p, e2, e1, d1, x, c, d2, n): u = ExpandIntegrand((d1 + e1*x)**p*(d2 + e2*x)**p*acosh(c*x)**n, RFx, x) return Int(u, x) rule206 = ReplacementRule(pattern206, lambda RFx, p, e2, e1, d1, x, c, d2, n : With206(RFx, p, e2, e1, d1, x, c, d2, n)) rubi.add(rule206) pattern207 = Pattern(Integral(RFx_*(a_ + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**p_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda RFx, x: RationalFunctionQ(RFx, x)), CustomConstraint(lambda n: PositiveIntegerQ(n)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda p: IntegerQ(p + S(-1)/2))) rule207 = ReplacementRule(pattern207, lambda RFx, p, x, b, c, a, d, e, n : Int(ExpandIntegrand((d + e*x**S(2))**p, RFx*(a + b*asinh(c*x))**n, x), x)) rubi.add(rule207) pattern208 = Pattern(Integral(RFx_*(a_ + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1))*(d1_ + x_*WC('e1', S(1)))**p_*(d2_ + x_*WC('e2', S(1)))**p_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d1, x: FreeQ(d1, x)), CustomConstraint(lambda e1, x: FreeQ(e1, x)), CustomConstraint(lambda d2, x: FreeQ(d2, x)), CustomConstraint(lambda e2, x: FreeQ(e2, x)), CustomConstraint(lambda RFx, x: RationalFunctionQ(RFx, x)), CustomConstraint(lambda n: PositiveIntegerQ(n)), CustomConstraint(lambda c, d1, e1: ZeroQ(-c*d1 + e1)), CustomConstraint(lambda d2, c, e2: ZeroQ(c*d2 + e2)), CustomConstraint(lambda p: IntegerQ(p + S(-1)/2))) rule208 = ReplacementRule(pattern208, lambda RFx, p, e2, e1, d1, x, b, c, a, d2, n : Int(ExpandIntegrand((d1 + e1*x)**p*(d2 + e2*x)**p, RFx*(a + b*acosh(c*x))**n, x), x)) rubi.add(rule208) pattern209 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asinh(x_*WC('c', S(1))))**WC('n', S(1))*WC('u', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda n, x: FreeQ(n, x))) rule209 = ReplacementRule(pattern209, lambda x, b, c, a, u, n : Int(u*(a + b*asinh(c*x))**n, x)) rubi.add(rule209) pattern210 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acosh(x_*WC('c', S(1))))**WC('n', S(1))*WC('u', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda n, x: FreeQ(n, x))) rule210 = ReplacementRule(pattern210, lambda x, b, c, a, u, n : Int(u*(a + b*acosh(c*x))**n, x)) rubi.add(rule210) pattern211 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asinh(c_ + x_*WC('d', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n, x: FreeQ(n, x))) rule211 = ReplacementRule(pattern211, lambda x, b, c, a, d, n : Subst(Int((a + b*asinh(x))**n, x), x, c + d*x)/d) rubi.add(rule211) pattern212 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acosh(c_ + x_*WC('d', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n, x: FreeQ(n, x))) rule212 = ReplacementRule(pattern212, lambda x, b, c, a, d, n : Subst(Int((a + b*acosh(x))**n, x), x, c + d*x)/d) rubi.add(rule212) pattern213 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(c_ + x_*WC('d', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n, x: FreeQ(n, x))) rule213 = ReplacementRule(pattern213, lambda x, b, m, f, c, a, d, e, n : Subst(Int((a + b*asinh(x))**n*(f*x/d + (-c*f + d*e)/d)**m, x), x, c + d*x)/d) rubi.add(rule213) pattern214 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(c_ + x_*WC('d', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n, x: FreeQ(n, x))) rule214 = ReplacementRule(pattern214, lambda x, b, m, f, c, a, d, e, n : Subst(Int((a + b*acosh(x))**n*(f*x/d + (-c*f + d*e)/d)**m, x), x, c + d*x)/d) rubi.add(rule214) pattern215 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asinh(c_ + x_*WC('d', S(1))))**WC('n', S(1))*(x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))**WC('p', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda A, x: FreeQ(A, x)), CustomConstraint(lambda B, x: FreeQ(B, x)), CustomConstraint(lambda C, x: FreeQ(C, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda B, c, A, d: ZeroQ(-S(2)*A*c*d + B*(c**S(2) + S(1)))), CustomConstraint(lambda B, c, C, d: ZeroQ(-B*d + S(2)*C*c))) rule215 = ReplacementRule(pattern215, lambda B, A, C, p, x, b, c, a, d, n : Subst(Int((a + b*asinh(x))**n*(C*x**S(2)/d**S(2) + C/d**S(2))**p, x), x, c + d*x)/d) rubi.add(rule215) pattern216 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acosh(c_ + x_*WC('d', S(1))))**WC('n', S(1))*(x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))**WC('p', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda A, x: FreeQ(A, x)), CustomConstraint(lambda B, x: FreeQ(B, x)), CustomConstraint(lambda C, x: FreeQ(C, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda B, c, A, d: ZeroQ(S(2)*A*c*d + B*(-c**S(2) + S(1)))), CustomConstraint(lambda B, c, C, d: ZeroQ(-B*d + S(2)*C*c))) rule216 = ReplacementRule(pattern216, lambda B, A, C, p, x, b, c, a, d, n : Subst(Int((a + b*acosh(x))**n*(C*x**S(2)/d**S(2) - C/d**S(2))**p, x), x, c + d*x)/d) rubi.add(rule216) pattern217 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(c_ + x_*WC('d', S(1))))**WC('n', S(1))*(x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))**WC('p', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda A, x: FreeQ(A, x)), CustomConstraint(lambda B, x: FreeQ(B, x)), CustomConstraint(lambda C, x: FreeQ(C, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda B, c, A, d: ZeroQ(-S(2)*A*c*d + B*(c**S(2) + S(1)))), CustomConstraint(lambda B, c, C, d: ZeroQ(-B*d + S(2)*C*c))) rule217 = ReplacementRule(pattern217, lambda B, A, C, p, x, b, m, f, c, a, d, e, n : Subst(Int((a + b*asinh(x))**n*(C*x**S(2)/d**S(2) + C/d**S(2))**p*(f*x/d + (-c*f + d*e)/d)**m, x), x, c + d*x)/d) rubi.add(rule217) pattern218 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(c_ + x_*WC('d', S(1))))**WC('n', S(1))*(x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))**WC('p', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda A, x: FreeQ(A, x)), CustomConstraint(lambda B, x: FreeQ(B, x)), CustomConstraint(lambda C, x: FreeQ(C, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda B, c, A, d: ZeroQ(S(2)*A*c*d + B*(-c**S(2) + S(1)))), CustomConstraint(lambda B, c, C, d: ZeroQ(-B*d + S(2)*C*c))) rule218 = ReplacementRule(pattern218, lambda B, A, C, p, x, b, m, f, c, a, d, e, n : Subst(Int((a + b*acosh(x))**n*(C*x**S(2)/d**S(2) - C/d**S(2))**p*(f*x/d + (-c*f + d*e)/d)**m, x), x, c + d*x)/d) rubi.add(rule218) pattern219 = Pattern(Integral(sqrt(WC('a', S(0)) + WC('b', S(1))*asinh(c_ + x_**S(2)*WC('d', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda c: ZeroQ(c**S(2) + S(1)))) rule219 = ReplacementRule(pattern219, lambda x, b, c, a, d : -sqrt(Pi)*x*(-c*sinh(a/(S(2)*b)) + Cosh(a/(S(2)*b)))*FresnelC(sqrt(-c/(Pi*b))*sqrt(a + b*asinh(c + d*x**S(2))))/(sqrt(-c/b)*(c*sinh(asinh(c + d*x**S(2))/S(2)) + Cosh(asinh(c + d*x**S(2))/S(2)))) + sqrt(Pi)*x*(c*sinh(a/(S(2)*b)) + Cosh(a/(S(2)*b)))*FresnelS(sqrt(-c/(Pi*b))*sqrt(a + b*asinh(c + d*x**S(2))))/(sqrt(-c/b)*(c*sinh(asinh(c + d*x**S(2))/S(2)) + Cosh(asinh(c + d*x**S(2))/S(2)))) + x*sqrt(a + b*asinh(c + d*x**S(2)))) rubi.add(rule219) pattern220 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asinh(c_ + x_**S(2)*WC('d', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda c: ZeroQ(c**S(2) + S(1))), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(1)))) rule220 = ReplacementRule(pattern220, lambda x, b, c, a, d, n : S(4)*b**S(2)*n*(n + S(-1))*Int((a + b*asinh(c + d*x**S(2)))**(n + S(-2)), x) - S(2)*b*n*(a + b*asinh(c + d*x**S(2)))**(n + S(-1))*sqrt(S(2)*c*d*x**S(2) + d**S(2)*x**S(4))/(d*x) + x*(a + b*asinh(c + d*x**S(2)))**n) rubi.add(rule220) pattern221 = Pattern(Integral(1/(WC('a', S(0)) + WC('b', S(1))*asinh(c_ + x_**S(2)*WC('d', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda c: ZeroQ(c**S(2) + S(1)))) rule221 = ReplacementRule(pattern221, lambda x, b, c, a, d : x*(c*Cosh(a/(S(2)*b)) - sinh(a/(S(2)*b)))*CoshIntegral((a + b*asinh(c + d*x**S(2)))/(S(2)*b))/(S(2)*b*(c*sinh(asinh(c + d*x**S(2))/S(2)) + Cosh(asinh(c + d*x**S(2))/S(2)))) + x*(-c*sinh(a/(S(2)*b)) + Cosh(a/(S(2)*b)))*SinhIntegral((a + b*asinh(c + d*x**S(2)))/(S(2)*b))/(S(2)*b*(c*sinh(asinh(c + d*x**S(2))/S(2)) + Cosh(asinh(c + d*x**S(2))/S(2))))) rubi.add(rule221) pattern222 = Pattern(Integral(1/sqrt(WC('a', S(0)) + WC('b', S(1))*asinh(c_ + x_**S(2)*WC('d', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda c: ZeroQ(c**S(2) + S(1)))) rule222 = ReplacementRule(pattern222, lambda x, b, c, a, d : sqrt(S(2))*sqrt(Pi)*x*(c + S(-1))*(Cosh(a/(S(2)*b)) + sinh(a/(S(2)*b)))*Erf(sqrt(S(2))*sqrt(a + b*asinh(c + d*x**S(2)))/(S(2)*sqrt(b)))/(S(4)*sqrt(b)*(c*sinh(asinh(c + d*x**S(2))/S(2)) + Cosh(asinh(c + d*x**S(2))/S(2)))) + sqrt(S(2))*sqrt(Pi)*x*(c + S(1))*(Cosh(a/(S(2)*b)) - sinh(a/(S(2)*b)))*Erfi(sqrt(S(2))*sqrt(a + b*asinh(c + d*x**S(2)))/(S(2)*sqrt(b)))/(S(4)*sqrt(b)*(c*sinh(asinh(c + d*x**S(2))/S(2)) + Cosh(asinh(c + d*x**S(2))/S(2))))) rubi.add(rule222) pattern223 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asinh(c_ + x_**S(2)*WC('d', S(1))))**(S(-3)/2), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda c: ZeroQ(c**S(2) + S(1)))) rule223 = ReplacementRule(pattern223, lambda x, b, c, a, d : -sqrt(Pi)*x*(-c/b)**(S(3)/2)*(-c*sinh(a/(S(2)*b)) + Cosh(a/(S(2)*b)))*FresnelC(sqrt(-c/(Pi*b))*sqrt(a + b*asinh(c + d*x**S(2))))/(c*sinh(asinh(c + d*x**S(2))/S(2)) + Cosh(asinh(c + d*x**S(2))/S(2))) + sqrt(Pi)*x*(-c/b)**(S(3)/2)*(c*sinh(a/(S(2)*b)) + Cosh(a/(S(2)*b)))*FresnelS(sqrt(-c/(Pi*b))*sqrt(a + b*asinh(c + d*x**S(2))))/(c*sinh(asinh(c + d*x**S(2))/S(2)) + Cosh(asinh(c + d*x**S(2))/S(2))) - sqrt(S(2)*c*d*x**S(2) + d**S(2)*x**S(4))/(b*d*x*sqrt(a + b*asinh(c + d*x**S(2))))) rubi.add(rule223) pattern224 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asinh(c_ + x_**S(2)*WC('d', S(1))))**(S(-2)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda c: ZeroQ(c**S(2) + S(1)))) rule224 = ReplacementRule(pattern224, lambda x, b, c, a, d : -sqrt(S(2)*c*d*x**S(2) + d**S(2)*x**S(4))/(S(2)*b*d*x*(a + b*asinh(c + d*x**S(2)))) + x*(c*Cosh(a/(S(2)*b)) - sinh(a/(S(2)*b)))*SinhIntegral((a + b*asinh(c + d*x**S(2)))/(S(2)*b))/(S(4)*b**S(2)*(c*sinh(asinh(c + d*x**S(2))/S(2)) + Cosh(asinh(c + d*x**S(2))/S(2)))) + x*(-c*sinh(a/(S(2)*b)) + Cosh(a/(S(2)*b)))*CoshIntegral((a + b*asinh(c + d*x**S(2)))/(S(2)*b))/(S(4)*b**S(2)*(c*sinh(asinh(c + d*x**S(2))/S(2)) + Cosh(asinh(c + d*x**S(2))/S(2))))) rubi.add(rule224) pattern225 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asinh(c_ + x_**S(2)*WC('d', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda c: ZeroQ(c**S(2) + S(1))), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Less(n, S(-1))), CustomConstraint(lambda n: Unequal(n, S(-2)))) rule225 = ReplacementRule(pattern225, lambda x, b, c, a, d, n : (a + b*asinh(c + d*x**S(2)))**(n + S(1))*sqrt(S(2)*c*d*x**S(2) + d**S(2)*x**S(4))/(S(2)*b*d*x*(n + S(1))) - x*(a + b*asinh(c + d*x**S(2)))**(n + S(2))/(S(4)*b**S(2)*(n + S(1))*(n + S(2))) + Int((a + b*asinh(c + d*x**S(2)))**(n + S(2)), x)/(S(4)*b**S(2)*(n + S(1))*(n + S(2)))) rubi.add(rule225) pattern226 = Pattern(Integral(sqrt(WC('a', S(0)) + WC('b', S(1))*acosh(x_**S(2)*WC('d', S(1)) + S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda d, x: FreeQ(d, x))) rule226 = ReplacementRule(pattern226, lambda x, a, d, b : -sqrt(S(2))*sqrt(Pi)*sqrt(b)*(Cosh(a/(S(2)*b)) - sinh(a/(S(2)*b)))*Erfi(sqrt(S(2))*sqrt(a + b*acosh(d*x**S(2) + S(1)))/(S(2)*sqrt(b)))*sinh(acosh(d*x**S(2) + S(1))/S(2))/(S(2)*d*x) + sqrt(S(2))*sqrt(Pi)*sqrt(b)*(Cosh(a/(S(2)*b)) + sinh(a/(S(2)*b)))*Erf(sqrt(S(2))*sqrt(a + b*acosh(d*x**S(2) + S(1)))/(S(2)*sqrt(b)))*sinh(acosh(d*x**S(2) + S(1))/S(2))/(S(2)*d*x) + S(2)*sqrt(a + b*acosh(d*x**S(2) + S(1)))*sinh(acosh(d*x**S(2) + S(1))/S(2))**S(2)/(d*x)) rubi.add(rule226) pattern227 = Pattern(Integral(sqrt(WC('a', S(0)) + WC('b', S(1))*acosh(x_**S(2)*WC('d', S(1)) + S(-1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda d, x: FreeQ(d, x))) rule227 = ReplacementRule(pattern227, lambda x, a, d, b : -sqrt(S(2))*sqrt(Pi)*sqrt(b)*(Cosh(a/(S(2)*b)) - sinh(a/(S(2)*b)))*Cosh(acosh(d*x**S(2) + S(-1))/S(2))*Erfi(sqrt(S(2))*sqrt(a + b*acosh(d*x**S(2) + S(-1)))/(S(2)*sqrt(b)))/(S(2)*d*x) - sqrt(S(2))*sqrt(Pi)*sqrt(b)*(Cosh(a/(S(2)*b)) + sinh(a/(S(2)*b)))*Cosh(acosh(d*x**S(2) + S(-1))/S(2))*Erf(sqrt(S(2))*sqrt(a + b*acosh(d*x**S(2) + S(-1)))/(S(2)*sqrt(b)))/(S(2)*d*x) + S(2)*sqrt(a + b*acosh(d*x**S(2) + S(-1)))*Cosh(acosh(d*x**S(2) + S(-1))/S(2))**S(2)/(d*x)) rubi.add(rule227) pattern228 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acosh(c_ + x_**S(2)*WC('d', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda c: ZeroQ(c**S(2) + S(-1))), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(1)))) rule228 = ReplacementRule(pattern228, lambda x, b, c, a, d, n : S(4)*b**S(2)*n*(n + S(-1))*Int((a + b*acosh(c + d*x**S(2)))**(n + S(-2)), x) - S(2)*b*n*(a + b*acosh(c + d*x**S(2)))**(n + S(-1))*(S(2)*c*d*x**S(2) + d**S(2)*x**S(4))/(d*x*sqrt(c + d*x**S(2) + S(-1))*sqrt(c + d*x**S(2) + S(1))) + x*(a + b*acosh(c + d*x**S(2)))**n) rubi.add(rule228) pattern229 = Pattern(Integral(1/(WC('a', S(0)) + WC('b', S(1))*acosh(x_**S(2)*WC('d', S(1)) + S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda d, x: FreeQ(d, x))) rule229 = ReplacementRule(pattern229, lambda x, a, d, b : sqrt(S(2))*x*Cosh(a/(S(2)*b))*CoshIntegral((a + b*acosh(d*x**S(2) + S(1)))/(S(2)*b))/(S(2)*b*sqrt(d*x**S(2))) - sqrt(S(2))*x*SinhIntegral((a + b*acosh(d*x**S(2) + S(1)))/(S(2)*b))*sinh(a/(S(2)*b))/(S(2)*b*sqrt(d*x**S(2)))) rubi.add(rule229) pattern230 = Pattern(Integral(1/(WC('a', S(0)) + WC('b', S(1))*acosh(x_**S(2)*WC('d', S(1)) + S(-1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda d, x: FreeQ(d, x))) rule230 = ReplacementRule(pattern230, lambda x, a, d, b : sqrt(S(2))*x*Cosh(a/(S(2)*b))*SinhIntegral((a + b*acosh(d*x**S(2) + S(-1)))/(S(2)*b))/(S(2)*b*sqrt(d*x**S(2))) - sqrt(S(2))*x*CoshIntegral((a + b*acosh(d*x**S(2) + S(-1)))/(S(2)*b))*sinh(a/(S(2)*b))/(S(2)*b*sqrt(d*x**S(2)))) rubi.add(rule230) pattern231 = Pattern(Integral(1/sqrt(WC('a', S(0)) + WC('b', S(1))*acosh(x_**S(2)*WC('d', S(1)) + S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda d, x: FreeQ(d, x))) rule231 = ReplacementRule(pattern231, lambda x, a, d, b : sqrt(S(2))*sqrt(Pi)*(Cosh(a/(S(2)*b)) - sinh(a/(S(2)*b)))*Erfi(sqrt(S(2))*sqrt(a + b*acosh(d*x**S(2) + S(1)))/(S(2)*sqrt(b)))*sinh(acosh(d*x**S(2) + S(1))/S(2))/(S(2)*sqrt(b)*d*x) + sqrt(S(2))*sqrt(Pi)*(Cosh(a/(S(2)*b)) + sinh(a/(S(2)*b)))*Erf(sqrt(S(2))*sqrt(a + b*acosh(d*x**S(2) + S(1)))/(S(2)*sqrt(b)))*sinh(acosh(d*x**S(2) + S(1))/S(2))/(S(2)*sqrt(b)*d*x)) rubi.add(rule231) pattern232 = Pattern(Integral(1/sqrt(WC('a', S(0)) + WC('b', S(1))*acosh(x_**S(2)*WC('d', S(1)) + S(-1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda d, x: FreeQ(d, x))) rule232 = ReplacementRule(pattern232, lambda x, a, d, b : sqrt(S(2))*sqrt(Pi)*(Cosh(a/(S(2)*b)) - sinh(a/(S(2)*b)))*Cosh(acosh(d*x**S(2) + S(-1))/S(2))*Erfi(sqrt(S(2))*sqrt(a + b*acosh(d*x**S(2) + S(-1)))/(S(2)*sqrt(b)))/(S(2)*sqrt(b)*d*x) - sqrt(S(2))*sqrt(Pi)*(Cosh(a/(S(2)*b)) + sinh(a/(S(2)*b)))*Cosh(acosh(d*x**S(2) + S(-1))/S(2))*Erf(sqrt(S(2))*sqrt(a + b*acosh(d*x**S(2) + S(-1)))/(S(2)*sqrt(b)))/(S(2)*sqrt(b)*d*x)) rubi.add(rule232) pattern233 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acosh(x_**S(2)*WC('d', S(1)) + S(1)))**(S(-3)/2), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda d, x: FreeQ(d, x))) rule233 = ReplacementRule(pattern233, lambda x, a, d, b : sqrt(S(2))*sqrt(Pi)*(Cosh(a/(S(2)*b)) - sinh(a/(S(2)*b)))*Erfi(sqrt(S(2))*sqrt(a + b*acosh(d*x**S(2) + S(1)))/(S(2)*sqrt(b)))*sinh(acosh(d*x**S(2) + S(1))/S(2))/(S(2)*b**(S(3)/2)*d*x) - sqrt(S(2))*sqrt(Pi)*(Cosh(a/(S(2)*b)) + sinh(a/(S(2)*b)))*Erf(sqrt(S(2))*sqrt(a + b*acosh(d*x**S(2) + S(1)))/(S(2)*sqrt(b)))*sinh(acosh(d*x**S(2) + S(1))/S(2))/(S(2)*b**(S(3)/2)*d*x) - sqrt(d*x**S(2))*sqrt(d*x**S(2) + S(2))/(b*d*x*sqrt(a + b*acosh(d*x**S(2) + S(1))))) rubi.add(rule233) pattern234 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acosh(x_**S(2)*WC('d', S(1)) + S(-1)))**(S(-3)/2), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda d, x: FreeQ(d, x))) rule234 = ReplacementRule(pattern234, lambda x, a, d, b : sqrt(S(2))*sqrt(Pi)*(Cosh(a/(S(2)*b)) - sinh(a/(S(2)*b)))*Cosh(acosh(d*x**S(2) + S(-1))/S(2))*Erfi(sqrt(S(2))*sqrt(a + b*acosh(d*x**S(2) + S(-1)))/(S(2)*sqrt(b)))/(S(2)*b**(S(3)/2)*d*x) + sqrt(S(2))*sqrt(Pi)*(Cosh(a/(S(2)*b)) + sinh(a/(S(2)*b)))*Cosh(acosh(d*x**S(2) + S(-1))/S(2))*Erf(sqrt(S(2))*sqrt(a + b*acosh(d*x**S(2) + S(-1)))/(S(2)*sqrt(b)))/(S(2)*b**(S(3)/2)*d*x) - sqrt(d*x**S(2))*sqrt(d*x**S(2) + S(-2))/(b*d*x*sqrt(a + b*acosh(d*x**S(2) + S(-1))))) rubi.add(rule234) pattern235 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acosh(x_**S(2)*WC('d', S(1)) + S(1)))**(S(-2)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda d, x: FreeQ(d, x))) rule235 = ReplacementRule(pattern235, lambda x, a, d, b : -sqrt(d*x**S(2))*sqrt(d*x**S(2) + S(2))/(S(2)*b*d*x*(a + b*acosh(d*x**S(2) + S(1)))) + sqrt(S(2))*x*Cosh(a/(S(2)*b))*SinhIntegral((a + b*acosh(d*x**S(2) + S(1)))/(S(2)*b))/(S(4)*b**S(2)*sqrt(d*x**S(2))) - sqrt(S(2))*x*CoshIntegral((a + b*acosh(d*x**S(2) + S(1)))/(S(2)*b))*sinh(a/(S(2)*b))/(S(4)*b**S(2)*sqrt(d*x**S(2)))) rubi.add(rule235) pattern236 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acosh(x_**S(2)*WC('d', S(1)) + S(-1)))**(S(-2)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda d, x: FreeQ(d, x))) rule236 = ReplacementRule(pattern236, lambda x, a, d, b : -sqrt(d*x**S(2))*sqrt(d*x**S(2) + S(-2))/(S(2)*b*d*x*(a + b*acosh(d*x**S(2) + S(-1)))) + sqrt(S(2))*x*Cosh(a/(S(2)*b))*CoshIntegral((a + b*acosh(d*x**S(2) + S(-1)))/(S(2)*b))/(S(4)*b**S(2)*sqrt(d*x**S(2))) - sqrt(S(2))*x*SinhIntegral((a + b*acosh(d*x**S(2) + S(-1)))/(S(2)*b))*sinh(a/(S(2)*b))/(S(4)*b**S(2)*sqrt(d*x**S(2)))) rubi.add(rule236) pattern237 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acosh(c_ + x_**S(2)*WC('d', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda c: ZeroQ(c**S(2) + S(-1))), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Less(n, S(-1))), CustomConstraint(lambda n: Unequal(n, S(-2)))) rule237 = ReplacementRule(pattern237, lambda x, b, c, a, d, n : (a + b*acosh(c + d*x**S(2)))**(n + S(1))*(S(2)*c*x**S(2) + d*x**S(4))/(S(2)*b*x*(n + S(1))*sqrt(c + d*x**S(2) + S(-1))*sqrt(c + d*x**S(2) + S(1))) - x*(a + b*acosh(c + d*x**S(2)))**(n + S(2))/(S(4)*b**S(2)*(n + S(1))*(n + S(2))) + Int((a + b*acosh(c + d*x**S(2)))**(n + S(2)), x)/(S(4)*b**S(2)*(n + S(1))*(n + S(2)))) rubi.add(rule237) pattern238 = Pattern(Integral(asinh(x_**p_*WC('a', S(1)))**WC('n', S(1))/x_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda n: PositiveIntegerQ(n))) rule238 = ReplacementRule(pattern238, lambda x, a, p, n : Subst(Int(x**n*coth(x), x), x, asinh(a*x**p))/p) rubi.add(rule238) pattern239 = Pattern(Integral(acosh(x_**p_*WC('a', S(1)))**WC('n', S(1))/x_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda n: PositiveIntegerQ(n))) rule239 = ReplacementRule(pattern239, lambda x, a, p, n : Subst(Int(x**n*tanh(x), x), x, acosh(a*x**p))/p) rubi.add(rule239) pattern240 = Pattern(Integral(WC('u', S(1))*asinh(WC('c', S(1))/(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda m, x: FreeQ(m, x))) rule240 = ReplacementRule(pattern240, lambda x, b, m, c, a, u, n : Int(u*acsch(a/c + b*x**n/c)**m, x)) rubi.add(rule240) pattern241 = Pattern(Integral(WC('u', S(1))*acosh(WC('c', S(1))/(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda m, x: FreeQ(m, x))) rule241 = ReplacementRule(pattern241, lambda x, b, m, c, a, u, n : Int(u*asech(a/c + b*x**n/c)**m, x)) rubi.add(rule241) pattern242 = Pattern(Integral(asinh(sqrt(x_**S(2)*WC('b', S(1)) + S(-1)))**WC('n', S(1))/sqrt(x_**S(2)*WC('b', S(1)) + S(-1)), x_), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda n, x: FreeQ(n, x))) rule242 = ReplacementRule(pattern242, lambda x, n, b : sqrt(b*x**S(2))*Subst(Int(asinh(x)**n/sqrt(x**S(2) + S(1)), x), x, sqrt(b*x**S(2) + S(-1)))/(b*x)) rubi.add(rule242) pattern243 = Pattern(Integral(acosh(sqrt(x_**S(2)*WC('b', S(1)) + S(1)))**WC('n', S(1))/sqrt(x_**S(2)*WC('b', S(1)) + S(1)), x_), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda n, x: FreeQ(n, x))) rule243 = ReplacementRule(pattern243, lambda x, n, b : sqrt(sqrt(b*x**S(2) + S(1)) + S(-1))*sqrt(sqrt(b*x**S(2) + S(1)) + S(1))*Subst(Int(acosh(x)**n/(sqrt(x + S(-1))*sqrt(x + S(1))), x), x, sqrt(b*x**S(2) + S(1)))/(b*x)) rubi.add(rule243) pattern244 = Pattern(Integral(f_**(WC('c', S(1))*asinh(x_*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda n: PositiveIntegerQ(n))) rule244 = ReplacementRule(pattern244, lambda x, b, c, f, a, n : Subst(Int(f**(c*x**n)*Cosh(x), x), x, asinh(a + b*x))/b) rubi.add(rule244) pattern245 = Pattern(Integral(f_**(WC('c', S(1))*acosh(x_*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda n: PositiveIntegerQ(n))) rule245 = ReplacementRule(pattern245, lambda x, b, c, f, a, n : Subst(Int(f**(c*x**n)*sinh(x), x), x, acosh(a + b*x))/b) rubi.add(rule245) pattern246 = Pattern(Integral(f_**(WC('c', S(1))*asinh(x_*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1)))*x_**WC('m', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda n, m: PositiveIntegerQ(m, n))) rule246 = ReplacementRule(pattern246, lambda x, b, m, c, f, a, n : Subst(Int(f**(c*x**n)*(-a/b + sinh(x)/b)**m*Cosh(x), x), x, asinh(a + b*x))/b) rubi.add(rule246) pattern247 = Pattern(Integral(f_**(WC('c', S(1))*acosh(x_*WC('b', S(1)) + WC('a', S(0)))**WC('n', S(1)))*x_**WC('m', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda n, m: PositiveIntegerQ(m, n))) rule247 = ReplacementRule(pattern247, lambda x, b, m, c, f, a, n : Subst(Int(f**(c*x**n)*(-a/b + Cosh(x)/b)**m*sinh(x), x), x, acosh(a + b*x))/b) rubi.add(rule247) pattern248 = Pattern(Integral(asinh(u_), x_), CustomConstraint(lambda x, u: InverseFunctionFreeQ(u, x)), CustomConstraint(lambda x, u: Not(FunctionOfExponentialQ(u, x)))) rule248 = ReplacementRule(pattern248, lambda x, u : x*asinh(u) - Int(SimplifyIntegrand(x*D(u, x)/sqrt(u**S(2) + S(1)), x), x)) rubi.add(rule248) pattern249 = Pattern(Integral(acosh(u_), x_), CustomConstraint(lambda x, u: InverseFunctionFreeQ(u, x)), CustomConstraint(lambda x, u: Not(FunctionOfExponentialQ(u, x)))) rule249 = ReplacementRule(pattern249, lambda x, u : x*acosh(u) - Int(SimplifyIntegrand(x*D(u, x)/(sqrt(u + S(-1))*sqrt(u + S(1))), x), x)) rubi.add(rule249) pattern250 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asinh(u_)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda m: NonzeroQ(m + S(1))), CustomConstraint(lambda x, u: InverseFunctionFreeQ(u, x)), CustomConstraint(lambda x, m, c, d, u: Not(FunctionOfQ((c + d*x)**(m + S(1)), u, x))), CustomConstraint(lambda x, u: Not(FunctionOfExponentialQ(u, x)))) rule250 = ReplacementRule(pattern250, lambda x, b, m, c, a, d, u : -b*Int(SimplifyIntegrand((c + d*x)**(m + S(1))*D(u, x)/sqrt(u**S(2) + S(1)), x), x)/(d*(m + S(1))) + (a + b*asinh(u))*(c + d*x)**(m + S(1))/(d*(m + S(1)))) rubi.add(rule250) pattern251 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acosh(u_)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda m: NonzeroQ(m + S(1))), CustomConstraint(lambda x, u: InverseFunctionFreeQ(u, x)), CustomConstraint(lambda x, m, c, d, u: Not(FunctionOfQ((c + d*x)**(m + S(1)), u, x))), CustomConstraint(lambda x, u: Not(FunctionOfExponentialQ(u, x)))) rule251 = ReplacementRule(pattern251, lambda x, b, m, c, a, d, u : -b*Int(SimplifyIntegrand((c + d*x)**(m + S(1))*D(u, x)/(sqrt(u + S(-1))*sqrt(u + S(1))), x), x)/(d*(m + S(1))) + (a + b*acosh(u))*(c + d*x)**(m + S(1))/(d*(m + S(1)))) rubi.add(rule251) pattern252 = Pattern(Integral(v_*(WC('a', S(0)) + WC('b', S(1))*asinh(u_)), x_), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda x, u: InverseFunctionFreeQ(u, x)), CustomConstraint(lambda v, x: Not(MatchQ(v, Condition((x*Optional(Pattern(d, Blank)) + Optional(Pattern(c, Blank)))**Optional(Pattern(m, Blank)))))), CustomConstraint(lambda a, u, x, b, w: InverseFunctionFreeQ(w, x))) def With252(x, b, v, a, u): w = IntHide(v, x) return -b*Int(SimplifyIntegrand(w*D(u, x)/sqrt(u**S(2) + S(1)), x), x) + Dist(a + b*asinh(u), w, x) rule252 = ReplacementRule(pattern252, lambda x, b, v, a, u : With252(x, b, v, a, u)) rubi.add(rule252) pattern253 = Pattern(Integral(v_*(WC('a', S(0)) + WC('b', S(1))*acosh(u_)), x_), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda x, u: InverseFunctionFreeQ(u, x)), CustomConstraint(lambda v, x: Not(MatchQ(v, Condition((x*Optional(Pattern(d, Blank)) + Optional(Pattern(c, Blank)))**Optional(Pattern(m, Blank)))))), CustomConstraint(lambda a, u, x, b, w: InverseFunctionFreeQ(w, x))) def With253(x, b, v, a, u): w = IntHide(v, x) return -b*Int(SimplifyIntegrand(w*D(u, x)/(sqrt(u + S(-1))*sqrt(u + S(1))), x), x) + Dist(a + b*acosh(u), w, x) rule253 = ReplacementRule(pattern253, lambda x, b, v, a, u : With253(x, b, v, a, u)) rubi.add(rule253) pattern254 = Pattern(Integral(exp(WC('n', S(1))*asinh(u_)), x_), CustomConstraint(lambda n: IntegerQ(n)), CustomConstraint(lambda x, u: PolynomialQ(u, x))) rule254 = ReplacementRule(pattern254, lambda x, u, n : Int((u + sqrt(u**S(2) + S(1)))**n, x)) rubi.add(rule254) pattern255 = Pattern(Integral(x_**WC('m', S(1))*exp(WC('n', S(1))*asinh(u_)), x_), CustomConstraint(lambda m: RationalQ(m)), CustomConstraint(lambda n: IntegerQ(n)), CustomConstraint(lambda x, u: PolynomialQ(u, x))) rule255 = ReplacementRule(pattern255, lambda x, u, n, m : Int(x**m*(u + sqrt(u**S(2) + S(1)))**n, x)) rubi.add(rule255) pattern256 = Pattern(Integral(exp(WC('n', S(1))*acosh(u_)), x_), CustomConstraint(lambda n: IntegerQ(n)), CustomConstraint(lambda x, u: PolynomialQ(u, x))) rule256 = ReplacementRule(pattern256, lambda x, u, n : Int((u + sqrt(u + S(-1))*sqrt(u + S(1)))**n, x)) rubi.add(rule256) pattern257 = Pattern(Integral(x_**WC('m', S(1))*exp(WC('n', S(1))*acosh(u_)), x_), CustomConstraint(lambda m: RationalQ(m)), CustomConstraint(lambda n: IntegerQ(n)), CustomConstraint(lambda x, u: PolynomialQ(u, x))) rule257 = ReplacementRule(pattern257, lambda x, u, n, m : Int(x**m*(u + sqrt(u + S(-1))*sqrt(u + S(1)))**n, x)) rubi.add(rule257) pattern258 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda n: PositiveIntegerQ(n))) rule258 = ReplacementRule(pattern258, lambda x, b, c, a, n : -b*c*n*Int(x*(a + b*atanh(c*x))**(n + S(-1))/(-c**S(2)*x**S(2) + S(1)), x) + x*(a + b*atanh(c*x))**n) rubi.add(rule258) pattern259 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda n: PositiveIntegerQ(n))) rule259 = ReplacementRule(pattern259, lambda x, b, c, a, n : -b*c*n*Int(x*(a + b*acoth(c*x))**(n + S(-1))/(-c**S(2)*x**S(2) + S(1)), x) + x*(a + b*acoth(c*x))**n) rubi.add(rule259) pattern260 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda n: Not(PositiveIntegerQ(n)))) rule260 = ReplacementRule(pattern260, lambda x, b, c, a, n : Int((a + b*atanh(c*x))**n, x)) rubi.add(rule260) pattern261 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda n: Not(PositiveIntegerQ(n)))) rule261 = ReplacementRule(pattern261, lambda x, b, c, a, n : Int((a + b*acoth(c*x))**n, x)) rubi.add(rule261) pattern262 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d**S(2) - e**S(2))), CustomConstraint(lambda n: PositiveIntegerQ(n))) rule262 = ReplacementRule(pattern262, lambda x, b, c, a, d, e, n : b*c*n*Int((a + b*atanh(c*x))**(n + S(-1))*log(S(2)*d/(d + e*x))/(-c**S(2)*x**S(2) + S(1)), x)/e - (a + b*atanh(c*x))**n*log(S(2)*d/(d + e*x))/e) rubi.add(rule262) pattern263 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d**S(2) - e**S(2))), CustomConstraint(lambda n: PositiveIntegerQ(n))) rule263 = ReplacementRule(pattern263, lambda x, b, c, a, d, e, n : b*c*n*Int((a + b*acoth(c*x))**(n + S(-1))*log(S(2)*d/(d + e*x))/(-c**S(2)*x**S(2) + S(1)), x)/e - (a + b*acoth(c*x))**n*log(S(2)*d/(d + e*x))/e) rubi.add(rule263) pattern264 = Pattern(Integral(atanh(x_*WC('c', S(1)))/(d_ + x_*WC('e', S(1))), x_), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: PositiveQ(c*d/e + S(1))), CustomConstraint(lambda c, e, d: NegativeQ(c*d/e + S(-1)))) rule264 = ReplacementRule(pattern264, lambda c, d, e, x : -PolyLog(S(2), Simp(c*(d + e*x)/(c*d - e), x))/(S(2)*e) + PolyLog(S(2), Simp(c*(d + e*x)/(c*d + e), x))/(S(2)*e) - log(d + e*x)*atanh(c*d/e)/e) rubi.add(rule264) pattern265 = Pattern(Integral(atanh(x_*WC('c', S(1)))/(x_*WC('e', S(1)) + WC('d', S(0))), x_), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x))) rule265 = ReplacementRule(pattern265, lambda c, e, d, x : -Int(log(-c*x + S(1))/(d + e*x), x)/S(2) + Int(log(c*x + S(1))/(d + e*x), x)/S(2)) rubi.add(rule265) pattern266 = Pattern(Integral(acoth(x_*WC('c', S(1)))/(x_*WC('e', S(1)) + WC('d', S(0))), x_), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x))) rule266 = ReplacementRule(pattern266, lambda c, e, d, x : -Int(log(S(1) - S(1)/(c*x))/(d + e*x), x)/S(2) + Int(log(S(1) + S(1)/(c*x))/(d + e*x), x)/S(2)) rubi.add(rule266) pattern267 = Pattern(Integral((a_ + WC('b', S(1))*atanh(x_*WC('c', S(1))))/(x_*WC('e', S(1)) + WC('d', S(0))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x))) rule267 = ReplacementRule(pattern267, lambda x, b, c, a, d, e : a*log(RemoveContent(d + e*x, x))/e + b*Int(atanh(c*x)/(d + e*x), x)) rubi.add(rule267) pattern268 = Pattern(Integral((a_ + WC('b', S(1))*acoth(x_*WC('c', S(1))))/(x_*WC('e', S(1)) + WC('d', S(0))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x))) rule268 = ReplacementRule(pattern268, lambda x, b, c, a, d, e : a*log(RemoveContent(d + e*x, x))/e + b*Int(acoth(c*x)/(d + e*x), x)) rubi.add(rule268) pattern269 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda p: NonzeroQ(p + S(1)))) rule269 = ReplacementRule(pattern269, lambda p, x, b, c, a, d, e : -b*c*Int((d + e*x)**(p + S(1))/(-c**S(2)*x**S(2) + S(1)), x)/(e*(p + S(1))) + (a + b*atanh(c*x))*(d + e*x)**(p + S(1))/(e*(p + S(1)))) rubi.add(rule269) pattern270 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda p: NonzeroQ(p + S(1)))) rule270 = ReplacementRule(pattern270, lambda p, x, b, c, a, d, e : -b*c*Int((d + e*x)**(p + S(1))/(-c**S(2)*x**S(2) + S(1)), x)/(e*(p + S(1))) + (a + b*acoth(c*x))*(d + e*x)**(p + S(1))/(e*(p + S(1)))) rubi.add(rule270) pattern271 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**n_/x_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda n: IntegerQ(n)), CustomConstraint(lambda n: Greater(n, S(1)))) rule271 = ReplacementRule(pattern271, lambda x, b, c, a, n : -S(2)*b*c*n*Int((a + b*atanh(c*x))**(n + S(-1))*atanh(S(1) - S(2)/(-c*x + S(1)))/(-c**S(2)*x**S(2) + S(1)), x) + S(2)*(a + b*atanh(c*x))**n*atanh(S(1) - S(2)/(-c*x + S(1)))) rubi.add(rule271) pattern272 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**n_/x_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda n: IntegerQ(n)), CustomConstraint(lambda n: Greater(n, S(1)))) rule272 = ReplacementRule(pattern272, lambda x, b, c, a, n : -S(2)*b*c*n*Int((a + b*acoth(c*x))**(n + S(-1))*acoth(S(1) - S(2)/(-c*x + S(1)))/(-c**S(2)*x**S(2) + S(1)), x) + S(2)*(a + b*acoth(c*x))**n*acoth(S(1) - S(2)/(-c*x + S(1)))) rubi.add(rule272) pattern273 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n: IntegerQ(n)), CustomConstraint(lambda n: Greater(n, S(1))), CustomConstraint(lambda m: NonzeroQ(m + S(1)))) rule273 = ReplacementRule(pattern273, lambda x, b, m, c, a, n : -b*c*n*Int(x**(m + S(1))*(a + b*atanh(c*x))**(n + S(-1))/(-c**S(2)*x**S(2) + S(1)), x)/(m + S(1)) + x**(m + S(1))*(a + b*atanh(c*x))**n/(m + S(1))) rubi.add(rule273) pattern274 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n: IntegerQ(n)), CustomConstraint(lambda n: Greater(n, S(1))), CustomConstraint(lambda m: NonzeroQ(m + S(1)))) rule274 = ReplacementRule(pattern274, lambda x, b, m, c, a, n : -b*c*n*Int(x**(m + S(1))*(a + b*acoth(c*x))**(n + S(-1))/(-c**S(2)*x**S(2) + S(1)), x)/(m + S(1)) + x**(m + S(1))*(a + b*acoth(c*x))**n/(m + S(1))) rubi.add(rule274) pattern275 = Pattern(Integral((d_ + x_*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda p, n: PositiveIntegerQ(n, p))) rule275 = ReplacementRule(pattern275, lambda p, x, b, c, a, d, e, n : Int(ExpandIntegrand((a + b*atanh(c*x))**n*(d + e*x)**p, x), x)) rubi.add(rule275) pattern276 = Pattern(Integral((d_ + x_*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda p, n: PositiveIntegerQ(n, p))) rule276 = ReplacementRule(pattern276, lambda p, x, b, c, a, d, e, n : Int(ExpandIntegrand((a + b*acoth(c*x))**n*(d + e*x)**p, x), x)) rubi.add(rule276) pattern277 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda n: Not(PositiveIntegerQ(n)))) rule277 = ReplacementRule(pattern277, lambda p, x, b, c, a, d, e, n : Int((a + b*atanh(c*x))**n*(d + e*x)**p, x)) rubi.add(rule277) pattern278 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda n: Not(PositiveIntegerQ(n)))) rule278 = ReplacementRule(pattern278, lambda p, x, b, c, a, d, e, n : Int((a + b*acoth(c*x))**n*(d + e*x)**p, x)) rubi.add(rule278) pattern279 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d**S(2) - e**S(2))), CustomConstraint(lambda n: PositiveIntegerQ(n)), CustomConstraint(lambda m: RationalQ(m)), CustomConstraint(lambda m: Greater(m, S(0)))) rule279 = ReplacementRule(pattern279, lambda x, b, m, c, a, d, e, n : -d*Int(x**(m + S(-1))*(a + b*atanh(c*x))**n/(d + e*x), x)/e + Int(x**(m + S(-1))*(a + b*atanh(c*x))**n, x)/e) rubi.add(rule279) pattern280 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d**S(2) - e**S(2))), CustomConstraint(lambda n: PositiveIntegerQ(n)), CustomConstraint(lambda m: RationalQ(m)), CustomConstraint(lambda m: Greater(m, S(0)))) rule280 = ReplacementRule(pattern280, lambda x, b, m, c, a, d, e, n : -d*Int(x**(m + S(-1))*(a + b*acoth(c*x))**n/(d + e*x), x)/e + Int(x**(m + S(-1))*(a + b*acoth(c*x))**n, x)/e) rubi.add(rule280) pattern281 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))/(x_*(d_ + x_*WC('e', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d**S(2) - e**S(2))), CustomConstraint(lambda n: PositiveIntegerQ(n))) rule281 = ReplacementRule(pattern281, lambda x, b, c, a, d, e, n : -b*c*n*Int((a + b*atanh(c*x))**(n + S(-1))*log(S(2)*e*x/(d + e*x))/(-c**S(2)*x**S(2) + S(1)), x)/d + (a + b*atanh(c*x))**n*log(S(2)*e*x/(d + e*x))/d) rubi.add(rule281) pattern282 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))/(x_*(d_ + x_*WC('e', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d**S(2) - e**S(2))), CustomConstraint(lambda n: PositiveIntegerQ(n))) rule282 = ReplacementRule(pattern282, lambda x, b, c, a, d, e, n : -b*c*n*Int((a + b*acoth(c*x))**(n + S(-1))*log(S(2)*e*x/(d + e*x))/(-c**S(2)*x**S(2) + S(1)), x)/d + (a + b*acoth(c*x))**n*log(S(2)*e*x/(d + e*x))/d) rubi.add(rule282) pattern283 = Pattern(Integral(x_**m_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d**S(2) - e**S(2))), CustomConstraint(lambda n: PositiveIntegerQ(n)), CustomConstraint(lambda m: RationalQ(m)), CustomConstraint(lambda m: Less(m, S(-1)))) rule283 = ReplacementRule(pattern283, lambda x, b, m, c, a, d, e, n : -e*Int(x**(m + S(1))*(a + b*atanh(c*x))**n/(d + e*x), x)/d + Int(x**m*(a + b*atanh(c*x))**n, x)/d) rubi.add(rule283) pattern284 = Pattern(Integral(x_**m_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d**S(2) - e**S(2))), CustomConstraint(lambda n: PositiveIntegerQ(n)), CustomConstraint(lambda m: RationalQ(m)), CustomConstraint(lambda m: Less(m, S(-1)))) rule284 = ReplacementRule(pattern284, lambda x, b, m, c, a, d, e, n : -e*Int(x**(m + S(1))*(a + b*acoth(c*x))**n/(d + e*x), x)/d + Int(x**m*(a + b*acoth(c*x))**n, x)/d) rubi.add(rule284) pattern285 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda p: IntegerQ(p)), CustomConstraint(lambda n: PositiveIntegerQ(n)), CustomConstraint(lambda a, p, m: IntegerQ(m) | NonzeroQ(a) | Greater(p, S(0)))) rule285 = ReplacementRule(pattern285, lambda p, x, b, m, c, a, d, e, n : Int(ExpandIntegrand(x**m*(a + b*atanh(c*x))**n*(d + e*x)**p, x), x)) rubi.add(rule285) pattern286 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda p: IntegerQ(p)), CustomConstraint(lambda n: PositiveIntegerQ(n)), CustomConstraint(lambda a, p, m: IntegerQ(m) | NonzeroQ(a) | Greater(p, S(0)))) rule286 = ReplacementRule(pattern286, lambda p, x, b, m, c, a, d, e, n : Int(ExpandIntegrand(x**m*(a + b*acoth(c*x))**n*(d + e*x)**p, x), x)) rubi.add(rule286) pattern287 = Pattern(Integral(x_**WC('m', S(1))*(x_*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x))) rule287 = ReplacementRule(pattern287, lambda p, x, b, m, c, a, d, e, n : Int(x**m*(a + b*atanh(c*x))**n*(d + e*x)**p, x)) rubi.add(rule287) pattern288 = Pattern(Integral(x_**WC('m', S(1))*(x_*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x))) rule288 = ReplacementRule(pattern288, lambda p, x, b, m, c, a, d, e, n : Int(x**m*(a + b*acoth(c*x))**n*(d + e*x)**p, x)) rubi.add(rule288) pattern289 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda p: RationalQ(p)), CustomConstraint(lambda p: Greater(p, S(0)))) rule289 = ReplacementRule(pattern289, lambda p, x, b, c, a, d, e : b*(d + e*x**S(2))**p/(S(2)*c*p*(S(2)*p + S(1))) + S(2)*d*p*Int((a + b*atanh(c*x))*(d + e*x**S(2))**(p + S(-1)), x)/(S(2)*p + S(1)) + x*(a + b*atanh(c*x))*(d + e*x**S(2))**p/(S(2)*p + S(1))) rubi.add(rule289) pattern290 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda p: RationalQ(p)), CustomConstraint(lambda p: Greater(p, S(0)))) rule290 = ReplacementRule(pattern290, lambda p, x, b, c, a, d, e : b*(d + e*x**S(2))**p/(S(2)*c*p*(S(2)*p + S(1))) + S(2)*d*p*Int((a + b*acoth(c*x))*(d + e*x**S(2))**(p + S(-1)), x)/(S(2)*p + S(1)) + x*(a + b*acoth(c*x))*(d + e*x**S(2))**p/(S(2)*p + S(1))) rubi.add(rule290) pattern291 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda p, n: RationalQ(n, p)), CustomConstraint(lambda p: Greater(p, S(0))), CustomConstraint(lambda n: Greater(n, S(1)))) rule291 = ReplacementRule(pattern291, lambda p, x, b, c, a, d, e, n : -b**S(2)*d*n*(n + S(-1))*Int((a + b*atanh(c*x))**(n + S(-2))*(d + e*x**S(2))**(p + S(-1)), x)/(S(2)*p*(S(2)*p + S(1))) + b*n*(a + b*atanh(c*x))**(n + S(-1))*(d + e*x**S(2))**p/(S(2)*c*p*(S(2)*p + S(1))) + S(2)*d*p*Int((a + b*atanh(c*x))**n*(d + e*x**S(2))**(p + S(-1)), x)/(S(2)*p + S(1)) + x*(a + b*atanh(c*x))**n*(d + e*x**S(2))**p/(S(2)*p + S(1))) rubi.add(rule291) pattern292 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda p, n: RationalQ(n, p)), CustomConstraint(lambda p: Greater(p, S(0))), CustomConstraint(lambda n: Greater(n, S(1)))) rule292 = ReplacementRule(pattern292, lambda p, x, b, c, a, d, e, n : -b**S(2)*d*n*(n + S(-1))*Int((a + b*acoth(c*x))**(n + S(-2))*(d + e*x**S(2))**(p + S(-1)), x)/(S(2)*p*(S(2)*p + S(1))) + b*n*(a + b*acoth(c*x))**(n + S(-1))*(d + e*x**S(2))**p/(S(2)*c*p*(S(2)*p + S(1))) + S(2)*d*p*Int((a + b*acoth(c*x))**n*(d + e*x**S(2))**(p + S(-1)), x)/(S(2)*p + S(1)) + x*(a + b*acoth(c*x))**n*(d + e*x**S(2))**p/(S(2)*p + S(1))) rubi.add(rule292) pattern293 = Pattern(Integral(S(1)/((d_ + x_**S(2)*WC('e', S(1)))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e))) rule293 = ReplacementRule(pattern293, lambda x, b, c, a, d, e : log(RemoveContent(a + b*atanh(c*x), x))/(b*c*d)) rubi.add(rule293) pattern294 = Pattern(Integral(S(1)/((d_ + x_**S(2)*WC('e', S(1)))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e))) rule294 = ReplacementRule(pattern294, lambda x, b, c, a, d, e : log(RemoveContent(a + b*acoth(c*x), x))/(b*c*d)) rubi.add(rule294) pattern295 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: NonzeroQ(n + S(1)))) rule295 = ReplacementRule(pattern295, lambda x, b, c, a, d, e, n : (a + b*atanh(c*x))**(n + S(1))/(b*c*d*(n + S(1)))) rubi.add(rule295) pattern296 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: NonzeroQ(n + S(1)))) rule296 = ReplacementRule(pattern296, lambda x, b, c, a, d, e, n : (a + b*acoth(c*x))**(n + S(1))/(b*c*d*(n + S(1)))) rubi.add(rule296) pattern297 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda d: PositiveQ(d))) rule297 = ReplacementRule(pattern297, lambda x, b, c, a, d, e : -ImaginaryI*b*PolyLog(S(2), -ImaginaryI*sqrt(-c*x + S(1))/sqrt(c*x + S(1)))/(c*sqrt(d)) + ImaginaryI*b*PolyLog(S(2), ImaginaryI*sqrt(-c*x + S(1))/sqrt(c*x + S(1)))/(c*sqrt(d)) - S(2)*(a + b*atanh(c*x))*ArcTan(sqrt(-c*x + S(1))/sqrt(c*x + S(1)))/(c*sqrt(d))) rubi.add(rule297) pattern298 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda d: PositiveQ(d))) rule298 = ReplacementRule(pattern298, lambda x, b, c, a, d, e : -ImaginaryI*b*PolyLog(S(2), -ImaginaryI*sqrt(-c*x + S(1))/sqrt(c*x + S(1)))/(c*sqrt(d)) + ImaginaryI*b*PolyLog(S(2), ImaginaryI*sqrt(-c*x + S(1))/sqrt(c*x + S(1)))/(c*sqrt(d)) - S(2)*(a + b*acoth(c*x))*ArcTan(sqrt(-c*x + S(1))/sqrt(c*x + S(1)))/(c*sqrt(d))) rubi.add(rule298) pattern299 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: PositiveIntegerQ(n)), CustomConstraint(lambda d: PositiveQ(d))) rule299 = ReplacementRule(pattern299, lambda x, b, c, a, d, e, n : Subst(Int((a + b*x)**n*sech(x), x), x, atanh(c*x))/(c*sqrt(d))) rubi.add(rule299) pattern300 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: PositiveIntegerQ(n)), CustomConstraint(lambda d: PositiveQ(d))) rule300 = ReplacementRule(pattern300, lambda x, b, c, a, d, e, n : -x*sqrt(S(1) - S(1)/(c**S(2)*x**S(2)))*Subst(Int((a + b*x)**n*csch(x), x), x, acoth(c*x))/sqrt(d + e*x**S(2))) rubi.add(rule300) pattern301 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: PositiveIntegerQ(n)), CustomConstraint(lambda d: Not(PositiveQ(d)))) rule301 = ReplacementRule(pattern301, lambda x, b, c, a, d, e, n : sqrt(-c**S(2)*x**S(2) + S(1))*Int((a + b*atanh(c*x))**n/sqrt(-c**S(2)*x**S(2) + S(1)), x)/sqrt(d + e*x**S(2))) rubi.add(rule301) pattern302 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: PositiveIntegerQ(n)), CustomConstraint(lambda d: Not(PositiveQ(d)))) rule302 = ReplacementRule(pattern302, lambda x, b, c, a, d, e, n : sqrt(-c**S(2)*x**S(2) + S(1))*Int((a + b*acoth(c*x))**n/sqrt(-c**S(2)*x**S(2) + S(1)), x)/sqrt(d + e*x**S(2))) rubi.add(rule302) pattern303 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1)))**S(2), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(0)))) rule303 = ReplacementRule(pattern303, lambda x, b, c, a, d, e, n : -b*c*n*Int(x*(a + b*atanh(c*x))**(n + S(-1))/(d + e*x**S(2))**S(2), x)/S(2) + x*(a + b*atanh(c*x))**n/(S(2)*d*(d + e*x**S(2))) + (a + b*atanh(c*x))**(n + S(1))/(S(2)*b*c*d**S(2)*(n + S(1)))) rubi.add(rule303) pattern304 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1)))**S(2), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(0)))) rule304 = ReplacementRule(pattern304, lambda x, b, c, a, d, e, n : -b*c*n*Int(x*(a + b*acoth(c*x))**(n + S(-1))/(d + e*x**S(2))**S(2), x)/S(2) + x*(a + b*acoth(c*x))**n/(S(2)*d*(d + e*x**S(2))) + (a + b*acoth(c*x))**(n + S(1))/(S(2)*b*c*d**S(2)*(n + S(1)))) rubi.add(rule304) pattern305 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))/(d_ + x_**S(2)*WC('e', S(1)))**(S(3)/2), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e))) rule305 = ReplacementRule(pattern305, lambda x, b, c, a, d, e : -b/(c*d*sqrt(d + e*x**S(2))) + x*(a + b*atanh(c*x))/(d*sqrt(d + e*x**S(2)))) rubi.add(rule305) pattern306 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))/(d_ + x_**S(2)*WC('e', S(1)))**(S(3)/2), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e))) rule306 = ReplacementRule(pattern306, lambda x, b, c, a, d, e : -b/(c*d*sqrt(d + e*x**S(2))) + x*(a + b*acoth(c*x))/(d*sqrt(d + e*x**S(2)))) rubi.add(rule306) pattern307 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda p: RationalQ(p)), CustomConstraint(lambda p: Less(p, S(-1))), CustomConstraint(lambda p: Unequal(p, S(-3)/2))) rule307 = ReplacementRule(pattern307, lambda p, x, b, c, a, d, e : -b*(d + e*x**S(2))**(p + S(1))/(S(4)*c*d*(p + S(1))**S(2)) - x*(a + b*atanh(c*x))*(d + e*x**S(2))**(p + S(1))/(S(2)*d*(p + S(1))) + (S(2)*p + S(3))*Int((a + b*atanh(c*x))*(d + e*x**S(2))**(p + S(1)), x)/(S(2)*d*(p + S(1)))) rubi.add(rule307) pattern308 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda p: RationalQ(p)), CustomConstraint(lambda p: Less(p, S(-1))), CustomConstraint(lambda p: Unequal(p, S(-3)/2))) rule308 = ReplacementRule(pattern308, lambda p, x, b, c, a, d, e : -b*(d + e*x**S(2))**(p + S(1))/(S(4)*c*d*(p + S(1))**S(2)) - x*(a + b*acoth(c*x))*(d + e*x**S(2))**(p + S(1))/(S(2)*d*(p + S(1))) + (S(2)*p + S(3))*Int((a + b*acoth(c*x))*(d + e*x**S(2))**(p + S(1)), x)/(S(2)*d*(p + S(1)))) rubi.add(rule308) pattern309 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**n_/(d_ + x_**S(2)*WC('e', S(1)))**(S(3)/2), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(1)))) rule309 = ReplacementRule(pattern309, lambda x, b, c, a, d, e, n : b**S(2)*n*(n + S(-1))*Int((a + b*atanh(c*x))**(n + S(-2))/(d + e*x**S(2))**(S(3)/2), x) - b*n*(a + b*atanh(c*x))**(n + S(-1))/(c*d*sqrt(d + e*x**S(2))) + x*(a + b*atanh(c*x))**n/(d*sqrt(d + e*x**S(2)))) rubi.add(rule309) pattern310 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**n_/(d_ + x_**S(2)*WC('e', S(1)))**(S(3)/2), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(1)))) rule310 = ReplacementRule(pattern310, lambda x, b, c, a, d, e, n : b**S(2)*n*(n + S(-1))*Int((a + b*acoth(c*x))**(n + S(-2))/(d + e*x**S(2))**(S(3)/2), x) - b*n*(a + b*acoth(c*x))**(n + S(-1))/(c*d*sqrt(d + e*x**S(2))) + x*(a + b*acoth(c*x))**n/(d*sqrt(d + e*x**S(2)))) rubi.add(rule310) pattern311 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda p, n: RationalQ(n, p)), CustomConstraint(lambda p: Less(p, S(-1))), CustomConstraint(lambda n: Greater(n, S(1))), CustomConstraint(lambda p: Unequal(p, S(-3)/2))) rule311 = ReplacementRule(pattern311, lambda p, x, b, c, a, d, e, n : b**S(2)*n*(n + S(-1))*Int((a + b*atanh(c*x))**(n + S(-2))*(d + e*x**S(2))**p, x)/(S(4)*(p + S(1))**S(2)) - b*n*(a + b*atanh(c*x))**(n + S(-1))*(d + e*x**S(2))**(p + S(1))/(S(4)*c*d*(p + S(1))**S(2)) - x*(a + b*atanh(c*x))**n*(d + e*x**S(2))**(p + S(1))/(S(2)*d*(p + S(1))) + (S(2)*p + S(3))*Int((a + b*atanh(c*x))**n*(d + e*x**S(2))**(p + S(1)), x)/(S(2)*d*(p + S(1)))) rubi.add(rule311) pattern312 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda p, n: RationalQ(n, p)), CustomConstraint(lambda p: Less(p, S(-1))), CustomConstraint(lambda n: Greater(n, S(1))), CustomConstraint(lambda p: Unequal(p, S(-3)/2))) rule312 = ReplacementRule(pattern312, lambda p, x, b, c, a, d, e, n : b**S(2)*n*(n + S(-1))*Int((a + b*acoth(c*x))**(n + S(-2))*(d + e*x**S(2))**p, x)/(S(4)*(p + S(1))**S(2)) - b*n*(a + b*acoth(c*x))**(n + S(-1))*(d + e*x**S(2))**(p + S(1))/(S(4)*c*d*(p + S(1))**S(2)) - x*(a + b*acoth(c*x))**n*(d + e*x**S(2))**(p + S(1))/(S(2)*d*(p + S(1))) + (S(2)*p + S(3))*Int((a + b*acoth(c*x))**n*(d + e*x**S(2))**(p + S(1)), x)/(S(2)*d*(p + S(1)))) rubi.add(rule312) pattern313 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda p, n: RationalQ(n, p)), CustomConstraint(lambda p: Less(p, S(-1))), CustomConstraint(lambda n: Less(n, S(-1)))) rule313 = ReplacementRule(pattern313, lambda p, x, b, c, a, d, e, n : S(2)*c*(p + S(1))*Int(x*(a + b*atanh(c*x))**(n + S(1))*(d + e*x**S(2))**p, x)/(b*(n + S(1))) + (a + b*atanh(c*x))**(n + S(1))*(d + e*x**S(2))**(p + S(1))/(b*c*d*(n + S(1)))) rubi.add(rule313) pattern314 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda p, n: RationalQ(n, p)), CustomConstraint(lambda p: Less(p, S(-1))), CustomConstraint(lambda n: Less(n, S(-1)))) rule314 = ReplacementRule(pattern314, lambda p, x, b, c, a, d, e, n : S(2)*c*(p + S(1))*Int(x*(a + b*acoth(c*x))**(n + S(1))*(d + e*x**S(2))**p, x)/(b*(n + S(1))) + (a + b*acoth(c*x))**(n + S(1))*(d + e*x**S(2))**(p + S(1))/(b*c*d*(n + S(1)))) rubi.add(rule314) pattern315 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda p: NegativeIntegerQ(S(2)*p + S(2))), CustomConstraint(lambda d, p: IntegerQ(p) | PositiveQ(d))) rule315 = ReplacementRule(pattern315, lambda p, x, b, c, a, d, e, n : d**p*Subst(Int((a + b*x)**n*Cosh(x)**(-S(2)*p + S(-2)), x), x, atanh(c*x))/c) rubi.add(rule315) pattern316 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda p: NegativeIntegerQ(S(2)*p + S(2))), CustomConstraint(lambda d, p: Not(IntegerQ(p) | PositiveQ(d)))) rule316 = ReplacementRule(pattern316, lambda p, x, b, c, a, d, e, n : d**(p + S(1)/2)*sqrt(-c**S(2)*x**S(2) + S(1))*Int((a + b*atanh(c*x))**n*(-c**S(2)*x**S(2) + S(1))**p, x)/sqrt(d + e*x**S(2))) rubi.add(rule316) pattern317 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda p: NegativeIntegerQ(S(2)*p + S(2))), CustomConstraint(lambda p: IntegerQ(p))) rule317 = ReplacementRule(pattern317, lambda p, x, b, c, a, d, e, n : -(-d)**p*Subst(Int((a + b*x)**n*sinh(x)**(-S(2)*p + S(-2)), x), x, acoth(c*x))/c) rubi.add(rule317) pattern318 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda p: NegativeIntegerQ(S(2)*p + S(2))), CustomConstraint(lambda p: Not(IntegerQ(p)))) rule318 = ReplacementRule(pattern318, lambda p, x, b, c, a, d, e, n : -x*(-d)**(p + S(1)/2)*sqrt((c**S(2)*x**S(2) + S(-1))/(c**S(2)*x**S(2)))*Subst(Int((a + b*x)**n*sinh(x)**(-S(2)*p + S(-2)), x), x, acoth(c*x))/sqrt(d + e*x**S(2))) rubi.add(rule318) pattern319 = Pattern(Integral(atanh(x_*WC('c', S(1)))/(x_**S(2)*WC('e', S(1)) + WC('d', S(0))), x_), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x))) rule319 = ReplacementRule(pattern319, lambda c, e, d, x : -Int(log(-c*x + S(1))/(d + e*x**S(2)), x)/S(2) + Int(log(c*x + S(1))/(d + e*x**S(2)), x)/S(2)) rubi.add(rule319) pattern320 = Pattern(Integral(acoth(x_*WC('c', S(1)))/(x_**S(2)*WC('e', S(1)) + WC('d', S(0))), x_), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x))) rule320 = ReplacementRule(pattern320, lambda c, e, d, x : -Int(log(S(1) - S(1)/(c*x))/(d + e*x**S(2)), x)/S(2) + Int(log(S(1) + S(1)/(c*x))/(d + e*x**S(2)), x)/S(2)) rubi.add(rule320) pattern321 = Pattern(Integral((a_ + WC('b', S(1))*atanh(x_*WC('c', S(1))))/(x_**S(2)*WC('e', S(1)) + WC('d', S(0))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x))) rule321 = ReplacementRule(pattern321, lambda x, b, c, a, d, e : a*Int(1/(d + e*x**S(2)), x) + b*Int(atanh(c*x)/(d + e*x**S(2)), x)) rubi.add(rule321) pattern322 = Pattern(Integral((a_ + WC('b', S(1))*acoth(x_*WC('c', S(1))))/(x_**S(2)*WC('e', S(1)) + WC('d', S(0))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x))) rule322 = ReplacementRule(pattern322, lambda x, b, c, a, d, e : a*Int(1/(d + e*x**S(2)), x) + b*Int(acoth(c*x)/(d + e*x**S(2)), x)) rubi.add(rule322) pattern323 = Pattern(Integral((x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda p: IntegerQ(p) | NegativeIntegerQ(p + S(1)/2)), ) def With323(p, x, b, c, a, d, e): u = IntHide((d + e*x**S(2))**p, x) return -b*c*Int(ExpandIntegrand(u/(-c**S(2)*x**S(2) + S(1)), x), x) + Dist(a + b*atanh(c*x), u, x) rule323 = ReplacementRule(pattern323, lambda p, x, b, c, a, d, e : With323(p, x, b, c, a, d, e)) rubi.add(rule323) pattern324 = Pattern(Integral((x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda p: IntegerQ(p) | NegativeIntegerQ(p + S(1)/2)), ) def With324(p, x, b, c, a, d, e): u = IntHide((d + e*x**S(2))**p, x) return -b*c*Int(ExpandIntegrand(u/(-c**S(2)*x**S(2) + S(1)), x), x) + Dist(a + b*acoth(c*x), u, x) rule324 = ReplacementRule(pattern324, lambda p, x, b, c, a, d, e : With324(p, x, b, c, a, d, e)) rubi.add(rule324) pattern325 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda p: IntegerQ(p)), CustomConstraint(lambda n: PositiveIntegerQ(n))) rule325 = ReplacementRule(pattern325, lambda p, x, b, c, a, d, e, n : Int(ExpandIntegrand((a + b*atanh(c*x))**n*(d + e*x**S(2))**p, x), x)) rubi.add(rule325) pattern326 = Pattern(Integral((d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda p: IntegerQ(p)), CustomConstraint(lambda n: PositiveIntegerQ(n))) rule326 = ReplacementRule(pattern326, lambda p, x, b, c, a, d, e, n : Int(ExpandIntegrand((a + b*acoth(c*x))**n*(d + e*x**S(2))**p, x), x)) rubi.add(rule326) pattern327 = Pattern(Integral((x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x))) rule327 = ReplacementRule(pattern327, lambda p, x, b, c, a, d, e, n : Int((a + b*atanh(c*x))**n*(d + e*x**S(2))**p, x)) rubi.add(rule327) pattern328 = Pattern(Integral((x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x))) rule328 = ReplacementRule(pattern328, lambda p, x, b, c, a, d, e, n : Int((a + b*acoth(c*x))**n*(d + e*x**S(2))**p, x)) rubi.add(rule328) pattern329 = Pattern(Integral(x_**m_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, m: RationalQ(m, n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda m: Greater(m, S(1)))) rule329 = ReplacementRule(pattern329, lambda x, b, m, c, a, d, e, n : -d*Int(x**(m + S(-2))*(a + b*atanh(c*x))**n/(d + e*x**S(2)), x)/e + Int(x**(m + S(-2))*(a + b*atanh(c*x))**n, x)/e) rubi.add(rule329) pattern330 = Pattern(Integral(x_**m_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, m: RationalQ(m, n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda m: Greater(m, S(1)))) rule330 = ReplacementRule(pattern330, lambda x, b, m, c, a, d, e, n : -d*Int(x**(m + S(-2))*(a + b*acoth(c*x))**n/(d + e*x**S(2)), x)/e + Int(x**(m + S(-2))*(a + b*acoth(c*x))**n, x)/e) rubi.add(rule330) pattern331 = Pattern(Integral(x_**m_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, m: RationalQ(m, n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda m: Less(m, S(-1)))) rule331 = ReplacementRule(pattern331, lambda x, b, m, c, a, d, e, n : -e*Int(x**(m + S(2))*(a + b*atanh(c*x))**n/(d + e*x**S(2)), x)/d + Int(x**m*(a + b*atanh(c*x))**n, x)/d) rubi.add(rule331) pattern332 = Pattern(Integral(x_**m_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, m: RationalQ(m, n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda m: Less(m, S(-1)))) rule332 = ReplacementRule(pattern332, lambda x, b, m, c, a, d, e, n : -e*Int(x**(m + S(2))*(a + b*acoth(c*x))**n/(d + e*x**S(2)), x)/d + Int(x**m*(a + b*acoth(c*x))**n, x)/d) rubi.add(rule332) pattern333 = Pattern(Integral(x_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: PositiveIntegerQ(n))) rule333 = ReplacementRule(pattern333, lambda x, b, c, a, d, e, n : Int((a + b*atanh(c*x))**n/(-c*x + S(1)), x)/(c*d) + (a + b*atanh(c*x))**(n + S(1))/(b*e*(n + S(1)))) rubi.add(rule333) pattern334 = Pattern(Integral(x_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: PositiveIntegerQ(n))) rule334 = ReplacementRule(pattern334, lambda x, b, c, a, d, e, n : Int((a + b*acoth(c*x))**n/(-c*x + S(1)), x)/(c*d) + (a + b*acoth(c*x))**(n + S(1))/(b*e*(n + S(1)))) rubi.add(rule334) pattern335 = Pattern(Integral(x_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**n_/(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: Not(PositiveIntegerQ(n))), CustomConstraint(lambda n: NonzeroQ(n + S(1)))) rule335 = ReplacementRule(pattern335, lambda x, b, c, a, d, e, n : x*(a + b*atanh(c*x))**(n + S(1))/(b*c*d*(n + S(1))) - Int((a + b*atanh(c*x))**(n + S(1)), x)/(b*c*d*(n + S(1)))) rubi.add(rule335) pattern336 = Pattern(Integral(x_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**n_/(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: Not(PositiveIntegerQ(n))), CustomConstraint(lambda n: NonzeroQ(n + S(1)))) rule336 = ReplacementRule(pattern336, lambda x, b, c, a, d, e, n : -x*(a + b*acoth(c*x))**(n + S(1))/(b*c*d*(n + S(1))) - Int((a + b*acoth(c*x))**(n + S(1)), x)/(b*c*d*(n + S(1)))) rubi.add(rule336) pattern337 = Pattern(Integral(x_**m_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n, m: RationalQ(m, n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda m: Greater(m, S(1)))) rule337 = ReplacementRule(pattern337, lambda x, b, m, c, a, d, e, n : -d*Int(x**(m + S(-2))*(a + b*atanh(c*x))**n/(d + e*x**S(2)), x)/e + Int(x**(m + S(-2))*(a + b*atanh(c*x))**n, x)/e) rubi.add(rule337) pattern338 = Pattern(Integral(x_**m_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n, m: RationalQ(m, n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda m: Greater(m, S(1)))) rule338 = ReplacementRule(pattern338, lambda x, b, m, c, a, d, e, n : -d*Int(x**(m + S(-2))*(a + b*acoth(c*x))**n/(d + e*x**S(2)), x)/e + Int(x**(m + S(-2))*(a + b*acoth(c*x))**n, x)/e) rubi.add(rule338) pattern339 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))/(x_*(d_ + x_**S(2)*WC('e', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(0)))) rule339 = ReplacementRule(pattern339, lambda x, b, c, a, d, e, n : Int((a + b*atanh(c*x))**n/(x*(c*x + S(1))), x)/d + (a + b*atanh(c*x))**(n + S(1))/(b*d*(n + S(1)))) rubi.add(rule339) pattern340 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))/(x_*(d_ + x_**S(2)*WC('e', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(0)))) rule340 = ReplacementRule(pattern340, lambda x, b, c, a, d, e, n : Int((a + b*acoth(c*x))**n/(x*(c*x + S(1))), x)/d + (a + b*acoth(c*x))**(n + S(1))/(b*d*(n + S(1)))) rubi.add(rule340) pattern341 = Pattern(Integral(x_**m_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n, m: RationalQ(m, n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda m: Less(m, S(-1)))) rule341 = ReplacementRule(pattern341, lambda x, b, m, c, a, d, e, n : -e*Int(x**(m + S(2))*(a + b*atanh(c*x))**n/(d + e*x**S(2)), x)/d + Int(x**m*(a + b*atanh(c*x))**n, x)/d) rubi.add(rule341) pattern342 = Pattern(Integral(x_**m_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n, m: RationalQ(m, n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda m: Less(m, S(-1)))) rule342 = ReplacementRule(pattern342, lambda x, b, m, c, a, d, e, n : -e*Int(x**(m + S(2))*(a + b*acoth(c*x))**n/(d + e*x**S(2)), x)/d + Int(x**m*(a + b*acoth(c*x))**n, x)/d) rubi.add(rule342) pattern343 = Pattern(Integral(x_**m_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**n_/(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Less(n, S(-1)))) rule343 = ReplacementRule(pattern343, lambda x, b, m, c, a, d, e, n : -m*Int(x**(m + S(-1))*(a + b*atanh(c*x))**(n + S(1)), x)/(b*c*d*(n + S(1))) + x**m*(a + b*atanh(c*x))**(n + S(1))/(b*c*d*(n + S(1)))) rubi.add(rule343) pattern344 = Pattern(Integral(x_**m_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**n_/(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Less(n, S(-1)))) rule344 = ReplacementRule(pattern344, lambda x, b, m, c, a, d, e, n : -m*Int(x**(m + S(-1))*(a + b*acoth(c*x))**(n + S(1)), x)/(b*c*d*(n + S(1))) + x**m*(a + b*acoth(c*x))**(n + S(1))/(b*c*d*(n + S(1)))) rubi.add(rule344) pattern345 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))/(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda m: IntegerQ(m)), CustomConstraint(lambda a, m: Not(NonzeroQ(a) & Equal(m, S(1))))) rule345 = ReplacementRule(pattern345, lambda x, b, m, c, a, d, e : Int(ExpandIntegrand(a + b*atanh(c*x), x**m/(d + e*x**S(2)), x), x)) rubi.add(rule345) pattern346 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))/(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda m: IntegerQ(m)), CustomConstraint(lambda a, m: Not(NonzeroQ(a) & Equal(m, S(1))))) rule346 = ReplacementRule(pattern346, lambda x, b, m, c, a, d, e : Int(ExpandIntegrand(a + b*acoth(c*x), x**m/(d + e*x**S(2)), x), x)) rubi.add(rule346) pattern347 = Pattern(Integral(x_*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda p: NonzeroQ(p + S(1)))) rule347 = ReplacementRule(pattern347, lambda p, x, b, c, a, d, e, n : b*n*Int((a + b*atanh(c*x))**(n + S(-1))*(d + e*x**S(2))**p, x)/(S(2)*c*(p + S(1))) + (a + b*atanh(c*x))**n*(d + e*x**S(2))**(p + S(1))/(S(2)*e*(p + S(1)))) rubi.add(rule347) pattern348 = Pattern(Integral(x_*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda p: NonzeroQ(p + S(1)))) rule348 = ReplacementRule(pattern348, lambda p, x, b, c, a, d, e, n : b*n*Int((a + b*acoth(c*x))**(n + S(-1))*(d + e*x**S(2))**p, x)/(S(2)*c*(p + S(1))) + (a + b*acoth(c*x))**n*(d + e*x**S(2))**(p + S(1))/(S(2)*e*(p + S(1)))) rubi.add(rule348) pattern349 = Pattern(Integral(x_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**n_/(d_ + x_**S(2)*WC('e', S(1)))**S(2), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Less(n, S(-1))), CustomConstraint(lambda n: Unequal(n, S(-2)))) rule349 = ReplacementRule(pattern349, lambda x, b, c, a, d, e, n : x*(a + b*atanh(c*x))**(n + S(1))/(b*c*d*(d + e*x**S(2))*(n + S(1))) + S(4)*Int(x*(a + b*atanh(c*x))**(n + S(2))/(d + e*x**S(2))**S(2), x)/(b**S(2)*(n + S(1))*(n + S(2))) + (a + b*atanh(c*x))**(n + S(2))*(c**S(2)*x**S(2) + S(1))/(b**S(2)*e*(d + e*x**S(2))*(n + S(1))*(n + S(2)))) rubi.add(rule349) pattern350 = Pattern(Integral(x_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**n_/(d_ + x_**S(2)*WC('e', S(1)))**S(2), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Less(n, S(-1))), CustomConstraint(lambda n: Unequal(n, S(-2)))) rule350 = ReplacementRule(pattern350, lambda x, b, c, a, d, e, n : x*(a + b*acoth(c*x))**(n + S(1))/(b*c*d*(d + e*x**S(2))*(n + S(1))) + S(4)*Int(x*(a + b*acoth(c*x))**(n + S(2))/(d + e*x**S(2))**S(2), x)/(b**S(2)*(n + S(1))*(n + S(2))) + (a + b*acoth(c*x))**(n + S(2))*(c**S(2)*x**S(2) + S(1))/(b**S(2)*e*(d + e*x**S(2))*(n + S(1))*(n + S(2)))) rubi.add(rule350) pattern351 = Pattern(Integral(x_**S(2)*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda p: RationalQ(p)), CustomConstraint(lambda p: Less(p, S(-1))), CustomConstraint(lambda p: Unequal(p, S(-5)/2))) rule351 = ReplacementRule(pattern351, lambda p, x, b, c, a, d, e : -b*(d + e*x**S(2))**(p + S(1))/(S(4)*c**S(3)*d*(p + S(1))**S(2)) - x*(a + b*atanh(c*x))*(d + e*x**S(2))**(p + S(1))/(S(2)*c**S(2)*d*(p + S(1))) + Int((a + b*atanh(c*x))*(d + e*x**S(2))**(p + S(1)), x)/(S(2)*c**S(2)*d*(p + S(1)))) rubi.add(rule351) pattern352 = Pattern(Integral(x_**S(2)*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda p: RationalQ(p)), CustomConstraint(lambda p: Less(p, S(-1))), CustomConstraint(lambda p: Unequal(p, S(-5)/2))) rule352 = ReplacementRule(pattern352, lambda p, x, b, c, a, d, e : -b*(d + e*x**S(2))**(p + S(1))/(S(4)*c**S(3)*d*(p + S(1))**S(2)) - x*(a + b*acoth(c*x))*(d + e*x**S(2))**(p + S(1))/(S(2)*c**S(2)*d*(p + S(1))) + Int((a + b*acoth(c*x))*(d + e*x**S(2))**(p + S(1)), x)/(S(2)*c**S(2)*d*(p + S(1)))) rubi.add(rule352) pattern353 = Pattern(Integral(x_**S(2)*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1)))**S(2), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(0)))) rule353 = ReplacementRule(pattern353, lambda x, b, c, a, d, e, n : -b*n*Int(x*(a + b*atanh(c*x))**(n + S(-1))/(d + e*x**S(2))**S(2), x)/(S(2)*c) + x*(a + b*atanh(c*x))**n/(S(2)*c**S(2)*d*(d + e*x**S(2))) - (a + b*atanh(c*x))**(n + S(1))/(S(2)*b*c**S(3)*d**S(2)*(n + S(1)))) rubi.add(rule353) pattern354 = Pattern(Integral(x_**S(2)*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1)))**S(2), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(0)))) rule354 = ReplacementRule(pattern354, lambda x, b, c, a, d, e, n : -b*n*Int(x*(a + b*acoth(c*x))**(n + S(-1))/(d + e*x**S(2))**S(2), x)/(S(2)*c) + x*(a + b*acoth(c*x))**n/(S(2)*c**S(2)*d*(d + e*x**S(2))) - (a + b*acoth(c*x))**(n + S(1))/(S(2)*b*c**S(3)*d**S(2)*(n + S(1)))) rubi.add(rule354) pattern355 = Pattern(Integral(x_**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda p, m: ZeroQ(m + S(2)*p + S(2))), CustomConstraint(lambda p: RationalQ(p)), CustomConstraint(lambda p: Less(p, S(-1)))) rule355 = ReplacementRule(pattern355, lambda p, x, b, m, c, a, d, e : -b*x**m*(d + e*x**S(2))**(p + S(1))/(c*d*m**S(2)) + x**(m + S(-1))*(a + b*atanh(c*x))*(d + e*x**S(2))**(p + S(1))/(c**S(2)*d*m) - (m + S(-1))*Int(x**(m + S(-2))*(a + b*atanh(c*x))*(d + e*x**S(2))**(p + S(1)), x)/(c**S(2)*d*m)) rubi.add(rule355) pattern356 = Pattern(Integral(x_**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda p, m: ZeroQ(m + S(2)*p + S(2))), CustomConstraint(lambda p: RationalQ(p)), CustomConstraint(lambda p: Less(p, S(-1)))) rule356 = ReplacementRule(pattern356, lambda p, x, b, m, c, a, d, e : -b*x**m*(d + e*x**S(2))**(p + S(1))/(c*d*m**S(2)) + x**(m + S(-1))*(a + b*acoth(c*x))*(d + e*x**S(2))**(p + S(1))/(c**S(2)*d*m) - (m + S(-1))*Int(x**(m + S(-2))*(a + b*acoth(c*x))*(d + e*x**S(2))**(p + S(1)), x)/(c**S(2)*d*m)) rubi.add(rule356) pattern357 = Pattern(Integral(x_**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda p, m: ZeroQ(m + S(2)*p + S(2))), CustomConstraint(lambda p, n: RationalQ(n, p)), CustomConstraint(lambda p: Less(p, S(-1))), CustomConstraint(lambda n: Greater(n, S(1)))) rule357 = ReplacementRule(pattern357, lambda p, x, b, m, c, a, d, e, n : b**S(2)*n*(n + S(-1))*Int(x**m*(a + b*atanh(c*x))**(n + S(-2))*(d + e*x**S(2))**p, x)/m**S(2) - b*n*x**m*(a + b*atanh(c*x))**(n + S(-1))*(d + e*x**S(2))**(p + S(1))/(c*d*m**S(2)) + x**(m + S(-1))*(a + b*atanh(c*x))**n*(d + e*x**S(2))**(p + S(1))/(c**S(2)*d*m) - (m + S(-1))*Int(x**(m + S(-2))*(a + b*atanh(c*x))**n*(d + e*x**S(2))**(p + S(1)), x)/(c**S(2)*d*m)) rubi.add(rule357) pattern358 = Pattern(Integral(x_**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda p, m: ZeroQ(m + S(2)*p + S(2))), CustomConstraint(lambda p, n: RationalQ(n, p)), CustomConstraint(lambda p: Less(p, S(-1))), CustomConstraint(lambda n: Greater(n, S(1)))) rule358 = ReplacementRule(pattern358, lambda p, x, b, m, c, a, d, e, n : b**S(2)*n*(n + S(-1))*Int(x**m*(a + b*acoth(c*x))**(n + S(-2))*(d + e*x**S(2))**p, x)/m**S(2) - b*n*x**m*(a + b*acoth(c*x))**(n + S(-1))*(d + e*x**S(2))**(p + S(1))/(c*d*m**S(2)) + x**(m + S(-1))*(a + b*acoth(c*x))**n*(d + e*x**S(2))**(p + S(1))/(c**S(2)*d*m) - (m + S(-1))*Int(x**(m + S(-2))*(a + b*acoth(c*x))**n*(d + e*x**S(2))**(p + S(1)), x)/(c**S(2)*d*m)) rubi.add(rule358) pattern359 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda p, m: ZeroQ(m + S(2)*p + S(2))), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Less(n, S(-1)))) rule359 = ReplacementRule(pattern359, lambda p, x, b, m, c, a, d, e, n : -m*Int(x**(m + S(-1))*(a + b*atanh(c*x))**(n + S(1))*(d + e*x**S(2))**p, x)/(b*c*(n + S(1))) + x**m*(a + b*atanh(c*x))**(n + S(1))*(d + e*x**S(2))**(p + S(1))/(b*c*d*(n + S(1)))) rubi.add(rule359) pattern360 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda p, m: ZeroQ(m + S(2)*p + S(2))), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Less(n, S(-1)))) rule360 = ReplacementRule(pattern360, lambda p, x, b, m, c, a, d, e, n : -m*Int(x**(m + S(-1))*(a + b*acoth(c*x))**(n + S(1))*(d + e*x**S(2))**p, x)/(b*c*(n + S(1))) + x**m*(a + b*acoth(c*x))**(n + S(1))*(d + e*x**S(2))**(p + S(1))/(b*c*d*(n + S(1)))) rubi.add(rule360) pattern361 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda p, m: ZeroQ(m + S(2)*p + S(3))), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda m: NonzeroQ(m + S(1)))) rule361 = ReplacementRule(pattern361, lambda p, x, b, m, c, a, d, e, n : -b*c*n*Int(x**(m + S(1))*(a + b*atanh(c*x))**(n + S(-1))*(d + e*x**S(2))**p, x)/(m + S(1)) + x**(m + S(1))*(a + b*atanh(c*x))**n*(d + e*x**S(2))**(p + S(1))/(d*(m + S(1)))) rubi.add(rule361) pattern362 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda p, m: ZeroQ(m + S(2)*p + S(3))), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda m: NonzeroQ(m + S(1)))) rule362 = ReplacementRule(pattern362, lambda p, x, b, m, c, a, d, e, n : -b*c*n*Int(x**(m + S(1))*(a + b*acoth(c*x))**(n + S(-1))*(d + e*x**S(2))**p, x)/(m + S(1)) + x**(m + S(1))*(a + b*acoth(c*x))**n*(d + e*x**S(2))**(p + S(1))/(d*(m + S(1)))) rubi.add(rule362) pattern363 = Pattern(Integral(x_**m_*sqrt(d_ + x_**S(2)*WC('e', S(1)))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda m: NonzeroQ(m + S(2)))) rule363 = ReplacementRule(pattern363, lambda x, b, m, c, a, d, e : -b*c*d*Int(x**(m + S(1))/sqrt(d + e*x**S(2)), x)/(m + S(2)) + d*Int(x**m*(a + b*atanh(c*x))/sqrt(d + e*x**S(2)), x)/(m + S(2)) + x**(m + S(1))*(a + b*atanh(c*x))*sqrt(d + e*x**S(2))/(m + S(2))) rubi.add(rule363) pattern364 = Pattern(Integral(x_**m_*sqrt(d_ + x_**S(2)*WC('e', S(1)))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda m: NonzeroQ(m + S(2)))) rule364 = ReplacementRule(pattern364, lambda x, b, m, c, a, d, e : -b*c*d*Int(x**(m + S(1))/sqrt(d + e*x**S(2)), x)/(m + S(2)) + d*Int(x**m*(a + b*acoth(c*x))/sqrt(d + e*x**S(2)), x)/(m + S(2)) + x**(m + S(1))*(a + b*acoth(c*x))*sqrt(d + e*x**S(2))/(m + S(2))) rubi.add(rule364) pattern365 = Pattern(Integral(x_**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: PositiveIntegerQ(n)), CustomConstraint(lambda p: IntegerQ(p)), CustomConstraint(lambda p: Greater(p, S(1)))) rule365 = ReplacementRule(pattern365, lambda p, x, b, m, c, a, d, e, n : Int(ExpandIntegrand(x**m*(a + b*atanh(c*x))**n*(d + e*x**S(2))**p, x), x)) rubi.add(rule365) pattern366 = Pattern(Integral(x_**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: PositiveIntegerQ(n)), CustomConstraint(lambda p: IntegerQ(p)), CustomConstraint(lambda p: Greater(p, S(1)))) rule366 = ReplacementRule(pattern366, lambda p, x, b, m, c, a, d, e, n : Int(ExpandIntegrand(x**m*(a + b*acoth(c*x))**n*(d + e*x**S(2))**p, x), x)) rubi.add(rule366) pattern367 = Pattern(Integral(x_**m_*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda p: RationalQ(p)), CustomConstraint(lambda p: Greater(p, S(0))), CustomConstraint(lambda n: PositiveIntegerQ(n)), CustomConstraint(lambda n, p, m: RationalQ(m) | (IntegerQ(p) & EqQ(n, S(1))))) rule367 = ReplacementRule(pattern367, lambda p, x, b, m, c, a, d, e, n : -c**S(2)*d*Int(x**(m + S(2))*(a + b*atanh(c*x))**n*(d + e*x**S(2))**(p + S(-1)), x) + d*Int(x**m*(a + b*atanh(c*x))**n*(d + e*x**S(2))**(p + S(-1)), x)) rubi.add(rule367) pattern368 = Pattern(Integral(x_**m_*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda p: RationalQ(p)), CustomConstraint(lambda p: Greater(p, S(0))), CustomConstraint(lambda n: PositiveIntegerQ(n)), CustomConstraint(lambda n, p, m: RationalQ(m) | (IntegerQ(p) & EqQ(n, S(1))))) rule368 = ReplacementRule(pattern368, lambda p, x, b, m, c, a, d, e, n : -c**S(2)*d*Int(x**(m + S(2))*(a + b*acoth(c*x))**n*(d + e*x**S(2))**(p + S(-1)), x) + d*Int(x**m*(a + b*acoth(c*x))**n*(d + e*x**S(2))**(p + S(-1)), x)) rubi.add(rule368) pattern369 = Pattern(Integral(x_**m_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n, m: RationalQ(m, n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda m: Greater(m, S(1)))) rule369 = ReplacementRule(pattern369, lambda x, b, m, c, a, d, e, n : b*n*Int(x**(m + S(-1))*(a + b*atanh(c*x))**(n + S(-1))/sqrt(d + e*x**S(2)), x)/(c*m) + (m + S(-1))*Int(x**(m + S(-2))*(a + b*atanh(c*x))**n/sqrt(d + e*x**S(2)), x)/(c**S(2)*m) - x**(m + S(-1))*(a + b*atanh(c*x))**n*sqrt(d + e*x**S(2))/(c**S(2)*d*m)) rubi.add(rule369) pattern370 = Pattern(Integral(x_**m_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n, m: RationalQ(m, n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda m: Greater(m, S(1)))) rule370 = ReplacementRule(pattern370, lambda x, b, m, c, a, d, e, n : b*n*Int(x**(m + S(-1))*(a + b*acoth(c*x))**(n + S(-1))/sqrt(d + e*x**S(2)), x)/(c*m) + (m + S(-1))*Int(x**(m + S(-2))*(a + b*acoth(c*x))**n/sqrt(d + e*x**S(2)), x)/(c**S(2)*m) - x**(m + S(-1))*(a + b*acoth(c*x))**n*sqrt(d + e*x**S(2))/(c**S(2)*d*m)) rubi.add(rule370) pattern371 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))/(x_*sqrt(d_ + x_**S(2)*WC('e', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda d: PositiveQ(d))) rule371 = ReplacementRule(pattern371, lambda x, b, c, a, d, e : b*PolyLog(S(2), -sqrt(-c*x + S(1))/sqrt(c*x + S(1)))/sqrt(d) - b*PolyLog(S(2), sqrt(-c*x + S(1))/sqrt(c*x + S(1)))/sqrt(d) - S(2)*(a + b*atanh(c*x))*atanh(sqrt(-c*x + S(1))/sqrt(c*x + S(1)))/sqrt(d)) rubi.add(rule371) pattern372 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))/(x_*sqrt(d_ + x_**S(2)*WC('e', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda d: PositiveQ(d))) rule372 = ReplacementRule(pattern372, lambda x, b, c, a, d, e : b*PolyLog(S(2), -sqrt(-c*x + S(1))/sqrt(c*x + S(1)))/sqrt(d) - b*PolyLog(S(2), sqrt(-c*x + S(1))/sqrt(c*x + S(1)))/sqrt(d) - S(2)*(a + b*acoth(c*x))*atanh(sqrt(-c*x + S(1))/sqrt(c*x + S(1)))/sqrt(d)) rubi.add(rule372) pattern373 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**n_/(x_*sqrt(d_ + x_**S(2)*WC('e', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: PositiveIntegerQ(n)), CustomConstraint(lambda d: PositiveQ(d))) rule373 = ReplacementRule(pattern373, lambda x, b, c, a, d, e, n : Subst(Int((a + b*x)**n*csch(x), x), x, atanh(c*x))/sqrt(d)) rubi.add(rule373) pattern374 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**n_/(x_*sqrt(d_ + x_**S(2)*WC('e', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: PositiveIntegerQ(n)), CustomConstraint(lambda d: PositiveQ(d))) rule374 = ReplacementRule(pattern374, lambda x, b, c, a, d, e, n : -c*x*sqrt(S(1) - S(1)/(c**S(2)*x**S(2)))*Subst(Int((a + b*x)**n*sech(x), x), x, acoth(c*x))/sqrt(d + e*x**S(2))) rubi.add(rule374) pattern375 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))/(x_*sqrt(d_ + x_**S(2)*WC('e', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: PositiveIntegerQ(n)), CustomConstraint(lambda d: Not(PositiveQ(d)))) rule375 = ReplacementRule(pattern375, lambda x, b, c, a, d, e, n : sqrt(-c**S(2)*x**S(2) + S(1))*Int((a + b*atanh(c*x))**n/(x*sqrt(-c**S(2)*x**S(2) + S(1))), x)/sqrt(d + e*x**S(2))) rubi.add(rule375) pattern376 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))/(x_*sqrt(d_ + x_**S(2)*WC('e', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: PositiveIntegerQ(n)), CustomConstraint(lambda d: Not(PositiveQ(d)))) rule376 = ReplacementRule(pattern376, lambda x, b, c, a, d, e, n : sqrt(-c**S(2)*x**S(2) + S(1))*Int((a + b*acoth(c*x))**n/(x*sqrt(-c**S(2)*x**S(2) + S(1))), x)/sqrt(d + e*x**S(2))) rubi.add(rule376) pattern377 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))/(x_**S(2)*sqrt(d_ + x_**S(2)*WC('e', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(0)))) rule377 = ReplacementRule(pattern377, lambda x, b, c, a, d, e, n : b*c*n*Int((a + b*atanh(c*x))**(n + S(-1))/(x*sqrt(d + e*x**S(2))), x) - (a + b*atanh(c*x))**n*sqrt(d + e*x**S(2))/(d*x)) rubi.add(rule377) pattern378 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))/(x_**S(2)*sqrt(d_ + x_**S(2)*WC('e', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(0)))) rule378 = ReplacementRule(pattern378, lambda x, b, c, a, d, e, n : b*c*n*Int((a + b*acoth(c*x))**(n + S(-1))/(x*sqrt(d + e*x**S(2))), x) - (a + b*acoth(c*x))**n*sqrt(d + e*x**S(2))/(d*x)) rubi.add(rule378) pattern379 = Pattern(Integral(x_**m_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n, m: RationalQ(m, n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda m: Less(m, S(-1))), CustomConstraint(lambda m: Unequal(m, S(-2)))) rule379 = ReplacementRule(pattern379, lambda x, b, m, c, a, d, e, n : -b*c*n*Int(x**(m + S(1))*(a + b*atanh(c*x))**(n + S(-1))/sqrt(d + e*x**S(2)), x)/(m + S(1)) + c**S(2)*(m + S(2))*Int(x**(m + S(2))*(a + b*atanh(c*x))**n/sqrt(d + e*x**S(2)), x)/(m + S(1)) + x**(m + S(1))*(a + b*atanh(c*x))**n*sqrt(d + e*x**S(2))/(d*(m + S(1)))) rubi.add(rule379) pattern380 = Pattern(Integral(x_**m_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))/sqrt(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n, m: RationalQ(m, n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda m: Less(m, S(-1))), CustomConstraint(lambda m: Unequal(m, S(-2)))) rule380 = ReplacementRule(pattern380, lambda x, b, m, c, a, d, e, n : -b*c*n*Int(x**(m + S(1))*(a + b*acoth(c*x))**(n + S(-1))/sqrt(d + e*x**S(2)), x)/(m + S(1)) + c**S(2)*(m + S(2))*Int(x**(m + S(2))*(a + b*acoth(c*x))**n/sqrt(d + e*x**S(2)), x)/(m + S(1)) + x**(m + S(1))*(a + b*acoth(c*x))**n*sqrt(d + e*x**S(2))/(d*(m + S(1)))) rubi.add(rule380) pattern381 = Pattern(Integral(x_**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n, p, m: IntegersQ(m, n, S(2)*p)), CustomConstraint(lambda p: Less(p, S(-1))), CustomConstraint(lambda m: Greater(m, S(1))), CustomConstraint(lambda n: Unequal(n, S(-1)))) rule381 = ReplacementRule(pattern381, lambda p, x, b, m, c, a, d, e, n : -d*Int(x**(m + S(-2))*(a + b*atanh(c*x))**n*(d + e*x**S(2))**p, x)/e + Int(x**(m + S(-2))*(a + b*atanh(c*x))**n*(d + e*x**S(2))**(p + S(1)), x)/e) rubi.add(rule381) pattern382 = Pattern(Integral(x_**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n, p, m: IntegersQ(m, n, S(2)*p)), CustomConstraint(lambda p: Less(p, S(-1))), CustomConstraint(lambda m: Greater(m, S(1))), CustomConstraint(lambda n: Unequal(n, S(-1)))) rule382 = ReplacementRule(pattern382, lambda p, x, b, m, c, a, d, e, n : -d*Int(x**(m + S(-2))*(a + b*acoth(c*x))**n*(d + e*x**S(2))**p, x)/e + Int(x**(m + S(-2))*(a + b*acoth(c*x))**n*(d + e*x**S(2))**(p + S(1)), x)/e) rubi.add(rule382) pattern383 = Pattern(Integral(x_**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n, p, m: IntegersQ(m, n, S(2)*p)), CustomConstraint(lambda p: Less(p, S(-1))), CustomConstraint(lambda m: Less(m, S(0))), CustomConstraint(lambda n: Unequal(n, S(-1)))) rule383 = ReplacementRule(pattern383, lambda p, x, b, m, c, a, d, e, n : -e*Int(x**(m + S(2))*(a + b*atanh(c*x))**n*(d + e*x**S(2))**p, x)/d + Int(x**m*(a + b*atanh(c*x))**n*(d + e*x**S(2))**(p + S(1)), x)/d) rubi.add(rule383) pattern384 = Pattern(Integral(x_**m_*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n, p, m: IntegersQ(m, n, S(2)*p)), CustomConstraint(lambda p: Less(p, S(-1))), CustomConstraint(lambda m: Less(m, S(0))), CustomConstraint(lambda n: Unequal(n, S(-1)))) rule384 = ReplacementRule(pattern384, lambda p, x, b, m, c, a, d, e, n : -e*Int(x**(m + S(2))*(a + b*acoth(c*x))**n*(d + e*x**S(2))**p, x)/d + Int(x**m*(a + b*acoth(c*x))**n*(d + e*x**S(2))**(p + S(1)), x)/d) rubi.add(rule384) pattern385 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n, p, m: RationalQ(m, n, p)), CustomConstraint(lambda p: Less(p, S(-1))), CustomConstraint(lambda n: Less(n, S(-1))), CustomConstraint(lambda p, m: NonzeroQ(m + S(2)*p + S(2)))) rule385 = ReplacementRule(pattern385, lambda p, x, b, m, c, a, d, e, n : c*(m + S(2)*p + S(2))*Int(x**(m + S(1))*(a + b*atanh(c*x))**(n + S(1))*(d + e*x**S(2))**p, x)/(b*(n + S(1))) - m*Int(x**(m + S(-1))*(a + b*atanh(c*x))**(n + S(1))*(d + e*x**S(2))**p, x)/(b*c*(n + S(1))) + x**m*(a + b*atanh(c*x))**(n + S(1))*(d + e*x**S(2))**(p + S(1))/(b*c*d*(n + S(1)))) rubi.add(rule385) pattern386 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n, p, m: RationalQ(m, n, p)), CustomConstraint(lambda p: Less(p, S(-1))), CustomConstraint(lambda n: Less(n, S(-1))), CustomConstraint(lambda p, m: NonzeroQ(m + S(2)*p + S(2)))) rule386 = ReplacementRule(pattern386, lambda p, x, b, m, c, a, d, e, n : c*(m + S(2)*p + S(2))*Int(x**(m + S(1))*(a + b*acoth(c*x))**(n + S(1))*(d + e*x**S(2))**p, x)/(b*(n + S(1))) - m*Int(x**(m + S(-1))*(a + b*acoth(c*x))**(n + S(1))*(d + e*x**S(2))**p, x)/(b*c*(n + S(1))) + x**m*(a + b*acoth(c*x))**(n + S(1))*(d + e*x**S(2))**(p + S(1))/(b*c*d*(n + S(1)))) rubi.add(rule386) pattern387 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda m: PositiveIntegerQ(m)), CustomConstraint(lambda p, m: NegativeIntegerQ(m + S(2)*p + S(1))), CustomConstraint(lambda d, p: IntegerQ(p) | PositiveQ(d))) rule387 = ReplacementRule(pattern387, lambda p, x, b, m, c, a, d, e, n : c**(-m + S(-1))*d**p*Subst(Int((a + b*x)**n*Cosh(x)**(-m - S(2)*p + S(-2))*sinh(x)**m, x), x, atanh(c*x))) rubi.add(rule387) pattern388 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda m: PositiveIntegerQ(m)), CustomConstraint(lambda p, m: NegativeIntegerQ(m + S(2)*p + S(1))), CustomConstraint(lambda d, p: Not(IntegerQ(p) | PositiveQ(d)))) rule388 = ReplacementRule(pattern388, lambda p, x, b, m, c, a, d, e, n : d**(p + S(1)/2)*sqrt(-c**S(2)*x**S(2) + S(1))*Int(x**m*(a + b*atanh(c*x))**n*(-c**S(2)*x**S(2) + S(1))**p, x)/sqrt(d + e*x**S(2))) rubi.add(rule388) pattern389 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda m: PositiveIntegerQ(m)), CustomConstraint(lambda p, m: NegativeIntegerQ(m + S(2)*p + S(1))), CustomConstraint(lambda p: IntegerQ(p))) rule389 = ReplacementRule(pattern389, lambda p, x, b, m, c, a, d, e, n : -c**(-m + S(-1))*(-d)**p*Subst(Int((a + b*x)**n*Cosh(x)**m*sinh(x)**(-m - S(2)*p + S(-2)), x), x, acoth(c*x))) rubi.add(rule389) pattern390 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**p_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda m: PositiveIntegerQ(m)), CustomConstraint(lambda p, m: NegativeIntegerQ(m + S(2)*p + S(1))), CustomConstraint(lambda p: Not(IntegerQ(p)))) rule390 = ReplacementRule(pattern390, lambda p, x, b, m, c, a, d, e, n : -c**(-m)*x*(-d)**(p + S(1)/2)*sqrt((c**S(2)*x**S(2) + S(-1))/(c**S(2)*x**S(2)))*Subst(Int((a + b*x)**n*Cosh(x)**m*sinh(x)**(-m - S(2)*p + S(-2)), x), x, acoth(c*x))/sqrt(d + e*x**S(2))) rubi.add(rule390) pattern391 = Pattern(Integral(x_*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda p: NonzeroQ(p + S(1)))) rule391 = ReplacementRule(pattern391, lambda p, x, b, c, a, d, e : -b*c*Int((d + e*x**S(2))**(p + S(1))/(-c**S(2)*x**S(2) + S(1)), x)/(S(2)*e*(p + S(1))) + (a + b*atanh(c*x))*(d + e*x**S(2))**(p + S(1))/(S(2)*e*(p + S(1)))) rubi.add(rule391) pattern392 = Pattern(Integral(x_*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda p: NonzeroQ(p + S(1)))) rule392 = ReplacementRule(pattern392, lambda p, x, b, c, a, d, e : -b*c*Int((d + e*x**S(2))**(p + S(1))/(-c**S(2)*x**S(2) + S(1)), x)/(S(2)*e*(p + S(1))) + (a + b*acoth(c*x))*(d + e*x**S(2))**(p + S(1))/(S(2)*e*(p + S(1)))) rubi.add(rule392) pattern393 = Pattern(Integral(x_**WC('m', S(1))*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda p, m: (NegativeIntegerQ(m/S(2) + p + S(1)/2) & Not(NegativeIntegerQ(m/S(2) + S(-1)/2))) | (PositiveIntegerQ(p) & Not(NegativeIntegerQ(m/S(2) + S(-1)/2) & Greater(m + S(2)*p + S(3), S(0)))) | (PositiveIntegerQ(m/S(2) + S(1)/2) & Not(NegativeIntegerQ(p) & Greater(m + S(2)*p + S(3), S(0))))), ) def With393(p, x, b, m, c, a, d, e): u = IntHide(x**m*(d + e*x**S(2))**p, x) return -b*c*Int(SimplifyIntegrand(u/(-c**S(2)*x**S(2) + S(1)), x), x) + Dist(a + b*atanh(c*x), u, x) rule393 = ReplacementRule(pattern393, lambda p, x, b, m, c, a, d, e : With393(p, x, b, m, c, a, d, e)) rubi.add(rule393) pattern394 = Pattern(Integral(x_**WC('m', S(1))*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda p, m: (NegativeIntegerQ(m/S(2) + p + S(1)/2) & Not(NegativeIntegerQ(m/S(2) + S(-1)/2))) | (PositiveIntegerQ(p) & Not(NegativeIntegerQ(m/S(2) + S(-1)/2) & Greater(m + S(2)*p + S(3), S(0)))) | (PositiveIntegerQ(m/S(2) + S(1)/2) & Not(NegativeIntegerQ(p) & Greater(m + S(2)*p + S(3), S(0))))), ) def With394(p, x, b, m, c, a, d, e): u = IntHide(x**m*(d + e*x**S(2))**p, x) return -b*c*Int(SimplifyIntegrand(u/(-c**S(2)*x**S(2) + S(1)), x), x) + Dist(a + b*acoth(c*x), u, x) rule394 = ReplacementRule(pattern394, lambda p, x, b, m, c, a, d, e : With394(p, x, b, m, c, a, d, e)) rubi.add(rule394) pattern395 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda p: IntegerQ(p)), CustomConstraint(lambda n: PositiveIntegerQ(n)), CustomConstraint(lambda p, m: Greater(p, S(0)) | (IntegerQ(m) & Less(p, S(-1)) & Unequal(m, S(1))))) rule395 = ReplacementRule(pattern395, lambda p, x, b, m, c, a, d, e, n : Int(ExpandIntegrand((a + b*atanh(c*x))**n, x**m*(d + e*x**S(2))**p, x), x)) rubi.add(rule395) pattern396 = Pattern(Integral(x_**WC('m', S(1))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda p: IntegerQ(p)), CustomConstraint(lambda n: PositiveIntegerQ(n)), CustomConstraint(lambda p, m: Greater(p, S(0)) | (IntegerQ(m) & Less(p, S(-1)) & Unequal(m, S(1))))) rule396 = ReplacementRule(pattern396, lambda p, x, b, m, c, a, d, e, n : Int(ExpandIntegrand((a + b*acoth(c*x))**n, x**m*(d + e*x**S(2))**p, x), x)) rubi.add(rule396) pattern397 = Pattern(Integral(x_**WC('m', S(1))*(a_ + WC('b', S(1))*atanh(x_*WC('c', S(1))))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda p, x: FreeQ(p, x))) rule397 = ReplacementRule(pattern397, lambda p, x, b, m, c, a, d, e : a*Int(x**m*(d + e*x**S(2))**p, x) + b*Int(x**m*(d + e*x**S(2))**p*atanh(c*x), x)) rubi.add(rule397) pattern398 = Pattern(Integral(x_**WC('m', S(1))*(a_ + WC('b', S(1))*acoth(x_*WC('c', S(1))))*(d_ + x_**S(2)*WC('e', S(1)))**WC('p', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda p, x: FreeQ(p, x))) rule398 = ReplacementRule(pattern398, lambda p, x, b, m, c, a, d, e : a*Int(x**m*(d + e*x**S(2))**p, x) + b*Int(x**m*(d + e*x**S(2))**p*acoth(c*x), x)) rubi.add(rule398) pattern399 = Pattern(Integral(x_**WC('m', S(1))*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x))) rule399 = ReplacementRule(pattern399, lambda p, x, b, m, c, a, d, e, n : Int(x**m*(a + b*atanh(c*x))**n*(d + e*x**S(2))**p, x)) rubi.add(rule399) pattern400 = Pattern(Integral(x_**WC('m', S(1))*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x))) rule400 = ReplacementRule(pattern400, lambda p, x, b, m, c, a, d, e, n : Int(x**m*(a + b*acoth(c*x))**n*(d + e*x**S(2))**p, x)) rubi.add(rule400) pattern401 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))*atanh(u_)/(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda c, u, x: ZeroQ(u**S(2) - (S(1) - S(2)/(c*x + S(1)))**S(2)))) rule401 = ReplacementRule(pattern401, lambda x, b, c, a, d, u, e, n : -Int((a + b*atanh(c*x))**n*log(-u + S(1))/(d + e*x**S(2)), x)/S(2) + Int((a + b*atanh(c*x))**n*log(u + S(1))/(d + e*x**S(2)), x)/S(2)) rubi.add(rule401) pattern402 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))*acoth(u_)/(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda c, u, x: ZeroQ(u**S(2) - (S(1) - S(2)/(c*x + S(1)))**S(2)))) rule402 = ReplacementRule(pattern402, lambda x, b, c, a, d, u, e, n : -Int((a + b*acoth(c*x))**n*log(SimplifyIntegrand(S(1) - S(1)/u, x))/(d + e*x**S(2)), x)/S(2) + Int((a + b*acoth(c*x))**n*log(SimplifyIntegrand(S(1) + 1/u, x))/(d + e*x**S(2)), x)/S(2)) rubi.add(rule402) pattern403 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))*atanh(u_)/(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda c, u, x: ZeroQ(u**S(2) - (S(1) - S(2)/(-c*x + S(1)))**S(2)))) rule403 = ReplacementRule(pattern403, lambda x, b, c, a, d, u, e, n : -Int((a + b*atanh(c*x))**n*log(-u + S(1))/(d + e*x**S(2)), x)/S(2) + Int((a + b*atanh(c*x))**n*log(u + S(1))/(d + e*x**S(2)), x)/S(2)) rubi.add(rule403) pattern404 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))*acoth(u_)/(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda c, u, x: ZeroQ(u**S(2) - (S(1) - S(2)/(-c*x + S(1)))**S(2)))) rule404 = ReplacementRule(pattern404, lambda x, b, c, a, d, u, e, n : -Int((a + b*acoth(c*x))**n*log(SimplifyIntegrand(S(1) - S(1)/u, x))/(d + e*x**S(2)), x)/S(2) + Int((a + b*acoth(c*x))**n*log(SimplifyIntegrand(S(1) + 1/u, x))/(d + e*x**S(2)), x)/S(2)) rubi.add(rule404) pattern405 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))*log(u_)/(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda c, u, x: ZeroQ(-(S(1) - S(2)/(c*x + S(1)))**S(2) + (-u + S(1))**S(2)))) rule405 = ReplacementRule(pattern405, lambda x, b, c, a, d, u, e, n : -b*n*Int((a + b*atanh(c*x))**(n + S(-1))*PolyLog(S(2), -u + S(1))/(d + e*x**S(2)), x)/S(2) + (a + b*atanh(c*x))**n*PolyLog(S(2), -u + S(1))/(S(2)*c*d)) rubi.add(rule405) pattern406 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))*log(u_)/(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda c, u, x: ZeroQ(-(S(1) - S(2)/(c*x + S(1)))**S(2) + (-u + S(1))**S(2)))) rule406 = ReplacementRule(pattern406, lambda x, b, c, a, d, u, e, n : -b*n*Int((a + b*acoth(c*x))**(n + S(-1))*PolyLog(S(2), -u + S(1))/(d + e*x**S(2)), x)/S(2) + (a + b*acoth(c*x))**n*PolyLog(S(2), -u + S(1))/(S(2)*c*d)) rubi.add(rule406) pattern407 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))*log(u_)/(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda c, u, x: ZeroQ(-(S(1) - S(2)/(-c*x + S(1)))**S(2) + (-u + S(1))**S(2)))) rule407 = ReplacementRule(pattern407, lambda x, b, c, a, d, u, e, n : b*n*Int((a + b*atanh(c*x))**(n + S(-1))*PolyLog(S(2), -u + S(1))/(d + e*x**S(2)), x)/S(2) - (a + b*atanh(c*x))**n*PolyLog(S(2), -u + S(1))/(S(2)*c*d)) rubi.add(rule407) pattern408 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))*log(u_)/(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda c, u, x: ZeroQ(-(S(1) - S(2)/(-c*x + S(1)))**S(2) + (-u + S(1))**S(2)))) rule408 = ReplacementRule(pattern408, lambda x, b, c, a, d, u, e, n : b*n*Int((a + b*acoth(c*x))**(n + S(-1))*PolyLog(S(2), -u + S(1))/(d + e*x**S(2)), x)/S(2) - (a + b*acoth(c*x))**n*PolyLog(S(2), -u + S(1))/(S(2)*c*d)) rubi.add(rule408) pattern409 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))*PolyLog(p_, u_)/(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda c, u, x: ZeroQ(u**S(2) - (S(1) - S(2)/(c*x + S(1)))**S(2)))) rule409 = ReplacementRule(pattern409, lambda p, x, b, c, a, d, u, e, n : b*n*Int((a + b*atanh(c*x))**(n + S(-1))*PolyLog(p + S(1), u)/(d + e*x**S(2)), x)/S(2) - (a + b*atanh(c*x))**n*PolyLog(p + S(1), u)/(S(2)*c*d)) rubi.add(rule409) pattern410 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))*PolyLog(p_, u_)/(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda c, u, x: ZeroQ(u**S(2) - (S(1) - S(2)/(c*x + S(1)))**S(2)))) rule410 = ReplacementRule(pattern410, lambda p, x, b, c, a, d, u, e, n : b*n*Int((a + b*acoth(c*x))**(n + S(-1))*PolyLog(p + S(1), u)/(d + e*x**S(2)), x)/S(2) - (a + b*acoth(c*x))**n*PolyLog(p + S(1), u)/(S(2)*c*d)) rubi.add(rule410) pattern411 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))*PolyLog(p_, u_)/(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda c, u, x: ZeroQ(u**S(2) - (S(1) - S(2)/(-c*x + S(1)))**S(2)))) rule411 = ReplacementRule(pattern411, lambda p, x, b, c, a, d, u, e, n : -b*n*Int((a + b*atanh(c*x))**(n + S(-1))*PolyLog(p + S(1), u)/(d + e*x**S(2)), x)/S(2) + (a + b*atanh(c*x))**n*PolyLog(p + S(1), u)/(S(2)*c*d)) rubi.add(rule411) pattern412 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))*PolyLog(p_, u_)/(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda c, u, x: ZeroQ(u**S(2) - (S(1) - S(2)/(-c*x + S(1)))**S(2)))) rule412 = ReplacementRule(pattern412, lambda p, x, b, c, a, d, u, e, n : -b*n*Int((a + b*acoth(c*x))**(n + S(-1))*PolyLog(p + S(1), u)/(d + e*x**S(2)), x)/S(2) + (a + b*acoth(c*x))**n*PolyLog(p + S(1), u)/(S(2)*c*d)) rubi.add(rule412) pattern413 = Pattern(Integral(S(1)/((d_ + x_**S(2)*WC('e', S(1)))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e))) rule413 = ReplacementRule(pattern413, lambda x, b, c, a, d, e : (-log(a + b*acoth(c*x)) + log(a + b*atanh(c*x)))/(b**S(2)*c*d*(acoth(c*x) - atanh(c*x)))) rubi.add(rule413) pattern414 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('n', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n, m: IntegersQ(m, n)), CustomConstraint(lambda n, m: Inequality(S(0), Less, n, LessEqual, m))) rule414 = ReplacementRule(pattern414, lambda x, b, m, c, a, d, e, n : -n*Int((a + b*acoth(c*x))**(m + S(1))*(a + b*atanh(c*x))**(n + S(-1))/(d + e*x**S(2)), x)/(m + S(1)) + (a + b*acoth(c*x))**(m + S(1))*(a + b*atanh(c*x))**n/(b*c*d*(m + S(1)))) rubi.add(rule414) pattern415 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**WC('n', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**WC('m', S(1))/(d_ + x_**S(2)*WC('e', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda n, m: IntegersQ(m, n)), CustomConstraint(lambda n, m: Less(S(0), n, m))) rule415 = ReplacementRule(pattern415, lambda x, b, m, c, a, d, e, n : -n*Int((a + b*acoth(c*x))**(n + S(-1))*(a + b*atanh(c*x))**(m + S(1))/(d + e*x**S(2)), x)/(m + S(1)) + (a + b*acoth(c*x))**n*(a + b*atanh(c*x))**(m + S(1))/(b*c*d*(m + S(1)))) rubi.add(rule415) pattern416 = Pattern(Integral(atanh(x_*WC('a', S(1)))/(c_ + x_**WC('n', S(1))*WC('d', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n: IntegerQ(n)), CustomConstraint(lambda c, a, d, n: Not(Equal(n, S(2)) & ZeroQ(a**S(2)*c + d)))) rule416 = ReplacementRule(pattern416, lambda x, c, a, d, n : -Int(log(-a*x + S(1))/(c + d*x**n), x)/S(2) + Int(log(a*x + S(1))/(c + d*x**n), x)/S(2)) rubi.add(rule416) pattern417 = Pattern(Integral(acoth(x_*WC('a', S(1)))/(c_ + x_**WC('n', S(1))*WC('d', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n: IntegerQ(n)), CustomConstraint(lambda c, a, d, n: Not(Equal(n, S(2)) & ZeroQ(a**S(2)*c + d)))) rule417 = ReplacementRule(pattern417, lambda x, c, a, d, n : -Int(log(S(1) - S(1)/(a*x))/(c + d*x**n), x)/S(2) + Int(log(S(1) + S(1)/(a*x))/(c + d*x**n), x)/S(2)) rubi.add(rule417) pattern418 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))*(WC('d', S(0)) + WC('e', S(1))*log(x_**S(2)*WC('g', S(1)) + WC('f', S(0)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda g, x: FreeQ(g, x))) rule418 = ReplacementRule(pattern418, lambda x, b, g, c, f, a, d, e : -b*c*Int(x*(d + e*log(f + g*x**S(2)))/(-c**S(2)*x**S(2) + S(1)), x) - S(2)*e*g*Int(x**S(2)*(a + b*atanh(c*x))/(f + g*x**S(2)), x) + x*(a + b*atanh(c*x))*(d + e*log(f + g*x**S(2)))) rubi.add(rule418) pattern419 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))*(WC('d', S(0)) + WC('e', S(1))*log(x_**S(2)*WC('g', S(1)) + WC('f', S(0)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda g, x: FreeQ(g, x))) rule419 = ReplacementRule(pattern419, lambda x, b, g, c, f, a, d, e : -b*c*Int(x*(d + e*log(f + g*x**S(2)))/(-c**S(2)*x**S(2) + S(1)), x) - S(2)*e*g*Int(x**S(2)*(a + b*acoth(c*x))/(f + g*x**S(2)), x) + x*(a + b*acoth(c*x))*(d + e*log(f + g*x**S(2)))) rubi.add(rule419) pattern420 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))*(WC('d', S(0)) + WC('e', S(1))*log(x_**S(2)*WC('g', S(1)) + WC('f', S(0)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda g, x: FreeQ(g, x)), CustomConstraint(lambda m: NegativeIntegerQ(m/S(2)))) rule420 = ReplacementRule(pattern420, lambda x, b, m, g, c, f, a, d, e : -b*c*Int(x**(m + S(1))*(d + e*log(f + g*x**S(2)))/(-c**S(2)*x**S(2) + S(1)), x)/(m + S(1)) - S(2)*e*g*Int(x**(m + S(2))*(a + b*atanh(c*x))/(f + g*x**S(2)), x)/(m + S(1)) + x**(m + S(1))*(a + b*atanh(c*x))*(d + e*log(f + g*x**S(2)))/(m + S(1))) rubi.add(rule420) pattern421 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))*(WC('d', S(0)) + WC('e', S(1))*log(x_**S(2)*WC('g', S(1)) + WC('f', S(0)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda g, x: FreeQ(g, x)), CustomConstraint(lambda m: NegativeIntegerQ(m/S(2)))) rule421 = ReplacementRule(pattern421, lambda x, b, m, g, c, f, a, d, e : -b*c*Int(x**(m + S(1))*(d + e*log(f + g*x**S(2)))/(-c**S(2)*x**S(2) + S(1)), x)/(m + S(1)) - S(2)*e*g*Int(x**(m + S(2))*(a + b*acoth(c*x))/(f + g*x**S(2)), x)/(m + S(1)) + x**(m + S(1))*(a + b*acoth(c*x))*(d + e*log(f + g*x**S(2)))/(m + S(1))) rubi.add(rule421) pattern422 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))*(WC('d', S(0)) + WC('e', S(1))*log(x_**S(2)*WC('g', S(1)) + WC('f', S(0)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda g, x: FreeQ(g, x)), CustomConstraint(lambda m: PositiveIntegerQ(m/S(2) + S(1)/2)), ) def With422(x, b, m, g, c, f, a, d, e): u = IntHide(x**m*(d + e*log(f + g*x**S(2))), x) return -b*c*Int(ExpandIntegrand(u/(-c**S(2)*x**S(2) + S(1)), x), x) + Dist(a + b*atanh(c*x), u, x) rule422 = ReplacementRule(pattern422, lambda x, b, m, g, c, f, a, d, e : With422(x, b, m, g, c, f, a, d, e)) rubi.add(rule422) pattern423 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))*(WC('d', S(0)) + WC('e', S(1))*log(x_**S(2)*WC('g', S(1)) + WC('f', S(0)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda g, x: FreeQ(g, x)), CustomConstraint(lambda m: PositiveIntegerQ(m/S(2) + S(1)/2)), ) def With423(x, b, m, g, c, f, a, d, e): u = IntHide(x**m*(d + e*log(f + g*x**S(2))), x) return -b*c*Int(ExpandIntegrand(u/(-c**S(2)*x**S(2) + S(1)), x), x) + Dist(a + b*acoth(c*x), u, x) rule423 = ReplacementRule(pattern423, lambda x, b, m, g, c, f, a, d, e : With423(x, b, m, g, c, f, a, d, e)) rubi.add(rule423) pattern424 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))*(WC('d', S(0)) + WC('e', S(1))*log(x_**S(2)*WC('g', S(1)) + WC('f', S(0)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda g, x: FreeQ(g, x)), CustomConstraint(lambda m: IntegerQ(m)), CustomConstraint(lambda m: Unequal(m, S(-1))), ) def With424(x, b, m, g, c, f, a, d, e): u = IntHide(x**m*(a + b*atanh(c*x)), x) return -S(2)*e*g*Int(ExpandIntegrand(u*x/(f + g*x**S(2)), x), x) + Dist(d + e*log(f + g*x**S(2)), u, x) rule424 = ReplacementRule(pattern424, lambda x, b, m, g, c, f, a, d, e : With424(x, b, m, g, c, f, a, d, e)) rubi.add(rule424) pattern425 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))*(WC('d', S(0)) + WC('e', S(1))*log(x_**S(2)*WC('g', S(1)) + WC('f', S(0)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda g, x: FreeQ(g, x)), CustomConstraint(lambda m: IntegerQ(m)), CustomConstraint(lambda m: Unequal(m, S(-1))), ) def With425(x, b, m, g, c, f, a, d, e): u = IntHide(x**m*(a + b*acoth(c*x)), x) return -S(2)*e*g*Int(ExpandIntegrand(u*x/(f + g*x**S(2)), x), x) + Dist(d + e*log(f + g*x**S(2)), u, x) rule425 = ReplacementRule(pattern425, lambda x, b, m, g, c, f, a, d, e : With425(x, b, m, g, c, f, a, d, e)) rubi.add(rule425) pattern426 = Pattern(Integral(x_*(WC('a', S(0)) + WC('b', S(1))*atanh(x_*WC('c', S(1))))**S(2)*(WC('d', S(0)) + WC('e', S(1))*log(f_ + x_**S(2)*WC('g', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda g, x: FreeQ(g, x)), CustomConstraint(lambda g, c, f: ZeroQ(c**S(2)*f + g))) rule426 = ReplacementRule(pattern426, lambda x, b, g, c, f, a, d, e : b*c*e*Int(x**S(2)*(a + b*atanh(c*x))/(-c**S(2)*x**S(2) + S(1)), x) + b*Int((a + b*atanh(c*x))*(d + e*log(f + g*x**S(2))), x)/c - e*x**S(2)*(a + b*atanh(c*x))**S(2)/S(2) + (a + b*atanh(c*x))**S(2)*(d + e*log(f + g*x**S(2)))*(f + g*x**S(2))/(S(2)*g)) rubi.add(rule426) pattern427 = Pattern(Integral(x_*(WC('a', S(0)) + WC('b', S(1))*acoth(x_*WC('c', S(1))))**S(2)*(WC('d', S(0)) + WC('e', S(1))*log(f_ + x_**S(2)*WC('g', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda g, x: FreeQ(g, x)), CustomConstraint(lambda g, c, f: ZeroQ(c**S(2)*f + g))) rule427 = ReplacementRule(pattern427, lambda x, b, g, c, f, a, d, e : b*c*e*Int(x**S(2)*(a + b*acoth(c*x))/(-c**S(2)*x**S(2) + S(1)), x) + b*Int((a + b*acoth(c*x))*(d + e*log(f + g*x**S(2))), x)/c - e*x**S(2)*(a + b*acoth(c*x))**S(2)/S(2) + (a + b*acoth(c*x))**S(2)*(d + e*log(f + g*x**S(2)))*(f + g*x**S(2))/(S(2)*g)) rubi.add(rule427) pattern428 = Pattern(Integral(exp(WC('n', S(1))*atanh(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda n: OddQ(n))) rule428 = ReplacementRule(pattern428, lambda x, a, n : Int((-a*x + S(1))**(-n/S(2) + S(1)/2)*(a*x + S(1))**(n/S(2) + S(1)/2)/sqrt(-a**S(2)*x**S(2) + S(1)), x)) rubi.add(rule428) pattern429 = Pattern(Integral(x_**WC('m', S(1))*exp(WC('n', S(1))*atanh(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n: OddQ(n))) rule429 = ReplacementRule(pattern429, lambda x, a, n, m : Int(x**m*(-a*x + S(1))**(-n/S(2) + S(1)/2)*(a*x + S(1))**(n/S(2) + S(1)/2)/sqrt(-a**S(2)*x**S(2) + S(1)), x)) rubi.add(rule429) pattern430 = Pattern(Integral(exp(n_*atanh(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda n: Not(OddQ(n)))) rule430 = ReplacementRule(pattern430, lambda x, a, n : Int((-a*x + S(1))**(-n/S(2))*(a*x + S(1))**(n/S(2)), x)) rubi.add(rule430) pattern431 = Pattern(Integral(x_**WC('m', S(1))*exp(n_*atanh(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda n: Not(OddQ(n)))) rule431 = ReplacementRule(pattern431, lambda x, a, n, m : Int(x**m*(-a*x + S(1))**(-n/S(2))*(a*x + S(1))**(n/S(2)), x)) rubi.add(rule431) pattern432 = Pattern(Integral((c_ + x_*WC('d', S(1)))**WC('p', S(1))*exp(WC('n', S(1))*atanh(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, a, d: ZeroQ(a*c + d)), CustomConstraint(lambda n: IntegerQ(n/S(2) + S(-1)/2)), CustomConstraint(lambda p: IntegerQ(S(2)*p))) rule432 = ReplacementRule(pattern432, lambda p, x, c, a, d, n : c**n*Int((c + d*x)**(-n + p)*(-a**S(2)*x**S(2) + S(1))**(n/S(2)), x)) rubi.add(rule432) pattern433 = Pattern(Integral((c_ + x_*WC('d', S(1)))**WC('p', S(1))*(x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*exp(WC('n', S(1))*atanh(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, a, d: ZeroQ(a*c + d)), CustomConstraint(lambda n: IntegerQ(n/S(2) + S(-1)/2)), CustomConstraint(lambda p, n: IntegerQ(p) | ZeroQ(-n/S(2) + p) | ZeroQ(-n/S(2) + p + S(-1))), CustomConstraint(lambda p: IntegerQ(S(2)*p))) rule433 = ReplacementRule(pattern433, lambda p, x, m, f, c, a, d, e, n : c**n*Int((c + d*x)**(-n + p)*(e + f*x)**m*(-a**S(2)*x**S(2) + S(1))**(n/S(2)), x)) rubi.add(rule433) pattern434 = Pattern(Integral((c_ + x_*WC('d', S(1)))**WC('p', S(1))*WC('u', S(1))*exp(WC('n', S(1))*atanh(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, a, d: ZeroQ(a**S(2)*c**S(2) - d**S(2))), CustomConstraint(lambda c, p: IntegerQ(p) | PositiveQ(c))) rule434 = ReplacementRule(pattern434, lambda p, x, c, a, d, u, n : c**p*Int(u*(S(1) + d*x/c)**p*(-a*x + S(1))**(-n/S(2))*(a*x + S(1))**(n/S(2)), x)) rubi.add(rule434) pattern435 = Pattern(Integral((c_ + x_*WC('d', S(1)))**WC('p', S(1))*WC('u', S(1))*exp(WC('n', S(1))*atanh(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, a, d: ZeroQ(a**S(2)*c**S(2) - d**S(2))), CustomConstraint(lambda c, p: Not(IntegerQ(p) | PositiveQ(c)))) rule435 = ReplacementRule(pattern435, lambda p, x, c, a, d, u, n : Int(u*(c + d*x)**p*(-a*x + S(1))**(-n/S(2))*(a*x + S(1))**(n/S(2)), x)) rubi.add(rule435) pattern436 = Pattern(Integral((c_ + WC('d', S(1))/x_)**WC('p', S(1))*WC('u', S(1))*exp(WC('n', S(1))*atanh(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, a, d: ZeroQ(-a**S(2)*d**S(2) + c**S(2))), CustomConstraint(lambda p: IntegerQ(p))) rule436 = ReplacementRule(pattern436, lambda p, x, c, a, d, u, n : d**p*Int(u*x**(-p)*(c*x/d + S(1))**p*exp(n*atanh(a*x)), x)) rubi.add(rule436) pattern437 = Pattern(Integral((c_ + WC('d', S(1))/x_)**p_*WC('u', S(1))*exp(n_*atanh(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, a, d: ZeroQ(-a**S(2)*d**S(2) + c**S(2))), CustomConstraint(lambda p: Not(IntegerQ(p))), CustomConstraint(lambda n: IntegerQ(n/S(2))), CustomConstraint(lambda c: PositiveQ(c))) rule437 = ReplacementRule(pattern437, lambda p, x, c, a, d, u, n : (S(-1))**(n/S(2))*c**p*Int(u*(S(1) - S(1)/(a*x))**(-n/S(2))*(S(1) + S(1)/(a*x))**(n/S(2))*(S(1) + d/(c*x))**p, x)) rubi.add(rule437) pattern438 = Pattern(Integral((c_ + WC('d', S(1))/x_)**p_*WC('u', S(1))*exp(n_*atanh(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, a, d: ZeroQ(-a**S(2)*d**S(2) + c**S(2))), CustomConstraint(lambda p: Not(IntegerQ(p))), CustomConstraint(lambda n: IntegerQ(n/S(2))), CustomConstraint(lambda c: Not(PositiveQ(c)))) rule438 = ReplacementRule(pattern438, lambda p, x, c, a, d, u, n : Int(u*(c + d/x)**p*(-a*x + S(1))**(-n/S(2))*(a*x + S(1))**(n/S(2)), x)) rubi.add(rule438) pattern439 = Pattern(Integral((c_ + WC('d', S(1))/x_)**p_*WC('u', S(1))*exp(WC('n', S(1))*atanh(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, a, d: ZeroQ(-a**S(2)*d**S(2) + c**S(2))), CustomConstraint(lambda p: Not(IntegerQ(p)))) rule439 = ReplacementRule(pattern439, lambda p, x, c, a, d, u, n : x**p*(c + d/x)**p*(c*x/d + S(1))**(-p)*Int(u*x**(-p)*(c*x/d + S(1))**p*exp(n*atanh(a*x)), x)) rubi.add(rule439) pattern440 = Pattern(Integral(exp(n_*atanh(x_*WC('a', S(1))))/(c_ + x_**S(2)*WC('d', S(1)))**(S(3)/2), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, a, d: ZeroQ(a**S(2)*c + d)), CustomConstraint(lambda n: Not(IntegerQ(n)))) rule440 = ReplacementRule(pattern440, lambda x, c, a, d, n : (-a*x + n)*exp(n*atanh(a*x))/(a*c*sqrt(c + d*x**S(2))*(n**S(2) + S(-1)))) rubi.add(rule440) pattern441 = Pattern(Integral((c_ + x_**S(2)*WC('d', S(1)))**p_*exp(n_*atanh(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, a, d: ZeroQ(a**S(2)*c + d)), CustomConstraint(lambda p: RationalQ(p)), CustomConstraint(lambda p: Less(p, S(-1))), CustomConstraint(lambda n: Not(IntegerQ(n))), CustomConstraint(lambda p, n: NonzeroQ(n**S(2) - S(4)*(p + S(1))**S(2))), CustomConstraint(lambda p: IntegerQ(S(2)*p))) rule441 = ReplacementRule(pattern441, lambda p, x, c, a, d, n : -S(2)*(p + S(1))*(S(2)*p + S(3))*Int((c + d*x**S(2))**(p + S(1))*exp(n*atanh(a*x)), x)/(c*(n**S(2) - S(4)*(p + S(1))**S(2))) + (c + d*x**S(2))**(p + S(1))*(S(2)*a*x*(p + S(1)) + n)*exp(n*atanh(a*x))/(a*c*(n**S(2) - S(4)*(p + S(1))**S(2)))) rubi.add(rule441) pattern442 = Pattern(Integral(exp(WC('n', S(1))*atanh(x_*WC('a', S(1))))/(c_ + x_**S(2)*WC('d', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, a, d: ZeroQ(a**S(2)*c + d)), CustomConstraint(lambda n: Not(IntegerQ(n/S(2))))) rule442 = ReplacementRule(pattern442, lambda x, c, a, d, n : exp(n*atanh(a*x))/(a*c*n)) rubi.add(rule442) pattern443 = Pattern(Integral((c_ + x_**S(2)*WC('d', S(1)))**WC('p', S(1))*exp(WC('n', S(1))*atanh(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, a, d: ZeroQ(a**S(2)*c + d)), CustomConstraint(lambda p: IntegerQ(p)), CustomConstraint(lambda n: PositiveIntegerQ(n/S(2) + S(1)/2)), CustomConstraint(lambda p, n: Not(IntegerQ(-n/S(2) + p)))) rule443 = ReplacementRule(pattern443, lambda p, x, c, a, d, n : c**p*Int((a*x + S(1))**n*(-a**S(2)*x**S(2) + S(1))**(-n/S(2) + p), x)) rubi.add(rule443) pattern444 = Pattern(Integral((c_ + x_**S(2)*WC('d', S(1)))**WC('p', S(1))*exp(n_*atanh(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, a, d: ZeroQ(a**S(2)*c + d)), CustomConstraint(lambda p: IntegerQ(p)), CustomConstraint(lambda n: NegativeIntegerQ(n/S(2) + S(-1)/2)), CustomConstraint(lambda p, n: Not(IntegerQ(-n/S(2) + p)))) rule444 = ReplacementRule(pattern444, lambda p, x, c, a, d, n : c**p*Int((-a*x + S(1))**(-n)*(-a**S(2)*x**S(2) + S(1))**(n/S(2) + p), x)) rubi.add(rule444) pattern445 = Pattern(Integral((c_ + x_**S(2)*WC('d', S(1)))**WC('p', S(1))*exp(WC('n', S(1))*atanh(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, a, d: ZeroQ(a**S(2)*c + d)), CustomConstraint(lambda c, p: IntegerQ(p) | PositiveQ(c))) rule445 = ReplacementRule(pattern445, lambda p, x, c, a, d, n : c**p*Int((-a*x + S(1))**(-n/S(2) + p)*(a*x + S(1))**(n/S(2) + p), x)) rubi.add(rule445) pattern446 = Pattern(Integral((c_ + x_**S(2)*WC('d', S(1)))**WC('p', S(1))*exp(n_*atanh(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, a, d: ZeroQ(a**S(2)*c + d)), CustomConstraint(lambda c, p: Not(IntegerQ(p) | PositiveQ(c))), CustomConstraint(lambda n: PositiveIntegerQ(n/S(2)))) rule446 = ReplacementRule(pattern446, lambda p, x, c, a, d, n : c**(n/S(2))*Int((c + d*x**S(2))**(-n/S(2) + p)*(a*x + S(1))**n, x)) rubi.add(rule446) pattern447 = Pattern(Integral((c_ + x_**S(2)*WC('d', S(1)))**WC('p', S(1))*exp(n_*atanh(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, a, d: ZeroQ(a**S(2)*c + d)), CustomConstraint(lambda c, p: Not(IntegerQ(p) | PositiveQ(c))), CustomConstraint(lambda n: NegativeIntegerQ(n/S(2)))) rule447 = ReplacementRule(pattern447, lambda p, x, c, a, d, n : c**(-n/S(2))*Int((c + d*x**S(2))**(n/S(2) + p)*(-a*x + S(1))**(-n), x)) rubi.add(rule447) pattern448 = Pattern(Integral((c_ + x_**S(2)*WC('d', S(1)))**p_*exp(WC('n', S(1))*atanh(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, a, d: ZeroQ(a**S(2)*c + d)), CustomConstraint(lambda c, p: Not(IntegerQ(p) | PositiveQ(c)))) rule448 = ReplacementRule(pattern448, lambda p, x, c, a, d, n : c**IntPart(p)*(c + d*x**S(2))**FracPart(p)*(-a**S(2)*x**S(2) + S(1))**(-FracPart(p))*Int((-a**S(2)*x**S(2) + S(1))**p*exp(n*atanh(a*x)), x)) rubi.add(rule448) pattern449 = Pattern(Integral(x_*exp(n_*atanh(x_*WC('a', S(1))))/(c_ + x_**S(2)*WC('d', S(1)))**(S(3)/2), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, a, d: ZeroQ(a**S(2)*c + d)), CustomConstraint(lambda n: Not(IntegerQ(n)))) rule449 = ReplacementRule(pattern449, lambda x, c, a, d, n : (-a*n*x + S(1))*exp(n*atanh(a*x))/(d*sqrt(c + d*x**S(2))*(n**S(2) + S(-1)))) rubi.add(rule449) pattern450 = Pattern(Integral(x_*(c_ + x_**S(2)*WC('d', S(1)))**p_*exp(n_*atanh(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, a, d: ZeroQ(a**S(2)*c + d)), CustomConstraint(lambda p: RationalQ(p)), CustomConstraint(lambda p: Less(p, S(-1))), CustomConstraint(lambda n: Not(IntegerQ(n))), CustomConstraint(lambda p: IntegerQ(S(2)*p))) rule450 = ReplacementRule(pattern450, lambda p, x, c, a, d, n : -a*c*n*Int((c + d*x**S(2))**p*exp(n*atanh(a*x)), x)/(S(2)*d*(p + S(1))) + (c + d*x**S(2))**(p + S(1))*exp(n*atanh(a*x))/(S(2)*d*(p + S(1)))) rubi.add(rule450) pattern451 = Pattern(Integral(x_**S(2)*(c_ + x_**S(2)*WC('d', S(1)))**WC('p', S(1))*exp(n_*atanh(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, a, d: ZeroQ(a**S(2)*c + d)), CustomConstraint(lambda p, n: ZeroQ(n**S(2) + S(2)*p + S(2))), CustomConstraint(lambda n: Not(IntegerQ(n)))) rule451 = ReplacementRule(pattern451, lambda p, x, c, a, d, n : (c + d*x**S(2))**(p + S(1))*(-a*n*x + S(1))*exp(n*atanh(a*x))/(a*d*n*(n**S(2) + S(-1)))) rubi.add(rule451) pattern452 = Pattern(Integral(x_**S(2)*(c_ + x_**S(2)*WC('d', S(1)))**p_*exp(n_*atanh(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, a, d: ZeroQ(a**S(2)*c + d)), CustomConstraint(lambda p: RationalQ(p)), CustomConstraint(lambda p: Less(p, S(-1))), CustomConstraint(lambda n: Not(IntegerQ(n))), CustomConstraint(lambda p, n: NonzeroQ(n**S(2) - S(4)*(p + S(1))**S(2))), CustomConstraint(lambda p: IntegerQ(S(2)*p))) rule452 = ReplacementRule(pattern452, lambda p, x, c, a, d, n : (n**S(2) + S(2)*p + S(2))*Int((c + d*x**S(2))**(p + S(1))*exp(n*atanh(a*x)), x)/(d*(n**S(2) - S(4)*(p + S(1))**S(2))) + (c + d*x**S(2))**(p + S(1))*(-S(2)*a*x*(p + S(1)) - n)*exp(n*atanh(a*x))/(a*d*(n**S(2) - S(4)*(p + S(1))**S(2)))) rubi.add(rule452) pattern453 = Pattern(Integral(x_**WC('m', S(1))*(c_ + x_**S(2)*WC('d', S(1)))**WC('p', S(1))*exp(WC('n', S(1))*atanh(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, a, d: ZeroQ(a**S(2)*c + d)), CustomConstraint(lambda c, p: IntegerQ(p) | PositiveQ(c)), CustomConstraint(lambda n: PositiveIntegerQ(n/S(2) + S(1)/2)), CustomConstraint(lambda p, n: Not(IntegerQ(-n/S(2) + p)))) rule453 = ReplacementRule(pattern453, lambda p, x, m, c, a, d, n : c**p*Int(x**m*(a*x + S(1))**n*(-a**S(2)*x**S(2) + S(1))**(-n/S(2) + p), x)) rubi.add(rule453) pattern454 = Pattern(Integral(x_**WC('m', S(1))*(c_ + x_**S(2)*WC('d', S(1)))**WC('p', S(1))*exp(n_*atanh(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, a, d: ZeroQ(a**S(2)*c + d)), CustomConstraint(lambda c, p: IntegerQ(p) | PositiveQ(c)), CustomConstraint(lambda n: NegativeIntegerQ(n/S(2) + S(-1)/2)), CustomConstraint(lambda p, n: Not(IntegerQ(-n/S(2) + p)))) rule454 = ReplacementRule(pattern454, lambda p, x, m, c, a, d, n : c**p*Int(x**m*(-a*x + S(1))**(-n)*(-a**S(2)*x**S(2) + S(1))**(n/S(2) + p), x)) rubi.add(rule454) pattern455 = Pattern(Integral(x_**WC('m', S(1))*(c_ + x_**S(2)*WC('d', S(1)))**WC('p', S(1))*exp(WC('n', S(1))*atanh(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, a, d: ZeroQ(a**S(2)*c + d)), CustomConstraint(lambda c, p: IntegerQ(p) | PositiveQ(c))) rule455 = ReplacementRule(pattern455, lambda p, x, m, c, a, d, n : c**p*Int(x**m*(-a*x + S(1))**(-n/S(2) + p)*(a*x + S(1))**(n/S(2) + p), x)) rubi.add(rule455) pattern456 = Pattern(Integral(x_**WC('m', S(1))*(c_ + x_**S(2)*WC('d', S(1)))**WC('p', S(1))*exp(n_*atanh(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, a, d: ZeroQ(a**S(2)*c + d)), CustomConstraint(lambda c, p: Not(IntegerQ(p) | PositiveQ(c))), CustomConstraint(lambda n: PositiveIntegerQ(n/S(2)))) rule456 = ReplacementRule(pattern456, lambda p, x, m, c, a, d, n : c**(n/S(2))*Int(x**m*(c + d*x**S(2))**(-n/S(2) + p)*(a*x + S(1))**n, x)) rubi.add(rule456) pattern457 = Pattern(Integral(x_**WC('m', S(1))*(c_ + x_**S(2)*WC('d', S(1)))**WC('p', S(1))*exp(n_*atanh(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, a, d: ZeroQ(a**S(2)*c + d)), CustomConstraint(lambda c, p: Not(IntegerQ(p) | PositiveQ(c))), CustomConstraint(lambda n: NegativeIntegerQ(n/S(2)))) rule457 = ReplacementRule(pattern457, lambda p, x, m, c, a, d, n : c**(-n/S(2))*Int(x**m*(c + d*x**S(2))**(n/S(2) + p)*(-a*x + S(1))**(-n), x)) rubi.add(rule457) pattern458 = Pattern(Integral(x_**WC('m', S(1))*(c_ + x_**S(2)*WC('d', S(1)))**p_*exp(WC('n', S(1))*atanh(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, a, d: ZeroQ(a**S(2)*c + d)), CustomConstraint(lambda c, p: Not(IntegerQ(p) | PositiveQ(c))), CustomConstraint(lambda n: Not(IntegerQ(n/S(2))))) rule458 = ReplacementRule(pattern458, lambda p, x, m, c, a, d, n : c**IntPart(p)*(c + d*x**S(2))**FracPart(p)*(-a**S(2)*x**S(2) + S(1))**(-FracPart(p))*Int(x**m*(-a**S(2)*x**S(2) + S(1))**p*exp(n*atanh(a*x)), x)) rubi.add(rule458) pattern459 = Pattern(Integral(u_*(c_ + x_**S(2)*WC('d', S(1)))**WC('p', S(1))*exp(WC('n', S(1))*atanh(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, a, d: ZeroQ(a**S(2)*c + d)), CustomConstraint(lambda c, p: IntegerQ(p) | PositiveQ(c))) rule459 = ReplacementRule(pattern459, lambda p, x, c, a, d, u, n : c**p*Int(u*(-a*x + S(1))**(-n/S(2) + p)*(a*x + S(1))**(n/S(2) + p), x)) rubi.add(rule459) pattern460 = Pattern(Integral(u_*(c_ + x_**S(2)*WC('d', S(1)))**p_*exp(n_*atanh(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, a, d: ZeroQ(a**S(2)*c + d)), CustomConstraint(lambda c, p: Not(IntegerQ(p) | PositiveQ(c))), CustomConstraint(lambda n: IntegerQ(n/S(2)))) rule460 = ReplacementRule(pattern460, lambda p, x, c, a, d, u, n : c**IntPart(p)*(c + d*x**S(2))**FracPart(p)*(-a*x + S(1))**(-FracPart(p))*(a*x + S(1))**(-FracPart(p))*Int(u*(-a*x + S(1))**(-n/S(2) + p)*(a*x + S(1))**(n/S(2) + p), x)) rubi.add(rule460) pattern461 = Pattern(Integral(u_*(c_ + x_**S(2)*WC('d', S(1)))**p_*exp(WC('n', S(1))*atanh(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, a, d: ZeroQ(a**S(2)*c + d)), CustomConstraint(lambda c, p: Not(IntegerQ(p) | PositiveQ(c))), CustomConstraint(lambda n: Not(IntegerQ(n/S(2))))) rule461 = ReplacementRule(pattern461, lambda p, x, c, a, d, u, n : c**IntPart(p)*(c + d*x**S(2))**FracPart(p)*(-a**S(2)*x**S(2) + S(1))**(-FracPart(p))*Int(u*(-a**S(2)*x**S(2) + S(1))**p*exp(n*atanh(a*x)), x)) rubi.add(rule461) pattern462 = Pattern(Integral((c_ + WC('d', S(1))/x_**S(2))**WC('p', S(1))*WC('u', S(1))*exp(WC('n', S(1))*atanh(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, a, d: ZeroQ(a**S(2)*d + c)), CustomConstraint(lambda p: IntegerQ(p))) rule462 = ReplacementRule(pattern462, lambda p, x, c, a, d, u, n : d**p*Int(u*x**(-S(2)*p)*(-a**S(2)*x**S(2) + S(1))**p*exp(n*atanh(a*x)), x)) rubi.add(rule462) pattern463 = Pattern(Integral((c_ + WC('d', S(1))/x_**S(2))**p_*WC('u', S(1))*exp(n_*atanh(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, a, d: ZeroQ(a**S(2)*d + c)), CustomConstraint(lambda p: Not(IntegerQ(p))), CustomConstraint(lambda n: IntegerQ(n/S(2))), CustomConstraint(lambda c: PositiveQ(c))) rule463 = ReplacementRule(pattern463, lambda p, x, c, a, d, u, n : c**p*Int(u*(S(1) - S(1)/(a*x))**p*(S(1) + S(1)/(a*x))**p*exp(n*atanh(a*x)), x)) rubi.add(rule463) pattern464 = Pattern(Integral((c_ + WC('d', S(1))/x_**S(2))**p_*WC('u', S(1))*exp(n_*atanh(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, a, d: ZeroQ(a**S(2)*d + c)), CustomConstraint(lambda p: Not(IntegerQ(p))), CustomConstraint(lambda n: IntegerQ(n/S(2))), CustomConstraint(lambda c: Not(PositiveQ(c)))) rule464 = ReplacementRule(pattern464, lambda p, x, c, a, d, u, n : x**(S(2)*p)*(c + d/x**S(2))**p*(-a*x + S(1))**(-p)*(a*x + S(1))**(-p)*Int(u*x**(-S(2)*p)*(-a*x + S(1))**p*(a*x + S(1))**p*exp(n*atanh(a*x)), x)) rubi.add(rule464) pattern465 = Pattern(Integral((c_ + WC('d', S(1))/x_**S(2))**p_*WC('u', S(1))*exp(WC('n', S(1))*atanh(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, a, d: ZeroQ(a**S(2)*d + c)), CustomConstraint(lambda p: Not(IntegerQ(p))), CustomConstraint(lambda n: Not(IntegerQ(n/S(2))))) rule465 = ReplacementRule(pattern465, lambda p, x, c, a, d, u, n : x**(S(2)*p)*(c + d/x**S(2))**p*(c*x**S(2)/d + S(1))**(-p)*Int(u*x**(-S(2)*p)*(c*x**S(2)/d + S(1))**p*exp(n*atanh(a*x)), x)) rubi.add(rule465) pattern466 = Pattern(Integral(exp(WC('n', S(1))*atanh((a_ + x_*WC('b', S(1)))*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda n, x: FreeQ(n, x))) rule466 = ReplacementRule(pattern466, lambda x, b, c, a, n : Int((-a*c - b*c*x + S(1))**(-n/S(2))*(a*c + b*c*x + S(1))**(n/S(2)), x)) rubi.add(rule466) pattern467 = Pattern(Integral(x_**m_*exp(n_*atanh((a_ + x_*WC('b', S(1)))*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda m: NegativeIntegerQ(m)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Less(S(-1), n, S(1)))) rule467 = ReplacementRule(pattern467, lambda x, b, m, c, a, n : S(4)*b**(-m + S(-1))*c**(-m + S(-1))*Subst(Int(x**(S(2)/n)*(x**(S(2)/n) + S(1))**(-m + S(-2))*(-a*c + x**(S(2)/n)*(-a*c + S(1)) + S(-1))**m, x), x, (-c*(a + b*x) + S(1))**(-n/S(2))*(c*(a + b*x) + S(1))**(n/S(2)))/n) rubi.add(rule467) pattern468 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*exp(WC('n', S(1))*atanh((a_ + x_*WC('b', S(1)))*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n, x: FreeQ(n, x))) rule468 = ReplacementRule(pattern468, lambda x, b, m, c, a, d, e, n : Int((d + e*x)**m*(-a*c - b*c*x + S(1))**(-n/S(2))*(a*c + b*c*x + S(1))**(n/S(2)), x)) rubi.add(rule468) pattern469 = Pattern(Integral((c_ + x_**S(2)*WC('e', S(1)) + x_*WC('d', S(1)))**WC('p', S(1))*WC('u', S(1))*exp(WC('n', S(1))*atanh(a_ + x_*WC('b', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda e, a, d, b: ZeroQ(-S(2)*a*e + b*d)), CustomConstraint(lambda c, a, e, b: ZeroQ(b**S(2)*c + e*(-a**S(2) + S(1)))), CustomConstraint(lambda c, a, p: IntegerQ(p) | PositiveQ(c/(-a**S(2) + S(1))))) rule469 = ReplacementRule(pattern469, lambda p, x, b, c, a, d, u, e, n : (c/(-a**S(2) + S(1)))**p*Int(u*(-a - b*x + S(1))**(-n/S(2) + p)*(a + b*x + S(1))**(n/S(2) + p), x)) rubi.add(rule469) pattern470 = Pattern(Integral((c_ + x_**S(2)*WC('e', S(1)) + x_*WC('d', S(1)))**WC('p', S(1))*WC('u', S(1))*exp(WC('n', S(1))*atanh(a_ + x_*WC('b', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda e, a, d, b: ZeroQ(-S(2)*a*e + b*d)), CustomConstraint(lambda c, a, e, b: ZeroQ(b**S(2)*c + e*(-a**S(2) + S(1)))), CustomConstraint(lambda c, a, p: Not(IntegerQ(p) | PositiveQ(c/(-a**S(2) + S(1)))))) rule470 = ReplacementRule(pattern470, lambda p, x, b, c, a, d, u, e, n : (c + d*x + e*x**S(2))**p*(-a**S(2) - S(2)*a*b*x - b**S(2)*x**S(2) + S(1))**(-p)*Int(u*(-a**S(2) - S(2)*a*b*x - b**S(2)*x**S(2) + S(1))**p*exp(n*atanh(a*x)), x)) rubi.add(rule470) pattern471 = Pattern(Integral(WC('u', S(1))*exp(WC('n', S(1))*atanh(WC('c', S(1))/(x_*WC('b', S(1)) + WC('a', S(0))))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda n, x: FreeQ(n, x))) rule471 = ReplacementRule(pattern471, lambda x, b, c, a, u, n : Int(u*exp(n*acoth(a/c + b*x/c)), x)) rubi.add(rule471) pattern472 = Pattern(Integral(WC('u', S(1))*exp(n_*acoth(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda n: IntegerQ(n/S(2)))) rule472 = ReplacementRule(pattern472, lambda x, u, a, n : (S(-1))**(n/S(2))*Int(u*exp(n*atanh(a*x)), x)) rubi.add(rule472) pattern473 = Pattern(Integral(exp(WC('n', S(1))*acoth(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda n: OddQ(n))) rule473 = ReplacementRule(pattern473, lambda x, a, n : -Subst(Int((S(1) - x/a)**(-n/S(2) + S(1)/2)*(S(1) + x/a)**(n/S(2) + S(1)/2)/(x**S(2)*sqrt(S(1) - x**S(2)/a**S(2))), x), x, 1/x)) rubi.add(rule473) pattern474 = Pattern(Integral(x_**WC('m', S(1))*exp(WC('n', S(1))*acoth(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda n: OddQ(n)), CustomConstraint(lambda m: IntegerQ(m))) rule474 = ReplacementRule(pattern474, lambda x, a, n, m : -Subst(Int(x**(-m + S(-2))*(S(1) - x/a)**(-n/S(2) + S(1)/2)*(S(1) + x/a)**(n/S(2) + S(1)/2)/sqrt(S(1) - x**S(2)/a**S(2)), x), x, 1/x)) rubi.add(rule474) pattern475 = Pattern(Integral(exp(n_*acoth(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda n: Not(IntegerQ(n)))) rule475 = ReplacementRule(pattern475, lambda x, a, n : -Subst(Int((S(1) - x/a)**(-n/S(2))*(S(1) + x/a)**(n/S(2))/x**S(2), x), x, 1/x)) rubi.add(rule475) pattern476 = Pattern(Integral(x_**WC('m', S(1))*exp(n_*acoth(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda n: Not(IntegerQ(n))), CustomConstraint(lambda m: IntegerQ(m))) rule476 = ReplacementRule(pattern476, lambda x, a, n, m : -Subst(Int(x**(-m + S(-2))*(S(1) - x/a)**(-n/S(2))*(S(1) + x/a)**(n/S(2)), x), x, 1/x)) rubi.add(rule476) pattern477 = Pattern(Integral(x_**m_*exp(WC('n', S(1))*acoth(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n: OddQ(n)), CustomConstraint(lambda m: Not(IntegerQ(m)))) rule477 = ReplacementRule(pattern477, lambda x, a, n, m : -x**m*(1/x)**m*Subst(Int(x**(-m + S(-2))*(S(1) - x/a)**(-n/S(2) + S(1)/2)*(S(1) + x/a)**(n/S(2) + S(1)/2)/sqrt(S(1) - x**S(2)/a**S(2)), x), x, 1/x)) rubi.add(rule477) pattern478 = Pattern(Integral(x_**m_*exp(n_*acoth(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda n: Not(IntegerQ(n))), CustomConstraint(lambda m: Not(IntegerQ(m)))) rule478 = ReplacementRule(pattern478, lambda x, a, n, m : -x**m*(1/x)**m*Subst(Int(x**(-m + S(-2))*(S(1) - x/a)**(-n/S(2))*(S(1) + x/a)**(n/S(2)), x), x, 1/x)) rubi.add(rule478) pattern479 = Pattern(Integral((c_ + x_*WC('d', S(1)))**WC('p', S(1))*exp(WC('n', S(1))*acoth(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, a, d: ZeroQ(a*c + d)), CustomConstraint(lambda p, n: ZeroQ(-n/S(2) + p)), CustomConstraint(lambda n: Not(IntegerQ(n/S(2))))) rule479 = ReplacementRule(pattern479, lambda p, x, c, a, d, n : (c + d*x)**p*(a*x + S(1))*exp(n*acoth(a*x))/(a*(p + S(1)))) rubi.add(rule479) pattern480 = Pattern(Integral((c_ + x_*WC('d', S(1)))**WC('p', S(1))*WC('u', S(1))*exp(WC('n', S(1))*acoth(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, a, d: ZeroQ(a**S(2)*c**S(2) - d**S(2))), CustomConstraint(lambda n: Not(IntegerQ(n/S(2)))), CustomConstraint(lambda p: IntegerQ(p))) rule480 = ReplacementRule(pattern480, lambda p, x, c, a, d, u, n : d**p*Int(u*x**p*(c/(d*x) + S(1))**p*exp(n*acoth(a*x)), x)) rubi.add(rule480) pattern481 = Pattern(Integral((c_ + x_*WC('d', S(1)))**p_*WC('u', S(1))*exp(WC('n', S(1))*acoth(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, a, d: ZeroQ(a**S(2)*c**S(2) - d**S(2))), CustomConstraint(lambda n: Not(IntegerQ(n/S(2)))), CustomConstraint(lambda p: Not(IntegerQ(p)))) rule481 = ReplacementRule(pattern481, lambda p, x, c, a, d, u, n : x**(-p)*(c + d*x)**p*(c/(d*x) + S(1))**(-p)*Int(u*x**p*(c/(d*x) + S(1))**p*exp(n*acoth(a*x)), x)) rubi.add(rule481) pattern482 = Pattern(Integral((c_ + WC('d', S(1))/x_)**WC('p', S(1))*exp(WC('n', S(1))*acoth(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, a, d: ZeroQ(a*d + c)), CustomConstraint(lambda n: IntegerQ(n/S(2) + S(-1)/2)), CustomConstraint(lambda p, n: IntegerQ(p) | ZeroQ(-n/S(2) + p) | ZeroQ(-n/S(2) + p + S(-1))), CustomConstraint(lambda p: IntegerQ(S(2)*p))) rule482 = ReplacementRule(pattern482, lambda p, x, c, a, d, n : -c**n*Subst(Int((S(1) - x**S(2)/a**S(2))**(n/S(2))*(c + d*x)**(-n + p)/x**S(2), x), x, 1/x)) rubi.add(rule482) pattern483 = Pattern(Integral(x_**WC('m', S(1))*(c_ + WC('d', S(1))/x_)**WC('p', S(1))*exp(WC('n', S(1))*acoth(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, a, d: ZeroQ(a*d + c)), CustomConstraint(lambda n: IntegerQ(n/S(2) + S(-1)/2)), CustomConstraint(lambda m: IntegerQ(m)), CustomConstraint(lambda p, n, m: IntegerQ(p) | Less(S(-5), m, S(-1)) | ZeroQ(-n/S(2) + p) | ZeroQ(-n/S(2) + p + S(-1))), CustomConstraint(lambda p: IntegerQ(S(2)*p))) rule483 = ReplacementRule(pattern483, lambda p, x, m, c, a, d, n : -c**n*Subst(Int(x**(-m + S(-2))*(S(1) - x**S(2)/a**S(2))**(n/S(2))*(c + d*x)**(-n + p), x), x, 1/x)) rubi.add(rule483) pattern484 = Pattern(Integral((c_ + WC('d', S(1))/x_)**WC('p', S(1))*exp(WC('n', S(1))*acoth(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, a, d: ZeroQ(-a**S(2)*d**S(2) + c**S(2))), CustomConstraint(lambda n: Not(IntegerQ(n/S(2)))), CustomConstraint(lambda c, p: IntegerQ(p) | PositiveQ(c))) rule484 = ReplacementRule(pattern484, lambda p, x, c, a, d, n : -c**p*Subst(Int((S(1) - x/a)**(-n/S(2))*(S(1) + x/a)**(n/S(2))*(S(1) + d*x/c)**p/x**S(2), x), x, 1/x)) rubi.add(rule484) pattern485 = Pattern(Integral(x_**WC('m', S(1))*(c_ + WC('d', S(1))/x_)**WC('p', S(1))*exp(WC('n', S(1))*acoth(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, a, d: ZeroQ(-a**S(2)*d**S(2) + c**S(2))), CustomConstraint(lambda n: Not(IntegerQ(n/S(2)))), CustomConstraint(lambda c, p: IntegerQ(p) | PositiveQ(c)), CustomConstraint(lambda m: IntegerQ(m))) rule485 = ReplacementRule(pattern485, lambda p, x, m, c, a, d, n : -c**p*Subst(Int(x**(-m + S(-2))*(S(1) - x/a)**(-n/S(2))*(S(1) + x/a)**(n/S(2))*(S(1) + d*x/c)**p, x), x, 1/x)) rubi.add(rule485) pattern486 = Pattern(Integral(x_**m_*(c_ + WC('d', S(1))/x_)**WC('p', S(1))*exp(WC('n', S(1))*acoth(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, a, d: ZeroQ(-a**S(2)*d**S(2) + c**S(2))), CustomConstraint(lambda n: Not(IntegerQ(n/S(2)))), CustomConstraint(lambda c, p: IntegerQ(p) | PositiveQ(c)), CustomConstraint(lambda m: Not(IntegerQ(m)))) rule486 = ReplacementRule(pattern486, lambda p, x, m, c, a, d, n : -c**p*x**m*(1/x)**m*Subst(Int(x**(-m + S(-2))*(S(1) - x/a)**(-n/S(2))*(S(1) + x/a)**(n/S(2))*(S(1) + d*x/c)**p, x), x, 1/x)) rubi.add(rule486) pattern487 = Pattern(Integral((c_ + WC('d', S(1))/x_)**p_*WC('u', S(1))*exp(WC('n', S(1))*acoth(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, a, d: ZeroQ(-a**S(2)*d**S(2) + c**S(2))), CustomConstraint(lambda n: Not(IntegerQ(n/S(2)))), CustomConstraint(lambda c, p: Not(IntegerQ(p) | PositiveQ(c)))) rule487 = ReplacementRule(pattern487, lambda p, x, c, a, d, u, n : (S(1) + d/(c*x))**(-p)*(c + d/x)**p*Int(u*(S(1) + d/(c*x))**p*exp(n*acoth(a*x)), x)) rubi.add(rule487) pattern488 = Pattern(Integral(exp(WC('n', S(1))*acoth(x_*WC('a', S(1))))/(c_ + x_**S(2)*WC('d', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, a, d: ZeroQ(a**S(2)*c + d)), CustomConstraint(lambda n: Not(IntegerQ(n/S(2))))) rule488 = ReplacementRule(pattern488, lambda x, c, a, d, n : exp(n*acoth(a*x))/(a*c*n)) rubi.add(rule488) pattern489 = Pattern(Integral(exp(n_*acoth(x_*WC('a', S(1))))/(c_ + x_**S(2)*WC('d', S(1)))**(S(3)/2), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, a, d: ZeroQ(a**S(2)*c + d)), CustomConstraint(lambda n: Not(IntegerQ(n)))) rule489 = ReplacementRule(pattern489, lambda x, c, a, d, n : (-a*x + n)*exp(n*acoth(a*x))/(a*c*sqrt(c + d*x**S(2))*(n**S(2) + S(-1)))) rubi.add(rule489) pattern490 = Pattern(Integral((c_ + x_**S(2)*WC('d', S(1)))**p_*exp(WC('n', S(1))*acoth(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, a, d: ZeroQ(a**S(2)*c + d)), CustomConstraint(lambda n: Not(IntegerQ(n/S(2)))), CustomConstraint(lambda p: RationalQ(p)), CustomConstraint(lambda p: Less(p, S(-1))), CustomConstraint(lambda p: Unequal(p, S(-3)/2)), CustomConstraint(lambda p, n: NonzeroQ(n**S(2) - S(4)*(p + S(1))**S(2))), CustomConstraint(lambda p, n: IntegerQ(p) | Not(IntegerQ(n)))) rule490 = ReplacementRule(pattern490, lambda p, x, c, a, d, n : -S(2)*(p + S(1))*(S(2)*p + S(3))*Int((c + d*x**S(2))**(p + S(1))*exp(n*acoth(a*x)), x)/(c*(n**S(2) - S(4)*(p + S(1))**S(2))) + (c + d*x**S(2))**(p + S(1))*(S(2)*a*x*(p + S(1)) + n)*exp(n*acoth(a*x))/(a*c*(n**S(2) - S(4)*(p + S(1))**S(2)))) rubi.add(rule490) pattern491 = Pattern(Integral(x_*exp(n_*acoth(x_*WC('a', S(1))))/(c_ + x_**S(2)*WC('d', S(1)))**(S(3)/2), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, a, d: ZeroQ(a**S(2)*c + d)), CustomConstraint(lambda n: Not(IntegerQ(n)))) rule491 = ReplacementRule(pattern491, lambda x, c, a, d, n : (a*n*x + S(-1))*exp(n*acoth(a*x))/(a**S(2)*c*sqrt(c + d*x**S(2))*(n**S(2) + S(-1)))) rubi.add(rule491) pattern492 = Pattern(Integral(x_*(c_ + x_**S(2)*WC('d', S(1)))**p_*exp(WC('n', S(1))*acoth(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, a, d: ZeroQ(a**S(2)*c + d)), CustomConstraint(lambda n: Not(IntegerQ(n/S(2)))), CustomConstraint(lambda p: RationalQ(p)), CustomConstraint(lambda p: LessEqual(p, S(-1))), CustomConstraint(lambda p: Unequal(p, S(-3)/2)), CustomConstraint(lambda p, n: NonzeroQ(n**S(2) - S(4)*(p + S(1))**S(2))), CustomConstraint(lambda p, n: IntegerQ(p) | Not(IntegerQ(n)))) rule492 = ReplacementRule(pattern492, lambda p, x, c, a, d, n : -n*(S(2)*p + S(3))*Int((c + d*x**S(2))**(p + S(1))*exp(n*acoth(a*x)), x)/(a*c*(n**S(2) - S(4)*(p + S(1))**S(2))) + (c + d*x**S(2))**(p + S(1))*(a*n*x + S(2)*p + S(2))*exp(n*acoth(a*x))/(a**S(2)*c*(n**S(2) - S(4)*(p + S(1))**S(2)))) rubi.add(rule492) pattern493 = Pattern(Integral(x_**S(2)*(c_ + x_**S(2)*WC('d', S(1)))**WC('p', S(1))*exp(WC('n', S(1))*acoth(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, a, d: ZeroQ(a**S(2)*c + d)), CustomConstraint(lambda n: Not(IntegerQ(n/S(2)))), CustomConstraint(lambda p, n: ZeroQ(n**S(2) + S(2)*p + S(2))), CustomConstraint(lambda n: NonzeroQ(n**S(2) + S(-1)))) rule493 = ReplacementRule(pattern493, lambda p, x, c, a, d, n : (c + d*x**S(2))**(p + S(1))*(-S(2)*a*x*(p + S(1)) - n)*exp(n*acoth(a*x))/(a**S(3)*c*n**S(2)*(n**S(2) + S(-1)))) rubi.add(rule493) pattern494 = Pattern(Integral(x_**S(2)*(c_ + x_**S(2)*WC('d', S(1)))**p_*exp(WC('n', S(1))*acoth(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, a, d: ZeroQ(a**S(2)*c + d)), CustomConstraint(lambda n: Not(IntegerQ(n/S(2)))), CustomConstraint(lambda p: RationalQ(p)), CustomConstraint(lambda p: LessEqual(p, S(-1))), CustomConstraint(lambda p, n: NonzeroQ(n**S(2) + S(2)*p + S(2))), CustomConstraint(lambda p, n: NonzeroQ(n**S(2) - S(4)*(p + S(1))**S(2))), CustomConstraint(lambda p, n: IntegerQ(p) | Not(IntegerQ(n)))) rule494 = ReplacementRule(pattern494, lambda p, x, c, a, d, n : -(n**S(2) + S(2)*p + S(2))*Int((c + d*x**S(2))**(p + S(1))*exp(n*acoth(a*x)), x)/(a**S(2)*c*(n**S(2) - S(4)*(p + S(1))**S(2))) + (c + d*x**S(2))**(p + S(1))*(S(2)*a*x*(p + S(1)) + n)*exp(n*acoth(a*x))/(a**S(3)*c*(n**S(2) - S(4)*(p + S(1))**S(2)))) rubi.add(rule494) pattern495 = Pattern(Integral(x_**WC('m', S(1))*(c_ + x_**S(2)*WC('d', S(1)))**p_*exp(WC('n', S(1))*acoth(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, a, d: ZeroQ(a**S(2)*c + d)), CustomConstraint(lambda n: Not(IntegerQ(n/S(2)))), CustomConstraint(lambda m: IntegerQ(m)), CustomConstraint(lambda p: RationalQ(p)), CustomConstraint(lambda p, m: LessEqual(S(3), m, -S(2)*p + S(-2))), CustomConstraint(lambda p: IntegerQ(p))) rule495 = ReplacementRule(pattern495, lambda p, x, m, c, a, d, n : -a**(-m + S(-1))*(-c)**p*Subst(Int(Cosh(x)**(-S(2)*p + S(-2))*exp(n*x)*coth(x)**(m + S(2)*p + S(2)), x), x, acoth(a*x))) rubi.add(rule495) pattern496 = Pattern(Integral((c_ + x_**S(2)*WC('d', S(1)))**WC('p', S(1))*WC('u', S(1))*exp(WC('n', S(1))*acoth(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, a, d: ZeroQ(a**S(2)*c + d)), CustomConstraint(lambda n: Not(IntegerQ(n/S(2)))), CustomConstraint(lambda p: IntegerQ(p))) rule496 = ReplacementRule(pattern496, lambda p, x, c, a, d, u, n : d**p*Int(u*x**(S(2)*p)*(S(1) - S(1)/(a**S(2)*x**S(2)))**p*exp(n*acoth(a*x)), x)) rubi.add(rule496) pattern497 = Pattern(Integral((c_ + x_**S(2)*WC('d', S(1)))**p_*WC('u', S(1))*exp(WC('n', S(1))*acoth(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, a, d: ZeroQ(a**S(2)*c + d)), CustomConstraint(lambda n: Not(IntegerQ(n/S(2)))), CustomConstraint(lambda p: Not(IntegerQ(p)))) rule497 = ReplacementRule(pattern497, lambda p, x, c, a, d, u, n : x**(-S(2)*p)*(S(1) - S(1)/(a**S(2)*x**S(2)))**(-p)*(c + d*x**S(2))**p*Int(u*x**(S(2)*p)*(S(1) - S(1)/(a**S(2)*x**S(2)))**p*exp(n*acoth(a*x)), x)) rubi.add(rule497) pattern498 = Pattern(Integral((c_ + WC('d', S(1))/x_**S(2))**WC('p', S(1))*WC('u', S(1))*exp(WC('n', S(1))*acoth(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, a, d: ZeroQ(a**S(2)*d + c)), CustomConstraint(lambda n: Not(IntegerQ(n/S(2)))), CustomConstraint(lambda c, p: IntegerQ(p) | PositiveQ(c)), CustomConstraint(lambda p, n: IntegersQ(S(2)*p, n/S(2) + p))) rule498 = ReplacementRule(pattern498, lambda p, x, c, a, d, u, n : a**(-S(2)*p)*c**p*Int(u*x**(-S(2)*p)*(a*x + S(-1))**(-n/S(2) + p)*(a*x + S(1))**(n/S(2) + p), x)) rubi.add(rule498) pattern499 = Pattern(Integral((c_ + WC('d', S(1))/x_**S(2))**WC('p', S(1))*exp(WC('n', S(1))*acoth(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, a, d: ZeroQ(a**S(2)*d + c)), CustomConstraint(lambda n: Not(IntegerQ(n/S(2)))), CustomConstraint(lambda c, p: IntegerQ(p) | PositiveQ(c)), CustomConstraint(lambda p, n: Not(IntegersQ(S(2)*p, n/S(2) + p)))) rule499 = ReplacementRule(pattern499, lambda p, x, c, a, d, n : -c**p*Subst(Int((S(1) - x/a)**(-n/S(2) + p)*(S(1) + x/a)**(n/S(2) + p)/x**S(2), x), x, 1/x)) rubi.add(rule499) pattern500 = Pattern(Integral(x_**WC('m', S(1))*(c_ + WC('d', S(1))/x_**S(2))**WC('p', S(1))*exp(WC('n', S(1))*acoth(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, a, d: ZeroQ(a**S(2)*d + c)), CustomConstraint(lambda n: Not(IntegerQ(n/S(2)))), CustomConstraint(lambda c, p: IntegerQ(p) | PositiveQ(c)), CustomConstraint(lambda p, n: Not(IntegersQ(S(2)*p, n/S(2) + p))), CustomConstraint(lambda m: IntegerQ(m))) rule500 = ReplacementRule(pattern500, lambda p, x, m, c, a, d, n : -c**p*Subst(Int(x**(-m + S(-2))*(S(1) - x/a)**(-n/S(2) + p)*(S(1) + x/a)**(n/S(2) + p), x), x, 1/x)) rubi.add(rule500) pattern501 = Pattern(Integral(x_**m_*(c_ + WC('d', S(1))/x_**S(2))**WC('p', S(1))*exp(WC('n', S(1))*acoth(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, a, d: ZeroQ(a**S(2)*d + c)), CustomConstraint(lambda n: Not(IntegerQ(n/S(2)))), CustomConstraint(lambda c, p: IntegerQ(p) | PositiveQ(c)), CustomConstraint(lambda p, n: Not(IntegersQ(S(2)*p, n/S(2) + p))), CustomConstraint(lambda m: Not(IntegerQ(m)))) rule501 = ReplacementRule(pattern501, lambda p, x, m, c, a, d, n : -c**p*x**m*(1/x)**m*Subst(Int(x**(-m + S(-2))*(S(1) - x/a)**(-n/S(2) + p)*(S(1) + x/a)**(n/S(2) + p), x), x, 1/x)) rubi.add(rule501) pattern502 = Pattern(Integral((c_ + WC('d', S(1))/x_**S(2))**p_*WC('u', S(1))*exp(WC('n', S(1))*acoth(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda c, a, d: ZeroQ(a**S(2)*d + c)), CustomConstraint(lambda n: Not(IntegerQ(n/S(2)))), CustomConstraint(lambda c, p: Not(IntegerQ(p) | PositiveQ(c)))) rule502 = ReplacementRule(pattern502, lambda p, x, c, a, d, u, n : c**IntPart(p)*(S(1) - S(1)/(a**S(2)*x**S(2)))**(-FracPart(p))*(c + d/x**S(2))**FracPart(p)*Int(u*(S(1) - S(1)/(a**S(2)*x**S(2)))**p*exp(n*acoth(a*x)), x)) rubi.add(rule502) pattern503 = Pattern(Integral(WC('u', S(1))*exp(n_*acoth((a_ + x_*WC('b', S(1)))*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda n: IntegerQ(n/S(2)))) rule503 = ReplacementRule(pattern503, lambda x, b, c, a, u, n : (S(-1))**(n/S(2))*Int(u*exp(n*atanh(c*(a + b*x))), x)) rubi.add(rule503) pattern504 = Pattern(Integral(exp(WC('n', S(1))*acoth((a_ + x_*WC('b', S(1)))*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda n: Not(IntegerQ(n/S(2))))) rule504 = ReplacementRule(pattern504, lambda x, b, c, a, n : (c*(a + b*x))**(n/S(2))*(S(1) + S(1)/(c*(a + b*x)))**(n/S(2))*(a*c + b*c*x + S(1))**(-n/S(2))*Int((a*c + b*c*x + S(-1))**(-n/S(2))*(a*c + b*c*x + S(1))**(n/S(2)), x)) rubi.add(rule504) pattern505 = Pattern(Integral(x_**m_*exp(n_*acoth((a_ + x_*WC('b', S(1)))*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda m: NegativeIntegerQ(m)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Less(S(-1), n, S(1)))) rule505 = ReplacementRule(pattern505, lambda x, b, m, c, a, n : -S(4)*b**(-m + S(-1))*c**(-m + S(-1))*Subst(Int(x**(S(2)/n)*(x**(S(2)/n) + S(-1))**(-m + S(-2))*(a*c + x**(S(2)/n)*(-a*c + S(1)) + S(1))**m, x), x, (S(1) - S(1)/(c*(a + b*x)))**(-n/S(2))*(S(1) + S(1)/(c*(a + b*x)))**(n/S(2)))/n) rubi.add(rule505) pattern506 = Pattern(Integral((x_*WC('e', S(1)) + WC('d', S(0)))**WC('m', S(1))*exp(WC('n', S(1))*acoth((a_ + x_*WC('b', S(1)))*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda n: Not(IntegerQ(n/S(2))))) rule506 = ReplacementRule(pattern506, lambda x, b, m, c, a, d, e, n : (c*(a + b*x))**(n/S(2))*(S(1) + S(1)/(c*(a + b*x)))**(n/S(2))*(a*c + b*c*x + S(1))**(-n/S(2))*Int((d + e*x)**m*(a*c + b*c*x + S(-1))**(-n/S(2))*(a*c + b*c*x + S(1))**(n/S(2)), x)) rubi.add(rule506) pattern507 = Pattern(Integral((c_ + x_**S(2)*WC('e', S(1)) + x_*WC('d', S(1)))**WC('p', S(1))*WC('u', S(1))*exp(WC('n', S(1))*acoth(a_ + x_*WC('b', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda n: Not(IntegerQ(n/S(2)))), CustomConstraint(lambda e, a, d, b: ZeroQ(-S(2)*a*e + b*d)), CustomConstraint(lambda c, a, e, b: ZeroQ(b**S(2)*c + e*(-a**S(2) + S(1)))), CustomConstraint(lambda c, a, p: IntegerQ(p) | PositiveQ(c/(-a**S(2) + S(1))))) rule507 = ReplacementRule(pattern507, lambda p, x, b, c, a, d, u, e, n : (c/(-a**S(2) + S(1)))**p*((a + b*x + S(1))/(a + b*x))**(n/S(2))*((a + b*x)/(a + b*x + S(1)))**(n/S(2))*(-a - b*x + S(1))**(n/S(2))*(a + b*x + S(-1))**(-n/S(2))*Int(u*(-a - b*x + S(1))**(-n/S(2) + p)*(a + b*x + S(1))**(n/S(2) + p), x)) rubi.add(rule507) pattern508 = Pattern(Integral((c_ + x_**S(2)*WC('e', S(1)) + x_*WC('d', S(1)))**WC('p', S(1))*WC('u', S(1))*exp(WC('n', S(1))*acoth(a_ + x_*WC('b', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda n: Not(IntegerQ(n/S(2)))), CustomConstraint(lambda e, a, d, b: ZeroQ(-S(2)*a*e + b*d)), CustomConstraint(lambda c, a, e, b: ZeroQ(b**S(2)*c + e*(-a**S(2) + S(1)))), CustomConstraint(lambda c, a, p: Not(IntegerQ(p) | PositiveQ(c/(-a**S(2) + S(1)))))) rule508 = ReplacementRule(pattern508, lambda p, x, b, c, a, d, u, e, n : (c + d*x + e*x**S(2))**p*(-a**S(2) - S(2)*a*b*x - b**S(2)*x**S(2) + S(1))**(-p)*Int(u*(-a**S(2) - S(2)*a*b*x - b**S(2)*x**S(2) + S(1))**p*exp(n*acoth(a*x)), x)) rubi.add(rule508) pattern509 = Pattern(Integral(WC('u', S(1))*exp(WC('n', S(1))*acoth(WC('c', S(1))/(x_*WC('b', S(1)) + WC('a', S(0))))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda n, x: FreeQ(n, x))) rule509 = ReplacementRule(pattern509, lambda x, b, c, a, u, n : Int(u*exp(n*atanh(a/c + b*x/c)), x)) rubi.add(rule509) pattern510 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(c_ + x_*WC('d', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n: PositiveIntegerQ(n))) rule510 = ReplacementRule(pattern510, lambda x, b, c, a, d, n : Subst(Int((a + b*atanh(x))**n, x), x, c + d*x)/d) rubi.add(rule510) pattern511 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(c_ + x_*WC('d', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n: PositiveIntegerQ(n))) rule511 = ReplacementRule(pattern511, lambda x, b, c, a, d, n : Subst(Int((a + b*acoth(x))**n, x), x, c + d*x)/d) rubi.add(rule511) pattern512 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(c_ + x_*WC('d', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda n: Not(PositiveIntegerQ(n)))) rule512 = ReplacementRule(pattern512, lambda x, b, c, a, d, n : Int((a + b*atanh(c + d*x))**n, x)) rubi.add(rule512) pattern513 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(c_ + x_*WC('d', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda n: Not(PositiveIntegerQ(n)))) rule513 = ReplacementRule(pattern513, lambda x, b, c, a, d, n : Int((a + b*acoth(c + d*x))**n, x)) rubi.add(rule513) pattern514 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(c_ + x_*WC('d', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda n: PositiveIntegerQ(n))) rule514 = ReplacementRule(pattern514, lambda x, b, m, f, c, a, d, e, n : Subst(Int((a + b*atanh(x))**n*(f*x/d + (-c*f + d*e)/d)**m, x), x, c + d*x)/d) rubi.add(rule514) pattern515 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(c_ + x_*WC('d', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda n: PositiveIntegerQ(n))) rule515 = ReplacementRule(pattern515, lambda x, b, m, f, c, a, d, e, n : Subst(Int((a + b*acoth(x))**n*(f*x/d + (-c*f + d*e)/d)**m, x), x, c + d*x)/d) rubi.add(rule515) pattern516 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**m_*(WC('a', S(0)) + WC('b', S(1))*atanh(c_ + x_*WC('d', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda n: Not(PositiveIntegerQ(n)))) rule516 = ReplacementRule(pattern516, lambda x, b, m, f, c, a, d, e, n : Int((a + b*atanh(c + d*x))**n*(e + f*x)**m, x)) rubi.add(rule516) pattern517 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**m_*(WC('a', S(0)) + WC('b', S(1))*acoth(c_ + x_*WC('d', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda n: Not(PositiveIntegerQ(n)))) rule517 = ReplacementRule(pattern517, lambda x, b, m, f, c, a, d, e, n : Int((a + b*acoth(c + d*x))**n*(e + f*x)**m, x)) rubi.add(rule517) pattern518 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*atanh(c_ + x_*WC('d', S(1))))**WC('n', S(1))*(x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))**WC('p', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda A, x: FreeQ(A, x)), CustomConstraint(lambda B, x: FreeQ(B, x)), CustomConstraint(lambda C, x: FreeQ(C, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda B, c, A, d: ZeroQ(S(2)*A*c*d + B*(-c**S(2) + S(1)))), CustomConstraint(lambda B, c, C, d: ZeroQ(-B*d + S(2)*C*c))) rule518 = ReplacementRule(pattern518, lambda B, A, C, p, x, b, c, a, d, n : Subst(Int((a + b*atanh(x))**n*(C*x**S(2)/d**S(2) - C/d**S(2))**p, x), x, c + d*x)/d) rubi.add(rule518) pattern519 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acoth(c_ + x_*WC('d', S(1))))**WC('n', S(1))*(x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))**WC('p', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda A, x: FreeQ(A, x)), CustomConstraint(lambda B, x: FreeQ(B, x)), CustomConstraint(lambda C, x: FreeQ(C, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda B, c, A, d: ZeroQ(S(2)*A*c*d + B*(-c**S(2) + S(1)))), CustomConstraint(lambda B, c, C, d: ZeroQ(-B*d + S(2)*C*c))) rule519 = ReplacementRule(pattern519, lambda B, A, C, p, x, b, c, a, d, n : Subst(Int((a + b*acoth(x))**n*(C*x**S(2)/d**S(2) + C/d**S(2))**p, x), x, c + d*x)/d) rubi.add(rule519) pattern520 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(c_ + x_*WC('d', S(1))))**WC('n', S(1))*(x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))**WC('p', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda A, x: FreeQ(A, x)), CustomConstraint(lambda B, x: FreeQ(B, x)), CustomConstraint(lambda C, x: FreeQ(C, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda B, c, A, d: ZeroQ(S(2)*A*c*d + B*(-c**S(2) + S(1)))), CustomConstraint(lambda B, c, C, d: ZeroQ(-B*d + S(2)*C*c))) rule520 = ReplacementRule(pattern520, lambda B, A, C, p, x, b, m, f, c, a, d, e, n : Subst(Int((a + b*atanh(x))**n*(C*x**S(2)/d**S(2) - C/d**S(2))**p*(f*x/d + (-c*f + d*e)/d)**m, x), x, c + d*x)/d) rubi.add(rule520) pattern521 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(c_ + x_*WC('d', S(1))))**WC('n', S(1))*(x_**S(2)*WC('C', S(1)) + x_*WC('B', S(1)) + WC('A', S(0)))**WC('p', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda A, x: FreeQ(A, x)), CustomConstraint(lambda B, x: FreeQ(B, x)), CustomConstraint(lambda C, x: FreeQ(C, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda B, c, A, d: ZeroQ(S(2)*A*c*d + B*(-c**S(2) + S(1)))), CustomConstraint(lambda B, c, C, d: ZeroQ(-B*d + S(2)*C*c))) rule521 = ReplacementRule(pattern521, lambda B, A, C, p, x, b, m, f, c, a, d, e, n : Subst(Int((a + b*acoth(x))**n*(C*x**S(2)/d**S(2) - C/d**S(2))**p*(f*x/d + (-c*f + d*e)/d)**m, x), x, c + d*x)/d) rubi.add(rule521) pattern522 = Pattern(Integral(atanh(a_ + x_*WC('b', S(1)))/(c_ + x_**WC('n', S(1))*WC('d', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n: RationalQ(n))) rule522 = ReplacementRule(pattern522, lambda x, b, c, a, d, n : -Int(log(-a - b*x + S(1))/(c + d*x**n), x)/S(2) + Int(log(a + b*x + S(1))/(c + d*x**n), x)/S(2)) rubi.add(rule522) pattern523 = Pattern(Integral(acoth(a_ + x_*WC('b', S(1)))/(c_ + x_**WC('n', S(1))*WC('d', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n: RationalQ(n))) rule523 = ReplacementRule(pattern523, lambda x, b, c, a, d, n : -Int(log((a + b*x + S(-1))/(a + b*x))/(c + d*x**n), x)/S(2) + Int(log((a + b*x + S(1))/(a + b*x))/(c + d*x**n), x)/S(2)) rubi.add(rule523) pattern524 = Pattern(Integral(atanh(a_ + x_*WC('b', S(1)))/(c_ + x_**n_*WC('d', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda n: Not(RationalQ(n)))) rule524 = ReplacementRule(pattern524, lambda x, b, c, a, d, n : Int(atanh(a + b*x)/(c + d*x**n), x)) rubi.add(rule524) pattern525 = Pattern(Integral(acoth(a_ + x_*WC('b', S(1)))/(c_ + x_**n_*WC('d', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda n: Not(RationalQ(n)))) rule525 = ReplacementRule(pattern525, lambda x, b, c, a, d, n : Int(acoth(a + b*x)/(c + d*x**n), x)) rubi.add(rule525) pattern526 = Pattern(Integral(atanh(a_ + x_**n_*WC('b', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda n, x: FreeQ(n, x))) rule526 = ReplacementRule(pattern526, lambda x, a, n, b : -b*n*Int(x**n/(-a**S(2) - S(2)*a*b*x**n - b**S(2)*x**(S(2)*n) + S(1)), x) + x*atanh(a + b*x**n)) rubi.add(rule526) pattern527 = Pattern(Integral(acoth(a_ + x_**n_*WC('b', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda n, x: FreeQ(n, x))) rule527 = ReplacementRule(pattern527, lambda x, a, n, b : -b*n*Int(x**n/(-a**S(2) - S(2)*a*b*x**n - b**S(2)*x**(S(2)*n) + S(1)), x) + x*acoth(a + b*x**n)) rubi.add(rule527) pattern528 = Pattern(Integral(atanh(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0)))/x_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda n, x: FreeQ(n, x))) rule528 = ReplacementRule(pattern528, lambda x, a, n, b : -Int(log(-a - b*x**n + S(1))/x, x)/S(2) + Int(log(a + b*x**n + S(1))/x, x)/S(2)) rubi.add(rule528) pattern529 = Pattern(Integral(acoth(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0)))/x_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda n, x: FreeQ(n, x))) rule529 = ReplacementRule(pattern529, lambda x, a, n, b : -Int(log(S(1) - S(1)/(a + b*x**n))/x, x)/S(2) + Int(log(S(1) + 1/(a + b*x**n))/x, x)/S(2)) rubi.add(rule529) pattern530 = Pattern(Integral(x_**WC('m', S(1))*atanh(a_ + x_**n_*WC('b', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda n, m: RationalQ(m, n)), CustomConstraint(lambda m: Unequal(m + S(1), S(0))), CustomConstraint(lambda n, m: Unequal(m + S(1), n))) rule530 = ReplacementRule(pattern530, lambda x, b, m, a, n : -b*n*Int(x**(m + n)/(-a**S(2) - S(2)*a*b*x**n - b**S(2)*x**(S(2)*n) + S(1)), x)/(m + S(1)) + x**(m + S(1))*atanh(a + b*x**n)/(m + S(1))) rubi.add(rule530) pattern531 = Pattern(Integral(x_**WC('m', S(1))*acoth(a_ + x_**n_*WC('b', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda n, m: RationalQ(m, n)), CustomConstraint(lambda m: Unequal(m + S(1), S(0))), CustomConstraint(lambda n, m: Unequal(m + S(1), n))) rule531 = ReplacementRule(pattern531, lambda x, b, m, a, n : -b*n*Int(x**(m + n)/(-a**S(2) - S(2)*a*b*x**n - b**S(2)*x**(S(2)*n) + S(1)), x)/(m + S(1)) + x**(m + S(1))*acoth(a + b*x**n)/(m + S(1))) rubi.add(rule531) pattern532 = Pattern(Integral(atanh(f_**(x_*WC('d', S(1)) + WC('c', S(0)))*WC('b', S(1)) + WC('a', S(0))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda f, x: FreeQ(f, x))) rule532 = ReplacementRule(pattern532, lambda x, b, c, f, a, d : -Int(log(-a - b*f**(c + d*x) + S(1)), x)/S(2) + Int(log(a + b*f**(c + d*x) + S(1)), x)/S(2)) rubi.add(rule532) pattern533 = Pattern(Integral(acoth(f_**(x_*WC('d', S(1)) + WC('c', S(0)))*WC('b', S(1)) + WC('a', S(0))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda f, x: FreeQ(f, x))) rule533 = ReplacementRule(pattern533, lambda x, b, c, f, a, d : -Int(log(S(1) - S(1)/(a + b*f**(c + d*x))), x)/S(2) + Int(log(S(1) + 1/(a + b*f**(c + d*x))), x)/S(2)) rubi.add(rule533) pattern534 = Pattern(Integral(x_**WC('m', S(1))*atanh(f_**(x_*WC('d', S(1)) + WC('c', S(0)))*WC('b', S(1)) + WC('a', S(0))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m: IntegerQ(m)), CustomConstraint(lambda m: Greater(m, S(0)))) rule534 = ReplacementRule(pattern534, lambda x, b, m, c, f, a, d : -Int(x**m*log(-a - b*f**(c + d*x) + S(1)), x)/S(2) + Int(x**m*log(a + b*f**(c + d*x) + S(1)), x)/S(2)) rubi.add(rule534) pattern535 = Pattern(Integral(x_**WC('m', S(1))*acoth(f_**(x_*WC('d', S(1)) + WC('c', S(0)))*WC('b', S(1)) + WC('a', S(0))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m: IntegerQ(m)), CustomConstraint(lambda m: Greater(m, S(0)))) rule535 = ReplacementRule(pattern535, lambda x, b, m, c, f, a, d : -Int(x**m*log(S(1) - S(1)/(a + b*f**(c + d*x))), x)/S(2) + Int(x**m*log(S(1) + 1/(a + b*f**(c + d*x))), x)/S(2)) rubi.add(rule535) pattern536 = Pattern(Integral(WC('u', S(1))*atanh(WC('c', S(1))/(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda m, x: FreeQ(m, x))) rule536 = ReplacementRule(pattern536, lambda x, b, m, c, a, u, n : Int(u*acoth(a/c + b*x**n/c)**m, x)) rubi.add(rule536) pattern537 = Pattern(Integral(WC('u', S(1))*acoth(WC('c', S(1))/(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda m, x: FreeQ(m, x))) rule537 = ReplacementRule(pattern537, lambda x, b, m, c, a, u, n : Int(u*atanh(a/c + b*x**n/c)**m, x)) rubi.add(rule537) pattern538 = Pattern(Integral(S(1)/(sqrt(x_**S(2)*WC('b', S(1)) + WC('a', S(0)))*atanh(x_*WC('c', S(1))/sqrt(x_**S(2)*WC('b', S(1)) + WC('a', S(0))))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda c, b: ZeroQ(b - c**S(2)))) rule538 = ReplacementRule(pattern538, lambda c, a, b, x : log(atanh(c*x/sqrt(a + b*x**S(2))))/c) rubi.add(rule538) pattern539 = Pattern(Integral(S(1)/(sqrt(x_**S(2)*WC('b', S(1)) + WC('a', S(0)))*acoth(x_*WC('c', S(1))/sqrt(x_**S(2)*WC('b', S(1)) + WC('a', S(0))))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda c, b: ZeroQ(b - c**S(2)))) rule539 = ReplacementRule(pattern539, lambda c, a, b, x : -log(acoth(c*x/sqrt(a + b*x**S(2))))/c) rubi.add(rule539) pattern540 = Pattern(Integral(atanh(x_*WC('c', S(1))/sqrt(x_**S(2)*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1))/sqrt(x_**S(2)*WC('b', S(1)) + WC('a', S(0))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda c, b: ZeroQ(b - c**S(2))), CustomConstraint(lambda m: NonzeroQ(m + S(1)))) rule540 = ReplacementRule(pattern540, lambda x, b, m, c, a : atanh(c*x/sqrt(a + b*x**S(2)))**(m + S(1))/(c*(m + S(1)))) rubi.add(rule540) pattern541 = Pattern(Integral(acoth(x_*WC('c', S(1))/sqrt(x_**S(2)*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1))/sqrt(x_**S(2)*WC('b', S(1)) + WC('a', S(0))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda c, b: ZeroQ(b - c**S(2))), CustomConstraint(lambda m: NonzeroQ(m + S(1)))) rule541 = ReplacementRule(pattern541, lambda x, b, m, c, a : -acoth(c*x/sqrt(a + b*x**S(2)))**(m + S(1))/(c*(m + S(1)))) rubi.add(rule541) pattern542 = Pattern(Integral(atanh(x_*WC('c', S(1))/sqrt(x_**S(2)*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1))/sqrt(x_**S(2)*WC('e', S(1)) + WC('d', S(0))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda c, b: ZeroQ(b - c**S(2))), CustomConstraint(lambda e, a, d, b: ZeroQ(-a*e + b*d))) rule542 = ReplacementRule(pattern542, lambda x, b, m, c, a, d, e : sqrt(a + b*x**S(2))*Int(atanh(c*x/sqrt(a + b*x**S(2)))**m/sqrt(a + b*x**S(2)), x)/sqrt(d + e*x**S(2))) rubi.add(rule542) pattern543 = Pattern(Integral(acoth(x_*WC('c', S(1))/sqrt(x_**S(2)*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1))/sqrt(x_**S(2)*WC('e', S(1)) + WC('d', S(0))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda c, b: ZeroQ(b - c**S(2))), CustomConstraint(lambda e, a, d, b: ZeroQ(-a*e + b*d))) rule543 = ReplacementRule(pattern543, lambda x, b, m, c, a, d, e : sqrt(a + b*x**S(2))*Int(acoth(c*x/sqrt(a + b*x**S(2)))**m/sqrt(a + b*x**S(2)), x)/sqrt(d + e*x**S(2))) rubi.add(rule543) pattern544 = Pattern(Integral((x_**S(2)*WC('d', S(1)) + WC('c', S(0)))**n_*atanh(x_*WC('a', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n: IntegerQ(S(2)*n)), CustomConstraint(lambda n: LessEqual(n, S(-1))), ) def With544(x, c, a, d, n): u = IntHide((c + d*x**S(2))**n, x) return -a*Int(Dist(1/(-a**S(2)*x**S(2) + S(1)), u, x), x) + Dist(atanh(a*x), u, x) rule544 = ReplacementRule(pattern544, lambda x, c, a, d, n : With544(x, c, a, d, n)) rubi.add(rule544) pattern545 = Pattern(Integral((x_**S(2)*WC('d', S(1)) + WC('c', S(0)))**n_*acoth(x_*WC('a', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n: IntegerQ(S(2)*n)), CustomConstraint(lambda n: LessEqual(n, S(-1))), ) def With545(x, c, a, d, n): u = IntHide((c + d*x**S(2))**n, x) return -a*Int(Dist(1/(-a**S(2)*x**S(2) + S(1)), u, x), x) + Dist(acoth(a*x), u, x) rule545 = ReplacementRule(pattern545, lambda x, c, a, d, n : With545(x, c, a, d, n)) rubi.add(rule545) pattern546 = Pattern(Integral(u_*v_**WC('n', S(1)), x_), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda v, x: QuadraticQ(v, x)), CustomConstraint(lambda n: IntegerQ(n)), CustomConstraint(lambda n: Less(n, S(0))), CustomConstraint(lambda v, x: PosQ(Discriminant(v, x))), CustomConstraint(lambda x, u: MatchQ(u, Condition(Optional(Pattern(r, Blank))*Pattern(f, Blank)**Pattern(w, Blank)))), CustomConstraint(lambda u, n, v, tmp, x, ArcTanh: Not(FalseQ(tmp)) & SameQ(Head(tmp), ArcTanh) & ZeroQ(-D(v, x)**S(2) + Discriminant(v, x)*Part(tmp, S(1))**S(2)))) def With546(v, x, u, n): tmp = InverseFunctionOfLinear(u, x) return (-Discriminant(v, x)/(S(4)*Coefficient(v, x, S(2))))**n*Subst(Int(SimplifyIntegrand(SubstForInverseFunction(u, tmp, x)*sech(x)**(S(2)*n + S(2)), x), x), x, tmp)/Coefficient(Part(tmp, S(1)), x, S(1)) rule546 = ReplacementRule(pattern546, lambda v, x, u, n : With546(v, x, u, n)) rubi.add(rule546) pattern547 = Pattern(Integral(u_*v_**WC('n', S(1)), x_), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda v, x: QuadraticQ(v, x)), CustomConstraint(lambda n: IntegerQ(n)), CustomConstraint(lambda n: Less(n, S(0))), CustomConstraint(lambda v, x: PosQ(Discriminant(v, x))), CustomConstraint(lambda x, u: MatchQ(u, Condition(Optional(Pattern(r, Blank))*Pattern(f, Blank)**Pattern(w, Blank)))), CustomConstraint(lambda u, n, ArcCoth, v, tmp, x: Not(FalseQ(tmp)) & SameQ(Head(tmp), ArcCoth) & ZeroQ(-D(v, x)**S(2) + Discriminant(v, x)*Part(tmp, S(1))**S(2)))) def With547(v, x, u, n): tmp = InverseFunctionOfLinear(u, x) return (-Discriminant(v, x)/(S(4)*Coefficient(v, x, S(2))))**n*Subst(Int(SimplifyIntegrand((-csch(x)**S(2))**(n + S(1))*SubstForInverseFunction(u, tmp, x), x), x), x, tmp)/Coefficient(Part(tmp, S(1)), x, S(1)) rule547 = ReplacementRule(pattern547, lambda v, x, u, n : With547(v, x, u, n)) rubi.add(rule547) pattern548 = Pattern(Integral(atanh(WC('c', S(0)) + WC('d', S(1))*tanh(x_*WC('b', S(1)) + WC('a', S(0)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda c, d: ZeroQ((c - d)**S(2) + S(-1)))) rule548 = ReplacementRule(pattern548, lambda x, b, c, a, d : b*Int(x/(c*exp(S(2)*a + S(2)*b*x) + c - d), x) + x*atanh(c + d*tanh(a + b*x))) rubi.add(rule548) pattern549 = Pattern(Integral(acoth(WC('c', S(0)) + WC('d', S(1))*tanh(x_*WC('b', S(1)) + WC('a', S(0)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda c, d: ZeroQ((c - d)**S(2) + S(-1)))) rule549 = ReplacementRule(pattern549, lambda x, b, c, a, d : b*Int(x/(c*exp(S(2)*a + S(2)*b*x) + c - d), x) + x*acoth(c + d*tanh(a + b*x))) rubi.add(rule549) pattern550 = Pattern(Integral(atanh(WC('c', S(0)) + WC('d', S(1))*coth(x_*WC('b', S(1)) + WC('a', S(0)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda c, d: ZeroQ((c - d)**S(2) + S(-1)))) rule550 = ReplacementRule(pattern550, lambda x, b, c, a, d : b*Int(x/(-c*exp(S(2)*a + S(2)*b*x) + c - d), x) + x*atanh(c + d*coth(a + b*x))) rubi.add(rule550) pattern551 = Pattern(Integral(acoth(WC('c', S(0)) + WC('d', S(1))*coth(x_*WC('b', S(1)) + WC('a', S(0)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda c, d: ZeroQ((c - d)**S(2) + S(-1)))) rule551 = ReplacementRule(pattern551, lambda x, b, c, a, d : b*Int(x/(-c*exp(S(2)*a + S(2)*b*x) + c - d), x) + x*acoth(c + d*coth(a + b*x))) rubi.add(rule551) pattern552 = Pattern(Integral(atanh(WC('c', S(0)) + WC('d', S(1))*tanh(x_*WC('b', S(1)) + WC('a', S(0)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda c, d: NonzeroQ((c - d)**S(2) + S(-1)))) rule552 = ReplacementRule(pattern552, lambda x, b, c, a, d : b*(-c - d + S(1))*Int(x*exp(S(2)*a + S(2)*b*x)/(-c + d + (-c - d + S(1))*exp(S(2)*a + S(2)*b*x) + S(1)), x) - b*(c + d + S(1))*Int(x*exp(S(2)*a + S(2)*b*x)/(c - d + (c + d + S(1))*exp(S(2)*a + S(2)*b*x) + S(1)), x) + x*atanh(c + d*tanh(a + b*x))) rubi.add(rule552) pattern553 = Pattern(Integral(acoth(WC('c', S(0)) + WC('d', S(1))*tanh(x_*WC('b', S(1)) + WC('a', S(0)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda c, d: NonzeroQ((c - d)**S(2) + S(-1)))) rule553 = ReplacementRule(pattern553, lambda x, b, c, a, d : b*(-c - d + S(1))*Int(x*exp(S(2)*a + S(2)*b*x)/(-c + d + (-c - d + S(1))*exp(S(2)*a + S(2)*b*x) + S(1)), x) - b*(c + d + S(1))*Int(x*exp(S(2)*a + S(2)*b*x)/(c - d + (c + d + S(1))*exp(S(2)*a + S(2)*b*x) + S(1)), x) + x*acoth(c + d*tanh(a + b*x))) rubi.add(rule553) pattern554 = Pattern(Integral(atanh(WC('c', S(0)) + WC('d', S(1))*coth(x_*WC('b', S(1)) + WC('a', S(0)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda c, d: NonzeroQ((c - d)**S(2) + S(-1)))) rule554 = ReplacementRule(pattern554, lambda x, b, c, a, d : -b*(-c - d + S(1))*Int(x*exp(S(2)*a + S(2)*b*x)/(-c + d - (-c - d + S(1))*exp(S(2)*a + S(2)*b*x) + S(1)), x) + b*(c + d + S(1))*Int(x*exp(S(2)*a + S(2)*b*x)/(c - d - (c + d + S(1))*exp(S(2)*a + S(2)*b*x) + S(1)), x) + x*atanh(c + d*coth(a + b*x))) rubi.add(rule554) pattern555 = Pattern(Integral(acoth(WC('c', S(0)) + WC('d', S(1))*coth(x_*WC('b', S(1)) + WC('a', S(0)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda c, d: NonzeroQ((c - d)**S(2) + S(-1)))) rule555 = ReplacementRule(pattern555, lambda x, b, c, a, d : -b*(-c - d + S(1))*Int(x*exp(S(2)*a + S(2)*b*x)/(-c + d - (-c - d + S(1))*exp(S(2)*a + S(2)*b*x) + S(1)), x) + b*(c + d + S(1))*Int(x*exp(S(2)*a + S(2)*b*x)/(c - d - (c + d + S(1))*exp(S(2)*a + S(2)*b*x) + S(1)), x) + x*acoth(c + d*coth(a + b*x))) rubi.add(rule555) pattern556 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*atanh(WC('c', S(0)) + WC('d', S(1))*tanh(x_*WC('b', S(1)) + WC('a', S(0)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m: PositiveIntegerQ(m)), CustomConstraint(lambda c, d: ZeroQ((c - d)**S(2) + S(-1)))) rule556 = ReplacementRule(pattern556, lambda x, b, m, c, f, a, d, e : b*Int((e + f*x)**(m + S(1))/(c*exp(S(2)*a + S(2)*b*x) + c - d), x)/(f*(m + S(1))) + (e + f*x)**(m + S(1))*atanh(c + d*tanh(a + b*x))/(f*(m + S(1)))) rubi.add(rule556) pattern557 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*acoth(WC('c', S(0)) + WC('d', S(1))*tanh(x_*WC('b', S(1)) + WC('a', S(0)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m: PositiveIntegerQ(m)), CustomConstraint(lambda c, d: ZeroQ((c - d)**S(2) + S(-1)))) rule557 = ReplacementRule(pattern557, lambda x, b, m, c, f, a, d, e : b*Int((e + f*x)**(m + S(1))/(c*exp(S(2)*a + S(2)*b*x) + c - d), x)/(f*(m + S(1))) + (e + f*x)**(m + S(1))*acoth(c + d*tanh(a + b*x))/(f*(m + S(1)))) rubi.add(rule557) pattern558 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*atanh(WC('c', S(0)) + WC('d', S(1))*coth(x_*WC('b', S(1)) + WC('a', S(0)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m: PositiveIntegerQ(m)), CustomConstraint(lambda c, d: ZeroQ((c - d)**S(2) + S(-1)))) rule558 = ReplacementRule(pattern558, lambda x, b, m, c, f, a, d, e : b*Int((e + f*x)**(m + S(1))/(-c*exp(S(2)*a + S(2)*b*x) + c - d), x)/(f*(m + S(1))) + (e + f*x)**(m + S(1))*atanh(c + d*coth(a + b*x))/(f*(m + S(1)))) rubi.add(rule558) pattern559 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*acoth(WC('c', S(0)) + WC('d', S(1))*coth(x_*WC('b', S(1)) + WC('a', S(0)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m: PositiveIntegerQ(m)), CustomConstraint(lambda c, d: ZeroQ((c - d)**S(2) + S(-1)))) rule559 = ReplacementRule(pattern559, lambda x, b, m, c, f, a, d, e : b*Int((e + f*x)**(m + S(1))/(-c*exp(S(2)*a + S(2)*b*x) + c - d), x)/(f*(m + S(1))) + (e + f*x)**(m + S(1))*acoth(c + d*coth(a + b*x))/(f*(m + S(1)))) rubi.add(rule559) pattern560 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*atanh(WC('c', S(0)) + WC('d', S(1))*tanh(x_*WC('b', S(1)) + WC('a', S(0)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m: PositiveIntegerQ(m)), CustomConstraint(lambda c, d: NonzeroQ((c - d)**S(2) + S(-1)))) rule560 = ReplacementRule(pattern560, lambda x, b, m, c, f, a, d, e : b*(-c - d + S(1))*Int((e + f*x)**(m + S(1))*exp(S(2)*a + S(2)*b*x)/(-c + d + (-c - d + S(1))*exp(S(2)*a + S(2)*b*x) + S(1)), x)/(f*(m + S(1))) - b*(c + d + S(1))*Int((e + f*x)**(m + S(1))*exp(S(2)*a + S(2)*b*x)/(c - d + (c + d + S(1))*exp(S(2)*a + S(2)*b*x) + S(1)), x)/(f*(m + S(1))) + (e + f*x)**(m + S(1))*atanh(c + d*tanh(a + b*x))/(f*(m + S(1)))) rubi.add(rule560) pattern561 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*acoth(WC('c', S(0)) + WC('d', S(1))*tanh(x_*WC('b', S(1)) + WC('a', S(0)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m: PositiveIntegerQ(m)), CustomConstraint(lambda c, d: NonzeroQ((c - d)**S(2) + S(-1)))) rule561 = ReplacementRule(pattern561, lambda x, b, m, c, f, a, d, e : b*(-c - d + S(1))*Int((e + f*x)**(m + S(1))*exp(S(2)*a + S(2)*b*x)/(-c + d + (-c - d + S(1))*exp(S(2)*a + S(2)*b*x) + S(1)), x)/(f*(m + S(1))) - b*(c + d + S(1))*Int((e + f*x)**(m + S(1))*exp(S(2)*a + S(2)*b*x)/(c - d + (c + d + S(1))*exp(S(2)*a + S(2)*b*x) + S(1)), x)/(f*(m + S(1))) + (e + f*x)**(m + S(1))*acoth(c + d*tanh(a + b*x))/(f*(m + S(1)))) rubi.add(rule561) pattern562 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*atanh(WC('c', S(0)) + WC('d', S(1))*coth(x_*WC('b', S(1)) + WC('a', S(0)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m: PositiveIntegerQ(m)), CustomConstraint(lambda c, d: NonzeroQ((c - d)**S(2) + S(-1)))) rule562 = ReplacementRule(pattern562, lambda x, b, m, c, f, a, d, e : -b*(-c - d + S(1))*Int((e + f*x)**(m + S(1))*exp(S(2)*a + S(2)*b*x)/(-c + d - (-c - d + S(1))*exp(S(2)*a + S(2)*b*x) + S(1)), x)/(f*(m + S(1))) + b*(c + d + S(1))*Int((e + f*x)**(m + S(1))*exp(S(2)*a + S(2)*b*x)/(c - d - (c + d + S(1))*exp(S(2)*a + S(2)*b*x) + S(1)), x)/(f*(m + S(1))) + (e + f*x)**(m + S(1))*atanh(c + d*coth(a + b*x))/(f*(m + S(1)))) rubi.add(rule562) pattern563 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*acoth(WC('c', S(0)) + WC('d', S(1))*coth(x_*WC('b', S(1)) + WC('a', S(0)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m: PositiveIntegerQ(m)), CustomConstraint(lambda c, d: NonzeroQ((c - d)**S(2) + S(-1)))) rule563 = ReplacementRule(pattern563, lambda x, b, m, c, f, a, d, e : -b*(-c - d + S(1))*Int((e + f*x)**(m + S(1))*exp(S(2)*a + S(2)*b*x)/(-c + d - (-c - d + S(1))*exp(S(2)*a + S(2)*b*x) + S(1)), x)/(f*(m + S(1))) + b*(c + d + S(1))*Int((e + f*x)**(m + S(1))*exp(S(2)*a + S(2)*b*x)/(c - d - (c + d + S(1))*exp(S(2)*a + S(2)*b*x) + S(1)), x)/(f*(m + S(1))) + (e + f*x)**(m + S(1))*acoth(c + d*coth(a + b*x))/(f*(m + S(1)))) rubi.add(rule563) pattern564 = Pattern(Integral(atanh(tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x))) rule564 = ReplacementRule(pattern564, lambda x, a, b : -b*Int(x*sec(S(2)*a + S(2)*b*x), x) + x*atanh(tan(a + b*x))) rubi.add(rule564) pattern565 = Pattern(Integral(acoth(tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x))) rule565 = ReplacementRule(pattern565, lambda x, a, b : -b*Int(x*sec(S(2)*a + S(2)*b*x), x) + x*acoth(tan(a + b*x))) rubi.add(rule565) pattern566 = Pattern(Integral(atanh(cot(x_*WC('b', S(1)) + WC('a', S(0)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x))) rule566 = ReplacementRule(pattern566, lambda x, a, b : -b*Int(x*sec(S(2)*a + S(2)*b*x), x) + x*atanh(cot(a + b*x))) rubi.add(rule566) pattern567 = Pattern(Integral(acoth(cot(x_*WC('b', S(1)) + WC('a', S(0)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x))) rule567 = ReplacementRule(pattern567, lambda x, a, b : -b*Int(x*sec(S(2)*a + S(2)*b*x), x) + x*acoth(cot(a + b*x))) rubi.add(rule567) pattern568 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*atanh(tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m: PositiveIntegerQ(m))) rule568 = ReplacementRule(pattern568, lambda x, b, m, f, a, e : -b*Int((e + f*x)**(m + S(1))*sec(S(2)*a + S(2)*b*x), x)/(f*(m + S(1))) + (e + f*x)**(m + S(1))*atanh(tan(a + b*x))/(f*(m + S(1)))) rubi.add(rule568) pattern569 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*acoth(tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m: PositiveIntegerQ(m))) rule569 = ReplacementRule(pattern569, lambda x, b, m, f, a, e : -b*Int((e + f*x)**(m + S(1))*sec(S(2)*a + S(2)*b*x), x)/(f*(m + S(1))) + (e + f*x)**(m + S(1))*acoth(tan(a + b*x))/(f*(m + S(1)))) rubi.add(rule569) pattern570 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*atanh(cot(x_*WC('b', S(1)) + WC('a', S(0)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m: PositiveIntegerQ(m))) rule570 = ReplacementRule(pattern570, lambda x, b, m, f, a, e : -b*Int((e + f*x)**(m + S(1))*sec(S(2)*a + S(2)*b*x), x)/(f*(m + S(1))) + (e + f*x)**(m + S(1))*atanh(cot(a + b*x))/(f*(m + S(1)))) rubi.add(rule570) pattern571 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*acoth(cot(x_*WC('b', S(1)) + WC('a', S(0)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m: PositiveIntegerQ(m))) rule571 = ReplacementRule(pattern571, lambda x, b, m, f, a, e : -b*Int((e + f*x)**(m + S(1))*sec(S(2)*a + S(2)*b*x), x)/(f*(m + S(1))) + (e + f*x)**(m + S(1))*acoth(cot(a + b*x))/(f*(m + S(1)))) rubi.add(rule571) pattern572 = Pattern(Integral(atanh(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda c, d: ZeroQ((ImaginaryI*d + c)**S(2) + S(-1)))) rule572 = ReplacementRule(pattern572, lambda x, b, c, a, d : ImaginaryI*b*Int(x/(ImaginaryI*d + c*exp(S(2)*ImaginaryI*a + S(2)*ImaginaryI*b*x) + c), x) + x*atanh(c + d*tan(a + b*x))) rubi.add(rule572) pattern573 = Pattern(Integral(acoth(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda c, d: ZeroQ((ImaginaryI*d + c)**S(2) + S(-1)))) rule573 = ReplacementRule(pattern573, lambda x, b, c, a, d : ImaginaryI*b*Int(x/(ImaginaryI*d + c*exp(S(2)*ImaginaryI*a + S(2)*ImaginaryI*b*x) + c), x) + x*acoth(c + d*tan(a + b*x))) rubi.add(rule573) pattern574 = Pattern(Integral(atanh(WC('c', S(0)) + WC('d', S(1))*cot(x_*WC('b', S(1)) + WC('a', S(0)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda c, d: ZeroQ((-ImaginaryI*d + c)**S(2) + S(-1)))) rule574 = ReplacementRule(pattern574, lambda x, b, c, a, d : ImaginaryI*b*Int(x/(-ImaginaryI*d - c*exp(S(2)*ImaginaryI*a + S(2)*ImaginaryI*b*x) + c), x) + x*atanh(c + d*cot(a + b*x))) rubi.add(rule574) pattern575 = Pattern(Integral(acoth(WC('c', S(0)) + WC('d', S(1))*cot(x_*WC('b', S(1)) + WC('a', S(0)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda c, d: ZeroQ((-ImaginaryI*d + c)**S(2) + S(-1)))) rule575 = ReplacementRule(pattern575, lambda x, b, c, a, d : ImaginaryI*b*Int(x/(-ImaginaryI*d - c*exp(S(2)*ImaginaryI*a + S(2)*ImaginaryI*b*x) + c), x) + x*acoth(c + d*cot(a + b*x))) rubi.add(rule575) pattern576 = Pattern(Integral(atanh(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda c, d: NonzeroQ((ImaginaryI*d + c)**S(2) + S(-1)))) rule576 = ReplacementRule(pattern576, lambda x, b, c, a, d : -ImaginaryI*b*(-ImaginaryI*d + c + S(1))*Int(x*exp(S(2)*ImaginaryI*a + S(2)*ImaginaryI*b*x)/(ImaginaryI*d + c + (-ImaginaryI*d + c + S(1))*exp(S(2)*ImaginaryI*a + S(2)*ImaginaryI*b*x) + S(1)), x) + ImaginaryI*b*(ImaginaryI*d - c + S(1))*Int(x*exp(S(2)*ImaginaryI*a + S(2)*ImaginaryI*b*x)/(-ImaginaryI*d - c + (ImaginaryI*d - c + S(1))*exp(S(2)*ImaginaryI*a + S(2)*ImaginaryI*b*x) + S(1)), x) + x*atanh(c + d*tan(a + b*x))) rubi.add(rule576) pattern577 = Pattern(Integral(acoth(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda c, d: NonzeroQ((ImaginaryI*d + c)**S(2) + S(-1)))) rule577 = ReplacementRule(pattern577, lambda x, b, c, a, d : -ImaginaryI*b*(-ImaginaryI*d + c + S(1))*Int(x*exp(S(2)*ImaginaryI*a + S(2)*ImaginaryI*b*x)/(ImaginaryI*d + c + (-ImaginaryI*d + c + S(1))*exp(S(2)*ImaginaryI*a + S(2)*ImaginaryI*b*x) + S(1)), x) + ImaginaryI*b*(ImaginaryI*d - c + S(1))*Int(x*exp(S(2)*ImaginaryI*a + S(2)*ImaginaryI*b*x)/(-ImaginaryI*d - c + (ImaginaryI*d - c + S(1))*exp(S(2)*ImaginaryI*a + S(2)*ImaginaryI*b*x) + S(1)), x) + x*acoth(c + d*tan(a + b*x))) rubi.add(rule577) pattern578 = Pattern(Integral(atanh(WC('c', S(0)) + WC('d', S(1))*cot(x_*WC('b', S(1)) + WC('a', S(0)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda c, d: NonzeroQ((-ImaginaryI*d + c)**S(2) + S(-1)))) rule578 = ReplacementRule(pattern578, lambda x, b, c, a, d : -ImaginaryI*b*(-ImaginaryI*d - c + S(1))*Int(x*exp(S(2)*ImaginaryI*a + S(2)*ImaginaryI*b*x)/(ImaginaryI*d - c - (-ImaginaryI*d - c + S(1))*exp(S(2)*ImaginaryI*a + S(2)*ImaginaryI*b*x) + S(1)), x) + ImaginaryI*b*(ImaginaryI*d + c + S(1))*Int(x*exp(S(2)*ImaginaryI*a + S(2)*ImaginaryI*b*x)/(-ImaginaryI*d + c - (ImaginaryI*d + c + S(1))*exp(S(2)*ImaginaryI*a + S(2)*ImaginaryI*b*x) + S(1)), x) + x*atanh(c + d*cot(a + b*x))) rubi.add(rule578) pattern579 = Pattern(Integral(acoth(WC('c', S(0)) + WC('d', S(1))*cot(x_*WC('b', S(1)) + WC('a', S(0)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda c, d: NonzeroQ((-ImaginaryI*d + c)**S(2) + S(-1)))) rule579 = ReplacementRule(pattern579, lambda x, b, c, a, d : -ImaginaryI*b*(-ImaginaryI*d - c + S(1))*Int(x*exp(S(2)*ImaginaryI*a + S(2)*ImaginaryI*b*x)/(ImaginaryI*d - c - (-ImaginaryI*d - c + S(1))*exp(S(2)*ImaginaryI*a + S(2)*ImaginaryI*b*x) + S(1)), x) + ImaginaryI*b*(ImaginaryI*d + c + S(1))*Int(x*exp(S(2)*ImaginaryI*a + S(2)*ImaginaryI*b*x)/(-ImaginaryI*d + c - (ImaginaryI*d + c + S(1))*exp(S(2)*ImaginaryI*a + S(2)*ImaginaryI*b*x) + S(1)), x) + x*acoth(c + d*cot(a + b*x))) rubi.add(rule579) pattern580 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*atanh(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m: PositiveIntegerQ(m)), CustomConstraint(lambda c, d: ZeroQ((ImaginaryI*d + c)**S(2) + S(-1)))) rule580 = ReplacementRule(pattern580, lambda x, b, m, c, f, a, d, e : ImaginaryI*b*Int((e + f*x)**(m + S(1))/(ImaginaryI*d + c*exp(S(2)*ImaginaryI*a + S(2)*ImaginaryI*b*x) + c), x)/(f*(m + S(1))) + (e + f*x)**(m + S(1))*atanh(c + d*tan(a + b*x))/(f*(m + S(1)))) rubi.add(rule580) pattern581 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*acoth(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m: PositiveIntegerQ(m)), CustomConstraint(lambda c, d: ZeroQ((ImaginaryI*d + c)**S(2) + S(-1)))) rule581 = ReplacementRule(pattern581, lambda x, b, m, c, f, a, d, e : ImaginaryI*b*Int((e + f*x)**(m + S(1))/(ImaginaryI*d + c*exp(S(2)*ImaginaryI*a + S(2)*ImaginaryI*b*x) + c), x)/(f*(m + S(1))) + (e + f*x)**(m + S(1))*acoth(c + d*tan(a + b*x))/(f*(m + S(1)))) rubi.add(rule581) pattern582 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*atanh(WC('c', S(0)) + WC('d', S(1))*cot(x_*WC('b', S(1)) + WC('a', S(0)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m: PositiveIntegerQ(m)), CustomConstraint(lambda c, d: ZeroQ((-ImaginaryI*d + c)**S(2) + S(-1)))) rule582 = ReplacementRule(pattern582, lambda x, b, m, c, f, a, d, e : ImaginaryI*b*Int((e + f*x)**(m + S(1))/(-ImaginaryI*d - c*exp(S(2)*ImaginaryI*a + S(2)*ImaginaryI*b*x) + c), x)/(f*(m + S(1))) + (e + f*x)**(m + S(1))*atanh(c + d*cot(a + b*x))/(f*(m + S(1)))) rubi.add(rule582) pattern583 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*acoth(WC('c', S(0)) + WC('d', S(1))*cot(x_*WC('b', S(1)) + WC('a', S(0)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m: PositiveIntegerQ(m)), CustomConstraint(lambda c, d: ZeroQ((-ImaginaryI*d + c)**S(2) + S(-1)))) rule583 = ReplacementRule(pattern583, lambda x, b, m, c, f, a, d, e : ImaginaryI*b*Int((e + f*x)**(m + S(1))/(-ImaginaryI*d - c*exp(S(2)*ImaginaryI*a + S(2)*ImaginaryI*b*x) + c), x)/(f*(m + S(1))) + (e + f*x)**(m + S(1))*acoth(c + d*cot(a + b*x))/(f*(m + S(1)))) rubi.add(rule583) pattern584 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*atanh(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m: PositiveIntegerQ(m)), CustomConstraint(lambda c, d: NonzeroQ((ImaginaryI*d + c)**S(2) + S(-1)))) rule584 = ReplacementRule(pattern584, lambda x, b, m, c, f, a, d, e : -ImaginaryI*b*(-ImaginaryI*d + c + S(1))*Int((e + f*x)**(m + S(1))*exp(S(2)*ImaginaryI*a + S(2)*ImaginaryI*b*x)/(ImaginaryI*d + c + (-ImaginaryI*d + c + S(1))*exp(S(2)*ImaginaryI*a + S(2)*ImaginaryI*b*x) + S(1)), x)/(f*(m + S(1))) + ImaginaryI*b*(ImaginaryI*d - c + S(1))*Int((e + f*x)**(m + S(1))*exp(S(2)*ImaginaryI*a + S(2)*ImaginaryI*b*x)/(-ImaginaryI*d - c + (ImaginaryI*d - c + S(1))*exp(S(2)*ImaginaryI*a + S(2)*ImaginaryI*b*x) + S(1)), x)/(f*(m + S(1))) + (e + f*x)**(m + S(1))*atanh(c + d*tan(a + b*x))/(f*(m + S(1)))) rubi.add(rule584) pattern585 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*acoth(WC('c', S(0)) + WC('d', S(1))*tan(x_*WC('b', S(1)) + WC('a', S(0)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m: PositiveIntegerQ(m)), CustomConstraint(lambda c, d: NonzeroQ((ImaginaryI*d + c)**S(2) + S(-1)))) rule585 = ReplacementRule(pattern585, lambda x, b, m, c, f, a, d, e : -ImaginaryI*b*(-ImaginaryI*d + c + S(1))*Int((e + f*x)**(m + S(1))*exp(S(2)*ImaginaryI*a + S(2)*ImaginaryI*b*x)/(ImaginaryI*d + c + (-ImaginaryI*d + c + S(1))*exp(S(2)*ImaginaryI*a + S(2)*ImaginaryI*b*x) + S(1)), x)/(f*(m + S(1))) + ImaginaryI*b*(ImaginaryI*d - c + S(1))*Int((e + f*x)**(m + S(1))*exp(S(2)*ImaginaryI*a + S(2)*ImaginaryI*b*x)/(-ImaginaryI*d - c + (ImaginaryI*d - c + S(1))*exp(S(2)*ImaginaryI*a + S(2)*ImaginaryI*b*x) + S(1)), x)/(f*(m + S(1))) + (e + f*x)**(m + S(1))*acoth(c + d*tan(a + b*x))/(f*(m + S(1)))) rubi.add(rule585) pattern586 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*atanh(WC('c', S(0)) + WC('d', S(1))*cot(x_*WC('b', S(1)) + WC('a', S(0)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m: PositiveIntegerQ(m)), CustomConstraint(lambda c, d: NonzeroQ((-ImaginaryI*d + c)**S(2) + S(-1)))) rule586 = ReplacementRule(pattern586, lambda x, b, m, c, f, a, d, e : -ImaginaryI*b*(-ImaginaryI*d - c + S(1))*Int((e + f*x)**(m + S(1))*exp(S(2)*ImaginaryI*a + S(2)*ImaginaryI*b*x)/(ImaginaryI*d - c - (-ImaginaryI*d - c + S(1))*exp(S(2)*ImaginaryI*a + S(2)*ImaginaryI*b*x) + S(1)), x)/(f*(m + S(1))) + ImaginaryI*b*(ImaginaryI*d + c + S(1))*Int((e + f*x)**(m + S(1))*exp(S(2)*ImaginaryI*a + S(2)*ImaginaryI*b*x)/(-ImaginaryI*d + c - (ImaginaryI*d + c + S(1))*exp(S(2)*ImaginaryI*a + S(2)*ImaginaryI*b*x) + S(1)), x)/(f*(m + S(1))) + (e + f*x)**(m + S(1))*atanh(c + d*cot(a + b*x))/(f*(m + S(1)))) rubi.add(rule586) pattern587 = Pattern(Integral((x_*WC('f', S(1)) + WC('e', S(0)))**WC('m', S(1))*acoth(WC('c', S(0)) + WC('d', S(1))*cot(x_*WC('b', S(1)) + WC('a', S(0)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda f, x: FreeQ(f, x)), CustomConstraint(lambda m: PositiveIntegerQ(m)), CustomConstraint(lambda c, d: NonzeroQ((-ImaginaryI*d + c)**S(2) + S(-1)))) rule587 = ReplacementRule(pattern587, lambda x, b, m, c, f, a, d, e : -ImaginaryI*b*(-ImaginaryI*d - c + S(1))*Int((e + f*x)**(m + S(1))*exp(S(2)*ImaginaryI*a + S(2)*ImaginaryI*b*x)/(ImaginaryI*d - c - (-ImaginaryI*d - c + S(1))*exp(S(2)*ImaginaryI*a + S(2)*ImaginaryI*b*x) + S(1)), x)/(f*(m + S(1))) + ImaginaryI*b*(ImaginaryI*d + c + S(1))*Int((e + f*x)**(m + S(1))*exp(S(2)*ImaginaryI*a + S(2)*ImaginaryI*b*x)/(-ImaginaryI*d + c - (ImaginaryI*d + c + S(1))*exp(S(2)*ImaginaryI*a + S(2)*ImaginaryI*b*x) + S(1)), x)/(f*(m + S(1))) + (e + f*x)**(m + S(1))*acoth(c + d*cot(a + b*x))/(f*(m + S(1)))) rubi.add(rule587) pattern588 = Pattern(Integral(atanh(u_), x_), CustomConstraint(lambda x, u: InverseFunctionFreeQ(u, x))) rule588 = ReplacementRule(pattern588, lambda x, u : x*atanh(u) - Int(SimplifyIntegrand(x*D(u, x)/(-u**S(2) + S(1)), x), x)) rubi.add(rule588) pattern589 = Pattern(Integral(acoth(u_), x_), CustomConstraint(lambda x, u: InverseFunctionFreeQ(u, x))) rule589 = ReplacementRule(pattern589, lambda x, u : x*acoth(u) - Int(SimplifyIntegrand(x*D(u, x)/(-u**S(2) + S(1)), x), x)) rubi.add(rule589) pattern590 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*atanh(u_)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda m: NonzeroQ(m + S(1))), CustomConstraint(lambda x, u: InverseFunctionFreeQ(u, x)), CustomConstraint(lambda x, m, c, d, u: Not(FunctionOfQ((c + d*x)**(m + S(1)), u, x))), CustomConstraint(lambda x, u, m: FalseQ(PowerVariableExpn(u, m + S(1), x)))) rule590 = ReplacementRule(pattern590, lambda x, b, m, c, a, d, u : -b*Int(SimplifyIntegrand((c + d*x)**(m + S(1))*D(u, x)/(-u**S(2) + S(1)), x), x)/(d*(m + S(1))) + (a + b*atanh(u))*(c + d*x)**(m + S(1))/(d*(m + S(1)))) rubi.add(rule590) pattern591 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acoth(u_)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda m: NonzeroQ(m + S(1))), CustomConstraint(lambda x, u: InverseFunctionFreeQ(u, x)), CustomConstraint(lambda x, m, c, d, u: Not(FunctionOfQ((c + d*x)**(m + S(1)), u, x))), CustomConstraint(lambda x, u, m: FalseQ(PowerVariableExpn(u, m + S(1), x)))) rule591 = ReplacementRule(pattern591, lambda x, b, m, c, a, d, u : -b*Int(SimplifyIntegrand((c + d*x)**(m + S(1))*D(u, x)/(-u**S(2) + S(1)), x), x)/(d*(m + S(1))) + (a + b*acoth(u))*(c + d*x)**(m + S(1))/(d*(m + S(1)))) rubi.add(rule591) pattern592 = Pattern(Integral(v_*(WC('a', S(0)) + WC('b', S(1))*atanh(u_)), x_), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda x, u: InverseFunctionFreeQ(u, x)), CustomConstraint(lambda v, x: Not(MatchQ(v, Condition((x*Optional(Pattern(d, Blank)) + Optional(Pattern(c, Blank)))**Optional(Pattern(m, Blank)))))), CustomConstraint(lambda x, b, v, a, u: FalseQ(FunctionOfLinear(v*(a + b*atanh(u)), x))), CustomConstraint(lambda a, u, x, b, w: InverseFunctionFreeQ(w, x))) def With592(x, b, v, a, u): w = IntHide(v, x) return -b*Int(SimplifyIntegrand(w*D(u, x)/(-u**S(2) + S(1)), x), x) + Dist(a + b*atanh(u), w, x) rule592 = ReplacementRule(pattern592, lambda x, b, v, a, u : With592(x, b, v, a, u)) rubi.add(rule592) pattern593 = Pattern(Integral(v_*(WC('a', S(0)) + WC('b', S(1))*acoth(u_)), x_), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda x, u: InverseFunctionFreeQ(u, x)), CustomConstraint(lambda v, x: Not(MatchQ(v, Condition((x*Optional(Pattern(d, Blank)) + Optional(Pattern(c, Blank)))**Optional(Pattern(m, Blank)))))), CustomConstraint(lambda x, b, v, a, u: FalseQ(FunctionOfLinear(v*(a + b*acoth(u)), x))), CustomConstraint(lambda a, u, x, b, w: InverseFunctionFreeQ(w, x))) def With593(x, b, v, a, u): w = IntHide(v, x) return -b*Int(SimplifyIntegrand(w*D(u, x)/(-u**S(2) + S(1)), x), x) + Dist(a + b*acoth(u), w, x) rule593 = ReplacementRule(pattern593, lambda x, b, v, a, u : With593(x, b, v, a, u)) rubi.add(rule593) pattern594 = Pattern(Integral(asech(x_*WC('c', S(1))), x_), CustomConstraint(lambda c, x: FreeQ(c, x))) rule594 = ReplacementRule(pattern594, lambda c, x : x*asech(c*x) + sqrt(c*x + S(1))*sqrt(1/(c*x + S(1)))*Int(S(1)/(sqrt(-c*x + S(1))*sqrt(c*x + S(1))), x)) rubi.add(rule594) pattern595 = Pattern(Integral(acsch(x_*WC('c', S(1))), x_), CustomConstraint(lambda c, x: FreeQ(c, x))) rule595 = ReplacementRule(pattern595, lambda c, x : x*acsch(c*x) + Int(S(1)/(x*sqrt(S(1) + S(1)/(c**S(2)*x**S(2)))), x)/c) rubi.add(rule595) pattern596 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asech(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda n, x: FreeQ(n, x))) rule596 = ReplacementRule(pattern596, lambda x, b, c, a, n : -Subst(Int((a + b*x)**n*tanh(x)*sech(x), x), x, asech(c*x))/c) rubi.add(rule596) pattern597 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acsch(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda n, x: FreeQ(n, x))) rule597 = ReplacementRule(pattern597, lambda x, b, c, a, n : -Subst(Int((a + b*x)**n*coth(x)*csch(x), x), x, acsch(c*x))/c) rubi.add(rule597) pattern598 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*asech(x_*WC('c', S(1))))/x_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x))) rule598 = ReplacementRule(pattern598, lambda c, a, b, x : -Subst(Int((a + b*acosh(x/c))/x, x), x, 1/x)) rubi.add(rule598) pattern599 = Pattern(Integral((WC('a', S(0)) + WC('b', S(1))*acsch(x_*WC('c', S(1))))/x_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x))) rule599 = ReplacementRule(pattern599, lambda c, a, b, x : -Subst(Int((a + b*asinh(x/c))/x, x), x, 1/x)) rubi.add(rule599) pattern600 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asech(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda m: NonzeroQ(m + S(1)))) rule600 = ReplacementRule(pattern600, lambda x, b, m, c, a : b*sqrt(c*x + S(1))*sqrt(1/(c*x + S(1)))*Int(x**m/(sqrt(-c*x + S(1))*sqrt(c*x + S(1))), x)/(m + S(1)) + x**(m + S(1))*(a + b*asech(c*x))/(m + S(1))) rubi.add(rule600) pattern601 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acsch(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda m: NonzeroQ(m + S(1)))) rule601 = ReplacementRule(pattern601, lambda x, b, m, c, a : b*Int(x**(m + S(-1))/sqrt(S(1) + S(1)/(c**S(2)*x**S(2))), x)/(c*(m + S(1))) + x**(m + S(1))*(a + b*acsch(c*x))/(m + S(1))) rubi.add(rule601) pattern602 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asech(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda m: IntegerQ(m))) rule602 = ReplacementRule(pattern602, lambda x, b, m, c, a, n : -c**(-m + S(-1))*Subst(Int((a + b*x)**n*tanh(x)*sech(x)**(m + S(1)), x), x, asech(c*x))) rubi.add(rule602) pattern603 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acsch(x_*WC('c', S(1))))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda m: IntegerQ(m))) rule603 = ReplacementRule(pattern603, lambda x, b, m, c, a, n : -c**(-m + S(-1))*Subst(Int((a + b*x)**n*coth(x)*csch(x)**(m + S(1)), x), x, acsch(c*x))) rubi.add(rule603) pattern604 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asech(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n, x: FreeQ(n, x))) rule604 = ReplacementRule(pattern604, lambda x, b, m, c, a, n : Int(x**m*(a + b*asech(c*x))**n, x)) rubi.add(rule604) pattern605 = Pattern(Integral(x_**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acsch(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n, x: FreeQ(n, x))) rule605 = ReplacementRule(pattern605, lambda x, b, m, c, a, n : Int(x**m*(a + b*acsch(c*x))**n, x)) rubi.add(rule605) pattern606 = Pattern(Integral((x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asech(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda p: PositiveIntegerQ(p) | NegativeIntegerQ(p + S(1)/2)), ) def With606(p, x, b, c, a, d, e): u = IntHide((d + e*x**S(2))**p, x) return b*sqrt(c*x + S(1))*sqrt(1/(c*x + S(1)))*Int(SimplifyIntegrand(u/(x*sqrt(-c*x + S(1))*sqrt(c*x + S(1))), x), x) + Dist(a + b*asech(c*x), u, x) rule606 = ReplacementRule(pattern606, lambda p, x, b, c, a, d, e : With606(p, x, b, c, a, d, e)) rubi.add(rule606) pattern607 = Pattern(Integral((x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acsch(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda p: PositiveIntegerQ(p) | NegativeIntegerQ(p + S(1)/2)), ) def With607(p, x, b, c, a, d, e): u = IntHide((d + e*x**S(2))**p, x) return -b*c*x*Int(SimplifyIntegrand(u/(x*sqrt(-c**S(2)*x**S(2) + S(-1))), x), x)/sqrt(-c**S(2)*x**S(2)) + Dist(a + b*acsch(c*x), u, x) rule607 = ReplacementRule(pattern607, lambda p, x, b, c, a, d, e : With607(p, x, b, c, a, d, e)) rubi.add(rule607) pattern608 = Pattern(Integral((x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asech(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p: IntegerQ(p))) rule608 = ReplacementRule(pattern608, lambda p, x, b, c, a, d, e, n : -Subst(Int(x**(-S(2)*p + S(-2))*(a + b*acosh(x/c))**n*(d*x**S(2) + e)**p, x), x, 1/x)) rubi.add(rule608) pattern609 = Pattern(Integral((x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acsch(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p: IntegerQ(p))) rule609 = ReplacementRule(pattern609, lambda p, x, b, c, a, d, e, n : -Subst(Int(x**(-S(2)*p + S(-2))*(a + b*asinh(x/c))**n*(d*x**S(2) + e)**p, x), x, 1/x)) rubi.add(rule609) pattern610 = Pattern(Integral((x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**p_*(WC('a', S(0)) + WC('b', S(1))*asech(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda p: IntegerQ(p + S(1)/2)), CustomConstraint(lambda e: PositiveQ(e)), CustomConstraint(lambda d: Negative(d))) rule610 = ReplacementRule(pattern610, lambda p, x, b, c, a, d, e, n : -sqrt(x**S(2))*Subst(Int(x**(-S(2)*p + S(-2))*(a + b*acosh(x/c))**n*(d*x**S(2) + e)**p, x), x, 1/x)/x) rubi.add(rule610) pattern611 = Pattern(Integral((x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**p_*(WC('a', S(0)) + WC('b', S(1))*acsch(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda p: IntegerQ(p + S(1)/2)), CustomConstraint(lambda e: PositiveQ(e)), CustomConstraint(lambda d: Negative(d))) rule611 = ReplacementRule(pattern611, lambda p, x, b, c, a, d, e, n : -sqrt(x**S(2))*Subst(Int(x**(-S(2)*p + S(-2))*(a + b*asinh(x/c))**n*(d*x**S(2) + e)**p, x), x, 1/x)/x) rubi.add(rule611) pattern612 = Pattern(Integral((x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**p_*(WC('a', S(0)) + WC('b', S(1))*asech(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda p: IntegerQ(p + S(1)/2)), CustomConstraint(lambda d, e: Not(Negative(d) & PositiveQ(e)))) rule612 = ReplacementRule(pattern612, lambda p, x, b, c, a, d, e, n : -sqrt(d + e*x**S(2))*Subst(Int(x**(-S(2)*p + S(-2))*(a + b*acosh(x/c))**n*(d*x**S(2) + e)**p, x), x, 1/x)/(x*sqrt(d/x**S(2) + e))) rubi.add(rule612) pattern613 = Pattern(Integral((x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**p_*(WC('a', S(0)) + WC('b', S(1))*acsch(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda p: IntegerQ(p + S(1)/2)), CustomConstraint(lambda d, e: Not(Negative(d) & PositiveQ(e)))) rule613 = ReplacementRule(pattern613, lambda p, x, b, c, a, d, e, n : -sqrt(d + e*x**S(2))*Subst(Int(x**(-S(2)*p + S(-2))*(a + b*asinh(x/c))**n*(d*x**S(2) + e)**p, x), x, 1/x)/(x*sqrt(d/x**S(2) + e))) rubi.add(rule613) pattern614 = Pattern(Integral((x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asech(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x))) rule614 = ReplacementRule(pattern614, lambda p, x, b, c, a, d, e, n : Int((a + b*asech(c*x))**n*(d + e*x**S(2))**p, x)) rubi.add(rule614) pattern615 = Pattern(Integral((x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acsch(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x))) rule615 = ReplacementRule(pattern615, lambda p, x, b, c, a, d, e, n : Int((a + b*acsch(c*x))**n*(d + e*x**S(2))**p, x)) rubi.add(rule615) pattern616 = Pattern(Integral(x_*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asech(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda p: NonzeroQ(p + S(1)))) rule616 = ReplacementRule(pattern616, lambda p, x, b, c, a, d, e : b*sqrt(c*x + S(1))*sqrt(1/(c*x + S(1)))*Int((d + e*x**S(2))**(p + S(1))/(x*sqrt(-c*x + S(1))*sqrt(c*x + S(1))), x)/(S(2)*e*(p + S(1))) + (a + b*asech(c*x))*(d + e*x**S(2))**(p + S(1))/(S(2)*e*(p + S(1)))) rubi.add(rule616) pattern617 = Pattern(Integral(x_*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acsch(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda p: NonzeroQ(p + S(1)))) rule617 = ReplacementRule(pattern617, lambda p, x, b, c, a, d, e : -b*c*x*Int((d + e*x**S(2))**(p + S(1))/(x*sqrt(-c**S(2)*x**S(2) + S(-1))), x)/(S(2)*e*sqrt(-c**S(2)*x**S(2))*(p + S(1))) + (a + b*acsch(c*x))*(d + e*x**S(2))**(p + S(1))/(S(2)*e*(p + S(1)))) rubi.add(rule617) pattern618 = Pattern(Integral(x_**WC('m', S(1))*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asech(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda p, m: (NegativeIntegerQ(m/S(2) + p + S(1)/2) & Not(NegativeIntegerQ(m/S(2) + S(-1)/2))) | (PositiveIntegerQ(p) & Not(NegativeIntegerQ(m/S(2) + S(-1)/2) & Greater(m + S(2)*p + S(3), S(0)))) | (PositiveIntegerQ(m/S(2) + S(1)/2) & Not(NegativeIntegerQ(p) & Greater(m + S(2)*p + S(3), S(0))))), ) def With618(p, x, b, m, c, a, d, e): u = IntHide(x**m*(d + e*x**S(2))**p, x) return b*sqrt(c*x + S(1))*sqrt(1/(c*x + S(1)))*Int(SimplifyIntegrand(u/(x*sqrt(-c*x + S(1))*sqrt(c*x + S(1))), x), x) + Dist(a + b*asech(c*x), u, x) rule618 = ReplacementRule(pattern618, lambda p, x, b, m, c, a, d, e : With618(p, x, b, m, c, a, d, e)) rubi.add(rule618) pattern619 = Pattern(Integral(x_**WC('m', S(1))*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acsch(x_*WC('c', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda p, m: (NegativeIntegerQ(m/S(2) + p + S(1)/2) & Not(NegativeIntegerQ(m/S(2) + S(-1)/2))) | (PositiveIntegerQ(p) & Not(NegativeIntegerQ(m/S(2) + S(-1)/2) & Greater(m + S(2)*p + S(3), S(0)))) | (PositiveIntegerQ(m/S(2) + S(1)/2) & Not(NegativeIntegerQ(p) & Greater(m + S(2)*p + S(3), S(0))))), ) def With619(p, x, b, m, c, a, d, e): u = IntHide(x**m*(d + e*x**S(2))**p, x) return -b*c*x*Int(SimplifyIntegrand(u/(x*sqrt(-c**S(2)*x**S(2) + S(-1))), x), x)/sqrt(-c**S(2)*x**S(2)) + Dist(a + b*acsch(c*x), u, x) rule619 = ReplacementRule(pattern619, lambda p, x, b, m, c, a, d, e : With619(p, x, b, m, c, a, d, e)) rubi.add(rule619) pattern620 = Pattern(Integral(x_**WC('m', S(1))*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asech(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, m: IntegersQ(m, p))) rule620 = ReplacementRule(pattern620, lambda p, x, b, m, c, a, d, e, n : -Subst(Int(x**(-m - S(2)*p + S(-2))*(a + b*acosh(x/c))**n*(d*x**S(2) + e)**p, x), x, 1/x)) rubi.add(rule620) pattern621 = Pattern(Integral(x_**WC('m', S(1))*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acsch(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, m: IntegersQ(m, p))) rule621 = ReplacementRule(pattern621, lambda p, x, b, m, c, a, d, e, n : -Subst(Int(x**(-m - S(2)*p + S(-2))*(a + b*asinh(x/c))**n*(d*x**S(2) + e)**p, x), x, 1/x)) rubi.add(rule621) pattern622 = Pattern(Integral(x_**WC('m', S(1))*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**p_*(WC('a', S(0)) + WC('b', S(1))*asech(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda m: IntegerQ(m)), CustomConstraint(lambda p: IntegerQ(p + S(1)/2)), CustomConstraint(lambda e: PositiveQ(e)), CustomConstraint(lambda d: Negative(d))) rule622 = ReplacementRule(pattern622, lambda p, x, b, m, c, a, d, e, n : -sqrt(x**S(2))*Subst(Int(x**(-m - S(2)*p + S(-2))*(a + b*acosh(x/c))**n*(d*x**S(2) + e)**p, x), x, 1/x)/x) rubi.add(rule622) pattern623 = Pattern(Integral(x_**WC('m', S(1))*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**p_*(WC('a', S(0)) + WC('b', S(1))*acsch(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda m: IntegerQ(m)), CustomConstraint(lambda p: IntegerQ(p + S(1)/2)), CustomConstraint(lambda e: PositiveQ(e)), CustomConstraint(lambda d: Negative(d))) rule623 = ReplacementRule(pattern623, lambda p, x, b, m, c, a, d, e, n : -sqrt(x**S(2))*Subst(Int(x**(-m - S(2)*p + S(-2))*(a + b*asinh(x/c))**n*(d*x**S(2) + e)**p, x), x, 1/x)/x) rubi.add(rule623) pattern624 = Pattern(Integral(x_**WC('m', S(1))*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**p_*(WC('a', S(0)) + WC('b', S(1))*asech(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, e, d: ZeroQ(c**S(2)*d + e)), CustomConstraint(lambda m: IntegerQ(m)), CustomConstraint(lambda p: IntegerQ(p + S(1)/2)), CustomConstraint(lambda d, e: Not(Negative(d) & PositiveQ(e)))) rule624 = ReplacementRule(pattern624, lambda p, x, b, m, c, a, d, e, n : -sqrt(d + e*x**S(2))*Subst(Int(x**(-m - S(2)*p + S(-2))*(a + b*acosh(x/c))**n*(d*x**S(2) + e)**p, x), x, 1/x)/(x*sqrt(d/x**S(2) + e))) rubi.add(rule624) pattern625 = Pattern(Integral(x_**WC('m', S(1))*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**p_*(WC('a', S(0)) + WC('b', S(1))*acsch(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda c, d, e: ZeroQ(-c**S(2)*d + e)), CustomConstraint(lambda m: IntegerQ(m)), CustomConstraint(lambda p: IntegerQ(p + S(1)/2)), CustomConstraint(lambda d, e: Not(Negative(d) & PositiveQ(e)))) rule625 = ReplacementRule(pattern625, lambda p, x, b, m, c, a, d, e, n : -sqrt(d + e*x**S(2))*Subst(Int(x**(-m - S(2)*p + S(-2))*(a + b*asinh(x/c))**n*(d*x**S(2) + e)**p, x), x, 1/x)/(x*sqrt(d/x**S(2) + e))) rubi.add(rule625) pattern626 = Pattern(Integral(x_**WC('m', S(1))*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*asech(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x))) rule626 = ReplacementRule(pattern626, lambda p, x, b, m, c, a, d, e, n : Int(x**m*(a + b*asech(c*x))**n*(d + e*x**S(2))**p, x)) rubi.add(rule626) pattern627 = Pattern(Integral(x_**WC('m', S(1))*(x_**S(2)*WC('e', S(1)) + WC('d', S(0)))**WC('p', S(1))*(WC('a', S(0)) + WC('b', S(1))*acsch(x_*WC('c', S(1))))**WC('n', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x))) rule627 = ReplacementRule(pattern627, lambda p, x, b, m, c, a, d, e, n : Int(x**m*(a + b*acsch(c*x))**n*(d + e*x**S(2))**p, x)) rubi.add(rule627) pattern628 = Pattern(Integral(asech(a_ + x_*WC('b', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x))) rule628 = ReplacementRule(pattern628, lambda x, a, b : Int(sqrt((-a - b*x + S(1))/(a + b*x + S(1)))/(-a - b*x + S(1)), x) + (a + b*x)*asech(a + b*x)/b) rubi.add(rule628) pattern629 = Pattern(Integral(acsch(a_ + x_*WC('b', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x))) rule629 = ReplacementRule(pattern629, lambda x, a, b : Int(S(1)/(sqrt(S(1) + (a + b*x)**(S(-2)))*(a + b*x)), x) + (a + b*x)*acsch(a + b*x)/b) rubi.add(rule629) pattern630 = Pattern(Integral(asech(a_ + x_*WC('b', S(1)))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda n, x: FreeQ(n, x))) rule630 = ReplacementRule(pattern630, lambda x, a, n, b : -Subst(Int(x**n*tanh(x)*sech(x), x), x, asech(a + b*x))/b) rubi.add(rule630) pattern631 = Pattern(Integral(acsch(a_ + x_*WC('b', S(1)))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda n, x: FreeQ(n, x))) rule631 = ReplacementRule(pattern631, lambda x, a, n, b : -Subst(Int(x**n*coth(x)*csch(x), x), x, acsch(a + b*x))/b) rubi.add(rule631) pattern632 = Pattern(Integral(asech(a_ + x_*WC('b', S(1)))/x_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x))) rule632 = ReplacementRule(pattern632, lambda x, a, b : -PolyLog(S(2), (-sqrt(-a**S(2) + S(1)) + S(1))*exp(-asech(a + b*x))/a) - PolyLog(S(2), (sqrt(-a**S(2) + S(1)) + S(1))*exp(-asech(a + b*x))/a) + PolyLog(S(2), -exp(-S(2)*asech(a + b*x)))/S(2) + log(S(1) - (-sqrt(-a**S(2) + S(1)) + S(1))*exp(-asech(a + b*x))/a)*asech(a + b*x) + log(S(1) - (sqrt(-a**S(2) + S(1)) + S(1))*exp(-asech(a + b*x))/a)*asech(a + b*x) - log(S(1) + exp(-S(2)*asech(a + b*x)))*asech(a + b*x)) rubi.add(rule632) pattern633 = Pattern(Integral(acsch(a_ + x_*WC('b', S(1)))/x_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x))) rule633 = ReplacementRule(pattern633, lambda x, a, b : PolyLog(S(2), (-sqrt(a**S(2) + S(1)) + S(-1))*exp(acsch(a + b*x))/a) + PolyLog(S(2), (sqrt(a**S(2) + S(1)) + S(-1))*exp(acsch(a + b*x))/a) + PolyLog(S(2), exp(-S(2)*acsch(a + b*x)))/S(2) + log(S(1) + (-sqrt(a**S(2) + S(1)) + S(1))*exp(acsch(a + b*x))/a)*acsch(a + b*x) + log(S(1) + (sqrt(a**S(2) + S(1)) + S(1))*exp(acsch(a + b*x))/a)*acsch(a + b*x) - log(S(1) - exp(-S(2)*acsch(a + b*x)))*acsch(a + b*x) - acsch(a + b*x)**S(2)) rubi.add(rule633) pattern634 = Pattern(Integral(x_**WC('m', S(1))*asech(a_ + x_*WC('b', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda m: IntegerQ(m)), CustomConstraint(lambda m: NonzeroQ(m + S(1)))) rule634 = ReplacementRule(pattern634, lambda x, a, b, m : b**(-m + S(-1))*(b**(m + S(1))*x**(m + S(1)) - (-a)**(m + S(1)))*asech(a + b*x)/(m + S(1)) + b**(-m + S(-1))*Subst(Int(x**(-m + S(-1))*((-a*x)**(m + S(1)) - (-a*x + S(1))**(m + S(1)))/(sqrt(x + S(-1))*sqrt(x + S(1))), x), x, 1/(a + b*x))/(m + S(1))) rubi.add(rule634) pattern635 = Pattern(Integral(x_**WC('m', S(1))*acsch(a_ + x_*WC('b', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda m: IntegerQ(m)), CustomConstraint(lambda m: NonzeroQ(m + S(1)))) rule635 = ReplacementRule(pattern635, lambda x, a, b, m : b**(-m + S(-1))*(b**(m + S(1))*x**(m + S(1)) - (-a)**(m + S(1)))*acsch(a + b*x)/(m + S(1)) + b**(-m + S(-1))*Subst(Int(x**(-m + S(-1))*((-a*x)**(m + S(1)) - (-a*x + S(1))**(m + S(1)))/sqrt(x**S(2) + S(1)), x), x, 1/(a + b*x))/(m + S(1))) rubi.add(rule635) pattern636 = Pattern(Integral(x_**WC('m', S(1))*asech(a_ + x_*WC('b', S(1)))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda m: PositiveIntegerQ(m))) rule636 = ReplacementRule(pattern636, lambda x, b, m, a, n : -b**(-m + S(-1))*Subst(Int(x**n*(-a + sech(x))**m*tanh(x)*sech(x), x), x, asech(a + b*x))) rubi.add(rule636) pattern637 = Pattern(Integral(x_**WC('m', S(1))*acsch(a_ + x_*WC('b', S(1)))**n_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda m: PositiveIntegerQ(m))) rule637 = ReplacementRule(pattern637, lambda x, b, m, a, n : -b**(-m + S(-1))*Subst(Int(x**n*(-a + csch(x))**m*coth(x)*csch(x), x), x, acsch(a + b*x))) rubi.add(rule637) pattern638 = Pattern(Integral(WC('u', S(1))*asech(WC('c', S(1))/(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda m, x: FreeQ(m, x))) rule638 = ReplacementRule(pattern638, lambda x, b, m, c, a, u, n : Int(u*acosh(a/c + b*x**n/c)**m, x)) rubi.add(rule638) pattern639 = Pattern(Integral(WC('u', S(1))*acsch(WC('c', S(1))/(x_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0))))**WC('m', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda m, x: FreeQ(m, x))) rule639 = ReplacementRule(pattern639, lambda x, b, m, c, a, u, n : Int(u*asinh(a/c + b*x**n/c)**m, x)) rubi.add(rule639) pattern640 = Pattern(Integral(exp(asech(x_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x))) rule640 = ReplacementRule(pattern640, lambda x, a : x*exp(asech(a*x)) + Int(sqrt((-a*x + S(1))/(a*x + S(1)))/(x*(-a*x + S(1))), x)/a + log(x)/a) rubi.add(rule640) pattern641 = Pattern(Integral(exp(asech(x_**p_*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda p, x: FreeQ(p, x))) rule641 = ReplacementRule(pattern641, lambda x, a, p : x*exp(asech(a*x**p)) + p*sqrt(a*x**p + S(1))*sqrt(1/(a*x**p + S(1)))*Int(x**(-p)/(sqrt(-a*x**p + S(1))*sqrt(a*x**p + S(1))), x)/a + p*Int(x**(-p), x)/a) rubi.add(rule641) pattern642 = Pattern(Integral(exp(acsch(x_**WC('p', S(1))*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda p, x: FreeQ(p, x))) rule642 = ReplacementRule(pattern642, lambda x, a, p : Int(sqrt(S(1) + x**(-S(2)*p)/a**S(2)), x) + Int(x**(-p), x)/a) rubi.add(rule642) pattern643 = Pattern(Integral(exp(WC('n', S(1))*asech(u_)), x_), CustomConstraint(lambda n: IntegerQ(n))) rule643 = ReplacementRule(pattern643, lambda x, u, n : Int((sqrt((-u + S(1))/(u + S(1))) + sqrt((-u + S(1))/(u + S(1)))/u + 1/u)**n, x)) rubi.add(rule643) pattern644 = Pattern(Integral(exp(WC('n', S(1))*acsch(u_)), x_), CustomConstraint(lambda n: IntegerQ(n))) rule644 = ReplacementRule(pattern644, lambda x, u, n : Int((sqrt(S(1) + u**(S(-2))) + 1/u)**n, x)) rubi.add(rule644) pattern645 = Pattern(Integral(exp(asech(x_**WC('p', S(1))*WC('a', S(1))))/x_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda p, x: FreeQ(p, x))) rule645 = ReplacementRule(pattern645, lambda x, a, p : sqrt(a*x**p + S(1))*sqrt(1/(a*x**p + S(1)))*Int(x**(-p + S(-1))*sqrt(-a*x**p + S(1))*sqrt(a*x**p + S(1)), x)/a - x**(-p)/(a*p)) rubi.add(rule645) pattern646 = Pattern(Integral(x_**WC('m', S(1))*exp(asech(x_**WC('p', S(1))*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda m: NonzeroQ(m + S(1)))) rule646 = ReplacementRule(pattern646, lambda x, a, p, m : x**(m + S(1))*exp(asech(a*x**p))/(m + S(1)) + p*sqrt(a*x**p + S(1))*sqrt(1/(a*x**p + S(1)))*Int(x**(m - p)/(sqrt(-a*x**p + S(1))*sqrt(a*x**p + S(1))), x)/(a*(m + S(1))) + p*Int(x**(m - p), x)/(a*(m + S(1)))) rubi.add(rule646) pattern647 = Pattern(Integral(x_**WC('m', S(1))*exp(acsch(x_**WC('p', S(1))*WC('a', S(1)))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda p, x: FreeQ(p, x))) rule647 = ReplacementRule(pattern647, lambda x, a, p, m : Int(x**m*sqrt(S(1) + x**(-S(2)*p)/a**S(2)), x) + Int(x**(m - p), x)/a) rubi.add(rule647) pattern648 = Pattern(Integral(x_**WC('m', S(1))*exp(WC('n', S(1))*asech(u_)), x_), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n: IntegerQ(n))) rule648 = ReplacementRule(pattern648, lambda x, u, n, m : Int(x**m*(sqrt((-u + S(1))/(u + S(1))) + sqrt((-u + S(1))/(u + S(1)))/u + 1/u)**n, x)) rubi.add(rule648) pattern649 = Pattern(Integral(x_**WC('m', S(1))*exp(WC('n', S(1))*acsch(u_)), x_), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n: IntegerQ(n))) rule649 = ReplacementRule(pattern649, lambda x, u, n, m : Int(x**m*(sqrt(S(1) + u**(S(-2))) + 1/u)**n, x)) rubi.add(rule649) pattern650 = Pattern(Integral(asech(u_), x_), CustomConstraint(lambda x, u: InverseFunctionFreeQ(u, x)), CustomConstraint(lambda x, u: Not(FunctionOfExponentialQ(u, x)))) rule650 = ReplacementRule(pattern650, lambda x, u : x*asech(u) + sqrt(-u**S(2) + S(1))*Int(SimplifyIntegrand(x*D(u, x)/(u*sqrt(-u**S(2) + S(1))), x), x)/(u*sqrt(S(-1) + 1/u)*sqrt(S(1) + 1/u))) rubi.add(rule650) pattern651 = Pattern(Integral(acsch(u_), x_), CustomConstraint(lambda x, u: InverseFunctionFreeQ(u, x)), CustomConstraint(lambda x, u: Not(FunctionOfExponentialQ(u, x)))) rule651 = ReplacementRule(pattern651, lambda x, u : -u*Int(SimplifyIntegrand(x*D(u, x)/(u*sqrt(-u**S(2) + S(-1))), x), x)/sqrt(-u**S(2)) + x*acsch(u)) rubi.add(rule651) pattern652 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*asech(u_)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda m: NonzeroQ(m + S(1))), CustomConstraint(lambda x, u: InverseFunctionFreeQ(u, x)), CustomConstraint(lambda x, m, c, d, u: Not(FunctionOfQ((c + d*x)**(m + S(1)), u, x))), CustomConstraint(lambda x, u: Not(FunctionOfExponentialQ(u, x)))) rule652 = ReplacementRule(pattern652, lambda x, b, m, c, a, d, u : b*sqrt(-u**S(2) + S(1))*Int(SimplifyIntegrand((c + d*x)**(m + S(1))*D(u, x)/(u*sqrt(-u**S(2) + S(1))), x), x)/(d*u*sqrt(S(-1) + 1/u)*sqrt(S(1) + 1/u)*(m + S(1))) + (a + b*asech(u))*(c + d*x)**(m + S(1))/(d*(m + S(1)))) rubi.add(rule652) pattern653 = Pattern(Integral((x_*WC('d', S(1)) + WC('c', S(0)))**WC('m', S(1))*(WC('a', S(0)) + WC('b', S(1))*acsch(u_)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda m: NonzeroQ(m + S(1))), CustomConstraint(lambda x, u: InverseFunctionFreeQ(u, x)), CustomConstraint(lambda x, m, c, d, u: Not(FunctionOfQ((c + d*x)**(m + S(1)), u, x))), CustomConstraint(lambda x, u: Not(FunctionOfExponentialQ(u, x)))) rule653 = ReplacementRule(pattern653, lambda x, b, m, c, a, d, u : -b*u*Int(SimplifyIntegrand((c + d*x)**(m + S(1))*D(u, x)/(u*sqrt(-u**S(2) + S(-1))), x), x)/(d*sqrt(-u**S(2))*(m + S(1))) + (a + b*acsch(u))*(c + d*x)**(m + S(1))/(d*(m + S(1)))) rubi.add(rule653) pattern654 = Pattern(Integral(v_*(WC('a', S(0)) + WC('b', S(1))*asech(u_)), x_), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda x, u: InverseFunctionFreeQ(u, x)), CustomConstraint(lambda v, x: Not(MatchQ(v, Condition((x*Optional(Pattern(d, Blank)) + Optional(Pattern(c, Blank)))**Optional(Pattern(m, Blank)))))), CustomConstraint(lambda a, u, x, b, w: InverseFunctionFreeQ(w, x))) def With654(x, b, v, a, u): w = IntHide(v, x) return b*sqrt(-u**S(2) + S(1))*Int(SimplifyIntegrand(w*D(u, x)/(u*sqrt(-u**S(2) + S(1))), x), x)/(u*sqrt(S(-1) + 1/u)*sqrt(S(1) + 1/u)) + Dist(a + b*asech(u), w, x) rule654 = ReplacementRule(pattern654, lambda x, b, v, a, u : With654(x, b, v, a, u)) rubi.add(rule654) pattern655 = Pattern(Integral(v_*(WC('a', S(0)) + WC('b', S(1))*acsch(u_)), x_), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda x, u: InverseFunctionFreeQ(u, x)), CustomConstraint(lambda v, x: Not(MatchQ(v, Condition((x*Optional(Pattern(d, Blank)) + Optional(Pattern(c, Blank)))**Optional(Pattern(m, Blank)))))), CustomConstraint(lambda a, u, x, b, w: InverseFunctionFreeQ(w, x))) def With655(x, b, v, a, u): w = IntHide(v, x) return -b*u*Int(SimplifyIntegrand(w*D(u, x)/(u*sqrt(-u**S(2) + S(-1))), x), x)/sqrt(-u**S(2)) + Dist(a + b*acsch(u), w, x) rule655 = ReplacementRule(pattern655, lambda x, b, v, a, u : With655(x, b, v, a, u)) rubi.add(rule655) return rubi
513,811
0
23
00f674dd269b5ded3bd8cfeb250e25da5e9bb9c5
1,777
py
Python
l19z3.py
hubieva-a/lab19
516357b25d62bc7aab9a6b45528b4611adf9acdd
[ "MIT" ]
null
null
null
l19z3.py
hubieva-a/lab19
516357b25d62bc7aab9a6b45528b4611adf9acdd
[ "MIT" ]
null
null
null
l19z3.py
hubieva-a/lab19
516357b25d62bc7aab9a6b45528b4611adf9acdd
[ "MIT" ]
null
null
null
from tkinter import * root = Tk() text1 = Text(width=20,height=1) label1 = Label(width=20) but1 = Button(width=5, height=5, bg='#ff0000') but2 = Button(width=5, height=5, bg='#ff7d00') but3 = Button(width=5, height=5, bg='#ffff00') but4 = Button(width=5, height=5, bg='#00ff00') but5 = Button(width=5, height=5, bg='#007dff') but6 = Button(width=5, height=5, bg='#0000ff') but7 = Button(width=5, height=5, bg='#7d00ff') but1.bind('<Button-1>', color_red) but2.bind('<Button-1>', color_orange) but3.bind('<Button-1>', color_yellow) but4.bind('<Button-1>', color_green) but5.bind('<Button-1>', color_blue) but6.bind('<Button-1>', color_indigo) but7.bind('<Button-1>', color_purple) text1.pack() label1.pack() but1.pack(side='left') but2.pack(side='left') but3.pack(side='left') but4.pack(side='left') but5.pack(side='left') but6.pack(side='left') but7.pack(side='left') root.mainloop()
26.132353
47
0.62296
from tkinter import * def color_red(event): text1.delete(1.0, "end") text1.insert(1.0,'Красный') label1['text'] = '#ff0000' def color_orange(event): text1.delete(1.0, "end") text1.insert(1.0,'Оранжевый') label1['text'] = '#ff7d00' def color_yellow(event): text1.delete(1.0, "end") text1.insert(1.0,'Жёлтый') label1['text'] = '#ffff00' def color_green(event): text1.delete(1.0, "end") text1.insert(1.0,'Зеленый') label1['text'] = '#00ff00' def color_blue(event): text1.delete(1.0, "end") text1.insert(1.0,'Голубой') label1['text'] = '#007dff' def color_indigo(event): text1.delete(1.0, "end") text1.insert(1.0,'Синий') label1['text'] = '#0000ff' def color_purple(event): text1.delete(1.0, "end") text1.insert(1.0,'Фиолетовый') label1['text'] = '#7d00ff' root = Tk() text1 = Text(width=20,height=1) label1 = Label(width=20) but1 = Button(width=5, height=5, bg='#ff0000') but2 = Button(width=5, height=5, bg='#ff7d00') but3 = Button(width=5, height=5, bg='#ffff00') but4 = Button(width=5, height=5, bg='#00ff00') but5 = Button(width=5, height=5, bg='#007dff') but6 = Button(width=5, height=5, bg='#0000ff') but7 = Button(width=5, height=5, bg='#7d00ff') but1.bind('<Button-1>', color_red) but2.bind('<Button-1>', color_orange) but3.bind('<Button-1>', color_yellow) but4.bind('<Button-1>', color_green) but5.bind('<Button-1>', color_blue) but6.bind('<Button-1>', color_indigo) but7.bind('<Button-1>', color_purple) text1.pack() label1.pack() but1.pack(side='left') but2.pack(side='left') but3.pack(side='left') but4.pack(side='left') but5.pack(side='left') but6.pack(side='left') but7.pack(side='left') root.mainloop()
733
0
175
c78e735101ac48aa6d6991855b779aa1b42eaff5
40,950
py
Python
src/rtl/decoder.py
giraffe50/RISCV-M4F
1b1ed756a8ea02c2d2a11d8472f8603847170ad8
[ "Apache-2.0" ]
3
2021-01-13T03:41:14.000Z
2021-03-23T11:31:48.000Z
src/rtl/decoder.py
scutdig/LG-32HP
1b1ed756a8ea02c2d2a11d8472f8603847170ad8
[ "Apache-2.0" ]
1
2021-03-01T09:32:59.000Z
2021-03-01T09:32:59.000Z
src/rtl/decoder.py
scutdig/LG-32HP
1b1ed756a8ea02c2d2a11d8472f8603847170ad8
[ "Apache-2.0" ]
4
2021-01-07T03:01:26.000Z
2021-02-28T02:20:10.000Z
""" Copyright Digisim, Computer Architecture team of South China University of Technology, 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. Author Name: Ruohui Chen Date: 2021-03-08 File Name: deocder.py Description: """ from pyhcl import * from src.include.pkg import * # Helper function for generating CSRs access illegal judgement # Hardware Performance Monitor # Hardware Performance Monitor (unprivileged read-only mirror CSRs) # PULP_XPULP, PULP_CLUSTER, A_EXTENSION, FPU, APU_WOP_CPU not used in our implementation if __name__ == '__main__': Emitter.dumpVerilog(Emitter.dump(Emitter.emit(decoder()), "decoder.fir"))
53.952569
136
0.522344
""" Copyright Digisim, Computer Architecture team of South China University of Technology, 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. Author Name: Ruohui Chen Date: 2021-03-08 File Name: deocder.py Description: """ from pyhcl import * from src.include.pkg import * # Helper function for generating CSRs access illegal judgement # Hardware Performance Monitor def csrs_hpm(addr): return (addr == CSR_MCYCLE) | (addr == CSR_MINSTRET) | (addr == CSR_MHPMCOUNTER3) | (addr == CSR_MHPMCOUNTER4) | \ (addr == CSR_MHPMCOUNTER5) | (addr == CSR_MHPMCOUNTER6) | (addr == CSR_MHPMCOUNTER7) | (addr == CSR_MHPMCOUNTER8) | \ (addr == CSR_MHPMCOUNTER9) | (addr == CSR_MHPMCOUNTER10) | (addr == CSR_MHPMCOUNTER11) | (addr == CSR_MHPMCOUNTER12) | \ (addr == CSR_MHPMCOUNTER13) | (addr == CSR_MHPMCOUNTER14) | (addr == CSR_MHPMCOUNTER15) | (addr == CSR_MHPMCOUNTER16) | \ (addr == CSR_MHPMCOUNTER17) | (addr == CSR_MHPMCOUNTER18) | (addr == CSR_MHPMCOUNTER19) | (addr == CSR_MHPMCOUNTER20) | \ (addr == CSR_MHPMCOUNTER21) | (addr == CSR_MHPMCOUNTER22) | (addr == CSR_MHPMCOUNTER23) | (addr == CSR_MHPMCOUNTER24) | \ (addr == CSR_MHPMCOUNTER25) | (addr == CSR_MHPMCOUNTER26) | (addr == CSR_MHPMCOUNTER27) | (addr == CSR_MHPMCOUNTER28) | \ (addr == CSR_MHPMCOUNTER29) | (addr == CSR_MHPMCOUNTER30) | (addr == CSR_MHPMCOUNTER31) | \ (addr == CSR_MCYCLEH) | (addr == CSR_MINSTRETH) | \ (addr == CSR_MHPMCOUNTER3H) | (addr == CSR_MHPMCOUNTER4H) | \ (addr == CSR_MHPMCOUNTER5H) | (addr == CSR_MHPMCOUNTER6H) | (addr == CSR_MHPMCOUNTER7H) | (addr == CSR_MHPMCOUNTER8H) | \ (addr == CSR_MHPMCOUNTER9H) | (addr == CSR_MHPMCOUNTER10H) | (addr == CSR_MHPMCOUNTER11H) | (addr == CSR_MHPMCOUNTER12H) | \ (addr == CSR_MHPMCOUNTER13H) | (addr == CSR_MHPMCOUNTER14H) | (addr == CSR_MHPMCOUNTER15H) | (addr == CSR_MHPMCOUNTER16H) | \ (addr == CSR_MHPMCOUNTER17H) | (addr == CSR_MHPMCOUNTER18H) | (addr == CSR_MHPMCOUNTER19H) | (addr == CSR_MHPMCOUNTER20H) | \ (addr == CSR_MHPMCOUNTER21H) | (addr == CSR_MHPMCOUNTER22H) | (addr == CSR_MHPMCOUNTER23H) | (addr == CSR_MHPMCOUNTER24H) | \ (addr == CSR_MHPMCOUNTER25H) | (addr == CSR_MHPMCOUNTER26H) | (addr == CSR_MHPMCOUNTER27H) | (addr == CSR_MHPMCOUNTER28H) | \ (addr == CSR_MHPMCOUNTER29H) | (addr == CSR_MHPMCOUNTER30H) | (addr == CSR_MHPMCOUNTER31H) | \ (addr == CSR_MCOUNTINHIBIT) | (addr == CSR_MHPMEVENT3) | (addr == CSR_MHPMEVENT4) | \ (addr == CSR_MHPMEVENT5) | (addr == CSR_MHPMEVENT6) | (addr == CSR_MHPMEVENT7) | (addr == CSR_MHPMEVENT8) | \ (addr == CSR_MHPMEVENT9) | (addr == CSR_MHPMEVENT10) | (addr == CSR_MHPMEVENT11) | (addr == CSR_MHPMEVENT12) | \ (addr == CSR_MHPMEVENT13) | (addr == CSR_MHPMEVENT14) | (addr == CSR_MHPMEVENT15) | (addr == CSR_MHPMEVENT16) | \ (addr == CSR_MHPMEVENT17) | (addr == CSR_MHPMEVENT18) | (addr == CSR_MHPMEVENT19) | (addr == CSR_MHPMEVENT20) | \ (addr == CSR_MHPMEVENT21) | (addr == CSR_MHPMEVENT22) | (addr == CSR_MHPMEVENT23) | (addr == CSR_MHPMEVENT24) | \ (addr == CSR_MHPMEVENT25) | (addr == CSR_MHPMEVENT26) | (addr == CSR_MHPMEVENT27) | (addr == CSR_MHPMEVENT28) | \ (addr == CSR_MHPMEVENT29) | (addr == CSR_MHPMEVENT30) | (addr == CSR_MHPMEVENT31) # Hardware Performance Monitor (unprivileged read-only mirror CSRs) def csrs_hpm_mirror(addr): return (addr == CSR_CYCLE) | \ (addr == CSR_INSTRET) | \ (addr == CSR_HPMCOUNTER3) | \ (addr == CSR_HPMCOUNTER4) | (addr == CSR_HPMCOUNTER5) | (addr == CSR_HPMCOUNTER6) | (addr == CSR_HPMCOUNTER7) | \ (addr == CSR_HPMCOUNTER8) | (addr == CSR_HPMCOUNTER9) | (addr == CSR_HPMCOUNTER10) | (addr == CSR_HPMCOUNTER11) | \ (addr == CSR_HPMCOUNTER12) | (addr == CSR_HPMCOUNTER13) | (addr == CSR_HPMCOUNTER14) | (addr == CSR_HPMCOUNTER15) | \ (addr == CSR_HPMCOUNTER16) | (addr == CSR_HPMCOUNTER17) | (addr == CSR_HPMCOUNTER18) | (addr == CSR_HPMCOUNTER19) | \ (addr == CSR_HPMCOUNTER20) | (addr == CSR_HPMCOUNTER21) | (addr == CSR_HPMCOUNTER22) | (addr == CSR_HPMCOUNTER23) | \ (addr == CSR_HPMCOUNTER24) | (addr == CSR_HPMCOUNTER25) | (addr == CSR_HPMCOUNTER26) | (addr == CSR_HPMCOUNTER27) | \ (addr == CSR_HPMCOUNTER28) | (addr == CSR_HPMCOUNTER29) | (addr == CSR_HPMCOUNTER30) | (addr == CSR_HPMCOUNTER31) | \ (addr == CSR_CYCLEH) | \ (addr == CSR_INSTRETH) | \ (addr == CSR_HPMCOUNTER3H) | \ (addr == CSR_HPMCOUNTER4H) | (addr == CSR_HPMCOUNTER5H) | (addr == CSR_HPMCOUNTER6H) | (addr == CSR_HPMCOUNTER7H) | \ (addr == CSR_HPMCOUNTER8H) | (addr == CSR_HPMCOUNTER9H) | (addr == CSR_HPMCOUNTER10H) | (addr == CSR_HPMCOUNTER11H) | \ (addr == CSR_HPMCOUNTER12H) | (addr == CSR_HPMCOUNTER13H) | (addr == CSR_HPMCOUNTER14H) | (addr == CSR_HPMCOUNTER15H) | \ (addr == CSR_HPMCOUNTER16H) | (addr == CSR_HPMCOUNTER17H) | (addr == CSR_HPMCOUNTER18H) | (addr == CSR_HPMCOUNTER19H) | \ (addr == CSR_HPMCOUNTER20H) | (addr == CSR_HPMCOUNTER21H) | (addr == CSR_HPMCOUNTER22H) | (addr == CSR_HPMCOUNTER23H) | \ (addr == CSR_HPMCOUNTER24H) | (addr == CSR_HPMCOUNTER25H) | (addr == CSR_HPMCOUNTER26H) | (addr == CSR_HPMCOUNTER27H) | \ (addr == CSR_HPMCOUNTER28H) | (addr == CSR_HPMCOUNTER29H) | (addr == CSR_HPMCOUNTER30H) | (addr == CSR_HPMCOUNTER31H) # PULP_XPULP, PULP_CLUSTER, A_EXTENSION, FPU, APU_WOP_CPU not used in our implementation def decoder(PULP_SECURE=0, USE_PMP=0, DEBUG_TRIGGER_EN=1): class DECODER(Module): io = IO( # Signals running to/from controller deassert_we_i=Input(Bool), # Deassert we, we are stalled or not active illegal_insn_o=Output(Bool), # Illegal instruction encountered ebrk_insn_o=Output(Bool), # Trap instruction encountered mret_insn_o=Output(Bool), # Return from exception instruction encountered (M) uret_insn_o=Output(Bool), # Return from exception instruction encountered (S) dret_insn_o=Output(Bool), # Return from debug (M) mret_dec_o=Output(Bool), # Return from exception instruction encountered (M) without deassert uret_dec_o=Output(Bool), # Return from exception instruction encountered (M) without deassert dret_dec_o=Output(Bool), # Return from debug (M) without deassert ecall_insn_o=Output(Bool), # Environment call (syscall) instruction encountered wfi_o=Output(Bool), # Pipeline flush is requested fencei_insn_o=Output(Bool), # FENCE.I instruction rega_used_o=Output(Bool), # rs1 is used by current instruction regb_used_o=Output(Bool), # rs2 is used by current instruction regc_used_o=Output(Bool), # rs3 is used by current instruction # fp registers currently not used in our implementation # Bit manipulation currently not used in our implementation # From IF/ID pipeline instr_rdata_i=Input(U.w(32)), # Instruction read from instr memory/cache illegal_c_insn_i=Input(Bool), # Compressed instruction decode failed # ALU signals alu_en_o=Output(Bool), # ALU enable alu_operator_o=Output(U.w(ALU_OP_WIDTH)), # ALU operation selection alu_op_a_mux_sel_o=Output(U.w(3)), # Operand a selection: reg value, PC, immediate or zero alu_op_b_mux_sel_o=Output(U.w(3)), # Operand b selection: reg value or immediate alu_op_c_mux_sel_o=Output(U.w(2)), # Reg value or jump target # alu_vec_mode_o, scalar_replication_o, scalar_replication_c_o # are deprecated currently in our implementation imm_a_mux_sel_o=Output(Bool), # Immediate selection for operand a imm_b_mux_sel_o=Output(U.w(4)), # Immediate selection for operand b regc_mux_o=Output(U.w(2)), # Register c selection: S3, RD or 0 # is_clpx_o and is_subrot_o are deprecated currently in our implementation # MUL related control signals mult_operator_o=Output(U.w(MUL_OP_WIDTH)), # Multiplication operation selection mult_int_en_o=Output(Bool), # Perform integer multiplication # mult_dot_en_o, mult_sel_subword_o, mult_dot_signed_o are deprecated # currently in our implementation mult_imm_mux_o=Output(Bool), # Multiplication immediate mux selector mult_signed_mode_o=Output(U.w(2)), # Multiplication in signed mode # APU and FPU currently not implemented # Register file related signals regfile_mem_we_o=Output(Bool), # Write enable for regfile regfile_alu_we_o=Output(Bool), # Write enable for 2nd regfile port regfile_alu_we_dec_o=Output(Bool), # Write enable for 2nd regfile port without deassert regfile_alu_waddr_sel_o=Output(Bool), # Select register write address for ALU/MUL operations # CSR manipulation csr_access_o=Output(Bool), # Access to CSR csr_status_o=Output(Bool), # Access to xstatus CSR csr_op_o=Output(U.w(CSR_OP_WIDTH)), # Operation to perform on CSR current_priv_lvl_i=Input(U.w(PRIV_SEL_WIDTH)), # The current privilege level # LD/ST unit signals data_req_o=Output(Bool), # Start transaction to data memory data_we_o=Output(Bool), # Data memory write enable prepost_useincr_o=Output(Bool), # When not active bypass the alu result for address calculation data_type_o=Output(U.w(2)), # Data type on data memory: byte, half word or word data_sign_extension_o=Output(U.w(2)), # Sign extension on read data from data memory data_reg_offset_o=Output(U.w(2)), # Offset in byte inside register for stores # data_load_event_o is deprecated currently in our implementation # Atomic memory access and hwloop signals are deprecated currently in our implementation debug_mode_i=Input(Bool), debug_wfi_no_sleep_i=Input(Bool), # Jump/Branches ctrl_transfer_insn_in_dec_o=Output(U.w(2)), # Control transfer instruction without deassert ctrl_transfer_insn_in_id_o=Output(U.w(2)), # Control transfer instruction is decoded ctrl_transfer_target_mux_sel_o=Output(U.w(2)), # Jump target selection # HPM related control signals mcounteren_i=Input(U.w(32)), # HPM related control signals ) # Write enable/request control regfile_mem_we = Wire(Bool) regfile_alu_we = Wire(Bool) data_req = Wire(Bool) csr_illegal = Wire(Bool) ctrl_transfer_insn = Wire(U.w(2)) csr_op = Wire(U.w(CSR_OP_WIDTH)) alu_en = Wire(Bool) mult_int_en = Wire(Bool) ################################################################################## # Decoder ################################################################################## # Initial assign ctrl_transfer_insn <<= BRANCH_NONE io.ctrl_transfer_target_mux_sel_o <<= JT_JAL alu_en <<= Bool(True) io.alu_operator_o <<= ALU_SLTU io.alu_op_a_mux_sel_o <<= OP_A_REGA_OR_FWD io.alu_op_b_mux_sel_o <<= OP_B_REGB_OR_FWD io.alu_op_c_mux_sel_o <<= OP_C_REGC_OR_FWD io.regc_mux_o <<= REGC_ZERO io.imm_a_mux_sel_o <<= IMMA_ZERO io.imm_b_mux_sel_o <<= IMMB_I io.mult_operator_o <<= MUL_I mult_int_en <<= Bool(False) io.mult_int_en_o <<= Bool(False) io.mult_imm_mux_o <<= MIMM_ZERO io.mult_signed_mode_o <<= U.w(2)(0) regfile_mem_we <<= Bool(False) regfile_alu_we <<= Bool(False) io.regfile_alu_waddr_sel_o <<= Bool(True) io.csr_access_o <<= Bool(False) io.csr_status_o <<= Bool(False) csr_illegal <<= Bool(False) csr_op <<= CSR_OP_READ io.mret_insn_o <<= Bool(False) io.uret_insn_o <<= Bool(False) io.dret_insn_o <<= Bool(False) io.data_we_o <<= Bool(False) io.data_type_o <<= U.w(2)(0) io.data_sign_extension_o <<= U.w(2)(0) io.data_reg_offset_o <<= U.w(2)(0) data_req <<= Bool(False) io.prepost_useincr_o <<= Bool(True) io.illegal_insn_o <<= Bool(False) io.ebrk_insn_o <<= Bool(False) io.ecall_insn_o <<= Bool(False) io.wfi_o <<= Bool(False) io.fencei_insn_o <<= Bool(False) io.rega_used_o <<= Bool(False) io.regb_used_o <<= Bool(False) io.regc_used_o <<= Bool(False) io.mret_dec_o <<= Bool(False) io.uret_dec_o <<= Bool(False) io.dret_dec_o <<= Bool(False) ################################################################################## # Jumps ################################################################################## # OPCODE Mux with when(io.instr_rdata_i[6:0] == OPCODE_JAL): # Jump and Link io.ctrl_transfer_target_mux_sel_o <<= JT_JAL ctrl_transfer_insn <<= BRANCH_JAL # Calculate and store PC+4 io.alu_op_a_mux_sel_o <<= OP_A_CURRPC io.alu_op_b_mux_sel_o <<= OP_B_IMM io.imm_b_mux_sel_o <<= IMMB_PCINCR io.alu_operator_o <<= ALU_ADD regfile_alu_we <<= Bool(True) # Calculate jump target (= PC + UJ imm) with elsewhen(io.instr_rdata_i[6:0] == OPCODE_JALR): # Jump and Link Register io.ctrl_transfer_target_mux_sel_o <<= JT_JALR ctrl_transfer_insn <<= BRANCH_JALR # Calculate and store PC+4 io.alu_op_a_mux_sel_o <<= OP_A_CURRPC io.alu_op_b_mux_sel_o <<= OP_B_IMM io.imm_b_mux_sel_o <<= IMMB_PCINCR io.alu_operator_o <<= ALU_ADD regfile_alu_we <<= Bool(True) # Calculate jump target (= RS1 + I imm) io.rega_used_o <<= Bool(True) with when(io.instr_rdata_i[14:12] != U.w(3)(0)): # funct3 != 0b000 ctrl_transfer_insn <<= BRANCH_NONE regfile_alu_we <<= Bool(False) io.illegal_insn_o <<= Bool(True) with elsewhen(io.instr_rdata_i[6:0] == OPCODE_BRANCH): # All Branch instructions io.ctrl_transfer_target_mux_sel_o <<= JT_COND ctrl_transfer_insn <<= BRANCH_COND io.alu_op_c_mux_sel_o <<= OP_C_JT io.rega_used_o <<= Bool(True) io.regb_used_o <<= Bool(True) # PULP_XPULP always == 0 # funct3 io.alu_operator_o <<= LookUpTable(io.instr_rdata_i[14:12], { U.w(3)(0b000): ALU_EQ, U.w(3)(0b001): ALU_NE, U.w(3)(0b100): ALU_LTS, U.w(3)(0b101): ALU_GES, U.w(3)(0b110): ALU_LTU, U.w(3)(0b111): ALU_GEU, ...: ALU_SLTU }) with when((io.instr_rdata_i[14:12] == U.w(3)(0b010)) | (io.instr_rdata_i[14:12] == U.w(3)(0b011))): io.illegal_insn_o <<= Bool(True) ################################################################################## # LD/ST ################################################################################## # All Store with elsewhen(io.instr_rdata_i[6:0] == OPCODE_STORE): data_req <<= Bool(True) io.data_we_o <<= Bool(True) io.rega_used_o <<= Bool(True) io.regb_used_o <<= Bool(True) io.alu_operator_o <<= ALU_ADD # Pass write data through ALU operand c io.alu_op_c_mux_sel_o <<= OP_C_REGB_OR_FWD # PULP_XPULP always == 0 with when(io.instr_rdata_i[14] == U.w(1)(0)): io.imm_b_mux_sel_o <<= IMMB_S io.alu_op_b_mux_sel_o <<= OP_B_IMM with otherwise(): io.illegal_insn_o <<= Bool(True) # funct3 io.data_type_o <<= LookUpTable(io.instr_rdata_i[13:12], { U.w(2)(0b00): U.w(2)(0b10), # SB U.w(2)(0b01): U.w(2)(0b01), # SH U.w(2)(0b10): U.w(2)(0b00), # SW ...: U.w(2)(0b00) }) with when(io.instr_rdata_i[13:12] == U.w(2)(0b11)): # Undefined data_req <<= Bool(False) io.data_we_o <<= Bool(False) io.illegal_insn_o <<= Bool(True) # All Load with elsewhen(io.instr_rdata_i[6:0] == OPCODE_LOAD): data_req <<= Bool(True) regfile_mem_we <<= Bool(True) io.rega_used_o <<= Bool(True) io.data_type_o <<= U.w(2)(0b00) # Read always read word # offset from immediate io.alu_operator_o <<= ALU_ADD io.alu_op_b_mux_sel_o <<= OP_B_IMM io.imm_b_mux_sel_o <<= IMMB_I # sign/zero extension # funct3[2] (bit 14): Zero (= 1), Sign (= 0) # Output io.data_sign_extension_o <<= CatBits(U.w(1)(0), ~io.instr_rdata_i[14]) # Load size io.data_type_o <<= LookUpTable(io.instr_rdata_i[13:12], { U.w(2)(0b00): U.w(2)(0b10), # LB U.w(2)(0b01): U.w(2)(0b01), # LH U.w(2)(0b10): U.w(2)(0b00), # LW ...: U.w(2)(0b00) # Illegal }) # funct3 = 0b011, 0b110, 0b111 are illegal with when((io.instr_rdata_i[14:12] == U.w(3)(0b111)) | (io.instr_rdata_i[14:12] == U.w(3)(0b110)) | (io.instr_rdata_i[14:12] == U.w(3)(0b011))): io.illegal_insn_o <<= Bool(True) with elsewhen(io.instr_rdata_i[6:0] == OPCODE_AMO): # We currently didn't support AMO instructions yet io.illegal_insn_o <<= Bool(True) ################################################################################## # ALU ################################################################################## with elsewhen(io.instr_rdata_i[6:0] == OPCODE_LUI): # Load Upper Immediate io.alu_op_a_mux_sel_o <<= OP_A_IMM io.alu_op_b_mux_sel_o <<= OP_B_IMM io.imm_a_mux_sel_o <<= IMMA_ZERO io.imm_b_mux_sel_o <<= IMMB_U io.alu_operator_o <<= ALU_ADD regfile_alu_we <<= Bool(True) with elsewhen(io.instr_rdata_i[6:0] == OPCODE_AUIPC): # Add Upper Immediate to PC io.alu_op_a_mux_sel_o <<= OP_A_CURRPC io.alu_op_b_mux_sel_o <<= OP_B_IMM io.imm_b_mux_sel_o <<= IMMB_U io.alu_operator_o <<= ALU_ADD regfile_alu_we <<= Bool(True) with elsewhen(io.instr_rdata_i[6:0] == OPCODE_OPIMM): # Register-Immediate ALU Operations io.alu_op_b_mux_sel_o <<= OP_B_IMM io.imm_b_mux_sel_o <<= IMMB_I regfile_alu_we <<= Bool(True) io.rega_used_o <<= Bool(True) # funct3 io.alu_operator_o <<= LookUpTable(io.instr_rdata_i[14:12], { U.w(3)(0b000): ALU_ADD, # addi U.w(3)(0b001): ALU_SLL, # slli U.w(3)(0b010): ALU_SLTS, # slti U.w(3)(0b011): ALU_SLTU, # sltiu U.w(3)(0b100): ALU_XOR, # xori U.w(3)(0b110): ALU_OR, # ori U.w(3)(0b111): ALU_AND, # andi ...: ALU_SLTU }) # slli, srli, srai -> funct7 has limits with when(io.instr_rdata_i[14:12] == U.w(3)(0b001)): with when(io.instr_rdata_i[31:25] != U.w(7)(0)): # slli -> imm[11:5] must be 0b00 io.illegal_insn_o <<= Bool(True) with when(io.instr_rdata_i[14:12] == U.w(3)(0b101)): # is srli or srai? with when(io.instr_rdata_i[31:25] == U.w(7)(0)): # srli -> imm[11:5] must be 0b00 io.alu_operator_o <<= ALU_SRL with elsewhen(io.instr_rdata_i[31:25] == U.w(7)(0b0100000)): # srai -> imm[11:5] must be 0b20 io.alu_operator_o <<= ALU_SRA with otherwise(): io.illegal_insn_o <<= Bool(True) with elsewhen(io.instr_rdata_i[6:0] == OPCODE_OP): # Register-Register ALU operation # In our current implementation, funct7 (io.instr_rdata_i[31:25]) only could # be 0b00/0b20 with when(io.instr_rdata_i[31:30] == U.w(2)(0b11)): # PREFIX 11, illegal io.illegal_insn_o <<= Bool(True) with elsewhen(io.instr_rdata_i[31:30] == U.w(2)(0b10)): # PREFIX 10, illegal io.illegal_insn_o <<= Bool(True) with otherwise(): # PREFIX 00/01 regfile_alu_we <<= Bool(True) io.rega_used_o <<= Bool(True) # In fact, in our implementation, this should not be 1 with when(~io.instr_rdata_i[28]): io.regb_used_o <<= Bool(True) rr_con = CatBits(io.instr_rdata_i[30:25], io.instr_rdata_i[14:12]) # RV32I ALU Operations # I should use when/elsewhen/otherwise is more clear to read # io.alu_operator_o <<= LookUpTable(rr_con, { # U.w(9)(0b000000000): ALU_ADD, # add # U.w(9)(0b100000000): ALU_SUB, # sub # U.w(9)(0b000000010): ALU_SLTS, # slt # U.w(9)(0b000000011): ALU_SLTU, # sltu # U.w(9)(0b000000100): ALU_XOR, # xor # U.w(9)(0b000000110): ALU_OR, # or # U.w(9)(0b000000111): ALU_AND, # and # U.w(9)(0b000000001): ALU_SLL, # sll # U.w(9)(0b000000101): ALU_SRL, # srl # U.w(9)(0b100000101): ALU_SRA, # sra # }) with when(rr_con == U.w(9)(0b000000000)): io.alu_operator_o <<= ALU_ADD with elsewhen(rr_con == U.w(9)(0b100000000)): io.alu_operator_o <<= ALU_SUB with elsewhen(rr_con == U.w(9)(0b000000010)): io.alu_operator_o <<= ALU_SLTS with elsewhen(rr_con == U.w(9)(0b000000011)): io.alu_operator_o <<= ALU_SLTU with elsewhen(rr_con == U.w(9)(0b000000100)): io.alu_operator_o <<= ALU_XOR with elsewhen(rr_con == U.w(9)(0b000000110)): io.alu_operator_o <<= ALU_OR with elsewhen(rr_con == U.w(9)(0b000000111)): io.alu_operator_o <<= ALU_AND with elsewhen(rr_con == U.w(9)(0b000000001)): io.alu_operator_o <<= ALU_SLL with elsewhen(rr_con == U.w(9)(0b000000101)): io.alu_operator_o <<= ALU_SRL with elsewhen(rr_con == U.w(9)(0b100000101)): io.alu_operator_o <<= ALU_SRA # RV32M instructions with elsewhen(rr_con == U.w(9)(0b000001000)): # mul # Default unsigned x unsigned 00 alu_en <<= Bool(False) mult_int_en <<= Bool(True) io.mult_operator_o <<= MUL_MAC32 io.regc_mux_o <<= REGC_ZERO with elsewhen(rr_con == U.w(9)(0b000001001)): # mulh alu_en <<= Bool(False) io.regc_used_o <<= Bool(True) io.regc_mux_o <<= REGC_ZERO io.mult_signed_mode_o <<= U.w(2)(0b11) # Default signed x signed 11 mult_int_en <<= Bool(True) io.mult_operator_o <<= MUL_H with elsewhen(rr_con == U.w(9)(0b000001010)): # mulsu alu_en <<= Bool(False) io.regc_used_o <<= Bool(True) io.regc_mux_o <<= REGC_ZERO io.mult_signed_mode_o <<= U.w(2)(0b01) # signed x unsigned 01 mult_int_en <<= Bool(True) io.mult_operator_o <<= MUL_H with elsewhen(rr_con == U.w(9)(0b000001011)): # mulu alu_en <<= Bool(False) io.regc_used_o <<= Bool(True) io.regc_mux_o <<= REGC_ZERO io.mult_signed_mode_o <<= U.w(2)(0b00) # unsigned x unsigned 00 mult_int_en <<= Bool(True) io.mult_operator_o <<= MUL_H with elsewhen(rr_con == U.w(9)(0b000001100)): # div io.alu_op_a_mux_sel_o <<= OP_A_REGB_OR_FWD io.alu_op_b_mux_sel_o <<= OP_B_REGA_OR_FWD io.regb_used_o <<= Bool(True) io.alu_operator_o <<= ALU_DIV with elsewhen(rr_con == U.w(9)(0b000001101)): # divu io.alu_op_a_mux_sel_o <<= OP_A_REGB_OR_FWD io.alu_op_b_mux_sel_o <<= OP_B_REGA_OR_FWD io.regb_used_o <<= Bool(True) io.alu_operator_o <<= ALU_DIVU with elsewhen(rr_con == U.w(9)(0b000001110)): # rem io.alu_op_a_mux_sel_o <<= OP_A_REGB_OR_FWD io.alu_op_b_mux_sel_o <<= OP_B_REGA_OR_FWD io.regb_used_o <<= Bool(True) io.alu_operator_o <<= ALU_REM with elsewhen(rr_con == U.w(9)(0b000001111)): # remu io.alu_op_a_mux_sel_o <<= OP_A_REGB_OR_FWD io.alu_op_b_mux_sel_o <<= OP_B_REGA_OR_FWD io.regb_used_o <<= Bool(True) io.alu_operator_o <<= ALU_REMU with otherwise(): io.illegal_insn_o <<= Bool(True) with elsewhen((io.instr_rdata_i[6:0] == OPCODE_OP_FP) | (io.instr_rdata_i[6:0] == OPCODE_OP_FMADD) | (io.instr_rdata_i[6:0] == OPCODE_OP_FMSUB) | (io.instr_rdata_i[6:0] == OPCODE_OP_FNMSUB) | (io.instr_rdata_i[6:0] == OPCODE_OP_FNMADD) | (io.instr_rdata_i[6:0] == OPCODE_STORE_FP) | (io.instr_rdata_i[6:0] == OPCODE_LOAD_FP) | (io.instr_rdata_i[6:0] == OPCODE_PULP_OP) | (io.instr_rdata_i[6:0] == OPCODE_VECOP)): # No FP/XPULP implementation currently io.illegal_insn_o <<= Bool(True) ################################################################################## # Special ################################################################################## with elsewhen(io.instr_rdata_i[6:0] == OPCODE_FENCE): # io.fencei_insn_o <<= LookUpTable(io.instr_rdata_i[14:12], { # U.w(3)(0b000): Bool(True), # FENCE (Synch thread), flush pipeline # U.w(3)(0b001): Bool(True), # FENCE.I, flush pipeline and prefetch buffer # ...: Bool(False) # }) with when(io.instr_rdata_i[14:12] == U.w(3)(0b000)): io.fencei_insn_o <<= Bool(True) with elsewhen(io.instr_rdata_i[14:12] == U.w(3)(0b001)): io.fencei_insn_o <<= Bool(True) with otherwise(): io.illegal_insn_o <<= Bool(True) with elsewhen(io.instr_rdata_i[6:0] == OPCODE_SYSTEM): with when(io.instr_rdata_i[14:12] == U.w(3)(0)): # Non CSR related SYSTEM instructions with when((io.instr_rdata_i[19:15] == U(0)) & (io.instr_rdata_i[11:7] == U(0))): with when(io.instr_rdata_i[31:20] == U.w(12)(0x000)): # imm=0x0, ECALL, environment (system) call io.ecall_insn_o <<= Bool(True) with elsewhen(io.instr_rdata_i[31:20] == U.w(12)(0x001)): # imm=0x1, EBREAK, debugger trap io.ebrk_insn_o <<= Bool(True) with elsewhen(io.instr_rdata_i[31:20] == U.w(12)(0x302)): # mret io.illegal_insn_o <<= (io.current_priv_lvl_i != PRIV_LVL_M) if PULP_SECURE else Bool(False) io.mret_insn_o <<= ~io.illegal_insn_o io.mret_dec_o <<= Bool(True) with elsewhen(io.instr_rdata_i[31:20] == U.w(12)(0x002)): # uret io.illegal_insn_o <<= Bool(True) if PULP_SECURE else Bool(False) io.uret_insn_o <<= ~io.illegal_insn_o io.uret_dec_o <<= Bool(True) with elsewhen(io.instr_rdata_i[31:20] == U.w(12)(0x7b2)): # dret io.illegal_insn_o <<= ~io.debug_mode_i io.dret_insn_o <<= io.debug_mode_i io.dret_dec_o <<= Bool(True) with elsewhen(io.instr_rdata_i[31:20] == U.w(12)(0x105)): # wfi # Wait for interrupt io.wfi_o <<= Bool(True) with when(io.debug_wfi_no_sleep_i): # Treat as NOP (do not cause sleep mode entry) # Using decoding similar to ADDI, but without regsiter reads/writes, i.e. # keep regfile_alu_we = 0, rega_used_o = 0 io.alu_op_b_mux_sel_o <<= OP_B_IMM io.imm_b_mux_sel_o <<= IMMB_I io.alu_operator_o <<= ALU_ADD with otherwise(): io.illegal_insn_o <<= Bool(True) with otherwise(): io.illegal_insn_o <<= Bool(True) with otherwise(): # instruction to read/modify CSR io.csr_access_o <<= Bool(True) regfile_alu_we <<= Bool(True) io.alu_op_b_mux_sel_o <<= OP_B_IMM io.imm_a_mux_sel_o <<= IMMA_Z io.imm_b_mux_sel_o <<= IMMB_I # CSR address is encoded in I imm with when(io.instr_rdata_i[14] == U.w(1)(1)): # rs1 field if used as immediate: CSRRXI io.alu_op_a_mux_sel_o <<= OP_A_IMM with otherwise(): # CSRRX io.rega_used_o <<= Bool(True) io.alu_op_a_mux_sel_o <<= OP_A_REGA_OR_FWD # instr_rdata_i[19:14] = rs or imm # if set (S) or clear (C) with rs == x0 or imm == 0 # then do not perform a write action with when(io.instr_rdata_i[13:12] == U.w(2)(0b01)): csr_op <<= CSR_OP_WRITE with elsewhen(io.instr_rdata_i[13:12] == U.w(2)(0b10)): csr_op <<= Mux(io.instr_rdata_i[19:15] == U(0), CSR_OP_READ, CSR_OP_SET) with elsewhen(io.instr_rdata_i[13:12] == U.w(2)(0b11)): csr_op <<= Mux(io.instr_rdata_i[19:15] == U(0), CSR_OP_READ, CSR_OP_CLEAR) with otherwise(): csr_illegal <<= Bool(True) with when(io.instr_rdata_i[29:28] > io.current_priv_lvl_i): # CSR Address[9:8] csr_illegal <<= Bool(True) # Determine if CSR access is illegal with when((io.instr_rdata_i[31:20] == CSR_FFLAGS) | (io.instr_rdata_i[31:20] == CSR_FRM) | (io.instr_rdata_i[31:20] == CSR_FCSR)): # FP csr_illegal <<= Bool(True) with elsewhen((io.instr_rdata_i[31:20] == CSR_MVENDORID) | (io.instr_rdata_i[31:20] == CSR_MARCHID) | (io.instr_rdata_i[31:20] == CSR_MIMPID) | (io.instr_rdata_i[31:20] == CSR_MHARTID)): # Writes to read only CSRs results in illegal instruction with when(csr_op != CSR_OP_READ): csr_illegal <<= Bool(True) with elsewhen((io.instr_rdata_i[31:20] == CSR_MSTATUS) | (io.instr_rdata_i[31:20] == CSR_MEPC) | (io.instr_rdata_i[31:20] == CSR_MTVEC) | (io.instr_rdata_i[31:20] == CSR_MCAUSE)): # These are valid CSR registers # Not illegal, but treat as status CSR for side effect handling io.csr_status_o <<= Bool(True) with elsewhen((io.instr_rdata_i[31:20] == CSR_MISA) | (io.instr_rdata_i[31:20] == CSR_MIE) | (io.instr_rdata_i[31:20] == CSR_MSCRATCH) | (io.instr_rdata_i[31:20] == CSR_MTVAL) | (io.instr_rdata_i[31:20] == CSR_MIP)): # do nothing, not illegal csr_illegal <<= Bool(False) with elsewhen(csrs_hpm(io.instr_rdata_i[31:20])): # Not illegal, but treat as status CSR to get accurate counts io.csr_status_o <<= U.w(1)(1) with elsewhen(csrs_hpm_mirror(io.instr_rdata_i[31:20])): # Read-only and readable from user mode only if the bit of mcounteren is set if PULP_SECURE: with when((csr_op != CSR_OP_READ) | ((io.current_priv_lvl_i != PRIV_LVL_M) & (~io.mcounteren_i[io.instr_rdata_i[24:20]]))): csr_illegal <<= Bool(True) else: with when(csr_op != CSR_OP_READ): io.csr_status_o <<= Bool(True) with elsewhen(io.instr_rdata_i[31:20] == CSR_MCOUNTEREN): # This register only exists in user mode if not PULP_SECURE: csr_illegal <<= Bool(True) else: io.csr_status_o <<= Bool(True) with elsewhen((io.instr_rdata_i[31:20] == CSR_DCSR) | (io.instr_rdata_i[31:20] == CSR_DPC) | (io.instr_rdata_i[31:20] == CSR_DSCRATCH0) | (io.instr_rdata_i[31:20] == CSR_DSCRATCH1)): # Debug register access with when(~io.debug_mode_i): csr_illegal <<= Bool(True) with otherwise(): io.csr_status_o <<= Bool(True) with elsewhen((io.instr_rdata_i[31:20] == CSR_TSELECT) | (io.instr_rdata_i[31:20] == CSR_TDATA1) | (io.instr_rdata_i[31:20] == CSR_TDATA2) | (io.instr_rdata_i[31:20] == CSR_TDATA3) | (io.instr_rdata_i[31:20] == CSR_TINFO) | (io.instr_rdata_i[31:20] == CSR_MCONTEXT) | (io.instr_rdata_i[31:20] == CSR_SCONTEXT)): # Debug Trigger register access if not DEBUG_TRIGGER_EN: csr_illegal <<= Bool(True) else: csr_illegal <<= Bool(False) with elsewhen((io.instr_rdata_i[31:20] == CSR_LPSTART0) | (io.instr_rdata_i[31:20] == CSR_LPEND0) | (io.instr_rdata_i[31:20] == CSR_LPCOUNT0) | (io.instr_rdata_i[31:20] == CSR_LPSTART1) | (io.instr_rdata_i[31:20] == CSR_LPEND1) | (io.instr_rdata_i[31:20] == CSR_LPCOUNT1) | (io.instr_rdata_i[31:20] == CSR_UHARTID)): # Hardware loop register, we currently do not implement csr_illegal <<= Bool(True) with elsewhen(io.instr_rdata_i[31:20] == CSR_PRIVLV): csr_illegal <<= Bool(True) with elsewhen((io.instr_rdata_i[31:20] == CSR_PMPCFG0) | (io.instr_rdata_i[31:20] == CSR_PMPCFG1) | (io.instr_rdata_i[31:20] == CSR_PMPCFG2) | (io.instr_rdata_i[31:20] == CSR_PMPCFG3) | (io.instr_rdata_i[31:20] == CSR_PMPADDR0) | (io.instr_rdata_i[31:20] == CSR_PMPADDR1) | (io.instr_rdata_i[31:20] == CSR_PMPADDR2) | (io.instr_rdata_i[31:20] == CSR_PMPADDR3) | (io.instr_rdata_i[31:20] == CSR_PMPADDR4) | (io.instr_rdata_i[31:20] == CSR_PMPADDR5) | (io.instr_rdata_i[31:20] == CSR_PMPADDR6) | (io.instr_rdata_i[31:20] == CSR_PMPADDR7) | (io.instr_rdata_i[31:20] == CSR_PMPADDR8) | (io.instr_rdata_i[31:20] == CSR_PMPADDR9) | (io.instr_rdata_i[31:20] == CSR_PMPADDR10) | (io.instr_rdata_i[31:20] == CSR_PMPADDR11) | (io.instr_rdata_i[31:20] == CSR_PMPADDR12) | (io.instr_rdata_i[31:20] == CSR_PMPADDR13) | (io.instr_rdata_i[31:20] == CSR_PMPADDR14) | (io.instr_rdata_i[31:20] == CSR_PMPADDR15)): # PMP register access if not USE_PMP: csr_illegal <<= Bool(True) with elsewhen((io.instr_rdata_i[31:20] == CSR_USTATUS) | (io.instr_rdata_i[31:20] == CSR_UEPC) | (io.instr_rdata_i[31:20] == CSR_UTVEC) | (io.instr_rdata_i[31:20] == CSR_UCAUSE)): # User register access if not PULP_SECURE: csr_illegal <<= Bool(True) else: io.csr_status_o <<= Bool(True) with otherwise(): csr_illegal <<= Bool(True) io.illegal_insn_o <<= csr_illegal with elsewhen(io.instr_rdata_i[6:0] == OPCODE_HWLOOP): io.illegal_insn_o <<= Bool(True) with otherwise(): io.illegal_insn_o <<= Bool(True) # make sure invalid compressed instruction causes an exception with when(io.illegal_c_insn_i): io.illegal_insn_o <<= Bool(True) # Deassert we signals (in case of stalls) io.alu_en_o <<= Mux(io.deassert_we_i, Bool(False), alu_en) io.mult_int_en_o <<= Mux(io.deassert_we_i, Bool(False), mult_int_en) io.regfile_mem_we_o <<= Mux(io.deassert_we_i, Bool(False), regfile_mem_we) io.regfile_alu_we_o <<= Mux(io.deassert_we_i, Bool(False), regfile_alu_we) io.data_req_o <<= Mux(io.deassert_we_i, Bool(False), data_req) io.csr_op_o <<= Mux(io.deassert_we_i, CSR_OP_READ, csr_op) io.ctrl_transfer_insn_in_id_o <<= Mux(io.deassert_we_i, BRANCH_NONE, ctrl_transfer_insn) io.ctrl_transfer_insn_in_dec_o <<= ctrl_transfer_insn io.regfile_alu_we_dec_o <<= regfile_alu_we return DECODER() if __name__ == '__main__': Emitter.dumpVerilog(Emitter.dump(Emitter.emit(decoder()), "decoder.fir"))
39,732
0
66
bff925f7c3f355eb5ffbb6f8cb0de00147144a52
884
py
Python
xuexiStudyScore_month_v2.py
g-mitu/timeseries
3b2daf33f9af022d1aae7c4a9caf69b8abd58348
[ "BSD-3-Clause" ]
null
null
null
xuexiStudyScore_month_v2.py
g-mitu/timeseries
3b2daf33f9af022d1aae7c4a9caf69b8abd58348
[ "BSD-3-Clause" ]
null
null
null
xuexiStudyScore_month_v2.py
g-mitu/timeseries
3b2daf33f9af022d1aae7c4a9caf69b8abd58348
[ "BSD-3-Clause" ]
null
null
null
# -*- coding: utf-8 -*- """ Created on Fri May 1 10:16:25 2020 @author: winhl modify 2022-1-6 """ import pandas as pd import json work_dir = "D:/__E__/支部/积分" #n0 = "2021s1p9" n0 = "2021.01-12.xuexi.cn" #2022-1-6 with open(f"{work_dir}/{n0}.json", "r", encoding="utf-8") as f: fr = f.read() j1 = json.loads(fr) l_str = j1.get("data_str") j2 = json.loads(l_str) dict_str = j2.get("dataList")["data"] print(type(dict_str)) # df = pd.read_json(dict_str, orient="records") df = pd.DataFrame(data=dict_str) print(df) df.to_csv(f"{work_dir}/{n0}.csv") """ from pandas import json_normalize import json data=open("F:/支部/XXQG/202009third_20200930.json",encoding="utf-8").read() user_dic = json.loads(data) data_list = user_dic["data"]["list"] df = json_normalize(data_list) print(df) df.to_csv("09.csv") """
22.666667
74
0.616516
# -*- coding: utf-8 -*- """ Created on Fri May 1 10:16:25 2020 @author: winhl modify 2022-1-6 """ import pandas as pd import json work_dir = "D:/__E__/支部/积分" #n0 = "2021s1p9" n0 = "2021.01-12.xuexi.cn" #2022-1-6 with open(f"{work_dir}/{n0}.json", "r", encoding="utf-8") as f: fr = f.read() j1 = json.loads(fr) l_str = j1.get("data_str") j2 = json.loads(l_str) dict_str = j2.get("dataList")["data"] print(type(dict_str)) # df = pd.read_json(dict_str, orient="records") df = pd.DataFrame(data=dict_str) print(df) df.to_csv(f"{work_dir}/{n0}.csv") """ from pandas import json_normalize import json data=open("F:/支部/XXQG/202009third_20200930.json",encoding="utf-8").read() user_dic = json.loads(data) data_list = user_dic["data"]["list"] df = json_normalize(data_list) print(df) df.to_csv("09.csv") """
0
0
0
cf9ad7ad972d6588d169b5cc55ce7927f2bf7751
799
py
Python
models.py
seanli3/fastGCN
e3704ae2c96363da0d6318f9f2a53df4384474bf
[ "MIT" ]
28
2020-06-03T01:03:05.000Z
2022-03-26T16:37:36.000Z
models.py
seanli3/fastGCN
e3704ae2c96363da0d6318f9f2a53df4384474bf
[ "MIT" ]
null
null
null
models.py
seanli3/fastGCN
e3704ae2c96363da0d6318f9f2a53df4384474bf
[ "MIT" ]
4
2020-08-12T07:55:50.000Z
2022-03-11T05:11:24.000Z
import torch.nn as nn import torch.nn.functional as F from layers import GraphConvolution
31.96
76
0.652065
import torch.nn as nn import torch.nn.functional as F from layers import GraphConvolution class GCN(nn.Module): def __init__(self, nfeat, nhid, nclass, dropout, sampler): super().__init__() self.gc1 = GraphConvolution(nfeat, nhid) self.gc2 = GraphConvolution(nhid, nclass) self.dropout = dropout self.sampler = sampler self.out_softmax = nn.Softmax(dim=1) def forward(self, x, adj): outputs1 = F.relu(self.gc1(x, adj[0])) outputs1 = F.dropout(outputs1, self.dropout, training=self.training) outputs2 = self.gc2(outputs1, adj[1]) return F.log_softmax(outputs2, dim=1) # return self.out_softmax(outputs2) def sampling(self, *args, **kwargs): return self.sampler.sampling(*args, **kwargs)
605
0
103
e2dedf6fb31777077279b3ee42c8daaea82f726d
10,683
py
Python
_tbnf/fable_modules/fable_library/reflection.py
thautwarm/Typed-BNF
897a4a2bd389dcb2ca16c6c773b28f0388336f63
[ "MIT" ]
38
2022-01-01T06:45:27.000Z
2022-03-20T14:18:38.000Z
lua_parser/fable_sedlex/fable_modules/fable_library/reflection.py
thautwarm/lua-parser-lark
06cf19bc8595a70823fc0f67462ca29dd9e118a0
[ "MIT" ]
7
2021-09-17T16:46:50.000Z
2021-12-31T20:49:35.000Z
_tbnf/fable_modules/fable_library/reflection.py
thautwarm/typed-bnf
b5694a34fe21a064250f2ef88745d8ebad51eb33
[ "MIT" ]
3
2022-01-01T07:33:44.000Z
2022-01-09T11:41:33.000Z
from __future__ import annotations from argparse import ArgumentError import functools from dataclasses import dataclass from typing import Any, Callable, List, Optional, Type, Union from .types import Union as FsUnion, FSharpRef, Record from .util import equal_arrays_with Constructor = Callable[..., Any] EnumCase = List[Union[str, int]] FieldInfo = List[Union[str, "TypeInfo"]] PropertyInfo = FieldInfo @dataclass @dataclass obj_type: TypeInfo = TypeInfo(fullname="System.Object") unit_type: TypeInfo = TypeInfo("Microsoft.FSharp.Core.Unit") char_type: TypeInfo = TypeInfo("System.Char") string_type: TypeInfo = TypeInfo("System.String") bool_type: TypeInfo = TypeInfo("System.Boolean") int8_type: TypeInfo = TypeInfo("System.SByte") uint8_type: TypeInfo = TypeInfo("System.Byte") int16_type: TypeInfo = TypeInfo("System.Int16") uint16_type: TypeInfo = TypeInfo("System.UInt16") int32_type: TypeInfo = TypeInfo("System.Int32") uint32_type: TypeInfo = TypeInfo("System.UInt32") float32_type: TypeInfo = TypeInfo("System.Single") float64_type: TypeInfo = TypeInfo("System.Double") decimal_type: TypeInfo = TypeInfo("System.Decimal") # In .NET this is false for delegates
27.89295
106
0.666479
from __future__ import annotations from argparse import ArgumentError import functools from dataclasses import dataclass from typing import Any, Callable, List, Optional, Type, Union from .types import Union as FsUnion, FSharpRef, Record from .util import equal_arrays_with Constructor = Callable[..., Any] EnumCase = List[Union[str, int]] FieldInfo = List[Union[str, "TypeInfo"]] PropertyInfo = FieldInfo @dataclass class CaseInfo: declaringType: TypeInfo tag: int name: str fields: List[FieldInfo] @dataclass class TypeInfo: fullname: str generics: Optional[List[TypeInfo]] = None construct: Optional[Constructor] = None parent: Optional[TypeInfo] = None fields: Optional[Callable[[], List[FieldInfo]]] = None cases: Optional[Callable[[], List[CaseInfo]]] = None enum_cases: Optional[List[EnumCase]] = None def __str__(self) -> str: return full_name(self) def __eq__(self, other: Any) -> bool: return equals(self, other) def class_type( fullname: str, generics: Optional[List[TypeInfo]] = None, construct: Optional[Constructor] = None, parent: Optional[TypeInfo] = None, ) -> TypeInfo: return TypeInfo(fullname, generics, construct, parent) def union_type( fullname: str, generics: List[TypeInfo], construct: Type[FsUnion], cases: Callable[[], List[List[FieldInfo]]], ) -> TypeInfo: def fn() -> List[CaseInfo]: caseNames: List[str] = construct.cases() def mapper(i: int, fields: List[FieldInfo]) -> CaseInfo: return CaseInfo(t, i, caseNames[i], fields) return [mapper(i, x) for i, x in enumerate(cases())] t: TypeInfo = TypeInfo(fullname, generics, construct, None, None, fn, None) return t def lambda_type(argType: TypeInfo, returnType: TypeInfo): return TypeInfo("Microsoft.FSharp.Core.FSharpFunc`2", [argType, returnType]) def delegate_type(*generics): return TypeInfo("System.Func` %d" % len(generics), list(generics)) def record_type( fullname: str, generics: List[TypeInfo], construct: Constructor, fields: Callable[[], List[FieldInfo]] ) -> TypeInfo: return TypeInfo(fullname, generics, construct, fields=fields) def anon_record_type(*fields: FieldInfo) -> TypeInfo: return TypeInfo("", None, None, None, lambda: list(fields)) def option_type(generic: TypeInfo) -> TypeInfo: return TypeInfo("Microsoft.FSharp.Core.FSharpOption`1", [generic]) def list_type(generic: TypeInfo) -> TypeInfo: return TypeInfo("Microsoft.FSharp.Collections.FSharpList`1", [generic]) def array_type(generic: TypeInfo) -> TypeInfo: return TypeInfo(generic.fullname + "[]", [generic]) def enum_type(fullname: str, underlyingType: TypeInfo, enumCases: List[EnumCase]) -> TypeInfo: return TypeInfo(fullname, [underlyingType], None, None, None, None, enumCases) def tuple_type(*generics: TypeInfo) -> TypeInfo: return TypeInfo(fullname=f"System.Tuple`{len(generics)}", generics=list(generics)) obj_type: TypeInfo = TypeInfo(fullname="System.Object") unit_type: TypeInfo = TypeInfo("Microsoft.FSharp.Core.Unit") char_type: TypeInfo = TypeInfo("System.Char") string_type: TypeInfo = TypeInfo("System.String") bool_type: TypeInfo = TypeInfo("System.Boolean") int8_type: TypeInfo = TypeInfo("System.SByte") uint8_type: TypeInfo = TypeInfo("System.Byte") int16_type: TypeInfo = TypeInfo("System.Int16") uint16_type: TypeInfo = TypeInfo("System.UInt16") int32_type: TypeInfo = TypeInfo("System.Int32") uint32_type: TypeInfo = TypeInfo("System.UInt32") float32_type: TypeInfo = TypeInfo("System.Single") float64_type: TypeInfo = TypeInfo("System.Double") decimal_type: TypeInfo = TypeInfo("System.Decimal") def equals(t1: TypeInfo, t2: TypeInfo) -> bool: if t1.fullname == "": return t2.fullname == "" and equal_arrays_with( get_record_elements(t1), get_record_elements(t2), lambda kv1, kv2: kv1[0] == kv2[0] and equals(kv1[1], kv2[1]), ) return t1.fullname == t2.fullname and equal_arrays_with(t1.generics, t2.generics, equals) def is_generic_type(t): return t.generics is not None and len(t.generics) def get_generic_type_definition(t): return t if t.generics is None else TypeInfo(t.fullname, list(map(lambda _: obj_type, t.generics))) def get_generics(t: TypeInfo) -> List[TypeInfo]: return t.generics if t.generics else [] def make_generic_type(t: TypeInfo, generics: List[TypeInfo]) -> TypeInfo: return TypeInfo(t.fullname, generics, t.construct, t.parent, t.fields, t.cases) def create_instance(t: TypeInfo, consArgs: List) -> Any: # TODO: Check if consArgs length is same as t.construct? # (Arg types can still be different) if callable(t.construct): return t.construct(*(consArgs or [])) else: raise ValueError(f"Cannot access constructor of {t.fullname}") def get_value(propertyInfo: PropertyInfo, v: Any) -> Any: return getattr(v, str(propertyInfo[0])) def name(info): if isinstance(info, list): return info[0] elif isinstance(info, CaseInfo): return info.name else: i = info.fullname.rfind(".") return info.fullname if i == -1 else info.fullname[i + 1 :] def full_name(t: TypeInfo) -> str: gen = t.generics if t.generics and not is_array(t) else [] if len(gen): gen = ",".join([full_name(x) for x in gen]) return f"{t.fullname}[{gen}]" else: return t.fullname def namespace(t: TypeInfo) -> str: i = t.fullname.rfind(".") return "" if i == -1 else t.fullname[0:i] def is_array(t: TypeInfo) -> bool: return t.fullname.endswith("[]") def is_enum(t: TypeInfo) -> bool: return t.enum_cases is not None and len(t.enum_cases) > 0 def is_record(t: Any) -> bool: return (t.fields is not None) if isinstance(t, TypeInfo) else isinstance(t, Record) def is_tuple(t: TypeInfo) -> bool: return t.fullname.startswith("System.Tuple") and not is_array(t) def is_union(t: Any) -> bool: if isinstance(t, TypeInfo): return t.cases is not None return isinstance(t, FsUnion) # In .NET this is false for delegates def is_function(t: TypeInfo) -> bool: return t.fullname == "Microsoft.FSharp.Core.FSharpFunc`2" def get_element_type(t: TypeInfo) -> Optional[TypeInfo]: return (t.generics[0] if t.generics else None) if is_array(t) else None def get_enum_underlying_type(t: TypeInfo): return t.generics[0] if t.generics else None def get_enum_values(t: TypeInfo) -> List[int]: if is_enum(t) and t.enum_cases is not None: return [int(kv[1]) for kv in t.enum_cases] else: raise ValueError(f"{t.fullname} is not an enum type") def get_enum_names(t: TypeInfo) -> List[str]: if is_enum(t) and t.enum_cases is not None: return [str(kv[0]) for kv in t.enum_cases] else: raise ValueError(f"{t.fullname} is not an enum type") def get_enum_case(t: TypeInfo, v: Union[int, str]) -> EnumCase: if t.enum_cases is None: raise ValueError(f"{t.fullname} is not an enum type") if isinstance(v, str): for kv in t.enum_cases: if kv[0] == v: return kv raise ValueError(f"{v}' was not found in ${t.fullname}") for kv in t.enum_cases: if kv[1] == v: return kv # .NET returns the number even if it doesn't match any of the cases return ["", v] def get_tuple_elements(t: TypeInfo) -> List[TypeInfo]: if is_tuple(t) and t.generics is not None: return t.generics else: raise ValueError(f"{t.fullname} is not a tuple type") def get_function_elements(t: TypeInfo) -> List[TypeInfo]: if is_function(t) and t.generics is not None: gen = t.generics return [gen[0], gen[1]] else: raise ValueError(f"{t.fullname} is not an F# function type") def parse_enum(t: TypeInfo, string: str) -> int: try: value = int(string) except Exception: value = None return int(get_enum_case(t, value if value else string)[1]) def try_parse_enum(t: TypeInfo, string: str, def_value: FSharpRef[int]) -> bool: try: def_value.contents = parse_enum(t, string) return True except Exception: return False def get_enum_name(t: TypeInfo, v: int) -> str: return str(get_enum_case(t, v)[0]) def is_enum_defined(t: TypeInfo, v: Union[str, int]) -> bool: try: kv = get_enum_case(t, v) return kv[0] is not None and kv[0] != "" except Exception: # Supress error pass return False def get_record_elements(t: TypeInfo) -> List[FieldInfo]: if t.fields is not None: return t.fields() else: raise ValueError(f"{t.fullname} is not an F# record type") def get_record_fields(v: Any) -> List: if isinstance(v, dict): return list(v.values()) return [getattr(v, k) for k in v.__dict__.keys()] def get_record_field(v: Any, field: FieldInfo) -> Any: if isinstance(field[0], str): if isinstance(v, dict): return v[field[0]] return getattr(v, field[0]) raise ValueError("Field not a string.") def get_tuple_fields(v: Any) -> List: return v def get_tuple_field(v: Any, i: int) -> Any: return v[i] def make_record(t: TypeInfo, values: List) -> Any: fields = get_record_elements(t) if len(fields) != len(values): raise ValueError(f"Expected an array of length {len(fields)} but got {len(values)}") if t.construct is not None: return t.construct(*values) def reducer(obj, ifield): i, field = ifield obj[field[0]] = values[i] return obj return functools.reduce(reducer, enumerate(fields), {}) def make_tuple(values: List, _t: TypeInfo) -> Any: return tuple(values) def make_union(uci: CaseInfo, values: List) -> Any: expectedLength = len(uci.fields or []) if len(values) != expectedLength: raise ValueError(f"Expected an array of length {expectedLength} but got {len(values)}") return uci.declaringType.construct(uci.tag, *values) if uci.declaringType.construct else {} def get_union_cases(t: TypeInfo) -> List[CaseInfo]: if t.cases: return t.cases() else: raise ValueError(f"{t.fullname} is not an F# union type") def get_union_fields(v: Any, t: TypeInfo) -> List: cases = get_union_cases(t) case_ = cases[v.tag] if not case_: raise ValueError(f"Cannot find case {v.name} in union type") return [case_, list(v.fields)] def get_union_case_fields(uci: CaseInfo) -> List[FieldInfo]: return uci.fields if uci.fields else []
7,846
435
1,170
75d1e9be3c0054dda73122202f10bfd3443b59e0
13,344
py
Python
cgal4py/domain_decomp/__init__.py
yuki-inaho/cgal4py
9e61000c01368f9a16844c243ad6aced8611d055
[ "BSD-3-Clause" ]
4
2020-01-05T06:31:55.000Z
2021-03-06T03:11:33.000Z
cgal4py/domain_decomp/__init__.py
yuki-inaho/cgal4py
9e61000c01368f9a16844c243ad6aced8611d055
[ "BSD-3-Clause" ]
1
2020-03-21T14:59:03.000Z
2020-03-21T14:59:03.000Z
cgal4py/domain_decomp/__init__.py
yuki-inaho/cgal4py
9e61000c01368f9a16844c243ad6aced8611d055
[ "BSD-3-Clause" ]
1
2021-03-07T07:08:11.000Z
2021-03-07T07:08:11.000Z
import numpy as np import cykdtree as kdtree from cgal4py import PY_MAJOR_VERSION def tree(method, pts, left_edge, right_edge, periodic, *args, **kwargs): r"""Get tree for a given domain decomposition schema. Args: method (str): Domain decomposition method. Supported options are: 'kdtree': KDTree based on median position along the dimension with the greatest domain width. See :meth:`cgal4py.domain_decomp.kdtree` for details on accepted keyword arguments. pts (np.ndarray of float64): (n, m) array of n coordinates in a m-dimensional domain. left_edge (np.ndarray of float64): (m,) domain minimum in each dimension. right_edge (np.ndarray of float64): (m,) domain maximum in each dimension. *args: Variable argument list. Passed to the selected domain decomposition method. **kwargs: Variable keyword argument list. Passed to the selected domain decomposition method. Returns: object: Tree of type specified by `method`. Raises: ValueError: If `method` is not one of the supported domain decomposition methods listed above. """ # Get leaves if method.lower() == 'kdtree': tree = kdtree.PyKDTree(pts, left_edge, right_edge, *args, **kwargs) else: raise ValueError("'{}' is not a supported ".format(method) + "domain decomposition.") # Return tree return tree def process_leaves(leaves, left_edge, right_edge, periodic): r"""Process leaves ensuring they have the necessary information/methods for parallel tessellation. Each leaf must have at least the following attributes: npts (int): Number of points on the leaf. left_edge (np.ndarray of float): min of leaf extent in each dimension. right_edge (np.ndarray of float): max of leaf extent in each dimension. Args: leaves (list of leaf objects): Leaves in an arbitrary domain decomposition. left_edge (np.ndarray of float64): domain minimum in each dimension. right_edge (np.ndarray of float64): domain maximum in each dimension. periodic (bool): True if domain is periodic, False otherwise. Returns: list of leaf objects: Leaves process with additional attributes added if they do not exist and can be added. Raises: AttributeError: If a leaf does not have one of the required attributes. TypeError: If a leaf has a required attribute, but of the wrong type. ValueError: If a leaf has a required attribute, but of the wrong size. """ ndim = len(left_edge) req_attr = {'npts': [int, np.int32, np.uint32, np.int64, np.uint64], 'left_edge': ([float, np.float32, np.float64], (ndim,)), 'right_edge': ([float, np.float32, np.float64], (ndim,))} if PY_MAJOR_VERSION < 3: req_attr['npts'].append(long) # Check for necessary attributes for k, v in req_attr.items(): if isinstance(v, tuple): for i, leaf in enumerate(leaves): if not hasattr(leaf, k): raise AttributeError( "Leaf {} does not have attribute {}.".format(i, k)) lv = getattr(leaf, k) if not isinstance(lv, np.ndarray): raise TypeError("Attribute {} ".format(k) + "of leaf {} ".format(i) + "is not an array.\n" + "It is type {}.".format(type(lv))) if lv.dtype not in v[0]: raise TypeError("Attribute {} ".format(k) + "of leaf {} ".format(i) + "is not an array with dtype " + "{}.\n".format(v[0]) + "It is type {}.".format(lv.dtype)) if v[1] is not None and lv.shape != v[1]: raise ValueError("Attribute {} ".format(k) + "of leaf {} ".format(i) + "is not an array with shape " + "{}.\n".format(v[1]) + "It is shape {}.".format(lv.shape)) else: for i, leaf in enumerate(leaves): if not hasattr(leaf, k): raise AttributeError("Leaf {} does not ".format(i) + "have attribute {}.".format(k)) lv = getattr(leaf, k) if not isinstance(lv, tuple(v)): raise TypeError("Attribute {} ".format(k) + "of leaf {} is not ".format(i) + "of type {}.\n".format(v) + "It is type {}.".format(type(lv))) # Set id & ensure leaves are sorted if getattr(leaves[0], 'id', None) is None: for i, leaf in enumerate(leaves): leaf.id = i else: leaves = sorted(leaves, key=lambda l: l.id) # Set number of dimensions if getattr(leaves[0], 'ndim', None) is None: for leaf in leaves: leaf.ndim = ndim # Set total number of leaves if getattr(leaves[0], 'num_leaves', None) is None: num_leaves = len(leaves) for leaf in leaves: leaf.num_leaves = num_leaves # Set starting index if getattr(leaves[0], 'start_idx', None) is None: nprev = 0 for leaf in leaves: leaf.start_idx = nprev nprev += leaf.npts # Set stopping index if getattr(leaves[0], 'stop_idx', None) is None: for leaf in leaves: leaf.stop_idx = leaf.start_idx + leaf.npts # Set domain width if getattr(leaves[0], 'domain_width', None) is None: domain_width = right_edge - left_edge for leaf in leaves: leaf.domain_width = domain_width # Determine if leaves are on periodic boundaries if getattr(leaves[0], 'periodic_left', None) is None: if periodic: for leaf in leaves: leaf.periodic_left = np.isclose(leaf.left_edge, left_edge) leaf.periodic_right = np.isclose(leaf.right_edge, right_edge) else: for leaf in leaves: leaf.periodic_left = np.zeros(leaf.ndim, 'bool') leaf.periodic_right = np.zeros(leaf.ndim, 'bool') # Add neighbors if getattr(leaves[0], 'left_neighbors', None) is None: for j, leaf in enumerate(leaves): leaf.left_neighbors = [[] for _ in range(ndim)] leaf.right_neighbors = [[] for _ in range(ndim)] for prev in leaves[:(j+1)]: match = True for i in range(ndim): if leaf.left_edge[i] > prev.right_edge[i]: if not (leaf.periodic_right[i] and prev.periodic_left[i]): match = False break if leaf.right_edge[i] < prev.left_edge[i]: if not (prev.periodic_right[i] and leaf.periodic_left[i]): match = False break if match: for i in range(ndim): if np.isclose(leaf.left_edge[i], prev.right_edge[i]): leaf.left_neighbors[i].append(prev.id) prev.right_neighbors[i].append(leaf.id) elif np.isclose(leaf.right_edge[i], prev.left_edge[i]): leaf.right_neighbors[i].append(prev.id) prev.left_neighbors[i].append(leaf.id) if periodic: if (leaf.periodic_right[i] and prev.periodic_left[i]): leaf.right_neighbors[i].append(prev.id) prev.left_neighbors[i].append(leaf.id) if (prev.periodic_right[i] and leaf.periodic_left[i]): leaf.left_neighbors[i].append(prev.id) prev.right_neighbors[i].append(leaf.id) if getattr(leaves[0], 'neighbors', None) is None: for leaf in leaves: neighbors = [leaf.id] for i in range(ndim): neighbors += leaf.left_neighbors[i] neighbors += leaf.right_neighbors[i] leaf.neighbors = list(set(neighbors)) # Return leaves return leaves __all__ = ["tree", "kdtree", "GenericLeaf", "GenericTree", "process_leaves"]
43.465798
79
0.549086
import numpy as np import cykdtree as kdtree from cgal4py import PY_MAJOR_VERSION def tree(method, pts, left_edge, right_edge, periodic, *args, **kwargs): r"""Get tree for a given domain decomposition schema. Args: method (str): Domain decomposition method. Supported options are: 'kdtree': KDTree based on median position along the dimension with the greatest domain width. See :meth:`cgal4py.domain_decomp.kdtree` for details on accepted keyword arguments. pts (np.ndarray of float64): (n, m) array of n coordinates in a m-dimensional domain. left_edge (np.ndarray of float64): (m,) domain minimum in each dimension. right_edge (np.ndarray of float64): (m,) domain maximum in each dimension. *args: Variable argument list. Passed to the selected domain decomposition method. **kwargs: Variable keyword argument list. Passed to the selected domain decomposition method. Returns: object: Tree of type specified by `method`. Raises: ValueError: If `method` is not one of the supported domain decomposition methods listed above. """ # Get leaves if method.lower() == 'kdtree': tree = kdtree.PyKDTree(pts, left_edge, right_edge, *args, **kwargs) else: raise ValueError("'{}' is not a supported ".format(method) + "domain decomposition.") # Return tree return tree class GenericLeaf(object): def __init__(self, npts, left_edge, right_edge): r"""A generic container for leaf info with the minimum required info. These leaves must still be processed to add additional properties using :meth:`cgal4py.domain_decomp.process_leaves`, but can serve as a base class for supplemental domain decompositions and be provided to :class:`cgal4py.domain_decomp.GenericTree`. Args: npts (int): Number of points on this leaf. left_edge (np.ndarray of float64): Leaf min along each dimension. right_edge (np.ndarray of float64): Leaf max along each dimension. Attributes: npts (int): Number of points on this leaf, including those added during communication. left_edge (np.ndarray of float64): Domain minimum along each dimension. right_edge (np.ndarray of float64): Domain maximum along each dimension. """ self.npts = npts self.left_edge = left_edge self.right_edge = right_edge @classmethod def from_leaf(cls, leaf): r"""Construct a GenericLeaf from a non-generic leaf. Args: leaf (Leaf): A leaf object. Returns: :class:`cgal4py.domain_decomp.GenericLeaf`: Generic version of the input leaf. """ out = cls(leaf.npts, leaf.left_edge, leaf.right_edge) other_attr = ['id', 'ndim', 'num_leaves', 'start_idx', 'stop_idx', 'domain_width', 'periodic_left', 'periodic_right', 'left_neighbors', 'right_neighbors', 'neighbors'] for k in other_attr: if hasattr(leaf, k): setattr(out, k, getattr(leaf, k)) return out class GenericTree(object): def __init__(self, idx, leaves, left_edge, right_edge, periodic): r"""Generic container for domain decomposition with the minimal required info. The leaves must have at least the following attributes: npts (int): Number of points on the leaf. left_edge (np.ndarray of float): min of leaf extent in each dimension. right_edge (np.ndarray of float): max of leaf extent in each dimension. Args: idx (np.ndarray of int): Indices sorting points in the tree by the leaf that contains them. leaves (list of leaf objects): Leaves in an arbitrary domain decomposition. left_edge (np.ndarray of float): domain minimum in each dimension. right_edge (np.ndarray of float): domain maximum in each dimension. periodic (bool): True if domain is periodic, False otherwise. Attributes: idx (np.ndarray of int): Indices sorting points in the tree by the leaf that contains them. leaves (list of leaf objects): Leaves in an arbitrary domain decomposition. left_edge (np.ndarray of float): domain minimum in each dimension. right_edge (np.ndarray of float): domain maximum in each dimension. periodic (bool): True if domain is periodic, False otherwise. num_leaves (int): Number of leaves in the tree. domain_width (np.ndarray of float): Domain width in each dimension. """ self.idx = idx self.left_edge = left_edge self.right_edge = right_edge self.periodic = periodic self.domain_width = right_edge - left_edge self.num_leaves = len(leaves) self.leaves = process_leaves(leaves, left_edge, right_edge, periodic) @classmethod def from_tree(cls, tree): r"""Construct a GenericTree from a non-generic tree. Args: tree (Tree): A tree object. Returns: :class:`cgal4py.domain_decomp.GenericTree`: Generic version of the input tree. """ leaves = [GenericLeaf.from_leaf(leaf) for leaf in tree.leaves] out = cls(tree.idx, leaves, tree.left_edge, tree.right_edge, tree.periodic) other_attr = [] for k in other_attr: if hasattr(leaf, k): setattr(out, k, getattr(leaf, k)) return out def process_leaves(leaves, left_edge, right_edge, periodic): r"""Process leaves ensuring they have the necessary information/methods for parallel tessellation. Each leaf must have at least the following attributes: npts (int): Number of points on the leaf. left_edge (np.ndarray of float): min of leaf extent in each dimension. right_edge (np.ndarray of float): max of leaf extent in each dimension. Args: leaves (list of leaf objects): Leaves in an arbitrary domain decomposition. left_edge (np.ndarray of float64): domain minimum in each dimension. right_edge (np.ndarray of float64): domain maximum in each dimension. periodic (bool): True if domain is periodic, False otherwise. Returns: list of leaf objects: Leaves process with additional attributes added if they do not exist and can be added. Raises: AttributeError: If a leaf does not have one of the required attributes. TypeError: If a leaf has a required attribute, but of the wrong type. ValueError: If a leaf has a required attribute, but of the wrong size. """ ndim = len(left_edge) req_attr = {'npts': [int, np.int32, np.uint32, np.int64, np.uint64], 'left_edge': ([float, np.float32, np.float64], (ndim,)), 'right_edge': ([float, np.float32, np.float64], (ndim,))} if PY_MAJOR_VERSION < 3: req_attr['npts'].append(long) # Check for necessary attributes for k, v in req_attr.items(): if isinstance(v, tuple): for i, leaf in enumerate(leaves): if not hasattr(leaf, k): raise AttributeError( "Leaf {} does not have attribute {}.".format(i, k)) lv = getattr(leaf, k) if not isinstance(lv, np.ndarray): raise TypeError("Attribute {} ".format(k) + "of leaf {} ".format(i) + "is not an array.\n" + "It is type {}.".format(type(lv))) if lv.dtype not in v[0]: raise TypeError("Attribute {} ".format(k) + "of leaf {} ".format(i) + "is not an array with dtype " + "{}.\n".format(v[0]) + "It is type {}.".format(lv.dtype)) if v[1] is not None and lv.shape != v[1]: raise ValueError("Attribute {} ".format(k) + "of leaf {} ".format(i) + "is not an array with shape " + "{}.\n".format(v[1]) + "It is shape {}.".format(lv.shape)) else: for i, leaf in enumerate(leaves): if not hasattr(leaf, k): raise AttributeError("Leaf {} does not ".format(i) + "have attribute {}.".format(k)) lv = getattr(leaf, k) if not isinstance(lv, tuple(v)): raise TypeError("Attribute {} ".format(k) + "of leaf {} is not ".format(i) + "of type {}.\n".format(v) + "It is type {}.".format(type(lv))) # Set id & ensure leaves are sorted if getattr(leaves[0], 'id', None) is None: for i, leaf in enumerate(leaves): leaf.id = i else: leaves = sorted(leaves, key=lambda l: l.id) # Set number of dimensions if getattr(leaves[0], 'ndim', None) is None: for leaf in leaves: leaf.ndim = ndim # Set total number of leaves if getattr(leaves[0], 'num_leaves', None) is None: num_leaves = len(leaves) for leaf in leaves: leaf.num_leaves = num_leaves # Set starting index if getattr(leaves[0], 'start_idx', None) is None: nprev = 0 for leaf in leaves: leaf.start_idx = nprev nprev += leaf.npts # Set stopping index if getattr(leaves[0], 'stop_idx', None) is None: for leaf in leaves: leaf.stop_idx = leaf.start_idx + leaf.npts # Set domain width if getattr(leaves[0], 'domain_width', None) is None: domain_width = right_edge - left_edge for leaf in leaves: leaf.domain_width = domain_width # Determine if leaves are on periodic boundaries if getattr(leaves[0], 'periodic_left', None) is None: if periodic: for leaf in leaves: leaf.periodic_left = np.isclose(leaf.left_edge, left_edge) leaf.periodic_right = np.isclose(leaf.right_edge, right_edge) else: for leaf in leaves: leaf.periodic_left = np.zeros(leaf.ndim, 'bool') leaf.periodic_right = np.zeros(leaf.ndim, 'bool') # Add neighbors if getattr(leaves[0], 'left_neighbors', None) is None: for j, leaf in enumerate(leaves): leaf.left_neighbors = [[] for _ in range(ndim)] leaf.right_neighbors = [[] for _ in range(ndim)] for prev in leaves[:(j+1)]: match = True for i in range(ndim): if leaf.left_edge[i] > prev.right_edge[i]: if not (leaf.periodic_right[i] and prev.periodic_left[i]): match = False break if leaf.right_edge[i] < prev.left_edge[i]: if not (prev.periodic_right[i] and leaf.periodic_left[i]): match = False break if match: for i in range(ndim): if np.isclose(leaf.left_edge[i], prev.right_edge[i]): leaf.left_neighbors[i].append(prev.id) prev.right_neighbors[i].append(leaf.id) elif np.isclose(leaf.right_edge[i], prev.left_edge[i]): leaf.right_neighbors[i].append(prev.id) prev.left_neighbors[i].append(leaf.id) if periodic: if (leaf.periodic_right[i] and prev.periodic_left[i]): leaf.right_neighbors[i].append(prev.id) prev.left_neighbors[i].append(leaf.id) if (prev.periodic_right[i] and leaf.periodic_left[i]): leaf.left_neighbors[i].append(prev.id) prev.right_neighbors[i].append(leaf.id) if getattr(leaves[0], 'neighbors', None) is None: for leaf in leaves: neighbors = [leaf.id] for i in range(ndim): neighbors += leaf.left_neighbors[i] neighbors += leaf.right_neighbors[i] leaf.neighbors = list(set(neighbors)) # Return leaves return leaves __all__ = ["tree", "kdtree", "GenericLeaf", "GenericTree", "process_leaves"]
0
4,336
46
47de195050b2ce241f5bd06bf41a7f034574533c
787
py
Python
satsound/migrations/0002_auto_20161110_1753.py
saanobhaai/apman
e07452f54fcb895fb6039b6be63abf3861d7b9cb
[ "MIT" ]
null
null
null
satsound/migrations/0002_auto_20161110_1753.py
saanobhaai/apman
e07452f54fcb895fb6039b6be63abf3861d7b9cb
[ "MIT" ]
null
null
null
satsound/migrations/0002_auto_20161110_1753.py
saanobhaai/apman
e07452f54fcb895fb6039b6be63abf3861d7b9cb
[ "MIT" ]
null
null
null
# -*- coding: utf-8 -*- # Generated by Django 1.10.1 on 2016-11-10 17:53 from __future__ import unicode_literals import django.db.models.deletion from django.db import migrations, models
29.148148
116
0.631512
# -*- coding: utf-8 -*- # Generated by Django 1.10.1 on 2016-11-10 17:53 from __future__ import unicode_literals import django.db.models.deletion from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('satsound', '0001_initial'), ] operations = [ migrations.AddField( model_name='satellitetrajectory', name='observer', field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to='satsound.Observer'), preserve_default=False, ), migrations.AlterField( model_name='satellite', name='tle', field=models.CharField(blank=True, max_length=164, verbose_name='two-line element'), ), ]
0
575
23
25e24f00aae6558660cbd00a9c7e07a9e7f285e8
2,990
py
Python
tests/test_config.py
power-edge/PySBR
f768c24e539557c08dfcaf39ce1eaca7d730cf25
[ "MIT" ]
49
2020-12-13T07:07:50.000Z
2022-02-09T18:54:39.000Z
tests/test_config.py
power-edge/PySBR
f768c24e539557c08dfcaf39ce1eaca7d730cf25
[ "MIT" ]
11
2021-01-08T05:04:52.000Z
2022-03-16T12:51:28.000Z
tests/test_config.py
power-edge/PySBR
f768c24e539557c08dfcaf39ce1eaca7d730cf25
[ "MIT" ]
9
2021-01-18T02:03:24.000Z
2022-01-29T04:47:01.000Z
import pytest from pytest import mark from pytest_lazyfixture import lazy_fixture
32.5
83
0.485619
import pytest from pytest import mark from pytest_lazyfixture import lazy_fixture class TestConfig: @mark.parametrize( "league", [ lazy_fixture("nfl"), lazy_fixture("ncaaf"), lazy_fixture("epl"), lazy_fixture("mlb"), lazy_fixture("nba"), lazy_fixture("nhl"), lazy_fixture("atp"), lazy_fixture("ncaab"), lazy_fixture("ufc"), lazy_fixture("sportsbook"), ], ) def test_init(self, league): pass @mark.parametrize( "league, terms, expected", [ (lazy_fixture("nfl"), ["2q money lines", "2q tot", "2qou"], [97, 408]), (lazy_fixture("nfl"), ["ml", "ps"], [83, 401]), ( lazy_fixture("nfl"), ["first half spread", "1q spread", "4th-quarter over/under"], [397, 403, 410], ), (lazy_fixture("ncaaf"), ["money lines", "ps"], [83, 401]), (lazy_fixture("ncaaf"), "foo", None), (lazy_fixture("ncaaf"), ["fg foo"], None), (lazy_fixture("ncaaf"), ["1h total"], [398]), (lazy_fixture("atp"), ["us open winner"], [721]), ], ) def test_market_ids(self, league, terms, expected): if expected is None: with pytest.raises(ValueError): league.market_ids(terms) else: assert league.market_ids(terms) == expected @mark.parametrize( "league, terms, expected", [ (lazy_fixture("nfl"), ["pit", "bal"], [1519, 1521]), (lazy_fixture("nfl"), ["Pittsburgh Steelers", "Ravens"], [1519, 1521]), (lazy_fixture("nfl"), ["foo Steelers", "Ravens"], None), (lazy_fixture("nfl"), ["New York"], None), # there are 2 teams called the mountaineers! (lazy_fixture("ncaaf"), ["WVU", "Mountaineers"], None), ( lazy_fixture("ncaaf"), ["WVU", "West Virginia Mountaineers", "West Virginia"], [407], ), ( lazy_fixture("ncaaf"), ["WVU", "Rutgers"], [407, 410], ), ], ) def test_team_ids(self, league, terms, expected): if expected is None: with pytest.raises(ValueError): league.team_ids(terms) else: assert league.team_ids(terms) == expected @mark.parametrize( "terms, expected", [ (["pinnacle", "bodog", "bet365"], [20, 9, 5]), (["pinnacle", "bodog sportsbook", "bet365"], [20, 9, 5]), ("foo", None), ], ) def test_sportsbook_ids(self, sportsbook, terms, expected): if expected is None: with pytest.raises(ValueError): sportsbook.ids(terms) else: assert sportsbook.ids(terms) == expected
659
2,225
23
65ad5cf978781fc39296c7ef6130f2bc6c3e1a86
21,851
py
Python
attic/pyromsguiwx_old.py
rsoutelino/romsview
0a44e6ef795ff3580960792836adcc64730994d6
[ "MIT" ]
2
2021-12-11T19:27:37.000Z
2022-03-05T04:09:18.000Z
attic/pyromsguiwx_old.py
rsoutelino/romsview
0a44e6ef795ff3580960792836adcc64730994d6
[ "MIT" ]
null
null
null
attic/pyromsguiwx_old.py
rsoutelino/romsview
0a44e6ef795ff3580960792836adcc64730994d6
[ "MIT" ]
3
2021-11-06T20:17:02.000Z
2022-01-16T09:23:48.000Z
#!/usr/bin/env python ###################################################### # GUI to vizualize ROMS input/output files # Sep 2021 # [email protected] ###################################################### import os import wx import datetime as dt from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas from matplotlib.backends.backend_wxagg import NavigationToolbar2WxAgg as Navbar from matplotlib.backends.backend_wx import NavigationToolbar2Wx from matplotlib.figure import Figure import numpy as np import matplotlib.pyplot as plt from matplotlib.path import Path import scipy.io as sp import netCDF4 as nc from lib import * # TO-DO LIST: ==================================================== # - correct bug with date selection: somehow the times re-start # every 00z # - need to decide which x-axis to use, lon or lat # ================================================================ # NICE TIP TO DEBUG THIS PROGRAM: ================================ # - comment out app.MainLoop at the last line of this script # - ipython --gui=wx # - run pyromsgui.py # - trigger the events and check out the objects in the shell # ================================================================ global currentDirectory currentDirectory = os.getcwd() PROJECT_DIR = os.path.abspath(os.path.dirname(__file__)) DEFAULT_VMIN = 0 DEFAULT_VMAX = 1.5 DEFAULT_CMAP = plt.cm.BrBG DEFAULT_DEPTH_FOR_LAND = -50 class SimpleMPLCanvas(object): """docstring for SimpleMPLCanvas""" def romsTime2string(nctime): """ nctime : netCDF4 variable """ timeunits = nctime.units units = timeunits.split(' ')[0] tstart = dt.datetime.strptime(timeunits.split(' ')[-2], "%Y-%m-%d") timelist = [] for t in nctime[:]: if units == 'seconds': current = tstart + dt.timedelta(seconds=t) if units == 'days': current = tstart + dt.timedelta(seconds=t*86400) timelist.append(current.strftime("%Y-%m-%d %H h")) return timelist def load_bitmap(filename, direc=None): """ Load a bitmap file from the ./icons subdirectory. The filename parameter should not contain any path information as this is determined automatically. Returns a wx.Bitmap object copied from matoplotlib resources """ if not direc: basedir = os.path.join(PROJECT_DIR, 'icons') else: basedir = os.path.join(PROJECT_DIR, direc) bmpFilename = os.path.normpath(os.path.join(basedir, filename)) if not os.path.exists(bmpFilename): raise IOError('Could not find bitmap file "%s"; dying' % bmpFilename) bmp = wx.Bitmap(bmpFilename) return bmp if __name__ == "__main__": app = App(False) app.MainLoop()
36.540134
103
0.565558
#!/usr/bin/env python ###################################################### # GUI to vizualize ROMS input/output files # Sep 2021 # [email protected] ###################################################### import os import wx import datetime as dt from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas from matplotlib.backends.backend_wxagg import NavigationToolbar2WxAgg as Navbar from matplotlib.backends.backend_wx import NavigationToolbar2Wx from matplotlib.figure import Figure import numpy as np import matplotlib.pyplot as plt from matplotlib.path import Path import scipy.io as sp import netCDF4 as nc from lib import * # TO-DO LIST: ==================================================== # - correct bug with date selection: somehow the times re-start # every 00z # - need to decide which x-axis to use, lon or lat # ================================================================ # NICE TIP TO DEBUG THIS PROGRAM: ================================ # - comment out app.MainLoop at the last line of this script # - ipython --gui=wx # - run pyromsgui.py # - trigger the events and check out the objects in the shell # ================================================================ global currentDirectory currentDirectory = os.getcwd() PROJECT_DIR = os.path.abspath(os.path.dirname(__file__)) DEFAULT_VMIN = 0 DEFAULT_VMAX = 1.5 DEFAULT_CMAP = plt.cm.BrBG DEFAULT_DEPTH_FOR_LAND = -50 class App(wx.App): def OnInit(self): self.frame = Interface("PyRomsGUI 0.1.0", size=(1024, 800)) self.frame.Show() return True class Interface(wx.Frame): def __init__(self, title=wx.EmptyString, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE, *args, **kwargs): wx.Frame.__init__(self, None, -1, "PyRomsGUI 0.1.0", pos=pos, size=size, style=style, *args, **kwargs) # Initializing toolbar self.toolbar = MainToolBar(self) # BASIC LAYOUT OF THE NESTED SIZERS ====================== panel1 = wx.Panel(self, wx.ID_ANY, style=wx.SUNKEN_BORDER) mplpanel = wx.Panel(self, wx.ID_ANY, style=wx.SUNKEN_BORDER) mplpanel.SetBackgroundColour("WHITE") # BOX 1 is the main sizer box1 = wx.BoxSizer(wx.HORIZONTAL) box1.Add(panel1, 1, wx.EXPAND) box1.Add(mplpanel, 4, wx.EXPAND) # BOX 2 is the inner sizer of the left big control panel box2 = wx.BoxSizer(wx.VERTICAL) # BOX 3 is the sizer of the right big parent panel(panel1), the one that will # serve as base for two child panels which will hold # the two matplotlib canvas's box3 = wx.BoxSizer(wx.VERTICAL) # panel 1 content ======================================== variable = wx.StaticText(panel1, label="Variable") box2.Add(variable, proportion=0, flag=wx.CENTER) self.var_select = wx.ComboBox(panel1, value='Choose variable') box2.Add(self.var_select, proportion=0, flag=wx.CENTER) self.var_select.Bind(wx.EVT_COMBOBOX, self.toolbar.OnUpdateHslice) time = wx.StaticText(panel1, label="Time record") box2.Add(time, proportion=0, flag=wx.CENTER) self.time_select = wx.ComboBox(panel1, value='Choose time step') box2.Add(self.time_select, proportion=0, flag=wx.CENTER) self.time_select.Bind(wx.EVT_COMBOBOX, self.toolbar.OnUpdateHslice) # mplpanel content ======================================== self.mplpanel = SimpleMPLCanvas(mplpanel) box3.Add(self.mplpanel.canvas, 1, flag=wx.CENTER) # FINAL LAYOUT CONFIGURATIONS ============================ self.SetAutoLayout(True) panel1.SetSizer(box2) mplpanel.SetSizer(box3) self.SetSizer(box1) self.InitMenu() self.Layout() self.Centre() def InitMenu(self): menubar = wx.MenuBar() fileMenu = wx.Menu() fileMenu.Append(wx.ID_OPEN, u'&Open ROMS grid file') fileMenu.Append(wx.ID_OPEN, u'&Open coastline file') fileMenu.Append(wx.ID_SAVE, '&Save grid') fileMenu.AppendSeparator() qmi = wx.MenuItem(fileMenu, wx.ID_EXIT, '&Quit\tCtrl+W') opf = wx.MenuItem(fileMenu, wx.ID_OPEN, '&Open\tCtrl+O') opc = wx.MenuItem(fileMenu, wx.ID_OPEN, '&Open\tCtrl+O+C') svf = wx.MenuItem(fileMenu, wx.ID_SAVE, '&Save\tCtrl+S') fileMenu.AppendItem(qmi) # fileMenu.AppendItem(svf) self.Bind(wx.EVT_MENU, self.OnQuit, qmi) self.Bind(wx.EVT_MENU, self.toolbar.OnLoadFile, opf) self.Bind(wx.EVT_MENU, self.toolbar.OnLoadCoastline, opc) self.Bind(wx.EVT_MENU, self.toolbar.OnPlotVslice, svf) menubar.Append(fileMenu, u'&PyRomsGUI') self.SetMenuBar(menubar) def OnQuit(self, e): """Fecha o programa""" self.Close() self.Destroy() def OnCloseWindow(self, e): self.Destroy() class SimpleMPLCanvas(object): """docstring for SimpleMPLCanvas""" def __init__(self, parent): super(SimpleMPLCanvas, self).__init__() self.parent = parent self.plot_properties() self.make_navbar() def make_navbar(self): self.navbar = Navbar(self.canvas) self.navbar.SetPosition(wx.Point(0, 0)) # this is not working !! def plot_properties(self): # Create matplotlib figure self.fig = Figure(facecolor='w', figsize=(12, 8)) self.canvas = FigureCanvas(self.parent, -1, self.fig) self.ax = self.fig.add_subplot(111) # tit = self.ax1.set_title("ROMS mask_rho", fontsize=12, fontweight='bold') # tit.set_position([0.9, 1.05]) class MainToolBar(object): def __init__(self, parent): self.currentDirectory = os.getcwd() self.parent = parent self.toolbar = parent.CreateToolBar(style=1, id=1, name="Toolbar") self.tools_params = { 'load_file': (load_bitmap('grid.png'), u"Load ROMS netcdf file", "Load ocean_???.nc ROMS netcdf file"), 'load_coastline': (load_bitmap('coast.png'), u"Load coastline", "Load *.mat coastline file [lon / lat poligons]"), 'plot_vslice': (load_bitmap('save.png'), u"Plot vertical slice", "Plot vertical slice of some variable"), 'settings': (load_bitmap('settings.png'), u"PyRomsGUI settings", "PyRomsGUI configurations"), 'quit': (load_bitmap('exit.png'), u"Quit", "Quit PyRomsGUI"), } self.createTool(self.toolbar, self.tools_params['load_file'], self.OnLoadFile) self.createTool(self.toolbar, self.tools_params['load_coastline'], self.OnLoadCoastline) self.toolbar.AddSeparator() # from IPython import embed; embed() self.plot_vslice = self.createTool(self.toolbar, self.tools_params['plot_vslice'], self.OnPlotVslice) self.toolbar.AddSeparator() self.createTool(self.toolbar, self.tools_params['settings'], self.OnSettings) self.createTool(self.toolbar, self.tools_params['quit'], self.parent.OnQuit) self.toolbar.Realize() def createTool(self, parent, params, evt, isToggle=False): tool = parent.AddTool(wx.NewId(), 'a', params[0], shortHelp=params[1]) self.parent.Bind(wx.EVT_TOOL, evt, id=tool.GetId()) return tool def OnLoadFile(self, evt): openFileDialog = wx.FileDialog(self.parent, "Open roms netcdf file [*.nc]", "/ops/hindcast/roms/", " ", "netcdf files (*.nc)|*.nc", wx.FD_OPEN | wx.FD_FILE_MUST_EXIST) if openFileDialog.ShowModal() == wx.ID_CANCEL: return # the user changed idea... filename = openFileDialog.GetPath() self.ncfile = nc.Dataset(filename) # this function is intended to return relevant information on the file varlist, axeslist, time = taste_ncfile(self.ncfile) timelist = romsTime2string(time) app.frame.var_select.SetItems(varlist) app.frame.time_select.SetItems(timelist) app.frame.time_select.SetValue(timelist[0]) # opening ROMS grid openFileDialog = wx.FileDialog(self.parent, "Open roms GRID netcdf file [*_grd.nc]", "/ops/hindcast/roms/", " ", "netcdf files (*.nc)|*.nc", wx.FD_OPEN | wx.FD_FILE_MUST_EXIST) if openFileDialog.ShowModal() == wx.ID_CANCEL: return # the user changed idea... grdname = openFileDialog.GetPath() self.grd = nc.Dataset(grdname) lon = self.grd.variables['lon_rho'][:] lat = self.grd.variables['lat_rho'][:] h = self.grd.variables['h'][:] mplpanel = app.frame.mplpanel ax = mplpanel.ax self.pcolor = ax.pcolormesh(lon, lat, h, cmap=plt.cm.terrain_r) ax.set_xlim([lon.min(), lon.max()]) ax.set_ylim([lat.min(), lat.max()]) ax.set_aspect('equal') mplpanel.canvas.draw() def OnUpdateHslice(self, evt): # from IPython import embed; embed() varname = app.frame.var_select.GetValue() var = self.ncfile.variables[varname] dimensions = var.dimensions grid = dimensions[-1].split('_')[-1] lon = self.grd.variables['lon_'+grid][:] lat = self.grd.variables['lat_'+grid][:] # time index varlist, axeslist, time = taste_ncfile(self.ncfile) timestr = app.frame.time_select.GetValue() selected_time = string2romsTime(timestr, self.ncfile) # from IPython import embed; embed() tindex = np.where(time[:] == selected_time)[0][0] if len(dimensions) == 3: arr = var[tindex, ...] if len(dimensions) == 4: arr = var[tindex, -1, ...] mplpanel = app.frame.mplpanel ax = mplpanel.ax ax.clear() ax.pcolormesh(lon, lat, arr, cmap=plt.cm.jet) ax.set_xlim([lon.min(), lon.max()]) ax.set_ylim([lat.min(), lat.max()]) ax.set_title("%s %s" % (varname, timestr)) ax.set_aspect('equal') mplpanel.canvas.draw() def OnLoadCoastline(self, evt): openFileDialog = wx.FileDialog(self.parent, "Open coastline file - MATLAB Seagrid-like format", "/home/rsoutelino/metocean/projects/mermaid", " ", "MAT files (*.mat)|*.mat", wx.FD_OPEN | wx.FD_FILE_MUST_EXIST) if openFileDialog.ShowModal() == wx.ID_CANCEL: return # the user changed idea... filename = openFileDialog.GetPath() coast = sp.loadmat(filename) lon, lat = coast['lon'], coast['lat'] mplpanel = app.frame.mplpanel ax = mplpanel.ax ax.plot(lon, lat, 'k') try: ax.set_xlim([self.grd.lonr.min(), self.grd.lonr.max()]) ax.set_ylim([self.grd.latr.min(), self.grd.latr.max()]) except AttributeError: # just in case a grid was not loaded before ax.set_xlim([np.nanmin(lon), np.nanmax(lon)]) ax.set_ylim([np.nanmin(lat), np.nanmax(lat)]) ax.set_aspect('equal') mplpanel.canvas.draw() def OnPlotVslice(self, evt): mplpanel = app.frame.mplpanel self.cid = mplpanel.canvas.mpl_connect( 'button_press_event', self.vslice) def OnSettings(self, evt): pass def vslice(self, evt): if evt.inaxes != app.frame.mplpanel.ax: return mplpanel = app.frame.mplpanel ax = mplpanel.ax x, y = evt.xdata, evt.ydata button = evt.button p = ax.plot(x, y, 'wo', markeredgecolor='k') try: self.points.append(p) self.area.append((x, y)) except AttributeError: self.points = [p] self.area = [(x, y)] if len(self.points) == 2: ax.plot([self.area[0][0], self.area[1][0]], [self.area[0][1], self.area[1][1]], 'k') p1, p2 = self.area[0], self.area[1] mplpanel.canvas.draw() if len(self.points) == 2: # assigning relevant variables varname = app.frame.var_select.GetValue() var = self.ncfile.variables[varname] dimensions = var.dimensions grid = dimensions[-1].split('_')[-1] lon = self.grd.variables['lon_'+grid][:] lat = self.grd.variables['lat_'+grid][:] ts = self.ncfile.variables['theta_s'][:] tb = self.ncfile.variables['theta_b'][:] hc = self.ncfile.variables['hc'][:] nlev = var.shape[1] sc = (np.arange(1, nlev + 1) - nlev - 0.5) / nlev sigma = self.ncfile.variables['Cs_r'][:] dl = (np.gradient(lon)[1].mean() + np.gradient(lat)[0].mean()) / 2 siz = int(np.sqrt((p1[0] - p2[0])**2 + (p1[1] - p2[1])**2) / dl) xs = np.linspace(p1[0], p2[0], siz) ys = np.linspace(p1[1], p2[1], siz) # time index varlist, axeslist, time = taste_ncfile(self.ncfile) timestr = app.frame.time_select.GetValue() selected_time = string2romsTime(timestr, self.ncfile) tindex = np.where(time[:] == selected_time)[0][0] # getting nearest values hsec, zeta, vsec = [], [], [] for ind in range(xs.size): line, col = near2d(lon, lat, xs[ind], ys[ind]) vsec.append(var[tindex, :, line, col]) hsec.append(self.grd.variables['h'][line, col]) zeta.append(self.ncfile.variables['zeta'][tindex, line, col]) vsec = np.array(vsec).transpose() hsec, zeta = np.array(hsec), np.array(zeta) xs = xs.reshape(1, xs.size).repeat(nlev, axis=0) ys = ys.reshape(1, ys.size).repeat(nlev, axis=0) zsec = get_zlev(hsec, sigma, 5, sc, ssh=zeta, Vtransform=2) xs = np.ma.masked_where(vsec > 1e20, xs) ys = np.ma.masked_where(vsec > 1e20, ys) zsec = np.ma.masked_where(vsec > 1e20, zsec) vsec = np.ma.masked_where(vsec > 1e20, vsec) self.vslice_dialog = VsliceDialog(app.frame, xs, ys, zsec, vsec) del self.points, self.area mplpanel.canvas.draw() class VsliceDialog(wx.Dialog): def __init__(self, parent, xs, ys, zsec, vsec, *args, **kwargs): wx.Dialog.__init__(self, parent, -1, "VARIABLE Vertical Slice, TIMERECORD", pos=(0, 0), size=(1200, 600), style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) self.xs, self.ys, self.zsec, self.vsec = xs, ys, zsec, vsec # BASIC LAYOUT OF THE NESTED SIZERS ====================== panel1 = wx.Panel(self, wx.ID_ANY, style=wx.SUNKEN_BORDER) mplpanel = wx.Panel(self, wx.ID_ANY, style=wx.SUNKEN_BORDER) mplpanel.SetBackgroundColour("WHITE") # BOX 1 is the main sizer box1 = wx.BoxSizer(wx.HORIZONTAL) box1.Add(panel1, 1, wx.EXPAND) box1.Add(mplpanel, 4, wx.EXPAND) # BOX 2 is the inner sizer of the left control panel box2 = wx.BoxSizer(wx.VERTICAL) # BOX 3 is the sizer of the panel1 box3 = wx.BoxSizer(wx.VERTICAL) # panel 1 content ======================================== plot_type = wx.StaticText(panel1, label="Plot type") box2.Add(plot_type, proportion=0, flag=wx.CENTER) self.plot_select = wx.ComboBox(panel1, value='scatter') box2.Add(self.plot_select, proportion=0, flag=wx.CENTER) self.plot_select.Bind(wx.EVT_COMBOBOX, self.OnUpdatePlot) self.plot_select.SetItems(['scatter', 'pcolormesh', 'contourf', 'contour']) minmax = wx.StaticText(panel1, label="Range") box2.Add(minmax, proportion=0, flag=wx.CENTER) self.max = wx.TextCtrl(panel1, value=str(vsec.max())) self.min = wx.TextCtrl(panel1, value=str(vsec.min())) box2.Add(self.max, proportion=0, flag=wx.CENTER) box2.Add(self.min, proportion=0, flag=wx.CENTER) scale = wx.StaticText(panel1, label="Scatter scale") box2.Add(scale, proportion=0, flag=wx.CENTER) self.scatter_scale = wx.SpinCtrl(panel1, value='50') box2.Add(self.scatter_scale, proportion=0, flag=wx.CENTER) # mplpanel content ======================================== self.mplpanel = SimpleMPLCanvas(mplpanel) box3.Add(self.mplpanel.canvas, 1, flag=wx.CENTER) ax = self.mplpanel.ax pl = ax.scatter(xs.ravel(), zsec.ravel(), s=50, c=vsec.ravel(), edgecolors='none', cmap=plt.cm.jet) self.mplpanel.ax2 = self.mplpanel.fig.add_axes( [0.93, 0.15, 0.015, 0.7]) ax2 = self.mplpanel.ax2 cbar = self.mplpanel.fig.colorbar(pl, cax=ax2) ax.set_xlim([xs.min(), xs.max()]) ax.set_ylim([zsec.min(), zsec.max()]) self.mplpanel.canvas.draw() # FINAL LAYOUT CONFIGURATIONS ============================ self.SetAutoLayout(True) panel1.SetSizer(box2) mplpanel.SetSizer(box3) self.SetSizer(box1) self.Show() def OnUpdatePlot(self, evt): xs, ys, zsec, vsec = self.xs, self.ys, self.zsec, self.vsec ax, ax2 = self.mplpanel.ax, self.mplpanel.ax2 ax.clear() ax2.clear() vmin, vmax = float(self.min.GetValue()), float(self.max.GetValue()) plot_type = self.plot_select.GetValue() sc = self.scatter_scale.GetValue() if plot_type == 'scatter': pl = ax.scatter(xs.ravel(), zsec.ravel(), s=sc, c=vsec.ravel(), vmin=vmin, vmax=vmax, edgecolors='none', cmap=plt.cm.jet) elif plot_type == 'pcolormesh': pl = ax.pcolormesh(xs, zsec, vsec, vmin=vmin, vmax=vmax, cmap=plt.cm.jet) elif plot_type == 'contourf': zsec = np.array(zsec) f = np.where(np.isnan(zsec) == True) zsec[f] = 0 levs = np.linspace(vmin, vmax, 50) pl = ax.contourf(xs, zsec, vsec, levs, cmap=plt.cm.jet) elif plot_type == 'contour': zsec = np.array(zsec) f = np.where(np.isnan(zsec) == True) zsec[f] = 0 levs = np.linspace(vmin, vmax, 50) pl = ax.contour(xs, zsec, vsec, levs, cmap=plt.cm.jet) ax.set_xlim([xs.min(), xs.max()]) ax.set_ylim([zsec.min(), zsec.max()]) cbar = self.mplpanel.fig.colorbar(pl, cax=ax2) self.mplpanel.canvas.draw() def taste_ncfile(ncfile): try: if "history" in ncfile.type: filetype = 'his' elif 'restart' in ncfile.type: filetype = 'rst' except AttributeError: print "Not a standard ROMS file !" filetype = 'clim' # old wrapper varlist = ROMSVARS[filetype]['variables'] axeslist = ROMSVARS[filetype]['axes'] for axes in axeslist: if 'time' in axes: try: time = ncfile.variables[axes] except KeyError: time = ncfile.variables['time'] # for non-default axes name else: pass return varlist, axeslist, time def romsTime2string(nctime): """ nctime : netCDF4 variable """ timeunits = nctime.units units = timeunits.split(' ')[0] tstart = dt.datetime.strptime(timeunits.split(' ')[-2], "%Y-%m-%d") timelist = [] for t in nctime[:]: if units == 'seconds': current = tstart + dt.timedelta(seconds=t) if units == 'days': current = tstart + dt.timedelta(seconds=t*86400) timelist.append(current.strftime("%Y-%m-%d %H h")) return timelist def string2romsTime(timelist, ncfile): if not isinstance(timelist, list): timelist = [timelist] varlist, axeslist, time = taste_ncfile(ncfile) timeunits = time.units units = timeunits.split(' ')[0] tstart = dt.datetime.strptime(timeunits.split(' ')[-2], "%Y-%m-%d") romstime = [] for timestr in timelist: dttime = dt.datetime.strptime(timestr, "%Y-%m-%d %H h") delta = dttime - tstart if units == 'seconds': current = delta.seconds if units == 'days': current = delta.days romstime.append(current) if len(romstime) == 1: return romstime[0] else: return romstime def load_bitmap(filename, direc=None): """ Load a bitmap file from the ./icons subdirectory. The filename parameter should not contain any path information as this is determined automatically. Returns a wx.Bitmap object copied from matoplotlib resources """ if not direc: basedir = os.path.join(PROJECT_DIR, 'icons') else: basedir = os.path.join(PROJECT_DIR, direc) bmpFilename = os.path.normpath(os.path.join(basedir, filename)) if not os.path.exists(bmpFilename): raise IOError('Could not find bitmap file "%s"; dying' % bmpFilename) bmp = wx.Bitmap(bmpFilename) return bmp if __name__ == "__main__": app = App(False) app.MainLoop()
18,372
197
513
700588898a4c3e0a8dc6ac4dc1d2cd5ed25b1673
1,464
py
Python
02_Math/sum_of_pairwise_hamming_distance.py
Sheetal0601/InterviewBit
72ba1507278dafac6e5fb81da20d372e3d141348
[ "MIT" ]
61
2018-02-18T08:16:31.000Z
2022-02-17T17:18:57.000Z
02_Math/sum_of_pairwise_hamming_distance.py
Sheetal0601/InterviewBit
72ba1507278dafac6e5fb81da20d372e3d141348
[ "MIT" ]
1
2018-02-23T20:06:18.000Z
2019-12-29T18:52:20.000Z
02_Math/sum_of_pairwise_hamming_distance.py
Sheetal0601/InterviewBit
72ba1507278dafac6e5fb81da20d372e3d141348
[ "MIT" ]
30
2018-03-28T19:02:23.000Z
2021-07-06T20:00:14.000Z
# Sum of pairwise Hamming Distance # https://www.interviewbit.com/problems/sum-of-pairwise-hamming-distance/ # # Hamming distance between two non-negative integers is defined as the number of positions at # which the corresponding bits are different. # # For example, # # HammingDistance(2, 7) = 2, as only the first and the third bit differs in the binary # representation of 2 (010) and 7 (111). # # Given an array of N non-negative integers, find the sum of hamming distances of all pairs of # integers in the array. # # Return the answer modulo 1000000007. # # Example # # Let f(x, y) be the hamming distance defined above. # # A=[2, 4, 6] # # We return, # f(2, 2) + f(2, 4) + f(2, 6) + # f(4, 2) + f(4, 4) + f(4, 6) + # f(6, 2) + f(6, 4) + f(6, 6) = # # 0 + 2 + 1 # 2 + 0 + 1 # 1 + 1 + 0 = 8 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # @param A : tuple of integers # @return an integer # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # if __name__ == "__main__": s = Solution() print(s.hammingDistance((2, 4, 6)))
26.142857
99
0.503415
# Sum of pairwise Hamming Distance # https://www.interviewbit.com/problems/sum-of-pairwise-hamming-distance/ # # Hamming distance between two non-negative integers is defined as the number of positions at # which the corresponding bits are different. # # For example, # # HammingDistance(2, 7) = 2, as only the first and the third bit differs in the binary # representation of 2 (010) and 7 (111). # # Given an array of N non-negative integers, find the sum of hamming distances of all pairs of # integers in the array. # # Return the answer modulo 1000000007. # # Example # # Let f(x, y) be the hamming distance defined above. # # A=[2, 4, 6] # # We return, # f(2, 2) + f(2, 4) + f(2, 6) + # f(4, 2) + f(4, 4) + f(4, 6) + # f(6, 2) + f(6, 4) + f(6, 6) = # # 0 + 2 + 1 # 2 + 0 + 1 # 1 + 1 + 0 = 8 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # class Solution: # @param A : tuple of integers # @return an integer def hammingDistance(self, A): flag, n, ans = 1, len(A), 0 for i in range(32): cnt = 0 for a in A: cnt += (a & flag) > 0 ans = (ans + cnt * (n - cnt)) % 1000000007 flag <<= 1 return (ans * 2) % 1000000007 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # if __name__ == "__main__": s = Solution() print(s.hammingDistance((2, 4, 6)))
274
-6
49
a3630273dbac15d887205a06684a473409e30b99
1,865
py
Python
Python/Algorithms/Machine Learning Algorithms/Naive Bayes in python.py
ThunderZ007/Data-Structures-and-Algorithms
148415faf6472115f6848b1a4e21b660b6d327da
[ "MIT" ]
245
2020-10-05T14:52:37.000Z
2022-03-29T07:40:38.000Z
Python/Algorithms/Machine Learning Algorithms/Naive Bayes in python.py
ThunderZ007/Data-Structures-and-Algorithms
148415faf6472115f6848b1a4e21b660b6d327da
[ "MIT" ]
521
2020-10-05T15:25:29.000Z
2021-11-09T13:24:01.000Z
Python/Algorithms/Machine Learning Algorithms/Naive Bayes in python.py
ThunderZ007/Data-Structures-and-Algorithms
148415faf6472115f6848b1a4e21b660b6d327da
[ "MIT" ]
521
2020-10-05T15:29:42.000Z
2022-03-27T10:22:00.000Z
#!/usr/bin/env python # coding: utf-8 # In[16]: #importing required packages import pandas as pd from sklearn import preprocessing from sklearn.model_selection import train_test_split from sklearn.naive_bayes import GaussianNB from sklearn.metrics import accuracy_score from sklearn.metrics import confusion_matrix from sklearn.naive_bayes import BernoulliNB clf=BernoulliNB() #loading the data dataset=pd.read_csv("C:/Users/ASUS/Downloads/train.csv") dataset.head() #getting the description of the dataset dataset.describe() dataset.describe().sum() #get some info about the data dataset.info() #getting the amount of null values in each column dataset.isnull().sum() #dropping the unimportant columns dataset=dataset.drop('PassengerId', axis=1) dataset=dataset.drop('Name', axis=1) dataset=dataset.drop('Ticket', axis=1) dataset=dataset.drop('Cabin', axis=1) dataset.head() #label encoding the categorical values which are of object type le=preprocessing.LabelEncoder() dataset['Sex']=le.fit_transform(dataset['Sex']) dataset['Embarked']=le.fit_transform(dataset['Embarked']) dataset.head() """this functions takes the independent variable column and trains the model after dividing the dataset into x and y and also spliting the dataset into training and testing data.This also prints the accuracy score and the confusion matrix""" #Calling the function navbaiyes('Survived') # In[ ]:
25.202703
124
0.742091
#!/usr/bin/env python # coding: utf-8 # In[16]: #importing required packages import pandas as pd from sklearn import preprocessing from sklearn.model_selection import train_test_split from sklearn.naive_bayes import GaussianNB from sklearn.metrics import accuracy_score from sklearn.metrics import confusion_matrix from sklearn.naive_bayes import BernoulliNB clf=BernoulliNB() #loading the data dataset=pd.read_csv("C:/Users/ASUS/Downloads/train.csv") dataset.head() #getting the description of the dataset dataset.describe() dataset.describe().sum() #get some info about the data dataset.info() #getting the amount of null values in each column dataset.isnull().sum() #dropping the unimportant columns dataset=dataset.drop('PassengerId', axis=1) dataset=dataset.drop('Name', axis=1) dataset=dataset.drop('Ticket', axis=1) dataset=dataset.drop('Cabin', axis=1) dataset.head() #label encoding the categorical values which are of object type le=preprocessing.LabelEncoder() dataset['Sex']=le.fit_transform(dataset['Sex']) dataset['Embarked']=le.fit_transform(dataset['Embarked']) dataset.head() """this functions takes the independent variable column and trains the model after dividing the dataset into x and y and also spliting the dataset into training and testing data.This also prints the accuracy score and the confusion matrix""" def navbaiyes(value): x=dataset.drop([value], axis=1) y=dataset[value] x_train,x_test,y_train,y_test=train_test_split(x,y,test_size=0.2,random_state=0) y_pred= clf.fit(x_train,y_train).predict(x_test) print("The accuracy score is:") print(accuracy_score(y_test, y_pred)*100) print('--------------------------------------------') print("The confusion matrix is:") print(confusion_matrix(y_test,y_pred)) #Calling the function navbaiyes('Survived') # In[ ]:
426
0
24
44ea9fb9dbeae66a8bc24c2056240e71d2dc20e2
464
py
Python
python/basis/11-string.py
weizhenwei/tech-docs-2016
253564a1633e9ec75ac94efede57f52c02b29280
[ "BSD-2-Clause" ]
3
2017-06-09T08:48:07.000Z
2020-12-13T10:37:44.000Z
python/basis/11-string.py
weizhenwei/tech-docs-sharetome
253564a1633e9ec75ac94efede57f52c02b29280
[ "BSD-2-Clause" ]
null
null
null
python/basis/11-string.py
weizhenwei/tech-docs-sharetome
253564a1633e9ec75ac94efede57f52c02b29280
[ "BSD-2-Clause" ]
4
2020-04-29T07:03:44.000Z
2021-07-25T15:12:15.000Z
#!/usr/bin/env python import math var1 = "Hello" var2 = "Worldpress" print "var1 = ", var1 print "var2 = ", var2 print "var1[0] = ", var1[0] print "var2[1:5] = ", var2[1:5] if ('H' in var1): print "H is in var1 ", var1 else: print "H is not in var1 ", var1 if ('H' not in var2): print "H is not in var2 ", var2 else: print "H is in var2 ", var2 var3 = var1 + var2; print "var1 + var2 = ", var3 print "var1 = %s, var2 = %s" % (var1, var2)
15.466667
43
0.571121
#!/usr/bin/env python import math var1 = "Hello" var2 = "Worldpress" print "var1 = ", var1 print "var2 = ", var2 print "var1[0] = ", var1[0] print "var2[1:5] = ", var2[1:5] if ('H' in var1): print "H is in var1 ", var1 else: print "H is not in var1 ", var1 if ('H' not in var2): print "H is not in var2 ", var2 else: print "H is in var2 ", var2 var3 = var1 + var2; print "var1 + var2 = ", var3 print "var1 = %s, var2 = %s" % (var1, var2)
0
0
0
a1352f79c8742aa930e6ed10fa6c5d2c55aed433
2,462
py
Python
quarantine/model/qplayer.py
kwoolter/Quarantine
7b824a3d6eebbded611c48e44dcb3c2e4007033e
[ "BSD-2-Clause" ]
null
null
null
quarantine/model/qplayer.py
kwoolter/Quarantine
7b824a3d6eebbded611c48e44dcb3c2e4007033e
[ "BSD-2-Clause" ]
null
null
null
quarantine/model/qplayer.py
kwoolter/Quarantine
7b824a3d6eebbded611c48e44dcb3c2e4007033e
[ "BSD-2-Clause" ]
null
null
null
import random
28.298851
88
0.606418
import random class QPlayer: # The states that a player can be in STATE_AWAKE = "awake" STATE_ASLEEP = "asleep" STATE_DEAD = "dead" STATES = (STATE_AWAKE, STATE_ASLEEP) # The properties that a player has PROPERTY_HUNGER = "hunger" PROPERTY_TIREDNESS = "tiredness" PROPERTY_ENERGY = "energy" PROPERTY_HEALTH = "health" # For each state... # How many ticks does it take to change a property... # Any by how much does it change. STATE_TICKS_PER_CHANGE = { STATE_AWAKE: { PROPERTY_HUNGER: (5, 1), PROPERTY_ENERGY: (5, -1), PROPERTY_TIREDNESS: (5, 1)}, STATE_ASLEEP: { PROPERTY_HUNGER: (5, 1), PROPERTY_ENERGY: (5, 1), PROPERTY_TIREDNESS: (5, -1)}, STATE_DEAD: { PROPERTY_HUNGER: (1, 0), PROPERTY_ENERGY: (1, 0), PROPERTY_TIREDNESS: (1, 0)}, } PROPERTIES = (PROPERTY_HEALTH, PROPERTY_ENERGY, PROPERTY_ENERGY, PROPERTY_TIREDNESS) def __init__(self, name: str): self.name = name self.state = QPlayer.STATE_AWAKE self.ticks = 0 self.properties = {} def __str__(self): text = f"My name is {self.name}: " for property_name in QPlayer.PROPERTIES: text += f'{property_name}={self.properties.get(property_name)},' return text def add_properties(self, new_properties: dict): self.properties.update(new_properties) def get_property(self, property_name: str): return self.properties.get(property_name, 0) def set_property(self, property_name: str, property_value, increment: bool = False): if increment is True: property_value += self.get_property(property_name) property_value = max(0, min(100, property_value)) self.properties[property_name] = property_value def roll(self): new_properties = {} for property in QPlayer.PROPERTIES: new_properties[property] = random.randint(50, 100) self.add_properties(new_properties) def tick(self, increment: int = 1): state_ticks = QPlayer.STATE_TICKS_PER_CHANGE.get(self.state) for i in range(increment): self.ticks += 1 for k, v in state_ticks.items(): ticks, delta = v if self.ticks % ticks == 0: self.set_property(k, delta, increment=True)
1,245
1,180
23
2a935db27b0f7abbafe27f11270e5ac3ad8002f9
3,293
py
Python
encyclopedia/views.py
jeff-eng/CS50W2020__Project1-Wiki
6eea612163aaf30bd5014da37afac10ce0f199df
[ "MIT" ]
null
null
null
encyclopedia/views.py
jeff-eng/CS50W2020__Project1-Wiki
6eea612163aaf30bd5014da37afac10ce0f199df
[ "MIT" ]
null
null
null
encyclopedia/views.py
jeff-eng/CS50W2020__Project1-Wiki
6eea612163aaf30bd5014da37afac10ce0f199df
[ "MIT" ]
null
null
null
import markdown2, re, random from django.shortcuts import render from django.urls import reverse from django.http import HttpResponseRedirect from . import util
33.948454
102
0.595809
import markdown2, re, random from django.shortcuts import render from django.urls import reverse from django.http import HttpResponseRedirect from . import util def index(request): return render(request, 'encyclopedia/index.html', { 'entries': util.list_entries() }) def entry(request, title): entry = util.get_entry(title) if entry: # Convert the markdown to HTML html = markdown2.markdown(entry) return render(request, 'encyclopedia/entry.html', { 'html': html, 'title': title }) else: # Render an error page return render(request, 'encyclopedia/error.html', { 'error_code': 404, 'error_message': 'Page Not Found' }) def search(request): if request.method == 'POST': # Obtain user input from search box query = request.POST['query'] # Direct user to page if there is exact match, otherwise display list of matches if util.get_entry(query): return HttpResponseRedirect(reverse('encyclopedia:entry', kwargs={'title': query})) else: entries = util.list_entries() matching_entries = list() for entry in entries: if re.search(query, entry, re.IGNORECASE): matching_entries.append(entry) return render(request, 'encyclopedia/search_results.html', { 'matches': matching_entries, 'query': query }) def new(request): return render(request, 'encyclopedia/new_page.html') def save(request): if request.method == 'POST': title = request.POST['title'].strip() content = request.POST['wiki-content'] # Check if entry already exists, otherwise save to disk if util.get_entry(title): return render(request, 'encyclopedia/error.html', { 'error_code': 403, 'error_message': 'Forbidden - Page Already Exists' }) else: util.save_entry(title, content) return HttpResponseRedirect(reverse('encyclopedia:entry', kwargs={'title': title})) else: return render(request, 'encyclopedia/error.html', { 'error_code': 404, 'error_message': 'Page Not Found' }) def random_page(request): entries = util.list_entries() if entries: random_selection = random.choice(entries) return HttpResponseRedirect(reverse('encyclopedia:entry', kwargs={'title': random_selection})) else: return render(request, 'encyclopedia/error.html', { 'error_code': 404, 'error_message': 'It\'s not you, it\'s us.' }) def edit_page(request, title): if request.method == 'GET': return render(request, 'encyclopedia/edit.html', { 'title': title, 'content': util.get_entry(title) }) elif request.method == 'POST': util.save_entry(title, request.POST['wiki-content']) return HttpResponseRedirect(reverse('encyclopedia:entry', kwargs={'title': title})) else: return render(request, 'encyclopedia/error.html', { 'error_code': 404, 'error_message': 'Page Not Found' })
2,970
0
161
62abacff8a003309f019d0e8ef1a6850d38f3dde
1,707
py
Python
gunpowder/tensorflow/local_server.py
trivoldus28/gunpowder
97e9e64709fb616e2c47567b22d5f11a9234fe48
[ "MIT" ]
43
2017-05-03T22:27:11.000Z
2022-02-11T19:07:28.000Z
gunpowder/tensorflow/local_server.py
trivoldus28/gunpowder
97e9e64709fb616e2c47567b22d5f11a9234fe48
[ "MIT" ]
102
2017-06-09T10:11:06.000Z
2022-03-29T13:56:37.000Z
gunpowder/tensorflow/local_server.py
trivoldus28/gunpowder
97e9e64709fb616e2c47567b22d5f11a9234fe48
[ "MIT" ]
43
2017-04-25T20:25:17.000Z
2022-02-11T19:07:34.000Z
import logging import multiprocessing import ctypes from gunpowder.ext import tensorflow as tf from gunpowder.freezable import Freezable logger = logging.getLogger(__name__) class LocalServer(Freezable): '''Wrapper around ``tf.train.Server`` to create a local server on-demand. This class is necessary because tensorflow's GPU support should not be initialized before forking processes (the CUDA driver needs to be initialized in each process separately, not in the main process and then forked). Creating a ``tf.train.Server`` initializes GPU support, however. With this wrapper, server creating can be delayed until a GPU process creates a ``tf.Session``:: session = tf.Session(target=LocalServer.get_target()) ''' __target = multiprocessing.Array(ctypes.c_char, b' '*256) __server = None @staticmethod def get_target(): '''Get the target string of this tensorflow server to connect a ``tf.Session()``. This will start the server, if it is not running already. ''' with LocalServer.__target.get_lock(): target = LocalServer.__target.value if target == b' '*256: logger.info("Creating local tensorflow server") LocalServer.__server = tf.train.Server.create_local_server() target = LocalServer.__server.target if not isinstance(target, bytes): target = target.encode('ascii') logger.info("Server running at %s", target) else: logger.info("Server already running at %s", target) LocalServer.__target.value = target return target
34.836735
77
0.656122
import logging import multiprocessing import ctypes from gunpowder.ext import tensorflow as tf from gunpowder.freezable import Freezable logger = logging.getLogger(__name__) class LocalServer(Freezable): '''Wrapper around ``tf.train.Server`` to create a local server on-demand. This class is necessary because tensorflow's GPU support should not be initialized before forking processes (the CUDA driver needs to be initialized in each process separately, not in the main process and then forked). Creating a ``tf.train.Server`` initializes GPU support, however. With this wrapper, server creating can be delayed until a GPU process creates a ``tf.Session``:: session = tf.Session(target=LocalServer.get_target()) ''' __target = multiprocessing.Array(ctypes.c_char, b' '*256) __server = None @staticmethod def get_target(): '''Get the target string of this tensorflow server to connect a ``tf.Session()``. This will start the server, if it is not running already. ''' with LocalServer.__target.get_lock(): target = LocalServer.__target.value if target == b' '*256: logger.info("Creating local tensorflow server") LocalServer.__server = tf.train.Server.create_local_server() target = LocalServer.__server.target if not isinstance(target, bytes): target = target.encode('ascii') logger.info("Server running at %s", target) else: logger.info("Server already running at %s", target) LocalServer.__target.value = target return target
0
0
0
838b2b92c45e629173b0d35fc53eade12724bb23
6,945
py
Python
src/python/pants/backend/go/tailor.py
williamscs/pants
4d1f2ca1a58e98c27a26adcb0e9b844a27b75a63
[ "Apache-2.0" ]
null
null
null
src/python/pants/backend/go/tailor.py
williamscs/pants
4d1f2ca1a58e98c27a26adcb0e9b844a27b75a63
[ "Apache-2.0" ]
null
null
null
src/python/pants/backend/go/tailor.py
williamscs/pants
4d1f2ca1a58e98c27a26adcb0e9b844a27b75a63
[ "Apache-2.0" ]
null
null
null
# Copyright 2021 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). import itertools import os from dataclasses import dataclass from typing import Dict, List from pants.backend.go.module import ResolvedGoModule, ResolveGoModuleRequest from pants.backend.go.pkg import ( ResolvedGoPackage, ResolveExternalGoModuleToPackagesRequest, ResolveExternalGoModuleToPackagesResult, ) from pants.backend.go.target_types import ( GoExternalPackageTarget, GoModule, GoModuleSources, GoPackage, ) from pants.base.specs import AddressSpecs, MaybeEmptyDescendantAddresses, MaybeEmptySiblingAddresses from pants.build_graph.address import Address from pants.core.goals.tailor import ( AllOwnedSources, PutativeTarget, PutativeTargets, PutativeTargetsRequest, group_by_dir, ) from pants.engine.fs import PathGlobs, Paths from pants.engine.internals.selectors import Get, MultiGet from pants.engine.rules import collect_rules, rule from pants.engine.target import UnexpandedTargets from pants.engine.unions import UnionRule from pants.util.logging import LogLevel @dataclass(frozen=True) @rule(level=LogLevel.DEBUG, desc="Determine candidate Go `go_package` targets to create") @dataclass(frozen=True) @rule(level=LogLevel.DEBUG, desc="Determine candidate Go `go_module` targets to create") @dataclass(frozen=True) @rule(level=LogLevel.DEBUG, desc="Determine candidate Go `go_external_module` targets to create")
38.370166
109
0.694168
# Copyright 2021 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). import itertools import os from dataclasses import dataclass from typing import Dict, List from pants.backend.go.module import ResolvedGoModule, ResolveGoModuleRequest from pants.backend.go.pkg import ( ResolvedGoPackage, ResolveExternalGoModuleToPackagesRequest, ResolveExternalGoModuleToPackagesResult, ) from pants.backend.go.target_types import ( GoExternalPackageTarget, GoModule, GoModuleSources, GoPackage, ) from pants.base.specs import AddressSpecs, MaybeEmptyDescendantAddresses, MaybeEmptySiblingAddresses from pants.build_graph.address import Address from pants.core.goals.tailor import ( AllOwnedSources, PutativeTarget, PutativeTargets, PutativeTargetsRequest, group_by_dir, ) from pants.engine.fs import PathGlobs, Paths from pants.engine.internals.selectors import Get, MultiGet from pants.engine.rules import collect_rules, rule from pants.engine.target import UnexpandedTargets from pants.engine.unions import UnionRule from pants.util.logging import LogLevel @dataclass(frozen=True) class PutativeGoPackageTargetsRequest(PutativeTargetsRequest): pass @rule(level=LogLevel.DEBUG, desc="Determine candidate Go `go_package` targets to create") async def find_putative_go_package_targets( request: PutativeGoPackageTargetsRequest, all_owned_sources: AllOwnedSources ) -> PutativeTargets: all_go_files = await Get(Paths, PathGlobs, request.search_paths.path_globs("*.go")) unowned_go_files = set(all_go_files.files) - set(all_owned_sources) putative_targets = [] for dirname, filenames in group_by_dir(unowned_go_files).items(): putative_targets.append( PutativeTarget.for_target_type( GoPackage, dirname, os.path.basename(dirname), sorted(filenames), ) ) return PutativeTargets(putative_targets) @dataclass(frozen=True) class PutativeGoModuleTargetsRequest(PutativeTargetsRequest): pass @rule(level=LogLevel.DEBUG, desc="Determine candidate Go `go_module` targets to create") async def find_putative_go_module_targets( request: PutativeGoModuleTargetsRequest, all_owned_sources: AllOwnedSources ) -> PutativeTargets: all_go_mod_files = await Get(Paths, PathGlobs, request.search_paths.path_globs("go.mod")) unowned_go_mod_files = set(all_go_mod_files.files) - set(all_owned_sources) putative_targets = [] for dirname, filenames in group_by_dir(unowned_go_mod_files).items(): putative_targets.append( PutativeTarget.for_target_type( GoModule, dirname, os.path.basename(dirname), sorted(filenames), ) ) return PutativeTargets(putative_targets) def compute_go_external_module_target_name(name: str, version: str) -> str: return f"{name.replace('/', '_')}_{version}" @dataclass(frozen=True) class PutativeGoExternalModuleTargetsRequest(PutativeTargetsRequest): pass @rule(level=LogLevel.DEBUG, desc="Determine candidate Go `go_external_module` targets to create") async def find_putative_go_external_module_targets( request: PutativeGoExternalModuleTargetsRequest, _all_owned_sources: AllOwnedSources ) -> PutativeTargets: # Unlike ordinary tailor invocations, this rule looks at existing `go_module` targets and not at actual # source files because it infers `go_external_module` targets based on go.mod contents. (This may require # invoking `tailor` first to create `go_module` targets and then again to create `go_external_module` # targets.) # # TODO: This might better work as a BUILD macro if https://github.com/pantsbuild/pants/issues/7022 is # resolved and macros are able to invoke the engine or processes. addresses = itertools.chain.from_iterable( [ [MaybeEmptySiblingAddresses(search_path), MaybeEmptyDescendantAddresses(search_path)] for search_path in request.search_paths.dirs ] ) candidate_targets = await Get(UnexpandedTargets, AddressSpecs(addresses)) go_module_targets = [tgt for tgt in candidate_targets if tgt.has_field(GoModuleSources)] putative_targets = [] resolved_go_modules = await MultiGet( Get(ResolvedGoModule, ResolveGoModuleRequest(go_module_target.address)) for go_module_target in go_module_targets ) # TODO: Figure out a MultiGet here. (Would be nice if MultiGet could operate on dictionaries.) resolved_ext_mod_packages: Dict[Address, List[ResolvedGoPackage]] = {} for resolved_go_module in resolved_go_modules: resolved_ext_mod_packages[resolved_go_module.target.address] = [] for module_descriptor in resolved_go_module.modules: result = await Get( ResolveExternalGoModuleToPackagesResult, ResolveExternalGoModuleToPackagesRequest( path=module_descriptor.path, version=module_descriptor.version, go_sum_digest=resolved_go_module.digest, ), ) resolved_ext_mod_packages[resolved_go_module.target.address] += result.packages for address, packages in resolved_ext_mod_packages.items(): for package in packages: assert package.module_path assert package.module_version assert package.import_path.startswith(package.module_path) subpath = package.import_path[len(package.module_path) :].replace("/", "_") ext_mod_target_name = compute_go_external_module_target_name( package.module_path, package.module_version ) target_name = f"{ext_mod_target_name}-{subpath}" putative_targets.append( PutativeTarget.for_target_type( GoExternalPackageTarget, address.spec_path, target_name, [], kwargs={ "path": package.module_path, "version": package.module_version, "import_path": package.import_path, }, build_file_name="BUILD.godeps", comments=( "# Auto-generated by `./pants tailor`. Re-run `./pants tailor` if " "go.mod changes.", ), ) ) return PutativeTargets(putative_targets) def rules(): return [ *collect_rules(), UnionRule(PutativeTargetsRequest, PutativeGoPackageTargetsRequest), UnionRule(PutativeTargetsRequest, PutativeGoModuleTargetsRequest), UnionRule(PutativeTargetsRequest, PutativeGoExternalModuleTargetsRequest), ]
5,090
156
178
5e55f73c2a86f2dd55e0bb3efcee4238d5951700
44
py
Python
Cursos/dados.py
FranciscoAlveJr/Bot_Telegram
9960485a4a25648719ef6fafcb3b02c82db79253
[ "MIT" ]
null
null
null
Cursos/dados.py
FranciscoAlveJr/Bot_Telegram
9960485a4a25648719ef6fafcb3b02c82db79253
[ "MIT" ]
null
null
null
Cursos/dados.py
FranciscoAlveJr/Bot_Telegram
9960485a4a25648719ef6fafcb3b02c82db79253
[ "MIT" ]
null
null
null
import os import cursos print(os.getcwd())
8.8
18
0.75
import os import cursos print(os.getcwd())
0
0
0
b28910cf47ea8e3a98d8eb43d5925251f87a8b1c
692
py
Python
onlinecourse/migrations/0007_auto_20210420_1459.py
enricosiagri/final-cloud-app-with-database
d4dc4646c1e238bcba71fa240cf808b360e959c0
[ "Apache-2.0" ]
null
null
null
onlinecourse/migrations/0007_auto_20210420_1459.py
enricosiagri/final-cloud-app-with-database
d4dc4646c1e238bcba71fa240cf808b360e959c0
[ "Apache-2.0" ]
null
null
null
onlinecourse/migrations/0007_auto_20210420_1459.py
enricosiagri/final-cloud-app-with-database
d4dc4646c1e238bcba71fa240cf808b360e959c0
[ "Apache-2.0" ]
null
null
null
# Generated by Django 3.1.3 on 2021-04-20 14:59 from django.db import migrations, models
23.862069
52
0.562139
# Generated by Django 3.1.3 on 2021-04-20 14:59 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('onlinecourse', '0006_auto_20210416_1459'), ] operations = [ migrations.RenameField( model_name='submission', old_name='chocies', new_name='choices', ), migrations.AlterField( model_name='question', name='content', field=models.TextField(max_length=500), ), migrations.AlterField( model_name='question', name='grade', field=models.IntegerField(default=1), ), ]
0
578
23
a65f39ef854ba9a4bb94c8cf08a568806963b135
7,416
py
Python
finitediff/unit_tests.py
jolyonb/finitediff
fb6d05490fcf8a7a7603e68aec165b9fb931ba3a
[ "MIT" ]
null
null
null
finitediff/unit_tests.py
jolyonb/finitediff
fb6d05490fcf8a7a7603e68aec165b9fb931ba3a
[ "MIT" ]
null
null
null
finitediff/unit_tests.py
jolyonb/finitediff
fb6d05490fcf8a7a7603e68aec165b9fb931ba3a
[ "MIT" ]
null
null
null
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Unit tests for finite_diff library """ import unittest import random from math import pi import numpy as np import finitediff class TestFiniteDiff(unittest.TestCase): """Unit test class for the finitediff library""" order = 4 # Order of the derivatives def setUp(self): """Initialize a differentiator on a random grid""" # Randomly pick some x values numvals = 40 self.x = np.sort(np.array([random.uniform(0.0, 2*pi) for i in range(numvals)])) # Create the differentiator on these x values self.diff = finitediff.Derivative(TestFiniteDiff.order) self.diff.set_x(self.x) def test_order(self): """Make sure we can get the order out correctly""" self.assertEqual(self.diff.get_order(), TestFiniteDiff.order) def test_cos(self): """Test a cosine function with no boundary conditions""" ycos = np.cos(self.x) dycos = self.diff.dydx(ycos) truevals = -np.sin(self.x) self.compare_arrays(dycos, truevals) def test_sin(self): """Test a sine function with no boundary conditions""" ysin = np.sin(self.x) dysin = self.diff.dydx(ysin) truevals = np.cos(self.x) self.compare_arrays(dysin, truevals) def test_matrix(self): """Test a matrix function with no boundary conditions""" ysin = np.sin(self.x) ycos = np.cos(self.x) # pylint: disable=no-member test = np.array([ysin, ycos]).transpose() truevals = np.array([ycos, -ysin]).transpose() # pylint: enable=no-member dtest = self.diff.dydx(test) self.assertTrue(np.all(np.abs(dtest - truevals) < 0.01)) def test_sin_odd(self): """Test a sine function with odd boundary conditions""" self.diff.apply_boundary(-1) ysin = np.sin(self.x) dysin = self.diff.dydx(ysin) truevals = np.cos(self.x) self.compare_arrays(dysin, truevals) def test_cos_even(self): """Test a cosine function with even boundary conditions""" self.diff.apply_boundary(1) ycos = np.cos(self.x) dycos = self.diff.dydx(ycos) truevals = -np.sin(self.x) self.compare_arrays(dycos, truevals) def compare_arrays(self, array1, array2): """Helper function to test equality of two arrays""" for i, _ in enumerate(array1): self.assertAlmostEqual(array1[i], array2[i], delta=0.01) def test_conversion1(self): """Test converting boundary conditions""" # pylint: disable=protected-access oldstencil = self.diff._stencil.copy() self.diff.set_x(self.x, 1) newstencil = self.diff._stencil.copy() self.diff.apply_boundary(0) # Test converting to no boundary condition self.assertTrue(np.all(self.diff._stencil == oldstencil)) # Test converting to even boundary condition newdiff = finitediff.Derivative(TestFiniteDiff.order) newdiff.set_x(self.x, 1) self.assertTrue(np.all(newdiff._stencil == newstencil)) # Test converting to odd boundary condition self.diff.set_x(self.x, -1) newstencil = self.diff._stencil.copy() newdiff = finitediff.Derivative(TestFiniteDiff.order) newdiff.set_x(self.x, -1) self.assertTrue(np.all(newdiff._stencil == newstencil)) def test_bad(self): """Make sure an error is raised appropriately""" # pylint: disable=protected-access # Insufficient gridpoints for order with self.assertRaises(finitediff.DerivativeError): self.diff.set_x(np.array([0.0, 0.5, 1.0])) # Something has gone very wrong - stencil and gridpoints are # out of alignment with self.assertRaises(finitediff.DerivativeError): test = finitediff.Derivative(TestFiniteDiff.order) test.set_x(np.array([1.0, 2, 3, 4, 5, 6])) test._xvals = np.array([1.0, 2.0, 3.0, 4.0]) test.apply_boundary() # Various tests for no stencil with self.assertRaises(finitediff.NoStencil): test = finitediff.Derivative(TestFiniteDiff.order) test.dydx(np.array([1, 2, 3])) with self.assertRaises(finitediff.NoStencil): test = finitediff.Derivative(TestFiniteDiff.order) test.leftdydx(np.array([1, 2, 3])) with self.assertRaises(finitediff.NoStencil): test = finitediff.Derivative(TestFiniteDiff.order) test.rightdydx(np.array([1, 2, 3])) with self.assertRaises(finitediff.NoStencil): test = finitediff.Derivative(TestFiniteDiff.order) test.position_dydx(np.array([1, 2, 3]), 1) with self.assertRaises(finitediff.NoStencil): test = finitediff.Derivative(TestFiniteDiff.order) test.get_xvals() with self.assertRaises(finitediff.NoStencil): test = finitediff.Derivative(TestFiniteDiff.order) test.apply_boundary() # xvals and yvals are out of alignment with self.assertRaises(finitediff.DerivativeError): test = finitediff.Derivative(TestFiniteDiff.order) test.set_x(np.array([1.0, 2, 3, 4, 5, 6])) test.dydx(np.array([1, 2, 3])) with self.assertRaises(finitediff.DerivativeError): test = finitediff.Derivative(TestFiniteDiff.order) test.set_x(np.array([1.0, 2, 3, 4, 5, 6])) test.leftdydx(np.array([1, 2, 3])) with self.assertRaises(finitediff.DerivativeError): test = finitediff.Derivative(TestFiniteDiff.order) test.set_x(np.array([1.0, 2, 3, 4, 5, 6])) test.rightdydx(np.array([1, 2, 3])) with self.assertRaises(finitediff.DerivativeError): test = finitediff.Derivative(TestFiniteDiff.order) test.set_x(np.array([1.0, 2, 3, 4, 5, 6])) test.position_dydx(np.array([1, 2, 3]), 3) # Position out of bounds with self.assertRaises(IndexError): test = finitediff.Derivative(TestFiniteDiff.order) test.set_x(np.array([1.0, 2, 3, 4, 5, 6])) test.position_dydx(np.array([1, 2, 3, 4, 5, 6]), 7) def test_copy(self): """Make sure things copy correctly""" # pylint: disable=protected-access # Make sure we get references xref = self.diff.get_xvals(False) self.x[0] += 1 self.assertTrue(xref[0] == self.x[0]) # Make sure we get copies! self.diff.set_x(self.x, copy=True) x = self.diff.get_xvals(True) xref = self.diff.get_xvals(False) x[0] += 1 self.assertFalse(xref[0] == x[0]) # get_xvals returned a copy xref[0] += 1 self.assertFalse(xref[0] == self.x[0]) # set_x stored a copy def test_positions(self): """Test that derivatives at all positions are correct""" ysin = np.sin(self.x) dysin = self.diff.dydx(ysin) for i in range(len(ysin)): self.assertAlmostEqual(dysin[i], self.diff.position_dydx(ysin, i), delta=1e-12) self.assertAlmostEqual(dysin[0], self.diff.leftdydx(ysin), delta=1e-12) self.assertAlmostEqual(dysin[-1], self.diff.rightdydx(ysin), delta=1e-12) if __name__ == '__main__': unittest.main()
37.836735
91
0.618797
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Unit tests for finite_diff library """ import unittest import random from math import pi import numpy as np import finitediff class TestFiniteDiff(unittest.TestCase): """Unit test class for the finitediff library""" order = 4 # Order of the derivatives def setUp(self): """Initialize a differentiator on a random grid""" # Randomly pick some x values numvals = 40 self.x = np.sort(np.array([random.uniform(0.0, 2*pi) for i in range(numvals)])) # Create the differentiator on these x values self.diff = finitediff.Derivative(TestFiniteDiff.order) self.diff.set_x(self.x) def test_order(self): """Make sure we can get the order out correctly""" self.assertEqual(self.diff.get_order(), TestFiniteDiff.order) def test_cos(self): """Test a cosine function with no boundary conditions""" ycos = np.cos(self.x) dycos = self.diff.dydx(ycos) truevals = -np.sin(self.x) self.compare_arrays(dycos, truevals) def test_sin(self): """Test a sine function with no boundary conditions""" ysin = np.sin(self.x) dysin = self.diff.dydx(ysin) truevals = np.cos(self.x) self.compare_arrays(dysin, truevals) def test_matrix(self): """Test a matrix function with no boundary conditions""" ysin = np.sin(self.x) ycos = np.cos(self.x) # pylint: disable=no-member test = np.array([ysin, ycos]).transpose() truevals = np.array([ycos, -ysin]).transpose() # pylint: enable=no-member dtest = self.diff.dydx(test) self.assertTrue(np.all(np.abs(dtest - truevals) < 0.01)) def test_sin_odd(self): """Test a sine function with odd boundary conditions""" self.diff.apply_boundary(-1) ysin = np.sin(self.x) dysin = self.diff.dydx(ysin) truevals = np.cos(self.x) self.compare_arrays(dysin, truevals) def test_cos_even(self): """Test a cosine function with even boundary conditions""" self.diff.apply_boundary(1) ycos = np.cos(self.x) dycos = self.diff.dydx(ycos) truevals = -np.sin(self.x) self.compare_arrays(dycos, truevals) def compare_arrays(self, array1, array2): """Helper function to test equality of two arrays""" for i, _ in enumerate(array1): self.assertAlmostEqual(array1[i], array2[i], delta=0.01) def test_conversion1(self): """Test converting boundary conditions""" # pylint: disable=protected-access oldstencil = self.diff._stencil.copy() self.diff.set_x(self.x, 1) newstencil = self.diff._stencil.copy() self.diff.apply_boundary(0) # Test converting to no boundary condition self.assertTrue(np.all(self.diff._stencil == oldstencil)) # Test converting to even boundary condition newdiff = finitediff.Derivative(TestFiniteDiff.order) newdiff.set_x(self.x, 1) self.assertTrue(np.all(newdiff._stencil == newstencil)) # Test converting to odd boundary condition self.diff.set_x(self.x, -1) newstencil = self.diff._stencil.copy() newdiff = finitediff.Derivative(TestFiniteDiff.order) newdiff.set_x(self.x, -1) self.assertTrue(np.all(newdiff._stencil == newstencil)) def test_bad(self): """Make sure an error is raised appropriately""" # pylint: disable=protected-access # Insufficient gridpoints for order with self.assertRaises(finitediff.DerivativeError): self.diff.set_x(np.array([0.0, 0.5, 1.0])) # Something has gone very wrong - stencil and gridpoints are # out of alignment with self.assertRaises(finitediff.DerivativeError): test = finitediff.Derivative(TestFiniteDiff.order) test.set_x(np.array([1.0, 2, 3, 4, 5, 6])) test._xvals = np.array([1.0, 2.0, 3.0, 4.0]) test.apply_boundary() # Various tests for no stencil with self.assertRaises(finitediff.NoStencil): test = finitediff.Derivative(TestFiniteDiff.order) test.dydx(np.array([1, 2, 3])) with self.assertRaises(finitediff.NoStencil): test = finitediff.Derivative(TestFiniteDiff.order) test.leftdydx(np.array([1, 2, 3])) with self.assertRaises(finitediff.NoStencil): test = finitediff.Derivative(TestFiniteDiff.order) test.rightdydx(np.array([1, 2, 3])) with self.assertRaises(finitediff.NoStencil): test = finitediff.Derivative(TestFiniteDiff.order) test.position_dydx(np.array([1, 2, 3]), 1) with self.assertRaises(finitediff.NoStencil): test = finitediff.Derivative(TestFiniteDiff.order) test.get_xvals() with self.assertRaises(finitediff.NoStencil): test = finitediff.Derivative(TestFiniteDiff.order) test.apply_boundary() # xvals and yvals are out of alignment with self.assertRaises(finitediff.DerivativeError): test = finitediff.Derivative(TestFiniteDiff.order) test.set_x(np.array([1.0, 2, 3, 4, 5, 6])) test.dydx(np.array([1, 2, 3])) with self.assertRaises(finitediff.DerivativeError): test = finitediff.Derivative(TestFiniteDiff.order) test.set_x(np.array([1.0, 2, 3, 4, 5, 6])) test.leftdydx(np.array([1, 2, 3])) with self.assertRaises(finitediff.DerivativeError): test = finitediff.Derivative(TestFiniteDiff.order) test.set_x(np.array([1.0, 2, 3, 4, 5, 6])) test.rightdydx(np.array([1, 2, 3])) with self.assertRaises(finitediff.DerivativeError): test = finitediff.Derivative(TestFiniteDiff.order) test.set_x(np.array([1.0, 2, 3, 4, 5, 6])) test.position_dydx(np.array([1, 2, 3]), 3) # Position out of bounds with self.assertRaises(IndexError): test = finitediff.Derivative(TestFiniteDiff.order) test.set_x(np.array([1.0, 2, 3, 4, 5, 6])) test.position_dydx(np.array([1, 2, 3, 4, 5, 6]), 7) def test_copy(self): """Make sure things copy correctly""" # pylint: disable=protected-access # Make sure we get references xref = self.diff.get_xvals(False) self.x[0] += 1 self.assertTrue(xref[0] == self.x[0]) # Make sure we get copies! self.diff.set_x(self.x, copy=True) x = self.diff.get_xvals(True) xref = self.diff.get_xvals(False) x[0] += 1 self.assertFalse(xref[0] == x[0]) # get_xvals returned a copy xref[0] += 1 self.assertFalse(xref[0] == self.x[0]) # set_x stored a copy def test_positions(self): """Test that derivatives at all positions are correct""" ysin = np.sin(self.x) dysin = self.diff.dydx(ysin) for i in range(len(ysin)): self.assertAlmostEqual(dysin[i], self.diff.position_dydx(ysin, i), delta=1e-12) self.assertAlmostEqual(dysin[0], self.diff.leftdydx(ysin), delta=1e-12) self.assertAlmostEqual(dysin[-1], self.diff.rightdydx(ysin), delta=1e-12) if __name__ == '__main__': unittest.main()
0
0
0
cd31afc24dd0c8fd36f1b2e599cb704db2845b1c
199
py
Python
problem0143.py
kmarcini/Project-Euler-Python
d644e8e1ec4fac70a9ab407ad5e1f0a75547c8d3
[ "BSD-3-Clause" ]
null
null
null
problem0143.py
kmarcini/Project-Euler-Python
d644e8e1ec4fac70a9ab407ad5e1f0a75547c8d3
[ "BSD-3-Clause" ]
null
null
null
problem0143.py
kmarcini/Project-Euler-Python
d644e8e1ec4fac70a9ab407ad5e1f0a75547c8d3
[ "BSD-3-Clause" ]
null
null
null
########################### # # #143 Investigating the Torricelli point of a triangle - Project Euler # https://projecteuler.net/problem=143 # # Code by Kevin Marciniak # ###########################
22.111111
71
0.537688
########################### # # #143 Investigating the Torricelli point of a triangle - Project Euler # https://projecteuler.net/problem=143 # # Code by Kevin Marciniak # ###########################
0
0
0
d0299594988dabb3885370f57f0c63136d56db5c
94
py
Python
connected_accounts/__init__.py
surajsonee/socialapp
e741d2467e2bbde5b7bdbe90702e4123ce31bddb
[ "BSD-3-Clause" ]
null
null
null
connected_accounts/__init__.py
surajsonee/socialapp
e741d2467e2bbde5b7bdbe90702e4123ce31bddb
[ "BSD-3-Clause" ]
null
null
null
connected_accounts/__init__.py
surajsonee/socialapp
e741d2467e2bbde5b7bdbe90702e4123ce31bddb
[ "BSD-3-Clause" ]
null
null
null
__version__ = '0.1.4' default_app_config = 'connected_accounts.apps.ConnectedAccountsConfig'
23.5
70
0.819149
__version__ = '0.1.4' default_app_config = 'connected_accounts.apps.ConnectedAccountsConfig'
0
0
0
648bed7c4d6a2f610991e053956f05ea27c2023b
1,600
py
Python
nehushtan/socket/NehushtanUDPSocketServer.py
sinri/nehushtan
6fda496e16a8d443a86c617173d35f31c392beb6
[ "MIT" ]
null
null
null
nehushtan/socket/NehushtanUDPSocketServer.py
sinri/nehushtan
6fda496e16a8d443a86c617173d35f31c392beb6
[ "MIT" ]
1
2020-11-20T03:10:23.000Z
2020-11-20T09:30:34.000Z
nehushtan/socket/NehushtanUDPSocketServer.py
sinri/nehushtan
6fda496e16a8d443a86c617173d35f31c392beb6
[ "MIT" ]
1
2021-10-13T10:16:58.000Z
2021-10-13T10:16:58.000Z
import socket from abc import abstractmethod from threading import Thread from typing import Optional from nehushtan.socket.SocketHandleThreadManager import SocketHandlerThreadManager class NehushtanUDPSocketServer: """ Since 0.4.16 """ def should_terminate(self) -> bool: """ If return True, stop the listener. Override it to implement it with your own logic. """ return False @abstractmethod
30.769231
99
0.6775
import socket from abc import abstractmethod from threading import Thread from typing import Optional from nehushtan.socket.SocketHandleThreadManager import SocketHandlerThreadManager class NehushtanUDPSocketServer: """ Since 0.4.16 """ def __init__(self, host: str, port: int, buffer_size=0, tm: SocketHandlerThreadManager = None): self.__listen_port = port self.__listen_host = host self.__socket_instance: Optional[socket.socket] = None if buffer_size <= 0: buffer_size = 1024 self.__buffer_size = buffer_size if not tm: tm = SocketHandlerThreadManager() self.__thread_manager = tm def get_thread_manager(self): return self.__thread_manager def get_socket_instance(self): return self.__socket_instance def listen(self): self.__socket_instance = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.__socket_instance.bind((self.__listen_host, self.__listen_port)) while not self.should_terminate(): data, address = self.__socket_instance.recvfrom(self.__buffer_size) thread = Thread(target=self.handle_incoming_data, name=address, args=(data, address)) self.__thread_manager.register_thread(thread) thread.start() def should_terminate(self) -> bool: """ If return True, stop the listener. Override it to implement it with your own logic. """ return False @abstractmethod def handle_incoming_data(self, data: bytes, address): pass
1,007
0
134
80397360440b25ef17a5effd5d326a5b6eb37ed9
4,603
py
Python
optable/OptModel.py
dgroner/optable
4ee2947901c179925cdb6a6ceb172c54bf9b1844
[ "MIT" ]
null
null
null
optable/OptModel.py
dgroner/optable
4ee2947901c179925cdb6a6ceb172c54bf9b1844
[ "MIT" ]
null
null
null
optable/OptModel.py
dgroner/optable
4ee2947901c179925cdb6a6ceb172c54bf9b1844
[ "MIT" ]
null
null
null
# Specify and solve an LP using a Pandas DataFrame import pandas as pd if __name__ != "__main__": from . import LpModel from . import Result else: from LpModel import LpModel from Result import Result if __name__ == "__main__": df = OptModel.read_csv("lpmodel.txt") #print(df.fillna("")) lpmodel = OptModel(df) print(lpmodel) result = lpmodel.solve() #print(result.status) #print("x:\n" , result.x, sep='') print(result) print("slack:\n" , result.slack, sep='') df2 = OptModel.read_str( """ name x1 x2 sense rhs # objective: obj 3 5 max # subject to: #x1lower 1 0 = 2 plant1 1 0 <= 4 plant2 0 2 <= 12 plant3 3 2 <= 18 """) lpmodel2 = OptModel(df2) print(lpmodel) result2 = lpmodel2.solve() print(result2)
27.562874
93
0.575277
# Specify and solve an LP using a Pandas DataFrame import pandas as pd if __name__ != "__main__": from . import LpModel from . import Result else: from LpModel import LpModel from Result import Result class OptModel: def __init__(self, df): #print("in OptModel()") self.df = df self.ismax = False def __str__(self): return self.df.fillna("").to_string() __repl__ = __str__ # convenience method to use pandas read_csv w/ good defaults @staticmethod def read_csv(filename): df = pd.read_csv(filename, sep=' ', skipinitialspace=True, index_col='name', comment='#') return df # convenience method to use pandas read_csv w/ string & good defaults @staticmethod def read_str(s): from io import StringIO df = pd.read_csv(StringIO(s), sep=' ', skipinitialspace=True, index_col='name', comment='#') return df # Add checks other than those in set up methods def check(self): #TODO - check for missing values #TODO - check for non-numeric values for c, A, b if not isinstance(self.df, pd.DataFrame): raise ValueError("Argument for OptModel must be a DataFrame") if 'sense' not in self.df.columns: raise AttributeError("DataFrame must have a 'sense' column") if 'rhs' not in self.df.columns: raise AttributeError("DataFrame must have a 'rhs' column") return def solve(self): self.check() objdir = self.getObjdir() #print(objdir) c = self.getC() #print(c) A = self.getA() #print(A) sense = self.getSense() #print(sense) b = self.getRhs() #print(b) lpm = LpModel(objdir, c, A, sense, b) res = lpm.solve() #print(res.slack) result = Result() result.status = res.status result.objective = res.fun if res.status == 0: result.x = pd.Series(res.x, self.getVarnames()) result.slack = pd.Series(res.slack, self.getIneqNames()) return result # determine if max or min def getObjdir(self): df = self.df row = df[(df.sense == 'min') | (df.sense == 'max')] if len(row) == 0: raise ValueError("min or max not specified for a row") if len(row) > 1: raise ValueError("multiple min or max found, only 1 may be specified") result = row.iloc[0].sense return result # get the A constraint matrix def getA(self): result = [] df = self.df df2 = df[(df.sense == '<=') | (df.sense == '>=') | (df.sense == '=')] for index, row in df2.iterrows(): rowvals = [] for name, value in row.items(): if name not in ['sense', 'rhs']: rowvals.append(value) result.append(rowvals) return result # extract the sense for all constraint rows def getSense(self): result = [] for index, row in self.df.iterrows(): if row.sense in ['<=', '>=', '=']: result.append(row.sense) return result # extract the rhs for all constraints def getRhs(self): result = [] for index, row in self.df.iterrows(): if row.sense in ['<=', '>=', '=']: result.append(row.rhs) return result # extract the objective function coefficients # TODO: err detect 0 or 2+ min/max rows found def getC(self): result = [] df = self.df row = df[(df.sense == 'min') | (df.sense == 'max')] for name, values in row.iteritems(): value = values[0] if name not in ['sense', 'rhs']: result.append(value) return result def getVarnames(self): result = [] df = self.df for name in df.columns: if name not in ['sense', 'rhs']: result.append(name) return result def getIneqNames(self): df = self.df df2 = df[(df.sense == '<=') | (df.sense == '>=')] values = df2.index.values return list(values) if __name__ == "__main__": df = OptModel.read_csv("lpmodel.txt") #print(df.fillna("")) lpmodel = OptModel(df) print(lpmodel) result = lpmodel.solve() #print(result.status) #print("x:\n" , result.x, sep='') print(result) print("slack:\n" , result.slack, sep='') df2 = OptModel.read_str( """ name x1 x2 sense rhs # objective: obj 3 5 max # subject to: #x1lower 1 0 = 2 plant1 1 0 <= 4 plant2 0 2 <= 12 plant3 3 2 <= 18 """) lpmodel2 = OptModel(df2) print(lpmodel) result2 = lpmodel2.solve() print(result2)
2,956
828
23
532041ff67fa4cd1a9c8b9a2481c86017407d677
1,264
py
Python
test/test_module1.py
PhilippSchuette/PackagingTest
51f151747b3f9d65ab0eb6168969df060071ed16
[ "MIT" ]
3
2020-09-10T13:34:47.000Z
2021-06-02T19:23:07.000Z
test/test_module1.py
PhilippSchuette/PackagingTest
51f151747b3f9d65ab0eb6168969df060071ed16
[ "MIT" ]
null
null
null
test/test_module1.py
PhilippSchuette/PackagingTest
51f151747b3f9d65ab0eb6168969df060071ed16
[ "MIT" ]
null
null
null
import argparse import module1 as mod1 import pytest from hypothesis import given from hypothesis.strategies import integers @given(integers()) @given(integers(), integers())
19.446154
54
0.635285
import argparse import module1 as mod1 import pytest from hypothesis import given from hypothesis.strategies import integers def test_parser(): parser = mod1.get_parser() assert isinstance(parser, argparse.ArgumentParser) def test_Employee(): emp = mod1.Employee(1234, "John", "Smith") assert emp.id == 1234 assert emp.first == "John" assert emp.last == "Smith" def test_func1(): assert mod1.func1() == mod1.__name__ def test_func2(): result = mod1.func2() assert result[0] == 2 * result[1] assert result[0] == 4 * result[2] assert result[0] == 8 * result[3] def test_func3(): assert mod1.func3() == 0 def test_add(): assert mod1.add(1, 2) == 3 assert mod1.add(0, 0) == 0 @given(integers()) def test_add2(x): assert mod1.add(x, 0) == x @given(integers(), integers()) def test_add3(x, y): assert mod1.add(x, y) == mod1.add(y, x) def test_subtract(): assert mod1.subtract(1, 2) == -1 assert mod1.subtract(0, 0) == 0 def test_multiply(): assert mod1.multiply(1, 2) == 2 assert mod1.multiply(0, 0) == 0 def test_divide(): assert mod1.divide(1, 2) == 0.5 assert mod1.divide(1, 1) == 1 with pytest.raises(ZeroDivisionError): mod1.divide(3.1415, 0)
825
0
251
2ad242ae4823f4b754e9228620d08ce52c874c74
2,320
py
Python
back-end/www/util/export_answers.py
Disfactory/SpotDiff
18a4bf88d9bd82cc58ac96658ad1f7d067f10a5c
[ "MIT" ]
2
2021-11-10T13:30:01.000Z
2021-11-17T13:15:19.000Z
back-end/www/util/export_answers.py
Disfactory/SpotDiff
18a4bf88d9bd82cc58ac96658ad1f7d067f10a5c
[ "MIT" ]
26
2021-10-06T12:01:33.000Z
2022-03-16T11:26:17.000Z
back-end/www/util/export_answers.py
Disfactory/SpotDiff
18a4bf88d9bd82cc58ac96658ad1f7d067f10a5c
[ "MIT" ]
1
2022-01-16T10:53:42.000Z
2022-01-16T10:53:42.000Z
""" The script exports the answer table to a CSV file. Config ------ CFG_NAME : The config name can be Develpment, Staging, Testing Output ------ The total answer numbers after export, and the CSV file. (aswer_YYYY_MM_DD_HH_mm_ss.csv) """ CFG_NAME = "config.config.DevelopmentConfig" import sys import os sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))) import csv from models.model import db from models.model import Answer from models.model_operations import location_operations from models.model_operations import answer_operations from models.model_operations import user_operations from config.config import Config from flask import Flask from controllers import root import datetime # init db app = Flask(__name__) app.register_blueprint(root.bp) app.config.from_object(CFG_NAME) db.init_app(app) app.app_context().push() cvs_file_name = "answer_" + datetime.datetime.today().strftime("%Y_%m_%d_%H_%M_%S") + ".csv" print("Exporting answers to " + cvs_file_name + "...") # Get all answers answer_query = Answer.query.order_by(Answer.user_id) answers = answer_query.all() with open(cvs_file_name, "w", newline="") as csvDataFile: # Write header csvWriter = csv.writer(csvDataFile, delimiter=",", quotechar='|', quoting=csv.QUOTE_MINIMAL) csvWriter.writerow(["Userid", "client_id", "location_id", "factory_id", "answer_id", "land_usage", "expansion", "gold_standard_status", "year_old", "year_new", "bbox_left_top_lat", "bbox_left_top_lng", "bbox_bottom_right_lat", "bbox_bottom_right_lng", "zoom_level", "timestamp"]) for answer in answers: # Write each record in answer table factory_id = location_operations.get_location_by_id(answer.location_id).factory_id client_id = user_operations.get_user_by_id(answer.user_id).client_id csvWriter.writerow([answer.user_id, client_id, answer.location_id, factory_id, answer.id, answer.land_usage,answer.expansion, answer.gold_standard_status, answer.year_old, answer.year_new, answer.bbox_left_top_lat, answer.bbox_left_top_lng, answer.bbox_bottom_right_lat, answer.bbox_bottom_right_lng, answer.zoom_level, answer.timestamp]) print("{} records reported.".format(len(answers))) db.session.remove() db.session.close()
38.032787
153
0.747845
""" The script exports the answer table to a CSV file. Config ------ CFG_NAME : The config name can be Develpment, Staging, Testing Output ------ The total answer numbers after export, and the CSV file. (aswer_YYYY_MM_DD_HH_mm_ss.csv) """ CFG_NAME = "config.config.DevelopmentConfig" import sys import os sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))) import csv from models.model import db from models.model import Answer from models.model_operations import location_operations from models.model_operations import answer_operations from models.model_operations import user_operations from config.config import Config from flask import Flask from controllers import root import datetime # init db app = Flask(__name__) app.register_blueprint(root.bp) app.config.from_object(CFG_NAME) db.init_app(app) app.app_context().push() cvs_file_name = "answer_" + datetime.datetime.today().strftime("%Y_%m_%d_%H_%M_%S") + ".csv" print("Exporting answers to " + cvs_file_name + "...") # Get all answers answer_query = Answer.query.order_by(Answer.user_id) answers = answer_query.all() with open(cvs_file_name, "w", newline="") as csvDataFile: # Write header csvWriter = csv.writer(csvDataFile, delimiter=",", quotechar='|', quoting=csv.QUOTE_MINIMAL) csvWriter.writerow(["Userid", "client_id", "location_id", "factory_id", "answer_id", "land_usage", "expansion", "gold_standard_status", "year_old", "year_new", "bbox_left_top_lat", "bbox_left_top_lng", "bbox_bottom_right_lat", "bbox_bottom_right_lng", "zoom_level", "timestamp"]) for answer in answers: # Write each record in answer table factory_id = location_operations.get_location_by_id(answer.location_id).factory_id client_id = user_operations.get_user_by_id(answer.user_id).client_id csvWriter.writerow([answer.user_id, client_id, answer.location_id, factory_id, answer.id, answer.land_usage,answer.expansion, answer.gold_standard_status, answer.year_old, answer.year_new, answer.bbox_left_top_lat, answer.bbox_left_top_lng, answer.bbox_bottom_right_lat, answer.bbox_bottom_right_lng, answer.zoom_level, answer.timestamp]) print("{} records reported.".format(len(answers))) db.session.remove() db.session.close()
0
0
0
8c71dc08b4073fc0f5c77bf4656761e04ddb2485
317
py
Python
src/blacksmith/sd/_async/base.py
mardiros/blacksmith
c86a870da04b0d916f243cb51f8861529284337d
[ "BSD-3-Clause" ]
15
2022-01-16T15:23:23.000Z
2022-01-20T21:42:53.000Z
src/blacksmith/sd/_async/base.py
mardiros/blacksmith
c86a870da04b0d916f243cb51f8861529284337d
[ "BSD-3-Clause" ]
9
2022-01-11T19:42:42.000Z
2022-01-26T20:24:23.000Z
src/blacksmith/sd/_async/base.py
mardiros/blacksmith
c86a870da04b0d916f243cb51f8861529284337d
[ "BSD-3-Clause" ]
null
null
null
import abc from blacksmith.typing import ServiceName, Url, Version class AsyncAbstractServiceDiscovery(abc.ABC): """Define the Service Discovery interface.""" @abc.abstractmethod async def get_endpoint(self, service: ServiceName, version: Version) -> Url: """Get the endpoint of a service."""
26.416667
80
0.725552
import abc from blacksmith.typing import ServiceName, Url, Version class AsyncAbstractServiceDiscovery(abc.ABC): """Define the Service Discovery interface.""" @abc.abstractmethod async def get_endpoint(self, service: ServiceName, version: Version) -> Url: """Get the endpoint of a service."""
0
0
0
b04105b29ed75ba096bb6529389fda511f9ef726
986
py
Python
data/anthropocentric/Geyer2017_plastic_production/viz/generate.py
ilopezgp/human_impacts
b2758245edac0946080a647f1dbfd1098c0f0b27
[ "MIT" ]
4
2020-08-25T00:52:01.000Z
2020-11-16T16:57:46.000Z
data/anthropocentric/Geyer2017_plastic_production/viz/generate.py
ilopezgp/human_impacts
b2758245edac0946080a647f1dbfd1098c0f0b27
[ "MIT" ]
5
2020-10-30T21:22:55.000Z
2021-12-30T02:07:02.000Z
data/anthropocentric/Geyer2017_plastic_production/viz/generate.py
ilopezgp/human_impacts
b2758245edac0946080a647f1dbfd1098c0f0b27
[ "MIT" ]
2
2020-08-28T10:11:28.000Z
2020-11-11T07:58:46.000Z
#%% import numpy as np import pandas as pd import altair as alt import anthro.io # Load the produciton data. data = pd.read_csv('../processed/Geyer2017_plastic_production.csv') data['year'] = pd.to_datetime(data['year'], format='%Y') chart = alt.Chart(data).encode( x=alt.X(field='year', type='temporal', timeUnit='year', title='year'), y=alt.Y(field='resin_production_Mt', type='quantitative', title='plastic resin produced [Mt]'), tooltip=[alt.Tooltip(field='year', type='temporal', timeUnit='year', title='year'), alt.Tooltip(field='resin_production_Mt', type='quantitative', title='produced mass [Mt]')] ).properties( width="container", height=300 ) l = chart.mark_line(color='dodgerblue') p = chart.mark_point(color='dodgerblue', filled=True) layer = alt.layer(l, p) layer.save('platic_production.json') # %% # %%
31.806452
95
0.600406
#%% import numpy as np import pandas as pd import altair as alt import anthro.io # Load the produciton data. data = pd.read_csv('../processed/Geyer2017_plastic_production.csv') data['year'] = pd.to_datetime(data['year'], format='%Y') chart = alt.Chart(data).encode( x=alt.X(field='year', type='temporal', timeUnit='year', title='year'), y=alt.Y(field='resin_production_Mt', type='quantitative', title='plastic resin produced [Mt]'), tooltip=[alt.Tooltip(field='year', type='temporal', timeUnit='year', title='year'), alt.Tooltip(field='resin_production_Mt', type='quantitative', title='produced mass [Mt]')] ).properties( width="container", height=300 ) l = chart.mark_line(color='dodgerblue') p = chart.mark_point(color='dodgerblue', filled=True) layer = alt.layer(l, p) layer.save('platic_production.json') # %% # %%
0
0
0
576e4546e2ca69d03d664c617ab23bbd9d8bb19c
6,967
py
Python
scripts/trio_ircproxy/ial.py
ashburry-chat-irc/trio_ircproxy
10d651d916505e3b3aeb9019e18466fffeaec667
[ "BSD-3-Clause" ]
null
null
null
scripts/trio_ircproxy/ial.py
ashburry-chat-irc/trio_ircproxy
10d651d916505e3b3aeb9019e18466fffeaec667
[ "BSD-3-Clause" ]
44
2021-08-28T00:48:31.000Z
2022-01-14T11:36:26.000Z
scripts/trio_ircproxy/ial.py
ashburry-chat-irc/trio_ircproxy
10d651d916505e3b3aeb9019e18466fffeaec667
[ "BSD-3-Clause" ]
null
null
null
#!/usr/bin/python # -*- coding: utf-8 -*- from fnmatch import fnmatch from typing import Union, List, Dict, Set from threading import Timer import circular
36.098446
105
0.592077
#!/usr/bin/python # -*- coding: utf-8 -*- from fnmatch import fnmatch from typing import Union, List, Dict, Set from threading import Timer import circular class IALData: from circular import XsSocket myial: Dict[XsSocket, Dict[str, str]] = dict() myial_chan: Dict[XsSocket, Dict[str, Set[str]]] = dict() myial_count: Dict[XsSocket, Dict[str, int]] = dict() timers: Set[Timer] = set() who: Dict[XsSocket, Dict[str, str]] = dict() @classmethod def sendwho(cls, server_socket: XsSocket, th: Timer, chan: str): circular.sc_send(server_socket, 'who ' + chan) cls.timers.remove(th) @classmethod def comchans_get_set(cls, client_socket: XsSocket, nick: str) -> frozenset: """Return the common channels with nick. :param client_socket: XsSocket() irc client socket stream :param nick: nick or nickmask to common channels with :return: returns a set of strings of common channel names """ cls.make_ial(client_socket) if not nick: nick = '' elif "!" in nick: nick = nick.split("!")[0] if nick in cls.myial_chan[client_socket]: return frozenset(cls.myial_chan[client_socket][nick]) else: return frozenset([]) @classmethod def comchans_get_list(cls, client_socket: XsSocket, nick: str) -> List[str]: """Return the common channels with nick. :rtype: list :param client_socket: XsSocket() irc client socket stream :param nick: nick to common channels with :return: returns a list of strings of common channel names """ cls.make_ial(client_socket) return list(cls.comchans_get_set(client_socket, nick)) @classmethod def ial_get_masks(cls, client_socket: XsSocket, mask: str) -> frozenset: """Retrieve an nickmask from the global IAL Vars: :rtype: frozenset :param client_socket: the client socket :param mask: '*!*@*addr.net' :returns: an frozenset() of matches """ found_ial = set() for nick in cls.myial[client_socket]: fullnick = cls.myial[client_socket][nick] if fnmatch(fullnick, mask): found_ial.add((nick, fullnick)) return frozenset(found_ial) @classmethod def ial_get_fullnick(cls, client_socket: XsSocket, nick: str) -> str: """Returns full address of nickname. Vars: :param client_socket: client socket :param nick: just a nickname :returns: the full complete nickmask of the nickname """ cls.make_ial(client_socket) if nick in cls.myial[client_socket]: return cls.myial[client_socket][nick] else: return '' @classmethod def ial_count_nicks(cls, client_socket: XsSocket, chan: str): count: int = 0 for nick in cls.myial_chan[client_socket]: if chan in cls.myial_chan[client_socket][nick]: count += 1 return count @classmethod def ial_add_newnick(cls, client_socket: XsSocket, oldnick: str, newnick: str, nickmask: str) -> None: """Replaces oldnick with newnick vars: :param client_socket: client socket :param oldnick: the old nickname :param newnick: the new nickname :param nickmask: the new nickmask that may change """ cls.make_ial(client_socket) cls.myial[client_socket][newnick] = nickmask if oldnick == newnick: return if newnick not in cls.myial_chan[client_socket]: cls.myial_chan[client_socket][newnick] = set() if oldnick in cls.myial_chan[client_socket]: chans = cls.myial_chan[client_socket][oldnick] cls.myial_chan[client_socket][newnick].update(chans) cls.ial_remove_nick(client_socket, oldnick, None) @classmethod def ial_remove_nick(cls, client_socket, old_nick, chans: Union[set, str, None]) -> None: """Removes nick from ial Vars: :rtype: None @param old_nick: nick to remove @param client_socket: client socket @param chans: set, str or None """ cls.make_ial(client_socket) try: if chans is not None: if isinstance(chans, set): for chan in chans: cls.myial_chan[client_socket][old_nick].discard(chan) elif chans: cls.myial_chan[client_socket][old_nick].discard(chans) if not chans or not cls.myial_chan[client_socket][old_nick]: del cls.myial_chan[client_socket][old_nick] del cls.myial[client_socket][old_nick] except KeyError: pass @classmethod def ial_remove_chan(cls, client_socket, chan) -> None: """Remove a chan from the ial. vars: client_socket: client socket chan: chan to remove """ cls.make_ial(client_socket) try: removed = [] for nick in cls.myial_chan[client_socket]: cls.myial_chan[client_socket][nick].discard(chan) if not cls.myial_chan[client_socket][nick]: removed += [nick] for nick in removed: del cls.myial_chan[client_socket][nick] del cls.myial[client_socket][nick] del cls.myial_count[client_socket][chan] except KeyError: # This should not happen pass @classmethod def ial_add_nick(cls, client_socket, nick, nickmask, chan=None) -> bool: """Add a nickname to the ial. for now chan maybe None, this will change sometime. vars: :param client_socket: client socket :param nick: nickname to add :param nickmask: the full address of the nickname :param chan: add an common channel to the ial :returns: None @rtype: None """ cls.make_ial(client_socket) cls.myial[client_socket][nick] = nickmask if nick not in cls.myial_chan[client_socket]: cls.myial_chan[client_socket][nick] = set() if chan: cls.myial_chan[client_socket][nick].add(chan) return False @classmethod def make_ial(cls, client_socket) -> None: """Make the client_socket ial dict Vars: :rtype: None :param client_socket: the client socket :returns: None """ if client_socket not in cls.myial: cls.myial[client_socket] = {} if client_socket not in cls.myial_chan: cls.myial_chan[client_socket] = {} if client_socket not in cls.who: cls.who[client_socket] = dict()
350
6,438
23
a92523bd30212da5bb8ef2fd59130659e4470e80
10,353
py
Python
eduid_proofing_amp/__init__.py
SUNET/eduid-proofing-amp
aaf4e93070089ba51c6a985e0c6fce0c9c687b93
[ "BSD-3-Clause" ]
null
null
null
eduid_proofing_amp/__init__.py
SUNET/eduid-proofing-amp
aaf4e93070089ba51c6a985e0c6fce0c9c687b93
[ "BSD-3-Clause" ]
1
2017-06-07T08:55:39.000Z
2017-06-07T08:55:39.000Z
eduid_proofing_amp/__init__.py
SUNET/eduid-proofing-amp
aaf4e93070089ba51c6a985e0c6fce0c9c687b93
[ "BSD-3-Clause" ]
null
null
null
from __future__ import absolute_import from eduid_userdb.proofing import OidcProofingUserDB, LetterProofingUserDB, LookupMobileProofingUserDB from eduid_userdb.proofing import EmailProofingUserDB, PhoneProofingUserDB, OrcidProofingUserDB from eduid_userdb.proofing import EidasProofingUserDB from eduid_userdb.personal_data import PersonalDataUserDB from eduid_userdb.security import SecurityUserDB from celery.utils.log import get_task_logger logger = get_task_logger(__name__) def filter_nin(value): """ :param value: dict :return: list This function will compile a users verified NINs to a list of strings. """ result = [] for item in value: verified = item.get('verified', False) if verified and type(verified) == bool: # Be sure that it's not something else that evaluates as True in Python result.append(item['nin']) return result class OidcProofingAMPContext(object): """ Private data for this AM plugin. """ class LetterProofingAMPContext(object): """ Private data for this AM plugin. """ class LookupMobileProofingAMPContext(object): """ Private data for this AM plugin. """ class EmailProofingAMPContext(object): """ Private data for this AM plugin. """ class PhoneProofingAMPContext(object): """ Private data for this AM plugin. """ class PersonalDataAMPContext(object): """ Private data for this AM plugin. """ class SecurityAMPContext(object): """ Private data for this AM plugin. """ class OrcidAMPContext(object): """ Private data for this AM plugin. """ class EidasAMPContext(object): """ Private data for this AM plugin. """ def oidc_plugin_init(am_conf): """ Create a private context for this plugin. Whatever is returned by this function will get passed to attribute_fetcher() as the `context' argument. :am_conf: Attribute Manager configuration data. :type am_conf: dict :rtype: OidcProofingAMPContext """ return OidcProofingAMPContext(am_conf['MONGO_URI']) def letter_plugin_init(am_conf): """ Create a private context for this plugin. Whatever is returned by this function will get passed to attribute_fetcher() as the `context' argument. :am_conf: Attribute Manager configuration data. :type am_conf: dict :rtype: LetterProofingAMPContext """ return LetterProofingAMPContext(am_conf['MONGO_URI']) def lookup_mobile_plugin_init(am_conf): """ Create a private context for this plugin. Whatever is returned by this function will get passed to attribute_fetcher() as the `context' argument. :am_conf: Attribute Manager configuration data. :type am_conf: dict :rtype: LetterProofingAMPContext """ return LookupMobileProofingAMPContext(am_conf['MONGO_URI']) def email_plugin_init(am_conf): """ Create a private context for this plugin. Whatever is returned by this function will get passed to attribute_fetcher() as the `context' argument. :am_conf: Attribute Manager configuration data. :type am_conf: dict :rtype: EmailProofingAMPContext """ return EmailProofingAMPContext(am_conf['MONGO_URI']) def phone_plugin_init(am_conf): """ Create a private context for this plugin. Whatever is returned by this function will get passed to attribute_fetcher() as the `context' argument. :am_conf: Attribute Manager configuration data. :type am_conf: dict :rtype: PhoneProofingAMPContext """ return PhoneProofingAMPContext(am_conf['MONGO_URI']) def personal_data_plugin_init(am_conf): """ Create a private context for this plugin. Whatever is returned by this function will get passed to attribute_fetcher() as the `context' argument. :am_conf: Attribute Manager configuration data. :type am_conf: dict :rtype: PersonalDataAMPContext """ return PersonalDataAMPContext(am_conf['MONGO_URI']) def security_plugin_init(am_conf): """ Create a private context for this plugin. Whatever is returned by this function will get passed to attribute_fetcher() as the `context' argument. :am_conf: Attribute Manager configuration data. :type am_conf: dict :rtype: SecurityAMPContext """ return SecurityAMPContext(am_conf['MONGO_URI']) def orcid_plugin_init(am_conf): """ Create a private context for this plugin. Whatever is returned by this function will get passed to attribute_fetcher() as the `context' argument. :am_conf: Attribute Manager configuration data. :type am_conf: dict :rtype: OrcidAMPContext """ return OrcidAMPContext(am_conf['MONGO_URI']) def eidas_plugin_init(am_conf): """ Create a private context for this plugin. Whatever is returned by this function will get passed to attribute_fetcher() as the `context' argument. :am_conf: Attribute Manager configuration data. :type am_conf: dict :rtype: EidasAMPContext """ return EidasAMPContext(am_conf['MONGO_URI']) def attribute_fetcher(context, user_id): """ Read a user from the Dashboard private private_db and return an update dict to let the Attribute Manager update the use in the central eduid user database. :param context: Plugin context, see plugin_init above. :param user_id: Unique identifier :type context: DashboardAMPContext :type user_id: ObjectId :return: update dict :rtype: dict """ attributes = {} logger.debug('Trying to get user with _id: {} from {}.'.format(user_id, context.private_db)) user = context.private_db.get_user_by_id(user_id) logger.debug('User: {} found.'.format(user)) user_dict = user.to_dict(old_userdb_format=False) # white list of valid attributes for security reasons attributes_set = {} attributes_unset = {} for attr in context.WHITELIST_SET_ATTRS: value = value_filter(attr, user_dict.get(attr, None)) if value: attributes_set[attr] = value elif attr in context.WHITELIST_UNSET_ATTRS: attributes_unset[attr] = value logger.debug('Will set attributes: {}'.format(attributes_set)) logger.debug('Will remove attributes: {}'.format(attributes_unset)) if attributes_set: attributes['$set'] = attributes_set if attributes_unset: attributes['$unset'] = attributes_unset return attributes
26.546154
120
0.640587
from __future__ import absolute_import from eduid_userdb.proofing import OidcProofingUserDB, LetterProofingUserDB, LookupMobileProofingUserDB from eduid_userdb.proofing import EmailProofingUserDB, PhoneProofingUserDB, OrcidProofingUserDB from eduid_userdb.proofing import EidasProofingUserDB from eduid_userdb.personal_data import PersonalDataUserDB from eduid_userdb.security import SecurityUserDB from celery.utils.log import get_task_logger logger = get_task_logger(__name__) def value_filter(attr, value): if value: # Check it we need to filter values for this attribute #if attr == 'norEduPersonNIN': # value = filter_nin(value) pass return value def filter_nin(value): """ :param value: dict :return: list This function will compile a users verified NINs to a list of strings. """ result = [] for item in value: verified = item.get('verified', False) if verified and type(verified) == bool: # Be sure that it's not something else that evaluates as True in Python result.append(item['nin']) return result class OidcProofingAMPContext(object): """ Private data for this AM plugin. """ def __init__(self, db_uri): self.private_db = OidcProofingUserDB(db_uri) self.WHITELIST_SET_ATTRS = [ # TODO: Arrays must use put or pop, not set, but need more deep refacts 'nins', # New format 'givenName', 'surname', # New format 'displayName', ] self.WHITELIST_UNSET_ATTRS = [ 'norEduPersonNIN', 'nins' # New format ] class LetterProofingAMPContext(object): """ Private data for this AM plugin. """ def __init__(self, db_uri): self.private_db = LetterProofingUserDB(db_uri) self.WHITELIST_SET_ATTRS = [ # TODO: Arrays must use put or pop, not set, but need more deep refacts 'nins', # New format 'letter_proofing_data', 'givenName', 'surname', # New format 'displayName', ] self.WHITELIST_UNSET_ATTRS = [ 'norEduPersonNIN', 'nins' # New format ] class LookupMobileProofingAMPContext(object): """ Private data for this AM plugin. """ def __init__(self, db_uri): self.private_db = LookupMobileProofingUserDB(db_uri) self.WHITELIST_SET_ATTRS = [ # TODO: Arrays must use put or pop, not set, but need more deep refacts 'nins', # New format 'givenName', 'surname', # New format 'displayName', ] self.WHITELIST_UNSET_ATTRS = [ 'norEduPersonNIN', 'nins' # New format ] class EmailProofingAMPContext(object): """ Private data for this AM plugin. """ def __init__(self, db_uri): self.private_db = EmailProofingUserDB(db_uri) self.WHITELIST_SET_ATTRS = [ # TODO: Arrays must use put or pop, not set, but need more deep refacts 'mailAliases', ] self.WHITELIST_UNSET_ATTRS = [ 'mailAliases', 'mail', # Old format ] class PhoneProofingAMPContext(object): """ Private data for this AM plugin. """ def __init__(self, db_uri): self.private_db = PhoneProofingUserDB(db_uri) self.WHITELIST_SET_ATTRS = [ # TODO: Arrays must use put or pop, not set, but need more deep refacts 'phone', ] self.WHITELIST_UNSET_ATTRS = [ 'phone', 'mobile', # Old format ] class PersonalDataAMPContext(object): """ Private data for this AM plugin. """ def __init__(self, db_uri): self.private_db = PersonalDataUserDB(db_uri) self.WHITELIST_SET_ATTRS = [ 'givenName', 'surname', # New format 'displayName', 'preferredLanguage', ] self.WHITELIST_UNSET_ATTRS = [ 'sn', # Old format ] class SecurityAMPContext(object): """ Private data for this AM plugin. """ def __init__(self, db_uri): self.private_db = SecurityUserDB(db_uri) self.WHITELIST_SET_ATTRS = [ 'passwords', 'terminated', 'nins', # For AL1 downgrade on password reset 'phone', # For AL1 downgrade on password reset ] self.WHITELIST_UNSET_ATTRS = [ 'passwords', 'terminated', 'norEduPersonNIN', # For AL1 downgrade on password reset 'nins', # For AL1 downgrade on password reset 'phone', # For AL1 downgrade on password reset ] class OrcidAMPContext(object): """ Private data for this AM plugin. """ def __init__(self, db_uri): self.private_db = OrcidProofingUserDB(db_uri) self.WHITELIST_SET_ATTRS = [ 'orcid', ] self.WHITELIST_UNSET_ATTRS = [ 'orcid', ] class EidasAMPContext(object): """ Private data for this AM plugin. """ def __init__(self, db_uri): self.private_db = EidasProofingUserDB(db_uri) self.WHITELIST_SET_ATTRS = [ 'passwords', 'nins', 'givenName', 'surname', # New format 'displayName', ] self.WHITELIST_UNSET_ATTRS = [] def oidc_plugin_init(am_conf): """ Create a private context for this plugin. Whatever is returned by this function will get passed to attribute_fetcher() as the `context' argument. :am_conf: Attribute Manager configuration data. :type am_conf: dict :rtype: OidcProofingAMPContext """ return OidcProofingAMPContext(am_conf['MONGO_URI']) def letter_plugin_init(am_conf): """ Create a private context for this plugin. Whatever is returned by this function will get passed to attribute_fetcher() as the `context' argument. :am_conf: Attribute Manager configuration data. :type am_conf: dict :rtype: LetterProofingAMPContext """ return LetterProofingAMPContext(am_conf['MONGO_URI']) def lookup_mobile_plugin_init(am_conf): """ Create a private context for this plugin. Whatever is returned by this function will get passed to attribute_fetcher() as the `context' argument. :am_conf: Attribute Manager configuration data. :type am_conf: dict :rtype: LetterProofingAMPContext """ return LookupMobileProofingAMPContext(am_conf['MONGO_URI']) def email_plugin_init(am_conf): """ Create a private context for this plugin. Whatever is returned by this function will get passed to attribute_fetcher() as the `context' argument. :am_conf: Attribute Manager configuration data. :type am_conf: dict :rtype: EmailProofingAMPContext """ return EmailProofingAMPContext(am_conf['MONGO_URI']) def phone_plugin_init(am_conf): """ Create a private context for this plugin. Whatever is returned by this function will get passed to attribute_fetcher() as the `context' argument. :am_conf: Attribute Manager configuration data. :type am_conf: dict :rtype: PhoneProofingAMPContext """ return PhoneProofingAMPContext(am_conf['MONGO_URI']) def personal_data_plugin_init(am_conf): """ Create a private context for this plugin. Whatever is returned by this function will get passed to attribute_fetcher() as the `context' argument. :am_conf: Attribute Manager configuration data. :type am_conf: dict :rtype: PersonalDataAMPContext """ return PersonalDataAMPContext(am_conf['MONGO_URI']) def security_plugin_init(am_conf): """ Create a private context for this plugin. Whatever is returned by this function will get passed to attribute_fetcher() as the `context' argument. :am_conf: Attribute Manager configuration data. :type am_conf: dict :rtype: SecurityAMPContext """ return SecurityAMPContext(am_conf['MONGO_URI']) def orcid_plugin_init(am_conf): """ Create a private context for this plugin. Whatever is returned by this function will get passed to attribute_fetcher() as the `context' argument. :am_conf: Attribute Manager configuration data. :type am_conf: dict :rtype: OrcidAMPContext """ return OrcidAMPContext(am_conf['MONGO_URI']) def eidas_plugin_init(am_conf): """ Create a private context for this plugin. Whatever is returned by this function will get passed to attribute_fetcher() as the `context' argument. :am_conf: Attribute Manager configuration data. :type am_conf: dict :rtype: EidasAMPContext """ return EidasAMPContext(am_conf['MONGO_URI']) def attribute_fetcher(context, user_id): """ Read a user from the Dashboard private private_db and return an update dict to let the Attribute Manager update the use in the central eduid user database. :param context: Plugin context, see plugin_init above. :param user_id: Unique identifier :type context: DashboardAMPContext :type user_id: ObjectId :return: update dict :rtype: dict """ attributes = {} logger.debug('Trying to get user with _id: {} from {}.'.format(user_id, context.private_db)) user = context.private_db.get_user_by_id(user_id) logger.debug('User: {} found.'.format(user)) user_dict = user.to_dict(old_userdb_format=False) # white list of valid attributes for security reasons attributes_set = {} attributes_unset = {} for attr in context.WHITELIST_SET_ATTRS: value = value_filter(attr, user_dict.get(attr, None)) if value: attributes_set[attr] = value elif attr in context.WHITELIST_UNSET_ATTRS: attributes_unset[attr] = value logger.debug('Will set attributes: {}'.format(attributes_set)) logger.debug('Will remove attributes: {}'.format(attributes_unset)) if attributes_set: attributes['$set'] = attributes_set if attributes_unset: attributes['$unset'] = attributes_unset return attributes
3,554
0
266
0a35a64bc8e129fa895b6268a0bf03dcfbeb2e19
3,974
py
Python
razzbee/webviewengine.py
razzbee/kivy-android-webview-
9f8910e710ed271ff32d20b6e1fd2bbab71522bf
[ "MIT" ]
14
2017-04-01T09:05:53.000Z
2021-02-05T19:31:28.000Z
razzbee/webviewengine.py
razzbee/kivy-android-webview-
9f8910e710ed271ff32d20b6e1fd2bbab71522bf
[ "MIT" ]
3
2018-03-16T00:35:16.000Z
2020-04-29T15:48:05.000Z
razzbee/webviewengine.py
razzbee/kivy-android-webview-
9f8910e710ed271ff32d20b6e1fd2bbab71522bf
[ "MIT" ]
8
2017-08-15T16:07:12.000Z
2022-03-27T03:41:34.000Z
from kivy.uix.widget import Widget from kivy.clock import Clock from runnable import run_on_ui_thread from kivy.event import EventDispatcher from jnius import autoclass from webviewclient import WebviewClient #Load Native Modules WebView = autoclass('android.webkit.WebView') WebViewClient = autoclass('android.webkit.WebViewClient') activity = autoclass('org.kivy.android.PythonActivity').mActivity LayoutParams = autoclass('android.view.ViewGroup$LayoutParams') View = autoclass('android.view.View')
28.589928
130
0.668596
from kivy.uix.widget import Widget from kivy.clock import Clock from runnable import run_on_ui_thread from kivy.event import EventDispatcher from jnius import autoclass from webviewclient import WebviewClient #Load Native Modules WebView = autoclass('android.webkit.WebView') WebViewClient = autoclass('android.webkit.WebViewClient') activity = autoclass('org.kivy.android.PythonActivity').mActivity LayoutParams = autoclass('android.view.ViewGroup$LayoutParams') View = autoclass('android.view.View') class WebviewEngine(Widget,EventDispatcher): is_visible = True _webview_obj = None #events _webview_events = ['on_page_started','on_page_finished', 'on_received_error','on_page_commit_visible', 'on_should_override_url_loading' ] #initialize :D -- Sweet def __init__(self, **kwargs): self.webviewWidth = kwargs.get('width') if kwargs.has_key('width') else LayoutParams.MATCH_PARENT self.webviewPosX = kwargs.get('posX') if kwargs.has_key('posX') else 0 self.webviewPosY = kwargs.get('posY') if kwargs.has_key('posY') else 0 self.webviewHeight = kwargs.get('height') if kwargs.has_key('height') else LayoutParams.MATCH_PARENT #register Events self._register_events() super(WebviewEngine, self).__init__(**kwargs) Clock.schedule_once(self.create_webview, 0) #method for dispatching events def dispatch_event(self,event_name,**kwargs): #dispatch self.dispatch(event_name,**kwargs) print('--- Eevent %s dispatched \n' %event_name, kwargs) #default event handler def _event_default_handler(self,**kwargs): pass #Event registrar def _register_events(self): events = self._webview_events #loop and register them for event_name in events: #create the default handler setattr(self,event_name,self._event_default_handler) #register the event self.register_event_type(event_name) #Magic Method to pipe java's webview methods to this class def __getattr__(self,method_name): print("----%s--- has been called ====" % method_name) #else if the method is a webview Obj if hasattr(self._webview_obj,method_name): #create a dummy function call_method = lambda *x: getattr(self._webview_obj,method_name)(*x) #return method return call_method else: raise Exception("Method %s not define" % method_name) @run_on_ui_thread def create_webview(self,*args): #if the webview is created already, skip it if(self._webview_obj): return True #if we have reached this point, then mean the webview is not created webview = WebView(activity) settings = webview.getSettings() settings.setJavaScriptEnabled(True) settings.setUseWideViewPort(True) # enables viewport html meta tags settings.setLoadWithOverviewMode(True) # uses viewport settings.setSupportZoom(True) # enables zoom settings.setBuiltInZoomControls(True) # enables zoom controls #set java events webviewClient = WebviewClient(self) webview.setWebViewClient(webviewClient) #webview.setWebChromeClient(WebChromeClient) #set Postions webview.setX(self.webviewPosX) webview.setY(self.webviewPosY) #webview.testNum = 12 activity.addContentView(webview, LayoutParams(self.webviewWidth,self.webviewHeight)) webview.loadUrl('http://www.google.com') self._webview_obj = webview #hide - This will hide the webview widget @run_on_ui_thread def hide(self): if self._webview_obj is None and self.is_visible == False: return False self._webview_obj.setVisibility(View.GONE)
2,480
737
23
22b196265c0b570aebf802d2bbc1df1a5a65933f
3,313
py
Python
vaas-app/src/vaas/purger/tests/test_views.py
allegro/vaas
3d2d1f1a9dae6ac69a13563a37f9bfdf4f986ae2
[ "Apache-2.0" ]
251
2015-09-02T10:50:51.000Z
2022-03-16T08:00:35.000Z
vaas-app/src/vaas/purger/tests/test_views.py
allegro/vaas
3d2d1f1a9dae6ac69a13563a37f9bfdf4f986ae2
[ "Apache-2.0" ]
154
2015-09-02T14:54:08.000Z
2022-03-16T08:34:17.000Z
vaas-app/src/vaas/purger/tests/test_views.py
allegro/vaas
3d2d1f1a9dae6ac69a13563a37f9bfdf4f986ae2
[ "Apache-2.0" ]
31
2015-09-03T07:51:05.000Z
2020-09-24T09:02:40.000Z
from unittest.mock import patch, Mock from vaas.cluster.models import LogicalCluster, VarnishServer, VclTemplateBlock, VclTemplate, Dc from vaas.manager.tests.test_views import BaseApiViewPermissionsTest
53.435484
168
0.589798
from unittest.mock import patch, Mock from vaas.cluster.models import LogicalCluster, VarnishServer, VclTemplateBlock, VclTemplate, Dc from vaas.manager.tests.test_views import BaseApiViewPermissionsTest class TestPurgerApiViewPermissions(BaseApiViewPermissionsTest): PURGER_RESOURCE = '/api/v0.1/purger/' API_KEY_NON_STAFF_USER = 'non_staff_user_12345' def setUp(self): super(TestPurgerApiViewPermissions, self).setUp() self.user_non_staff = self.create_user(username='user_non_staff', email='[email protected]', password='user', is_staff=False, is_superuser=False ) self.create_api_key_for_user(self.user_non_staff, self.API_KEY_NON_STAFF_USER) cluster1 = LogicalCluster.objects.create(name="first_cluster") dc1 = Dc.objects.create(name="Bilbao", symbol="dc1") template_v4 = VclTemplate.objects.create(name='new-v4', content='<VCL/>', version='4.0') self.varnish = VarnishServer.objects.create(ip='127.0.0.1', hostname='server1', dc=dc1, status='enabled', template=template_v4, cluster=cluster1) self.purger_data = { "url": "http://example.com/contact", "clusters": "first_cluster", "headers": {"key1": ["val1"]} } def test_get_directors_unauthenticated(self): self.assertHttpUnauthorized(self.api_client.post(self.PURGER_RESOURCE, format='json', data=self.purger_data)) @patch('vaas.purger.purger.HTTPConnection.getresponse', Mock(return_value=Mock(status=200))) @patch('http.client.HTTPConnection.request') def test_user_with_staff_status_can_purge_url(self, request_mock): resp = self.api_client.post(self.PURGER_RESOURCE, format='json', data=self.purger_data, authentication=self.create_apikey(self.normal_user, self.API_KEY_USER)) self.assertValidJSONResponse(resp) print(self.deserialize(resp)['success']) self.assertEqual( self.deserialize(resp)['success'], { '127.0.0.1': [ "varnish http response code: 200, url=http://example.com/contact, headers=[('Host', 'example.com'), ('key1', 'val1')], server=127.0.0.1:80" # noqa ] } ) request_mock.assert_called_with('PURGE', '/contact', body='', headers={'key1': 'val1', 'Host': 'example.com'}) @patch('vaas.purger.purger.HTTPConnection.getresponse', Mock(return_value=Mock(status=200))) @patch('http.client.HTTPConnection.request') def test_user_without_staff_status_can_not_purge_url(self, response_mock): self.assertHttpUnauthorized(self.api_client.post(self.PURGER_RESOURCE, format='json', data=self.purger_data, authentication=self.create_apikey( self.user_non_staff, self.API_KEY_NON_STAFF_USER) ))
2,547
537
23
200332a5b27e708f82148bbda4a77c474dc9ccba
1,861
py
Python
app/views/arduino.py
yakinaround/myadventure-api
aae56a93748457c2f060434b9faf81830de5bc99
[ "Apache-2.0" ]
null
null
null
app/views/arduino.py
yakinaround/myadventure-api
aae56a93748457c2f060434b9faf81830de5bc99
[ "Apache-2.0" ]
2
2021-03-31T18:30:32.000Z
2021-12-13T19:44:07.000Z
app/views/arduino.py
myadventure/myadventure-api
aae56a93748457c2f060434b9faf81830de5bc99
[ "Apache-2.0" ]
null
null
null
""" android.py Android views. """ import logging from datetime import datetime from flask import Blueprint, abort, request, jsonify from werkzeug.exceptions import BadRequest from app.decorators import crossdomain, ignore_exception from app.models.adventure import Adventure from app.models.point import Point SFLOAT = ignore_exception(TypeError)(float) SINT = ignore_exception(TypeError)(int) SBOOL = ignore_exception(TypeError)(bool) MOD_ARDUINO = Blueprint('arduino', __name__, url_prefix='/api/v1/adventure/<slug>/arduino') @MOD_ARDUINO.route('/', methods=['POST']) @crossdomain('*') def add_point(slug): """Create a new point based on post parameters.""" try: timestamp = datetime.now() adventure = Adventure.objects(slug=slug).get() point = Point( title='Arduino tracker', desc=None, altitude=request.form.get('alt', None), speed=request.form.get('spd', None), direction=request.form.get('dir', None), latitude=SFLOAT(request.form.get('lat', None)), longitude=SFLOAT(request.form.get('lon', None)), resource=None, point_type='tracker', timestamp=timestamp, delorme_id=None, aio_id=None, hide=bool(request.form.get('hide', None) in ['true', 'True', 'TRUE', '1', 'y', 'yes']), thumb=None, photo=None, video=None, source='arduino', battery=SINT(request.form.get('bat', None)), user=None ) adventure.points.append(point) adventure.save() return jsonify({'status': "ok"}) except ValueError as err: logging.error(err) abort(400) except BadRequest as err: logging.error(err) abort(400) return jsonify({'status': "ok"})
30.508197
99
0.612574
""" android.py Android views. """ import logging from datetime import datetime from flask import Blueprint, abort, request, jsonify from werkzeug.exceptions import BadRequest from app.decorators import crossdomain, ignore_exception from app.models.adventure import Adventure from app.models.point import Point SFLOAT = ignore_exception(TypeError)(float) SINT = ignore_exception(TypeError)(int) SBOOL = ignore_exception(TypeError)(bool) MOD_ARDUINO = Blueprint('arduino', __name__, url_prefix='/api/v1/adventure/<slug>/arduino') @MOD_ARDUINO.route('/', methods=['POST']) @crossdomain('*') def add_point(slug): """Create a new point based on post parameters.""" try: timestamp = datetime.now() adventure = Adventure.objects(slug=slug).get() point = Point( title='Arduino tracker', desc=None, altitude=request.form.get('alt', None), speed=request.form.get('spd', None), direction=request.form.get('dir', None), latitude=SFLOAT(request.form.get('lat', None)), longitude=SFLOAT(request.form.get('lon', None)), resource=None, point_type='tracker', timestamp=timestamp, delorme_id=None, aio_id=None, hide=bool(request.form.get('hide', None) in ['true', 'True', 'TRUE', '1', 'y', 'yes']), thumb=None, photo=None, video=None, source='arduino', battery=SINT(request.form.get('bat', None)), user=None ) adventure.points.append(point) adventure.save() return jsonify({'status': "ok"}) except ValueError as err: logging.error(err) abort(400) except BadRequest as err: logging.error(err) abort(400) return jsonify({'status': "ok"})
0
0
0
625140e4b32448c38225b930dd958630e387c909
1,231
py
Python
models/embedding.py
woo1/Anim-NeRF
03977700420691b18b6aa0bc809f3a05a9f07b12
[ "MIT" ]
130
2021-09-07T15:37:42.000Z
2022-03-30T16:22:50.000Z
models/embedding.py
woo1/Anim-NeRF
03977700420691b18b6aa0bc809f3a05a9f07b12
[ "MIT" ]
18
2021-11-24T05:01:50.000Z
2022-03-18T07:11:13.000Z
models/embedding.py
woo1/Anim-NeRF
03977700420691b18b6aa0bc809f3a05a9f07b12
[ "MIT" ]
15
2022-01-21T10:26:41.000Z
2022-03-30T08:32:12.000Z
import torch import torch.nn as nn import torch.nn.functional as F
31.564103
76
0.566206
import torch import torch.nn as nn import torch.nn.functional as F class Embedding(nn.Module): def __init__(self, in_channels, N_freqs, logscale=True): """ Defines a function that embeds x to (x, sin(2^k x), cos(2^k x), ...) in_channels: number of input channels (3 for both xyz and direction) """ super(Embedding, self).__init__() self.N_freqs = N_freqs self.in_channels = in_channels self.funcs = [torch.sin, torch.cos] self.out_channels = in_channels*(len(self.funcs)*N_freqs+1) if logscale: self.freq_bands = 2**torch.linspace(0, N_freqs-1, N_freqs) else: self.freq_bands = torch.linspace(1, 2**(N_freqs-1), N_freqs) def forward(self, x): """ Embeds x to (x, sin(2^k x), cos(2^k x), ...) Different from the paper, "x" is also in the output See https://github.com/bmild/nerf/issues/12 Inputs: x: (B, self.in_channels) Outputs: out: (B, self.out_channels) """ out = [x] for freq in self.freq_bands: for func in self.funcs: out += [func(freq*x)] return torch.cat(out, -1)
0
1,142
23
8281f6c429c581dacbd8c9cc2bf5636484bbc7fa
989
py
Python
flyer/fix.py
FIXFlyer/pyflyer
e40fdedff4db642a804ed6c29de742444ab0ffe5
[ "MIT" ]
2
2019-06-07T16:03:26.000Z
2020-12-20T22:12:19.000Z
flyer/fix.py
mdvx/pyflyer
e40fdedff4db642a804ed6c29de742444ab0ffe5
[ "MIT" ]
null
null
null
flyer/fix.py
mdvx/pyflyer
e40fdedff4db642a804ed6c29de742444ab0ffe5
[ "MIT" ]
4
2017-07-18T15:06:33.000Z
2022-03-30T05:26:46.000Z
#! /usr/bin/env python #----------------------------------------------------------------------- # COPYRIGHT_BEGIN # Copyright (C) 2016, FixFlyer, LLC. # All rights reserved. # COPYRIGHT_END #-----------------------------------------------------------------------
21.5
88
0.517695
#! /usr/bin/env python #----------------------------------------------------------------------- # COPYRIGHT_BEGIN # Copyright (C) 2016, FixFlyer, LLC. # All rights reserved. # COPYRIGHT_END #----------------------------------------------------------------------- class Message(object): def clear(self): pass def size(self): pass def add(self, tag, value, index=-1): pass def add_tag_value(self, tag_value, index=-1): pass def add_utc_timestamp(self, tag, seconds, index=-1): pass def add_utc_timestamp_with_milliseconds(self, tag, seconds, milliseconds, index=-1): pass def remove(self, tag, nth=0): pass def remove_at(self, index): pass def get(self, tag, value_out, nth=0): pass def get_at(self, index, tag_out, value_out): pass def encode(self, buffer, buflen, length_out, raw=False): pass def decode(self, buffer, buflen): pass
378
1
347
e3f5fa29d31a1ca5ef53447a8be8495dc15d52a4
328
py
Python
djangomom/account/views.py
emiamar/d
abfd0ca81224a1259fdfac92ed21ad771d901e18
[ "BSD-3-Clause" ]
null
null
null
djangomom/account/views.py
emiamar/d
abfd0ca81224a1259fdfac92ed21ad771d901e18
[ "BSD-3-Clause" ]
2
2018-02-27T07:56:18.000Z
2018-03-09T12:45:48.000Z
djangomom/account/views.py
emiamar/d
abfd0ca81224a1259fdfac92ed21ad771d901e18
[ "BSD-3-Clause" ]
2
2018-02-21T07:43:04.000Z
2018-11-10T18:09:26.000Z
from django import forms from .models import SignUp from base.views import GenericModalCreateView
16.4
45
0.698171
from django import forms from .models import SignUp from base.views import GenericModalCreateView class SignUpForm(forms.ModelForm): class Meta: model = SignUp fields = ('email', ) class SignUpView(GenericModalCreateView): form_class = SignUpForm success_url = '/' object_name = 'SignUp'
0
180
46
167af61bf6438845997063a10538e46eff0df427
4,815
py
Python
AI701/bbo_osi/example_submissions/turbo/optimizer.py
sungnyun/AI-assignments
6451fd6db33fd8671ca362b4ad4c190979a98c22
[ "MIT" ]
103
2020-06-26T04:10:11.000Z
2022-03-17T02:09:29.000Z
example_submissions/turbo/optimizer.py
ntienvu/bbo_challenge_starter_kit
bba852b380388c1f1087b232dae62117ddb065bf
[ "Apache-2.0" ]
5
2020-07-12T16:49:42.000Z
2021-07-21T23:26:22.000Z
example_submissions/turbo/optimizer.py
ntienvu/bbo_challenge_starter_kit
bba852b380388c1f1087b232dae62117ddb065bf
[ "Apache-2.0" ]
35
2020-07-02T07:55:19.000Z
2021-03-31T19:00:27.000Z
from copy import deepcopy import numpy as np import scipy.stats as ss from turbo import Turbo1 from turbo.utils import from_unit_cube, latin_hypercube, to_unit_cube from bayesmark.abstract_optimizer import AbstractOptimizer from bayesmark.experiment import experiment_main from bayesmark.space import JointSpace if __name__ == "__main__": experiment_main(TurboOptimizer)
36.755725
101
0.61703
from copy import deepcopy import numpy as np import scipy.stats as ss from turbo import Turbo1 from turbo.utils import from_unit_cube, latin_hypercube, to_unit_cube from bayesmark.abstract_optimizer import AbstractOptimizer from bayesmark.experiment import experiment_main from bayesmark.space import JointSpace def order_stats(X): _, idx, cnt = np.unique(X, return_inverse=True, return_counts=True) obs = np.cumsum(cnt) # Need to do it this way due to ties o_stats = obs[idx] return o_stats def copula_standardize(X): X = np.nan_to_num(np.asarray(X)) # Replace inf by something large assert X.ndim == 1 and np.all(np.isfinite(X)) o_stats = order_stats(X) quantile = np.true_divide(o_stats, len(X) + 1) X_ss = ss.norm.ppf(quantile) return X_ss class TurboOptimizer(AbstractOptimizer): primary_import = "Turbo" def __init__(self, api_config, **kwargs): """Build wrapper class to use an optimizer in benchmark. Parameters ---------- api_config : dict-like of dict-like Configuration of the optimization variables. See API description. """ AbstractOptimizer.__init__(self, api_config) self.space_x = JointSpace(api_config) self.bounds = self.space_x.get_bounds() self.lb, self.ub = self.bounds[:, 0], self.bounds[:, 1] self.dim = len(self.bounds) self.max_evals = np.iinfo(np.int32).max # NOTE: Largest possible int self.batch_size = None self.history = [] self.turbo = Turbo1( f=None, lb=self.bounds[:, 0], ub=self.bounds[:, 1], n_init=2 * self.dim + 1, max_evals=self.max_evals, batch_size=1, # We need to update this later verbose=False, ) def restart(self): self.turbo._restart() self.turbo._X = np.zeros((0, self.turbo.dim)) self.turbo._fX = np.zeros((0, 1)) X_init = latin_hypercube(self.turbo.n_init, self.dim) self.X_init = from_unit_cube(X_init, self.lb, self.ub) def suggest(self, n_suggestions=1): if self.batch_size is None: # Remember the batch size on the first call to suggest self.batch_size = n_suggestions self.turbo.batch_size = n_suggestions self.turbo.failtol = np.ceil(np.max([4.0 / self.batch_size, self.dim / self.batch_size])) self.turbo.n_init = max([self.turbo.n_init, self.batch_size]) self.restart() X_next = np.zeros((n_suggestions, self.dim)) # Pick from the initial points n_init = min(len(self.X_init), n_suggestions) if n_init > 0: X_next[:n_init] = deepcopy(self.X_init[:n_init, :]) self.X_init = self.X_init[n_init:, :] # Remove these pending points # Get remaining points from TuRBO n_adapt = n_suggestions - n_init if n_adapt > 0: if len(self.turbo._X) > 0: # Use random points if we can't fit a GP X = to_unit_cube(deepcopy(self.turbo._X), self.lb, self.ub) fX = copula_standardize(deepcopy(self.turbo._fX).ravel()) # Use Copula X_cand, y_cand, _ = self.turbo._create_candidates( X, fX, length=self.turbo.length, n_training_steps=100, hypers={} ) X_next[-n_adapt:, :] = self.turbo._select_candidates(X_cand, y_cand)[:n_adapt, :] X_next[-n_adapt:, :] = from_unit_cube(X_next[-n_adapt:, :], self.lb, self.ub) # Unwarp the suggestions suggestions = self.space_x.unwarp(X_next) return suggestions def observe(self, X, y): """Send an observation of a suggestion back to the optimizer. Parameters ---------- X : list of dict-like Places where the objective function has already been evaluated. Each suggestion is a dictionary where each key corresponds to a parameter being optimized. y : array-like, shape (n,) Corresponding values where objective has been evaluated """ assert len(X) == len(y) XX, yy = self.space_x.warp(X), np.array(y)[:, None] if len(self.turbo._fX) >= self.turbo.n_init: self.turbo._adjust_length(yy) self.turbo.n_evals += self.batch_size self.turbo._X = np.vstack((self.turbo._X, deepcopy(XX))) self.turbo._fX = np.vstack((self.turbo._fX, deepcopy(yy))) self.turbo.X = np.vstack((self.turbo.X, deepcopy(XX))) self.turbo.fX = np.vstack((self.turbo.fX, deepcopy(yy))) # Check for a restart if self.turbo.length < self.turbo.length_min: self.restart() if __name__ == "__main__": experiment_main(TurboOptimizer)
2,223
2,141
69
794bd7ed69e1e978e635f64a2d7412ba530be4c8
4,375
py
Python
setup.py
PRITI1999/klever
ac80edf4301c15f6b63e35837f4ffbf7e3e68809
[ "Apache-2.0" ]
1
2021-01-09T08:44:37.000Z
2021-01-09T08:44:37.000Z
setup.py
Abhik1998/klever
827bbd31b29e213bf74cb1d1b158153e62a2933e
[ "Apache-2.0" ]
3
2021-03-19T09:15:16.000Z
2021-09-22T19:24:40.000Z
setup.py
Abhik1998/klever
827bbd31b29e213bf74cb1d1b158153e62a2933e
[ "Apache-2.0" ]
null
null
null
# Copyright (c) 2020 ISP RAS (http://www.ispras.ru) # Ivannikov Institute for System Programming of the Russian Academy of Sciences # # 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 os import setuptools VERSION = '3.0' setuptools.setup( name="klever", use_scm_version={'fallback_version': get_fallback_version()}, author="ISP RAS", author_email="[email protected]", url="http://forge.ispras.ru/projects/klever", license="LICENSE", description="Klever is a software verification framework", long_description=open("README.md", encoding="utf8").read(), python_requires=">=3.7", packages=["klever"], package_data={"klever": package_files("klever")}, entry_points={ "console_scripts": [ "klever-core=klever.core.__main__:main", "klever-client-controller=klever.scheduler.main:client_controller", "klever-debug-scheduler=klever.scheduler.main:debug_scheduler", "klever-native-scheduler=klever.scheduler.main:native_scheduler", "klever-scheduler-client=klever.scheduler.main:scheduler_client", "klever-verifiercloud-scheduler=klever.scheduler.main:verifiercloud_scheduler", "klever-node-check=klever.scheduler.controller.checks.node:main", "klever-resources-check=klever.scheduler.controller.checks.resources:main", "klever-schedulers-check=klever.scheduler.controller.checks.schedulers:main", "klever-build=klever.cli.klever_build:klever_build", "klever-download-job=klever.cli.cli:download_job", "klever-download-marks=klever.cli.cli:download_marks", "klever-download-progress=klever.cli.cli:download_progress", "klever-download-results=klever.cli.cli:download_results", "klever-start-preset-solution=klever.cli.cli:start_preset_solution", "klever-start-solution=klever.cli.cli:start_solution", "klever-update-preset-mark=klever.cli.cli:update_preset_mark", "klever-update-job=klever.cli.cli:upload_job", "klever-deploy-local=klever.deploys.local:main", "klever-deploy-openstack=klever.deploys.openstack:main", ] }, install_requires=[ "Django==3.0.6", "BenchExec==1.18", "clade==3.2.7", "psycopg2", "graphviz", "celery", "django_celery_results", "djangorestframework", "django-compressor", "django-mptt", "gunicorn", "pika", "python-slugify", "pytz", "jinja2", "ply", "pygments", "requests", "setuptools_scm", "sortedcontainers", "consulate" ], extras_require={ "strict": open("requirements.txt", encoding="utf8").read().splitlines(), "docs": ["sphinx", "sphinx_rtd_theme"], "openstack": [ "python-novaclient", "python-neutronclient", "python-glanceclient", "python-cinderclient", "keystoneauth1", "paramiko", "pycryptodome" ] }, classifiers=[ "Programming Language :: Python :: 3", "Programming Language :: Python :: Implementation :: CPython", "License :: OSI Approved :: Apache Software License", "Operating System :: POSIX :: Linux", ], )
35.282258
91
0.636343
# Copyright (c) 2020 ISP RAS (http://www.ispras.ru) # Ivannikov Institute for System Programming of the Russian Academy of Sciences # # 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 os import setuptools VERSION = '3.0' def get_fallback_version(): if os.path.isfile('version'): with open('version') as fp: return fp.read() return VERSION def package_files(package_directory): paths = [] for (root, _, filenames) in os.walk(package_directory): for filename in filenames: path = os.path.relpath( os.path.join(root, filename), start=package_directory ) paths.append(path) return paths setuptools.setup( name="klever", use_scm_version={'fallback_version': get_fallback_version()}, author="ISP RAS", author_email="[email protected]", url="http://forge.ispras.ru/projects/klever", license="LICENSE", description="Klever is a software verification framework", long_description=open("README.md", encoding="utf8").read(), python_requires=">=3.7", packages=["klever"], package_data={"klever": package_files("klever")}, entry_points={ "console_scripts": [ "klever-core=klever.core.__main__:main", "klever-client-controller=klever.scheduler.main:client_controller", "klever-debug-scheduler=klever.scheduler.main:debug_scheduler", "klever-native-scheduler=klever.scheduler.main:native_scheduler", "klever-scheduler-client=klever.scheduler.main:scheduler_client", "klever-verifiercloud-scheduler=klever.scheduler.main:verifiercloud_scheduler", "klever-node-check=klever.scheduler.controller.checks.node:main", "klever-resources-check=klever.scheduler.controller.checks.resources:main", "klever-schedulers-check=klever.scheduler.controller.checks.schedulers:main", "klever-build=klever.cli.klever_build:klever_build", "klever-download-job=klever.cli.cli:download_job", "klever-download-marks=klever.cli.cli:download_marks", "klever-download-progress=klever.cli.cli:download_progress", "klever-download-results=klever.cli.cli:download_results", "klever-start-preset-solution=klever.cli.cli:start_preset_solution", "klever-start-solution=klever.cli.cli:start_solution", "klever-update-preset-mark=klever.cli.cli:update_preset_mark", "klever-update-job=klever.cli.cli:upload_job", "klever-deploy-local=klever.deploys.local:main", "klever-deploy-openstack=klever.deploys.openstack:main", ] }, install_requires=[ "Django==3.0.6", "BenchExec==1.18", "clade==3.2.7", "psycopg2", "graphviz", "celery", "django_celery_results", "djangorestframework", "django-compressor", "django-mptt", "gunicorn", "pika", "python-slugify", "pytz", "jinja2", "ply", "pygments", "requests", "setuptools_scm", "sortedcontainers", "consulate" ], extras_require={ "strict": open("requirements.txt", encoding="utf8").read().splitlines(), "docs": ["sphinx", "sphinx_rtd_theme"], "openstack": [ "python-novaclient", "python-neutronclient", "python-glanceclient", "python-cinderclient", "keystoneauth1", "paramiko", "pycryptodome" ] }, classifiers=[ "Programming Language :: Python :: 3", "Programming Language :: Python :: Implementation :: CPython", "License :: OSI Approved :: Apache Software License", "Operating System :: POSIX :: Linux", ], )
422
0
46
28334f96479ecb761075604e60d6c1e5c3a15823
1,891
py
Python
Lib/vanilla/test/list2/selection.py
roboDocs/vanilla
d8bb60b24edcc550c3d8cc60cf73143eee87d547
[ "MIT" ]
31
2015-02-09T09:09:26.000Z
2019-01-01T19:04:52.000Z
Lib/vanilla/test/list2/selection.py
roboDocs/vanilla
d8bb60b24edcc550c3d8cc60cf73143eee87d547
[ "MIT" ]
63
2015-04-14T00:40:50.000Z
2019-01-12T15:04:54.000Z
Lib/vanilla/test/list2/selection.py
roboDocs/vanilla
d8bb60b24edcc550c3d8cc60cf73143eee87d547
[ "MIT" ]
16
2015-03-28T21:00:22.000Z
2018-08-17T20:28:53.000Z
import vanilla if __name__ == "__main__": from vanilla.test.testTools import executeVanillaTest executeVanillaTest(Test)
27.405797
61
0.524061
import vanilla def makeItems(): items = [] letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" for i, letter in enumerate(letters): number = i + 1 item = dict( letter=letter, number=number ) items.append(item) return items class Test: def __init__(self): self.w = vanilla.Window((500, 1)) self.w.line = vanilla.VerticalLine("auto") columnDescriptions = [ dict( identifier="letter", title="Letter", sortable=True ), dict( identifier="number", title="Number", sortable=True ) ] self.w.text = vanilla.TextBox( "auto", "Select items on the left and the same items " "should be selected on the right regardless " "of different sort orders." ) self.w.itemList1 = vanilla.List2( "auto", items=makeItems(), columnDescriptions=columnDescriptions, selectionCallback=self.itemList1SelectionCallback ) self.w.itemList2 = vanilla.List2( "auto", items=makeItems(), columnDescriptions=columnDescriptions ) rules = [ "H:|-[text]-|", "H:|-[itemList1]-[itemList2(==itemList1)]-|", "V:|-[text]", "V:[text]-[itemList1(==300)]-|", "V:[text]-[itemList2(==itemList1)]-|", ] self.w.addAutoPosSizeRules(rules) self.w.open() def itemList1SelectionCallback(self, sender): indexes = self.w.itemList1.getSelectedIndexes() self.w.itemList2.setSelectedIndexes(indexes) if __name__ == "__main__": from vanilla.test.testTools import executeVanillaTest executeVanillaTest(Test)
1,669
-10
100
76f55ae94b6824f6292bc5b3ea75cb7ecfa43f4f
398
py
Python
api/sonetworks/migrations/0016_remove_staticpage_page.py
gvaldez81/semitki
6c7cbb2bb2260db79478de48a9b2e71b8ed633ff
[ "MIT" ]
null
null
null
api/sonetworks/migrations/0016_remove_staticpage_page.py
gvaldez81/semitki
6c7cbb2bb2260db79478de48a9b2e71b8ed633ff
[ "MIT" ]
51
2017-02-07T22:30:49.000Z
2022-03-11T23:15:55.000Z
api/sonetworks/migrations/0016_remove_staticpage_page.py
gvaldez81/semitki
6c7cbb2bb2260db79478de48a9b2e71b8ed633ff
[ "MIT" ]
1
2017-10-09T14:21:35.000Z
2017-10-09T14:21:35.000Z
# -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-03-30 20:21 from __future__ import unicode_literals from django.db import migrations
19.9
50
0.61809
# -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-03-30 20:21 from __future__ import unicode_literals from django.db import migrations class Migration(migrations.Migration): dependencies = [ ('sonetworks', '0015_auto_20170330_2001'), ] operations = [ migrations.RemoveField( model_name='staticpage', name='page', ), ]
0
227
23
f7b6ea0ae206265a155eeb220d8b4777db821527
13,540
py
Python
bitsharesbase/operations.py
gdfbacchus/python-bitshares
95f9cefab2f6b72073221bb647df8ab40bcf8e4b
[ "MIT" ]
null
null
null
bitsharesbase/operations.py
gdfbacchus/python-bitshares
95f9cefab2f6b72073221bb647df8ab40bcf8e4b
[ "MIT" ]
null
null
null
bitsharesbase/operations.py
gdfbacchus/python-bitshares
95f9cefab2f6b72073221bb647df8ab40bcf8e4b
[ "MIT" ]
1
2018-11-20T03:50:25.000Z
2018-11-20T03:50:25.000Z
from collections import OrderedDict import json from graphenebase.types import ( Uint8, Int16, Uint16, Uint32, Uint64, Varint32, Int64, String, Bytes, Void, Array, PointInTime, Signature, Bool, Set, Fixed_array, Optional, Static_variant, Map, Id, VoteId ) from .objects import GrapheneObject, isArgsThisClass from .account import PublicKey from .operationids import operations from .objects import ( Operation, Asset, Memo, Price, PriceFeed, Permission, AccountOptions, AssetOptions, ObjectId ) default_prefix = "BTS" def getOperationNameForId(i): """ Convert an operation id into the corresponding string """ for key in operations: if int(operations[key]) is int(i): return key return "Unknown Operation ID %d" % i
37.821229
99
0.511226
from collections import OrderedDict import json from graphenebase.types import ( Uint8, Int16, Uint16, Uint32, Uint64, Varint32, Int64, String, Bytes, Void, Array, PointInTime, Signature, Bool, Set, Fixed_array, Optional, Static_variant, Map, Id, VoteId ) from .objects import GrapheneObject, isArgsThisClass from .account import PublicKey from .operationids import operations from .objects import ( Operation, Asset, Memo, Price, PriceFeed, Permission, AccountOptions, AssetOptions, ObjectId ) default_prefix = "BTS" def getOperationNameForId(i): """ Convert an operation id into the corresponding string """ for key in operations: if int(operations[key]) is int(i): return key return "Unknown Operation ID %d" % i class Transfer(GrapheneObject): def __init__(self, *args, **kwargs): if isArgsThisClass(self, args): self.data = args[0].data else: if len(args) == 1 and len(kwargs) == 0: kwargs = args[0] if "memo" in kwargs and kwargs["memo"]: memo = Optional(Memo(kwargs["memo"])) else: memo = Optional(None) super().__init__(OrderedDict([ ('fee', Asset(kwargs["fee"])), ('from', ObjectId(kwargs["from"], "account")), ('to', ObjectId(kwargs["to"], "account")), ('amount', Asset(kwargs["amount"])), ('memo', memo), ('extensions', Set([])), ])) class Asset_publish_feed(GrapheneObject): def __init__(self, *args, **kwargs): if isArgsThisClass(self, args): self.data = args[0].data else: if len(args) == 1 and len(kwargs) == 0: kwargs = args[0] super().__init__(OrderedDict([ ('fee', Asset(kwargs["fee"])), ('publisher', ObjectId(kwargs["publisher"], "account")), ('asset_id', ObjectId(kwargs["asset_id"], "asset")), ('feed', PriceFeed(kwargs["feed"])), ('extensions', Set([])), ])) class Asset_update(GrapheneObject): def __init__(self, *args, **kwargs): if isArgsThisClass(self, args): self.data = args[0].data else: if len(args) == 1 and len(kwargs) == 0: kwargs = args[0] if "new_issuer" in kwargs: new_issuer = Optional(ObjectId(kwargs["new_issuer"], "account")) else: new_issuer = Optional(None) super().__init__(OrderedDict([ ('fee', Asset(kwargs["fee"])), ('issuer', ObjectId(kwargs["issuer"], "account")), ('asset_to_update', ObjectId(kwargs["asset_to_update"], "asset")), ('new_issuer', new_issuer), ('new_options', AssetOptions(kwargs["new_options"])), ('extensions', Set([])), ])) class Op_wrapper(GrapheneObject): def __init__(self, *args, **kwargs): if isArgsThisClass(self, args): self.data = args[0].data else: if len(args) == 1 and len(kwargs) == 0: kwargs = args[0] super().__init__(OrderedDict([ ('op', Operation(kwargs["op"])), ])) class Proposal_create(GrapheneObject): def __init__(self, *args, **kwargs): if isArgsThisClass(self, args): self.data = args[0].data else: if len(args) == 1 and len(kwargs) == 0: kwargs = args[0] if "review_period_seconds" in kwargs: review = Optional(Uint32(kwargs["review_period_seconds"])) else: review = Optional(None) super().__init__(OrderedDict([ ('fee', Asset(kwargs["fee"])), ('fee_paying_account', ObjectId(kwargs["fee_paying_account"], "account")), ('expiration_time', PointInTime(kwargs["expiration_time"])), ('proposed_ops', Array([Op_wrapper(o) for o in kwargs["proposed_ops"]])), ('review_period_seconds', review), ('extensions', Set([])), ])) class Proposal_update(GrapheneObject): def __init__(self, *args, **kwargs): if isArgsThisClass(self, args): self.data = args[0].data else: if len(args) == 1 and len(kwargs) == 0: kwargs = args[0] for o in ['active_approvals_to_add', 'active_approvals_to_remove', 'owner_approvals_to_add', 'owner_approvals_to_remove', 'key_approvals_to_add', 'key_approvals_to_remove']: if o not in kwargs: kwargs[o] = [] super().__init__(OrderedDict([ ('fee', Asset(kwargs["fee"])), ('fee_paying_account', ObjectId(kwargs["fee_paying_account"], "account")), ('proposal', ObjectId(kwargs["proposal"], "proposal")), ('active_approvals_to_add', Array([ObjectId(o, "account") for o in kwargs["active_approvals_to_add"]])), ('active_approvals_to_remove', Array([ObjectId(o, "account") for o in kwargs["active_approvals_to_remove"]])), ('owner_approvals_to_add', Array([ObjectId(o, "account") for o in kwargs["owner_approvals_to_add"]])), ('owner_approvals_to_remove', Array([ObjectId(o, "account") for o in kwargs["owner_approvals_to_remove"]])), ('key_approvals_to_add', Array([PublicKey(o) for o in kwargs["key_approvals_to_add"]])), ('key_approvals_to_remove', Array([PublicKey(o) for o in kwargs["key_approvals_to_remove"]])), ('extensions', Set([])), ])) class Limit_order_create(GrapheneObject): def __init__(self, *args, **kwargs): if isArgsThisClass(self, args): self.data = args[0].data else: if len(args) == 1 and len(kwargs) == 0: kwargs = args[0] super().__init__(OrderedDict([ ('fee', Asset(kwargs["fee"])), ('seller', ObjectId(kwargs["seller"], "account")), ('amount_to_sell', Asset(kwargs["amount_to_sell"])), ('min_to_receive', Asset(kwargs["min_to_receive"])), ('expiration', PointInTime(kwargs["expiration"])), ('fill_or_kill', Bool(kwargs["fill_or_kill"])), ('extensions', Set([])), ])) class Limit_order_cancel(GrapheneObject): def __init__(self, *args, **kwargs): if isArgsThisClass(self, args): self.data = args[0].data else: if len(args) == 1 and len(kwargs) == 0: kwargs = args[0] super().__init__(OrderedDict([ ('fee', Asset(kwargs["fee"])), ('fee_paying_account', ObjectId(kwargs["fee_paying_account"], "account")), ('order', ObjectId(kwargs["order"], "limit_order")), ('extensions', Set([])), ])) class Call_order_update(GrapheneObject): def __init__(self, *args, **kwargs): if isArgsThisClass(self, args): self.data = args[0].data else: if len(args) == 1 and len(kwargs) == 0: kwargs = args[0] super().__init__(OrderedDict([ ('fee', Asset(kwargs["fee"])), ('funding_account', ObjectId(kwargs["funding_account"], "account")), ('delta_collateral', Asset(kwargs["delta_collateral"])), ('delta_debt', Asset(kwargs["delta_debt"])), ('extensions', Set([])), ])) class Asset_fund_fee_pool(GrapheneObject): def __init__(self, *args, **kwargs): if isArgsThisClass(self, args): self.data = args[0].data else: if len(args) == 1 and len(kwargs) == 0: kwargs = args[0] super().__init__(OrderedDict([ ('fee', Asset(kwargs["fee"])), ('from_account', ObjectId(kwargs["from_account"], "account")), ('asset_id', ObjectId(kwargs["asset_id"], "asset")), ('amount', Int64(kwargs["amount"])), ('extensions', Set([])), ])) class Override_transfer(GrapheneObject): def __init__(self, *args, **kwargs): if isArgsThisClass(self, args): self.data = args[0].data else: if len(args) == 1 and len(kwargs) == 0: kwargs = args[0] if "memo" in kwargs: memo = Optional(Memo(kwargs["memo"])) else: memo = Optional(None) super().__init__(OrderedDict([ ('fee', Asset(kwargs["fee"])), ('issuer', ObjectId(kwargs["issuer"], "account")), ('from', ObjectId(kwargs["from"], "account")), ('to', ObjectId(kwargs["to"], "account")), ('amount', Asset(kwargs["amount"])), ('memo', memo), ('extensions', Set([])), ])) class Account_create(GrapheneObject): def __init__(self, *args, **kwargs): # Allow for overwrite of prefix if isArgsThisClass(self, args): self.data = args[0].data else: if len(args) == 1 and len(kwargs) == 0: kwargs = args[0] prefix = kwargs.get("prefix", default_prefix) super().__init__(OrderedDict([ ('fee', Asset(kwargs["fee"])), ('registrar', ObjectId(kwargs["registrar"], "account")), ('referrer', ObjectId(kwargs["referrer"], "account")), ('referrer_percent', Uint16(kwargs["referrer_percent"])), ('name', String(kwargs["name"])), ('owner', Permission(kwargs["owner"], prefix=prefix)), ('active', Permission(kwargs["active"], prefix=prefix)), ('options', AccountOptions(kwargs["options"], prefix=prefix)), ('extensions', Set([])), ])) class Account_update(GrapheneObject): def __init__(self, *args, **kwargs): # Allow for overwrite of prefix if isArgsThisClass(self, args): self.data = args[0].data else: if len(args) == 1 and len(kwargs) == 0: kwargs = args[0] prefix = kwargs.get("prefix", default_prefix) if "owner" in kwargs: owner = Optional(Permission(kwargs["owner"], prefix=prefix)) else: owner = Optional(None) if "active" in kwargs: active = Optional(Permission(kwargs["active"], prefix=prefix)) else: active = Optional(None) if "new_options" in kwargs: options = Optional(AccountOptions(kwargs["new_options"], prefix=prefix)) else: options = Optional(None) super().__init__(OrderedDict([ ('fee', Asset(kwargs["fee"])), ('account', ObjectId(kwargs["account"], "account")), ('owner', owner), ('active', active), ('new_options', options), ('extensions', Set([])), ])) class Account_whitelist(GrapheneObject): def __init__(self, *args, **kwargs): if isArgsThisClass(self, args): self.data = args[0].data else: if len(args) == 1 and len(kwargs) == 0: kwargs = args[0] super().__init__(OrderedDict([ ('fee', Asset(kwargs["fee"])), ('authorizing_account', ObjectId(kwargs["authorizing_account"], "account")), ('account_to_list', ObjectId(kwargs["account_to_list"], "account")), ('new_listing', Uint8(kwargs["new_listing"])), ('extensions', Set([])), ])) class Vesting_balance_withdraw(GrapheneObject): def __init__(self, *args, **kwargs): if isArgsThisClass(self, args): self.data = args[0].data else: if len(args) == 1 and len(kwargs) == 0: kwargs = args[0] super().__init__(OrderedDict([ ('fee', Asset(kwargs["fee"])), ('vesting_balance', ObjectId(kwargs["vesting_balance"], "vesting_balance")), ('owner', ObjectId(kwargs["owner"], "account")), ('amount', Asset(kwargs["amount"])), ])) class Account_upgrade(GrapheneObject): def __init__(self, *args, **kwargs): if isArgsThisClass(self, args): self.data = args[0].data else: if len(args) == 1 and len(kwargs) == 0: kwargs = args[0] super().__init__(OrderedDict([ ('fee', Asset(kwargs["fee"])), ('account_to_upgrade', ObjectId(kwargs["account_to_upgrade"], "account")), ('upgrade_to_lifetime_member', Bool(kwargs["upgrade_to_lifetime_member"])), ('extensions', Set([])), ]))
11,646
283
784