hexsha
stringlengths 40
40
| size
int64 1
1.03M
| ext
stringclasses 10
values | lang
stringclasses 1
value | max_stars_repo_path
stringlengths 3
239
| max_stars_repo_name
stringlengths 5
130
| max_stars_repo_head_hexsha
stringlengths 40
78
| max_stars_repo_licenses
listlengths 1
10
| max_stars_count
int64 1
191k
⌀ | 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 3
239
| max_issues_repo_name
stringlengths 5
130
| max_issues_repo_head_hexsha
stringlengths 40
78
| max_issues_repo_licenses
listlengths 1
10
| max_issues_count
int64 1
67k
⌀ | 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 3
239
| max_forks_repo_name
stringlengths 5
130
| 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.03M
| avg_line_length
float64 1
958k
| max_line_length
int64 1
1.03M
| alphanum_fraction
float64 0
1
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
7951ad713e836dd5189c5aecb9f4d2e602977807
| 1,457
|
py
|
Python
|
MRNet_code/utils/dice_loss.py
|
jiwei0921/MRNet
|
0778f52abb19fd4ae29a5ede21c06afa37c11ba4
|
[
"MIT"
] | 61
|
2021-06-13T15:40:06.000Z
|
2022-03-30T03:01:58.000Z
|
PaddleCare/Deep_learning/TRansformer/transformer/MRNet-main/MRNet_code/utils/dice_loss.py
|
momozi1996/Medical_AI_analysis
|
e1736a9e0d4c1b0996badbbeb870703fef119ab2
|
[
"OML"
] | null | null | null |
PaddleCare/Deep_learning/TRansformer/transformer/MRNet-main/MRNet_code/utils/dice_loss.py
|
momozi1996/Medical_AI_analysis
|
e1736a9e0d4c1b0996badbbeb870703fef119ab2
|
[
"OML"
] | 11
|
2021-06-19T06:46:31.000Z
|
2022-02-18T07:56:47.000Z
|
import torch
from torch.autograd import Function
import numpy as np
class DiceCoeff(Function):
"""Dice coeff for individual examples"""
def forward(self, input, target):
self.save_for_backward(input, target)
eps = 0.0001
self.inter = torch.dot(input.view(-1), target.view(-1))
self.union = torch.sum(input) + torch.sum(target) + eps
t = (2 * self.inter.float() + eps) / self.union.float()
return t
# This function has only a single output, so it gets only one gradient
def backward(self, grad_output):
input, target = self.saved_variables
grad_input = grad_target = None
if self.needs_input_grad[0]:
grad_input = grad_output * 2 * (target * self.union - self.inter) \
/ (self.union * self.union)
if self.needs_input_grad[1]:
grad_target = None
return grad_input, grad_target
def dice_coeff(input, target):
"""Dice coeff for batches"""
if input.is_cuda:
s = torch.FloatTensor(1).cuda().zero_()
else:
s = torch.FloatTensor(1).zero_()
for i, c in enumerate(zip(input, target)):
s = s + DiceCoeff().forward(c[0], c[1])
return s / (i + 1)
def iou(outputs: np.array, labels: np.array):
intersection = (outputs & labels).sum((1, 2))
union = (outputs | labels).sum((1, 2))
iou = (intersection + 1e-6) / (union + 1e-6)
return iou.mean()
| 27.490566
| 79
| 0.601235
|
7951adc70a033df0a8c1781cd1fe250fbdea553f
| 499
|
py
|
Python
|
adslproxy/config.py
|
ruoshuifuping/AdslProxyPool
|
271aec68432509911a19b0c11777309a81f21fc9
|
[
"MIT"
] | 2
|
2017-07-17T11:00:55.000Z
|
2018-03-15T09:56:53.000Z
|
adslproxy/config.py
|
ruoshuifuping/AdslProxyPool
|
271aec68432509911a19b0c11777309a81f21fc9
|
[
"MIT"
] | null | null | null |
adslproxy/config.py
|
ruoshuifuping/AdslProxyPool
|
271aec68432509911a19b0c11777309a81f21fc9
|
[
"MIT"
] | 1
|
2018-11-22T10:03:14.000Z
|
2018-11-22T10:03:14.000Z
|
# coding:utf-8
# 拨号间隔
ADSL_CYCLE = 251
# 拨号出错重试间隔
ADSL_ERROR_CYCLE = 10
# ADSL命令
ADSL_BASH = 'adsl-stop;adsl-start'
# 代理运行端口
PROXY_PORT = 8888
# 客户端唯一标识
CLIENT_NAME = 'adsl1'
# 拨号网卡
ADSL_IFNAME = 'ppp0'
# Redis数据库IP
REDIS_HOST = '39.105.26.123'
# Redis数据库密码, 如无则填None
REDIS_PASSWORD = 'QKhQLSCKJGEFXgQXgfDULJjGGj_VLDNRpPMKpp_HZRhUA'
# Redis数据库端口
REDIS_PORT = 6379
# 代理池键名
PROXY_KEY = 'adsl'
# 测试URL
TEST_URL = 'https://www.amazon.com/'
# 测试超时时间
TEST_TIMEOUT = 10
# API端口
API_PORT = 7999
| 12.475
| 64
| 0.727455
|
7951aedafb09c3b8aa03d378cec5ae9e2d4509e5
| 474
|
py
|
Python
|
datastructure/practice/c7/c_7_43.py
|
stoneyangxu/python-kata
|
979af91c74718a525dcd2a83fe53ec6342af9741
|
[
"MIT"
] | null | null | null |
datastructure/practice/c7/c_7_43.py
|
stoneyangxu/python-kata
|
979af91c74718a525dcd2a83fe53ec6342af9741
|
[
"MIT"
] | null | null | null |
datastructure/practice/c7/c_7_43.py
|
stoneyangxu/python-kata
|
979af91c74718a525dcd2a83fe53ec6342af9741
|
[
"MIT"
] | null | null | null |
import unittest
from datastructure.links.PositionList import PositionList
class MyTestCase(unittest.TestCase):
def test_something(self):
L = PositionList()
L.add_last(1)
L.add_last(2)
L.add_last(3)
L.add_last(4)
L.add_last(5)
L.add_last(6)
L.add_last(7)
L.shuffle()
r = [k for k in L]
self.assertEqual([1, 5, 2, 6, 3, 7, 4], r)
if __name__ == '__main__':
unittest.main()
| 18.96
| 57
| 0.57173
|
7951af432dc28e4b1fa23d920ddeba8a01ae99ed
| 622
|
py
|
Python
|
questionnaire/migrations/0007_auto_20210505_2146.py
|
smlaming/Roomate-Finder
|
864d6633f4303b53596d8fe62572bf7808c6c443
|
[
"MIT"
] | null | null | null |
questionnaire/migrations/0007_auto_20210505_2146.py
|
smlaming/Roomate-Finder
|
864d6633f4303b53596d8fe62572bf7808c6c443
|
[
"MIT"
] | null | null | null |
questionnaire/migrations/0007_auto_20210505_2146.py
|
smlaming/Roomate-Finder
|
864d6633f4303b53596d8fe62572bf7808c6c443
|
[
"MIT"
] | null | null | null |
# Generated by Django 3.1.6 on 2021-05-06 01:46
import django.core.validators
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('questionnaire', '0006_auto_20210420_1201'),
]
operations = [
migrations.AlterField(
model_name='question',
name='ideal_rent',
field=models.PositiveBigIntegerField(validators=[django.core.validators.MinValueValidator(200, message='Please enter a number above 200'), django.core.validators.MaxValueValidator(1500, message='Please enter a number below 1500')]),
),
]
| 31.1
| 244
| 0.689711
|
7951afeef007ccb63ff8cb4a2a37cbe23bed5f19
| 2,034
|
py
|
Python
|
.history/run_update_20220325120859.py
|
miguel-fresh/geoip-translation
|
ccf9dbc0330e597704e57d8b2967fc9be16017ed
|
[
"Info-ZIP"
] | null | null | null |
.history/run_update_20220325120859.py
|
miguel-fresh/geoip-translation
|
ccf9dbc0330e597704e57d8b2967fc9be16017ed
|
[
"Info-ZIP"
] | null | null | null |
.history/run_update_20220325120859.py
|
miguel-fresh/geoip-translation
|
ccf9dbc0330e597704e57d8b2967fc9be16017ed
|
[
"Info-ZIP"
] | null | null | null |
import subprocess
from sys import stderr, stdout
from pathlib import Path
from os import rename, getcwd, path
import yaml
# Default values
ONSTART_DOWNLOAD = False
ONSTART_CONVERT = False
CURRENT_DIR = Path(getcwd())
CONFIG_FILENAME = 'config.yml'
CONFIG_ABSPATH = CURRENT_DIR.joinpath(CONFIG_FILENAME)
ZIP_NAME = 'GeoLite2-City-CSV.zip'
DAT_NAME = 'GeoLiteCity.dat'
DOWNLOAD_DIRNAME = './data'
OUTPUT_DIRNAME = './output'
try:
with open(CONFIG_ABSPATH) as cfg_file:
documents = yaml.full_load(cfg_file)
paths = documents['paths']
names = documents['names']
on_start = documents['on_start']
OUTPUT_DIRNAME = paths['output']
DOWNLOAD_DIRNAME = paths['data']
ZIP_NAME = names['zip']
DAT_NAME = names['dat']
ONSTART_DOWNLOAD = on_start['download_zip']
ONSTART_CONVERT = on_start['convert_to_dat']
except:
DOWNLOAD_ABSPATH = CURRENT_DIR.joinpath(DOWNLOAD_DIRNAME)
OUTPUT_ABSPATH = CURRENT_DIR.joinpath(OUTPUT_DIRNAME)
ZIP_ABSPATH = DOWNLOAD_ABSPATH.joinpath(ZIP_NAME)
DAT_ABSPATH = OUTPUT_ABSPATH.joinpath(DAT_NAME)
if ONSTART_DOWNLOAD:
# Download .zip
download_output = subprocess.run(['composer', 'update', 'tronovav/geoip2-update'],
capture_output=True,
shell=True,
cwd='./geoip2-update')
print(download_output)
# TODO: Rename .zip to GeoLite2-City-CSV.zip
# Convert format
if ONSTART_CONVERT:
# python geolite2legacy.py -i GeoLite2-City-CSV.zip -o GeoLiteCity.dat -f geoname2fips.csv
downloaded_zip_asbpath = CURRENT_DIR.joinpath(ZIP_NAME)
print(downloaded_zip_asbpath)
update_output = subprocess.run(['python', 'geolite2legacy.py',
'-i', ZIP_ABSPATH,
'-o', DAT_ABSPATH,
'-f', 'geoname2fips.csv'],
cwd='./geolite2legacy')
print(update_output)
| 29.478261
| 94
| 0.635693
|
7951b191b91bd50f602658019e1148dff220c067
| 1,904
|
py
|
Python
|
tests/test_nml_generation.py
|
fossabot/wknml
|
942a571f07618e0fb79498f141128b9ae16aaf4a
|
[
"MIT"
] | null | null | null |
tests/test_nml_generation.py
|
fossabot/wknml
|
942a571f07618e0fb79498f141128b9ae16aaf4a
|
[
"MIT"
] | null | null | null |
tests/test_nml_generation.py
|
fossabot/wknml
|
942a571f07618e0fb79498f141128b9ae16aaf4a
|
[
"MIT"
] | null | null | null |
from wknml import parse_nml, write_nml
from wknml.nml_generation import generate_graph, generate_nml
import os
import filecmp
def test_generate_nml():
with open("testdata/nml_with_invalid_ids.nml", "r") as file:
test_nml = parse_nml(file)
(graph, parameter_dict) = generate_graph(test_nml)
test_result_nml = generate_nml(tree_dict=graph, parameters=parameter_dict)
with open("testdata/expected_result.nml", "r") as file:
expected_nml = parse_nml(file)
# need to save and load the test_result_nml since reading applies default values
# thus this is needed to be able to compare the nmls
with open("testoutput/temp.nml", "wb") as file:
write_nml(file=file, nml=test_result_nml)
with open("testoutput/temp.nml", "r") as file:
test_result_nml = parse_nml(file)
assert test_result_nml == expected_nml
def test_no_default_values_written():
input_file_name = "testdata/nml_without_default_values.nml"
output_file_name = "testoutput/nml_without_default_values.nml"
# read and write the test file
with open(input_file_name, "r") as file:
test_nml = parse_nml(file)
with open(output_file_name, "wb") as output_file:
write_nml(file=output_file, nml=test_nml)
# read the written testfile and compare the content
with open(input_file_name, "r") as file:
test_nml = parse_nml(file)
with open(output_file_name, "r") as output_file:
test_result_nml = parse_nml(output_file)
assert test_nml == test_result_nml, "The testdata file and the testoutput file do not have the same content."
# test if both files have the same content
assert filecmp.cmp(input_file_name, output_file_name), "The testdata and the testoutput file do not have the same content."
if __name__ == "__main__":
test_generate_nml()
test_no_default_values_written()
| 37.333333
| 127
| 0.722689
|
7951b1a24e7930a10cb74471c585cd9fbb5005ce
| 7,504
|
py
|
Python
|
wienerschnitzelgemeinschaft/src/shai/fastai/other_ensemble_scripts/enstw39c.py
|
guitarmind/HPA-competition-solutions
|
547d53aaca148fdb5f4585526ad7364dfa47967d
|
[
"MIT"
] | null | null | null |
wienerschnitzelgemeinschaft/src/shai/fastai/other_ensemble_scripts/enstw39c.py
|
guitarmind/HPA-competition-solutions
|
547d53aaca148fdb5f4585526ad7364dfa47967d
|
[
"MIT"
] | null | null | null |
wienerschnitzelgemeinschaft/src/shai/fastai/other_ensemble_scripts/enstw39c.py
|
guitarmind/HPA-competition-solutions
|
547d53aaca148fdb5f4585526ad7364dfa47967d
|
[
"MIT"
] | null | null | null |
# individual nan corrected
# Final nan matches highest probable label (optional)
import pandas as pd
import numpy as np
from tqdm import tqdm
import matplotlib.pyplot as plt
SAMPLE = '../input/sample_submission.csv'
label_names = {
0: "Nucleoplasm",
1: "Nuclear membrane",
2: "Nucleoli",
3: "Nucleoli fibrillar center",
4: "Nuclear speckles",
5: "Nuclear bodies",
6: "Endoplasmic reticulum",
7: "Golgi apparatus",
8: "Peroxisomes",
9: "Endosomes",
10: "Lysosomes",
11: "Intermediate filaments",
12: "Actin filaments",
13: "Focal adhesion sites",
14: "Microtubules",
15: "Microtubule ends",
16: "Cytokinetic bridge",
17: "Mitotic spindle",
18: "Microtubule organizing center",
19: "Centrosome",
20: "Lipid droplets",
21: "Plasma membrane",
22: "Cell junctions",
23: "Mitochondria",
24: "Aggresome",
25: "Cytosol",
26: "Cytoplasmic bodies",
27: "Rods & rings"
}
column_sum = []
sub_name = []
def expand(csv):
sub = pd.read_csv(csv)
print(csv, sub.isna().sum())
sub = sub.replace(pd.np.nan, '101')
sub[f'target_vec'] = sub['Predicted'].map(lambda x: list(map(int, x.strip().split())))
for i in range(28):
sub[f'{label_names[i]}'] = sub['Predicted'].map(
lambda x: 1 if str(i) in x.strip().split() else 0)
sub = sub.values
sub = np.delete(sub, [1, 2], axis=1)
a = sub[:, 1:]
unique, counts = np.unique(a, return_counts=True)
print('Unique counts:',np.asarray((unique, counts)).T)
print('Total labels:{} Class-wise:{}'.format(a.sum(), a.sum(axis=0)))
column_sum.append( a.sum(axis=0))
sub_name.append(csv)
return sub
#======================================================================================================================
# Input submissions
#====================================================================================================================
sub_dir = 'sub_dir_team/'
df_1 = expand('sub_dir_team/leak_brian_tommy_en_res34swa_re50xt_re101xtswa_wrn_4.8_562.csv')
df_2 = expand( 'sub_dir_team/Christof_blend_4_580.csv')
df_3 = expand('sub_dir_team/ens85bd_russ_616.csv')
df_4 = expand('sub_dir_team/enspreds103_12mdl_512-256_wtth0.45_leak_shai_593.csv')
df_5 = expand('sub_dir_team/hill_m94d_dmytro_627.csv')
df_6 = expand('sub_dir_team/voted_5_d_kevin_602.csv')
df_7 = expand('sub_dir_team/hill_b93d_l2_615update.csv')
df_8 = expand('sub_dir_team/submission_loss_5fold_mean_2_GAP_chrs_602.csv')
#=======================================================================================================================
# Visualize distribution
#=======================================================================================================================
list =[0,1,2,3,4,5,6,7]
colors = ['r', 'g', 'b', 'c', 'm', 'y', 'k', 'orange']
w=0
for i in list:
x = np.arange(0, 28, 1)
plt.bar(x+w, column_sum[i],width = 0.08, color = colors[i], label=sub_name[i], )
w=w+0.09
plt.legend()
plt.grid(True)
plt.yscale('log')
plt.show()
#=======================================================================================================================
sim = df_1*1 + df_2*1 + df_3*1 + df_4*1 + df_5*1 + df_6*1 + df_7*1 + df_8*1
sim = sim[:, 1:]
unique, counts = np.unique(sim, return_counts=True)
#=======================================================================================================================
sum = df_1[:, 1:]*1 + \
df_2[:, 1:]*2 + \
df_3[:, 1:]*3 + \
df_4[:, 1:]*2 + \
df_5[:, 1:]*3 + \
df_6[:, 1:]*2 + \
df_7[:, 1:]*1 + \
df_8[:, 1:]*2
vote = 8 #7
#=======================================================================================================================
# Selecting most probable label for nan rows
#=======================================================================================================================
# sum_tmp = sum.copy()
# for i,row in enumerate(sum):
# #print (str(row))
# #print(max(row))
# #print(row.argmax(axis=0))
# row_max_idx = row.argmax(axis=0)
# if max(row)<vote:
# #row[row_max_idx] = vote
# sum[i,row_max_idx] = vote
# #print(str(row))
# diff = sum-sum_tmp
#=======================================================================================================================
vote_sub0 = np.where(sum[:,0] >= vote, 1, 0) #high
vote_sub1 = np.where(sum[:,1] >= vote, 1, 0)
vote_sub2 = np.where(sum[:,2] >= vote, 1, 0)
vote_sub3 = np.where(sum[:,3] >= vote, 1, 0)
vote_sub4 = np.where(sum[:,4] >= vote, 1, 0)
vote_sub5 = np.where(sum[:,5] >= vote, 1, 0)
vote_sub6 = np.where(sum[:,6] >= vote, 1, 0)
vote_sub7 = np.where(sum[:,7] >= vote, 1, 0)
vote_sub8 = np.where(sum[:,8] >= vote-2, 1, 0) #low
vote_sub9 = np.where(sum[:,9] >= vote-2, 1, 0) #low
vote_sub10 = np.where(sum[:,10] >= vote-2, 1, 0) #low
vote_sub11 = np.where(sum[:,11] >= vote, 1, 0)
vote_sub12 = np.where(sum[:,12] >= vote, 1, 0)
vote_sub13 = np.where(sum[:,13] >= vote, 1, 0)
vote_sub14 = np.where(sum[:,14] >= vote, 1, 0)
vote_sub15 = np.where(sum[:,15] >= vote-2, 1, 0) #low
vote_sub16 = np.where(sum[:,16] >= vote, 1, 0)
vote_sub17 = np.where(sum[:,17] >= vote, 1, 0)
vote_sub18 = np.where(sum[:,18] >= vote, 1, 0)
vote_sub19 = np.where(sum[:,19] >= vote, 1, 0)
vote_sub20 = np.where(sum[:,20] >= vote, 1, 0)
vote_sub21 = np.where(sum[:,21] >= vote, 1, 0)
vote_sub22 = np.where(sum[:,22] >= vote, 1, 0)
vote_sub23 = np.where(sum[:,23] >= vote, 1, 0)
vote_sub24 = np.where(sum[:,24] >= vote, 1, 0)
vote_sub25 = np.where(sum[:,25] >= vote, 1, 0) #high
vote_sub26 = np.where(sum[:,26] >= vote, 1, 0)
vote_sub27 = np.where(sum[:,27] >= vote-2, 1, 0) #low
vote_sub = np.column_stack((vote_sub0, vote_sub1, vote_sub2, vote_sub3,
vote_sub4, vote_sub5, vote_sub6, vote_sub7,
vote_sub8, vote_sub9, vote_sub10, vote_sub11,
vote_sub12, vote_sub13, vote_sub14, vote_sub15,
vote_sub16, vote_sub17, vote_sub18, vote_sub19,
vote_sub20, vote_sub21, vote_sub22, vote_sub23,
vote_sub24, vote_sub25, vote_sub26, vote_sub27)
)
#======================================================================================================================
# prepare submission format
#======================================================================================================================
submit = pd.read_csv(SAMPLE)
prediction = []
for row in tqdm(range(submit.shape[0])):
str_label = ''
for col in range(vote_sub.shape[1]):
if (vote_sub[row, col] < 1):
str_label += ''
else:
str_label += str(col) + ' '
prediction.append(str_label.strip())
submit['Predicted'] = np.array(prediction)
#submit.to_csv('sub_dir_team/39test_nonan_mostproba.csv', index=False)
submit.to_csv('sub_dir_team/enstw39c_low-2_1sh562_3ru616_2die580_2sh593_3dm627_2ke602_1l2.615updt_2die602_8.16_clswt.csv', index=False)
#=======================================================================================================================
| 40.782609
| 135
| 0.472948
|
7951b1f1ca811a0066b18d30dd81c51f8ab29a03
| 1,491
|
py
|
Python
|
discovery-provider/src/api/v1/models/activities.py
|
ppak10/audius-protocol
|
4dd9df787cbd39f86c5623ce7899b3855b7b314e
|
[
"Apache-2.0"
] | null | null | null |
discovery-provider/src/api/v1/models/activities.py
|
ppak10/audius-protocol
|
4dd9df787cbd39f86c5623ce7899b3855b7b314e
|
[
"Apache-2.0"
] | null | null | null |
discovery-provider/src/api/v1/models/activities.py
|
ppak10/audius-protocol
|
4dd9df787cbd39f86c5623ce7899b3855b7b314e
|
[
"Apache-2.0"
] | null | null | null |
from flask_restx import fields
from flask_restx.fields import MarshallingError
from flask_restx.marshalling import marshal
from .common import ns
from .tracks import track, track_full
from .playlists import playlist_model, full_playlist_model
class ItemType(fields.Raw):
def format(self, value):
if value == "track":
return "track"
if value == "playlist":
return "playlist"
raise MarshallingError("Unable to marshal as activity type")
class ActivityItem(fields.Raw):
def format(self, value):
try:
if value.get("track_id"):
return marshal(value, track)
if value.get("playlist_id"):
return marshal(value, playlist_model)
except:
raise MarshallingError("Unable to marshal as activity item")
class FullActivityItem(fields.Raw):
def format(self, value):
try:
if value.get("track_id"):
return marshal(value, track_full)
if value.get("playlist_id"):
return marshal(value, full_playlist_model)
except:
raise MarshallingError("Unable to marshal as activity item")
activity_model = ns.model("activity", {
"timestamp": fields.String(allow_null=True),
"item_type": ItemType,
"item": ActivityItem
})
activity_model_full = ns.model("activity_full", {
"timestamp": fields.String(allow_null=True),
"item_type": ItemType,
"item": FullActivityItem
})
| 31.0625
| 72
| 0.649229
|
7951b2972569a508049cd3e24ab316cb8be312f6
| 5,531
|
py
|
Python
|
samples/support_bundle_e2800.py
|
NetApp/santricity-webapi-pythonsdk
|
1d3df4a00561192f4cdcdd1890f4d27547ed2de2
|
[
"BSD-3-Clause-Clear"
] | 5
|
2016-08-23T17:52:22.000Z
|
2019-05-16T08:45:30.000Z
|
samples/support_bundle_e2800.py
|
NetApp/santricity-webapi-pythonsdk
|
1d3df4a00561192f4cdcdd1890f4d27547ed2de2
|
[
"BSD-3-Clause-Clear"
] | 2
|
2016-11-10T05:30:21.000Z
|
2019-04-05T15:03:37.000Z
|
samples/support_bundle_e2800.py
|
NetApp/santricity-webapi-pythonsdk
|
1d3df4a00561192f4cdcdd1890f4d27547ed2de2
|
[
"BSD-3-Clause-Clear"
] | 7
|
2016-08-25T16:11:44.000Z
|
2021-02-22T05:31:25.000Z
|
#!/bin/env python
"""
The Clear BSD License
Copyright (c) – 2016, NetApp, Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted (subject to the limitations in the disclaimer below) provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of NetApp, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""
import argparse
import sys
from time import sleep
from netapp.santricity.api_client import ApiClient
from netapp.santricity.configuration import Configuration
from netapp.santricity.api.v2.storage_systems_api import StorageSystemsApi
from netapp.santricity.api.v2.diagnostics_api import DiagnosticsApi
from netapp.santricity.api.v2.file_management_api import FileManagementApi
from netapp.santricity.models.v2.support_data_request import SupportDataRequest
from netapp.santricity.models.v2.support_data_response import SupportDataResponse
from netapp.santricity.rest import ApiException
import urllib3
import pprint
parser = argparse.ArgumentParser()
parser.add_argument(
'-p', '--proxy',
default="",
help="The base URL for the proxy. Ex. http://proxyhost.mydomain.com:8080")
parser.add_argument(
'-a', '--api',
default='v2',
help='Specify the API to use. Default="v2"')
parser.add_argument(
'--password',
default="rw",
help="The password to use for HTTP basic auth.")
parser.add_argument(
'--systemid',
default="",
help="Specify the system-id of the storage array.")
args = parser.parse_args()
if not args.proxy:
print("Missing mandatory argument (--proxy)")
sys.exit()
if not args.systemid:
print("Missing mandatory argument (-systemid)")
sys.exit()
# This will disable warnings for unverified HTTPS requests.
# This is not recommended, but added here to clean up output.
urllib3.disable_warnings()
# Create a configuration object and set the appropriate parameters
api_configuration = Configuration()
api_configuration.password = args.password
api_configuration.host = args.proxy
# For demonstration purposes, let's disable SSL verification
api_configuration.verify_ssl = False
# Now create the generic ApiClient object
# The ApiClient will utilize the Configuration object automatically
client = ApiClient()
# remove this prior to release
#print("client:\n{}".format(client.__dict__))
storage_api = StorageSystemsApi()
# remove this prior to release
#print("storage_api: \n{}".format(storage_api.__dict__))
diagnostics_api = DiagnosticsApi()
data_request = SupportDataRequest() # type, filename
data_request.type = "supportBundle"
data_request.filename = "sampledata"
try:
initial_response = diagnostics_api.start_support_data_retrieval_request(
args.systemid, body=data_request)
except ApiException:
print("An error occurred retrieving the support bundle.")
sys.exit()
print("Response from DiagnosticsApi.start_support_data_retrieval:\n")
pprint.pprint(initial_response)
# Now we need to wait a bit for the bundle to be generated
# Lets check on the status periodically so we know when it's done
try:
bundle_ready = False
while not bundle_ready:
request_status = diagnostics_api.get_support_data_retrieval_request_status(args.systemid, initial_response.request_id)
print("request complete percentage: {}".format(request_status.progress.percentage))
bundle_ready = request_status.progress.complete
sleep(5)
except ApiException:
print("An error occurred retrieving the support bundle.")
sys.exit()
# Now the bundle should be ready to download
# We can just download it, but let's verify the file is there first
file_api = FileManagementApi()
try:
file_list = file_api.get_scratch_file()
except ApiException:
print("Could not get the list of files")
sys.exit()
file_found = False
for file_info in file_list:
if file_info.file_name == data_request.filename:
print("The file was found on the proxy. Ready to download: {}".format(file_info.file_name))
file_found = True
if file_found:
try:
resp = file_api.get_file_from_scratch_dir(file_info.file_name, auto_delete=True)
print("Downloaded to file: {}".format(resp))
except ApiException:
print("Error getting file")
| 46.478992
| 843
| 0.775447
|
7951b2ba17ea407e089ab8a11dce9e9f3ac5b249
| 2,187
|
py
|
Python
|
upsplus_iot.py
|
mikvdw/upsplus
|
ed7e8eb1607e8dce6e3b3d1a19e315ec8cfe37a3
|
[
"MIT"
] | null | null | null |
upsplus_iot.py
|
mikvdw/upsplus
|
ed7e8eb1607e8dce6e3b3d1a19e315ec8cfe37a3
|
[
"MIT"
] | null | null | null |
upsplus_iot.py
|
mikvdw/upsplus
|
ed7e8eb1607e8dce6e3b3d1a19e315ec8cfe37a3
|
[
"MIT"
] | null | null | null |
# ''' Update the status of batteries to IoT platform '''
import time
import smbus
import requests
from ina219 import INA219,DeviceRangeError
import random
DEVICE_BUS = 1
DEVICE_ADDR = 0x17
PROTECT_VOLT = 3700
SAMPLE_TIME = 2
FEED_URL = "https://api.thekoziolfoundation.com/feed"
time.sleep(random.randint(0, 59))
DATA = dict()
ina = INA219(0.00725,address=0x40)
ina.configure()
DATA['PiVccVolt'] = ina.voltage()
DATA['PiIddAmps'] = ina.current()
ina = INA219(0.005,address=0x45)
ina.configure()
DATA['BatVccVolt'] = ina.voltage()
try:
DATA['BatIddAmps'] = ina.current()
except DeviceRangeError:
DATA['BatIddAmps'] = 16000
bus = smbus.SMBus(DEVICE_BUS)
aReceiveBuf = []
aReceiveBuf.append(0x00)
for i in range(1,255):
aReceiveBuf.append(bus.read_byte_data(DEVICE_ADDR, i))
DATA['McuVccVolt'] = aReceiveBuf[2] << 8 | aReceiveBuf[1]
DATA['BatPinCVolt'] = aReceiveBuf[6] << 8 | aReceiveBuf[5]
DATA['ChargeTypeCVolt'] = aReceiveBuf[8] << 8 | aReceiveBuf[7]
DATA['ChargeMicroVolt'] = aReceiveBuf[10] << 8 | aReceiveBuf[9]
DATA['BatTemperature'] = aReceiveBuf[12] << 8 | aReceiveBuf[11]
DATA['BatFullVolt'] = aReceiveBuf[14] << 8 | aReceiveBuf[13]
DATA['BatEmptyVolt'] = aReceiveBuf[16] << 8 | aReceiveBuf[15]
DATA['BatProtectVolt'] = aReceiveBuf[18] << 8 | aReceiveBuf[17]
DATA['SampleTime'] = aReceiveBuf[22] << 8 | aReceiveBuf[21]
DATA['AutoPowerOn'] = aReceiveBuf[24]
DATA['OnlineTime'] = aReceiveBuf[31] << 24 | aReceiveBuf[30] << 16 | aReceiveBuf[29] << 8 | aReceiveBuf[28]
DATA['FullTime'] = aReceiveBuf[35] << 24 | aReceiveBuf[34] << 16 | aReceiveBuf[33] << 8 | aReceiveBuf[32]
DATA['OneshotTime'] = aReceiveBuf[39] << 24 | aReceiveBuf[38] << 16 | aReceiveBuf[37] << 8 | aReceiveBuf[36]
DATA['Version'] = aReceiveBuf[41] << 8 | aReceiveBuf[40]
DATA['UID0'] = "%08X" % (aReceiveBuf[243] << 24 | aReceiveBuf[242] << 16 | aReceiveBuf[241] << 8 | aReceiveBuf[240])
DATA['UID1'] = "%08X" % (aReceiveBuf[247] << 24 | aReceiveBuf[246] << 16 | aReceiveBuf[245] << 8 | aReceiveBuf[244])
DATA['UID2'] = "%08X" % (aReceiveBuf[251] << 24 | aReceiveBuf[250] << 16 | aReceiveBuf[249] << 8 | aReceiveBuf[248])
print(DATA)
r = requests.post(FEED_URL, data=DATA)
print(r.text)
| 35.274194
| 116
| 0.689072
|
7951b3154ff3f8a2505bb163ecf39f166b71ed5e
| 464
|
py
|
Python
|
packages/selenium/galaxy/project_galaxy_selenium.py
|
ResearchObject/galaxy
|
39c7c3dfd417eb01d276e86046825bfea2208291
|
[
"CC-BY-3.0"
] | 4
|
2015-05-12T20:36:41.000Z
|
2017-06-26T15:34:02.000Z
|
packages/selenium/galaxy/project_galaxy_selenium.py
|
ResearchObject/galaxy
|
39c7c3dfd417eb01d276e86046825bfea2208291
|
[
"CC-BY-3.0"
] | 52
|
2015-03-16T14:02:14.000Z
|
2021-12-24T09:50:23.000Z
|
packages/selenium/galaxy/project_galaxy_selenium.py
|
ResearchObject/galaxy
|
39c7c3dfd417eb01d276e86046825bfea2208291
|
[
"CC-BY-3.0"
] | 1
|
2016-03-21T12:54:06.000Z
|
2016-03-21T12:54:06.000Z
|
# -*- coding: utf-8 -*-
__version__ = '20.9.1.dev0'
PROJECT_NAME = "galaxy-selenium"
PROJECT_OWNER = PROJECT_USERAME = "galaxyproject"
PROJECT_URL = "https://github.com/galaxyproject/galaxy"
PROJECT_AUTHOR = 'Galaxy Project and Community'
PROJECT_DESCRIPTION = 'Galaxy Selenium Interaction Framework'
PROJECT_EMAIL = 'galaxy-committers@lists.galaxyproject.org'
RAW_CONTENT_URL = "https://raw.github.com/{}/{}/master/".format(
PROJECT_USERAME, PROJECT_NAME
)
| 33.142857
| 64
| 0.760776
|
7951b36a5dcb9680cf37923754bb63e71302c311
| 6,040
|
py
|
Python
|
gui/api_call_renderers_test.py
|
patriotemeritus/grr
|
bf2b9268c8b9033ab091e27584986690438bd7c3
|
[
"Apache-2.0"
] | 1
|
2016-02-13T15:40:20.000Z
|
2016-02-13T15:40:20.000Z
|
gui/api_call_renderers_test.py
|
patriotemeritus/grr
|
bf2b9268c8b9033ab091e27584986690438bd7c3
|
[
"Apache-2.0"
] | 3
|
2020-02-11T22:29:15.000Z
|
2021-06-10T17:44:31.000Z
|
gui/api_call_renderers_test.py
|
wandec/grr
|
7fb7e6d492d1325a5fe1559d3aeae03a301c4baa
|
[
"Apache-2.0"
] | null | null | null |
#!/usr/bin/env python
"""Tests for API call renderers."""
# pylint: disable=unused-import,g-bad-import-order
from grr.lib import server_plugins
# pylint: enable=unused-import,g-bad-import-order
import json
from grr.gui import api_aff4_object_renderers
from grr.gui import api_call_renderers
from grr.lib import flags
from grr.lib import rdfvalue
from grr.lib import registry
from grr.lib import test_lib
from grr.lib import utils
from grr.proto import tests_pb2
class SampleGetRendererArgs(rdfvalue.RDFProtoStruct):
protobuf = tests_pb2.SampleGetRendererArgs
class SampleGetRenderer(api_call_renderers.ApiCallRenderer):
args_type = SampleGetRendererArgs
def Render(self, args, token=None):
return {
"method": "GET",
"path": args.path,
"foo": args.foo
}
class SampleGetRendererWithAdditionalArgsArgs(rdfvalue.RDFProtoStruct):
protobuf = tests_pb2.SampleGetRendererWithAdditionalArgsArgs
class SampleGetRendererWithAdditionalArgs(api_call_renderers.ApiCallRenderer):
args_type = SampleGetRendererWithAdditionalArgsArgs
additional_args_types = {
"AFF4Object": api_aff4_object_renderers.ApiAFF4ObjectRendererArgs,
"RDFValueCollection": (api_aff4_object_renderers.
ApiRDFValueCollectionRendererArgs)
}
def Render(self, args, token=None):
result = {
"method": "GET",
"path": args.path,
"foo": args.foo
}
if args.additional_args:
rendered_additional_args = []
for arg in args.additional_args:
rendered_additional_args.append(str(arg))
result["additional_args"] = rendered_additional_args
return result
class TestHttpRoutingInit(registry.InitHook):
def RunOnce(self):
api_call_renderers.RegisterHttpRouteHandler(
"GET", "/test_sample/<path:path>", SampleGetRenderer)
api_call_renderers.RegisterHttpRouteHandler(
"GET", "/test_sample_with_additional_args/<path:path>",
SampleGetRendererWithAdditionalArgs)
class RenderHttpResponseTest(test_lib.GRRBaseTest):
"""Test for api_call_renderers.RenderHttpResponse logic."""
def _CreateRequest(self, method, path, query_parameters=None):
if not query_parameters:
query_parameters = {}
request = utils.DataObject()
request.method = method
request.path = path
request.scheme = "http"
request.environ = {
"SERVER_NAME": "foo.bar",
"SERVER_PORT": 1234
}
request.user = "test"
if method == "GET":
request.GET = query_parameters
request.META = {}
return request
def _RenderResponse(self, request):
response = api_call_renderers.RenderHttpResponse(request)
if response.content.startswith(")]}'\n"):
response.content = response.content[5:]
return response
def testReturnsRendererMatchingUrlAndMethod(self):
renderer, _ = api_call_renderers.GetRendererForHttpRequest(
self._CreateRequest("GET", "/test_sample/some/path"))
self.assertTrue(isinstance(renderer, SampleGetRenderer))
def testPathParamsAreReturnedWithMatchingRenderer(self):
_, path_params = api_call_renderers.GetRendererForHttpRequest(
self._CreateRequest("GET", "/test_sample/some/path"))
self.assertEqual(path_params, {"path": "some/path"})
def testRaisesIfNoRendererMatchesUrl(self):
self.assertRaises(api_call_renderers.ApiCallRendererNotFoundError,
api_call_renderers.GetRendererForHttpRequest,
self._CreateRequest("GET",
"/some/missing/path"))
def testRendersGetRendererCorrectly(self):
response = self._RenderResponse(
self._CreateRequest("GET", "/test_sample/some/path"))
self.assertEqual(
json.loads(response.content),
{"method": "GET",
"path": "some/path",
"foo": ""})
self.assertEqual(response.status_code, 200)
def testQueryParamsArePassedIntoRendererArgs(self):
response = self._RenderResponse(
self._CreateRequest("GET", "/test_sample/some/path",
query_parameters={"foo": "bar"}))
self.assertEqual(
json.loads(response.content),
{"method": "GET",
"path": "some/path",
"foo": "bar"})
def testRouteArgumentTakesPrecedenceOverQueryParams(self):
response = self._RenderResponse(
self._CreateRequest("GET", "/test_sample/some/path",
query_parameters={"path": "foobar"}))
self.assertEqual(
json.loads(response.content),
{"method": "GET",
"path": "some/path",
"foo": ""})
def testAdditionalArgumentsAreParsedCorrectly(self):
additional_args = api_call_renderers.FillAdditionalArgsFromRequest(
{"AFF4Object.limit_lists": "10",
"RDFValueCollection.with_total_count": "1"},
{"AFF4Object": rdfvalue.ApiAFF4ObjectRendererArgs,
"RDFValueCollection": rdfvalue.ApiRDFValueCollectionRendererArgs})
additional_args = sorted(additional_args, key=lambda x: x.name)
self.assertListEqual(
[x.name for x in additional_args],
["AFF4Object", "RDFValueCollection"])
self.assertListEqual(
[x.type for x in additional_args],
["ApiAFF4ObjectRendererArgs", "ApiRDFValueCollectionRendererArgs"])
self.assertListEqual(
[x.args for x in additional_args],
[rdfvalue.ApiAFF4ObjectRendererArgs(limit_lists=10),
rdfvalue.ApiRDFValueCollectionRendererArgs(with_total_count=True)])
def testAdditionalArgumentsAreFoundAndPassedToTheRenderer(self):
response = self._RenderResponse(
self._CreateRequest("GET",
"/test_sample_with_additional_args/some/path",
query_parameters={"foo": "42"}))
self.assertEqual(
json.loads(response.content),
{"method": "GET",
"path": "some/path",
"foo": "42"})
def main(argv):
test_lib.main(argv)
if __name__ == "__main__":
flags.StartMain(main)
| 31.458333
| 78
| 0.684768
|
7951b42058e49f9a08ad63854c58dd040cdaa90f
| 4,322
|
py
|
Python
|
tests/integration/elasticsearch_/test_instrumented_transport.py
|
hackerrdave/signalfx-python-tracing
|
55f50c7b71cea642bb18733e452988a32f899fbb
|
[
"Apache-2.0"
] | null | null | null |
tests/integration/elasticsearch_/test_instrumented_transport.py
|
hackerrdave/signalfx-python-tracing
|
55f50c7b71cea642bb18733e452988a32f899fbb
|
[
"Apache-2.0"
] | null | null | null |
tests/integration/elasticsearch_/test_instrumented_transport.py
|
hackerrdave/signalfx-python-tracing
|
55f50c7b71cea642bb18733e452988a32f899fbb
|
[
"Apache-2.0"
] | null | null | null |
# Copyright (C) 2019 SignalFx, Inc. All rights reserved.
from time import sleep
from opentracing.mocktracer import MockTracer
import elasticsearch
import docker
import pytest
from signalfx_tracing.libraries import elasticsearch_config
from signalfx_tracing import instrument, uninstrument
from tests.utils import random_int
@pytest.fixture(scope='session')
def elasticsearch_container(request):
es_version = request.config.getoption('--elasticsearch-image-version', '6.5.4')
docker_client = docker.from_env()
es_container = docker_client.containers.run('elasticsearch:{}'.format(es_version),
ports={'9200/tcp': 9200}, detach=True)
try:
es_client = elasticsearch.Elasticsearch()
for i in range(60):
try:
if es_client.ping():
break
except elasticsearch.ConnectionError:
pass
if i == 59:
raise RuntimeError('Failed to connect to Elasticsearch.')
sleep(.5)
yield es_container
finally:
es_container.remove(v=True, force=True)
class TestElasticsearch(object):
@pytest.fixture
def tracer(self, elasticsearch_container):
yield MockTracer()
@pytest.fixture
def instrumented_elasticsearch(self, tracer):
elasticsearch_config.prefix = 'MyPrefix'
yield instrument(tracer, elasticsearch=True)
uninstrument('elasticsearch')
@pytest.fixture
def tracer_and_elasticsearch(self, tracer):
return tracer, elasticsearch.Elasticsearch()
@pytest.fixture
def tracer_and_elasticsearch_transport(self, tracer):
return tracer, elasticsearch.Elasticsearch(transport=elasticsearch.Transport)
@pytest.fixture
def tracer_and_elasticsearch_transport_transport(self, tracer):
import elasticsearch.transport # must be imported after auto-instrumentation
return tracer, elasticsearch.Elasticsearch(transport=elasticsearch.transport.Transport)
@pytest.fixture(params=('tracer_and_elasticsearch', 'tracer_and_elasticsearch_transport',
'tracer_and_elasticsearch_transport_transport'))
def tracer_and_client(self, request, instrumented_elasticsearch):
yield request.getfixturevalue(request.param)
@pytest.fixture(params=('tracer_and_elasticsearch', 'tracer_and_elasticsearch_transport',
'tracer_and_elasticsearch_transport_transport'))
def tracer_and_uninstrumented_client(self, request):
uninstrument('elasticsearch')
yield request.getfixturevalue(request.param)
def test_uninstrumented_not_traced(self, instrumented_elasticsearch, tracer_and_uninstrumented_client):
tracer, es = tracer_and_uninstrumented_client
doc_id = random_int(0)
body = dict(lorem='ipsum' * 1024)
index = es.index(index='some-index', doc_type='some-doc-type', id=doc_id, body=body, params={'refresh': 'true'})
doc_id = str(doc_id)
assert index['_id'] == doc_id
assert index.get('result') == 'created' or index.get('created')
lorem = es.get(index='some-index', doc_type='some-doc-type', id=doc_id)
assert lorem['_id'] == doc_id
assert lorem['_source'] == body
assert not tracer.finished_spans()
def test_add_and_get_document(self, tracer_and_client):
tracer, es = tracer_and_client
doc_id = random_int(0)
body = dict(lorem='ipsum' * 1024)
index = es.index(index='some-index', doc_type='some-doc-type', id=doc_id, body=body, params={'refresh': 'true'})
doc_id = str(doc_id)
assert index['_id'] == doc_id
assert index.get('result') == 'created' or index.get('created')
lorem = es.get(index='some-index', doc_type='some-doc-type', id=doc_id)
assert lorem['_id'] == doc_id
assert lorem['_source'] == body
spans = tracer.finished_spans()
assert len(spans) == 2
expected_url = '/some-index/some-doc-type/{}'.format(doc_id)
for span in spans:
assert span.operation_name == 'MyPrefix{}'.format(expected_url)
assert span.tags['elasticsearch.url'] == expected_url
assert span.tags['component'] == 'elasticsearch-py'
| 39.651376
| 120
| 0.672374
|
7951b4404d2cd43ac27f6dca90ac4e07079e7a85
| 445
|
py
|
Python
|
examples/scripts/ephemeris/create_ephemeris_search_object.py
|
fossabot/pyaurorax
|
cb3e72a90f3107302d4f9fd4b0478fe98616354d
|
[
"MIT"
] | null | null | null |
examples/scripts/ephemeris/create_ephemeris_search_object.py
|
fossabot/pyaurorax
|
cb3e72a90f3107302d4f9fd4b0478fe98616354d
|
[
"MIT"
] | 45
|
2021-11-07T22:02:23.000Z
|
2022-03-09T03:04:27.000Z
|
examples/scripts/ephemeris/create_ephemeris_search_object.py
|
fossabot/pyaurorax
|
cb3e72a90f3107302d4f9fd4b0478fe98616354d
|
[
"MIT"
] | 1
|
2022-01-16T17:28:14.000Z
|
2022-01-16T17:28:14.000Z
|
import pyaurorax
import datetime
def main():
s = pyaurorax.ephemeris.Search(datetime.datetime(2020, 1, 1, 0, 0, 0),
datetime.datetime(2020, 1, 10, 0, 0, 0),
programs=["swarm"],
platforms=["swarma"],
instrument_types=["footprint"])
print(s)
# ----------
if (__name__ == "__main__"):
main()
| 26.176471
| 75
| 0.433708
|
7951b4b6ae21ff2178d25af72fd97064f4c48c3f
| 6,656
|
py
|
Python
|
benchmarks/f3_wrong_hints/scaling_ltl_infinite_state/5-extending_bound_20.py
|
EnricoMagnago/F3
|
c863215c318d7d5f258eb9be38c6962cf6863b52
|
[
"MIT"
] | 3
|
2021-04-23T23:29:26.000Z
|
2022-03-23T10:00:30.000Z
|
benchmarks/f3_wrong_hints/scaling_ltl_infinite_state/5-extending_bound_20.py
|
EnricoMagnago/F3
|
c863215c318d7d5f258eb9be38c6962cf6863b52
|
[
"MIT"
] | null | null | null |
benchmarks/f3_wrong_hints/scaling_ltl_infinite_state/5-extending_bound_20.py
|
EnricoMagnago/F3
|
c863215c318d7d5f258eb9be38c6962cf6863b52
|
[
"MIT"
] | 1
|
2021-11-17T22:02:56.000Z
|
2021-11-17T22:02:56.000Z
|
from typing import Tuple, FrozenSet
from collections import Iterable
from mathsat import msat_term, msat_env
from mathsat import msat_make_constant, msat_declare_function
from mathsat import msat_get_integer_type, msat_get_rational_type, msat_get_bool_type
from mathsat import msat_make_and, msat_make_not, msat_make_or
from mathsat import msat_make_leq, msat_make_equal
from mathsat import msat_make_number, msat_make_plus
from pysmt.environment import Environment as PysmtEnv
import pysmt.typing as types
from ltl.ltl import TermMap, LTLEncoder
from utils import name_next, symb_to_next
from hint import Hint, Location
def msat_make_lt(menv: msat_env, arg0: msat_term, arg1: msat_term):
geq = msat_make_geq(menv, arg0, arg1)
return msat_make_not(menv, geq)
def msat_make_geq(menv: msat_env, arg0: msat_term, arg1: msat_term):
return msat_make_leq(menv, arg1, arg0)
def msat_make_gt(menv: msat_env, arg0: msat_term, arg1: msat_term):
leq = msat_make_leq(menv, arg0, arg1)
return msat_make_not(menv, leq)
def msat_make_impl(menv: msat_env, arg0: msat_term, arg1: msat_term):
n_arg0 = msat_make_not(menv, arg0)
return msat_make_or(menv, n_arg0, arg1)
def check_ltl(menv: msat_env, enc: LTLEncoder) -> Tuple[Iterable, msat_term,
msat_term, msat_term]:
assert menv
assert isinstance(menv, msat_env)
assert enc
assert isinstance(enc, LTLEncoder)
bool_type = msat_get_bool_type(menv)
real_type = msat_get_rational_type(menv)
i = msat_declare_function(menv, "i", real_type)
i = msat_make_constant(menv, i)
r = msat_declare_function(menv, "r", real_type)
r = msat_make_constant(menv, r)
l = msat_declare_function(menv, "l", real_type)
l = msat_make_constant(menv, l)
inc_i = msat_declare_function(menv, "inc_i", bool_type)
inc_i = msat_make_constant(menv, inc_i)
x_i = msat_declare_function(menv, name_next("i"), real_type)
x_i = msat_make_constant(menv, x_i)
x_r = msat_declare_function(menv, name_next("r"), real_type)
x_r = msat_make_constant(menv, x_r)
x_l = msat_declare_function(menv, name_next("l"), real_type)
x_l = msat_make_constant(menv, x_l)
x_inc_i = msat_declare_function(menv, name_next("inc_i"), bool_type)
x_inc_i = msat_make_constant(menv, x_inc_i)
curr2next = {i: x_i, r: x_r, l: x_l, inc_i: x_inc_i}
zero = msat_make_number(menv, "0")
one = msat_make_number(menv, "1")
r_gt_0 = msat_make_gt(menv, r, zero)
r_lt_l = msat_make_lt(menv, r, l)
i_geq_0 = msat_make_geq(menv, i, zero)
init = msat_make_and(menv, r_gt_0, r_lt_l)
init = msat_make_and(menv, init,
msat_make_and(menv, i_geq_0,
msat_make_not(menv, inc_i)))
init = msat_make_and(menv, init, msat_make_gt(menv, l, zero))
# r' = r
trans = msat_make_equal(menv, x_r, r)
# i < l -> ((inc_i' & i' = i + 1) | (!inc_i' & i' = i)) & l' = l
i_lt_l = msat_make_lt(menv, i, l)
x_i_eq_i_p_1 = msat_make_and(menv, x_inc_i,
msat_make_equal(menv, x_i,
msat_make_plus(menv, i, one)))
x_i_eq_i = msat_make_and(menv, msat_make_not(menv, x_inc_i),
msat_make_equal(menv, x_i, i))
x_i_eq_i_p_1_or_i = msat_make_or(menv, x_i_eq_i_p_1, x_i_eq_i)
x_l_eq_l = msat_make_equal(menv, x_l, l)
x_i_eq_i_p_1_or_i_and_x_l_eq_l = msat_make_and(menv, x_i_eq_i_p_1_or_i,
x_l_eq_l)
trans = msat_make_and(menv, trans,
msat_make_impl(menv, i_lt_l,
x_i_eq_i_p_1_or_i_and_x_l_eq_l))
# i >= l -> i' = 0 & l' = l + 1 & !inc_i'
i_geq_l = msat_make_geq(menv, i, l)
x_i_eq_0 = msat_make_equal(menv, x_i, zero)
x_l_eq_l_p_1 = msat_make_equal(menv, x_l, msat_make_plus(menv, l, one))
x_i_eq_0_and_x_l_eq_l_p_1 = msat_make_and(menv,
msat_make_and(menv, x_i_eq_0,
x_l_eq_l_p_1),
msat_make_not(menv, x_inc_i))
trans = msat_make_and(menv, trans,
msat_make_impl(menv, i_geq_l,
x_i_eq_0_and_x_l_eq_l_p_1))
# (G F inc_i) -> ! G F r > i
G_F_x_i_gt_i = enc.make_G(enc.make_F(inc_i))
r_gt_i = msat_make_gt(menv, r, i)
n_G_F_r_gt_i = msat_make_not(menv, enc.make_G(enc.make_F(r_gt_i)))
ltl = msat_make_impl(menv, G_F_x_i_gt_i, n_G_F_r_gt_i)
return TermMap(curr2next), init, trans, ltl
def hints(env: PysmtEnv) -> FrozenSet[Hint]:
assert isinstance(env, PysmtEnv)
mgr = env.formula_manager
i = mgr.Symbol("i", types.REAL)
r = mgr.Symbol("r", types.REAL)
l = mgr.Symbol("l", types.REAL)
inc_i = mgr.Symbol("inc_i", types.BOOL)
symbs = frozenset([i, r, l, inc_i])
x_i = symb_to_next(mgr, i)
x_r = symb_to_next(mgr, r)
x_l = symb_to_next(mgr, l)
x_inc_i = symb_to_next(mgr, inc_i)
res = []
n0 = mgr.Real(0)
n1 = mgr.Real(1)
loc = Location(env, mgr.GE(l, n0))
loc.set_progress(0, mgr.Equals(x_l, mgr.Plus(l, n1)))
h_l = Hint("h_l0", env, frozenset([l]), symbs)
h_l.set_locs([loc])
res.append(h_l)
loc = Location(env, mgr.LE(r, n0))
loc.set_progress(0, mgr.Equals(x_r, mgr.Minus(r, n1)))
h_r = Hint("h_r1", env, frozenset([r]), symbs)
h_r.set_locs([loc])
res.append(h_r)
loc0 = Location(env, mgr.GE(r, n0))
loc0.set_progress(1, mgr.Equals(x_r, r))
loc1 = Location(env, mgr.GE(r, n0))
loc1.set_progress(0, mgr.Equals(x_r, mgr.Plus(r, n1)))
h_r = Hint("h_r2", env, frozenset([r]), symbs)
h_r.set_locs([loc0, loc1])
res.append(h_r)
loc0 = Location(env, mgr.GE(i, n0), mgr.GE(l, n0),
stutterT=mgr.Equals(x_i, mgr.Plus(i, l)))
loc0.set_progress(1, mgr.Equals(x_i, mgr.Plus(i, n1)))
loc1 = Location(env, mgr.GE(i, n0))
loc1.set_progress(0, mgr.Equals(x_i, i))
h_i = Hint("h_i3", env, frozenset([i]), symbs)
h_i.set_locs([loc0, loc1])
res.append(h_i)
loc0 = Location(env, mgr.GE(r, n0), mgr.GE(i, n0),
stutterT=mgr.Equals(x_r, mgr.Plus(r, i)))
loc0.set_progress(1, mgr.Equals(x_r, r))
loc1 = Location(env, mgr.GE(r, n0))
loc1.set_progress(0, mgr.Equals(x_r, mgr.Plus(r, n1)))
h_r = Hint("h_r3", env, frozenset([r]), symbs)
h_r.set_locs([loc0, loc1])
res.append(h_r)
return frozenset(res)
| 37.60452
| 89
| 0.626953
|
7951b517a5289981266695286b89a65a6cd610c2
| 3,906
|
py
|
Python
|
fabtools/python_setuptools.py
|
hagai26/fabtools
|
2992546df965892acafe34895251012a74a51611
|
[
"BSD-2-Clause"
] | 1
|
2016-02-12T02:05:41.000Z
|
2016-02-12T02:05:41.000Z
|
fabtools/python_setuptools.py
|
datascopeanalytics/fabtools
|
430073d2b1d8a61ec11fef2aff57ded4c505681f
|
[
"BSD-2-Clause"
] | null | null | null |
fabtools/python_setuptools.py
|
datascopeanalytics/fabtools
|
430073d2b1d8a61ec11fef2aff57ded4c505681f
|
[
"BSD-2-Clause"
] | 1
|
2020-10-26T15:03:37.000Z
|
2020-10-26T15:03:37.000Z
|
"""
Python packages
===============
This module provides tools for installing Python packages using
the ``easy_install`` command provided by `setuptools`_.
.. _setuptools: http://pythonhosted.org/setuptools/
"""
from fabric.api import cd, run
from fabtools.utils import download, run_as_root
EZ_SETUP_URL = 'https://bootstrap.pypa.io/ez_setup.py'
def package_version(name, python_cmd='python'):
"""
Get the installed version of a package
Returns ``None`` if it can't be found.
"""
cmd = '''%(python_cmd)s -c \
"import pkg_resources;\
dist = pkg_resources.get_distribution('%(name)s');\
print dist.version"
''' % locals()
res = run(cmd, quiet=True)
if res.succeeded:
return res
else:
return None
def is_setuptools_installed(python_cmd='python'):
"""
Check if `setuptools`_ is installed.
.. _setuptools: http://pythonhosted.org/setuptools/
"""
version = package_version('setuptools', python_cmd=python_cmd)
return (version is not None)
def install_setuptools(python_cmd='python', use_sudo=True):
"""
Install the latest version of `setuptools`_.
::
import fabtools
fabtools.python_setuptools.install_setuptools()
"""
setuptools_version = package_version('setuptools', python_cmd)
distribute_version = package_version('distribute', python_cmd)
if setuptools_version is None:
_install_from_scratch(python_cmd, use_sudo)
else:
if distribute_version is None:
_upgrade_from_setuptools(python_cmd, use_sudo)
else:
_upgrade_from_distribute(python_cmd, use_sudo)
def _install_from_scratch(python_cmd, use_sudo):
"""
Install setuptools from scratch using installer
"""
with cd("/tmp"):
download(EZ_SETUP_URL)
command = '%(python_cmd)s ez_setup.py' % locals()
if use_sudo:
run_as_root(command)
else:
run(command)
run('rm -f ez_setup.py')
def _upgrade_from_setuptools(python_cmd, use_sudo):
"""
Upgrading from setuptools 0.6 to 0.7+ is supported
"""
_easy_install(['-U', 'setuptools'], python_cmd, use_sudo)
def _upgrade_from_distribute(python_cmd, use_sudo):
"""
Upgrading from distribute 0.6 to setuptools 0.7+ directly is not
supported. We need to upgrade distribute to version 0.7, which is
a dummy package acting as a wrapper to install setuptools 0.7+.
"""
_easy_install(['-U', 'distribute'], python_cmd, use_sudo)
def install(packages, upgrade=False, use_sudo=False, python_cmd='python'):
"""
Install Python packages with ``easy_install``.
Examples::
import fabtools
# Install a single package
fabtools.python_setuptools.install('package', use_sudo=True)
# Install a list of packages
fabtools.python_setuptools.install(['pkg1', 'pkg2'], use_sudo=True)
.. note:: most of the time, you'll want to use
:py:func:`fabtools.python.install()` instead,
which uses ``pip`` to install packages.
"""
argv = []
if upgrade:
argv.append("-U")
if isinstance(packages, basestring):
argv.append(packages)
else:
argv.extend(packages)
_easy_install(argv, python_cmd, use_sudo)
def _easy_install(argv, python_cmd, use_sudo):
"""
Install packages using easy_install
We don't know if the easy_install command in the path will be the
right one, so we use the setuptools entry point to call the script's
main function ourselves.
"""
command = """python -c "\
from pkg_resources import load_entry_point;\
ez = load_entry_point('setuptools', 'console_scripts', 'easy_install');\
ez(argv=%(argv)r)\
""" % locals()
if use_sudo:
run_as_root(command)
else:
run(command)
| 25.86755
| 80
| 0.651562
|
7951b73a28ca6cdaa1b4e8686651217e6bdcd281
| 58
|
py
|
Python
|
basic/loops/for_list.py
|
robertob45/learning-python
|
7407f7d9e513792150eb2b65ebc644b5f8632c56
|
[
"MIT"
] | null | null | null |
basic/loops/for_list.py
|
robertob45/learning-python
|
7407f7d9e513792150eb2b65ebc644b5f8632c56
|
[
"MIT"
] | null | null | null |
basic/loops/for_list.py
|
robertob45/learning-python
|
7407f7d9e513792150eb2b65ebc644b5f8632c56
|
[
"MIT"
] | null | null | null |
list = [1,2,3,4,5,6,7,8,9,10]
for x in list:
print(x)
| 14.5
| 29
| 0.534483
|
7951b7aad1464d5f384bc7bf47476b78b4327858
| 845
|
py
|
Python
|
4 fuzzy distances.py
|
satyarth42/Soft-computing-lab
|
0142332e8c17d358c3518cd2bdfef1f74b1a340d
|
[
"MIT"
] | null | null | null |
4 fuzzy distances.py
|
satyarth42/Soft-computing-lab
|
0142332e8c17d358c3518cd2bdfef1f74b1a340d
|
[
"MIT"
] | null | null | null |
4 fuzzy distances.py
|
satyarth42/Soft-computing-lab
|
0142332e8c17d358c3518cd2bdfef1f74b1a340d
|
[
"MIT"
] | null | null | null |
import numpy as np
a = [x for x in input().split(" ")]
b = [x for x in input().split(" ")]
d_a = {}
d_b = {}
for x in a:
x = x.split(',')
d_a[int(x[0])]=float(x[1])
for x in b:
x = x.split(',')
d_b[int(x[0])]=float(x[1])
print("set A "+str(d_a))
print("set B "+str(d_b))
hamming_dist = 0.0
euclidean_dist = 0.0
for x in d_a.keys():
if x in d_b.keys():
hamming_dist+=(abs(d_a[x]-d_b[x]))
euclidean_dist+=((d_a[x]-d_b[x])**2)
else:
hamming_dist+=d_a[x]
euclidean_dist+=(d_a[x]**2)
for x in d_b.keys():
if x not in d_a.keys():
hamming_dist+=d_b[x]
euclidean_dist+=(d_b[x]**2)
euclidean_dist = np.sqrt(euclidean_dist)
print("Hamming distance: "+str(hamming_dist))
print("Euclidean distance: "+str(euclidean_dist))
| 22.837838
| 50
| 0.539645
|
7951b7b6e428e1455dc65523fa2df7293140543f
| 1,998
|
py
|
Python
|
twsyncer/main.py
|
sorrowless/twsyncer
|
ed46ebf0075f4fe663d1b3c17e7c48f78602b1a7
|
[
"Apache-2.0"
] | 1
|
2021-09-17T15:21:16.000Z
|
2021-09-17T15:21:16.000Z
|
twsyncer/main.py
|
sorrowless/twsyncer
|
ed46ebf0075f4fe663d1b3c17e7c48f78602b1a7
|
[
"Apache-2.0"
] | 1
|
2022-01-18T14:25:48.000Z
|
2022-01-21T22:00:54.000Z
|
twsyncer/main.py
|
sorrowless/twsyncer
|
ed46ebf0075f4fe663d1b3c17e7c48f78602b1a7
|
[
"Apache-2.0"
] | 1
|
2022-01-18T14:26:12.000Z
|
2022-01-18T14:26:12.000Z
|
from .config import load_config
from .ghub import GithubWorker
from .twarrior import TaskWarriorWorker
from .worker import Worker
import os
def main():
config = load_config()
if not config:
dry_run = os.environ.get("TW_DRY_RUN", True)
# Actually you getting str from env, let's roughly convert it
dry_run = False if dry_run == "False" else True
token = os.environ.get("TW_GITHUB_TOKEN", False)
org_login = os.environ.get("TW_GITHUB_ORG_LOGIN", "")
project_name = os.environ.get("TW_GITHUB_PROJECT", "")
issues_repo_name = os.environ.get("TW_GITHUB_ISSUES_REPO", "")
tw_filter_project = os.environ.get("TW_FILTER_PROJECT", "")
else:
dry_run = config.get("dry_run", True)
dry_run = False if dry_run == "False" else True
token = config.get("token", False)
org_login = config.get("org_login", False)
project_name = config.get("project_name", False)
issues_repo_name = config.get("issues_repo", False)
tw_filter_project = config.get("tw_filter_project", False)
# We somehow should map Github project columns to states in Taskwarrior. We
# could use UDA but actually it is way easier to use some mapping to the
# existing in Taskwarrior states
tw_to_github_states = {
"pending": ["Backlog", "To do"],
"active": ["In progress"],
"completed": ["Done", "Cancelled", "Feedback Needed"],
}
gh_worker = GithubWorker(
dry_run=dry_run,
token=token,
org_login=org_login,
project_name=project_name,
issues_repo_name=issues_repo_name,
)
gh_worker.initialize()
gh_worker.get_issues()
gh_worker.set_states_mapping(tw_to_github_states)
# Now start working with taskwarrior
tw_worker = TaskWarriorWorker(filter_project=tw_filter_project)
tw_worker.initialize()
worker = Worker(gh_worker, tw_worker)
worker.resolve()
if __name__ == "__main__":
main()
| 33.864407
| 79
| 0.668669
|
7951b7c363df98996e9e2fc8b043df7078d7fc3d
| 6,119
|
py
|
Python
|
Source/sgc/widgets/switch.py
|
tvenissat/CSCI-413-A-Team-FooBar-Project-01
|
53240fea5b4e2a1f688083d2a7fe9cd40827bb0d
|
[
"MIT"
] | null | null | null |
Source/sgc/widgets/switch.py
|
tvenissat/CSCI-413-A-Team-FooBar-Project-01
|
53240fea5b4e2a1f688083d2a7fe9cd40827bb0d
|
[
"MIT"
] | null | null | null |
Source/sgc/widgets/switch.py
|
tvenissat/CSCI-413-A-Team-FooBar-Project-01
|
53240fea5b4e2a1f688083d2a7fe9cd40827bb0d
|
[
"MIT"
] | 1
|
2019-10-30T20:44:35.000Z
|
2019-10-30T20:44:35.000Z
|
# Copyright 2010-2012 the SGC project developers.
# See the LICENSE file at the top-level directory of this distribution
# and at http://program.sambull.org/sgc/license.html.
"""
Switch widget, allows the user to change a boolean setting.
"""
import pygame
from pygame.locals import *
from pygame import display, draw
from _locals import *
from _locals import focus
from base_widget import Simple
class Switch(Simple):
"""
A switch widget, allowing the user to select between two states.
Attributes:
state: True if switched on.
Images:
'image': The background when the widget is set to off.
'active': The background when the widget is set to on.
'handle': The image used for the slider.
"""
_can_focus = True
_default_size = (85,26)
_available_images = ("active",)
_extra_images = {"handle": ((0.5, -4), (1, -4))}
_settings_default = {"state": False, "on_col": (88, 158, 232),
"off_col": (191, 191, 186),
"on_label_col": (255,255,255),
"off_label_col": (93,82,80)}
_drag = None
_handle_rect = None
def _config(self, **kwargs):
"""
state: ``bool`` Sets the state of the widget (False by default).
on_col: ``tuple`` (r,g,b) The background colour when the widget is
set to the 'on' state.
off_col: ``tuple`` (r,g,b) The background colour when the widget is
set to the 'off' state.
on_label_col: ``tuple`` (r,g,b) The on/off text colour when the
widget is set to the 'on' state.
off_label_col: ``tuple`` (r,g,b) The on/off text colour when the
widget is set to the 'off' state.
"""
if "init" in kwargs:
self._images["handle"].rect.y = 2
if "state" in kwargs:
self._settings["state"] = bool(kwargs["state"])
for key in ("on_col", "off_col", "on_label_col", "off_label_col"):
if key in kwargs:
self._settings[key] = kwargs[key]
def on_click(self):
"""
Called when the switch widget is clicked by mouse or keyboard.
Emits an event with attribute 'gui_type' == "click" and
'on' == (True or False) depending on whether the switch is set to
the on position or not.
Override this function to use as a callback handler.
"""
pygame.event.post(self._create_event("click", on=self.state))
def _draw_base(self):
# Draw main images
for state in ("off", "on"):
image = "image" if (state == "off") else "active"
self._images[image].fill(self._settings[state + "_col"])
# Render the labels
col = self._settings[state + "_label_col"]
on = Simple(Font["widget"].render("ON", True, col))
off = Simple(Font["widget"].render("OFF", True, col))
on.rect.center = (self.rect.w*.25 - 1, self.rect.h/2)
off.rect.center = (self.rect.w*.75 + 1, self.rect.h/2)
# Blit all text
self._images[image].blit(on.image, on.pos)
self._images[image].blit(off.image, off.pos)
def _draw_handle(self, image, size):
# Draw handle
image.fill((245,245,244))
w,h = size
for x in range(2,5): # Grips
draw.line(image, (227,227,224), ((w/6)*x, h*.3), ((w/6)*x, h*.7), 3)
def _event(self, event):
if event.type == MOUSEBUTTONDOWN and event.button == 1:
# If clicking handle
if self._images["handle"].rect.collidepoint(
(event.pos[0]-self.pos_abs[0], event.pos[1]-self.pos_abs[1])):
self._drag = (event.pos[0],
event.pos[0] - self._images["handle"].rect.x)
elif event.type == MOUSEMOTION and event.buttons[0]:
if self._drag is not None:
# Move handle
self._images["handle"].rect.x = max(min(
self.rect.w/2 + 2, event.pos[0] - self._drag[1]), 2)
elif event.type == MOUSEBUTTONUP and event.button == 1:
if self._drag is not None:
if abs(self._drag[0] - event.pos[0]) < 5: # Clicked
self._settings["state"] = not self._settings["state"]
else: # Dragged
# Determine if dropped in on/off position
if self._images["handle"].rect.centerx < self.rect.w/2:
self._settings["state"] = False
else:
self._settings["state"] = True
self._drag = None
self.on_click()
self._switch()
elif self.rect_abs.collidepoint(event.pos):
# Clicked outside of handle
self._settings["state"] = not self._settings["state"]
self.on_click()
self._switch()
elif event.type == KEYUP:
if event.key in (K_RETURN, K_SPACE):
self._settings["state"] = not self._settings["state"]
self.on_click()
self._switch()
def _focus_enter(self, focus):
"""Draw dotted rect when focus is gained from keyboard."""
if focus == 1:
self._draw_rect = True
self._switch()
def _focus_exit(self):
"""Stop drawing dotted rect when focus is lost."""
self._draw_rect = False
self._switch()
def _switch(self):
img = "image" if (self._settings["state"] is False) else "active"
super(Switch, self)._switch(img)
self._fix_handle()
def _fix_handle(self):
"""Fix handle position in place."""
if self._drag is None:
# Fix handle in place when not dragging
if self._settings["state"] is False:
self._images["handle"].rect.x = 2
else:
self._images["handle"].rect.x = self.rect.w/2 + 2
@property
def state(self):
return self._settings["state"]
| 36.207101
| 80
| 0.547639
|
7951b888d59377b3e5f7c1141855b8372b9ee75c
| 2,149
|
py
|
Python
|
tests/equivalence_test.py
|
cgruber/make-open-easy
|
b433ba61d2f7b32d06eb7df8db38ba545827ad5e
|
[
"Apache-2.0"
] | 5
|
2016-05-08T00:55:46.000Z
|
2020-03-14T06:57:30.000Z
|
tests/equivalence_test.py
|
cgruber/make-open-easy
|
b433ba61d2f7b32d06eb7df8db38ba545827ad5e
|
[
"Apache-2.0"
] | null | null | null |
tests/equivalence_test.py
|
cgruber/make-open-easy
|
b433ba61d2f7b32d06eb7df8db38ba545827ad5e
|
[
"Apache-2.0"
] | 10
|
2015-06-08T21:15:13.000Z
|
2021-10-16T15:06:01.000Z
|
#!/usr/bin/env python
#
# Copyright 2010 Google Inc. All Rights Reserved.
"""Tests for moe.actions.EquivalenceCheck."""
__author__ = 'dbentley@google.com (Daniel Bentley)'
import gflags as flags
from google.apputils import basetest
from moe import actions
from moe import base
from moe import codebase_utils
from moe import moe_app
import test_util
FLAGS = flags.FLAGS
def setUp():
moe_app.InitForTest()
class EquivalenceTest(basetest.TestCase):
def testEquivalent(self):
project = test_util.EmptyMoeProjectConfig()
ec = actions.EquivalenceCheck(
'1001', '1', project, [], actions.EquivalenceCheck.ErrorIfDifferent)
internal_creator = test_util.StaticCodebaseCreator(
{'1001': 'simple_python'})
public_creator = test_util.StaticCodebaseCreator(
{'1': 'simple_python'})
result = ec.Perform(internal_creator, public_creator, None, None,
FLAGS.test_tmpdir, [])
self.assertEqual(result, None)
def testEquivalentIfDifferentButHaveManualDeltas(self):
project = test_util.EmptyMoeProjectConfig()
project.manual_equivalence_deltas = True
ec = actions.EquivalenceCheck(
'1001', '1', project, [], actions.EquivalenceCheck.ErrorIfDifferent)
internal_creator = test_util.StaticCodebaseCreator(
{'1001': 'simple_python'})
public_creator = test_util.StaticCodebaseCreator(
{'1': 'modified_python'})
result = ec.Perform(internal_creator, public_creator, None, None,
FLAGS.test_tmpdir, [])
self.assertEqual(result, None)
def testDifferent(self):
project = test_util.EmptyMoeProjectConfig()
ec = actions.EquivalenceCheck(
'1001', '1', project, [], actions.EquivalenceCheck.ErrorIfDifferent)
internal_creator = test_util.StaticCodebaseCreator(
{'1001': 'simple_python'})
public_creator = test_util.StaticCodebaseCreator(
{'1': 'modified_python'})
self.assertRaises(base.Error, ec.Perform,
internal_creator, public_creator, None, None,
FLAGS.test_tmpdir, [])
if __name__ == '__main__':
basetest.main()
| 29.438356
| 76
| 0.695672
|
7951bcdadb5588e46251133f29c3f2fa96b6a14b
| 21,514
|
py
|
Python
|
Chimera/python3_scripts/sequencer.py
|
zzpwahaha/Chimera-Control-Trim
|
df1bbf6bea0b87b8c7c9a99dce213fdc249118f2
|
[
"MIT"
] | null | null | null |
Chimera/python3_scripts/sequencer.py
|
zzpwahaha/Chimera-Control-Trim
|
df1bbf6bea0b87b8c7c9a99dce213fdc249118f2
|
[
"MIT"
] | null | null | null |
Chimera/python3_scripts/sequencer.py
|
zzpwahaha/Chimera-Control-Trim
|
df1bbf6bea0b87b8c7c9a99dce213fdc249118f2
|
[
"MIT"
] | null | null | null |
from time import sleep
from axis_fifo import AXIS_FIFO
from devices import fifo_devices
from devices import gpio_devices
from axi_gpio import AXI_GPIO
from dac81416 import DAC81416
from ad9959 import AD9959
from test_sequencer import write_point as TS_write_point
from reset_all import reset
from writeToSeqGPIO import writeToSeqGPIO
from getSeqGPIOWords import getSeqGPIOWords
import dds_lock_pll
from soft_trigger import trigger
import struct
import math
class GPIO_seq_point:
def __init__(self, address, time, outputA, outputB):
self.address = address
self.time = time
self.outputA = outputA
self.outputB = outputB
class DAC_seq_point:
def __init__(self, address, time, start, incr, chan, clr_incr=0):
assert (address >= 0),"invalid address!"
assert (address <= 1023),"invalid address!"
assert (time >= 0),"invalid time!"
assert (time <= 65536*65536-1),"invalid time!"
assert (clr_incr >= 0),"invalid clr_incr!"
assert (clr_incr <= 1),"invalid clr_incr!"
assert (chan >= 0),"invalid channel!"
assert (chan <= 15),"invalid channel!"
assert (start >= 0),"invalid start!"
assert (start <= 65535),"invalid start!"
assert (incr >= 0),"invalid increment!"
assert (incr <= 65536*65536-1),"invalid increment!"
self.address = address
self.time = time
self.start = start
self.clr_incr = clr_incr
self.incr = incr
self.chan = chan
class DDS_atw_seq_point:
def __init__(self, address, time, start, steps, incr, chan):
self.address = address
self.time = time
self.start = start
self.steps = steps
self.incr = incr
self.chan = chan
class DDS_ftw_seq_point:
def __init__(self, address, time, start, steps, incr, chan):
self.address = address
self.time = time
self.start = start
self.steps = steps
self.incr = incr
self.chan = chan
class sequencer:
def __init__(self):
self.dacRes = 65535 #0xffff
self.dacRange = [-10, 10]
self.dacIncrMax = 0xffffffff # 32bit
self.dacRampTimeRes = 2000 #20us in the unit of system clk (10ns)
self.ddsAmpRange = [0, 5]
self.ddsFreqRange = [0, 500]
self.accUpdateFreq = 1.0 # accumulator update freq in MHz, not really used, for reminder
self.ddsUpdateFreq = 50.0 # dds update freq in kHz, not really used, for reminder
self.ddsFreqRangeConv = 0xffffffff / 500.0 #8589930 # (2^32 - 1)/500 MHz
self.ddsAmpRangeConv = 0x3ff/100 # (2^10 - 1)/100
self.ddsFreqIncMax = 0xfffffffffff # 32 ftw + 12 acc = 44bit
self.ddsAmpIncMax = 0x3fffff # 10 atw + 12 acc = 22bit
# self.ddsTimeRes = 1.0e3 # in us
# initialize DACs
self.dac0 = DAC81416(fifo_devices['DAC81416_0'])
self.dac1 = DAC81416(fifo_devices['DAC81416_1'])
self.dds0 = AD9959(fifo_devices['AD9959_0'])
self.dds1 = AD9959(fifo_devices['AD9959_1'])
self.dds2 = AD9959(fifo_devices['AD9959_2'])
self.fifo_dac0_seq = AXIS_FIFO(fifo_devices['DAC81416_0_seq'])
self.fifo_dac1_seq = AXIS_FIFO(fifo_devices['DAC81416_1_seq'])
dds_lock_pll.dds_lock_pll()
# initialize DDSs
self.fifo_dds0_atw_seq = AXIS_FIFO(fifo_devices['AD9959_0_seq_atw'])
self.fifo_dds0_ftw_seq = AXIS_FIFO(fifo_devices['AD9959_0_seq_ftw'])
self.fifo_dds1_atw_seq = AXIS_FIFO(fifo_devices['AD9959_1_seq_atw'])
self.fifo_dds1_ftw_seq = AXIS_FIFO(fifo_devices['AD9959_1_seq_ftw'])
self.fifo_dds2_atw_seq = AXIS_FIFO(fifo_devices['AD9959_2_seq_atw'])
self.fifo_dds2_ftw_seq = AXIS_FIFO(fifo_devices['AD9959_2_seq_ftw'])
# self.dds = AD9959(dds_device) # initialize DDS
self.gpio2 = AXI_GPIO(gpio_devices['axi_gpio_2'])
self.fifo_dio_seq = AXIS_FIFO(fifo_devices['GPIO_seq'])
reset()
def initExp(self):
print('******************************************************************************************************************************************************************')
print('initializing experiment')
self.mod_disable()
reset()
dds_lock_pll.dds_lock_pll()
self.mod_enable()
self.mod_report()
def getWord(self, bytes):
return bytes[3] + bytes[2] + bytes[1] + bytes[0]
def soft_trigger(self):
trigger()
def write_dio_point(self, point):
#01XXAAAA TTTTTTTT DDDDDDDD
self.fifo_dio_seq.write_axis_fifo(b"\x01\x00" + struct.pack('>H', point.address))
self.fifo_dio_seq.write_axis_fifo(struct.pack('>I', point.time))
self.fifo_dio_seq.write_axis_fifo(struct.pack('>I', point.outputA))
self.fifo_dio_seq.write_axis_fifo(struct.pack('>I', point.outputB))
def write_dio(self, byte_buf):
#01XXAAAA TTTTTTTT DDDDDDDD
self.fifo_dio_seq.write_axis_fifo(byte_buf, MSB_first=False)
def write_dac_point(self, fifo, point):
#01XXAAAA TTTTTTTT DDDDDDDD DDDDDDDD
#phase acc shifts by 12 bit => 4096
#clr_incr <= gpio_in(52 downto 52);
#acc_chan <= gpio_in(51 downto 48);
#acc_start <= gpio_in(47 downto 32);
#acc_incr <= gpio_in(31 downto 0);
fifo.write_axis_fifo(b"\x01\x00" + struct.pack('>H', point.address))
fifo.write_axis_fifo(struct.pack('>I', point.time))
fifo.write_axis_fifo(struct.pack('>I', point.clr_incr*16*256*256 + point.chan*256*256 + point.start))
fifo.write_axis_fifo(struct.pack('>I', point.incr))
def write_atw_point(self, fifo, point):
#01XXAAAA TTTTTTTT DDDDDDDD DDDDDDDD
#phase acc shifts by 12 bit => 4096
#unused <= gpio_in(63 downto 58);
#acc_start <= gpio_in(57 downto 48);
#acc_steps <= gpio_in(47 downto 32);
#unused <= gpio_in(31 downto 26);
#acc_incr <= gpio_in(25 downto 4);
#unused <= gpio_in( 3 downto 2);
#acc_chan <= gpio_in( 1 downto 0);
# print('addr', point.address, 'time', point.time, 'start', point.start, 'steps', point.steps, 'incr', point.incr, 'channel', point.chan)
fifo.write_axis_fifo(b"\x01\x00" + struct.pack('>H', point.address))
fifo.write_axis_fifo(struct.pack('>I', point.time))
fifo.write_axis_fifo(struct.pack('>I', (point.start << 16) + point.steps))
fifo.write_axis_fifo(struct.pack('>I', (point.incr << 4) + point.chan))
def write_ftw_point(self, fifo, point):
#01XXAAAA TTTTTTTT DDDDDDDD DDDDDDDD DDDDDDDD
#phase acc shifts by 12 bit => 4096
#acc_start <= gpio_in(95 downto 64);
#acc_steps <= gpio_in(63 downto 48);
#acc_incr <= gpio_in(47 downto 4) 32 ftw + 12 phase acc;
#acc_chan <= to_integer(unsigned(gpio_in( 3 downto 0)));
incr_hi = point.incr >> 28 #(point.incr & (0xffff << 28)) # acc_incr_hi <= gpio_in(47 downto 32)
incr_lo = point.incr & ((1 << 28) - 1) # acc_incr_lo <= gpio_in(31 downto 4)
# print point.steps * 256 * 256, incr_hi,incr_lo, point.incr, point.steps * 256 * 256 + incr_hi
# print point.incr & (0xffff>>28), point.incr & ((1<<28)-1), (point.steps << 16) + incr_hi, (incr_lo << 4) + point.chan
# print incr_hi, incr_lo, point.steps * 256 * 256 + incr_hi, incr_lo * 16 + point.chan
fifo.write_axis_fifo(b"\x01\x00" + struct.pack('>H', point.address))
fifo.write_axis_fifo(struct.pack('>I', point.time))
fifo.write_axis_fifo(struct.pack('>I', point.start))
fifo.write_axis_fifo(struct.pack('>I', (point.steps << 16) + incr_hi))
fifo.write_axis_fifo(struct.pack('>I', (incr_lo << 4) + point.chan))
def reset_DAC(self):
self.dac0 = DAC81416(fifo_devices['DAC81416_0'])
self.dac1 = DAC81416(fifo_devices['DAC81416_1'])
def set_DAC(self, channel, value):
valueInt = int((value-self.dacRange[0])*self.dacRes/(self.dacRange[1]-self.dacRange[0]) + 0.5)
assert channel>=0 and channel<=31, 'Invalid channel for DAC81416 in set_DAC'
assert valueInt>=0 and valueInt<=65536, 'Invalid value for DAC81416 in set_DAC'
if valueInt == 65536:
valueInt -= 1
if (channel > 15):
channel = channel-16
self.dac1.set_DAC(channel, valueInt)
else:
self.dac0.set_DAC(channel, valueInt)
def set_DDS(self, channel, freq, amp=None):
assert channel>=0 and channel<=11, 'Invalid channel for AD9959 in set_DDS'
dds_lock_pll.dds_lock_pll()
if (channel > 7):
channel = channel-8
self.dds2.set_DDS(channel, freq, amp)
elif (3 < channel < 8):
channel = channel-4
self.dds1.set_DDS(channel, freq, amp)
else:
self.dds0.set_DDS(channel, freq, amp)
def mod_enable(self):
print('mod enabled from zynq')
self.gpio2.set_bit(0, channel=1)
self.mod_report()
def mod_disable(self):
print('mod disabled from zynq')
self.gpio2.clear_bit(0, channel=1)
def reset(self):
self.gpio2.write_axi_gpio(0xffff0000,channel=2)
self.gpio2.write_axi_gpio(0x0000ffff,channel=2)
def reset_disable_mod(self):
print('disabling mod and resetting sequencers')
self.reset()
self.mod_disable()
def reset_enable_mod(self):
print('resetting sequencers and enabling mod')
self.mod_disable()
dds_lock_pll.dds_lock_pll()
self.reset()
self.mod_enable()
def mod_report(self):
status = int(self.gpio2.read_axi_gpio(channel=1).hex(), 16)
if status == 1:
print('MOD IS ON, CAN RUN SEQUENCER FOR EXPERIMENT OR CHANGE DAC, TTL NOW')
elif status == 0:
print('MOD IS OFF, CAN UPDATE DDS GUI NOW')
else:
print('MOD is not in valid state, a low level bug')
def dac_seq_write_points(self, byte_len, byte_buf, num_snapshots):
print('DAC points')
points0 = []
points1 = []
for ii in range(num_snapshots):
# t is in 10ns, s is in V, end is in V, duration is in 10ns
[t, chan, s, end, duration] = self.dac_read_point(byte_buf[ii*byte_len: ii*byte_len + byte_len])
print('time',t,'channel', chan,'start', s,'end', end,'duration', duration)
num_steps = int(duration/self.dacRampTimeRes + 0.5)
# num_steps = int(duration * self.accUpdateFreq) # duration is in us and accUpdateFreq is in MHz
if (num_steps < 1):
ramp_inc = 0
clr_incr = 1
else:
ramp_inc = int(abs((end<<16)-(s<<16))/num_steps+0.5)
clr_incr = 0
# print(s, end, num_steps, ramp_inc)
if (end<s and ramp_inc != 0):
ramp_inc = int(self.dacIncrMax + 1 - ramp_inc)
print('time',t,'channel', chan,'start', s,'end', end,'duration', duration, 'num_step',num_steps, 'ramp_inc: ', ramp_inc)
t = int(t/self.dacRampTimeRes + 0.5) * self.dacRampTimeRes + (chan%16)
if (chan < 16):
points0.append(DAC_seq_point(address=len(points0),time=t,start=s,incr=ramp_inc,chan=chan,clr_incr=clr_incr))
else:
points1.append(DAC_seq_point(address=len(points1),time=t,start=s,incr=ramp_inc,chan=chan-16,clr_incr=clr_incr))
if (len(points0) != 0):
points0.append(DAC_seq_point(address=len(points0), time=0, start=0,incr=0,chan=0,clr_incr=0))
if (len(points1) != 0):
points1.append(DAC_seq_point(address=len(points1), time=0, start=0,incr=0,chan=0,clr_incr=0))
for point in points0:
print('DAC_seq_point(',
'address=', point.address,
', time = ', point.time,
',start =', point.start,
',incr = ', point.incr,
',chan=', point.chan,
',clr_incr=', point.clr_incr, ')' )
self.write_dac_point(self.fifo_dac0_seq, point)
for point in points1:
print('DAC_seq_point(',
'address=', point.address,
', time = ', point.time,
',start =', point.start,
',incr = ', point.incr,
',chan=', point.chan,
',clr_incr=', point.clr_incr, ')' )
self.write_dac_point(self.fifo_dac1_seq, point)
def dds_seq_write_points(self, byte_len, byte_buf, num_snapshots):
ftw_points0=[]
ftw_points1=[]
ftw_points2=[]
atw_points0=[]
atw_points1=[]
atw_points2=[]
for ii in range(num_snapshots):
[t, channel, aorf, s, end, duration] = self.dds_read_point(byte_buf[ii*byte_len: ii*byte_len + byte_len])
# num_steps = (duration/self.ddsTimeRes)
num_steps = int(duration * self.accUpdateFreq) # duration is in us and accUpdateFreq is in MHz
if (num_steps == 0):
ramp_inc = 0
else:
# ramp_inc = int((end-s)/num_steps) * 4 #somehow setting ddsTimeRes to 1.0e3 and add *4 works for freq ramp final value
ramp_inc = int((end - s)*1.0 / num_steps * 4096)
# * 1.0 just to avoid zero if end-s < num_steps(this is not true in python3, but in python2 int(2)/int(3)=0),
# 4096=0xfff+1 comes from the 12bit accumulator
print('time',t,'channel', channel, aorf,'start', s,'end', end,'duration', duration, 'num_step',num_steps, 'ramp_inc: ', ramp_inc)
if (aorf == b'f'):
if (ramp_inc < 0):
# ramp_inc = int(self.ddsFreqRangeConv + ramp_inc)
ramp_inc = int(self.ddsFreqIncMax + ramp_inc)
if (channel < 4):
ftw_points0.append(DDS_ftw_seq_point(address=len(ftw_points0), time=t, start=s, steps=num_steps, incr=ramp_inc, chan=channel))
elif (4 <= channel < 8):
channel = channel-4
ftw_points1.append(DDS_ftw_seq_point(address=len(ftw_points1), time=t, start=s, steps=num_steps, incr=ramp_inc, chan=channel))
else:
channel = channel-8
ftw_points2.append(DDS_ftw_seq_point(address=len(ftw_points2), time=t, start=s, steps=num_steps, incr=ramp_inc, chan=channel))
elif (aorf == b'a'):
if (ramp_inc < 0):
ramp_inc = int(self.ddsAmpIncMax + ramp_inc)
if (channel < 4):
atw_points0.append(DDS_atw_seq_point(address=len(atw_points0), time=t, start=s, steps=num_steps, incr=ramp_inc, chan=channel))
elif (4 <= channel < 8):
channel = channel-4
atw_points1.append(DDS_atw_seq_point(address=len(atw_points1), time=t, start=s, steps=num_steps, incr=ramp_inc, chan=channel))
else:
channel = channel-8
atw_points2.append(DDS_atw_seq_point(address=len(atw_points2), time=t, start=s, steps=num_steps, incr=ramp_inc, chan=channel))
else:
print("invalid dds type. set to 'f' for freq or 'a' for amp")
if (len(atw_points0) != 0):
atw_points0.append(DDS_atw_seq_point(address=len(atw_points0), time=0, start=0, steps=0, incr=0, chan=0))
if (len(atw_points1) != 0):
atw_points1.append(DDS_atw_seq_point(address=len(atw_points1), time=0, start=0, steps=0, incr=0, chan=0))
if (len(atw_points2) != 0):
atw_points2.append(DDS_atw_seq_point(address=len(atw_points2), time=0, start=0, steps=0, incr=0, chan=0))
if (len(ftw_points0) != 0):
ftw_points0.append(DDS_ftw_seq_point(address=len(ftw_points0), time=0, start=0, steps=0, incr=0, chan=0))
if (len(ftw_points1) != 0):
ftw_points1.append(DDS_ftw_seq_point(address=len(ftw_points1), time=0, start=0, steps=0, incr=0, chan=0))
if (len(ftw_points2) != 0):
ftw_points2.append(DDS_ftw_seq_point(address=len(ftw_points2), time=0, start=0, steps=0, incr=0, chan=0))
for point in ftw_points0:
print("ftw dds0")
self.write_ftw_point(self.fifo_dds0_ftw_seq, point)
for point in ftw_points1:
print("ftw dds1")
self.write_ftw_point(self.fifo_dds1_ftw_seq, point)
for point in ftw_points2:
print("ftw dds2")
# print(point.address, point.time, point.chan)
self.write_ftw_point(self.fifo_dds2_ftw_seq, point)
for point in atw_points0:
print("atw dds0")
self.write_atw_point(self.fifo_dds0_atw_seq, point)
for point in atw_points1:
print("atw dds1")
self.write_atw_point(self.fifo_dds1_atw_seq, point)
for point in atw_points2:
print("atw dds2")
self.write_atw_point(self.fifo_dds2_atw_seq, point)
def dds_seq_write_atw_points(self):
points=[]
#these ramps should complete in just under 64 ms
points.append(DDS_atw_seq_point(address=0,time= 0,start=1023,steps=0,incr=0,chan=0)) #25% to 75%
# points.append(DDS_atw_seq_point(address=1,time=1000,start=256,steps=1,incr=0,chan=3)) #25% to 75%
points.append(DDS_atw_seq_point(address=1,time= 0,start=0,steps= 0,incr= 0,chan=0))
for point in points:
self.write_atw_point(self.fifo_dds_atw_seq, point)
def dds_seq_write_ftw_points(self):
points=[]
# points.append(DDS_ftw_seq_point(address=0,time=0,start=200000000,steps=0,incr=0,chan=0))
# ~ points.append(DDS_ftw_seq_point(address=0,time= 0,start=800000,steps=10000,incr=30000,chan=0))
points.append(DDS_ftw_seq_point(address=0,time=0,start=800000,steps=0,incr=0,chan=1))
points.append(DDS_ftw_seq_point(address=1,time=20000,start=500000,steps=0,incr=0,chan=2))
points.append(DDS_ftw_seq_point(address=2,time=0,start=0,steps=0,incr=0,chan=0))
for point in points:
self.write_ftw_point(self.fifo_dds_ftw_seq, point)
def dio_seq_write_points(self, byte_len, byte_buf, num_snapshots):
print('DIO points')
points=[]
for ii in range(num_snapshots):
[t, outA, outB] = self.dio_read_point(byte_buf[ii*byte_len: ii*byte_len + byte_len])
points.append(GPIO_seq_point(address=ii,time=t,outputA=outA,outputB=outB))
# points.append(GPIO_seq_point(address=num_snapshots,time=6400000,outputA=0x00000000,outputB=0x00000000))
points.append(GPIO_seq_point(address=num_snapshots,time=0,outputA=0x00000000,outputB=0x00000000))
# with open("/dev/axis_fifo_0x0000000080004000", "wb") as character:
for point in points:
# writeToSeqGPIO(character, point)
seqWords = getSeqGPIOWords(point)
print('GPIO_seq_point(address = ',point.address,
',time=',point.time,
',outputA = ',"{0:#0{1}x}".format(point.outputA,8+2),
',outputB = ',"{0:#0{1}x}".format(point.outputB,8+2), ')')
for word in seqWords:
# print word
self.fifo_dio_seq.write_axis_fifo(word[0], MSB_first=False)
def dio_read_point(self, snapshot):
print(snapshot)
snapshot_split = snapshot.split(b'_')
t = int(snapshot_split[0].strip(b't'), 16)
out = snapshot_split[1].strip(b'b').strip(b'\0')
outB = int(out[:8], 16)
outA = int(out[8:], 16)
return [t, outA, outB]
def dac_read_point(self, snapshot):
print(snapshot)
snapshot_split = snapshot.split(b'_')
t = int(snapshot_split[0].strip(b't'), 16)
chan = int(snapshot_split[1].strip(b'c'), 16)
start = int(self.dacRes*(float(snapshot_split[2].strip(b's')) - self.dacRange[0])
/(self.dacRange[1]-self.dacRange[0]) + 0.5)
end = int(self.dacRes*(float(snapshot_split[3].strip(b'e')) - self.dacRange[0])
/(self.dacRange[1]-self.dacRange[0]) + 0.5)
duration = int(snapshot_split[4].strip(b'd').strip(b'\0'), 16)
return [t, chan, start, end, duration]
def dds_read_point(self, snapshot):
print(snapshot)
snapshot_split = snapshot.split(b'_')
t = int(snapshot_split[0].strip(b't'), 16)
chan = int(snapshot_split[1].strip(b'c'), 16)
aorf = snapshot_split[2]
if (aorf == b'f'):
ddsConv = self.ddsFreqRangeConv
elif (aorf == b'a'):
ddsConv = self.ddsAmpRangeConv
else:
print("invalid dds type. set to 'f' for freq or 'a' for amp")
start = int(float(snapshot_split[3].strip(b's'))*ddsConv)
end = int(float(snapshot_split[4].strip(b'e'))*ddsConv)
duration = int(snapshot_split[5].strip(b'd').strip(b'\0'), 16)
return [t, chan, aorf, start, end, duration]
if __name__ == "__main__":
from soft_trigger import trigger
from reset_all import reset
import dds_lock_pll
import time
byte_buf_dio = 't00000010_b000fff0000000000\0' \
't00000A00_bF000000100000000\0' \
't00030d40_b000fff0000000001\0' \
't00061a80_b0000000000000000\0'
byte_buf_dds = 't00000064_c0001_f_s100.000_e050.000_000009ff0\0' \
't00010064_c0002_f_s080.000_e050.000_000009ff0\0'
byte_buf_dds = 't00000064_c0001_a_s001.000_e000.000_0000000f0\0'
#byte_buf1 = 't00000064_c0000_f_s080.000_e000.000_d00000000\0'
byte_buf_dac = 't00000000_c0000_s05.000_e00.000_d0000c350\0' \
't005b8d80_c0000_s05.000_e00.000_d0000c350\0'
byte_buf_dac = 't00000000_c0000_s00.000_e00.000_d00000000\0' \
't005b8d80_c0000_s05.000_e00.000_d0000c350\0'
byte_buf_dio = b't00002710_b0000000000000000\x00'\
b't00004E20_b0000000000C00000\x00'\
b't000061A8_b0000000000000000\x00'\
b't000186A0_b0000000000000001\x00'\
b't00030D40_b0000000000000000\x00'\
b't05F78EB0_b0000000000008000\x00'
byte_buf_dac = b't000186A0_c0000_s01.0000_e01.0000_d00000000\x00' \
b't000186A0_c0002_s05.0000_e05.0000_d00000000\x00'\
b't0001ADB0_c0000_s04.0000_e05.9600_d00017ed0\x00'\
b't0001ADB0_c0002_s00.0000_e06.9720_d00079950\x00'\
b't00032C80_c0000_s05.9600_e06.0000_d000007d0\x00'\
b't00033450_c0000_s06.0000_e06.0000_d00000000\x00'\
b't00094700_c0002_s06.9720_e07.0000_d000007d0\x00'\
b't00094ED0_c0002_s07.0000_e07.0000_d00000000\x00'\
b't05F78EB0_c0000_s09.0000_e09.0000_d00000000\x00'
byte_buf_dio = b't00002710_b0000610000000000\x00'\
b't00004E20_b0000610000C00000\x00'\
b't000061A8_b0000610000000000\x00'\
b't000186A0_b0000610000000001\x00'\
b't00030D40_b0000610000000000\x00'\
b't0014B040_b0000610000000010\x00'\
b't001636E0_b0000610000000000\x00'
# b't11E4B040_b0000610000000010\x00'\
# b't11E636E0_b0000610000000000\x00'
byte_buf_dac = b't00030D40_c0006_s10.0000_e00.0398_d00079950\x00'\
b't000AA690_c0006_s00.0398_e00.0000_d000007D0\x00'\
b't000AAE60_c0006_s00.0000_e00.0000_d00000000\x00'
byte_buf_dds = b't000186A0_c000A_f_s080.000_e080.000_d00000000\x00'\
b't000186A0_c000A_a_s100.000_e000.000_d00002710\x00'\
b't0010C8E2_c000A_a_s000.000_e000.000_d00000000\x00'
seq = sequencer()
seq.mod_disable()
reset()
dds_lock_pll.dds_lock_pll()
for i in range(1500):
# reset()
# seq.set_DDS(1, 100, 10)
# seq.dds_seq_write_points(46, byte_buf_dds, 1)
# time.sleep(0.005)
# seq.set_DDS(1, 100, 0)
# seq.dds_seq_write_atw_points()
#seq.dds_seq_write_ftw_points()
# seq.set_DAC(0, -1)
# seq.set_DAC(16, 1)
# seq.set_DAC(19, 1)
seq.dac_seq_write_points(44, byte_buf_dac, 3)
seq.mod_enable()
seq.dio_seq_write_points(28, byte_buf_dio, 7)
seq.mod_enable()
seq.dds_seq_write_points(46, byte_buf_dds, 3)
seq.mod_enable()
trigger()
print('*****************************************' + str(i) + '******************************************************')
sleep(.5)
| 39.914657
| 173
| 0.697964
|
7951bce8ab95e47ff8d6c373a8cef615166f882c
| 11,093
|
py
|
Python
|
plotly_study/graph_objs/sunburst/hoverlabel/__init__.py
|
lucasiscovici/plotly_py
|
42ab769febb45fbbe0a3c677dc4306a4f59cea36
|
[
"MIT"
] | null | null | null |
plotly_study/graph_objs/sunburst/hoverlabel/__init__.py
|
lucasiscovici/plotly_py
|
42ab769febb45fbbe0a3c677dc4306a4f59cea36
|
[
"MIT"
] | null | null | null |
plotly_study/graph_objs/sunburst/hoverlabel/__init__.py
|
lucasiscovici/plotly_py
|
42ab769febb45fbbe0a3c677dc4306a4f59cea36
|
[
"MIT"
] | null | null | null |
from plotly_study.basedatatypes import BaseTraceHierarchyType as _BaseTraceHierarchyType
import copy as _copy
class Font(_BaseTraceHierarchyType):
# color
# -----
@property
def color(self):
"""
The 'color' property is a color and may be specified as:
- A hex string (e.g. '#ff0000')
- An rgb/rgba string (e.g. 'rgb(255,0,0)')
- An hsl/hsla string (e.g. 'hsl(0,100%,50%)')
- An hsv/hsva string (e.g. 'hsv(0,100%,100%)')
- A named CSS color:
aliceblue, antiquewhite, aqua, aquamarine, azure,
beige, bisque, black, blanchedalmond, blue,
blueviolet, brown, burlywood, cadetblue,
chartreuse, chocolate, coral, cornflowerblue,
cornsilk, crimson, cyan, darkblue, darkcyan,
darkgoldenrod, darkgray, darkgrey, darkgreen,
darkkhaki, darkmagenta, darkolivegreen, darkorange,
darkorchid, darkred, darksalmon, darkseagreen,
darkslateblue, darkslategray, darkslategrey,
darkturquoise, darkviolet, deeppink, deepskyblue,
dimgray, dimgrey, dodgerblue, firebrick,
floralwhite, forestgreen, fuchsia, gainsboro,
ghostwhite, gold, goldenrod, gray, grey, green,
greenyellow, honeydew, hotpink, indianred, indigo,
ivory, khaki, lavender, lavenderblush, lawngreen,
lemonchiffon, lightblue, lightcoral, lightcyan,
lightgoldenrodyellow, lightgray, lightgrey,
lightgreen, lightpink, lightsalmon, lightseagreen,
lightskyblue, lightslategray, lightslategrey,
lightsteelblue, lightyellow, lime, limegreen,
linen, magenta, maroon, mediumaquamarine,
mediumblue, mediumorchid, mediumpurple,
mediumseagreen, mediumslateblue, mediumspringgreen,
mediumturquoise, mediumvioletred, midnightblue,
mintcream, mistyrose, moccasin, navajowhite, navy,
oldlace, olive, olivedrab, orange, orangered,
orchid, palegoldenrod, palegreen, paleturquoise,
palevioletred, papayawhip, peachpuff, peru, pink,
plum, powderblue, purple, red, rosybrown,
royalblue, rebeccapurple, saddlebrown, salmon,
sandybrown, seagreen, seashell, sienna, silver,
skyblue, slateblue, slategray, slategrey, snow,
springgreen, steelblue, tan, teal, thistle, tomato,
turquoise, violet, wheat, white, whitesmoke,
yellow, yellowgreen
- A list or array of any of the above
Returns
-------
str|numpy.ndarray
"""
return self["color"]
@color.setter
def color(self, val):
self["color"] = val
# colorsrc
# --------
@property
def colorsrc(self):
"""
Sets the source reference on plot.ly for color .
The 'colorsrc' property must be specified as a string or
as a plotly_study.grid_objs.Column object
Returns
-------
str
"""
return self["colorsrc"]
@colorsrc.setter
def colorsrc(self, val):
self["colorsrc"] = val
# family
# ------
@property
def family(self):
"""
HTML font family - the typeface that will be applied by the web
browser. The web browser will only be able to apply a font if
it is available on the system which it operates. Provide
multiple font families, separated by commas, to indicate the
preference in which to apply fonts if they aren't available on
the system. The plotly service (at https://plot.ly or on-
premise) generates images on a server, where only a select
number of fonts are installed and supported. These include
"Arial", "Balto", "Courier New", "Droid Sans",, "Droid Serif",
"Droid Sans Mono", "Gravitas One", "Old Standard TT", "Open
Sans", "Overpass", "PT Sans Narrow", "Raleway", "Times New
Roman".
The 'family' property is a string and must be specified as:
- A non-empty string
- A tuple, list, or one-dimensional numpy array of the above
Returns
-------
str|numpy.ndarray
"""
return self["family"]
@family.setter
def family(self, val):
self["family"] = val
# familysrc
# ---------
@property
def familysrc(self):
"""
Sets the source reference on plot.ly for family .
The 'familysrc' property must be specified as a string or
as a plotly_study.grid_objs.Column object
Returns
-------
str
"""
return self["familysrc"]
@familysrc.setter
def familysrc(self, val):
self["familysrc"] = val
# size
# ----
@property
def size(self):
"""
The 'size' property is a number and may be specified as:
- An int or float in the interval [1, inf]
- A tuple, list, or one-dimensional numpy array of the above
Returns
-------
int|float|numpy.ndarray
"""
return self["size"]
@size.setter
def size(self, val):
self["size"] = val
# sizesrc
# -------
@property
def sizesrc(self):
"""
Sets the source reference on plot.ly for size .
The 'sizesrc' property must be specified as a string or
as a plotly_study.grid_objs.Column object
Returns
-------
str
"""
return self["sizesrc"]
@sizesrc.setter
def sizesrc(self, val):
self["sizesrc"] = val
# property parent name
# --------------------
@property
def _parent_path_str(self):
return "sunburst.hoverlabel"
# Self properties description
# ---------------------------
@property
def _prop_descriptions(self):
return """\
color
colorsrc
Sets the source reference on plot.ly for color .
family
HTML font family - the typeface that will be applied by
the web browser. The web browser will only be able to
apply a font if it is available on the system which it
operates. Provide multiple font families, separated by
commas, to indicate the preference in which to apply
fonts if they aren't available on the system. The
plotly service (at https://plot.ly or on-premise)
generates images on a server, where only a select
number of fonts are installed and supported. These
include "Arial", "Balto", "Courier New", "Droid Sans",,
"Droid Serif", "Droid Sans Mono", "Gravitas One", "Old
Standard TT", "Open Sans", "Overpass", "PT Sans
Narrow", "Raleway", "Times New Roman".
familysrc
Sets the source reference on plot.ly for family .
size
sizesrc
Sets the source reference on plot.ly for size .
"""
def __init__(
self,
arg=None,
color=None,
colorsrc=None,
family=None,
familysrc=None,
size=None,
sizesrc=None,
**kwargs
):
"""
Construct a new Font object
Sets the font used in hover labels.
Parameters
----------
arg
dict of properties compatible with this constructor or
an instance of
plotly_study.graph_objs.sunburst.hoverlabel.Font
color
colorsrc
Sets the source reference on plot.ly for color .
family
HTML font family - the typeface that will be applied by
the web browser. The web browser will only be able to
apply a font if it is available on the system which it
operates. Provide multiple font families, separated by
commas, to indicate the preference in which to apply
fonts if they aren't available on the system. The
plotly service (at https://plot.ly or on-premise)
generates images on a server, where only a select
number of fonts are installed and supported. These
include "Arial", "Balto", "Courier New", "Droid Sans",,
"Droid Serif", "Droid Sans Mono", "Gravitas One", "Old
Standard TT", "Open Sans", "Overpass", "PT Sans
Narrow", "Raleway", "Times New Roman".
familysrc
Sets the source reference on plot.ly for family .
size
sizesrc
Sets the source reference on plot.ly for size .
Returns
-------
Font
"""
super(Font, self).__init__("font")
# Validate arg
# ------------
if arg is None:
arg = {}
elif isinstance(arg, self.__class__):
arg = arg.to_plotly_json()
elif isinstance(arg, dict):
arg = _copy.copy(arg)
else:
raise ValueError(
"""\
The first argument to the plotly_study.graph_objs.sunburst.hoverlabel.Font
constructor must be a dict or
an instance of plotly_study.graph_objs.sunburst.hoverlabel.Font"""
)
# Handle skip_invalid
# -------------------
self._skip_invalid = kwargs.pop("skip_invalid", False)
# Import validators
# -----------------
from plotly_study.validators.sunburst.hoverlabel import font as v_font
# Initialize validators
# ---------------------
self._validators["color"] = v_font.ColorValidator()
self._validators["colorsrc"] = v_font.ColorsrcValidator()
self._validators["family"] = v_font.FamilyValidator()
self._validators["familysrc"] = v_font.FamilysrcValidator()
self._validators["size"] = v_font.SizeValidator()
self._validators["sizesrc"] = v_font.SizesrcValidator()
# Populate data dict with properties
# ----------------------------------
_v = arg.pop("color", None)
self["color"] = color if color is not None else _v
_v = arg.pop("colorsrc", None)
self["colorsrc"] = colorsrc if colorsrc is not None else _v
_v = arg.pop("family", None)
self["family"] = family if family is not None else _v
_v = arg.pop("familysrc", None)
self["familysrc"] = familysrc if familysrc is not None else _v
_v = arg.pop("size", None)
self["size"] = size if size is not None else _v
_v = arg.pop("sizesrc", None)
self["sizesrc"] = sizesrc if sizesrc is not None else _v
# Process unknown kwargs
# ----------------------
self._process_kwargs(**dict(arg, **kwargs))
# Reset skip_invalid
# ------------------
self._skip_invalid = False
__all__ = ["Font"]
| 34.237654
| 88
| 0.565582
|
7951be6aededc604b847b5a4bd0a6424ff1c393d
| 3,113
|
py
|
Python
|
eggs/bx_python-0.7.1_7b95ff194725-py2.7-linux-x86_64-ucs4.egg/EGG-INFO/scripts/mask_quality.py
|
bopopescu/phyG
|
023f505b705ab953f502cbc55e90612047867583
|
[
"CC-BY-3.0"
] | null | null | null |
eggs/bx_python-0.7.1_7b95ff194725-py2.7-linux-x86_64-ucs4.egg/EGG-INFO/scripts/mask_quality.py
|
bopopescu/phyG
|
023f505b705ab953f502cbc55e90612047867583
|
[
"CC-BY-3.0"
] | null | null | null |
eggs/bx_python-0.7.1_7b95ff194725-py2.7-linux-x86_64-ucs4.egg/EGG-INFO/scripts/mask_quality.py
|
bopopescu/phyG
|
023f505b705ab953f502cbc55e90612047867583
|
[
"CC-BY-3.0"
] | 1
|
2020-07-25T21:03:18.000Z
|
2020-07-25T21:03:18.000Z
|
#!/afs/bx.psu.edu/project/pythons/linux-x86_64-ucs4/bin/python2.7
"""
Masks an AXT or MAF file based on quality (from a binned_array) and
outputs AXT or MAF.
Binned array form of quality scores can be generated with `qv_to_bqv.py`.
usage: %prog input output
-i, --input=N: Format of input (axt or maf)
-o, --output=N: Format of output (axt or maf)
-m, --mask=N: Character to use as mask character
-q, --quality=N: Min quality allowed
-t, --type=N: base_pair or nqs
-l, --list=N: colon seperated list of species,len_file[,qualityfile].
"""
import sys
import bx.align.axt
import bx.align.maf
import bx.binned_array
from bx.cookbook import doc_optparse
import fileinput
from bx.align.sitemask.quality import *
def main():
options, args = doc_optparse.parse( __doc__ )
try:
inputformat = options.input
outputformat = options.output
mask = options.mask
minqual = int(options.quality)
qtype = options.type
speciesAndLens = options.list
inputfile = args[0]
outputfile = args[1]
except:
doc_optparse.exception()
outstream = open( outputfile, "w" )
instream = open( inputfile, "r" )
qualfiles = {}
# read lens
specieslist = speciesAndLens.split(":")
species_to_lengths = {}
for entry in specieslist:
fields = entry.split(",")
lenstream = fileinput.FileInput( fields[1] )
lendict = dict()
for line in lenstream:
region = line.split()
lendict[region[0]] = int(region[1])
species_to_lengths[fields[0]] = lendict
if len(fields) >= 3:
qualfiles[fields[0]] = fields[2]
specieslist = map( lambda(a): a.split(":")[0], specieslist )
# open quality binned_arrays
reader = None
writer = None
if inputformat == "axt":
# load axt
if len(specieslist) != 2:
print "AXT is pairwise only."
sys.exit()
reader = bx.align.axt.Reader(instream, species1=specieslist[0], \
species2=specieslist[1], \
species_to_lengths = species_to_lengths)
elif outputformat == "maf":
# load maf
reader = bx.align.maf.Reader(instream, species_to_lengths=species_to_lengths)
if outputformat == "axt":
# setup axt
if len(specieslist) != 2:
print "AXT is pairwise only."
sys.exit()
writer = bx.align.axt.Writer(outstream, attributes=reader.attributes)
elif outputformat == "maf":
# setup maf
writer = bx.align.maf.Writer(outstream, attributes=reader.attributes)
qualfilter = Simple( mask=mask, qualspecies = species_to_lengths, \
qualfiles = qualfiles, minqual = minqual, cache=50 )
qualfilter.run( reader, writer.write )
print "For "+str(qualfilter.total)+" base pairs, "+str(qualfilter.masked)+" base pairs were masked."
print str(float(qualfilter.masked)/float(qualfilter.total) * 100)+"%"
if __name__ == "__main__":
main()
| 31.444444
| 104
| 0.612271
|
7951bf8558808751e0c6702c596e64637786e70e
| 1,511
|
py
|
Python
|
src/utils/archive/roc_img.py
|
xmuyzz/IVContrast
|
f3100e54f1808e1a796acd97ef5d23d0a2fd4f6c
|
[
"MIT"
] | null | null | null |
src/utils/archive/roc_img.py
|
xmuyzz/IVContrast
|
f3100e54f1808e1a796acd97ef5d23d0a2fd4f6c
|
[
"MIT"
] | null | null | null |
src/utils/archive/roc_img.py
|
xmuyzz/IVContrast
|
f3100e54f1808e1a796acd97ef5d23d0a2fd4f6c
|
[
"MIT"
] | null | null | null |
#--------------------------------------------------------------------------------------
# Deep learning for classification for contrast CT;
# Transfer learning using Google Inception V3;
#-----------------------------------------------------------------------------------------
import os
import numpy as np
import pandas as pd
import pickle
from utils.mean_CI import mean_CI
from utils.plot_roc import plot_roc
from utils.roc_bootstrap import roc_bootstrap
# ----------------------------------------------------------------------------------
# ROC and AUC on image level
# ----------------------------------------------------------------------------------
def roc_img(run_type, output_dir, roc_fn, color, bootstrap, save_dir):
### determine if this is train or test
if run_type == 'train' or run_type == 'val':
df_sum = pd.read_pickle(os.path.join(save_dir, 'df_val_pred.p'))
if run_type == 'test':
df_sum = pd.read_pickle(os.path.join(save_dir, 'df_test_pred.p'))
y_true = df_sum['label'].to_numpy()
y_pred = df_sum['y_pred'].to_numpy()
### plot roc curve
auc1 = plot_roc(
save_dir=save_dir,
y_true=y_true,
y_pred=y_pred,
roc_fn=roc_fn,
color=color
)
### calculate roc, tpr, tnr with 1000 bootstrap
stat1 = roc_bootstrap(
bootstrap=bootstrap,
y_true=y_true,
y_pred=y_pred
)
print('roc img:')
print(auc1)
print(stat1)
return auc1, stat1
| 29.627451
| 90
| 0.499669
|
7951bf9d752b67a9460634d77ce6bd44c14e2eb3
| 1,231
|
py
|
Python
|
scripts/pat_comp_cordic.py
|
tzaumiaan/vhdl_repo
|
1fc24e1fc1b6930de069f37cc80922cbb7dd2c2c
|
[
"MIT"
] | null | null | null |
scripts/pat_comp_cordic.py
|
tzaumiaan/vhdl_repo
|
1fc24e1fc1b6930de069f37cc80922cbb7dd2c2c
|
[
"MIT"
] | null | null | null |
scripts/pat_comp_cordic.py
|
tzaumiaan/vhdl_repo
|
1fc24e1fc1b6930de069f37cc80922cbb7dd2c2c
|
[
"MIT"
] | null | null | null |
import verif_utils
w_data = 16
thr_err = 8
class pattern_comparator(verif_utils.pattern_comparator):
def run(self) -> int:
cnt_err = 0
for p_, d_ in self.pattern_list:
cnt_err += verif_utils.check_pat_diff(p_, d_, f_diff=line_comp_cordic)
return cnt_err
def line_comp_cordic(golden: str, dump: str, line_id: int) -> int:
line_decode = lambda x: [
verif_utils.signed_hex2int(v, w_data) for v in x.split(" ")
]
err_msg = ""
for v, g, d in zip(["x", "y", "theta"], line_decode(golden), line_decode(dump)):
if abs(g - d) > thr_err:
# exception for theta if one is close to 0x7fff and anotehr is close to 0x8000
if abs(abs(g - d) - (1 << w_data)) < thr_err:
continue # not counted as error
err_msg += "\n {}: expected({}) differ from result({}) too much!".format(
v, verif_utils.int2hex(g, w_data), verif_utils.int2hex(d, w_data)
)
if err_msg != "":
print(
verif_utils.ascii_colorize(
"Mismatch at line {}:{}".format(line_id, err_msg), color="red"
)
)
return 1
return 0
| 34.194444
| 91
| 0.556458
|
7951c06e847047cc41968ea987954dd8636d101d
| 553
|
py
|
Python
|
trick.py
|
Fog-Wolf/flask_toolkots
|
1ca320f5cf9ebb14f56b054c952be06bacd4936d
|
[
"MIT"
] | 4
|
2020-09-10T08:32:53.000Z
|
2020-09-16T06:05:46.000Z
|
trick.py
|
Fog-Wolf/flask_toolkits
|
1ca320f5cf9ebb14f56b054c952be06bacd4936d
|
[
"MIT"
] | null | null | null |
trick.py
|
Fog-Wolf/flask_toolkits
|
1ca320f5cf9ebb14f56b054c952be06bacd4936d
|
[
"MIT"
] | null | null | null |
# -*- coding: utf-8 -*-
# ░░░░░░░░░░░░░░░░░░░░░░░░▄░░
# ░░░░░░░░░▐█░░░░░░░░░░░▄▀▒▌░
# ░░░░░░░░▐▀▒█░░░░░░░░▄▀▒▒▒▐
# ░░░░░░░▐▄▀▒▒▀▀▀▀▄▄▄▀▒▒▒▒▒▐
# ░░░░░▄▄▀▒░▒▒▒▒▒▒▒▒▒█▒▒▄█▒▐
# ░░░▄▀▒▒▒░░░▒▒▒░░░▒▒▒▀██▀▒▌
# ░░▐▒▒▒▄▄▒▒▒▒░░░▒▒▒▒▒▒▒▀▄▒▒
# ░░▌░░▌█▀▒▒▒▒▒▄▀█▄▒▒▒▒▒▒▒█▒▐
# ░▐░░░▒▒▒▒▒▒▒▒▌██▀▒▒░░░▒▒▒▀▄
# ░▌░▒▄██▄▒▒▒▒▒▒▒▒▒░░░░░░▒▒▒▒
# ▀▒▀▐▄█▄█▌▄░▀▒▒░░░░░░░░░░▒▒▒
# @Author : 雾江南
def simple_async(f):
from threading import Thread
def wrapper(*args, **kwargs):
thr = Thread(target=f, args=args, kwargs=kwargs)
thr.start()
return wrapper
| 23.041667
| 56
| 0.24774
|
7951c0c6d4e283afcb48ecf7053acb9e1c01c928
| 1,626
|
py
|
Python
|
test_rpic.py
|
clamytoe/Random-Picture
|
8acef2bf179d94032a0aef5d54078befa6cb401f
|
[
"MIT"
] | 4
|
2019-08-18T02:06:05.000Z
|
2021-05-15T00:49:03.000Z
|
test_rpic.py
|
clamytoe/Random-Picture
|
8acef2bf179d94032a0aef5d54078befa6cb401f
|
[
"MIT"
] | null | null | null |
test_rpic.py
|
clamytoe/Random-Picture
|
8acef2bf179d94032a0aef5d54078befa6cb401f
|
[
"MIT"
] | null | null | null |
from os import path, rmdir, sys, unlink
import pytest
from rpic import Wallhaven
PLATFORM = sys.platform
@pytest.fixture(scope="session")
def haven():
return Wallhaven()
def test_url(haven):
url = (
"https://wallhaven.cc/search?categories=111&purity=100&"
"atleast=1920x1080&sorting=random&order=desc"
)
assert haven.url == url
def test_local_path(haven):
if PLATFORM == "win32":
assert haven.local_path == r"C:\Users\clamy\Pictures\wallpaper.jpg"
else:
assert haven.local_path == "/home/mohh/Pictures/wallpaper.jpg"
def test_wallpapers(haven):
if PLATFORM == "win32":
assert haven.wallpapers == r"C:\Users\clamy\Pictures\wallpapers"
else:
assert haven.wallpapers == "/home/mohh/Pictures/wallpapers"
def test_check_dir(haven):
tmp = "tmp"
assert not path.exists(tmp)
haven.check_dir(tmp)
assert path.exists(tmp)
assert path.isdir(tmp)
rmdir(tmp)
def test_download_image(haven):
url = "https://wallhaven.cc/images/layout/logo_sm.png"
image_loc = path.join(haven.img_folder, "test.jpg")
assert not path.exists(image_loc)
haven.download_image(image_loc, url)
assert path.exists(image_loc)
unlink(image_loc)
def test_download_image_bad_url(haven, capfd):
url = "https://webgenetics.com/wg_logo.png"
image_loc = path.join(haven.img_folder, "wg_logo.png")
assert not path.exists(image_loc)
with pytest.raises(SystemExit):
haven.download_image(image_loc, url)
output = capfd.readouterr()[0].strip()
assert output == "<Response [404]>"
unlink(image_loc)
| 25.809524
| 75
| 0.686347
|
7951c234c897b66587a135ab2359e2790f1fda45
| 2,884
|
py
|
Python
|
Chapter05/webapp/blog/controllers.py
|
jayakumardhananjayan/pythonwebtut
|
a7547473fec5b90a91aea5395131e6eff245b495
|
[
"MIT"
] | 4
|
2019-05-16T16:34:06.000Z
|
2021-09-10T17:47:36.000Z
|
Chapter05/webapp/blog/controllers.py
|
jayakumardhananjayan/pythonwebtut
|
a7547473fec5b90a91aea5395131e6eff245b495
|
[
"MIT"
] | null | null | null |
Chapter05/webapp/blog/controllers.py
|
jayakumardhananjayan/pythonwebtut
|
a7547473fec5b90a91aea5395131e6eff245b495
|
[
"MIT"
] | 1
|
2018-11-29T13:54:38.000Z
|
2018-11-29T13:54:38.000Z
|
from sqlalchemy import func
from flask import render_template, Blueprint, flash, redirect, url_for, current_app
from .models import db, Post, Tag, Comment, User, tags
from .forms import CommentForm
blog_blueprint = Blueprint(
'blog',
__name__,
template_folder='../templates/blog',
url_prefix="/blog"
)
def sidebar_data():
recent = Post.query.order_by(Post.publish_date.desc()).limit(5).all()
top_tags = db.session.query(
Tag, func.count(tags.c.post_id).label('total')
).join(tags).group_by(Tag).order_by('total DESC').limit(5).all()
return recent, top_tags
@blog_blueprint.route('/')
@blog_blueprint.route('/<int:page>')
def home(page=1):
posts = Post.query.order_by(Post.publish_date.desc()).paginate(page,
current_app.config.get('POSTS_PER_PAGE', 10),
False)
recent, top_tags = sidebar_data()
return render_template(
'home.html',
posts=posts,
recent=recent,
top_tags=top_tags
)
@blog_blueprint.route('/post/<int:post_id>', methods=('GET', 'POST'))
def post(post_id):
form = CommentForm()
if form.validate_on_submit():
new_comment = Comment()
new_comment.name = form.name.data
new_comment.text = form.text.data
new_comment.post_id = post_id
try:
db.session.add(new_comment)
db.session.commit()
except Exception as e:
flash('Error adding your comment: %s' % str(e), 'error')
db.session.rollback()
else:
flash('Comment added', 'info')
return redirect(url_for('blog.post', post_id=post_id))
post = Post.query.get_or_404(post_id)
tags = post.tags
comments = post.comments.order_by(Comment.date.desc()).all()
recent, top_tags = sidebar_data()
return render_template(
'post.html',
post=post,
tags=tags,
comments=comments,
recent=recent,
top_tags=top_tags,
form=form
)
@blog_blueprint.route('/tag/<string:tag_name>')
def posts_by_tag(tag_name):
tag = Tag.query.filter_by(title=tag_name).first_or_404()
posts = tag.posts.order_by(Post.publish_date.desc()).all()
recent, top_tags = sidebar_data()
return render_template(
'tag.html',
tag=tag,
posts=posts,
recent=recent,
top_tags=top_tags
)
@blog_blueprint.route('/user/<string:username>')
def posts_by_user(username):
user = User.query.filter_by(username=username).first_or_404()
posts = user.posts.order_by(Post.publish_date.desc()).all()
recent, top_tags = sidebar_data()
return render_template(
'user.html',
user=user,
posts=posts,
recent=recent,
top_tags=top_tags
)
| 28.27451
| 112
| 0.610957
|
7951c36467770bf6c45e78684fecb32d630b462c
| 1,059
|
py
|
Python
|
Array/FirstBadVersion.py
|
menghanY/LeetCode-Python
|
85f9dc4a5b18a3b8a4a3d7b3a6eeb0e935901534
|
[
"MIT"
] | null | null | null |
Array/FirstBadVersion.py
|
menghanY/LeetCode-Python
|
85f9dc4a5b18a3b8a4a3d7b3a6eeb0e935901534
|
[
"MIT"
] | null | null | null |
Array/FirstBadVersion.py
|
menghanY/LeetCode-Python
|
85f9dc4a5b18a3b8a4a3d7b3a6eeb0e935901534
|
[
"MIT"
] | null | null | null |
# https://leetcode.com/problems/first-bad-version/
# You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the previous version, all the versions after a bad version are also bad.
#
# Suppose you have n versions [1, 2, ..., n] and you want to find out the first bad one, which causes all the following ones to be bad.
#
# You are given an API bool isBadVersion(version) which will return whether version is bad. Implement a function to find the first bad version. You should minimize the number of calls to the API.
def isBadVersion(version):
return version > 2
def firstBadVersion(n):
if n == 1: return 1
beginV = 1
endV = n
while beginV < endV:
currentV = (beginV + endV) // 2
if isBadVersion(currentV):
endV = currentV - 1
if isBadVersion(endV) == False:
return currentV
else:
beginV = currentV + 1
return endV
| 44.125
| 271
| 0.68272
|
7951c45b8db38dac6468a25a64ed56dab7445fee
| 983
|
py
|
Python
|
modules/role_tag/cog.py
|
abrahammurciano/rolling-tags
|
189a05087c55f255be110ce6239518c1113bd24f
|
[
"MIT"
] | 2
|
2021-02-02T16:28:52.000Z
|
2021-04-19T11:13:04.000Z
|
modules/role_tag/cog.py
|
abrahammurciano/rolling-tags
|
189a05087c55f255be110ce6239518c1113bd24f
|
[
"MIT"
] | 4
|
2021-04-21T15:31:24.000Z
|
2022-01-20T23:27:45.000Z
|
modules/role_tag/cog.py
|
abrahammurciano/rolling-tags
|
189a05087c55f255be110ce6239518c1113bd24f
|
[
"MIT"
] | 1
|
2021-04-22T14:17:50.000Z
|
2021-04-22T14:17:50.000Z
|
from modules.role_tag.role import Role
from modules.role_tag.member import Member
from discord.ext import commands
import discord
class RoleTagsCog(commands.Cog, name="Role Tags"):
def __init__(self, bot: commands.Bot):
self.bot = bot
@commands.Cog.listener()
async def on_member_update(self, before: discord.Member, after: discord.Member):
before = Member(before)
after = Member(after)
if after.current_tags() != after.tags():
await after.apply_tags()
print(
"Renamed",
before.inner_member.display_name,
"to",
after.inner_member.display_name,
)
@commands.Cog.listener()
async def on_guild_role_update(self, before: discord.Role, after: discord.Role):
before = Role(before)
after = Role(after)
if before.tag != after.tag:
print(before.inner_role.name, "changed to", after.inner_role.name)
for member in after.inner_role.members:
await Member(member).apply_tags()
def setup(bot: commands.Bot):
bot.add_cog(RoleTagsCog(bot))
| 28.085714
| 81
| 0.732452
|
7951c4621320ead3274e7bfc2b56767f3c7c8d13
| 4,502
|
py
|
Python
|
titer_model/implementation-nextstrain-augur/base/prediction.py
|
blab/dengue
|
5eacc47fbd77c59e7342d5be4aa81f7d3b4ff0bf
|
[
"CC-BY-4.0",
"MIT"
] | 4
|
2019-03-31T22:03:48.000Z
|
2020-06-16T21:04:24.000Z
|
titer_model/implementation-nextstrain-augur/base/prediction.py
|
emmahodcroft/dengue-antigenic-dynamics
|
5eacc47fbd77c59e7342d5be4aa81f7d3b4ff0bf
|
[
"CC-BY-4.0",
"MIT"
] | 4
|
2018-10-12T02:13:10.000Z
|
2019-07-24T02:44:53.000Z
|
titer_model/implementation-nextstrain-augur/base/prediction.py
|
emmahodcroft/dengue-antigenic-dynamics
|
5eacc47fbd77c59e7342d5be4aa81f7d3b4ff0bf
|
[
"CC-BY-4.0",
"MIT"
] | 5
|
2018-09-10T23:14:09.000Z
|
2020-12-27T20:57:34.000Z
|
from __future__ import division, print_function
import numpy as np
import time
from collections import defaultdict
from base.io_util import myopen
from itertools import izip
import pandas as pd
def LBI(tree, tau=0.001, attr='lbi'):
'''
traverses the tree in postorder and preorder to calculate the
up and downstream tree length exponentially weighted by distance.
then adds them as LBI
tree -- Biopython tree
tau -- time scale for tree length integration
attr -- the attribute name used to store the result
'''
# traverse the tree in postorder (children first) to calculate msg to parents
for node in tree.find_clades(order='postorder'):
node.down_polarizer = 0
node.up_polarizer = 0
for child in node:
node.up_polarizer += child.up_polarizer
bl = node.branch_length/tau
node.up_polarizer *= np.exp(-bl)
if node.train: node.up_polarizer += tau*(1-np.exp(-bl))
# traverse the tree in preorder (parents first) to calculate msg to children
for node in tree.get_nonterminals(order='preorder'):
for child1 in node:
child1.down_polarizer = node.down_polarizer
for child2 in node:
if child1!=child2:
child1.down_polarizer += child2.up_polarizer
bl = child1.branch_length/tau
child1.down_polarizer *= np.exp(-bl)
if child1.train: child1.down_polarizer += tau*(1-np.exp(-bl))
# go over all nodes and calculate the LBI (can be done in any order)
for node in tree.find_clades():
tmp_LBI = node.down_polarizer
for child in node:
tmp_LBI += child.up_polarizer
node.__setattr__(attr, tmp_LBI)
class tree_predictor(object):
"""class implementing basic methods to extrapolate genetic diversity
into the future. specific predictive features need to be implemented
by the subclasses"""
def __init__(self, tree=None, seqs=None, features=[], **kwargs):
super(tree_predictor, self).__init__()
self.tree = tree
self.seqs = seqs
self.features = features
self.kwargs = kwargs
def set_train(self, train_interval, train_filter=None):
'''
mark all nodes in tree as test, train, or neither
train_interval -- (start_date, stop_date) as numerical date
'''
if train_filter is None: train_filter = lambda x:True
self.train_interval = train_interval
in_interval = lambda x,y: (x>=y[0])&(x<y[1])
n_train = 0
for node in self.tree.find_clades(order='postorder'):
if node.is_terminal():
node.train = in_interval(node.numdate, train_interval)&train_filter(node)
n_train+=node.train
else:
node.train = any([c.train for c in node.clades])
print(train_interval, 'selected',n_train, 'terminals for training')
def set_test(self, test_interval, test_filter=None):
'''
mark all nodes in tree as test, train, or neither
test_interval -- (start_date, stop_date) as numerical date
'''
if test_filter is None: test_filter = lambda x:True
self.test_interval = test_interval
in_interval = lambda x,y: (x>=y[0])&(x<y[1])
for node in self.tree.get_terminals():
if node.is_terminal():
node.test = in_interval(node.numdate, test_interval)&test_filter(node)
else:
node.test = any([c.test for c in node.clades])
def estimate_training_frequencies(self):
from base.frequencies import tree_frequencies
npivots = int((self.train_interval[1]-self.train_interval[0])*12)
pivots=np.linspace(self.train_interval[0], self.train_interval[1], 12)
fe = tree_frequencies(self.tree, pivots, node_filter=lambda x:x.train,
min_clades=10, **self.kwargs)
fe.estimate_clade_frequencies()
# dictionary containing frequencies of all clades.
# the keys are the node.clade attributes
return fe.pivots, fe.frequencies
def calculate_LBI(self, tau=0.0005, dt=1):
for node in self.tree.find_clades():
node.LBI={}
for tint in self.train_intervals:
self.set_train((tint[1]-dt, tint[1]))
LBI(self.tree, tau=tau, attr='lbi')
for node in self.tree.find_clades():
node.LBI[tint] = node.lbi/tau
| 39.147826
| 89
| 0.635717
|
7951c612dbc697b10391c85f6669a5abee4cbdd8
| 2,179
|
py
|
Python
|
setup.py
|
Manny27nyc/oci-python-sdk
|
de60b04e07a99826254f7255e992f41772902df7
|
[
"Apache-2.0",
"BSD-3-Clause"
] | null | null | null |
setup.py
|
Manny27nyc/oci-python-sdk
|
de60b04e07a99826254f7255e992f41772902df7
|
[
"Apache-2.0",
"BSD-3-Clause"
] | null | null | null |
setup.py
|
Manny27nyc/oci-python-sdk
|
de60b04e07a99826254f7255e992f41772902df7
|
[
"Apache-2.0",
"BSD-3-Clause"
] | null | null | null |
# coding: utf-8
# Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
# This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license.
import io
import os
import re
from setuptools import setup, find_packages
def open_relative(*path):
"""
Opens files in read-only with a fixed utf-8 encoding.
All locations are relative to this setup.py file.
"""
here = os.path.abspath(os.path.dirname(__file__))
filename = os.path.join(here, *path)
return io.open(filename, mode="r", encoding="utf-8")
with open_relative("src", "oci", "version.py") as fd:
version = re.search(
r"^__version__\s*=\s*['\"]([^'\"]*)['\"]",
fd.read(), re.MULTILINE).group(1)
if not version:
raise RuntimeError("Cannot find version information")
with open_relative("README.rst") as f:
readme = f.read()
requires = [
"certifi",
"configparser==4.0.2 ; python_version < '3'",
"cryptography>=3.2.1,<=3.4.7",
"pyOpenSSL>=17.5.0,<=19.1.0",
"python-dateutil>=2.5.3,<3.0.0",
"pytz>=2016.10",
]
setup(
name="oci",
url="https://docs.oracle.com/en-us/iaas/tools/python/latest/index.html",
version=version,
description="Oracle Cloud Infrastructure Python SDK",
long_description=readme,
author="Oracle",
author_email="joe.levy@oracle.com",
packages=find_packages(where="src"),
package_dir={"": "src"},
include_package_data=True,
install_requires=requires,
license="Universal Permissive License 1.0 or Apache License 2.0",
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"License :: OSI Approved :: Universal Permissive License (UPL)",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
]
)
| 33.523077
| 245
| 0.649839
|
7951c6da18afea0dcb145c3653b7b89f78f9ad60
| 2,462
|
py
|
Python
|
utils.py
|
bkong1990/pytorch-adda
|
a503bc47187e61f06636d843be067ffb889dda6f
|
[
"MIT"
] | 415
|
2017-08-22T11:29:38.000Z
|
2022-03-22T15:54:17.000Z
|
utils.py
|
bkong1990/pytorch-adda
|
a503bc47187e61f06636d843be067ffb889dda6f
|
[
"MIT"
] | 26
|
2017-12-19T02:53:21.000Z
|
2021-12-08T06:29:44.000Z
|
utils.py
|
bkong1990/pytorch-adda
|
a503bc47187e61f06636d843be067ffb889dda6f
|
[
"MIT"
] | 136
|
2017-11-15T01:08:40.000Z
|
2022-03-23T23:19:50.000Z
|
"""Utilities for ADDA."""
import os
import random
import torch
import torch.backends.cudnn as cudnn
from torch.autograd import Variable
import params
from datasets import get_mnist, get_usps
def make_variable(tensor, volatile=False):
"""Convert Tensor to Variable."""
if torch.cuda.is_available():
tensor = tensor.cuda()
return Variable(tensor, volatile=volatile)
def make_cuda(tensor):
"""Use CUDA if it's available."""
if torch.cuda.is_available():
tensor = tensor.cuda()
return tensor
def denormalize(x, std, mean):
"""Invert normalization, and then convert array into image."""
out = x * std + mean
return out.clamp(0, 1)
def init_weights(layer):
"""Init weights for layers w.r.t. the original paper."""
layer_name = layer.__class__.__name__
if layer_name.find("Conv") != -1:
layer.weight.data.normal_(0.0, 0.02)
elif layer_name.find("BatchNorm") != -1:
layer.weight.data.normal_(1.0, 0.02)
layer.bias.data.fill_(0)
def init_random_seed(manual_seed):
"""Init random seed."""
seed = None
if manual_seed is None:
seed = random.randint(1, 10000)
else:
seed = manual_seed
print("use random seed: {}".format(seed))
random.seed(seed)
torch.manual_seed(seed)
if torch.cuda.is_available():
torch.cuda.manual_seed_all(seed)
def get_data_loader(name, train=True):
"""Get data loader by name."""
if name == "MNIST":
return get_mnist(train)
elif name == "USPS":
return get_usps(train)
def init_model(net, restore):
"""Init models with cuda and weights."""
# init weights of model
net.apply(init_weights)
# restore model weights
if restore is not None and os.path.exists(restore):
net.load_state_dict(torch.load(restore))
net.restored = True
print("Restore model from: {}".format(os.path.abspath(restore)))
# check if cuda is available
if torch.cuda.is_available():
cudnn.benchmark = True
net.cuda()
return net
def save_model(net, filename):
"""Save trained model."""
if not os.path.exists(params.model_root):
os.makedirs(params.model_root)
torch.save(net.state_dict(),
os.path.join(params.model_root, filename))
print("save pretrained model to: {}".format(os.path.join(params.model_root,
filename)))
| 26.473118
| 79
| 0.637693
|
7951c73956c506bd02c34e5c7fd3e559875c08fd
| 4,805
|
py
|
Python
|
pyelect/utils.py
|
cjerdonek/sf-election-data
|
ad9a86245d6bb2aa7b488d94b24b0ba9ca999b1e
|
[
"BSD-3-Clause"
] | null | null | null |
pyelect/utils.py
|
cjerdonek/sf-election-data
|
ad9a86245d6bb2aa7b488d94b24b0ba9ca999b1e
|
[
"BSD-3-Clause"
] | null | null | null |
pyelect/utils.py
|
cjerdonek/sf-election-data
|
ad9a86245d6bb2aa7b488d94b24b0ba9ca999b1e
|
[
"BSD-3-Clause"
] | null | null | null |
"""Project-wide helper functions."""
import logging
import os
import yaml
_log = logging.getLogger()
FILE_MANUAL = 'manual'
FILE_AUTO_GENERATED = 'auto_generated'
FILE_AUTO_UPDATED = 'auto_updated'
FILE_TYPES = (FILE_MANUAL, FILE_AUTO_UPDATED, FILE_AUTO_GENERATED)
DIR_PRE_DATA = 'pre_data'
KEY_META_COMMENTS = 'comments'
KEY_META = '_meta'
KEY_META_COMMENTS = 'comments'
KEY_FILE_TYPE = '_type'
KEY_FILE_TYPE_COMMENT = '_type_comment'
FILE_TYPE_COMMENTS = {
FILE_AUTO_UPDATED:
"WARNING: this file is auto-updated. Any YAML comments will be deleted.",
FILE_AUTO_GENERATED:
"WARNING: this file is auto-generated. Do not edit this file!",
}
# The idea for this comes from here:
# http://stackoverflow.com/questions/8640959/how-can-i-control-what-scalar-form-pyyaml-uses-for-my-data
def _yaml_str_representer(dumper, data):
"""A PyYAML representer that uses literal blocks for multi-line strings.
For example--
long: |
This is
a multi-line
string.
short: This is a one-line string.
"""
style = '|' if '\n' in data else None
return dumper.represent_scalar('tag:yaml.org,2002:str', data, style=style)
yaml.add_representer(str, _yaml_str_representer)
def filter_dict_by_keys(data, keys):
return {k: v for k, v in data.items() if k in keys}
def get_required(dict_, key, message=None):
try:
value = dict_[key]
except:
raise Exception("error getting key {0!r} from: {1!r} message={2}"
.format(key, dict_, message))
return value
def get_repo_dir():
repo_dir = os.path.join(os.path.dirname(__file__), os.pardir)
return os.path.abspath(repo_dir)
def get_pre_data_dir():
repo_dir = get_repo_dir()
dir_path = os.path.join(repo_dir, DIR_PRE_DATA)
return dir_path
def write(path, text):
_log.info("writing to: {0}".format(path))
with open(path, mode='w') as f:
f.write(text)
def read_yaml(path):
with open(path) as f:
data = yaml.load(f)
return data
def read_yaml_rel(rel_path, file_base=None, key=None):
"""Return the data in a YAML file as a Python dict.
Arguments:
rel_path: the path to the file relative to the repo root.
key: optionally, the key-value to return.
"""
if file_base is not None:
file_name = "{0}.yaml".format(file_base)
rel_path = os.path.join(rel_path, file_name)
repo_dir = get_repo_dir()
path = os.path.join(repo_dir, rel_path)
data = read_yaml(path)
if key is not None:
data = data[key]
return data
def yaml_dump(*args):
return yaml.dump(*args, default_flow_style=False, allow_unicode=True, default_style=None)
def _write_yaml(data, path, stdout=None):
if stdout is None:
stdout = False
with open(path, "w") as f:
yaml_dump(data, f)
if stdout:
print(yaml_dump(data))
def get_yaml_meta(data):
return get_required(data, KEY_META)
def _get_yaml_file_type_from_meta(meta):
file_type = get_required(meta, KEY_FILE_TYPE)
if file_type not in FILE_TYPES:
raise Exception('bad file type: {0}'.format(file_type))
return file_type
def _get_yaml_file_type(data):
meta = get_yaml_meta(data)
file_type = _get_yaml_file_type_from_meta(meta)
return file_type
def _set_header(data, file_type, comments=None):
meta = data.setdefault(KEY_META, {})
if file_type is None:
# Then we require that the file type already be specified.
file_type = _get_yaml_file_type_from_meta(meta)
else:
meta[KEY_FILE_TYPE] = file_type
comment = FILE_TYPE_COMMENTS.get(file_type)
if comment:
meta[KEY_FILE_TYPE_COMMENT] = comment
if comments is not None:
meta[KEY_META_COMMENTS] = comments
def write_yaml_with_header(data, rel_path, file_type=None, comments=None,
stdout=None):
repo_dir = get_repo_dir()
path = os.path.join(repo_dir, rel_path)
_set_header(data, file_type=file_type, comments=comments)
_write_yaml(data, path, stdout=stdout)
def _is_yaml_normalizable(data, path_hint):
try:
file_type = _get_yaml_file_type(data)
except:
raise Exception("for file: {0}".format(path_hint))
# Use a white list instead of a black list to be safe.
return file_type in (FILE_AUTO_UPDATED, FILE_AUTO_GENERATED)
def is_yaml_file_normalizable(path):
data = read_yaml(path)
return _is_yaml_normalizable(data, path_hint=path)
def normalize_yaml(path, stdout=None):
data = read_yaml(path)
normalizable = _is_yaml_normalizable(data, path_hint=path)
if not normalizable:
_log.info("skipping normalization: {0}".format(path))
return
write_yaml_with_header(data, path, stdout=stdout)
| 25.833333
| 103
| 0.685744
|
7951c7476cb998e605b8746ddd27d7af731a6432
| 529
|
py
|
Python
|
lec4.py
|
Caleb0929/IA241
|
2fed3e8d0f12bb8180a3e53beed036949cd9eaa0
|
[
"MIT"
] | null | null | null |
lec4.py
|
Caleb0929/IA241
|
2fed3e8d0f12bb8180a3e53beed036949cd9eaa0
|
[
"MIT"
] | null | null | null |
lec4.py
|
Caleb0929/IA241
|
2fed3e8d0f12bb8180a3e53beed036949cd9eaa0
|
[
"MIT"
] | null | null | null |
"""
lec 4 dict and tuple
"""
#my_tuple = 'a','b','c','d','e'
#print(my_tuple)
#my_2nd_tuple = ('a','b','c','d','e')
#print(my_2nd_tuple)
#not_a_tuple = ('a')
#print(type (not_a_tuple))
#is_a_tuple = ('a',)
#print(type (is_a_tuple))
#print(my_tuple[:])
my_car = {
'color': 'red',
'maker': 'toyota',
'year': 2015
}
print(my_car['year'])
print(my_car.get('year'))
my_car['model'] = 'Corolla'
print(my_car)
my_car['year'] = 2020
print(my_car)
print(len(my_car))
print('color'in my_car)
| 14.297297
| 37
| 0.572779
|
7951c784d422635fc6d5cb0596eeff1d1166a7d9
| 13,777
|
py
|
Python
|
neurogym/utils/plotting.py
|
lijianhet/neurogym
|
b82981f7ecac556e9dd3c478ffc37cce49e4ead1
|
[
"MIT"
] | null | null | null |
neurogym/utils/plotting.py
|
lijianhet/neurogym
|
b82981f7ecac556e9dd3c478ffc37cce49e4ead1
|
[
"MIT"
] | null | null | null |
neurogym/utils/plotting.py
|
lijianhet/neurogym
|
b82981f7ecac556e9dd3c478ffc37cce49e4ead1
|
[
"MIT"
] | null | null | null |
"""Plotting functions."""
import glob
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import gym
# TODO: This is changing user's plotting behavior for non-neurogym plots
mpl.rcParams['font.size'] = 7
mpl.rcParams['pdf.fonttype'] = 42
mpl.rcParams['ps.fonttype'] = 42
mpl.rcParams['font.family'] = 'arial'
def plot_env(env, num_steps=200, num_trials=None, def_act=None, model=None,
name=None, legend=True, ob_traces=[], fig_kwargs={}, fname=None):
"""Plot environment with agent.
Args:
env: already built neurogym task or name of it
num_steps: number of steps to run the task
num_trials: if not None, the number of trials to run
def_act: if not None (and model=None), the task will be run with the
specified action
model: if not None, the task will be run with the actions predicted by
model, which so far is assumed to be created and trained with the
stable-baselines toolbox:
(https://github.com/hill-a/stable-baselines)
name: title to show on the rewards panel
legend: whether to show the legend for actions panel or not.
ob_traces: if != [] observations will be plot as traces, with the labels
specified by ob_traces
fig_kwargs: figure properties admited by matplotlib.pyplot.subplots() fun.
fname: if not None, save fig or movie to fname
"""
# We don't use monitor here because:
# 1) env could be already prewrapped with monitor
# 2) monitor will save data and so the function will need a folder
if isinstance(env, str):
env = gym.make(env)
if name is None:
name = type(env).__name__
data = run_env(env=env, num_steps=num_steps, num_trials=num_trials,
def_act=def_act, model=model)
fig = fig_(
data['ob'], data['actions'],
gt=data['gt'], rewards=data['rewards'],
legend=legend, performance=data['perf'],
states=data['states'], name=name, ob_traces=ob_traces,
fig_kwargs=fig_kwargs, env=env, fname=fname
)
return fig
def run_env(env, num_steps=200, num_trials=None, def_act=None, model=None):
observations = []
ob_cum = []
state_mat = []
rewards = []
actions = []
actions_end_of_trial = []
gt = []
perf = []
ob = env.reset() # TODO: not saving this first observation
ob_cum_temp = ob
if num_trials is not None:
num_steps = 1e5 # Overwrite num_steps value
trial_count = 0
for stp in range(int(num_steps)):
if model is not None:
action, _states = model.predict(ob)
if isinstance(action, float) or isinstance(action, int):
action = [action]
if len(_states) > 0:
state_mat.append(_states)
elif def_act is not None:
action = def_act
else:
action = env.action_space.sample()
ob, rew, done, info = env.step(action)
ob_cum_temp += ob
ob_cum.append(ob_cum_temp.copy())
if isinstance(info, list):
info = info[0]
ob_aux = ob[0]
rew = rew[0]
done = done[0]
action = action[0]
else:
ob_aux = ob
if done:
env.reset()
observations.append(ob_aux)
rewards.append(rew)
actions.append(action)
if 'gt' in info.keys():
gt.append(info['gt'])
else:
gt.append(0)
if info['new_trial']:
actions_end_of_trial.append(action)
perf.append(info['performance'])
ob_cum_temp = np.zeros_like(ob_cum_temp)
trial_count += 1
if num_trials is not None and trial_count >= num_trials:
break
else:
actions_end_of_trial.append(-1)
perf.append(-1)
if model is not None and len(state_mat) > 0:
states = np.array(state_mat)
states = states[:, 0, :]
else:
states = None
data = {
'ob': np.array(observations).astype(np.float),
'ob_cum': np.array(ob_cum).astype(np.float),
'rewards': rewards,
'actions': actions,
'perf': perf,
'actions_end_of_trial': actions_end_of_trial,
'gt': gt,
'states': states
}
return data
# TODO: Change name, fig_ not a good name
def fig_(ob, actions, gt=None, rewards=None, performance=None, states=None,
legend=True, ob_traces=None, name='', fname=None, fig_kwargs={},
env=None):
"""Visualize a run in a simple environment.
Args:
ob: np array of observation (n_step, n_unit)
actions: np array of action (n_step, n_unit)
gt: np array of groud truth
rewards: np array of rewards
performance: np array of performance
states: np array of network states
name: title to show on the rewards panel and name to save figure
fname: if != '', where to save the figure
legend: whether to show the legend for actions panel or not.
ob_traces: None or list.
If list, observations will be plot as traces, with the labels
specified by ob_traces
fig_kwargs: figure properties admited by matplotlib.pyplot.subplots() fun.
env: environment class for extra information
"""
ob = np.array(ob)
actions = np.array(actions)
if len(ob.shape) == 2:
return plot_env_1dbox(
ob, actions, gt=gt, rewards=rewards,
performance=performance, states=states, legend=legend,
ob_traces=ob_traces, name=name, fname=fname,
fig_kwargs=fig_kwargs, env=env
)
elif len(ob.shape) == 4:
return plot_env_3dbox(
ob, actions, fname=fname, env=env
)
else:
raise ValueError('ob shape {} not supported'.format(str(ob.shape)))
def plot_env_1dbox(
ob, actions, gt=None, rewards=None, performance=None, states=None,
legend=True, ob_traces=None, name='', fname=None, fig_kwargs={},
env=None):
"""Plot environment with 1-D Box observation space."""
if len(ob.shape) != 2:
raise ValueError('ob has to be 2-dimensional.')
steps = np.arange(ob.shape[0]) # XXX: +1? 1st ob doesn't have action/gt
n_row = 2 # observation and action
n_row += rewards is not None
n_row += performance is not None
n_row += states is not None
gt_colors = 'gkmcry'
if not fig_kwargs:
fig_kwargs = dict(sharex=True, figsize=(5, n_row*1.2))
f, axes = plt.subplots(n_row, 1, **fig_kwargs)
i_ax = 0
# ob
ax = axes[i_ax]
i_ax += 1
if ob_traces:
assert len(ob_traces) == ob.shape[1],\
'Please provide label for each of the '+str(ob.shape[1]) +\
' traces in the observations'
for ind_tr, tr in enumerate(ob_traces):
ax.plot(ob[:, ind_tr], label=ob_traces[ind_tr])
ax.legend()
ax.set_xlim([-0.5, len(steps)-0.5])
else:
ax.imshow(ob.T, aspect='auto', origin='lower')
if env and hasattr(env.observation_space, 'name'):
# Plot environment annotation
yticks = []
yticklabels = []
for key, val in env.observation_space.name.items():
yticks.append((np.min(val)+np.max(val))/2)
yticklabels.append(key)
ax.set_yticks(yticks)
ax.set_yticklabels(yticklabels)
else:
ax.set_yticks([])
ax.spines['top'].set_visible(False)
ax.spines['bottom'].set_visible(False)
ax.spines['right'].set_visible(False)
if name:
ax.set_title(name + ' env')
ax.set_ylabel('Observations')
# actions
ax = axes[i_ax]
i_ax += 1
if len(actions.shape) > 1:
# Changes not implemented yet
ax.plot(steps, actions, marker='+', label='Actions')
else:
ax.plot(steps, actions, marker='+', label='Actions')
if gt is not None:
gt = np.array(gt)
if len(gt.shape) > 1:
for ind_gt in range(gt.shape[1]):
ax.plot(steps, gt[:, ind_gt], '--'+gt_colors[ind_gt],
label='Ground truth '+str(ind_gt))
else:
ax.plot(steps, gt, '--'+gt_colors[0], label='Ground truth')
ax.set_xlim([-0.5, len(steps)-0.5])
ax.set_ylabel('Actions')
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
if legend:
ax.legend()
if env and hasattr(env.action_space, 'name'):
# Plot environment annotation
yticks = []
yticklabels = []
for key, val in env.action_space.name.items():
yticks.append((np.min(val) + np.max(val)) / 2)
yticklabels.append(key)
ax.set_yticks(yticks)
ax.set_yticklabels(yticklabels)
# rewards
if rewards is not None:
ax = axes[i_ax]
i_ax += 1
ax.plot(steps, rewards, 'r', label='Rewards')
ax.set_ylabel('Reward')
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
if legend:
ax.legend()
ax.set_xlim([-0.5, len(steps)-0.5])
if env and hasattr(env, 'reward') and env.rewards:
# Plot environment annotation
yticks = []
yticklabels = []
for key, val in env.rewards.items():
yticks.append(val)
yticklabels.append('{:s} {:0.2f}'.format(key, val))
ax.set_yticks(yticks)
ax.set_yticklabels(yticklabels)
if performance is not None:
ax = axes[i_ax]
i_ax += 1
ax.plot(steps, performance, 'k', label='Performance')
ax.set_ylabel('Performance')
performance = np.array(performance)
mean_perf = np.mean(performance[performance != -1])
ax.set_title('Mean performance: ' + str(np.round(mean_perf, 2)))
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
if legend:
ax.legend()
ax.set_xlim([-0.5, len(steps)-0.5])
# states
if states is not None:
ax.set_xticks([])
ax = axes[i_ax]
i_ax += 1
plt.imshow(states[:, int(states.shape[1]/2):].T,
aspect='auto')
ax.set_title('Activity')
ax.set_ylabel('Neurons')
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.set_xlabel('Steps')
plt.tight_layout()
if fname:
fname = str(fname)
if not (fname.endswith('.png') or fname.endswith('.svg')):
fname += '.png'
f.savefig(fname, dpi=300)
plt.close(f)
return f
def plot_env_3dbox(ob, actions=None, fname='', env=None):
"""Plot environment with 3-D Box observation space."""
ob = ob.astype(np.uint8) # TODO: Temporary
fig = plt.figure()
ax = fig.add_axes([0.1, 0.1, 0.8, 0.8])
ax.axis('off')
im = ax.imshow(ob[0], animated=True)
def animate(i, *args, **kwargs):
im.set_array(ob[i])
return im,
if env is not None:
interval = env.dt
else:
interval = 50
ani = animation.FuncAnimation(fig, animate, frames=ob.shape[0],
interval=interval)
if fname:
writer = animation.writers['ffmpeg'](fps=int(1000 / interval))
fname = str(fname)
if not fname.endswith('.mp4'):
fname += '.mp4'
ani.save(fname, writer=writer, dpi=300)
def plot_rew_across_training(folder, window=500, ax=None,
fkwargs={'c': 'tab:blue'}, ytitle='',
legend=False, zline=False, metric_name='reward'):
data = put_together_files(folder)
if data:
sv_fig = False
if ax is None:
sv_fig = True
f, ax = plt.subplots(figsize=(8, 8))
metric = data[metric_name]
if isinstance(window, float):
if window < 1.0:
window = int(metric.size * window)
mean_metric = np.convolve(metric, np.ones((window,))/window,
mode='valid')
ax.plot(mean_metric, **fkwargs) # add color, label etc.
ax.set_xlabel('trials')
if not ytitle:
ax.set_ylabel('mean ' + metric_name + ' (running window' +
' of {:d} trials)'.format(window))
else:
ax.set_ylabel(ytitle)
if legend:
ax.legend()
if zline:
ax.axhline(0, c='k', ls=':')
if sv_fig:
f.savefig(folder + '/mean_' + metric_name + '_across_training.png')
else:
print('No data in: ', folder)
def put_together_files(folder):
files = glob.glob(folder + '/*_bhvr_data*npz')
data = {}
if len(files) > 0:
files = order_by_sufix(files)
file_data = np.load(files[0], allow_pickle=True)
for key in file_data.keys():
data[key] = file_data[key]
for ind_f in range(1, len(files)):
file_data = np.load(files[ind_f], allow_pickle=True)
for key in file_data.keys():
data[key] = np.concatenate((data[key], file_data[key]))
np.savez(folder + '/bhvr_data_all.npz', **data)
return data
def order_by_sufix(file_list):
sfx = [int(x[x.rfind('_')+1:x.rfind('.')]) for x in file_list]
sorted_list = [x for _, x in sorted(zip(sfx, file_list))]
return sorted_list
if __name__ == '__main__':
f = '/home/molano/res080220/SL_PerceptualDecisionMaking-v0_0/'
plot_rew_across_training(folder=f)
| 33.767157
| 82
| 0.575089
|
7951c796255457a419199d1cc4508eed48ddc81d
| 15,051
|
py
|
Python
|
venv/lib/python3.6/site-packages/openerplib/main.py
|
mathsaad/crudCRMOdoo
|
e6328a735ded31a3ebff3eb7e2ae9f39d2c48d29
|
[
"MIT"
] | null | null | null |
venv/lib/python3.6/site-packages/openerplib/main.py
|
mathsaad/crudCRMOdoo
|
e6328a735ded31a3ebff3eb7e2ae9f39d2c48d29
|
[
"MIT"
] | null | null | null |
venv/lib/python3.6/site-packages/openerplib/main.py
|
mathsaad/crudCRMOdoo
|
e6328a735ded31a3ebff3eb7e2ae9f39d2c48d29
|
[
"MIT"
] | null | null | null |
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) Stephane Wirtel
# Copyright (C) 2011 Nicolas Vanhoren
# Copyright (C) 2011 OpenERP s.a. (<http://openerp.com>).
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
##############################################################################
"""
OpenERP Client Library
Home page: http://pypi.python.org/pypi/openerp-client-lib
Code repository: https://code.launchpad.net/~niv-openerp/openerp-client-lib/trunk
"""
import xmlrpclib
import logging
import json
import urllib2
import random
_logger = logging.getLogger(__name__)
def _getChildLogger(logger, subname):
return logging.getLogger(logger.name + "." + subname)
class Connector(object):
"""
The base abstract class representing a connection to an OpenERP Server.
"""
__logger = _getChildLogger(_logger, 'connector')
def get_service(self, service_name):
"""
Returns a Service instance to allow easy manipulation of one of the services offered by the remote server.
:param service_name: The name of the service.
"""
return Service(self, service_name)
class XmlRPCConnector(Connector):
"""
A type of connector that uses the XMLRPC protocol.
"""
PROTOCOL = 'xmlrpc'
__logger = _getChildLogger(_logger, 'connector.xmlrpc')
def __init__(self, hostname, port=8069):
"""
Initialize by specifying the hostname and the port.
:param hostname: The hostname of the computer holding the instance of OpenERP.
:param port: The port used by the OpenERP instance for XMLRPC (default to 8069).
"""
self.url = 'http://%s:%d/xmlrpc' % (hostname, port)
def send(self, service_name, method, *args):
url = '%s/%s' % (self.url, service_name)
service = xmlrpclib.ServerProxy(url)
return getattr(service, method)(*args)
class XmlRPCSConnector(XmlRPCConnector):
"""
A type of connector that uses the secured XMLRPC protocol.
"""
PROTOCOL = 'xmlrpcs'
__logger = _getChildLogger(_logger, 'connector.xmlrpcs')
def __init__(self, hostname, port=8069):
super(XmlRPCSConnector, self).__init__(hostname, port)
self.url = 'https://%s:%d/xmlrpc' % (hostname, port)
class JsonRPCException(Exception):
def __init__(self, error):
self.error = error
def __str__(self):
return repr(self.error)
def json_rpc(url, fct_name, params):
data = {
"jsonrpc": "2.0",
"method": fct_name,
"params": params,
"id": random.randint(0, 1000000000),
}
req = urllib2.Request(url=url, data=json.dumps(data), headers={
"Content-Type":"application/json",
})
result = urllib2.urlopen(req)
result = json.load(result)
if result.get("error", None):
raise JsonRPCException(result["error"])
return result["result"]
class JsonRPCConnector(Connector):
"""
A type of connector that uses the JsonRPC protocol.
"""
PROTOCOL = 'jsonrpc'
__logger = _getChildLogger(_logger, 'connector.jsonrpc')
def __init__(self, hostname, port=8069):
"""
Initialize by specifying the hostname and the port.
:param hostname: The hostname of the computer holding the instance of OpenERP.
:param port: The port used by the OpenERP instance for JsonRPC (default to 8069).
"""
self.url = 'http://%s:%d/jsonrpc' % (hostname, port)
def send(self, service_name, method, *args):
return json_rpc(self.url, "call", {"service": service_name, "method": method, "args": args})
class JsonRPCSConnector(Connector):
"""
A type of connector that uses the JsonRPC protocol.
"""
PROTOCOL = 'jsonrpcs'
__logger = _getChildLogger(_logger, 'connector.jsonrpc')
def __init__(self, hostname, port=8069):
"""
Initialize by specifying the hostname and the port.
:param hostname: The hostname of the computer holding the instance of OpenERP.
:param port: The port used by the OpenERP instance for JsonRPC (default to 8069).
"""
self.url = 'https://%s:%d/jsonrpc' % (hostname, port)
def send(self, service_name, method, *args):
return json_rpc(self.url, "call", {"service": service_name, "method": method, "args": args})
class Service(object):
"""
A class to execute RPC calls on a specific service of the remote server.
"""
def __init__(self, connector, service_name):
"""
:param connector: A valid Connector instance.
:param service_name: The name of the service on the remote server.
"""
self.connector = connector
self.service_name = service_name
self.__logger = _getChildLogger(_getChildLogger(_logger, 'service'),service_name or "")
def __getattr__(self, method):
"""
:param method: The name of the method to execute on the service.
"""
self.__logger.debug('method: %r', method)
def proxy(*args):
"""
:param args: A list of values for the method
"""
self.__logger.debug('args: %r', args)
result = self.connector.send(self.service_name, method, *args)
self.__logger.debug('result: %r', result)
return result
return proxy
class Connection(object):
"""
A class to represent a connection with authentication to an OpenERP Server.
It also provides utility methods to interact with the server more easily.
"""
__logger = _getChildLogger(_logger, 'connection')
def __init__(self, connector,
database=None,
login=None,
password=None,
user_id=None):
"""
Initialize with login information. The login information is facultative to allow specifying
it after the initialization of this object.
:param connector: A valid Connector instance to send messages to the remote server.
:param database: The name of the database to work on.
:param login: The login of the user.
:param password: The password of the user.
:param user_id: The user id is a number identifying the user. This is only useful if you
already know it, in most cases you don't need to specify it.
"""
self.connector = connector
self.set_login_info(database, login, password, user_id)
self.user_context = None
def set_login_info(self, database, login, password, user_id=None):
"""
Set login information after the initialisation of this object.
:param connector: A valid Connector instance to send messages to the remote server.
:param database: The name of the database to work on.
:param login: The login of the user.
:param password: The password of the user.
:param user_id: The user id is a number identifying the user. This is only useful if you
already know it, in most cases you don't need to specify it.
"""
self.database, self.login, self.password = database, login, password
self.user_id = user_id
def check_login(self, force=True):
"""
Checks that the login information is valid. Throws an AuthenticationError if the
authentication fails.
:param force: Force to re-check even if this Connection was already validated previously.
Default to True.
"""
if self.user_id and not force:
return
if not self.database or not self.login or self.password is None:
raise AuthenticationError("Credentials not provided")
# TODO use authenticate instead of login
self.user_id = self.get_service("common").login(self.database, self.login, self.password)
if not self.user_id:
raise AuthenticationError("Authentication failure")
self.__logger.debug("Authenticated with user id %s", self.user_id)
def get_user_context(self):
"""
Query the default context of the user.
"""
if not self.user_context:
self.user_context = self.get_model('res.users').context_get()
return self.user_context
def get_model(self, model_name):
"""
Returns a Model instance to allow easy remote manipulation of an OpenERP model.
:param model_name: The name of the model.
"""
return Model(self, model_name)
def get_service(self, service_name):
"""
Returns a Service instance to allow easy manipulation of one of the services offered by the remote server.
Please note this Connection instance does not need to have valid authentication information since authentication
is only necessary for the "object" service that handles models.
:param service_name: The name of the service.
"""
return self.connector.get_service(service_name)
class AuthenticationError(Exception):
"""
An error thrown when an authentication to an OpenERP server failed.
"""
pass
class Model(object):
"""
Useful class to dialog with one of the models provided by an OpenERP server.
An instance of this class depends on a Connection instance with valid authentication information.
"""
def __init__(self, connection, model_name):
"""
:param connection: A valid Connection instance with correct authentication information.
:param model_name: The name of the model.
"""
self.connection = connection
self.model_name = model_name
self.__logger = _getChildLogger(_getChildLogger(_logger, 'object'), model_name or "")
def __getattr__(self, method):
"""
Provides proxy methods that will forward calls to the model on the remote OpenERP server.
:param method: The method for the linked model (search, read, write, unlink, create, ...)
"""
def proxy(*args, **kw):
"""
:param args: A list of values for the method
"""
self.connection.check_login(False)
self.__logger.debug(args)
result = self.connection.get_service('object').execute_kw(
self.connection.database,
self.connection.user_id,
self.connection.password,
self.model_name,
method,
args, kw)
if method == "read":
if isinstance(result, list) and len(result) > 0 and "id" in result[0]:
index = {}
for r in result:
index[r['id']] = r
result = [index[x] for x in args[0] if x in index]
self.__logger.debug('result: %r', result)
return result
return proxy
def search_read(self, domain=None, fields=None, offset=0, limit=None, order=None, context=None):
"""
A shortcut method to combine a search() and a read().
:param domain: The domain for the search.
:param fields: The fields to extract (can be None or [] to extract all fields).
:param offset: The offset for the rows to read.
:param limit: The maximum number of rows to read.
:param order: The order to class the rows.
:param context: The context.
:return: A list of dictionaries containing all the specified fields.
"""
record_ids = self.search(domain or [], offset, limit or False, order or False, context or {})
if not record_ids: return []
records = self.read(record_ids, fields or [], context or {})
return records
def get_connector(hostname=None, protocol="xmlrpc", port="auto"):
"""
A shortcut method to easily create a connector to a remote server using XMLRPC.
:param hostname: The hostname to the remote server.
:param protocol: The name of the protocol, must be "xmlrpc", "xmlrpcs", "jsonrpc" or "jsonrpcs".
:param port: The number of the port. Defaults to auto.
"""
if port == 'auto':
port = 8069
if protocol == "xmlrpc":
return XmlRPCConnector(hostname, port)
elif protocol == "xmlrpcs":
return XmlRPCSConnector(hostname, port)
if protocol == "jsonrpc":
return JsonRPCConnector(hostname, port)
elif protocol == "jsonrpcs":
return JsonRPCSConnector(hostname, port)
else:
raise ValueError("You must choose xmlrpc, xmlrpcs, jsonrpc or jsonrpcs")
def get_connection(hostname=None, protocol="xmlrpc", port='auto', database=None,
login=None, password=None, user_id=None):
"""
A shortcut method to easily create a connection to a remote OpenERP server.
:param hostname: The hostname to the remote server.
:param protocol: The name of the protocol, must be "xmlrpc", "xmlrpcs", "jsonrpc" or "jsonrpcs".
:param port: The number of the port. Defaults to auto.
:param connector: A valid Connector instance to send messages to the remote server.
:param database: The name of the database to work on.
:param login: The login of the user.
:param password: The password of the user.
:param user_id: The user id is a number identifying the user. This is only useful if you
already know it, in most cases you don't need to specify it.
"""
return Connection(get_connector(hostname, protocol, port), database, login, password, user_id)
| 39.712401
| 120
| 0.636503
|
7951c7f1520928499303c5622c13356d122b7e76
| 1,668
|
py
|
Python
|
jdcloud_sdk/services/vm/models/BriefInstanceDiskAttachment.py
|
jdcloud-apigateway/jdcloud-sdk-python
|
0886769bcf1fb92128a065ff0f4695be099571cc
|
[
"Apache-2.0"
] | 14
|
2018-04-19T09:53:56.000Z
|
2022-01-27T06:05:48.000Z
|
jdcloud_sdk/services/vm/models/BriefInstanceDiskAttachment.py
|
jdcloud-apigateway/jdcloud-sdk-python
|
0886769bcf1fb92128a065ff0f4695be099571cc
|
[
"Apache-2.0"
] | 15
|
2018-09-11T05:39:54.000Z
|
2021-07-02T12:38:02.000Z
|
jdcloud_sdk/services/vm/models/BriefInstanceDiskAttachment.py
|
jdcloud-apigateway/jdcloud-sdk-python
|
0886769bcf1fb92128a065ff0f4695be099571cc
|
[
"Apache-2.0"
] | 33
|
2018-04-20T05:29:16.000Z
|
2022-02-17T09:10:05.000Z
|
# coding=utf8
# Copyright 2018 JDCLOUD.COM
#
# 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.
#
# NOTE: This class is auto generated by the jdcloud code generator program.
class BriefInstanceDiskAttachment(object):
def __init__(self, diskCategory=None, autoDelete=None, localDisk=None, cloudDisk=None, deviceName=None, status=None):
"""
:param diskCategory: (Optional) 磁盘类型。
**系统盘**:取值为:`local` 本地系统盘 或 `cloud` 云盘系统盘。
**数据盘**:取值为:`local` 本地数据盘 或 `cloud` 云盘数据盘。
:param autoDelete: (Optional) 是否随实例一起删除,即删除实例时是否自动删除此磁盘。此参数仅对按配置计费的非多点挂载云硬盘生效。
`true`:随实例删除。
`false`:不随实例删除。
:param localDisk: (Optional) 本地磁盘配置,对应 `diskCategory=local`。
:param cloudDisk: (Optional) 云硬盘配置,对应 `diskCategory=cloud`。
:param deviceName: (Optional) 磁盘逻辑挂载点。
**系统盘**:默认为vda。
**数据盘**:取值范围:`[vdb~vdbm]`。
:param status: (Optional) 磁盘挂载状态。
取值范围:`attaching、detaching、attached、detached、error_attach、error_detach`。
"""
self.diskCategory = diskCategory
self.autoDelete = autoDelete
self.localDisk = localDisk
self.cloudDisk = cloudDisk
self.deviceName = deviceName
self.status = status
| 34.75
| 121
| 0.708633
|
7951c8aa92ba70f4a74ec305a24f5c52d507bfff
| 1,104
|
py
|
Python
|
contrib/opencensus-ext-azure/examples/metrics/standard.py
|
jtbeach/opencensus-python
|
2e396b063a238b3e823b6efc136b9a0405dd5565
|
[
"Apache-2.0"
] | 1
|
2019-09-21T13:52:19.000Z
|
2019-09-21T13:52:19.000Z
|
contrib/opencensus-ext-azure/examples/metrics/standard.py
|
jtbeach/opencensus-python
|
2e396b063a238b3e823b6efc136b9a0405dd5565
|
[
"Apache-2.0"
] | null | null | null |
contrib/opencensus-ext-azure/examples/metrics/standard.py
|
jtbeach/opencensus-python
|
2e396b063a238b3e823b6efc136b9a0405dd5565
|
[
"Apache-2.0"
] | null | null | null |
# Copyright 2019, OpenCensus Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# 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 psutil
import time
from opencensus.ext.azure import metrics_exporter
def main():
# All you need is the next line. You can disable standard metrics by
# passing in enable_standard_metrics=False into the constructor of
# new_metrics_exporter()
_exporter = metrics_exporter.new_metrics_exporter()
print(_exporter.max_batch_size)
for i in range(100):
print(psutil.virtual_memory())
time.sleep(5)
print("Done recording metrics")
if __name__ == "__main__":
main()
| 29.837838
| 74
| 0.740942
|
7951c8d0ecf0483d0875943bafef6573ab964005
| 1,282
|
py
|
Python
|
remind.py
|
vgeorgework/tk_gui_sqlite_project
|
f8de50ee685678d4eee238b3e60369cc9d699c92
|
[
"Unlicense"
] | null | null | null |
remind.py
|
vgeorgework/tk_gui_sqlite_project
|
f8de50ee685678d4eee238b3e60369cc9d699c92
|
[
"Unlicense"
] | null | null | null |
remind.py
|
vgeorgework/tk_gui_sqlite_project
|
f8de50ee685678d4eee238b3e60369cc9d699c92
|
[
"Unlicense"
] | null | null | null |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import Tkinter
import random
import backend as myback # i imported the backend file as an object
from Tkinter import StringVar
root = Tkinter.Tk()
root.configure(bg="white")
root.title("My Super To Do List")
root.geometry("500x500")
print "haiiiiiiiiiiii"
def add_task():
print "This is the place you need to add the insert comand which is in backend.py",txt_input.get()
#myback.connect() #accessing connect function from backend.py
myback.insert(1,txt_input.get())
def del_all():
pass
def del_one():
pass
lbl_title=Tkinter.Label(root,text="Reminder",bg="white")
lbl_title.pack()
lbl_display=Tkinter.Label(root,text=" ",bg="white")
lbl_display.pack()
txt_input = Tkinter.Entry(root,width=15)
txt_input.pack()
btn_add_task=Tkinter.Button(root,text="Add task",fg='green',bg='white',command=add_task)
btn_add_task.pack()
btn_del_task=Tkinter.Button(root,text="Delete All",fg='green',bg='white',command=del_all)
btn_del_task.pack()
btn_del_one_task=Tkinter.Button(root,text="Delete One",fg='green',bg='white',command=del_one)
btn_del_one_task.pack()
btn_quit=Tkinter.Button(root,text="Exit",fg='green',bg='white',command=exit)
btn_quit.pack()
lb_tasks=Tkinter.Listbox(root)
lb_tasks.pack()
root.mainloop()
| 22.892857
| 101
| 0.74493
|
7951c9516d11bd6d3c054d467563f963e71cfb2f
| 566
|
py
|
Python
|
ginger/app/validators/base.py
|
MiracleWong/flask-api
|
a3e14c666284a39b3a9992558c494b869f9d864f
|
[
"MIT"
] | null | null | null |
ginger/app/validators/base.py
|
MiracleWong/flask-api
|
a3e14c666284a39b3a9992558c494b869f9d864f
|
[
"MIT"
] | null | null | null |
ginger/app/validators/base.py
|
MiracleWong/flask-api
|
a3e14c666284a39b3a9992558c494b869f9d864f
|
[
"MIT"
] | null | null | null |
# -*- coding:utf-8 -*-
"""
created by MiracleWong on 2019/2/8
"""
from flask import request
from wtforms import Form
from app.libs.error_code import ParameterException
__author__ = 'MiracleWong'
class BaseForm(Form):
def __init__(self):
data = request.json
print(data)
super(BaseForm, self).__init__(data=data)
def validate_for_api(self):
valid = super(BaseForm, self).validate()
print("valid:")
print(valid)
if not valid:
raise ParameterException(msg=self.errors)
return self
| 21.769231
| 53
| 0.644876
|
7951c9aa6a9a9f08ba51ecbf41c4bcc7f6268bca
| 84
|
py
|
Python
|
telethon/_updates/__init__.py
|
MrGam-oy/Telethon
|
acc512683c107f80d47ab0fdaac0d1ac9439d43c
|
[
"MIT"
] | null | null | null |
telethon/_updates/__init__.py
|
MrGam-oy/Telethon
|
acc512683c107f80d47ab0fdaac0d1ac9439d43c
|
[
"MIT"
] | null | null | null |
telethon/_updates/__init__.py
|
MrGam-oy/Telethon
|
acc512683c107f80d47ab0fdaac0d1ac9439d43c
|
[
"MIT"
] | null | null | null |
from .entitycache import EntityCache, PackedChat
from .messagebox import MessageBox
| 28
| 48
| 0.857143
|
7951cad305af074540352b1394dcb9df0522e207
| 98
|
py
|
Python
|
xknx/io/const.py
|
jonppe/xknx
|
b08a122b0f3c170d91aae6213a60c7038e451c93
|
[
"MIT"
] | 1
|
2020-12-27T13:54:34.000Z
|
2020-12-27T13:54:34.000Z
|
xknx/io/const.py
|
jonppe/xknx
|
b08a122b0f3c170d91aae6213a60c7038e451c93
|
[
"MIT"
] | 1
|
2021-02-17T23:54:32.000Z
|
2021-02-17T23:54:32.000Z
|
xknx/io/const.py
|
mielune/xknx
|
57c248c386f2ae150d983f72a5a8da684097265d
|
[
"MIT"
] | null | null | null |
"""KNX Constants used within io."""
DEFAULT_MCAST_GRP = "224.0.23.12"
DEFAULT_MCAST_PORT = 3671
| 19.6
| 36
| 0.72449
|
7951cc7c784312b3d1728173d2ba65d41face630
| 1,284
|
py
|
Python
|
electrum_gui/common/coin/registry.py
|
liuzjalex/electrum
|
98f7c8bfdef071cd859d54f1f72c39688cde41cf
|
[
"MIT"
] | null | null | null |
electrum_gui/common/coin/registry.py
|
liuzjalex/electrum
|
98f7c8bfdef071cd859d54f1f72c39688cde41cf
|
[
"MIT"
] | null | null | null |
electrum_gui/common/coin/registry.py
|
liuzjalex/electrum
|
98f7c8bfdef071cd859d54f1f72c39688cde41cf
|
[
"MIT"
] | null | null | null |
import json
import os
from typing import Dict
from electrum_gui.common.coin.data import ChainInfo, ChainModel, CoinInfo
def _load_chains(chains_json_name: str) -> Dict[str, ChainInfo]:
raw_chains = json.loads(open(chains_json_name).read())
ret = {}
for config in raw_chains:
config["chain_model"] = ChainModel[config["chain_model"].upper()]
chain_info = ChainInfo(**config)
ret[chain_info.chain_code] = chain_info
return ret
def _load_coins(coins_json_name: str) -> Dict[str, CoinInfo]:
raw_coins_dict = json.loads(open(coins_json_name).read())
ret = {}
for chain_code, coins in raw_coins_dict.items():
for coin in coins:
coin_info = CoinInfo(chain_code=chain_code, **coin)
ret[coin_info.code] = coin_info
return ret
_base_pth = os.path.dirname(__file__)
mainnet_chains = _load_chains(os.path.join(_base_pth, "./configs/chains.json"))
testnet_chains = _load_chains(os.path.join(_base_pth, "./configs/testnet_chains.json"))
mainnet_coins = _load_coins(os.path.join(_base_pth, "./configs/coins.json"))
testnet_coins = _load_coins(os.path.join(_base_pth, "./configs/testnet_coins.json"))
chain_dict = {**mainnet_chains, **testnet_chains}
coin_dict = {**mainnet_coins, **testnet_coins}
| 30.571429
| 87
| 0.715732
|
7951cc995dd01b1a2776c7be40015f38555452d4
| 439
|
py
|
Python
|
transactions/migrations/0007_auto_20210108_2018.py
|
ankit-ryan/Banksystem
|
40138fdec7e3eba0430571a63026f97fba37dbcc
|
[
"MIT"
] | null | null | null |
transactions/migrations/0007_auto_20210108_2018.py
|
ankit-ryan/Banksystem
|
40138fdec7e3eba0430571a63026f97fba37dbcc
|
[
"MIT"
] | null | null | null |
transactions/migrations/0007_auto_20210108_2018.py
|
ankit-ryan/Banksystem
|
40138fdec7e3eba0430571a63026f97fba37dbcc
|
[
"MIT"
] | null | null | null |
# Generated by Django 3.1.3 on 2021-01-08 14:48
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('transactions', '0006_auto_20201230_0702'),
]
operations = [
migrations.AlterField(
model_name='statement',
name='statements_pdf',
field=models.FileField(upload_to='D:\\Mov\\banking-system-master2\\media'),
),
]
| 23.105263
| 87
| 0.621868
|
7951cccccdce63e2f75707acb8de5fd8e6787fd5
| 23,843
|
py
|
Python
|
stix_shifter_modules/splunk/tests/stix_translation/test_splunk_json_to_stix.py
|
grimmjow8/stix-shifter
|
7d252fc241a606f0141ed50d64368d8a5e7e5c5a
|
[
"Apache-2.0"
] | 129
|
2019-10-09T17:13:03.000Z
|
2022-03-03T08:25:46.000Z
|
stix_shifter_modules/splunk/tests/stix_translation/test_splunk_json_to_stix.py
|
grimmjow8/stix-shifter
|
7d252fc241a606f0141ed50d64368d8a5e7e5c5a
|
[
"Apache-2.0"
] | 415
|
2019-10-03T14:29:20.000Z
|
2022-03-31T18:23:41.000Z
|
stix_shifter_modules/splunk/tests/stix_translation/test_splunk_json_to_stix.py
|
grimmjow8/stix-shifter
|
7d252fc241a606f0141ed50d64368d8a5e7e5c5a
|
[
"Apache-2.0"
] | 178
|
2019-10-08T22:18:48.000Z
|
2022-03-21T11:04:05.000Z
|
import json
import logging
from stix_shifter_utils.stix_translation.src.json_to_stix import json_to_stix_translator
from stix_shifter.stix_translation import stix_translation
from stix_shifter_modules.splunk.entry_point import EntryPoint
from stix2validator import validate_instance
from stix_shifter_modules.splunk.stix_translation.splunk_utils import hash_type_lookup
from stix_shifter_utils.stix_translation.src.utils.transformer_utils import get_module_transformers
MODULE = "splunk"
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger()
entry_point = EntryPoint()
map_data = entry_point.get_results_translator().map_data
data_source = {
"type": "identity",
"id": "identity--3532c56d-ea72-48be-a2ad-1a53f4c9c6d3",
"name": "Splunk",
"identity_class": "events"
}
options = {}
class TestTransform(object):
@staticmethod
def get_first(itr, constraint):
return next(
(obj for obj in itr if constraint(obj)),
None
)
@staticmethod
def get_first_of_type(itr, typ):
return TestTransform.get_first(itr, lambda o: type(o) == dict and o.get('type') == typ)
def test_common_prop(self):
data = {"_time": "2018-08-21T15:11:55.000+00:00", "event_count": 5}
result_bundle = json_to_stix_translator.convert_to_stix(
data_source, map_data, [data], get_module_transformers(MODULE), options)
assert(result_bundle['type'] == 'bundle')
result_bundle_objects = result_bundle['objects']
result_bundle_identity = result_bundle_objects[0]
assert(result_bundle_identity['type'] == data_source['type'])
assert(result_bundle_identity['id'] == data_source['id'])
assert(result_bundle_identity['name'] == data_source['name'])
assert(result_bundle_identity['identity_class']
== data_source['identity_class'])
observed_data = result_bundle_objects[1]
assert(observed_data['id'] is not None)
assert(observed_data['type'] == "observed-data")
assert(observed_data['created_by_ref'] == result_bundle_identity['id'])
assert(observed_data['number_observed'] == 5)
assert(observed_data['created'] is not None)
assert(observed_data['modified'] is not None)
assert(observed_data['first_observed'] is not None)
assert(observed_data['last_observed'] is not None)
def test_change_cim_to_stix(self):
count = 1
time = "2018-08-21T15:11:55.000+00:00"
file_bytes = "300"
user = "ibm_user"
objPath = "hkey_local_machine\\system\\bar\\foo"
filePath = "C:\\Users\\someuser\\sample.dll"
create_time = "2018-08-15T15:11:55.676+00:00"
modify_time = "2018-08-15T18:10:30.456+00:00"
file_hash = "41a26255d16d121dc525a6445144b895"
file_name = "sample.dll"
file_size = 25536
data = {
"event_count": count, "_time": time, "user": user,
"bytes": file_bytes, "object_path": objPath, "file_path": filePath,
"file_create_time": create_time, "file_modify_time": modify_time,
"file_hash": file_hash, "file_size": file_size, "file_name": file_name
}
result_bundle = json_to_stix_translator.convert_to_stix(
data_source, map_data, [data], get_module_transformers(MODULE), options, callback=hash_type_lookup)
assert(result_bundle['type'] == 'bundle')
result_bundle_objects = result_bundle['objects']
observed_data = result_bundle_objects[1]
validated_result = validate_instance(observed_data)
assert(validated_result.is_valid == True)
assert('objects' in observed_data)
objects = observed_data['objects']
# Test objects in Stix observable data model after transform
wrk_obj = TestTransform.get_first_of_type(objects.values(), 'windows-registry-key')
assert(wrk_obj is not None)
assert(wrk_obj.keys() == {'type', 'key'})
assert(wrk_obj['key'] == "hkey_local_machine\\system\\bar\\foo")
user_obj = TestTransform.get_first_of_type(objects.values(), 'user-account')
assert(user_obj is not None), 'user-account object type not found'
assert(user_obj.keys() == {'type', 'account_login', 'user_id'})
assert(user_obj['account_login'] == "ibm_user")
assert(user_obj['user_id'] == "ibm_user")
file_obj = TestTransform.get_first_of_type(objects.values(), 'file')
assert(file_obj is not None), 'file object type not found'
assert(file_obj.keys() == {'type', 'parent_directory_ref', 'created', 'modified', 'hashes', 'name', 'size'})
assert(file_obj['created'] == "2018-08-15T15:11:55.676Z")
assert(file_obj['modified'] == "2018-08-15T18:10:30.456Z")
assert(file_obj['name'] == "sample.dll")
assert(file_obj['size'] == 25536)
assert (file_obj['hashes']['MD5'] == "41a26255d16d121dc525a6445144b895")
dir_ref = file_obj['parent_directory_ref']
assert(dir_ref in objects), f"parent_directory_ref with key {file_obj['parent_directory_ref']} not found"
dir_obj = objects[dir_ref]
assert(dir_obj is not None), 'directory object type not found'
assert(dir_obj.keys() == {'type', 'path', 'created', 'modified'})
assert(dir_obj['path'] == "C:\\Users\\someuser\\sample.dll")
assert(dir_obj['created'] == "2018-08-15T15:11:55.676Z")
assert(dir_obj['modified'] == "2018-08-15T18:10:30.456Z")
assert(objects.keys() == set(map(str, range(0, 4))))
def test_certificate_cim_to_stix(self):
count = 1
time = "2018-08-21T15:11:55.000+00:00"
serial = "1234"
version = "1"
sig_algorithm = "md5WithRSAEncryption"
key_algorithm = "rsaEncryption"
issuer = "C=US, ST=California, O=www.example.com, OU=new, CN=new"
subject = "C=US, ST=Maryland, L=Baltimore, O=John Doe, OU=ExampleCorp, CN=www.example.com/emailAddress=doe@example.com"
ssl_hash = "aec070645fe53ee3b3763059376134f058cc337247c978add178b6ccdfb0019f"
data = {
"event_count": count, "_time": time, "ssl_serial": serial,
"ssl_version": version, "ssl_signature_algorithm": sig_algorithm,
"ssl_issuer": issuer, "ssl_subject": subject,
"ssl_hash": ssl_hash, "ssl_publickey_algorithm": key_algorithm
}
result_bundle = json_to_stix_translator.convert_to_stix(
data_source, map_data, [data], get_module_transformers(MODULE), options)
assert(result_bundle['type'] == 'bundle')
result_bundle_objects = result_bundle['objects']
observed_data = result_bundle_objects[1]
validated_result = validate_instance(observed_data)
assert(validated_result.is_valid == True)
assert('objects' in observed_data)
objects = observed_data['objects']
# Test objects in Stix observable data model after transform
cert_obj = TestTransform.get_first_of_type(objects.values(), 'x509-certificate')
assert(cert_obj is not None), 'x509-certificate object type not found'
assert(cert_obj.keys() == {'type', 'serial_number', 'version', "signature_algorithm", "subject_public_key_algorithm", "issuer", "subject", "hashes"})
assert(cert_obj['serial_number'] == "1234")
assert(cert_obj['version'] == "1")
assert(cert_obj['signature_algorithm'] == "md5WithRSAEncryption")
assert(cert_obj['issuer'] == "C=US, ST=California, O=www.example.com, OU=new, CN=new")
assert(cert_obj['subject'] == "C=US, ST=Maryland, L=Baltimore, O=John Doe, OU=ExampleCorp, CN=www.example.com/emailAddress=doe@example.com")
assert(cert_obj['subject_public_key_algorithm'] == "rsaEncryption")
assert(cert_obj['hashes']['SHA-256'] == "aec070645fe53ee3b3763059376134f058cc337247c978add178b6ccdfb0019f")
assert(objects.keys() == set(map(str, range(0, 1))))
def test_process_cim_to_stix(self):
count = 1
time = "2018-08-21T15:11:55.000+00:00"
user = "test_user"
pid = 0
name = "test_process"
filePath = "C:\\Users\\someuser\\sample.dll"
create_time = "2018-08-15T15:11:55.676+00:00"
modify_time = "2018-08-15T18:10:30.456+00:00"
file_hash = "aec070645fe53ee3b3763059376134f058cc337247c978add178b6ccdfb0019f"
file_name = "sample.dll"
file_size = 25536
data = {
"event_count": count, "_time": time, "user": user,
"process_name": name, "process_id": pid, "file_path": filePath,
"file_create_time": create_time, "file_modify_time": modify_time,
"file_hash": file_hash, "file_size": file_size, "file_name": file_name
}
result_bundle = json_to_stix_translator.convert_to_stix(
data_source, map_data, [data], get_module_transformers(MODULE), options, callback=hash_type_lookup)
assert(result_bundle['type'] == 'bundle')
result_bundle_objects = result_bundle['objects']
observed_data = result_bundle_objects[1]
validated_result = validate_instance(observed_data)
assert(validated_result.is_valid == True)
assert('objects' in observed_data)
objects = observed_data['objects']
# Test objects in Stix observable data model after transform
proc_obj = TestTransform.get_first_of_type(objects.values(), 'process')
assert(proc_obj is not None), 'process object type not found'
assert(proc_obj.keys() == {'type', 'name', 'pid', 'binary_ref'})
assert(proc_obj['name'] == "test_process")
assert(proc_obj['pid'] == 0)
user_obj = TestTransform.get_first_of_type(objects.values(), 'user-account')
assert(user_obj is not None), 'user-account object type not found'
assert(user_obj.keys() == {'type', 'account_login', 'user_id'})
assert(user_obj['account_login'] == "test_user")
assert(user_obj['user_id'] == "test_user")
bin_ref = proc_obj['binary_ref']
assert(bin_ref in objects), f"binary_ref with key {proc_obj['binary_ref']} not found"
file_obj = objects[bin_ref]
assert(file_obj is not None), 'file object type not found'
assert(file_obj.keys() == {'type', 'parent_directory_ref', 'created', 'modified', 'size', 'name', 'hashes'})
assert(file_obj['created'] == "2018-08-15T15:11:55.676Z")
assert(file_obj['modified'] == "2018-08-15T18:10:30.456Z")
assert(file_obj['name'] == "sample.dll")
assert(file_obj['size'] == 25536)
assert (file_obj['hashes']['SHA-256'] == "aec070645fe53ee3b3763059376134f058cc337247c978add178b6ccdfb0019f")
dir_ref = file_obj['parent_directory_ref']
assert(dir_ref in objects), f"parent_directory_ref with key {file_obj['parent_directory_ref']} not found"
dir_obj = objects[dir_ref]
assert(dir_obj is not None), 'directory object type not found'
assert(dir_obj.keys() == {'type', 'path', 'created', 'modified'})
assert(dir_obj['path'] == "C:\\Users\\someuser\\sample.dll")
assert(dir_obj['created'] == "2018-08-15T15:11:55.676Z")
assert(dir_obj['modified'] == "2018-08-15T18:10:30.456Z")
assert(objects.keys() == set(map(str, range(0, 4))))
def test_network_cim_to_stix(self):
count = 2
time = "2018-08-21T15:11:55.000+00:00"
user = "ibm_user"
dest_ip = "127.0.0.1"
dest_port = "8090"
src_ip = "2001:0db8:85a3:0000:0000:8a2e:0370:7334"
src_port = "8080"
transport = "http"
data = {"event_count": count, "_time": time, "user": user,
"dest_ip": dest_ip, "dest_port": dest_port, "src_ip": src_ip,
"src_port": src_port, "protocol": transport
}
print(data)
result_bundle = json_to_stix_translator.convert_to_stix(
data_source, map_data, [data], get_module_transformers(MODULE), options)
assert(result_bundle['type'] == 'bundle')
result_bundle_objects = result_bundle['objects']
observed_data = result_bundle_objects[1]
validated_result = validate_instance(observed_data)
assert(validated_result.is_valid == True)
assert('objects' in observed_data)
objects = observed_data['objects']
nt_obj = TestTransform.get_first_of_type(objects.values(), 'network-traffic')
assert(nt_obj is not None), 'network-traffic object type not found'
assert(nt_obj.keys() == {'type', 'src_port', 'dst_port', 'src_ref', 'dst_ref', 'protocols'})
assert(nt_obj['src_port'] == 8080)
assert(nt_obj['dst_port'] == 8090)
assert(nt_obj['protocols'] == ['http'])
ip_ref = nt_obj['dst_ref']
assert(ip_ref in objects), f"dst_ref with key {nt_obj['dst_ref']} not found"
ip_obj = objects[ip_ref]
assert(ip_obj.keys() == {'type', 'value'})
assert(ip_obj['type'] == 'ipv4-addr')
assert(ip_obj['value'] == dest_ip)
ip_ref = nt_obj['src_ref']
assert(ip_ref in objects), f"src_ref with key {nt_obj['src_ref']} not found"
ip_obj = objects[ip_ref]
assert(ip_obj.keys() == {'type', 'value'})
assert(ip_obj['type'] == 'ipv6-addr')
assert(ip_obj['value'] == src_ip)
def test_email_cim_to_stix(self):
count = 3
time = "2018-08-21T15:11:55.000+00:00"
src_user = "Jane_Doe@ibm.com"
subject = "Test Subject"
multi = "False"
data = {"event_count": count, "_time": time,
"src_user": src_user, "subject": subject, "is_multipart": multi
}
result_bundle = json_to_stix_translator.convert_to_stix(
data_source, map_data, [data], get_module_transformers(MODULE), options)
assert(result_bundle['type'] == 'bundle')
result_bundle_objects = result_bundle['objects']
observed_data = result_bundle_objects[1]
validated_result = validate_instance(observed_data)
assert(validated_result.is_valid == True)
assert('objects' in observed_data)
objects = observed_data['objects']
msg_obj = TestTransform.get_first_of_type(objects.values(), 'email-message')
assert(msg_obj is not None), 'email-message object type not found'
assert(msg_obj.keys() == {'type', 'subject', 'sender_ref', 'from_ref', 'is_multipart'})
assert(msg_obj['subject'] == "Test Subject")
assert(msg_obj['is_multipart'] == False)
sender_ref = msg_obj['sender_ref']
assert(sender_ref in objects), f"sender_ref with key {msg_obj['sender_ref']} not found"
addr_obj = objects[sender_ref]
assert(addr_obj.keys() == {'type', 'value'})
assert(addr_obj['type'] == 'email-addr')
assert(addr_obj['value'] == src_user)
from_ref = msg_obj['from_ref']
assert(sender_ref in objects), f"from_ref with key {msg_obj['from_ref']} not found"
addr_obj = objects[from_ref]
assert(addr_obj.keys() == {'type', 'value'})
assert(addr_obj['type'] == 'email-addr')
assert(addr_obj['value'] == src_user)
def test_custom_mapping(self):
data_source = "{\"type\": \"identity\", \"id\": \"identity--3532c56d-ea72-48be-a2ad-1a53f4c9c6d3\", \"name\": \"Splunk\", \"identity_class\": \"events\"}"
data = "[{\"tag\":\"network\", \"src_ip\": \"127.0.0.1\"}]"
options = {
"mapping": {
"cim": {
"to_stix": {
"tag_to_model": {
"network": [
"network-traffic",
"dst_ip",
"src_ip"
]
},
"event_count": {
"key": "number_observed",
"cybox": False,
"transformer": "ToInteger"
},
"src_ip": [
{
"key": "ipv4-addr.value",
"object": "src_ip"
},
{
"key": "ipv6-addr.value",
"object": "src_ip"
},
{
"key": "network-traffic.src_ref",
"object": "network-traffic",
"references": "src_ip"
}
]
}
}
}
}
translation = stix_translation.StixTranslation()
result_bundle = translation.translate('splunk', 'results', data_source, data, options)
result_bundle_objects = result_bundle['objects']
observed_data = result_bundle_objects[1]
assert('objects' in observed_data)
objects = observed_data['objects']
curr_obj = TestTransform.get_first_of_type(objects.values(), 'ipv4-addr')
assert(curr_obj is not None), 'ipv4-addr object type not found'
assert(curr_obj.keys() == {'type', 'value'})
assert(curr_obj['value'] == "127.0.0.1")
def test_cim_to_stix_no_tags(self):
data = {"src_ip": "169.250.0.1", "src_port": "1220", "src_mac": "aa:bb:cc:dd:11:22",
"dest_ip": "127.0.0.1", "dest_port": "1120", "dest_mac": "ee:dd:bb:aa:cc:11",
"file_hash": "cf23df2207d99a74fbe169e3eba035e633b65d94",
"user": "sname", "url": "https://wally.fireeye.com/malware_analysis/analyses?maid=1",
"protocol": "tcp", "_bkt": "main~44~6D3E49A0-31FE-44C3-8373-C3AC6B1ABF06", "_cd": "44:12606114",
"_indextime": "1546960685",
"_raw": "Jan 08 2019 15:18:04 192.168.33.131 fenotify-2.alert: CEF:0|FireEye|MAS|6.2.0.74298|MO|"
"malware-object|4|rt=Jan 08 2019 15:18:04 Z src=169.250.0.1 dpt=1120 dst=127.0.0.1"
" spt=1220 smac=AA:BB:CC:DD:11:22 dmac=EE:DD:BB:AA:CC:11 cn2Label=sid cn2=111"
" fileHash=41a26255d16d121dc525a6445144b895 proto=tcp "
"request=http://qa-server.eng.fireeye.com/QE/NotificationPcaps/"
"58.253.68.29_80-192.168.85.128_1165-2119283109_T.exe cs3Label=osinfo"
" cs3=Microsoft Windows7 Professional 6.1 sp1 dvchost=wally dvc=10.2.101.101 cn1Label=vlan"
" cn1=0 externalId=1 cs4Label=link "
"cs4=https://wally.fireeye.com/malware_analysis/analyses?maid=1 cs2Label=anomaly"
" cs2=misc-anomaly cs1Label=sname cs1=FE_UPX;Trojan.PWS.OnlineGames",
"_serial": "0", "_si": ["splunk3-01.internal.resilientsystems.com", "main"],
"_sourcetype": "fe_cef_syslog", "_time": "2019-01-08T15:18:04.000+00:00", "event_count": 1
}
# result_bundle = json_to_stix_translator.convert_to_stix(
# data_source, map_data, [data], get_module_transformers(MODULE), options, callback=hash_type_lookup)
result_bundle = entry_point.translate_results(json.dumps(data_source), json.dumps([data]))
assert(result_bundle['type'] == 'bundle')
result_bundle_objects = result_bundle['objects']
observed_data = result_bundle_objects[1]
# somehow breaking the stix validation
# validated_result = validate_instance(observed_data)
# assert(validated_result.is_valid == True)
assert('objects' in observed_data)
objects = observed_data['objects']
nt_obj = TestTransform.get_first_of_type(objects.values(), 'network-traffic')
assert(nt_obj is not None), 'network-traffic object type not found'
assert(nt_obj.keys() == {'type', 'src_ref', 'src_port', 'dst_ref', 'dst_port', 'protocols'})
assert(nt_obj['src_port'] == 1220)
assert(nt_obj['dst_port'] == 1120)
assert(nt_obj['protocols'] == ['tcp'])
ip_ref = nt_obj['dst_ref']
assert(ip_ref in objects), "dst_ref with key {nt_obj['dst_ref']} not found"
ip_obj = objects[ip_ref]
assert(ip_obj.keys() == {'type', 'value', 'resolves_to_refs'})
assert(ip_obj['type'] == 'ipv4-addr')
assert(ip_obj['value'] == '127.0.0.1')
assert (isinstance(ip_obj['resolves_to_refs'], list) and isinstance(ip_obj['resolves_to_refs'][0], str))
ip_ref = nt_obj['src_ref']
assert(ip_ref in objects), "src_ref with key {nt_obj['src_ref']} not found"
ip_obj = objects[ip_ref]
assert(ip_obj.keys() == {'type', 'value', 'resolves_to_refs'})
assert(ip_obj['type'] == 'ipv4-addr')
assert(ip_obj['value'] == '169.250.0.1')
assert (isinstance(ip_obj['resolves_to_refs'], list) and isinstance(ip_obj['resolves_to_refs'][0], str))
file_obj = TestTransform.get_first_of_type(objects.values(), 'file')
assert (file_obj is not None), 'file object type not found'
assert (file_obj.keys() == {'type', 'hashes'})
assert (file_obj['hashes']['SHA-1'] == "cf23df2207d99a74fbe169e3eba035e633b65d94")
user_obj = TestTransform.get_first_of_type(objects.values(), 'user-account')
assert (user_obj is not None), 'user object type not found'
assert (user_obj.keys() == {'type', 'account_login', 'user_id'})
assert (user_obj['account_login'] == "sname")
assert (user_obj['user_id'] == "sname")
url_obj = TestTransform.get_first_of_type(objects.values(), 'url')
assert (url_obj is not None), 'url object type not found'
assert (url_obj.keys() == {'type', 'value'})
assert (url_obj['value'] == "https://wally.fireeye.com/malware_analysis/analyses?maid=1")
domain_obj = TestTransform.get_first_of_type(objects.values(), 'domain-name')
assert (domain_obj is not None), 'domain object type not found'
assert (domain_obj.keys() == {'type', 'value'})
assert (domain_obj['value'] == "wally.fireeye.com")
payload_obj = TestTransform.get_first_of_type(objects.values(), 'artifact')
assert (payload_obj is not None), 'payload object type not found'
assert (payload_obj.keys() == {'type', 'payload_bin', 'mime_type'})
payload = 'SmFuIDA4IDIwMTkgMTU6MTg6MDQgMTkyLjE2OC4zMy4xMzEgZmVub3RpZnktMi5hbGVydDogQ0VGOjB8RmlyZUV5ZXxNQV' \
'N8Ni4yLjAuNzQyOTh8TU98bWFsd2FyZS1vYmplY3R8NHxydD1KYW4gMDggMjAxOSAxNToxODowNCBaIHNyYz0xNjkuMjUw' \
'LjAuMSBkcHQ9MTEyMCBkc3Q9MTI3LjAuMC4xIHNwdD0xMjIwIHNtYWM9QUE6QkI6Q0M6REQ6MTE6MjIgZG1hYz1FRTpERD' \
'pCQjpBQTpDQzoxMSBjbjJMYWJlbD1zaWQgY24yPTExMSBmaWxlSGFzaD00MWEyNjI1NWQxNmQxMjFkYzUyNWE2NDQ1MTQ0' \
'Yjg5NSBwcm90bz10Y3AgcmVxdWVzdD1odHRwOi8vcWEtc2VydmVyLmVuZy5maXJlZXllLmNvbS9RRS9Ob3RpZmljYXRpb2' \
'5QY2Fwcy81OC4yNTMuNjguMjlfODAtMTkyLjE2OC44NS4xMjhfMTE2NS0yMTE5MjgzMTA5X1QuZXhlIGNzM0xhYmVsPW9z' \
'aW5mbyBjczM9TWljcm9zb2Z0IFdpbmRvd3M3IFByb2Zlc3Npb25hbCA2LjEgc3AxIGR2Y2hvc3Q9d2FsbHkgZHZjPTEwLj' \
'IuMTAxLjEwMSBjbjFMYWJlbD12bGFuIGNuMT0wIGV4dGVybmFsSWQ9MSBjczRMYWJlbD1saW5rIGNzND1odHRwczovL3dh' \
'bGx5LmZpcmVleWUuY29tL21hbHdhcmVfYW5hbHlzaXMvYW5hbHlzZXM/bWFpZD0xIGNzMkxhYmVsPWFub21hbHkgY3MyPW' \
'1pc2MtYW5vbWFseSBjczFMYWJlbD1zbmFtZSBjczE9RkVfVVBYO1Ryb2phbi5QV1MuT25saW5lR2FtZXM='
assert (payload_obj['payload_bin'] == payload)
assert (payload_obj['mime_type'] == 'text/plain')
| 48.363083
| 162
| 0.624124
|
7951ccf9f6e4864b1283cfa3ef65c3b7323a1483
| 8,328
|
py
|
Python
|
tft/data_formatters/electricity.py
|
deepneuralmachine/google-research
|
d2ce2cf0f5c004f8d78bfeddf6e88e88f4840231
|
[
"Apache-2.0"
] | 23,901
|
2018-10-04T19:48:53.000Z
|
2022-03-31T21:27:42.000Z
|
tft/data_formatters/electricity.py
|
deepneuralmachine/google-research
|
d2ce2cf0f5c004f8d78bfeddf6e88e88f4840231
|
[
"Apache-2.0"
] | 891
|
2018-11-10T06:16:13.000Z
|
2022-03-31T10:42:34.000Z
|
tft/data_formatters/electricity.py
|
deepneuralmachine/google-research
|
d2ce2cf0f5c004f8d78bfeddf6e88e88f4840231
|
[
"Apache-2.0"
] | 6,047
|
2018-10-12T06:31:02.000Z
|
2022-03-31T13:59:28.000Z
|
# coding=utf-8
# Copyright 2021 The Google Research Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# 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.
# Lint as: python3
"""Custom formatting functions for Electricity dataset.
Defines dataset specific column definitions and data transformations. Uses
entity specific z-score normalization.
"""
import data_formatters.base
import libs.utils as utils
import pandas as pd
import sklearn.preprocessing
GenericDataFormatter = data_formatters.base.GenericDataFormatter
DataTypes = data_formatters.base.DataTypes
InputTypes = data_formatters.base.InputTypes
class ElectricityFormatter(GenericDataFormatter):
"""Defines and formats data for the electricity dataset.
Note that per-entity z-score normalization is used here, and is implemented
across functions.
Attributes:
column_definition: Defines input and data type of column used in the
experiment.
identifiers: Entity identifiers used in experiments.
"""
_column_definition = [
('id', DataTypes.REAL_VALUED, InputTypes.ID),
('hours_from_start', DataTypes.REAL_VALUED, InputTypes.TIME),
('power_usage', DataTypes.REAL_VALUED, InputTypes.TARGET),
('hour', DataTypes.REAL_VALUED, InputTypes.KNOWN_INPUT),
('day_of_week', DataTypes.REAL_VALUED, InputTypes.KNOWN_INPUT),
('hours_from_start', DataTypes.REAL_VALUED, InputTypes.KNOWN_INPUT),
('categorical_id', DataTypes.CATEGORICAL, InputTypes.STATIC_INPUT),
]
def __init__(self):
"""Initialises formatter."""
self.identifiers = None
self._real_scalers = None
self._cat_scalers = None
self._target_scaler = None
self._num_classes_per_cat_input = None
self._time_steps = self.get_fixed_params()['total_time_steps']
def split_data(self, df, valid_boundary=1315, test_boundary=1339):
"""Splits data frame into training-validation-test data frames.
This also calibrates scaling object, and transforms data for each split.
Args:
df: Source data frame to split.
valid_boundary: Starting year for validation data
test_boundary: Starting year for test data
Returns:
Tuple of transformed (train, valid, test) data.
"""
print('Formatting train-valid-test splits.')
index = df['days_from_start']
train = df.loc[index < valid_boundary]
valid = df.loc[(index >= valid_boundary - 7) & (index < test_boundary)]
test = df.loc[index >= test_boundary - 7]
self.set_scalers(train)
return (self.transform_inputs(data) for data in [train, valid, test])
def set_scalers(self, df):
"""Calibrates scalers using the data supplied.
Args:
df: Data to use to calibrate scalers.
"""
print('Setting scalers with training data...')
column_definitions = self.get_column_definition()
id_column = utils.get_single_col_by_input_type(InputTypes.ID,
column_definitions)
target_column = utils.get_single_col_by_input_type(InputTypes.TARGET,
column_definitions)
# Format real scalers
real_inputs = utils.extract_cols_from_data_type(
DataTypes.REAL_VALUED, column_definitions,
{InputTypes.ID, InputTypes.TIME})
# Initialise scaler caches
self._real_scalers = {}
self._target_scaler = {}
identifiers = []
for identifier, sliced in df.groupby(id_column):
if len(sliced) >= self._time_steps:
data = sliced[real_inputs].values
targets = sliced[[target_column]].values
self._real_scalers[identifier] \
= sklearn.preprocessing.StandardScaler().fit(data)
self._target_scaler[identifier] \
= sklearn.preprocessing.StandardScaler().fit(targets)
identifiers.append(identifier)
# Format categorical scalers
categorical_inputs = utils.extract_cols_from_data_type(
DataTypes.CATEGORICAL, column_definitions,
{InputTypes.ID, InputTypes.TIME})
categorical_scalers = {}
num_classes = []
for col in categorical_inputs:
# Set all to str so that we don't have mixed integer/string columns
srs = df[col].apply(str)
categorical_scalers[col] = sklearn.preprocessing.LabelEncoder().fit(
srs.values)
num_classes.append(srs.nunique())
# Set categorical scaler outputs
self._cat_scalers = categorical_scalers
self._num_classes_per_cat_input = num_classes
# Extract identifiers in case required
self.identifiers = identifiers
def transform_inputs(self, df):
"""Performs feature transformations.
This includes both feature engineering, preprocessing and normalisation.
Args:
df: Data frame to transform.
Returns:
Transformed data frame.
"""
if self._real_scalers is None and self._cat_scalers is None:
raise ValueError('Scalers have not been set!')
# Extract relevant columns
column_definitions = self.get_column_definition()
id_col = utils.get_single_col_by_input_type(InputTypes.ID,
column_definitions)
real_inputs = utils.extract_cols_from_data_type(
DataTypes.REAL_VALUED, column_definitions,
{InputTypes.ID, InputTypes.TIME})
categorical_inputs = utils.extract_cols_from_data_type(
DataTypes.CATEGORICAL, column_definitions,
{InputTypes.ID, InputTypes.TIME})
# Transform real inputs per entity
df_list = []
for identifier, sliced in df.groupby(id_col):
# Filter out any trajectories that are too short
if len(sliced) >= self._time_steps:
sliced_copy = sliced.copy()
sliced_copy[real_inputs] = self._real_scalers[identifier].transform(
sliced_copy[real_inputs].values)
df_list.append(sliced_copy)
output = pd.concat(df_list, axis=0)
# Format categorical inputs
for col in categorical_inputs:
string_df = df[col].apply(str)
output[col] = self._cat_scalers[col].transform(string_df)
return output
def format_predictions(self, predictions):
"""Reverts any normalisation to give predictions in original scale.
Args:
predictions: Dataframe of model predictions.
Returns:
Data frame of unnormalised predictions.
"""
if self._target_scaler is None:
raise ValueError('Scalers have not been set!')
column_names = predictions.columns
df_list = []
for identifier, sliced in predictions.groupby('identifier'):
sliced_copy = sliced.copy()
target_scaler = self._target_scaler[identifier]
for col in column_names:
if col not in {'forecast_time', 'identifier'}:
sliced_copy[col] = target_scaler.inverse_transform(sliced_copy[col])
df_list.append(sliced_copy)
output = pd.concat(df_list, axis=0)
return output
# Default params
def get_fixed_params(self):
"""Returns fixed model parameters for experiments."""
fixed_params = {
'total_time_steps': 8 * 24,
'num_encoder_steps': 7 * 24,
'num_epochs': 100,
'early_stopping_patience': 5,
'multiprocessing_workers': 5
}
return fixed_params
def get_default_model_params(self):
"""Returns default optimised model parameters."""
model_params = {
'dropout_rate': 0.1,
'hidden_layer_size': 160,
'learning_rate': 0.001,
'minibatch_size': 64,
'max_gradient_norm': 0.01,
'num_heads': 4,
'stack_size': 1
}
return model_params
def get_num_samples_for_calibration(self):
"""Gets the default number of training and validation samples.
Use to sub-sample the data for network calibration and a value of -1 uses
all available samples.
Returns:
Tuple of (training samples, validation samples)
"""
return 450000, 50000
| 31.78626
| 78
| 0.695965
|
7951cd27e78a3e6282eaa1b087b27d5e076b25a6
| 5,762
|
py
|
Python
|
test/test_optimizer.py
|
fritzo/funsor
|
1d07af18c21894dd56e2f4f877c7845430c3b729
|
[
"Apache-2.0"
] | 198
|
2019-02-04T19:13:14.000Z
|
2022-03-26T18:33:47.000Z
|
test/test_optimizer.py
|
fritzo/funsor
|
1d07af18c21894dd56e2f4f877c7845430c3b729
|
[
"Apache-2.0"
] | 334
|
2019-02-14T19:33:32.000Z
|
2022-03-18T00:55:40.000Z
|
test/test_optimizer.py
|
fritzo/funsor
|
1d07af18c21894dd56e2f4f877c7845430c3b729
|
[
"Apache-2.0"
] | 19
|
2019-05-18T01:58:10.000Z
|
2022-03-04T16:40:00.000Z
|
# Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
from collections import OrderedDict
import pytest
import funsor
from funsor.domains import Bint
from funsor.einsum import (
einsum,
naive_contract_einsum,
naive_einsum,
naive_plated_einsum,
)
from funsor.interpretations import normalize, reflect
from funsor.interpreter import reinterpret
from funsor.optimizer import apply_optimizer
from funsor.tensor import Tensor
from funsor.terms import Variable
from funsor.testing import (
assert_close,
make_chain_einsum,
make_einsum_example,
make_hmm_einsum,
make_plated_hmm_einsum,
)
from funsor.util import get_backend
# TODO: make this file backend agnostic
pytestmark = pytest.mark.skipif(
get_backend() != "torch",
reason="jax backend does not have pyro.ops.contract.einsum equivalent",
)
if get_backend() == "torch":
import torch
from pyro.ops.contract import einsum as pyro_einsum
from funsor.torch.distributions import Categorical
OPTIMIZED_EINSUM_EXAMPLES = [make_chain_einsum(t) for t in range(2, 50, 10)] + [
make_hmm_einsum(t) for t in range(2, 50, 10)
]
@pytest.mark.parametrize("equation", OPTIMIZED_EINSUM_EXAMPLES)
@pytest.mark.parametrize(
"backend", ["pyro.ops.einsum.torch_log", "pyro.ops.einsum.torch_map"]
)
@pytest.mark.parametrize("einsum_impl", [naive_einsum, naive_contract_einsum])
def test_optimized_einsum(equation, backend, einsum_impl):
inputs, outputs, sizes, operands, funsor_operands = make_einsum_example(equation)
expected = pyro_einsum(equation, *operands, backend=backend)[0]
with normalize:
naive_ast = einsum_impl(equation, *funsor_operands, backend=backend)
optimized_ast = apply_optimizer(naive_ast)
actual = reinterpret(optimized_ast) # eager by default
assert isinstance(actual, funsor.Tensor) and len(outputs) == 1
if len(outputs[0]) > 0:
actual = actual.align(tuple(outputs[0]))
assert expected.shape == actual.data.shape
assert torch.allclose(expected, actual.data)
for output in outputs:
for i, output_dim in enumerate(output):
assert output_dim in actual.inputs
assert actual.inputs[output_dim].dtype == sizes[output_dim]
@pytest.mark.parametrize(
"eqn1,eqn2", [("a,ab->b", "bc->"), ("ab,bc,cd->d", "de,ef,fg->")]
)
@pytest.mark.parametrize("optimize1", [False, True])
@pytest.mark.parametrize("optimize2", [False, True])
@pytest.mark.parametrize(
"backend1", ["torch", "pyro.ops.einsum.torch_log", "pyro.ops.einsum.torch_map"]
)
@pytest.mark.parametrize(
"backend2", ["torch", "pyro.ops.einsum.torch_log", "pyro.ops.einsum.torch_map"]
)
@pytest.mark.parametrize("einsum_impl", [naive_einsum, naive_contract_einsum])
def test_nested_einsum(
eqn1, eqn2, optimize1, optimize2, backend1, backend2, einsum_impl
):
inputs1, outputs1, sizes1, operands1, _ = make_einsum_example(eqn1, sizes=(3,))
inputs2, outputs2, sizes2, operands2, funsor_operands2 = make_einsum_example(
eqn2, sizes=(3,)
)
# normalize the probs for ground-truth comparison
operands1 = [
operand.abs() / operand.abs().sum(-1, keepdim=True) for operand in operands1
]
expected1 = pyro_einsum(eqn1, *operands1, backend=backend1, modulo_total=True)[0]
expected2 = pyro_einsum(
outputs1[0] + "," + eqn2,
*([expected1] + operands2),
backend=backend2,
modulo_total=True
)[0]
with normalize:
funsor_operands1 = [
Categorical(
probs=Tensor(
operand,
inputs=OrderedDict([(d, Bint[sizes1[d]]) for d in inp[:-1]]),
)
)(value=Variable(inp[-1], Bint[sizes1[inp[-1]]])).exp()
for inp, operand in zip(inputs1, operands1)
]
output1_naive = einsum_impl(eqn1, *funsor_operands1, backend=backend1)
with reflect:
output1 = apply_optimizer(output1_naive) if optimize1 else output1_naive
output2_naive = einsum_impl(
outputs1[0] + "," + eqn2, *([output1] + funsor_operands2), backend=backend2
)
with reflect:
output2 = apply_optimizer(output2_naive) if optimize2 else output2_naive
actual1 = reinterpret(output1)
actual2 = reinterpret(output2)
assert torch.allclose(expected1, actual1.data)
assert torch.allclose(expected2, actual2.data)
PLATED_EINSUM_EXAMPLES = [
make_plated_hmm_einsum(num_steps, num_obs_plates=b, num_hidden_plates=a)
for num_steps in range(3, 50, 6)
for (a, b) in [(0, 1), (0, 2), (0, 0), (1, 1), (1, 2)]
]
@pytest.mark.parametrize("equation,plates", PLATED_EINSUM_EXAMPLES)
@pytest.mark.parametrize(
"backend", ["pyro.ops.einsum.torch_log", "pyro.ops.einsum.torch_map"]
)
def test_optimized_plated_einsum(equation, plates, backend):
inputs, outputs, sizes, operands, funsor_operands = make_einsum_example(equation)
expected = pyro_einsum(equation, *operands, plates=plates, backend=backend)[0]
actual = einsum(equation, *funsor_operands, plates=plates, backend=backend)
if len(equation) < 10:
actual_naive = naive_plated_einsum(
equation, *funsor_operands, plates=plates, backend=backend
)
assert_close(actual, actual_naive)
assert isinstance(actual, funsor.Tensor) and len(outputs) == 1
if len(outputs[0]) > 0:
actual = actual.align(tuple(outputs[0]))
assert expected.shape == actual.data.shape
assert torch.allclose(expected, actual.data)
for output in outputs:
for i, output_dim in enumerate(output):
assert output_dim in actual.inputs
assert actual.inputs[output_dim].dtype == sizes[output_dim]
| 35.349693
| 87
| 0.692121
|
7951cd8b9e86e00d8bd6f36c356c6e8a1801417a
| 3,082
|
py
|
Python
|
pbge/scenes/waypoints.py
|
marblexu/gearhead-caramel
|
8bf4572aefb5f3a1bafd20ad04dfa0b2f44be8b1
|
[
"Apache-2.0"
] | null | null | null |
pbge/scenes/waypoints.py
|
marblexu/gearhead-caramel
|
8bf4572aefb5f3a1bafd20ad04dfa0b2f44be8b1
|
[
"Apache-2.0"
] | null | null | null |
pbge/scenes/waypoints.py
|
marblexu/gearhead-caramel
|
8bf4572aefb5f3a1bafd20ad04dfa0b2f44be8b1
|
[
"Apache-2.0"
] | 1
|
2022-02-24T13:23:01.000Z
|
2022-02-24T13:23:01.000Z
|
from .. import container,image,KeyObject,rpgmenu,frects,draw_text,default_border,my_state,alert
import pygame
class PuzzleMenu( rpgmenu.Menu ):
WIDTH = 350
HEIGHT = 250
MENU_HEIGHT = 75
FULL_RECT = frects.Frect(-175,-125,350,250)
TEXT_RECT = frects.Frect(-175,-125,350,165)
def __init__( self, camp, wp ):
super(PuzzleMenu, self).__init__(-self.WIDTH//2,self.HEIGHT//2-self.MENU_HEIGHT,self.WIDTH,self.MENU_HEIGHT,border=None,predraw=self.pre)
self.desc = wp.desc
def pre( self ):
if my_state.view:
my_state.view()
default_border.render( self.FULL_RECT.get_rect() )
draw_text( my_state.medium_font, self.desc, self.TEXT_RECT.get_rect(), justify = 0 )
class Waypoint( object ):
TILE = None
ATTACH_TO_WALL = False
name = None
desc = ""
desctags = tuple()
def __init__( self, scene=None, pos=(0,0), plot_locked=False, desc=None, anchor=None, name='' ):
"""Place this waypoint in a scene."""
if scene:
self.place( scene, pos )
self.contents = container.ContainerList(owner=self)
self.plot_locked = plot_locked
if desc:
self.desc = desc
if anchor:
self.anchor = anchor
if name is not '':
self.name = name
def place( self, scene, pos=None ):
if hasattr( self, "container" ) and self.container:
self.container.remove( self )
self.scene = scene
scene.contents.append( self )
if pos and scene.on_the_map( *pos ):
self.pos = pos
if self.TILE:
if self.TILE.floor:
scene._map[pos[0]][pos[1]].floor = self.TILE.floor
if self.TILE.wall:
scene._map[pos[0]][pos[1]].wall = self.TILE.wall
if self.TILE.decor:
scene._map[pos[0]][pos[1]].decor = self.TILE.decor
else:
self.pos = (0,0)
def remove(self, scene):
if self in scene.contents:
scene.contents.remove(self)
if self.TILE:
if self.TILE.floor:
scene._map[self.pos[0]][self.pos[1]].floor = None
if self.TILE.wall:
scene._map[self.pos[0]][self.pos[1]].wall = None
if self.TILE.decor:
scene._map[self.pos[0]][self.pos[1]].decor = None
def unlocked_use( self, camp ):
# Perform this waypoint's special action.
if self.desc:
alert( self.desc )
def bump( self, camp, pc ):
# Send a BUMP trigger.
camp.check_trigger("BUMP",self)
# If plot_locked, check plots for possible actions.
# Otherwise, use the normal unlocked_use.
if self.plot_locked:
rpm = PuzzleMenu( camp, self )
camp.expand_puzzle_menu( self, rpm )
fx = rpm.query()
if fx:
fx( camp )
else:
self.unlocked_use( camp )
def __str__(self):
return self.name
| 32.787234
| 145
| 0.55743
|
7951cdab5475ba4f1445607c7d395298858b69bb
| 19,142
|
py
|
Python
|
src/azure-cli/azure/cli/command_modules/resource/tests/hybrid_2019_03_01/test_managmentgroups.py
|
YuanyuanNi/azure-cli
|
63844964374858bfacd209bfe1b69eb456bd64ca
|
[
"MIT"
] | 3,287
|
2016-07-26T17:34:33.000Z
|
2022-03-31T09:52:13.000Z
|
src/azure-cli/azure/cli/command_modules/resource/tests/hybrid_2019_03_01/test_managmentgroups.py
|
YuanyuanNi/azure-cli
|
63844964374858bfacd209bfe1b69eb456bd64ca
|
[
"MIT"
] | 19,206
|
2016-07-26T07:04:42.000Z
|
2022-03-31T23:57:09.000Z
|
src/azure-cli/azure/cli/command_modules/resource/tests/hybrid_2019_03_01/test_managmentgroups.py
|
YuanyuanNi/azure-cli
|
63844964374858bfacd209bfe1b69eb456bd64ca
|
[
"MIT"
] | 2,575
|
2016-07-26T06:44:40.000Z
|
2022-03-31T22:56:06.000Z
|
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
from azure.cli.testsdk import ScenarioTest, record_only
@record_only()
class AzureManagementGroupsScenarioTest(ScenarioTest):
def test_show_managementgroup(self):
self.cmd('account management-group create --name testcligetgroup1')
self.cmd('account management-group create --name testcligetgroup2 --parent /providers/Microsoft.Management/managementGroups/testcligetgroup1')
managementgroup_get = self.cmd(
'account management-group show --name testcligetgroup2').get_output_in_json()
self.cmd('account management-group delete --name testcligetgroup2')
self.cmd('account management-group delete --name testcligetgroup1')
self.assertIsNotNone(managementgroup_get)
self.assertIsNone(managementgroup_get["children"])
self.assertIsNotNone(managementgroup_get["details"])
self.assertEqual(
managementgroup_get["id"],
"/providers/Microsoft.Management/managementGroups/testcligetgroup2")
self.assertEqual(managementgroup_get["name"], "testcligetgroup2")
self.assertEqual(
managementgroup_get["displayName"],
"testcligetgroup2")
self.assertEqual(
managementgroup_get["details"]["parent"]["displayName"],
"testcligetgroup1")
self.assertEqual(
managementgroup_get["details"]["parent"]["id"],
"/providers/Microsoft.Management/managementGroups/testcligetgroup1")
self.assertEqual(
managementgroup_get["details"]["parent"]["name"],
"testcligetgroup1")
self.assertIsNotNone(managementgroup_get["tenantId"])
self.assertEqual(
managementgroup_get["type"],
"/providers/Microsoft.Management/managementGroups")
def test_show_managementgroup_with_expand(self):
self.cmd('account management-group create --name testcligetgroup1')
self.cmd('account management-group create --name testcligetgroup2 --parent testcligetgroup1')
self.cmd('account management-group create --name testcligetgroup3 --parent /providers/Microsoft.Management/managementGroups/testcligetgroup2')
managementgroup_get = self.cmd(
'account management-group show --name testcligetgroup2 --expand').get_output_in_json()
self.cmd('account management-group delete --name testcligetgroup3')
self.cmd('account management-group delete --name testcligetgroup2')
self.cmd('account management-group delete --name testcligetgroup1')
self.assertIsNotNone(managementgroup_get)
self.assertIsNotNone(managementgroup_get["children"])
self.assertIsNotNone(managementgroup_get["details"])
self.assertEqual(
managementgroup_get["id"],
"/providers/Microsoft.Management/managementGroups/testcligetgroup2")
self.assertEqual(managementgroup_get["name"], "testcligetgroup2")
self.assertEqual(
managementgroup_get["displayName"],
"testcligetgroup2")
self.assertEqual(
managementgroup_get["details"]["parent"]["displayName"],
"testcligetgroup1")
self.assertEqual(
managementgroup_get["details"]["parent"]["id"],
"/providers/Microsoft.Management/managementGroups/testcligetgroup1")
self.assertEqual(
managementgroup_get["details"]["parent"]["name"],
"testcligetgroup1")
self.assertIsNotNone(managementgroup_get["tenantId"])
self.assertEqual(
managementgroup_get["type"],
"/providers/Microsoft.Management/managementGroups")
self.assertEqual(
managementgroup_get["children"][0]["id"],
"/providers/Microsoft.Management/managementGroups/testcligetgroup3")
self.assertEqual(
managementgroup_get["children"][0]["type"],
"/providers/Microsoft.Management/managementGroups")
self.assertEqual(
managementgroup_get["children"][0]["displayName"],
"testcligetgroup3")
self.assertEqual(
managementgroup_get["children"][0]["name"],
"testcligetgroup3")
def test_show_managementgroup_with_expand_and_recurse(self):
self.cmd('account management-group create --name testcligetgroup1')
self.cmd('account management-group create --name testcligetgroup2 --parent /providers/Microsoft.Management/managementGroups/testcligetgroup1')
self.cmd('account management-group create --name testcligetgroup3 --parent testcligetgroup2')
self.cmd('account management-group create --name testcligetgroup4 --parent /providers/Microsoft.Management/managementGroups/testcligetgroup3')
managementgroup_get = self.cmd(
'account management-group show --name testcligetgroup2 --expand --recurse').get_output_in_json()
self.cmd('account management-group delete --name testcligetgroup4')
self.cmd('account management-group delete --name testcligetgroup3')
self.cmd('account management-group delete --name testcligetgroup2')
self.cmd('account management-group delete --name testcligetgroup1')
self.assertIsNotNone(managementgroup_get)
self.assertIsNotNone(managementgroup_get["children"])
self.assertIsNotNone(managementgroup_get["details"])
self.assertEqual(
managementgroup_get["id"],
"/providers/Microsoft.Management/managementGroups/testcligetgroup2")
self.assertEqual(managementgroup_get["name"], "testcligetgroup2")
self.assertEqual(
managementgroup_get["displayName"],
"testcligetgroup2")
self.assertEqual(
managementgroup_get["details"]["parent"]["displayName"],
"testcligetgroup1")
self.assertEqual(
managementgroup_get["details"]["parent"]["id"],
"/providers/Microsoft.Management/managementGroups/testcligetgroup1")
self.assertEqual(
managementgroup_get["details"]["parent"]["name"],
"testcligetgroup1")
self.assertIsNotNone(managementgroup_get["tenantId"])
self.assertEqual(
managementgroup_get["type"],
"/providers/Microsoft.Management/managementGroups")
self.assertEqual(
managementgroup_get["children"][0]["id"],
"/providers/Microsoft.Management/managementGroups/testcligetgroup3")
self.assertEqual(
managementgroup_get["children"][0]["type"],
"/providers/Microsoft.Management/managementGroups")
self.assertEqual(
managementgroup_get["children"][0]["displayName"],
"testcligetgroup3")
self.assertEqual(
managementgroup_get["children"][0]["name"],
"testcligetgroup3")
self.assertEqual(
managementgroup_get["children"][0]["children"][0]["id"],
"/providers/Microsoft.Management/managementGroups/testcligetgroup4")
self.assertEqual(
managementgroup_get["children"][0]["children"][0]["type"],
"/providers/Microsoft.Management/managementGroups")
self.assertEqual(
managementgroup_get["children"][0]["children"][0]["displayName"],
"testcligetgroup4")
self.assertEqual(
managementgroup_get["children"][0]["children"][0]["name"],
"testcligetgroup4")
def test_create_managementgroup(self):
name = "testcligroup"
displayName = "testcligroup"
managementgroup_create = self.cmd(
'account management-group create --name ' +
name).get_output_in_json()
self.cmd('account management-group delete --name ' + name)
self.assertIsNotNone(managementgroup_create)
self.assertIsNotNone(managementgroup_create["properties"]["details"])
self.assertEqual(
managementgroup_create["id"],
"/providers/Microsoft.Management/managementGroups/" + name)
self.assertEqual(managementgroup_create["name"], name)
self.assertEqual(
managementgroup_create["properties"]["displayName"],
displayName)
self.assertEqual(
managementgroup_create["properties"]["details"]["parent"]["id"],
"/providers/Microsoft.Management/managementGroups/" +
managementgroup_create["properties"]["tenantId"])
self.assertEqual(
managementgroup_create["properties"]["details"]["parent"]["name"],
managementgroup_create["properties"]["tenantId"])
self.assertIsNotNone(managementgroup_create["properties"]["tenantId"])
self.assertEqual(
managementgroup_create["type"],
"/providers/Microsoft.Management/managementGroups")
def test_create_managementgroup_with_displayname(self):
name = "testcligroup"
displayName = "TestCliDisplayName"
managementgroup_create = self.cmd(
'account management-group create --name ' +
name +
' --display-name ' +
displayName).get_output_in_json()
self.cmd('account management-group delete --name ' + name)
self.assertIsNotNone(managementgroup_create)
self.assertIsNotNone(managementgroup_create["properties"]["details"])
self.assertEqual(
managementgroup_create["id"],
"/providers/Microsoft.Management/managementGroups/" + name)
self.assertEqual(managementgroup_create["name"], name)
self.assertEqual(
managementgroup_create["properties"]["displayName"],
displayName)
self.assertEqual(
managementgroup_create["properties"]["details"]["parent"]["id"],
"/providers/Microsoft.Management/managementGroups/" +
managementgroup_create["properties"]["tenantId"])
self.assertEqual(
managementgroup_create["properties"]["details"]["parent"]["name"],
managementgroup_create["properties"]["tenantId"])
self.assertIsNotNone(managementgroup_create["properties"]["tenantId"])
self.assertEqual(
managementgroup_create["type"],
"/providers/Microsoft.Management/managementGroups")
def test_create_managementgroup_with_parentid(self):
name = "testcligroupchild"
displayName = "testcligroupchild"
parentId = "/providers/Microsoft.Management/managementGroups/testcligroup"
parentName = "testcligroup"
self.cmd('account management-group create --name ' + parentName)
managementgroup_create = self.cmd(
'account management-group create --name ' +
name +
' --parent ' +
parentId).get_output_in_json()
self.cmd('account management-group delete --name ' + name)
self.cmd('account management-group delete --name ' + parentName)
self.assertIsNotNone(managementgroup_create)
self.assertIsNotNone(managementgroup_create["properties"]["details"])
self.assertEqual(
managementgroup_create["id"],
"/providers/Microsoft.Management/managementGroups/" + name)
self.assertEqual(managementgroup_create["name"], name)
self.assertEqual(
managementgroup_create["properties"]["displayName"],
displayName)
self.assertEqual(
managementgroup_create["properties"]["details"]["parent"]["displayName"],
parentName)
self.assertEqual(
managementgroup_create["properties"]["details"]["parent"]["id"],
parentId)
self.assertEqual(
managementgroup_create["properties"]["details"]["parent"]["name"],
parentName)
self.assertIsNotNone(managementgroup_create["properties"]["tenantId"])
self.assertEqual(
managementgroup_create["type"],
"/providers/Microsoft.Management/managementGroups")
def test_create_managementgroup_with_displayname_and_parentid(self):
name = "testcligroupchild"
displayName = "testcligroupchildDisplayName"
parentId = "/providers/Microsoft.Management/managementGroups/testcligroup"
parentName = "testcligroup"
self.cmd('account management-group create --name ' + parentName)
managementgroup_create = self.cmd(
'account management-group create --name ' +
name +
' --display-name ' +
displayName +
' --parent ' +
parentName).get_output_in_json()
self.cmd('account management-group delete --name ' + name)
self.cmd('account management-group delete --name ' + parentName)
self.assertIsNotNone(managementgroup_create)
self.assertIsNotNone(managementgroup_create["properties"]["details"])
self.assertEqual(
managementgroup_create["id"],
"/providers/Microsoft.Management/managementGroups/" + name)
self.assertEqual(managementgroup_create["name"], name)
self.assertEqual(
managementgroup_create["properties"]["displayName"],
displayName)
self.assertEqual(
managementgroup_create["properties"]["details"]["parent"]["displayName"],
parentName)
self.assertEqual(
managementgroup_create["properties"]["details"]["parent"]["id"],
parentId)
self.assertEqual(
managementgroup_create["properties"]["details"]["parent"]["name"],
parentName)
self.assertIsNotNone(managementgroup_create["properties"]["tenantId"])
self.assertEqual(
managementgroup_create["type"],
"/providers/Microsoft.Management/managementGroups")
def test_update_managementgroup_with_displayname(self):
name = "testcligroup"
displayName = "testcligroupDisplayName"
self.cmd('account management-group create --name ' + name)
managementgroup_update = self.cmd(
'account management-group update --name ' +
name +
' --display-name ' +
displayName).get_output_in_json()
self.cmd('account management-group delete --name ' + name)
self.assertIsNotNone(managementgroup_update)
self.assertIsNotNone(managementgroup_update["details"])
self.assertEqual(
managementgroup_update["id"],
"/providers/Microsoft.Management/managementGroups/" + name)
self.assertEqual(managementgroup_update["name"], name)
self.assertEqual(managementgroup_update["displayName"], displayName)
self.assertEqual(
managementgroup_update["details"]["parent"]["id"],
"/providers/Microsoft.Management/managementGroups/" +
managementgroup_update["tenantId"])
self.assertEqual(
managementgroup_update["details"]["parent"]["name"],
managementgroup_update["tenantId"])
self.assertIsNotNone(managementgroup_update["tenantId"])
self.assertEqual(
managementgroup_update["type"],
"/providers/Microsoft.Management/managementGroups")
def test_update_managementgroup_with_parentid(self):
name = "testcligroupchild"
displayName = "testcligroupchild"
parentId = "/providers/Microsoft.Management/managementGroups/testcligroup"
parentName = "testcligroup"
self.cmd('account management-group create --name ' + parentName)
self.cmd('account management-group create --name ' + name)
managementgroup_update = self.cmd(
'account management-group update --name ' +
name +
' --parent ' +
parentId).get_output_in_json()
self.cmd('account management-group delete --name ' + name)
self.cmd('account management-group delete --name ' + parentName)
self.assertIsNotNone(managementgroup_update)
self.assertIsNotNone(managementgroup_update["details"])
self.assertEqual(
managementgroup_update["id"],
"/providers/Microsoft.Management/managementGroups/" + name)
self.assertEqual(managementgroup_update["name"], name)
self.assertEqual(managementgroup_update["displayName"], displayName)
self.assertEqual(
managementgroup_update["details"]["parent"]["displayName"],
parentName)
self.assertEqual(
managementgroup_update["details"]["parent"]["id"],
parentId)
self.assertEqual(
managementgroup_update["details"]["parent"]["name"],
parentName)
self.assertIsNotNone(managementgroup_update["tenantId"])
self.assertEqual(
managementgroup_update["type"],
"/providers/Microsoft.Management/managementGroups")
def test_update_managementgroup_with_displayname_and_parentid(self):
name = "testcligroupchild"
displayName = "testcligroupchild"
parentId = "/providers/Microsoft.Management/managementGroups/testcligroup"
parentName = "testcligroup"
self.cmd('account management-group create --name ' + parentName)
self.cmd('account management-group create --name ' + name)
managementgroup_update = self.cmd(
'account management-group update --name ' +
name +
' --display-name ' +
displayName +
' --parent ' +
parentName).get_output_in_json()
self.cmd('account management-group delete --name ' + name)
self.cmd('account management-group delete --name ' + parentName)
self.assertIsNotNone(managementgroup_update)
self.assertIsNotNone(managementgroup_update["details"])
self.assertEqual(
managementgroup_update["id"],
"/providers/Microsoft.Management/managementGroups/" + name)
self.assertEqual(managementgroup_update["name"], name)
self.assertEqual(managementgroup_update["displayName"], displayName)
self.assertEqual(
managementgroup_update["details"]["parent"]["displayName"],
parentName)
self.assertEqual(
managementgroup_update["details"]["parent"]["id"],
parentId)
self.assertEqual(
managementgroup_update["details"]["parent"]["name"],
parentName)
self.assertIsNotNone(managementgroup_update["tenantId"])
self.assertEqual(
managementgroup_update["type"],
"/providers/Microsoft.Management/managementGroups")
def test_create_delete_group_managementgroup(self):
self.cmd('account management-group create --name testcligroup')
self.cmd('account management-group delete --name testcligroup')
| 48.831633
| 150
| 0.649775
|
7951cee890c9b9c12b1fbe55f0a2a704d6d0982f
| 464
|
py
|
Python
|
server/djangoapp/admin.py
|
ymitsutomi-personal/agfzb-CloudAppDevelopment_Capstone
|
91ffa41d75f72d41403639d998f2fbea85c42d8b
|
[
"Apache-2.0"
] | null | null | null |
server/djangoapp/admin.py
|
ymitsutomi-personal/agfzb-CloudAppDevelopment_Capstone
|
91ffa41d75f72d41403639d998f2fbea85c42d8b
|
[
"Apache-2.0"
] | null | null | null |
server/djangoapp/admin.py
|
ymitsutomi-personal/agfzb-CloudAppDevelopment_Capstone
|
91ffa41d75f72d41403639d998f2fbea85c42d8b
|
[
"Apache-2.0"
] | null | null | null |
from django.contrib import admin
# from .models import related models
from .models import *
# Register your models here.
class CarModelInline(admin.StackedInline):
model = CarModel
extra = 5
class CarMakeAdmin(admin.ModelAdmin):
inlines = [CarModelInline]
admin.site.register(CarMake, CarMakeAdmin)
admin.site.register(CarModel)
# CarModelInline class
# CarModelAdmin class
# CarMakeAdmin class with CarModelInline
# Register models here
| 17.846154
| 42
| 0.765086
|
7951cf719d2ba072f054235e65c4fee4012f88a5
| 3,920
|
py
|
Python
|
sdks/python/http_client/v1/polyaxon_sdk/models/v1_events_response.py
|
rimon-safesitehq/polyaxon
|
c456d5bec00b36d75feabdccffa45b2be9a6346e
|
[
"Apache-2.0"
] | null | null | null |
sdks/python/http_client/v1/polyaxon_sdk/models/v1_events_response.py
|
rimon-safesitehq/polyaxon
|
c456d5bec00b36d75feabdccffa45b2be9a6346e
|
[
"Apache-2.0"
] | null | null | null |
sdks/python/http_client/v1/polyaxon_sdk/models/v1_events_response.py
|
rimon-safesitehq/polyaxon
|
c456d5bec00b36d75feabdccffa45b2be9a6346e
|
[
"Apache-2.0"
] | null | null | null |
#!/usr/bin/python
#
# Copyright 2018-2021 Polyaxon, Inc.
#
# 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.
# coding: utf-8
"""
Polyaxon SDKs and REST API specification.
Polyaxon SDKs and REST API specification. # noqa: E501
The version of the OpenAPI document: 1.8.3
Contact: contact@polyaxon.com
Generated by: https://openapi-generator.tech
"""
import pprint
import re # noqa: F401
import six
from polyaxon_sdk.configuration import Configuration
class V1EventsResponse(object):
"""NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Do not edit the class manually.
"""
"""
Attributes:
openapi_types (dict): The key is attribute name
and the value is attribute type.
attribute_map (dict): The key is attribute name
and the value is json key in definition.
"""
openapi_types = {
'data': 'list[object]'
}
attribute_map = {
'data': 'data'
}
def __init__(self, data=None, local_vars_configuration=None): # noqa: E501
"""V1EventsResponse - a model defined in OpenAPI""" # noqa: E501
if local_vars_configuration is None:
local_vars_configuration = Configuration()
self.local_vars_configuration = local_vars_configuration
self._data = None
self.discriminator = None
if data is not None:
self.data = data
@property
def data(self):
"""Gets the data of this V1EventsResponse. # noqa: E501
:return: The data of this V1EventsResponse. # noqa: E501
:rtype: list[object]
"""
return self._data
@data.setter
def data(self, data):
"""Sets the data of this V1EventsResponse.
:param data: The data of this V1EventsResponse. # noqa: E501
:type: list[object]
"""
self._data = data
def to_dict(self):
"""Returns the model properties as a dict"""
result = {}
for attr, _ in six.iteritems(self.openapi_types):
value = getattr(self, attr)
if isinstance(value, list):
result[attr] = list(map(
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
value
))
elif hasattr(value, "to_dict"):
result[attr] = value.to_dict()
elif isinstance(value, dict):
result[attr] = dict(map(
lambda item: (item[0], item[1].to_dict())
if hasattr(item[1], "to_dict") else item,
value.items()
))
else:
result[attr] = value
return result
def to_str(self):
"""Returns the string representation of the model"""
return pprint.pformat(self.to_dict())
def __repr__(self):
"""For `print` and `pprint`"""
return self.to_str()
def __eq__(self, other):
"""Returns true if both objects are equal"""
if not isinstance(other, V1EventsResponse):
return False
return self.to_dict() == other.to_dict()
def __ne__(self, other):
"""Returns true if both objects are not equal"""
if not isinstance(other, V1EventsResponse):
return True
return self.to_dict() != other.to_dict()
| 28.405797
| 79
| 0.59949
|
7951cfa62df492dcd527fc41724a3f6296c339f7
| 3,095
|
py
|
Python
|
src/zptess/dbase/utils.py
|
STARS4ALL/zptess
|
9bbe91720f283756a0938c7ac4dde180c1e1eda2
|
[
"MIT"
] | null | null | null |
src/zptess/dbase/utils.py
|
STARS4ALL/zptess
|
9bbe91720f283756a0938c7ac4dde180c1e1eda2
|
[
"MIT"
] | null | null | null |
src/zptess/dbase/utils.py
|
STARS4ALL/zptess
|
9bbe91720f283756a0938c7ac4dde180c1e1eda2
|
[
"MIT"
] | null | null | null |
# ----------------------------------------------------------------------
# Copyright (c) 2022
#
# See the LICENSE file for details
# see the AUTHORS file for authors
# ----------------------------------------------------------------------
#--------------------
# System wide imports
# -------------------
import os
import os.path
import glob
import sqlite3
# -------------------
# Third party imports
# -------------------
#--------------
# local imports
# -------------
# ----------------
# Module constants
# ----------------
VERSION_QUERY = "SELECT value from config_t WHERE section ='database' AND property = 'version'"
# -----------------------
# Module global variables
# -----------------------
# ------------------------
# Module Utility Functions
# ------------------------
def _filter_factory(connection):
cursor = connection.cursor()
cursor.execute(VERSION_QUERY)
result = cursor.fetchone()
if not result:
raise NotImplementedError(VERSION_QUERY)
version = int(result[0])
return lambda path: int(os.path.basename(path)[:2]) > version
# -------------------------
# Module exported functions
# -------------------------
def create_database(dbase_path):
'''Creates a Database file if not exists and returns a connection'''
new_database = False
output_dir = os.path.dirname(dbase_path)
if not output_dir:
output_dir = os.getcwd()
os.makedirs(output_dir, exist_ok=True)
if not os.path.exists(dbase_path):
with open(dbase_path, 'w') as f:
pass
new_database = True
return sqlite3.connect(dbase_path), new_database
def create_schema(connection, schema_path, initial_data_dir_path, updates_data_dir, query=VERSION_QUERY):
created = True
cursor = connection.cursor()
try:
cursor.execute(query)
except Exception:
created = False
if not created:
with open(schema_path) as f:
lines = f.readlines()
script = ''.join(lines)
connection.executescript(script)
#log.info("Created data model from {0}".format(os.path.basename(schema_path)))
file_list = glob.glob(os.path.join(initial_data_dir_path, '*.sql'))
for sql_file in file_list:
#log.info("Populating data model from {0}".format(os.path.basename(sql_file)))
with open(sql_file) as f:
lines = f.readlines()
script = ''.join(lines)
connection.executescript(script)
else:
filter_func = _filter_factory(connection)
file_list = sorted(glob.glob(os.path.join(updates_data_dir, '*.sql')))
file_list = list(filter(filter_func,file_list))
for sql_file in file_list:
#log.info("Applying updates to data model from {0}".format(os.path.basename(sql_file)))
with open(sql_file) as f:
lines = f.readlines()
script = ''.join(lines)
connection.executescript(script)
connection.commit()
return not created, file_list
__all__ = [
"create_database",
"create_schema",
]
| 29.198113
| 105
| 0.559612
|
7951d06092873a757c9bf0d9a00145154eac0945
| 485
|
py
|
Python
|
scale/scheduler/node/agent.py
|
kaydoh/scale
|
1b6a3b879ffe83e10d3b9d9074835a4c3bf476ee
|
[
"Apache-2.0"
] | 121
|
2015-11-18T18:15:33.000Z
|
2022-03-10T01:55:00.000Z
|
scale/scheduler/node/agent.py
|
kaydoh/scale
|
1b6a3b879ffe83e10d3b9d9074835a4c3bf476ee
|
[
"Apache-2.0"
] | 1,415
|
2015-12-23T23:36:04.000Z
|
2022-01-07T14:10:09.000Z
|
scale/scheduler/node/agent.py
|
kaydoh/scale
|
1b6a3b879ffe83e10d3b9d9074835a4c3bf476ee
|
[
"Apache-2.0"
] | 66
|
2015-12-03T20:38:56.000Z
|
2020-07-27T15:28:11.000Z
|
"""Defines the class that represents an agent in the scheduler"""
from __future__ import unicode_literals
class Agent(object):
"""This class represents an agent available to Scale."""
def __init__(self, agent_id, hostname):
"""Constructor
:param agent_id: The agent ID
:type agent_id: string
:param hostname: The agent's host name
:type hostname: string
"""
self.agent_id = agent_id
self.hostname = hostname
| 25.526316
| 65
| 0.649485
|
7951d2b389f06c81b1a3a407fe38f4564b0b6a52
| 3,693
|
py
|
Python
|
app/models.py
|
fnyaoke/blog
|
89727db4e82e2c2852e38fc4662742696091f6ba
|
[
"MIT"
] | null | null | null |
app/models.py
|
fnyaoke/blog
|
89727db4e82e2c2852e38fc4662742696091f6ba
|
[
"MIT"
] | null | null | null |
app/models.py
|
fnyaoke/blog
|
89727db4e82e2c2852e38fc4662742696091f6ba
|
[
"MIT"
] | null | null | null |
from werkzeug.security import generate_password_hash,check_password_hash
from . import db
from datetime import datetime
from flask_login import UserMixin
from . import login_manager
class User(UserMixin, db.Model):
"""
class modelling the users
"""
__tablename__='users'
#create the columns
id = db.Column(db.Integer,primary_key = True)
username = db.Column(db.String(255))
email = db.Column(db.String(255),unique = True, index =True)
pass_secure = db.Column(db.String(255))
bio = db.Column(db.String(255))
profile_pic_path = db.Column(db.String(20), default='default.jpeg')
posts = db.relationship("Post", backref="user", lazy = "dynamic")
comment = db.relationship("Comments", backref="user", lazy = "dynamic")
vote = db.relationship("Votes", backref="user", lazy = "dynamic")
# securing passwords
@property
def password(self):
raise AttributeError('You can not read the password Attribute')
@password.setter
def password(self, password):
self.pass_secure = generate_password_hash(password)
def verify_password(self,password):
return check_password_hash(self.pass_secure,password)
def __repr__(self):
return f'User {self.username}'
#posts class
class Post(db.Model):
"""
List of posts in each category
"""
__tablename__ = 'posts'
id = db.Column(db.Integer,primary_key = True)
title = db.Column(db.String())
content = db.Column(db.String())
user_id = db.Column(db.Integer,db.ForeignKey("users.id"))
#comment = db.relationship("Comments", backref="posts", lazy = "dynamic")
vote = db.relationship("Votes", backref="posts", lazy = "dynamic")
def save_post(self):
"""
Save the posts
"""
db.session.add(self)
db.session.commit()
@classmethod
def clear_posts(cls):
Post.all_posts.clear()
# display posts
def get_posts(id):
post = Post.query.filter_by(category_id=id).all()
return post
# comments
class Comments(db.Model):
"""
User comment model for each pitch
"""
__tablename__ = 'comments'
# add columns
id = db.Column(db. Integer, primary_key=True)
opinion = db.Column(db.String(255))
time_posted = db.Column(db.DateTime, default=datetime.utcnow)
user_id = db.Column(db.Integer, db.ForeignKey("users.id"))
#posts_id = db.Column(db.Integer, db.ForeignKey("posts.id"))
posts_id = db.Column(db.Integer)
def save_comment(self):
"""
Save the Comments/comments per pitch
"""
db.session.add(self)
db.session.commit()
@classmethod
def get_comments(self):
# comment = Comments.query.filter_by(posts_id=id).all()
comment = Comments.query.all()
return comment
#votes
class Votes(db.Model):
"""
class to model votes
"""
__tablename__='votes'
id = db.Column(db. Integer, primary_key=True)
vote = db.Column(db.Integer)
user_id = db.Column(db.Integer, db.ForeignKey("users.id"))
posts_id = db.Column(db.Integer, db.ForeignKey("posts.id"))
def save_vote(self):
db.session.add(self)
db.session.commit()
@classmethod
def get_votes(cls,user_id, posts_id):
votes = Votes.query.filter_by(user_id=user_id, posts_id= posts_id).all()
return votes
class Quote:
'''
Quote class which defines the Quote objects to be created
'''
def __init__(self,quote,author):
self.quote = quote
self.author = author
@login_manager.user_loader
def load_user(user_id):
return User.query.get(int(user_id))
| 23.980519
| 80
| 0.645275
|
7951d408b781ee158c13f34ec922d769eff59f3b
| 3,227
|
py
|
Python
|
etc/structure/project_name/settings.py
|
Lovekesh-GH/Restapi
|
e66c057b67356545564f348f1d067e2eb5f89e66
|
[
"MIT"
] | 3
|
2021-08-08T05:36:31.000Z
|
2022-03-10T13:27:22.000Z
|
etc/structure/project_name/settings.py
|
Lovekesh-GH/Restapi
|
e66c057b67356545564f348f1d067e2eb5f89e66
|
[
"MIT"
] | 1
|
2021-07-10T17:31:59.000Z
|
2021-07-11T06:14:53.000Z
|
etc/structure/project_name/settings.py
|
Lovekesh-GH/Restapi
|
e66c057b67356545564f348f1d067e2eb5f89e66
|
[
"MIT"
] | 1
|
2021-07-10T17:39:00.000Z
|
2021-07-10T17:39:00.000Z
|
"""
Django settings for {{project_name}} project.
Generated by 'django-admin startproject' using Django 3.2.5.
For more information on this file, see
https://docs.djangoproject.com/en/3.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.2/ref/settings/
"""
import os
from pathlib import Path
from dotenv import load_dotenv
load_dotenv()
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
# Environment
SECRET_KEY = os.getenv("SECRET_KEY")
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
]
MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
]
ROOT_URLCONF = "{{project_name}}.urls"
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.template.context_processors.debug",
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
],
},
},
]
WSGI_APPLICATION = "{{project_name}}.wsgi.application"
# Database
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": BASE_DIR / "db.sqlite3",
}
}
# Password validation
# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
},
{
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
},
{
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
},
{
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
},
]
# Internationalization
# https://docs.djangoproject.com/en/3.2/topics/i18n/
LANGUAGE_CODE = "en-us"
TIME_ZONE = "UTC"
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.2/howto/static-files/
STATIC_URL = "/static/"
# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
| 24.823077
| 91
| 0.700341
|
7951d484094aa752a34510e30e98c026b356c49d
| 329
|
py
|
Python
|
web/private/deck_code_decode.py
|
mashirozx/hearthstone-deck-embed
|
82768ce0ec33e9909cb2acb3e4911223fb8121d6
|
[
"MIT"
] | 5
|
2018-12-16T16:34:38.000Z
|
2019-05-26T20:46:11.000Z
|
web/private/deck_code_decode.py
|
mashirozx/hearthstone-deck-embed
|
82768ce0ec33e9909cb2acb3e4911223fb8121d6
|
[
"MIT"
] | 47
|
2018-12-22T13:56:29.000Z
|
2020-11-01T17:02:28.000Z
|
web/private/deck_code_decode.py
|
Zevs6/Awesome-Deck
|
7228b6ec613b941692c2e37bae95c6d199c82b56
|
[
"MIT"
] | 2
|
2018-12-14T15:37:43.000Z
|
2019-11-12T06:52:40.000Z
|
from hearthstone.deckstrings import Deck
from hearthstone.enums import FormatType
def deck_code_decode(deck_code):
# Deckstring decode. See:
# https://hearthsim.info/docs/deckstrings/
deck = Deck.from_deckstring(deck_code)
deck_hero = deck.heroes[0]
deck_card = deck.cards
return [deck_hero, deck_card]
| 27.416667
| 46
| 0.74772
|
7951d5523a5a707c62cb41aba3d77847d3d79557
| 23,365
|
py
|
Python
|
LBH_to_eflux/observations/ssusi.py
|
jali7001/LBH_to_E_flux
|
ad51ea46f72855db805e28fa0ca0b227b43d2683
|
[
"MIT"
] | 1
|
2021-02-12T19:59:36.000Z
|
2021-02-12T19:59:36.000Z
|
LBH_to_eflux/observations/ssusi.py
|
jali7001/LBH_to_E_flux
|
ad51ea46f72855db805e28fa0ca0b227b43d2683
|
[
"MIT"
] | 1
|
2021-11-02T05:14:33.000Z
|
2021-11-02T05:14:33.000Z
|
LBH_to_eflux/observations/ssusi.py
|
jali7001/LBH_to_E_flux
|
ad51ea46f72855db805e28fa0ca0b227b43d2683
|
[
"MIT"
] | 1
|
2021-04-10T23:01:29.000Z
|
2021-04-10T23:01:29.000Z
|
from collections import OrderedDict
import numpy as np
from geospacepy.special_datetime import (datetimearr2jd,
datetime2jd,
jd2datetime)
import esabin
import datetime, os
import h5py
from sklearn import linear_model
from LBH_to_eflux.helper_funcs import latlt2polar, polar2dial, module_Apex, update_apex_epoch
class SDRPass(object):
"""
Description
-----------
This class reads in a NASA CDAweb SSUSI SDR disk file corresponding to one spacecraft orbit and stores the pass data as class attributes.
After instantiating this class, you can call get_ingest_data() to get observations for one polar pass,
Attributes
----------
name : str
Name of observations
['jds'] : np.ndarray (n_obs x 1)
Array of observation times (in Julian Data)
['observer_ids'] : np.ndarray (n_obs x 1)
Satellite number associated with observations
['Y'] : array_like (n_obs x 1)
Observations of FUV radiance whose color is specified by radiance_type (in kilo rayleighs)
['Y_var'] : np.ndarray (n_obs x 1)
Observation error
['lats'] : np.ndarray (n_obs x 1)
Magnetic latitude (degrees) of observations in Apex coordinates of reference height 110 km
['lons'] : np.ndarray (n_obs x 1)
Magnetic local time of observations (expressed in degrees ) of observations in Apex coordinates
['observer_ids'] : np.ndarrray (n_obs x 1)
Satellite number associated with observations
"""
def __init__(self, ssusi_file, dmsp, hemisphere, radiance_type = 'LBHL', noise_removal = True, spatial_bin = False, minlat = 50):
"""
Parameters
----------
ssusi_file : str
Location of SSUSI file to read in
dmsp : int
DMSP spacecraft number which must take value in [16, 17, 18]
hemisphere : str
Hemisphere of observations (must be either 'N' or 'S')
radiance_type : str
"Color" of FUV radiance to read in. Must be one of ['Lyman Alpha','OI 130.4', 'OI 135.6', 'LBHS', 'LBHL']
noise_removal : bool, optional
If true, removes solar influence from FUV radiances
Its default value is True
spatial_bin : bool, optional
If true, spatially bins observations
Its default value is False
minlat : int, optional
Minimum latitude in magnetic degrees a polar pass
"""
self.ssusi_file = ssusi_file
self.dmsp = dmsp
self.hemisphere = hemisphere
self.radiance_type = radiance_type
self.noise_removal = noise_removal
self.spatial_bin = spatial_bin
self.minlat = minlat
self.name = 'SSUSI ' + radiance_type
self.ssusi_colors = {
'Lyman Alpha':0,
'OI 130.4':1,
'OI 135.6':2,
'LBHS':3,
'LBHL':4
}
self.observers = [16,17,18]
self.arg_radiance = self.ssusi_colors[radiance_type]
#prepare grid if spatially binning
if spatial_bin:
self.grid = esabin.esagrid.Esagrid(2, azi_coord = 'lt')
pass_data = self.get_ssusi_pass()
self['jds'] = pass_data['epochjd_match']
self['observer_ids'] = pass_data['observer']
self['Y'] = pass_data['Y']
self['Y_var'] = pass_data['Y_var']
self['lats'] = pass_data['mlat']
self['lons'] = pass_data['mlon']
def get_data_window(self, startdt, enddt, hemisphere, allowed_observers):
"""
Applies the hemisphere and datetime interval to the attributes of the class.
Parameters
----------
startdt : datetime object
Defaults to first available observation time
enddt : datetime object
Defaults to last available observation time
hemisphere : str
Defaults to hemisphere specified in init
Returns
-------
data_window : OrderedDict
Contains the following elements
['jds'] : np.ndarray (n_obs x 1)
Array of observation times (in Julian Data)
['observer_ids'] : np.ndarray (n_obs x 1)
Satellite number associated with observations
['Y'] : array_like (n_obs x 1)
Observations of FUV radiance whose color is specified by radiance_type (in kilo rayleighs)
['Y_var'] : np.ndarray (n_obs x 1)
Observation error
['lats'] : np.ndarray (n_obs x 1)
Magnetic latitude (degrees) of observations in Apex coordinates of reference height 110 km
['lons'] : np.ndarray (n_obs x 1)
Magnetic local time of observations (expressed in degrees ) of observations in Apex coordinates
['observer_ids'] : np.ndarrray (n_obs x 1)
Satellite number associated with observations
"""
mask = self.get_data_window_mask(startdt, enddt, hemisphere, allowed_observers)
data_window = OrderedDict()
for datavarname,datavararr in self.items():
data_window[datavarname] = datavararr[mask]
return data_window
def _read_SDR_file(self, file_name):
"""
Reads in the Disk Radiances and their piercepoint day observation location.
SSUSI data comes in sweeps of 42 cross track observations.
Therefore the total number of observation is n_obs = 42 * n_sweeps
Parameters
----------
file_name : str
location of SSUSI SDR file
Returns
-------
disk : dict
Dictionary of relevant values from the SDR value with elements
['glat'] : np.ndarray (42 x n_sweeps)
Geographic Latitude of observations
['glon'] : np.ndarray (42 x n_sweeps)
Geographic longitude of observations
['alt'] : np.ndarray (1 x 1)
Altitude of observations
['time'] : np.ndarray (n_sweeps)
Seconds during day
['year'] : np.ndarray (n_sweeps)
Year of obs
['radiance_all_colors'] : np.ndarray (42 x n_sweeps x 5)
All 5 FUV "colors" (kRa)
['radiance_all_colors_uncertainty'] : np.ndarray (42 x n_obs x 5)
Uncertainty of FUV radiances (kRa)
['SZA'] : np.ndarray (42 x n_sweeps x 5)
Solar Zenith angle of observations (deg)
['epooch'] : list (n_sweeps x 1)
list of observation times in datetime objects
"""
disk = {} #initialize disk measurements
with h5py.File(file_name,'r') as h5f:
#location of obs in geographic coordinates
disk['glat'] = h5f['PIERCEPOINT_DAY_LATITUDE_AURORAL'][:]
disk['glon'] = h5f['PIERCEPOINT_DAY_LONGITUDE_AURORAL'][:]
disk['alt'] = h5f['PIERCEPOINT_DAY_ALTITUDE_AURORAL'][:]
#time of observations
disk['time'] = h5f['TIME_DAY_AURORAL'][:] #seconds since start of day
disk['year'] = h5f['YEAR_DAY_AURORAL'][:]
disk['doy'] = h5f['DOY_DAY_AURORAL'][:]
#read radiances as kR
disk['radiance_all_colors_uncertainty'] = h5f['DISK_RADIANCE_UNCERTAINTY_DAY_AURORAL'][:] /1000.
disk['radiance_all_colors'] = h5f['DISK_RECTIFIED_INTENSITY_DAY_AURORAL'][:] / 1000.
#read in solar zenith angle in degrees
disk['SZA'] = h5f['PIERCEPOINT_DAY_SZA_AURORAL'][:]
h5f.close()
#get epoch from seconds of day, day of year, and year in terms of datetimes
dt = np.empty((len(disk['doy']),1),dtype='object')
for k in range(len(dt)):
dt[k,0] = datetime.datetime(disk['year'][k],1,1,0,0,0)+datetime.timedelta(days=disk['doy'][k]-1.) + datetime.timedelta(seconds= disk['time'][k])
disk['epoch'] = dt.flatten()
return disk
def get_ssusi_pass(self):
"""
Main function to read in and preprocess SDR file.
1. Read SDR ncdf file
2. Convert observations to magnetic coordinates
3. Applies solar influence removal if desired
4. Applies Spatial binning if desired
Returns
-------
disk_int : dict
Dictionary preprocessed observations with elements
['epochjd_match'] : np.ndarray (n_obs x 1)
Array of observation times (in Julian Data)
['observer_ids'] : np.ndarray (n_obs x 1)
Satellite number associated with observations
['Y'] : array_like (n_obs x 1)
Observations of FUV radiance whose color is specified by radiance_type (in kilo rayleighs)
['Y_var'] : np.ndarray (n_obs x 1)
Observation error
['mlat'] : np.ndarray (n_obs x 1)
Magnetic latitude (degrees) of observations in Apex coordinates of reference height 110 km
['mlon'] : np.ndarray (n_obs x 1)
Magnetic local time of observations (expressed in degrees ) of observations in Apex coordinates
['observer'] : np.ndarrray (n_obs x 1)
Satellite number associated with observations
"""
ssusi_file = self.ssusi_file
#Step 1: read in each file
disk_data = self._read_SDR_file(ssusi_file)
#Step 2: integrate disk data into usable magnetic coordinates
disk_int = self._ssusi_integrate(disk_data)
#report mlon is magnetic local time in degrees
disk_int['mlon'] = disk_int['mlt'] * 15
#get observation times
shape = np.shape(disk_int['mlat'])
disk_int['epoch_match'] = np.tile(disk_int['epoch'].flatten(), (shape[0],1))
#get the relevant observations
disk_int['Y'] = disk_int['radiance_all_colors'][:,:,self.arg_radiance]
disk_int['Y_var'] = disk_int['radiance_all_colors_uncertainty'][:,:,self.arg_radiance]
#get rid of negative values
disk_int['Y'][disk_int['Y']<0] = 0
#Step 3: if solar influence removal
if self.noise_removal:
radiance_fit = self._radiance_zenith_correction(disk_data['SZA'],disk_int['Y'])
disk_int['Y'] = disk_int['Y'] - radiance_fit
disk_int['Y'][disk_int['Y']<0] = 0
#flatten data
for item in disk_int:
disk_int[item] = disk_int[item].flatten()
#get times in terms of jds
disk_int['epochjd_match'] = datetimearr2jd(disk_int['epoch_match']).flatten()
#Step 4: spatially bin observations if desired
if self.spatial_bin:
disk_int = self.ssusi_spatial_binning(disk_int)
disk_int['observer'] = np.ones_like(disk_int['epochjd_match']) * self.dmsp
return disk_int
def ssusi_spatial_binning(self,disk_int):
"""
This function spatially bins the observations using equal solid angle binning.
Parameters
----------
disk_int : dict
dictionary from ssusi_pass with elements
['epochjd_match'] : np.ndarray (n_obs x 1)
Array of observation times (in Julian Data)
['observer_ids'] : np.ndarray (n_obs x 1)
Satellite number associated with observations
['Y'] : array_like (n_obs x 1)
Observations of FUV radiance whose color is specified by radiance_type (in kilo rayleighs)
['Y_var'] : np.ndarray (n_obs x 1)
Observation error
['mlat'] : np.ndarray (n_obs x 1)
Magnetic latitude (degrees) of observations in Apex coordinates of reference height 110 km
['mlon'] : np.ndarray (n_obs x 1)
Magnetic local time of observations (expressed in degrees ) of observations in Apex coordinates
['observer'] : np.ndarrray (n_obs x 1)
Satellite number associated with observations
Returns
-------
disk_int : dict
Same keys as input but binned lol
"""
disk_binned = {}
#spatial bin
lats_in_pass, lts_in_pass, Y_in_pass, Y_var_in_pass = disk_int['mlat'], disk_int['mlt'], disk_int['Y'], disk_int['Y_var']
epochjds_in_pass = disk_int['epochjd_match']
#convert from mlt [0, 24] to [-12, 12]
lts_mask = lts_in_pass >= 12
lts_in_pass[lts_mask] -= 24
#bin observation values
binlats, binlons, binstats = self.grid.bin_stats(lats_in_pass.flatten(), lts_in_pass.flatten(), Y_in_pass.flatten(), \
statfun = np.nanmean, center_or_edges = 'center')
#get varaince of each bin
binlats, binlons, binstats_var = self.grid.bin_stats(lats_in_pass.flatten(), lts_in_pass.flatten(), Y_var_in_pass.flatten(), \
statfun = np.nanvar, center_or_edges = 'center')
#bin observation time
binlats, binlons, binstats_time = self.grid.bin_stats(lats_in_pass.flatten(), lts_in_pass.flatten(), epochjds_in_pass.flatten(), \
statfun = np.nanmedian, center_or_edges = 'center')
#convert from mlt -12 to 12 to degrees 0 to 360
binlons[binlons>=0] = 15*binlons[binlons>=0]
binlons[binlons<0] = (binlons[binlons<0]+24)*15
disk_binned['mlat'], disk_binned['mlon'], disk_binned['Y'], disk_binned['Y_var'] = binlats, binlons, binstats, binstats_var
disk_binned['epochjd_match'] = binstats_time
return disk_binned
def geo2apex(self,datadict):
"""
Perform coordinate transform for disk measurements from geographic to apex magnetic coordinates
Parameters
----------
datadict : dict
dictionary object from _read_SDR_file()
Returns
-------
alat : np.ndarray (same shape as datadict['glat'])
Apex latitude
mlt, : np.ndarray (same shape as datadict['glat'])
Magnetic local time
"""
#take coordinates from data dictionary
glat,glon,alt = datadict['glat'].flatten(),datadict['glon'].flatten(),datadict['alt'][0]
alt = 110
dt_arrs = datadict['epoch']
#convert to apex coordinates
alat = np.full_like(glat,np.nan)
alon = np.full_like(glat,np.nan)
qdlat = np.full_like(glat,np.nan)
update_apex_epoch(dt_arrs[0]) #This does not need to be precise, time-wise
alatout,alonout = module_Apex.geo2apex(glat,glon,alt)
alat,alon = alatout.flatten(),alonout.flatten()
#calculate time for observations because it isn't available in SDR product
utsec = datadict['time'].flatten()
utsec = (np.tile(utsec, (42,1))).flatten()
dt_arrs_tiled = (np.tile(dt_arrs, (42,1))).flatten()
mlt = np.full_like(alon, np.nan)
for i in range(np.size(mlt)):
mlt[i] = module_Apex.mlon2mlt(alon[i], dt_arrs_tiled[i],alt)
#reshape to original shapes
alat = alat.reshape(datadict['glat'].shape)
mlt = mlt.reshape(datadict['glon'].shape)
return alat,mlt
def get_ingest_data(self,startdt = None, enddt = None, hemisphere = None):
"""
Call to return observations from a polar pass
Parameters
----------
startdt : datetime object
Defaults to first available observation time
enddt : datetime object
Defaults to last available observation time
hemisphere : str
Defaults to hemisphere specified in init
Returns
-------
ylats : np.ndarray
Absolute magnetic latitudes of observations
ylons : np.ndarray
magnetic 'longitudes' (MLT in degrees) of observations
y : np.ndarray
1D array of kiloRayleighs
y_var : np.ndarray
1D array of uncertainies (variances in kiloRayleighs)
jds : np.ndarray
"""
startdt = jd2datetime(np.nanmin(self['jds'])) if startdt is None else startdt
enddt = jd2datetime(np.nanmax(self['jds'])) if enddt is None else enddt
hemisphere = self.hemisphere if hemisphere is None else hemisphere
datadict = self.get_data_window(startdt,
enddt,
hemisphere,
'all')
y = datadict['Y'].reshape(-1,1)
#Format the error/variance vector similarly,
y_var = datadict['Y_var'].reshape(-1,1);
#Locations for each vector component
ylats = datadict['lats'].reshape(-1,1)
ylons = datadict['lons'].reshape(-1,1)
#jds
jds = datadict['jds'].reshape(-1,1)
return np.abs(ylats),ylons,y,y_var,jds
def plot_obs(self, ax, startdt = None,enddt = None,hemisphere = None, **kwargs):
"""
Plot observations from a particular polar pass
Paramters
---------
ax : matplotlib axis
startdt : datetime object
Defaults to first available observation time
enddt : datetime object
Defaults to last available observation time
hemisphere : str
Defaults to hemisphere specified in init
"""
lats,lons,obs,y_var,jds = self.get_ingest_data(startdt,enddt,hemisphere)
r,theta = latlt2polar(lats.flatten(),lons.flatten()/180*12,'N')
ax.scatter(theta,r,c = obs, **kwargs)
polar2dial(ax)
@staticmethod
def _ssusi_integrate_position(position_data):
return np.squeeze(position_data[:,:])
@staticmethod
def _ssusi_integrate_radiance(radiance_data):
return np.squeeze(radiance_data[:,:])
def _ssusi_integrate(self,datadict):
"""
General wrapper for coordinate convserion
datadict - dict
use the output dictionary from the read in function readSSUSISDR()
"""
datadict_out = {}
for varname in datadict:
if 'radiance' in varname:
datadict_out[varname] = self._ssusi_integrate_radiance(datadict[varname])
elif varname in ['glat','glon','SZA']:
datadict_out[varname] = self._ssusi_integrate_position(datadict[varname])
else:
datadict_out[varname] = datadict[varname]
alat,mlt = self.geo2apex(datadict_out)
datadict_out['mlat'] = alat
datadict_out['mlt'] = mlt
return datadict_out
@staticmethod
def _radiance_zenith_correction(sza,radiance):
"""
A quick correction for the solar influence noise on the radiance data using a simple regression following the methods of
Parameters
----------
SZA - list, num_obsx1
Solar zenith angle of the radiance observations(degrees)
radiance - list, num_obsx1
Radiance observations
"""
#mask out non finite values
finite = np.logical_and(np.isfinite(sza.flatten()),
np.isfinite(radiance.flatten()))
#mask out values above 1 kR
mask_high_radiance = radiance.flatten() < 1
finite = np.logical_and(finite,mask_high_radiance)
# clf = linear_model.LinearRegression(fit_intercept=True)
clf = linear_model.Ridge(fit_intercept=True)
X = sza.reshape((-1,1))
X = np.cos(np.deg2rad(sza).reshape((-1,1)))
y = radiance.reshape((-1,1))
clf.fit(X[finite],y[finite])
return clf.predict(X).reshape(radiance.shape)
def __str__(self):
return '{} {}:\n hemisphere {},\n date {}-{}-{}'.format(self.name,
self.observation_type,
self.hemisphere,
self.year,
self.month,
self.day)
def __setitem__(self,item,value):
if not hasattr(self,'_observation_data'):
self._observation_data = OrderedDict()
self._observation_data[item]=value
def __getitem__(self,item):
return self._observation_data[item]
def __contains__(self,item):
return item in self._observation_data
def __iter__(self):
for item in self._observation_data:
yield item
def items(self):
for key,value in self._observation_data.items():
yield key,value
def get_data_window_mask(self,startdt,enddt,hemisphere,allowed_observers):
"""Return a 1D mask into the data arrays for all points in the
specified time range, hemisphere and with radar IDs (RIDs) in
list of RIDs allowed_observers"""
mask = np.ones(self['jds'].shape,dtype=bool)
mask = np.logical_and(mask, self._get_finite())
mask = np.logical_and(mask,self._get_time_mask(startdt,enddt))
mask = np.logical_and(mask,self._get_hemisphere_mask(hemisphere))
mask = np.logical_and(mask,self._get_observers_mask(allowed_observers))
return mask
def _get_finite(self):
return np.isfinite(self['Y'])
def _get_time_mask(self,startdt,enddt):
"""Return mask in data arrays for all
data in interval [startdt,enddt)"""
startjd = datetime2jd(startdt)
endjd = datetime2jd(enddt)
inrange = np.logical_and(self['jds'].flatten()>=startjd,
self['jds'].flatten()<endjd)
return inrange
def _get_hemisphere_mask(self,hemisphere):
if hemisphere not in ['N','S']:
return ValueError(('{}'.format(hemisphere)
+' is not a valid hemisphere (use N or S)'))
if hemisphere == 'N':
inhemi = self['lats'] > self.minlat
elif hemisphere == 'S':
inhemi = self['lats'] < -self.minlat
return inhemi
def _check_allowed_observers(self,allowed_observers):
if not isinstance(allowed_observers,list):
raise RuntimeError('allowed_observers must be a list of '
+'DMSP satellite numbers')
for observer_id in allowed_observers:
if observer_id not in self.observers:
raise ValueError('DMSP satellite number {} not'.format(observer_id)
+'in \n({})'.format(self.observers))
def _get_observers_mask(self,allowed_observers):
if allowed_observers != 'all':
self._check_allowed_observers(allowed_observers)
observers_mask = np.zeros(self['jds'].shape,dtype=bool)
for observer_id in allowed_observers:
observers_mask = np.logical_or(observers_mask,
self['observer_ids']==observer_id)
else:
observers_mask = np.ones(self['jds'].shape,dtype=bool)
return observers_mask
| 40.008562
| 156
| 0.589129
|
7951d5ca8ce161d8c8c9bbe1ea349c18cc23c10c
| 28,856
|
py
|
Python
|
google/cloud/aiplatform_v1beta1/types/__init__.py
|
TheMichaelHu/python-aiplatform
|
e03f373a7e44c354eda88875a41c771f6d7e3ce1
|
[
"Apache-2.0"
] | null | null | null |
google/cloud/aiplatform_v1beta1/types/__init__.py
|
TheMichaelHu/python-aiplatform
|
e03f373a7e44c354eda88875a41c771f6d7e3ce1
|
[
"Apache-2.0"
] | null | null | null |
google/cloud/aiplatform_v1beta1/types/__init__.py
|
TheMichaelHu/python-aiplatform
|
e03f373a7e44c354eda88875a41c771f6d7e3ce1
|
[
"Apache-2.0"
] | null | null | null |
# -*- coding: utf-8 -*-
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from .annotation import (
Annotation,
)
from .annotation_spec import (
AnnotationSpec,
)
from .artifact import (
Artifact,
)
from .batch_prediction_job import (
BatchPredictionJob,
)
from .completion_stats import (
CompletionStats,
)
from .context import (
Context,
)
from .custom_job import (
ContainerSpec,
CustomJob,
CustomJobSpec,
PythonPackageSpec,
Scheduling,
WorkerPoolSpec,
)
from .data_item import (
DataItem,
)
from .data_labeling_job import (
ActiveLearningConfig,
DataLabelingJob,
SampleConfig,
TrainingConfig,
)
from .dataset import (
Dataset,
ExportDataConfig,
ImportDataConfig,
)
from .dataset_service import (
CreateDatasetOperationMetadata,
CreateDatasetRequest,
DeleteDatasetRequest,
ExportDataOperationMetadata,
ExportDataRequest,
ExportDataResponse,
GetAnnotationSpecRequest,
GetDatasetRequest,
ImportDataOperationMetadata,
ImportDataRequest,
ImportDataResponse,
ListAnnotationsRequest,
ListAnnotationsResponse,
ListDataItemsRequest,
ListDataItemsResponse,
ListDatasetsRequest,
ListDatasetsResponse,
UpdateDatasetRequest,
)
from .deployed_index_ref import (
DeployedIndexRef,
)
from .deployed_model_ref import (
DeployedModelRef,
)
from .encryption_spec import (
EncryptionSpec,
)
from .endpoint import (
DeployedModel,
Endpoint,
PredictRequestResponseLoggingConfig,
PrivateEndpoints,
)
from .endpoint_service import (
CreateEndpointOperationMetadata,
CreateEndpointRequest,
DeleteEndpointRequest,
DeployModelOperationMetadata,
DeployModelRequest,
DeployModelResponse,
GetEndpointRequest,
ListEndpointsRequest,
ListEndpointsResponse,
UndeployModelOperationMetadata,
UndeployModelRequest,
UndeployModelResponse,
UpdateEndpointRequest,
)
from .entity_type import (
EntityType,
)
from .env_var import (
EnvVar,
)
from .event import (
Event,
)
from .execution import (
Execution,
)
from .explanation import (
Attribution,
BlurBaselineConfig,
Examples,
Explanation,
ExplanationMetadataOverride,
ExplanationParameters,
ExplanationSpec,
ExplanationSpecOverride,
FeatureNoiseSigma,
IntegratedGradientsAttribution,
ModelExplanation,
SampledShapleyAttribution,
SmoothGradConfig,
XraiAttribution,
)
from .explanation_metadata import (
ExplanationMetadata,
)
from .feature import (
Feature,
)
from .feature_monitoring_stats import (
FeatureStatsAnomaly,
)
from .feature_selector import (
FeatureSelector,
IdMatcher,
)
from .featurestore import (
Featurestore,
)
from .featurestore_monitoring import (
FeaturestoreMonitoringConfig,
)
from .featurestore_online_service import (
FeatureValue,
FeatureValueList,
ReadFeatureValuesRequest,
ReadFeatureValuesResponse,
StreamingReadFeatureValuesRequest,
)
from .featurestore_service import (
BatchCreateFeaturesOperationMetadata,
BatchCreateFeaturesRequest,
BatchCreateFeaturesResponse,
BatchReadFeatureValuesOperationMetadata,
BatchReadFeatureValuesRequest,
BatchReadFeatureValuesResponse,
CreateEntityTypeOperationMetadata,
CreateEntityTypeRequest,
CreateFeatureOperationMetadata,
CreateFeatureRequest,
CreateFeaturestoreOperationMetadata,
CreateFeaturestoreRequest,
DeleteEntityTypeRequest,
DeleteFeatureRequest,
DeleteFeaturestoreRequest,
DestinationFeatureSetting,
ExportFeatureValuesOperationMetadata,
ExportFeatureValuesRequest,
ExportFeatureValuesResponse,
FeatureValueDestination,
GetEntityTypeRequest,
GetFeatureRequest,
GetFeaturestoreRequest,
ImportFeatureValuesOperationMetadata,
ImportFeatureValuesRequest,
ImportFeatureValuesResponse,
ListEntityTypesRequest,
ListEntityTypesResponse,
ListFeaturesRequest,
ListFeaturesResponse,
ListFeaturestoresRequest,
ListFeaturestoresResponse,
SearchFeaturesRequest,
SearchFeaturesResponse,
UpdateEntityTypeRequest,
UpdateFeatureRequest,
UpdateFeaturestoreOperationMetadata,
UpdateFeaturestoreRequest,
)
from .hyperparameter_tuning_job import (
HyperparameterTuningJob,
)
from .index import (
Index,
)
from .index_endpoint import (
DeployedIndex,
DeployedIndexAuthConfig,
IndexEndpoint,
IndexPrivateEndpoints,
)
from .index_endpoint_service import (
CreateIndexEndpointOperationMetadata,
CreateIndexEndpointRequest,
DeleteIndexEndpointRequest,
DeployIndexOperationMetadata,
DeployIndexRequest,
DeployIndexResponse,
GetIndexEndpointRequest,
ListIndexEndpointsRequest,
ListIndexEndpointsResponse,
MutateDeployedIndexOperationMetadata,
MutateDeployedIndexRequest,
MutateDeployedIndexResponse,
UndeployIndexOperationMetadata,
UndeployIndexRequest,
UndeployIndexResponse,
UpdateIndexEndpointRequest,
)
from .index_service import (
CreateIndexOperationMetadata,
CreateIndexRequest,
DeleteIndexRequest,
GetIndexRequest,
ListIndexesRequest,
ListIndexesResponse,
NearestNeighborSearchOperationMetadata,
UpdateIndexOperationMetadata,
UpdateIndexRequest,
)
from .io import (
AvroSource,
BigQueryDestination,
BigQuerySource,
ContainerRegistryDestination,
CsvDestination,
CsvSource,
GcsDestination,
GcsSource,
TFRecordDestination,
)
from .job_service import (
CancelBatchPredictionJobRequest,
CancelCustomJobRequest,
CancelDataLabelingJobRequest,
CancelHyperparameterTuningJobRequest,
CreateBatchPredictionJobRequest,
CreateCustomJobRequest,
CreateDataLabelingJobRequest,
CreateHyperparameterTuningJobRequest,
CreateModelDeploymentMonitoringJobRequest,
DeleteBatchPredictionJobRequest,
DeleteCustomJobRequest,
DeleteDataLabelingJobRequest,
DeleteHyperparameterTuningJobRequest,
DeleteModelDeploymentMonitoringJobRequest,
GetBatchPredictionJobRequest,
GetCustomJobRequest,
GetDataLabelingJobRequest,
GetHyperparameterTuningJobRequest,
GetModelDeploymentMonitoringJobRequest,
ListBatchPredictionJobsRequest,
ListBatchPredictionJobsResponse,
ListCustomJobsRequest,
ListCustomJobsResponse,
ListDataLabelingJobsRequest,
ListDataLabelingJobsResponse,
ListHyperparameterTuningJobsRequest,
ListHyperparameterTuningJobsResponse,
ListModelDeploymentMonitoringJobsRequest,
ListModelDeploymentMonitoringJobsResponse,
PauseModelDeploymentMonitoringJobRequest,
ResumeModelDeploymentMonitoringJobRequest,
SearchModelDeploymentMonitoringStatsAnomaliesRequest,
SearchModelDeploymentMonitoringStatsAnomaliesResponse,
UpdateModelDeploymentMonitoringJobOperationMetadata,
UpdateModelDeploymentMonitoringJobRequest,
)
from .lineage_subgraph import (
LineageSubgraph,
)
from .machine_resources import (
AutomaticResources,
AutoscalingMetricSpec,
BatchDedicatedResources,
DedicatedResources,
DiskSpec,
MachineSpec,
NfsMount,
ResourcesConsumed,
)
from .manual_batch_tuning_parameters import (
ManualBatchTuningParameters,
)
from .metadata_schema import (
MetadataSchema,
)
from .metadata_service import (
AddContextArtifactsAndExecutionsRequest,
AddContextArtifactsAndExecutionsResponse,
AddContextChildrenRequest,
AddContextChildrenResponse,
AddExecutionEventsRequest,
AddExecutionEventsResponse,
CreateArtifactRequest,
CreateContextRequest,
CreateExecutionRequest,
CreateMetadataSchemaRequest,
CreateMetadataStoreOperationMetadata,
CreateMetadataStoreRequest,
DeleteArtifactRequest,
DeleteContextRequest,
DeleteExecutionRequest,
DeleteMetadataStoreOperationMetadata,
DeleteMetadataStoreRequest,
GetArtifactRequest,
GetContextRequest,
GetExecutionRequest,
GetMetadataSchemaRequest,
GetMetadataStoreRequest,
ListArtifactsRequest,
ListArtifactsResponse,
ListContextsRequest,
ListContextsResponse,
ListExecutionsRequest,
ListExecutionsResponse,
ListMetadataSchemasRequest,
ListMetadataSchemasResponse,
ListMetadataStoresRequest,
ListMetadataStoresResponse,
PurgeArtifactsMetadata,
PurgeArtifactsRequest,
PurgeArtifactsResponse,
PurgeContextsMetadata,
PurgeContextsRequest,
PurgeContextsResponse,
PurgeExecutionsMetadata,
PurgeExecutionsRequest,
PurgeExecutionsResponse,
QueryArtifactLineageSubgraphRequest,
QueryContextLineageSubgraphRequest,
QueryExecutionInputsAndOutputsRequest,
UpdateArtifactRequest,
UpdateContextRequest,
UpdateExecutionRequest,
)
from .metadata_store import (
MetadataStore,
)
from .migratable_resource import (
MigratableResource,
)
from .migration_service import (
BatchMigrateResourcesOperationMetadata,
BatchMigrateResourcesRequest,
BatchMigrateResourcesResponse,
MigrateResourceRequest,
MigrateResourceResponse,
SearchMigratableResourcesRequest,
SearchMigratableResourcesResponse,
)
from .model import (
Model,
ModelContainerSpec,
Port,
PredictSchemata,
)
from .model_deployment_monitoring_job import (
ModelDeploymentMonitoringBigQueryTable,
ModelDeploymentMonitoringJob,
ModelDeploymentMonitoringObjectiveConfig,
ModelDeploymentMonitoringScheduleConfig,
ModelMonitoringStatsAnomalies,
ModelDeploymentMonitoringObjectiveType,
)
from .model_evaluation import (
ModelEvaluation,
)
from .model_evaluation_slice import (
ModelEvaluationSlice,
)
from .model_monitoring import (
ModelMonitoringAlertConfig,
ModelMonitoringObjectiveConfig,
SamplingStrategy,
ThresholdConfig,
)
from .model_service import (
DeleteModelRequest,
DeleteModelVersionRequest,
ExportModelOperationMetadata,
ExportModelRequest,
ExportModelResponse,
GetModelEvaluationRequest,
GetModelEvaluationSliceRequest,
GetModelRequest,
ImportModelEvaluationRequest,
ListModelEvaluationSlicesRequest,
ListModelEvaluationSlicesResponse,
ListModelEvaluationsRequest,
ListModelEvaluationsResponse,
ListModelsRequest,
ListModelsResponse,
ListModelVersionsRequest,
ListModelVersionsResponse,
MergeVersionAliasesRequest,
UpdateModelRequest,
UploadModelOperationMetadata,
UploadModelRequest,
UploadModelResponse,
)
from .operation import (
DeleteOperationMetadata,
GenericOperationMetadata,
)
from .pipeline_job import (
PipelineJob,
PipelineJobDetail,
PipelineTaskDetail,
PipelineTaskExecutorDetail,
)
from .pipeline_service import (
CancelPipelineJobRequest,
CancelTrainingPipelineRequest,
CreatePipelineJobRequest,
CreateTrainingPipelineRequest,
DeletePipelineJobRequest,
DeleteTrainingPipelineRequest,
GetPipelineJobRequest,
GetTrainingPipelineRequest,
ListPipelineJobsRequest,
ListPipelineJobsResponse,
ListTrainingPipelinesRequest,
ListTrainingPipelinesResponse,
)
from .prediction_service import (
ExplainRequest,
ExplainResponse,
PredictRequest,
PredictResponse,
RawPredictRequest,
)
from .specialist_pool import (
SpecialistPool,
)
from .specialist_pool_service import (
CreateSpecialistPoolOperationMetadata,
CreateSpecialistPoolRequest,
DeleteSpecialistPoolRequest,
GetSpecialistPoolRequest,
ListSpecialistPoolsRequest,
ListSpecialistPoolsResponse,
UpdateSpecialistPoolOperationMetadata,
UpdateSpecialistPoolRequest,
)
from .study import (
Measurement,
Study,
StudySpec,
Trial,
)
from .tensorboard import (
Tensorboard,
)
from .tensorboard_data import (
Scalar,
TensorboardBlob,
TensorboardBlobSequence,
TensorboardTensor,
TimeSeriesData,
TimeSeriesDataPoint,
)
from .tensorboard_experiment import (
TensorboardExperiment,
)
from .tensorboard_run import (
TensorboardRun,
)
from .tensorboard_service import (
BatchCreateTensorboardRunsRequest,
BatchCreateTensorboardRunsResponse,
BatchCreateTensorboardTimeSeriesRequest,
BatchCreateTensorboardTimeSeriesResponse,
BatchReadTensorboardTimeSeriesDataRequest,
BatchReadTensorboardTimeSeriesDataResponse,
CreateTensorboardExperimentRequest,
CreateTensorboardOperationMetadata,
CreateTensorboardRequest,
CreateTensorboardRunRequest,
CreateTensorboardTimeSeriesRequest,
DeleteTensorboardExperimentRequest,
DeleteTensorboardRequest,
DeleteTensorboardRunRequest,
DeleteTensorboardTimeSeriesRequest,
ExportTensorboardTimeSeriesDataRequest,
ExportTensorboardTimeSeriesDataResponse,
GetTensorboardExperimentRequest,
GetTensorboardRequest,
GetTensorboardRunRequest,
GetTensorboardTimeSeriesRequest,
ListTensorboardExperimentsRequest,
ListTensorboardExperimentsResponse,
ListTensorboardRunsRequest,
ListTensorboardRunsResponse,
ListTensorboardsRequest,
ListTensorboardsResponse,
ListTensorboardTimeSeriesRequest,
ListTensorboardTimeSeriesResponse,
ReadTensorboardBlobDataRequest,
ReadTensorboardBlobDataResponse,
ReadTensorboardTimeSeriesDataRequest,
ReadTensorboardTimeSeriesDataResponse,
UpdateTensorboardExperimentRequest,
UpdateTensorboardOperationMetadata,
UpdateTensorboardRequest,
UpdateTensorboardRunRequest,
UpdateTensorboardTimeSeriesRequest,
WriteTensorboardExperimentDataRequest,
WriteTensorboardExperimentDataResponse,
WriteTensorboardRunDataRequest,
WriteTensorboardRunDataResponse,
)
from .tensorboard_time_series import (
TensorboardTimeSeries,
)
from .training_pipeline import (
FilterSplit,
FractionSplit,
InputDataConfig,
PredefinedSplit,
StratifiedSplit,
TimestampSplit,
TrainingPipeline,
)
from .types import (
BoolArray,
DoubleArray,
Int64Array,
StringArray,
)
from .unmanaged_container_model import (
UnmanagedContainerModel,
)
from .user_action_reference import (
UserActionReference,
)
from .value import (
Value,
)
from .vizier_service import (
AddTrialMeasurementRequest,
CheckTrialEarlyStoppingStateMetatdata,
CheckTrialEarlyStoppingStateRequest,
CheckTrialEarlyStoppingStateResponse,
CompleteTrialRequest,
CreateStudyRequest,
CreateTrialRequest,
DeleteStudyRequest,
DeleteTrialRequest,
GetStudyRequest,
GetTrialRequest,
ListOptimalTrialsRequest,
ListOptimalTrialsResponse,
ListStudiesRequest,
ListStudiesResponse,
ListTrialsRequest,
ListTrialsResponse,
LookupStudyRequest,
StopTrialRequest,
SuggestTrialsMetadata,
SuggestTrialsRequest,
SuggestTrialsResponse,
)
__all__ = (
"AcceleratorType",
"Annotation",
"AnnotationSpec",
"Artifact",
"BatchPredictionJob",
"CompletionStats",
"Context",
"ContainerSpec",
"CustomJob",
"CustomJobSpec",
"PythonPackageSpec",
"Scheduling",
"WorkerPoolSpec",
"DataItem",
"ActiveLearningConfig",
"DataLabelingJob",
"SampleConfig",
"TrainingConfig",
"Dataset",
"ExportDataConfig",
"ImportDataConfig",
"CreateDatasetOperationMetadata",
"CreateDatasetRequest",
"DeleteDatasetRequest",
"ExportDataOperationMetadata",
"ExportDataRequest",
"ExportDataResponse",
"GetAnnotationSpecRequest",
"GetDatasetRequest",
"ImportDataOperationMetadata",
"ImportDataRequest",
"ImportDataResponse",
"ListAnnotationsRequest",
"ListAnnotationsResponse",
"ListDataItemsRequest",
"ListDataItemsResponse",
"ListDatasetsRequest",
"ListDatasetsResponse",
"UpdateDatasetRequest",
"DeployedIndexRef",
"DeployedModelRef",
"EncryptionSpec",
"DeployedModel",
"Endpoint",
"PredictRequestResponseLoggingConfig",
"PrivateEndpoints",
"CreateEndpointOperationMetadata",
"CreateEndpointRequest",
"DeleteEndpointRequest",
"DeployModelOperationMetadata",
"DeployModelRequest",
"DeployModelResponse",
"GetEndpointRequest",
"ListEndpointsRequest",
"ListEndpointsResponse",
"UndeployModelOperationMetadata",
"UndeployModelRequest",
"UndeployModelResponse",
"UpdateEndpointRequest",
"EntityType",
"EnvVar",
"Event",
"Execution",
"Attribution",
"BlurBaselineConfig",
"Examples",
"Explanation",
"ExplanationMetadataOverride",
"ExplanationParameters",
"ExplanationSpec",
"ExplanationSpecOverride",
"FeatureNoiseSigma",
"IntegratedGradientsAttribution",
"ModelExplanation",
"SampledShapleyAttribution",
"SmoothGradConfig",
"XraiAttribution",
"ExplanationMetadata",
"Feature",
"FeatureStatsAnomaly",
"FeatureSelector",
"IdMatcher",
"Featurestore",
"FeaturestoreMonitoringConfig",
"FeatureValue",
"FeatureValueList",
"ReadFeatureValuesRequest",
"ReadFeatureValuesResponse",
"StreamingReadFeatureValuesRequest",
"BatchCreateFeaturesOperationMetadata",
"BatchCreateFeaturesRequest",
"BatchCreateFeaturesResponse",
"BatchReadFeatureValuesOperationMetadata",
"BatchReadFeatureValuesRequest",
"BatchReadFeatureValuesResponse",
"CreateEntityTypeOperationMetadata",
"CreateEntityTypeRequest",
"CreateFeatureOperationMetadata",
"CreateFeatureRequest",
"CreateFeaturestoreOperationMetadata",
"CreateFeaturestoreRequest",
"DeleteEntityTypeRequest",
"DeleteFeatureRequest",
"DeleteFeaturestoreRequest",
"DestinationFeatureSetting",
"ExportFeatureValuesOperationMetadata",
"ExportFeatureValuesRequest",
"ExportFeatureValuesResponse",
"FeatureValueDestination",
"GetEntityTypeRequest",
"GetFeatureRequest",
"GetFeaturestoreRequest",
"ImportFeatureValuesOperationMetadata",
"ImportFeatureValuesRequest",
"ImportFeatureValuesResponse",
"ListEntityTypesRequest",
"ListEntityTypesResponse",
"ListFeaturesRequest",
"ListFeaturesResponse",
"ListFeaturestoresRequest",
"ListFeaturestoresResponse",
"SearchFeaturesRequest",
"SearchFeaturesResponse",
"UpdateEntityTypeRequest",
"UpdateFeatureRequest",
"UpdateFeaturestoreOperationMetadata",
"UpdateFeaturestoreRequest",
"HyperparameterTuningJob",
"Index",
"DeployedIndex",
"DeployedIndexAuthConfig",
"IndexEndpoint",
"IndexPrivateEndpoints",
"CreateIndexEndpointOperationMetadata",
"CreateIndexEndpointRequest",
"DeleteIndexEndpointRequest",
"DeployIndexOperationMetadata",
"DeployIndexRequest",
"DeployIndexResponse",
"GetIndexEndpointRequest",
"ListIndexEndpointsRequest",
"ListIndexEndpointsResponse",
"MutateDeployedIndexOperationMetadata",
"MutateDeployedIndexRequest",
"MutateDeployedIndexResponse",
"UndeployIndexOperationMetadata",
"UndeployIndexRequest",
"UndeployIndexResponse",
"UpdateIndexEndpointRequest",
"CreateIndexOperationMetadata",
"CreateIndexRequest",
"DeleteIndexRequest",
"GetIndexRequest",
"ListIndexesRequest",
"ListIndexesResponse",
"NearestNeighborSearchOperationMetadata",
"UpdateIndexOperationMetadata",
"UpdateIndexRequest",
"AvroSource",
"BigQueryDestination",
"BigQuerySource",
"ContainerRegistryDestination",
"CsvDestination",
"CsvSource",
"GcsDestination",
"GcsSource",
"TFRecordDestination",
"CancelBatchPredictionJobRequest",
"CancelCustomJobRequest",
"CancelDataLabelingJobRequest",
"CancelHyperparameterTuningJobRequest",
"CreateBatchPredictionJobRequest",
"CreateCustomJobRequest",
"CreateDataLabelingJobRequest",
"CreateHyperparameterTuningJobRequest",
"CreateModelDeploymentMonitoringJobRequest",
"DeleteBatchPredictionJobRequest",
"DeleteCustomJobRequest",
"DeleteDataLabelingJobRequest",
"DeleteHyperparameterTuningJobRequest",
"DeleteModelDeploymentMonitoringJobRequest",
"GetBatchPredictionJobRequest",
"GetCustomJobRequest",
"GetDataLabelingJobRequest",
"GetHyperparameterTuningJobRequest",
"GetModelDeploymentMonitoringJobRequest",
"ListBatchPredictionJobsRequest",
"ListBatchPredictionJobsResponse",
"ListCustomJobsRequest",
"ListCustomJobsResponse",
"ListDataLabelingJobsRequest",
"ListDataLabelingJobsResponse",
"ListHyperparameterTuningJobsRequest",
"ListHyperparameterTuningJobsResponse",
"ListModelDeploymentMonitoringJobsRequest",
"ListModelDeploymentMonitoringJobsResponse",
"PauseModelDeploymentMonitoringJobRequest",
"ResumeModelDeploymentMonitoringJobRequest",
"SearchModelDeploymentMonitoringStatsAnomaliesRequest",
"SearchModelDeploymentMonitoringStatsAnomaliesResponse",
"UpdateModelDeploymentMonitoringJobOperationMetadata",
"UpdateModelDeploymentMonitoringJobRequest",
"JobState",
"LineageSubgraph",
"AutomaticResources",
"AutoscalingMetricSpec",
"BatchDedicatedResources",
"DedicatedResources",
"DiskSpec",
"MachineSpec",
"NfsMount",
"ResourcesConsumed",
"ManualBatchTuningParameters",
"MetadataSchema",
"AddContextArtifactsAndExecutionsRequest",
"AddContextArtifactsAndExecutionsResponse",
"AddContextChildrenRequest",
"AddContextChildrenResponse",
"AddExecutionEventsRequest",
"AddExecutionEventsResponse",
"CreateArtifactRequest",
"CreateContextRequest",
"CreateExecutionRequest",
"CreateMetadataSchemaRequest",
"CreateMetadataStoreOperationMetadata",
"CreateMetadataStoreRequest",
"DeleteArtifactRequest",
"DeleteContextRequest",
"DeleteExecutionRequest",
"DeleteMetadataStoreOperationMetadata",
"DeleteMetadataStoreRequest",
"GetArtifactRequest",
"GetContextRequest",
"GetExecutionRequest",
"GetMetadataSchemaRequest",
"GetMetadataStoreRequest",
"ListArtifactsRequest",
"ListArtifactsResponse",
"ListContextsRequest",
"ListContextsResponse",
"ListExecutionsRequest",
"ListExecutionsResponse",
"ListMetadataSchemasRequest",
"ListMetadataSchemasResponse",
"ListMetadataStoresRequest",
"ListMetadataStoresResponse",
"PurgeArtifactsMetadata",
"PurgeArtifactsRequest",
"PurgeArtifactsResponse",
"PurgeContextsMetadata",
"PurgeContextsRequest",
"PurgeContextsResponse",
"PurgeExecutionsMetadata",
"PurgeExecutionsRequest",
"PurgeExecutionsResponse",
"QueryArtifactLineageSubgraphRequest",
"QueryContextLineageSubgraphRequest",
"QueryExecutionInputsAndOutputsRequest",
"UpdateArtifactRequest",
"UpdateContextRequest",
"UpdateExecutionRequest",
"MetadataStore",
"MigratableResource",
"BatchMigrateResourcesOperationMetadata",
"BatchMigrateResourcesRequest",
"BatchMigrateResourcesResponse",
"MigrateResourceRequest",
"MigrateResourceResponse",
"SearchMigratableResourcesRequest",
"SearchMigratableResourcesResponse",
"Model",
"ModelContainerSpec",
"Port",
"PredictSchemata",
"ModelDeploymentMonitoringBigQueryTable",
"ModelDeploymentMonitoringJob",
"ModelDeploymentMonitoringObjectiveConfig",
"ModelDeploymentMonitoringScheduleConfig",
"ModelMonitoringStatsAnomalies",
"ModelDeploymentMonitoringObjectiveType",
"ModelEvaluation",
"ModelEvaluationSlice",
"ModelMonitoringAlertConfig",
"ModelMonitoringObjectiveConfig",
"SamplingStrategy",
"ThresholdConfig",
"DeleteModelRequest",
"DeleteModelVersionRequest",
"ExportModelOperationMetadata",
"ExportModelRequest",
"ExportModelResponse",
"GetModelEvaluationRequest",
"GetModelEvaluationSliceRequest",
"GetModelRequest",
"ImportModelEvaluationRequest",
"ListModelEvaluationSlicesRequest",
"ListModelEvaluationSlicesResponse",
"ListModelEvaluationsRequest",
"ListModelEvaluationsResponse",
"ListModelsRequest",
"ListModelsResponse",
"ListModelVersionsRequest",
"ListModelVersionsResponse",
"MergeVersionAliasesRequest",
"UpdateModelRequest",
"UploadModelOperationMetadata",
"UploadModelRequest",
"UploadModelResponse",
"DeleteOperationMetadata",
"GenericOperationMetadata",
"PipelineJob",
"PipelineJobDetail",
"PipelineTaskDetail",
"PipelineTaskExecutorDetail",
"CancelPipelineJobRequest",
"CancelTrainingPipelineRequest",
"CreatePipelineJobRequest",
"CreateTrainingPipelineRequest",
"DeletePipelineJobRequest",
"DeleteTrainingPipelineRequest",
"GetPipelineJobRequest",
"GetTrainingPipelineRequest",
"ListPipelineJobsRequest",
"ListPipelineJobsResponse",
"ListTrainingPipelinesRequest",
"ListTrainingPipelinesResponse",
"PipelineState",
"ExplainRequest",
"ExplainResponse",
"PredictRequest",
"PredictResponse",
"RawPredictRequest",
"SpecialistPool",
"CreateSpecialistPoolOperationMetadata",
"CreateSpecialistPoolRequest",
"DeleteSpecialistPoolRequest",
"GetSpecialistPoolRequest",
"ListSpecialistPoolsRequest",
"ListSpecialistPoolsResponse",
"UpdateSpecialistPoolOperationMetadata",
"UpdateSpecialistPoolRequest",
"Measurement",
"Study",
"StudySpec",
"Trial",
"Tensorboard",
"Scalar",
"TensorboardBlob",
"TensorboardBlobSequence",
"TensorboardTensor",
"TimeSeriesData",
"TimeSeriesDataPoint",
"TensorboardExperiment",
"TensorboardRun",
"BatchCreateTensorboardRunsRequest",
"BatchCreateTensorboardRunsResponse",
"BatchCreateTensorboardTimeSeriesRequest",
"BatchCreateTensorboardTimeSeriesResponse",
"BatchReadTensorboardTimeSeriesDataRequest",
"BatchReadTensorboardTimeSeriesDataResponse",
"CreateTensorboardExperimentRequest",
"CreateTensorboardOperationMetadata",
"CreateTensorboardRequest",
"CreateTensorboardRunRequest",
"CreateTensorboardTimeSeriesRequest",
"DeleteTensorboardExperimentRequest",
"DeleteTensorboardRequest",
"DeleteTensorboardRunRequest",
"DeleteTensorboardTimeSeriesRequest",
"ExportTensorboardTimeSeriesDataRequest",
"ExportTensorboardTimeSeriesDataResponse",
"GetTensorboardExperimentRequest",
"GetTensorboardRequest",
"GetTensorboardRunRequest",
"GetTensorboardTimeSeriesRequest",
"ListTensorboardExperimentsRequest",
"ListTensorboardExperimentsResponse",
"ListTensorboardRunsRequest",
"ListTensorboardRunsResponse",
"ListTensorboardsRequest",
"ListTensorboardsResponse",
"ListTensorboardTimeSeriesRequest",
"ListTensorboardTimeSeriesResponse",
"ReadTensorboardBlobDataRequest",
"ReadTensorboardBlobDataResponse",
"ReadTensorboardTimeSeriesDataRequest",
"ReadTensorboardTimeSeriesDataResponse",
"UpdateTensorboardExperimentRequest",
"UpdateTensorboardOperationMetadata",
"UpdateTensorboardRequest",
"UpdateTensorboardRunRequest",
"UpdateTensorboardTimeSeriesRequest",
"WriteTensorboardExperimentDataRequest",
"WriteTensorboardExperimentDataResponse",
"WriteTensorboardRunDataRequest",
"WriteTensorboardRunDataResponse",
"TensorboardTimeSeries",
"FilterSplit",
"FractionSplit",
"InputDataConfig",
"PredefinedSplit",
"StratifiedSplit",
"TimestampSplit",
"TrainingPipeline",
"BoolArray",
"DoubleArray",
"Int64Array",
"StringArray",
"UnmanagedContainerModel",
"UserActionReference",
"Value",
"AddTrialMeasurementRequest",
"CheckTrialEarlyStoppingStateMetatdata",
"CheckTrialEarlyStoppingStateRequest",
"CheckTrialEarlyStoppingStateResponse",
"CompleteTrialRequest",
"CreateStudyRequest",
"CreateTrialRequest",
"DeleteStudyRequest",
"DeleteTrialRequest",
"GetStudyRequest",
"GetTrialRequest",
"ListOptimalTrialsRequest",
"ListOptimalTrialsResponse",
"ListStudiesRequest",
"ListStudiesResponse",
"ListTrialsRequest",
"ListTrialsResponse",
"LookupStudyRequest",
"StopTrialRequest",
"SuggestTrialsMetadata",
"SuggestTrialsRequest",
"SuggestTrialsResponse",
)
| 28.290196
| 74
| 0.765872
|
7951d6e00c7aa8b96faa2135b77898acf1fb6381
| 25,259
|
py
|
Python
|
hug/api.py
|
pnijhara/hug
|
95e2f66baa57494b8751b43ad3da6c2d0e2d535d
|
[
"MIT"
] | 1
|
2021-06-17T12:02:25.000Z
|
2021-06-17T12:02:25.000Z
|
hug/api.py
|
Warlockk/hug
|
95e2f66baa57494b8751b43ad3da6c2d0e2d535d
|
[
"MIT"
] | 5
|
2021-06-29T18:34:13.000Z
|
2021-06-29T18:34:44.000Z
|
hug/api.py
|
Warlockk/hug
|
95e2f66baa57494b8751b43ad3da6c2d0e2d535d
|
[
"MIT"
] | 1
|
2021-06-17T12:02:26.000Z
|
2021-06-17T12:02:26.000Z
|
"""hug/api.py
Defines the dynamically generated Hug API object that is responsible for storing all routes and state within a module
Copyright (C) 2016 Timothy Edmund Crosley
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
"""
from __future__ import absolute_import
import asyncio
import sys
from collections import OrderedDict, namedtuple
from distutils.util import strtobool
from functools import partial
from itertools import chain
from types import ModuleType
from wsgiref.simple_server import make_server
import falcon
from falcon import HTTP_METHODS
import hug.defaults
import hug.output_format
from hug import introspect
from hug._version import current
INTRO = """
/#######################################################################\\
`.----``..-------..``.----.
:/:::::--:---------:--::::://.
.+::::----##/-/oo+:-##----:::://
`//::-------/oosoo-------::://. ## ## ## ## #####
.-:------./++o/o-.------::-` ``` ## ## ## ## ##
`----.-./+o+:..----. `.:///. ######## ## ## ##
``` `----.-::::::------ `.-:::://. ## ## ## ## ## ####
://::--.``` -:``...-----...` `:--::::::-.` ## ## ## ## ## ##
:/:::::::::-:- ````` .:::::-.` ## ## #### ######
``.--:::::::. .:::.`
``..::. .:: EMBRACE THE APIs OF THE FUTURE
::- .:-
-::` ::- VERSION {0}
`::- -::`
-::-` -::-
\########################################################################/
Copyright (C) 2016 Timothy Edmund Crosley
Under the MIT License
""".format(
current
)
class InterfaceAPI(object):
"""Defines the per-interface API which defines all shared information for a specific interface, and how it should
be exposed
"""
__slots__ = ("api",)
def __init__(self, api):
self.api = api
class HTTPInterfaceAPI(InterfaceAPI):
"""Defines the HTTP interface specific API"""
__slots__ = (
"routes",
"versions",
"base_url",
"falcon",
"_output_format",
"_input_format",
"versioned",
"_middleware",
"_not_found_handlers",
"sinks",
"_not_found",
"_exception_handlers",
)
def __init__(self, api, base_url=""):
super().__init__(api)
self.versions = set()
self.routes = OrderedDict()
self.sinks = OrderedDict()
self.versioned = OrderedDict()
self.base_url = base_url
@property
def output_format(self):
return getattr(self, "_output_format", hug.defaults.output_format)
@output_format.setter
def output_format(self, formatter):
self._output_format = formatter
@property
def not_found(self):
"""Returns the active not found handler"""
return getattr(self, "_not_found", self.base_404)
def urls(self):
"""Returns a generator of all URLs attached to this API"""
for base_url, mapping in self.routes.items():
for url, _ in mapping.items():
yield base_url + url
def handlers(self):
"""Returns all registered handlers attached to this API"""
used = []
for _base_url, mapping in self.routes.items():
for _url, methods in mapping.items():
for _method, versions in methods.items():
for _version, handler in versions.items():
if not handler in used:
used.append(handler)
yield handler
def input_format(self, content_type):
"""Returns the set input_format handler for the given content_type"""
return getattr(self, "_input_format", {}).get(
content_type, hug.defaults.input_format.get(content_type, None)
)
def set_input_format(self, content_type, handler):
"""Sets an input format handler for this Hug API, given the specified content_type"""
if getattr(self, "_input_format", None) is None:
self._input_format = {}
self._input_format[content_type] = handler
@property
def middleware(self):
return getattr(self, "_middleware", None)
def add_middleware(self, middleware):
"""Adds a middleware object used to process all incoming requests against the API"""
if self.middleware is None:
self._middleware = []
self.middleware.append(middleware)
def add_sink(self, sink, url, base_url=""):
base_url = base_url or self.base_url
self.sinks.setdefault(base_url, OrderedDict())
self.sinks[base_url][url] = sink
def exception_handlers(self, version=None):
if not hasattr(self, "_exception_handlers"):
return None
return self._exception_handlers.get(version, self._exception_handlers.get(None, None))
def add_exception_handler(self, exception_type, error_handler, versions=(None,)):
"""Adds a error handler to the hug api"""
versions = (versions,) if not isinstance(versions, (tuple, list)) else versions
if not hasattr(self, "_exception_handlers"):
self._exception_handlers = {}
for version in versions:
placement = self._exception_handlers.setdefault(version, OrderedDict())
placement[exception_type] = (error_handler,) + placement.get(exception_type, tuple())
def extend(self, http_api, route="", base_url="", **kwargs):
"""Adds handlers from a different Hug API to this one - to create a single API"""
self.versions.update(http_api.versions)
base_url = base_url or self.base_url
for _router_base_url, routes in http_api.routes.items():
self.routes.setdefault(base_url, OrderedDict())
for item_route, handler in routes.items():
for _method, versions in handler.items():
for _version, function in versions.items():
function.interface.api = self.api
self.routes[base_url].setdefault(route + item_route, {}).update(handler)
for _sink_base_url, sinks in http_api.sinks.items():
for url, sink in sinks.items():
self.add_sink(sink, route + url, base_url=base_url)
for middleware in http_api.middleware or ():
self.add_middleware(middleware)
for version, handler in getattr(http_api, "_exception_handlers", {}).items():
for exception_type, exception_handlers in handler.items():
target_exception_handlers = self.exception_handlers(version) or {}
for exception_handler in exception_handlers:
if exception_type not in target_exception_handlers:
self.add_exception_handler(exception_type, exception_handler, version)
for input_format, input_format_handler in getattr(http_api, "_input_format", {}).items():
if not input_format in getattr(self, "_input_format", {}):
self.set_input_format(input_format, input_format_handler)
for version, handler in http_api.not_found_handlers.items():
if version not in self.not_found_handlers:
self.set_not_found_handler(handler, version)
@property
def not_found_handlers(self):
return getattr(self, "_not_found_handlers", {})
def set_not_found_handler(self, handler, version=None):
"""Sets the not_found handler for the specified version of the api"""
if not self.not_found_handlers:
self._not_found_handlers = {}
self.not_found_handlers[version] = handler
def documentation(self, base_url=None, api_version=None, prefix=""):
"""Generates and returns documentation for this API endpoint"""
documentation = OrderedDict()
base_url = self.base_url if base_url is None else base_url
overview = self.api.doc
if overview:
documentation["overview"] = overview
version_dict = OrderedDict()
versions = self.versions
versions_list = list(versions)
if None in versions_list:
versions_list.remove(None)
if False in versions_list:
versions_list.remove(False)
if api_version is None and len(versions_list) > 0:
api_version = max(versions_list)
documentation["version"] = api_version
elif api_version is not None:
documentation["version"] = api_version
if versions_list:
documentation["versions"] = versions_list
for router_base_url, routes in self.routes.items():
for url, methods in routes.items():
for method, method_versions in methods.items():
for version, handler in method_versions.items():
if getattr(handler, "private", False):
continue
if version is None:
applies_to = versions
else:
applies_to = (version,)
for version in applies_to:
if api_version and version != api_version:
continue
if base_url and router_base_url != base_url:
continue
doc = version_dict.setdefault(url, OrderedDict())
doc[method] = handler.documentation(
doc.get(method, None),
version=version,
prefix=prefix,
base_url=router_base_url,
url=url,
)
documentation["handlers"] = version_dict
return documentation
def serve(self, host="", port=8000, no_documentation=False, display_intro=True):
"""Runs the basic hug development server against this API"""
if no_documentation:
api = self.server(None)
else:
api = self.server()
if display_intro:
print(INTRO)
httpd = make_server(host, port, api)
print("Serving on {0}:{1}...".format(host, port))
httpd.serve_forever()
@staticmethod
def base_404(request, response, *args, **kwargs):
"""Defines the base 404 handler"""
response.status = falcon.HTTP_NOT_FOUND
def determine_version(self, request, api_version=None):
"""Determines the appropriate version given the set api_version, the request header, and URL query params"""
if api_version is False:
api_version = None
for version in self.versions:
if version and "v{0}".format(version) in request.path:
api_version = version
break
request_version = set()
if api_version is not None:
request_version.add(api_version)
version_header = request.get_header("X-API-VERSION")
if version_header:
request_version.add(version_header)
version_param = request.get_param("api_version")
if version_param is not None:
request_version.add(version_param)
if len(request_version) > 1:
raise ValueError("You are requesting conflicting versions")
return next(iter(request_version or (None,)))
def documentation_404(self, base_url=None):
"""Returns a smart 404 page that contains documentation for the written API"""
base_url = self.base_url if base_url is None else base_url
def handle_404(request, response, *args, **kwargs):
url_prefix = request.forwarded_uri[:-1]
if request.path and request.path != "/":
url_prefix = request.forwarded_uri.split(request.path)[0]
to_return = OrderedDict()
to_return["404"] = (
"The API call you tried to make was not defined. "
"Here's a definition of the API to help you get going :)"
)
to_return["documentation"] = self.documentation(
base_url, self.determine_version(request, False), prefix=url_prefix
)
if self.output_format == hug.output_format.json:
response.data = hug.output_format.json(to_return, indent=4, separators=(",", ": "))
response.content_type = "application/json; charset=utf-8"
else:
response.data = self.output_format(to_return, request=request, response=response)
response.content_type = self.output_format.content_type
response.status = falcon.HTTP_NOT_FOUND
handle_404.interface = True
return handle_404
def version_router(
self, request, response, api_version=None, versions=None, not_found=None, **kwargs
):
"""Intelligently routes a request to the correct handler based on the version being requested"""
versions = {} if versions is None else versions
request_version = self.determine_version(request, api_version)
if request_version:
request_version = int(request_version)
versions.get(request_version or False, versions.get(None, not_found))(
request, response, api_version=api_version, **kwargs
)
def server(self, default_not_found=True, base_url=None):
"""Returns a WSGI compatible API server for the given Hug API module"""
falcon_api = self.falcon = falcon.API(middleware=self.middleware)
if not self.api.future:
falcon_api.req_options.keep_blank_qs_values = False
falcon_api.req_options.auto_parse_qs_csv = True
falcon_api.req_options.strip_url_path_trailing_slash = True
default_not_found = self.documentation_404() if default_not_found is True else None
base_url = self.base_url if base_url is None else base_url
not_found_handler = default_not_found
self.api._ensure_started()
if self.not_found_handlers:
if len(self.not_found_handlers) == 1 and None in self.not_found_handlers:
not_found_handler = self.not_found_handlers[None]
else:
not_found_handler = partial(
self.version_router,
api_version=False,
versions=self.not_found_handlers,
not_found=default_not_found,
)
not_found_handler.interface = True
if not_found_handler:
falcon_api.add_sink(not_found_handler)
self._not_found = not_found_handler
for sink_base_url, sinks in self.sinks.items():
for url, extra_sink in sinks.items():
falcon_api.add_sink(extra_sink, sink_base_url + url + "(?P<path>.*)")
for router_base_url, routes in self.routes.items():
for url, methods in routes.items():
router = {}
for method, versions in methods.items():
method_function = "on_{0}".format(method.lower())
if len(versions) == 1 and None in versions.keys():
router[method_function] = versions[None]
else:
router[method_function] = partial(
self.version_router, versions=versions, not_found=not_found_handler
)
router = namedtuple("Router", router.keys())(**router)
falcon_api.add_route(router_base_url + url, router)
if self.versions and self.versions != (None,):
falcon_api.add_route(router_base_url + "/v{api_version}" + url, router)
def error_serializer(request, response, error):
response.content_type = self.output_format.content_type
response.body = self.output_format(
{"errors": {error.title: error.description}}, request, response
)
falcon_api.set_error_serializer(error_serializer)
return falcon_api
HTTPInterfaceAPI.base_404.interface = True
class CLIInterfaceAPI(InterfaceAPI):
"""Defines the CLI interface specific API"""
__slots__ = ("commands", "error_exit_codes", "_output_format")
def __init__(self, api, version="", error_exit_codes=False):
super().__init__(api)
self.commands = {}
self.error_exit_codes = error_exit_codes
def __call__(self, args=None):
"""Routes to the correct command line tool"""
self.api._ensure_started()
args = sys.argv if args is None else args
if not len(args) > 1 or not args[1] in self.commands:
print(str(self))
return sys.exit(1)
command = args.pop(1)
result = self.commands.get(command)()
if self.error_exit_codes and bool(strtobool(result.decode("utf-8"))) is False:
sys.exit(1)
def handlers(self):
"""Returns all registered handlers attached to this API"""
return self.commands.values()
def extend(self, cli_api, command_prefix="", sub_command="", **kwargs):
"""Extends this CLI api with the commands present in the provided cli_api object"""
if sub_command and command_prefix:
raise ValueError(
"It is not currently supported to provide both a command_prefix and sub_command"
)
if sub_command:
self.commands[sub_command] = cli_api
else:
for name, command in cli_api.commands.items():
self.commands["{}{}".format(command_prefix, name)] = command
@property
def output_format(self):
return getattr(self, "_output_format", hug.defaults.cli_output_format)
@output_format.setter
def output_format(self, formatter):
self._output_format = formatter
def __str__(self):
output = "{0}\n\nAvailable Commands:\n\n".format(self.api.doc or self.api.name)
for command_name, command in self.commands.items():
command_string = " - {}{}".format(
command_name, ": " + str(command).replace("\n", " ") if str(command) else ""
)
output += command_string[:77] + "..." if len(command_string) > 80 else command_string
output += "\n"
return output
class ModuleSingleton(type):
"""Defines the module level __hug__ singleton"""
def __call__(cls, module=None, *args, **kwargs):
if isinstance(module, API):
return module
if type(module) == str:
if module not in sys.modules:
sys.modules[module] = ModuleType(module)
module = sys.modules[module]
elif module is None:
return super().__call__(*args, **kwargs)
if not "__hug__" in module.__dict__:
def api_auto_instantiate(*args, **kwargs):
if not hasattr(module, "__hug_serving__"):
module.__hug_wsgi__ = module.__hug__.http.server()
module.__hug_serving__ = True
return module.__hug_wsgi__(*args, **kwargs)
module.__hug__ = super().__call__(module, *args, **kwargs)
module.__hug_wsgi__ = api_auto_instantiate
return module.__hug__
class API(object, metaclass=ModuleSingleton):
"""Stores the information necessary to expose API calls within this module externally"""
__slots__ = (
"module",
"_directives",
"_http",
"_cli",
"_context",
"_context_factory",
"_delete_context",
"_startup_handlers",
"started",
"name",
"doc",
"future",
"cli_error_exit_codes",
)
def __init__(self, module=None, name="", doc="", cli_error_exit_codes=False, future=False):
self.module = module
if module:
self.name = name or module.__name__ or ""
self.doc = doc or module.__doc__ or ""
else:
self.name = name
self.doc = doc
self.started = False
self.cli_error_exit_codes = cli_error_exit_codes
self.future = future
def directives(self):
"""Returns all directives applicable to this Hug API"""
directive_sources = chain(
hug.defaults.directives.items(), getattr(self, "_directives", {}).items()
)
return {
"hug_" + directive_name: directive for directive_name, directive in directive_sources
}
def directive(self, name, default=None):
"""Returns the loaded directive with the specified name, or default if passed name is not present"""
return getattr(self, "_directives", {}).get(
name, hug.defaults.directives.get(name, default)
)
def add_directive(self, directive):
self._directives = getattr(self, "_directives", {})
self._directives[directive.__name__] = directive
def handlers(self):
"""Returns all registered handlers attached to this API"""
if getattr(self, "_http", None):
yield from self.http.handlers()
if getattr(self, "_cli", None):
yield from self.cli.handlers()
@property
def http(self):
if not hasattr(self, "_http"):
self._http = HTTPInterfaceAPI(self)
return self._http
@property
def cli(self):
if not hasattr(self, "_cli"):
self._cli = CLIInterfaceAPI(self, error_exit_codes=self.cli_error_exit_codes)
return self._cli
@property
def context_factory(self):
return getattr(self, "_context_factory", hug.defaults.context_factory)
@context_factory.setter
def context_factory(self, context_factory_):
self._context_factory = context_factory_
@property
def delete_context(self):
return getattr(self, "_delete_context", hug.defaults.delete_context)
@delete_context.setter
def delete_context(self, delete_context_):
self._delete_context = delete_context_
@property
def context(self):
if not hasattr(self, "_context"):
self._context = {}
return self._context
def extend(self, api, route="", base_url="", http=True, cli=True, **kwargs):
"""Adds handlers from a different Hug API to this one - to create a single API"""
api = API(api)
if http and hasattr(api, "_http"):
self.http.extend(api.http, route, base_url, **kwargs)
if cli and hasattr(api, "_cli"):
self.cli.extend(api.cli, **kwargs)
for directive in getattr(api, "_directives", {}).values():
self.add_directive(directive)
for startup_handler in api.startup_handlers or ():
self.add_startup_handler(startup_handler)
def add_startup_handler(self, handler):
"""Adds a startup handler to the hug api"""
if not self.startup_handlers:
self._startup_handlers = []
self.startup_handlers.append(handler)
def _ensure_started(self):
"""Marks the API as started and runs all startup handlers"""
if not self.started:
async_handlers = [
startup_handler
for startup_handler in self.startup_handlers
if introspect.is_coroutine(startup_handler)
]
if async_handlers:
loop = asyncio.get_event_loop()
loop.run_until_complete(
asyncio.gather(*[handler(self) for handler in async_handlers], loop=loop)
)
for startup_handler in self.startup_handlers:
if not startup_handler in async_handlers:
startup_handler(self)
@property
def startup_handlers(self):
return getattr(self, "_startup_handlers", ())
def from_object(obj):
"""Returns a Hug API instance from a given object (function, class, instance)"""
return API(obj.__module__)
| 38.979938
| 117
| 0.597055
|
7951d6e14ca41d9aa62f04448dc9fda38861b561
| 1,315
|
py
|
Python
|
cli/polyaxon/connections/schemas/k8s_resources.py
|
polyaxon/cli
|
3543c0220a8a7c06fc9573cd2a740f8ae4930641
|
[
"Apache-2.0"
] | null | null | null |
cli/polyaxon/connections/schemas/k8s_resources.py
|
polyaxon/cli
|
3543c0220a8a7c06fc9573cd2a740f8ae4930641
|
[
"Apache-2.0"
] | 1
|
2022-01-24T11:26:47.000Z
|
2022-03-18T23:17:58.000Z
|
cli/polyaxon/connections/schemas/k8s_resources.py
|
polyaxon/cli
|
3543c0220a8a7c06fc9573cd2a740f8ae4930641
|
[
"Apache-2.0"
] | null | null | null |
#!/usr/bin/python
#
# Copyright 2018-2022 Polyaxon, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from marshmallow import fields
import polyaxon_sdk
from polyaxon.schemas.base import BaseCamelSchema, BaseConfig
class K8sResourceSchema(BaseCamelSchema):
name = fields.Str(required=True)
mount_path = fields.Str(allow_none=True)
items = fields.List(fields.Str(), allow_none=True)
default_mode = fields.Int(allow_none=True)
@staticmethod
def schema_config():
return V1K8sResourceSchema
class V1K8sResourceSchema(BaseConfig, polyaxon_sdk.V1K8sResourceSchema):
SCHEMA = K8sResourceSchema
IDENTIFIER = "k8s_resource"
REDUCED_ATTRIBUTES = ["mountPath", "items", "defaultMode"]
def validate_k8s_resource(definition):
V1K8sResourceSchema.from_dict(definition)
| 30.581395
| 74
| 0.761217
|
7951d885baaf4e806b7a7fc6e6073a98c13d0a52
| 5,422
|
py
|
Python
|
sktime/classification/feature_based/_matrix_profile_classifier.py
|
FilipBronic/sktime
|
d613d704cdc7263ad28fb4519d2d301f2ebd0779
|
[
"BSD-3-Clause"
] | 5,349
|
2019-03-21T14:56:50.000Z
|
2022-03-31T11:25:30.000Z
|
sktime/classification/feature_based/_matrix_profile_classifier.py
|
FilipBronic/sktime
|
d613d704cdc7263ad28fb4519d2d301f2ebd0779
|
[
"BSD-3-Clause"
] | 1,803
|
2019-03-26T13:33:53.000Z
|
2022-03-31T23:58:10.000Z
|
sktime/classification/feature_based/_matrix_profile_classifier.py
|
FilipBronic/sktime
|
d613d704cdc7263ad28fb4519d2d301f2ebd0779
|
[
"BSD-3-Clause"
] | 911
|
2019-03-25T01:21:30.000Z
|
2022-03-31T04:45:51.000Z
|
# -*- coding: utf-8 -*-
"""Martrix Profile classifier.
Pipeline classifier using the Matrix Profile transformer and an estimator.
"""
__author__ = ["Matthew Middlehurst"]
__all__ = ["MatrixProfileClassifier"]
import numpy as np
from sklearn.neighbors import KNeighborsClassifier
from sktime.base._base import _clone_estimator
from sktime.classification.base import BaseClassifier
from sktime.transformations.panel.matrix_profile import MatrixProfile
from sktime.utils.validation.panel import check_X, check_X_y
class MatrixProfileClassifier(BaseClassifier):
"""Martrix Profile (MP) classifier.
This classifier simply transforms the input data using the MatrixProfile [1]
transformer and builds a provided estimator using the transformed data.
Parameters
----------
subsequence_length : int, default=10
The subsequence length for the MatrixProfile transformer.
estimator : sklearn classifier, default=None
An sklearn estimator to be built using the transformed data. Defaults to a
1-nearest neighbour classifier.
n_jobs : int, default=1
The number of jobs to run in parallel for both `fit` and `predict`.
``-1`` means using all processors.
random_state : int or None, default=None
Seed for random, integer.
Attributes
----------
n_classes : int
Number of classes. Extracted from the data.
classes_ : ndarray of shape (n_classes)
Holds the label for each class.
See Also
--------
MatrixProfile
References
----------
.. [1] Yeh, Chin-Chia Michael, et al. "Time series joins, motifs, discords and
shapelets: a unifying view that exploits the matrix profile." Data Mining and
Knowledge Discovery 32.1 (2018): 83-123.
https://link.springer.com/article/10.1007/s10618-017-0519-9
Examples
--------
>>> from sktime.classification.feature_based import MatrixProfileClassifier
>>> from sktime.datasets import load_italy_power_demand
>>> X_train, y_train = load_italy_power_demand(split="train", return_X_y=True)
>>> X_test, y_test = load_italy_power_demand(split="test", return_X_y=True)
>>> clf = MatrixProfileClassifier()
>>> clf.fit(X_train, y_train)
MatrixProfileClassifier(...)
>>> y_pred = clf.predict(X_test)
"""
# Capability tags
capabilities = {
"multivariate": False,
"unequal_length": False,
"missing_values": False,
"train_estimate": False,
"contractable": False,
}
def __init__(
self,
subsequence_length=10,
estimator=None,
n_jobs=1,
random_state=None,
):
self.subsequence_length = subsequence_length
self.estimator = estimator
self.n_jobs = n_jobs
self.random_state = random_state
self._transformer = None
self._estimator = None
self.n_classes = 0
self.classes_ = []
super(MatrixProfileClassifier, self).__init__()
def fit(self, X, y):
"""Fit an estimator using transformed data from the MatrixProfile transformer.
Parameters
----------
X : nested pandas DataFrame of shape [n_instances, 1]
Nested dataframe with univariate time-series in cells.
y : array-like, shape = [n_instances] The class labels.
Returns
-------
self : object
"""
X, y = check_X_y(X, y, enforce_univariate=True)
self.classes_ = np.unique(y)
self.n_classes = self.classes_.shape[0]
self._transformer = MatrixProfile(m=self.subsequence_length)
self._estimator = _clone_estimator(
KNeighborsClassifier(n_neighbors=1)
if self.estimator is None
else self.estimator,
self.random_state,
)
m = getattr(self._estimator, "n_jobs", None)
if m is not None:
self._estimator.n_jobs = self.n_jobs
X_t = self._transformer.fit_transform(X, y)
self._estimator.fit(X_t, y)
self._is_fitted = True
return self
def predict(self, X):
"""Predict class values of n_instances in X.
Parameters
----------
X : pd.DataFrame of shape (n_instances, 1)
Returns
-------
preds : np.ndarray of shape (n, 1)
Predicted class.
"""
self.check_is_fitted()
X = check_X(X, enforce_univariate=True)
return self._estimator.predict(self._transformer.transform(X))
def predict_proba(self, X):
"""Predict class probabilities for n_instances in X.
Parameters
----------
X : pd.DataFrame of shape (n_instances, 1)
Returns
-------
predicted_probs : array of shape (n_instances, n_classes)
Predicted probability of each class.
"""
self.check_is_fitted()
X = check_X(X, enforce_univariate=True)
m = getattr(self._estimator, "predict_proba", None)
if callable(m):
return self._estimator.predict_proba(self._transformer.transform(X))
else:
dists = np.zeros((X.shape[0], self.n_classes))
preds = self._estimator.predict(self._transformer.transform(X))
for i in range(0, X.shape[0]):
dists[i, np.where(self.classes_ == preds[i])] = 1
return dists
| 31.34104
| 86
| 0.63021
|
7951d8aa6cca26bb926e9e96f81cc4962564fb3d
| 234,913
|
py
|
Python
|
seahub/api2/views.py
|
odontomachus/seahub
|
5b6f2153921da21a473d9ff20ce443d40efc93ab
|
[
"Apache-2.0"
] | null | null | null |
seahub/api2/views.py
|
odontomachus/seahub
|
5b6f2153921da21a473d9ff20ce443d40efc93ab
|
[
"Apache-2.0"
] | null | null | null |
seahub/api2/views.py
|
odontomachus/seahub
|
5b6f2153921da21a473d9ff20ce443d40efc93ab
|
[
"Apache-2.0"
] | null | null | null |
# Copyright (c) 2012-2016 Seafile Ltd.
# encoding: utf-8
import logging
import os
import stat
from importlib import import_module
import json
import datetime
import posixpath
import re
from dateutil.relativedelta import relativedelta
from urllib2 import quote
from rest_framework import parsers
from rest_framework import status
from rest_framework import renderers
from rest_framework.authentication import SessionAuthentication
from rest_framework.permissions import IsAuthenticated, IsAdminUser
from rest_framework.reverse import reverse
from rest_framework.response import Response
from django.conf import settings as dj_settings
from django.contrib.auth.hashers import check_password
from django.contrib.sites.shortcuts import get_current_site
from django.db import IntegrityError
from django.db.models import F
from django.http import HttpResponse
from django.template.defaultfilters import filesizeformat
from django.utils import timezone
from django.utils.translation import ugettext as _
from .throttling import ScopedRateThrottle, AnonRateThrottle, UserRateThrottle
from .authentication import TokenAuthentication
from .serializers import AuthTokenSerializer
from .utils import get_diff_details, to_python_boolean, \
api_error, get_file_size, prepare_starred_files, is_web_request, \
get_groups, api_group_check, get_timestamp, json_response, is_seafile_pro
from seahub.wopi.utils import get_wopi_dict
from seahub.api2.base import APIView
from seahub.api2.models import TokenV2, DESKTOP_PLATFORMS
from seahub.api2.endpoints.group_owned_libraries import get_group_id_by_repo_owner
from seahub.avatar.templatetags.avatar_tags import api_avatar_url, avatar
from seahub.avatar.templatetags.group_avatar_tags import api_grp_avatar_url, \
grp_avatar
from seahub.base.accounts import User
from seahub.base.models import UserStarredFiles, DeviceToken, RepoSecretKey, FileComment
from seahub.share.models import ExtraSharePermission, ExtraGroupsSharePermission
from seahub.share.utils import is_repo_admin, check_group_share_in_permission
from seahub.base.templatetags.seahub_tags import email2nickname, \
translate_seahub_time, translate_commit_desc_escape, \
email2contact_email
from seahub.constants import PERMISSION_READ_WRITE, PERMISSION_PREVIEW_EDIT
from seahub.group.views import remove_group_common, \
rename_group_with_new_name, is_group_staff
from seahub.group.utils import BadGroupNameError, ConflictGroupNameError, \
validate_group_name, is_group_member, group_id_to_name, is_group_admin
from seahub.thumbnail.utils import generate_thumbnail
from seahub.notifications.models import UserNotification
from seahub.options.models import UserOptions
from seahub.profile.models import Profile, DetailedProfile
from seahub.drafts.models import Draft
from seahub.drafts.utils import get_file_draft, \
is_draft_file, has_draft_file
from seahub.signals import (repo_created, repo_deleted, repo_transfer)
from seahub.share.models import FileShare, OrgFileShare, UploadLinkShare
from seahub.utils import gen_file_get_url, gen_token, gen_file_upload_url, \
check_filename_with_rename, is_valid_username, EVENTS_ENABLED, \
get_user_events, EMPTY_SHA1, get_ccnet_server_addr_port, is_pro_version, \
gen_block_get_url, get_file_type_and_ext, HAS_FILE_SEARCH, \
gen_file_share_link, gen_dir_share_link, is_org_context, gen_shared_link, \
get_org_user_events, calculate_repos_last_modify, send_perm_audit_msg, \
gen_shared_upload_link, convert_cmmt_desc_link, is_valid_dirent_name, \
normalize_file_path, get_no_duplicate_obj_name, normalize_dir_path
from seahub.utils.file_revisions import get_file_revisions_after_renamed
from seahub.utils.devices import do_unlink_device
from seahub.utils.repo import get_repo_owner, get_library_storages, \
get_locked_files_by_dir, get_related_users_by_repo, \
is_valid_repo_id_format, can_set_folder_perm_by_user, \
add_encrypted_repo_secret_key_to_database, get_available_repo_perms, \
parse_repo_perm
from seahub.utils.star import star_file, unstar_file, get_dir_starred_files
from seahub.utils.file_tags import get_files_tags_in_dir
from seahub.utils.file_types import DOCUMENT, MARKDOWN
from seahub.utils.file_size import get_file_size_unit
from seahub.utils.file_op import check_file_lock
from seahub.utils.timeutils import utc_to_local, \
datetime_to_isoformat_timestr, datetime_to_timestamp, \
timestamp_to_isoformat_timestr
from seahub.views import is_registered_user, check_folder_permission, \
create_default_library, list_inner_pub_repos
from seahub.views.file import get_file_view_path_and_perm, send_file_access_msg, can_edit_file
if HAS_FILE_SEARCH:
from seahub_extra.search.utils import search_files, get_search_repos_map, SEARCH_FILEEXT
from seahub.utils import HAS_OFFICE_CONVERTER
if HAS_OFFICE_CONVERTER:
from seahub.utils import query_office_convert_status, prepare_converted_html
import seahub.settings as settings
from seahub.settings import THUMBNAIL_EXTENSION, THUMBNAIL_ROOT, \
FILE_LOCK_EXPIRATION_DAYS, ENABLE_STORAGE_CLASSES, \
ENABLE_THUMBNAIL, STORAGE_CLASS_MAPPING_POLICY, \
ENABLE_RESET_ENCRYPTED_REPO_PASSWORD, SHARE_LINK_EXPIRE_DAYS_MAX, \
SHARE_LINK_EXPIRE_DAYS_MIN, SHARE_LINK_EXPIRE_DAYS_DEFAULT
try:
from seahub.settings import CLOUD_MODE
except ImportError:
CLOUD_MODE = False
try:
from seahub.settings import MULTI_TENANCY
except ImportError:
MULTI_TENANCY = False
try:
from seahub.settings import ORG_MEMBER_QUOTA_DEFAULT
except ImportError:
ORG_MEMBER_QUOTA_DEFAULT = None
try:
from seahub.settings import ENABLE_OFFICE_WEB_APP
except ImportError:
ENABLE_OFFICE_WEB_APP = False
try:
from seahub.settings import OFFICE_WEB_APP_FILE_EXTENSION
except ImportError:
OFFICE_WEB_APP_FILE_EXTENSION = ()
from pysearpc import SearpcError, SearpcObjEncoder
import seaserv
from seaserv import seafserv_threaded_rpc, \
get_personal_groups_by_user, get_session_info, is_personal_repo, \
get_repo, check_permission, get_commits, is_passwd_set,\
check_quota, list_share_repos, get_group_repos_by_owner, get_group_repoids, \
remove_share, get_group, \
get_commit, get_file_id_by_path, MAX_DOWNLOAD_DIR_SIZE, edit_repo, \
ccnet_threaded_rpc, get_personal_groups, seafile_api, \
create_org, ccnet_api, send_message
from constance import config
logger = logging.getLogger(__name__)
json_content_type = 'application/json; charset=utf-8'
# Define custom HTTP status code. 4xx starts from 440, 5xx starts from 520.
HTTP_440_REPO_PASSWD_REQUIRED = 440
HTTP_441_REPO_PASSWD_MAGIC_REQUIRED = 441
HTTP_443_ABOVE_QUOTA = 443
HTTP_520_OPERATION_FAILED = 520
########## Test
class Ping(APIView):
"""
Returns a simple `pong` message when client calls `api2/ping/`.
For example:
curl http://127.0.0.1:8000/api2/ping/
"""
throttle_classes = (ScopedRateThrottle, )
throttle_scope = 'ping'
def get(self, request, format=None):
return Response('pong')
def head(self, request, format=None):
return Response(headers={'foo': 'bar',})
class AuthPing(APIView):
"""
Returns a simple `pong` message when client provided an auth token.
For example:
curl -H "Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b" http://127.0.0.1:8000/api2/auth/ping/
"""
authentication_classes = (TokenAuthentication, )
permission_classes = (IsAuthenticated,)
throttle_classes = (UserRateThrottle, )
def get(self, request, format=None):
return Response('pong')
########## Token
class ObtainAuthToken(APIView):
"""
Returns auth token if username and password are valid.
For example:
curl -d "username=foo@example.com&password=123456" http://127.0.0.1:8000/api2/auth-token/
"""
throttle_classes = (AnonRateThrottle, )
permission_classes = ()
parser_classes = (parsers.FormParser, parsers.MultiPartParser, parsers.JSONParser,)
renderer_classes = (renderers.JSONRenderer,)
def post(self, request):
headers = {}
context = { 'request': request }
serializer = AuthTokenSerializer(data=request.data, context=context)
if serializer.is_valid():
key = serializer.validated_data
trust_dev = False
try:
trust_dev_header = int(request.META.get('HTTP_X_SEAFILE_2FA_TRUST_DEVICE', ''))
trust_dev = True if trust_dev_header == 1 else False
except ValueError:
trust_dev = False
skip_2fa_header = request.META.get('HTTP_X_SEAFILE_S2FA', None)
if skip_2fa_header is None:
if trust_dev:
# 2fa login with trust device,
# create new session, and return session id.
pass
else:
# No 2fa login or 2fa login without trust device,
# return token only.
return Response({'token': key})
else:
# 2fa login without OTP token,
# get or create session, and return session id
pass
SessionStore = import_module(dj_settings.SESSION_ENGINE).SessionStore
s = SessionStore(skip_2fa_header)
if not s.exists(skip_2fa_header) or s.is_empty():
from seahub.two_factor.views.login import remember_device
s = remember_device(request.data['username'])
headers = {
'X-SEAFILE-S2FA': s.session_key
}
return Response({'token': key}, headers=headers)
if serializer.two_factor_auth_failed:
# Add a special response header so the client knows to ask the user
# for the 2fa token.
headers = {
'X-Seafile-OTP': 'required',
}
return Response(serializer.errors,
status=status.HTTP_400_BAD_REQUEST,
headers=headers)
########## Accounts
class Accounts(APIView):
"""List all accounts.
Administrator permission is required.
"""
authentication_classes = (TokenAuthentication, )
permission_classes = (IsAdminUser, )
throttle_classes = (UserRateThrottle, )
def get(self, request, format=None):
# list accounts
start = int(request.GET.get('start', '0'))
limit = int(request.GET.get('limit', '100'))
# reading scope user list
scope = request.GET.get('scope', None)
accounts_ldapimport = []
accounts_ldap = []
accounts_db = []
if scope:
scope = scope.upper()
if scope == 'LDAP':
accounts_ldap = ccnet_api.get_emailusers('LDAP', start, limit)
elif scope == 'LDAPIMPORT':
accounts_ldapimport = ccnet_api.get_emailusers('LDAPImport', start, limit)
elif scope == 'DB':
accounts_db = ccnet_api.get_emailusers('DB', start, limit)
else:
return api_error(status.HTTP_400_BAD_REQUEST, "%s is not a valid scope value" % scope)
else:
# old way - search first in LDAP if available then DB if no one found
accounts_ldap = seaserv.get_emailusers('LDAP', start, limit)
if len(accounts_ldap) == 0:
accounts_db = seaserv.get_emailusers('DB', start, limit)
accounts_json = []
for account in accounts_ldap:
accounts_json.append({'email': account.email, 'source' : 'LDAP'})
for account in accounts_ldapimport:
accounts_json.append({'email': account.email, 'source' : 'LDAPImport'})
for account in accounts_db:
accounts_json.append({'email': account.email, 'source' : 'DB'})
return Response(accounts_json)
class AccountInfo(APIView):
""" Show account info.
"""
authentication_classes = (TokenAuthentication, SessionAuthentication)
permission_classes = (IsAuthenticated,)
throttle_classes = (UserRateThrottle, )
def _get_account_info(self, request):
info = {}
email = request.user.username
p = Profile.objects.get_profile_by_user(email)
d_p = DetailedProfile.objects.get_detailed_profile_by_user(email)
if is_org_context(request):
org_id = request.user.org.org_id
quota_total = seafile_api.get_org_user_quota(org_id, email)
quota_usage = seafile_api.get_org_user_quota_usage(org_id, email)
is_org_staff = request.user.org.is_staff
info['is_org_staff'] = is_org_staff
else:
quota_total = seafile_api.get_user_quota(email)
quota_usage = seafile_api.get_user_self_usage(email)
if quota_total > 0:
info['space_usage'] = str(float(quota_usage) / quota_total * 100) + '%'
else: # no space quota set in config
info['space_usage'] = '0%'
url, _, _ = api_avatar_url(email, int(72))
info['avatar_url'] = url
info['email'] = email
info['name'] = email2nickname(email)
info['total'] = quota_total
info['usage'] = quota_usage
info['login_id'] = p.login_id if p and p.login_id else ""
info['department'] = d_p.department if d_p else ""
info['contact_email'] = p.contact_email if p else ""
info['institution'] = p.institution if p and p.institution else ""
info['is_staff'] = request.user.is_staff
interval = UserOptions.objects.get_file_updates_email_interval(email)
info['email_notification_interval'] = 0 if interval is None else interval
return info
def get(self, request, format=None):
return Response(self._get_account_info(request))
def put(self, request, format=None):
"""Update account info.
"""
username = request.user.username
name = request.data.get("name", None)
if name is not None:
if len(name) > 64:
return api_error(status.HTTP_400_BAD_REQUEST,
_(u'Name is too long (maximum is 64 characters)'))
if "/" in name:
return api_error(status.HTTP_400_BAD_REQUEST,
_(u"Name should not include '/'."))
email_interval = request.data.get("email_notification_interval", None)
if email_interval is not None:
try:
email_interval = int(email_interval)
except ValueError:
return api_error(status.HTTP_400_BAD_REQUEST,
'email_interval invalid')
# update user info
if name is not None:
profile = Profile.objects.get_profile_by_user(username)
if profile is None:
profile = Profile(user=username)
profile.nickname = name
profile.save()
if email_interval is not None:
if email_interval <= 0:
UserOptions.objects.unset_file_updates_email_interval(username)
else:
UserOptions.objects.set_file_updates_email_interval(
username, email_interval)
return Response(self._get_account_info(request))
class RegDevice(APIView):
"""Reg device for iOS push notification.
"""
authentication_classes = (TokenAuthentication, )
permission_classes = (IsAuthenticated,)
throttle_classes = (UserRateThrottle, )
def post(self, request, format=None):
version = request.POST.get('version')
platform = request.POST.get('platform')
pversion = request.POST.get('pversion')
devicetoken = request.POST.get('deviceToken')
if not devicetoken or not version or not platform or not pversion:
return api_error(status.HTTP_400_BAD_REQUEST, "Missing argument")
token, modified = DeviceToken.objects.get_or_create(
token=devicetoken, user=request.user.username)
if token.version != version:
token.version = version
modified = True
if token.pversion != pversion:
token.pversion = pversion
modified = True
if token.platform != platform:
token.platform = platform
modified = True
if modified:
token.save()
return Response("success")
class Search(APIView):
""" Search all the repos
"""
authentication_classes = (TokenAuthentication, SessionAuthentication)
permission_classes = (IsAuthenticated,)
throttle_classes = (UserRateThrottle, )
def get(self, request, format=None):
if not HAS_FILE_SEARCH:
error_msg = 'Search not supported.'
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
# argument check
keyword = request.GET.get('q', None)
if not keyword:
error_msg = 'q invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
try:
current_page = int(request.GET.get('page', '1'))
per_page = int(request.GET.get('per_page', '10'))
if per_page > 100:
per_page = 100
except ValueError:
current_page = 1
per_page = 10
start = (current_page - 1) * per_page
size = per_page
if start < 0 or size < 0:
error_msg = 'page or per_page invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
search_repo = request.GET.get('search_repo', 'all') # val: scope or 'repo_id'
search_repo = search_repo.lower()
if not is_valid_repo_id_format(search_repo) and \
search_repo not in ('all', 'mine', 'shared', 'group', 'public'):
error_msg = 'search_repo invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
search_path = request.GET.get('search_path', None)
if search_path:
search_path = normalize_dir_path(search_path)
if not is_valid_repo_id_format(search_repo):
error_msg = 'search_repo invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
dir_id = seafile_api.get_dir_id_by_path(search_repo, search_path)
if not dir_id:
error_msg = 'Folder %s not found.' % search_path
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
obj_type = request.GET.get('obj_type', None)
if obj_type:
obj_type = obj_type.lower()
if obj_type and obj_type not in ('dir', 'file'):
error_msg = 'obj_type invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
search_ftypes = request.GET.get('search_ftypes', 'all') # val: 'all' or 'custom'
search_ftypes = search_ftypes.lower()
if search_ftypes not in ('all', 'custom'):
error_msg = 'search_ftypes invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
with_permission = request.GET.get('with_permission', 'false')
with_permission = with_permission.lower()
if with_permission not in ('true', 'false'):
error_msg = 'with_permission invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
time_from = request.GET.get('time_from', None)
time_to = request.GET.get('time_to', None)
if time_from is not None:
try:
time_from = int(time_from)
except:
error_msg = 'time_from invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
if time_to is not None:
try:
time_to = int(time_to)
except:
error_msg = 'time_to invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
size_from = request.GET.get('size_from', None)
size_to = request.GET.get('size_to', None)
if size_from is not None:
try:
size_from = int(size_from)
except:
error_msg = 'size_from invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
if size_to is not None:
try:
size_to = int(size_to)
except:
error_msg = 'size_to invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
time_range = (time_from, time_to)
size_range = (size_from, size_to)
suffixes = None
custom_ftypes = request.GET.getlist('ftype') # types like 'Image', 'Video'... same in utils/file_types.py
input_fileexts = request.GET.get('input_fexts', '') # file extension input by the user
if search_ftypes == 'custom':
suffixes = []
if len(custom_ftypes) > 0:
for ftp in custom_ftypes:
if SEARCH_FILEEXT.has_key(ftp):
for ext in SEARCH_FILEEXT[ftp]:
suffixes.append(ext)
if input_fileexts:
input_fexts = input_fileexts.split(',')
for i_ext in input_fexts:
i_ext = i_ext.strip()
if i_ext:
suffixes.append(i_ext)
username = request.user.username
org_id = request.user.org.org_id if is_org_context(request) else None
repo_id_map = {}
# check recourse and permissin when search in a single repo
if is_valid_repo_id_format(search_repo):
repo_id = search_repo
repo = seafile_api.get_repo(repo_id)
# recourse check
if not repo:
error_msg = 'Library %s not found.' % repo_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
# permission check
if not check_folder_permission(request, repo_id, '/'):
error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
map_id = repo.origin_repo_id if repo.origin_repo_id else repo_id
repo_id_map[map_id] = repo
repo_type_map = {}
else:
shared_from = request.GET.get('shared_from', None)
not_shared_from = request.GET.get('not_shared_from', None)
repo_id_map, repo_type_map = get_search_repos_map(search_repo,
username, org_id, shared_from, not_shared_from)
obj_desc = {
'obj_type': obj_type,
'suffixes': suffixes,
'time_range': time_range,
'size_range': size_range
}
# search file
try:
results, total = search_files(repo_id_map, search_path, keyword, obj_desc, start, size, org_id)
except Exception as e:
logger.error(e)
error_msg = 'Internal Server Error'
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
for e in results:
e.pop('repo', None)
e.pop('exists', None)
e.pop('last_modified_by', None)
e.pop('name_highlight', None)
e.pop('score', None)
repo_id = e['repo_id']
if with_permission.lower() == 'true':
permission = check_folder_permission(request, repo_id, '/')
if not permission:
continue
e['permission'] = permission
# get repo type
if repo_type_map.has_key(repo_id):
e['repo_type'] = repo_type_map[repo_id]
else:
e['repo_type'] = ''
has_more = True if total > current_page * per_page else False
return Response({"total":total, "results":results, "has_more":has_more})
########## Repo related
def repo_download_info(request, repo_id, gen_sync_token=True):
repo = get_repo(repo_id)
if not repo:
return api_error(status.HTTP_404_NOT_FOUND, 'Library not found.')
# generate download url for client
relay_id = get_session_info().id
addr, port = get_ccnet_server_addr_port()
email = request.user.username
if gen_sync_token:
token = seafile_api.generate_repo_token(repo_id, email)
else:
token = ''
repo_name = repo.name
repo_desc = repo.desc
repo_size = repo.size
repo_size_formatted = filesizeformat(repo.size)
enc = 1 if repo.encrypted else ''
magic = repo.magic if repo.encrypted else ''
random_key = repo.random_key if repo.random_key else ''
enc_version = repo.enc_version
repo_version = repo.version
calculate_repos_last_modify([repo])
info_json = {
'relay_id': relay_id,
'relay_addr': addr,
'relay_port': port,
'email': email,
'token': token,
'repo_id': repo_id,
'repo_name': repo_name,
'repo_desc': repo_desc,
'repo_size': repo_size,
'repo_size_formatted': repo_size_formatted,
'mtime': repo.latest_modify,
'mtime_relative': translate_seahub_time(repo.latest_modify),
'encrypted': enc,
'enc_version': enc_version,
'salt': repo.salt if enc_version == 3 else '',
'magic': magic,
'random_key': random_key,
'repo_version': repo_version,
'head_commit_id': repo.head_cmmt_id,
'permission': seafile_api.check_permission_by_path(repo_id, '/', email)
}
if is_pro_version() and ENABLE_STORAGE_CLASSES:
info_json['storage_name'] = repo.storage_name
return Response(info_json)
class Repos(APIView):
authentication_classes = (TokenAuthentication, SessionAuthentication)
permission_classes = (IsAuthenticated,)
throttle_classes = (UserRateThrottle, )
def get(self, request, format=None):
# parse request params
filter_by = {
'mine': False,
'shared': False,
'group': False,
'org': False,
}
q = request.GET.get('nameContains', '')
rtype = request.GET.get('type', "")
if not rtype:
# set all to True, no filter applied
filter_by = filter_by.fromkeys(filter_by.iterkeys(), True)
for f in rtype.split(','):
f = f.strip()
filter_by[f] = True
email = request.user.username
owner_name = email2nickname(email)
owner_contact_email = email2contact_email(email)
# Use dict to reduce memcache fetch cost in large for-loop.
contact_email_dict = {}
nickname_dict = {}
repos_json = []
if filter_by['mine']:
if is_org_context(request):
org_id = request.user.org.org_id
owned_repos = seafile_api.get_org_owned_repo_list(org_id,
email, ret_corrupted=True)
else:
owned_repos = seafile_api.get_owned_repo_list(email,
ret_corrupted=True)
# Reduce memcache fetch ops.
modifiers_set = set([x.last_modifier for x in owned_repos])
for e in modifiers_set:
if e not in contact_email_dict:
contact_email_dict[e] = email2contact_email(e)
if e not in nickname_dict:
nickname_dict[e] = email2nickname(e)
owned_repos.sort(lambda x, y: cmp(y.last_modify, x.last_modify))
for r in owned_repos:
# do not return virtual repos
if r.is_virtual:
continue
if q and q.lower() not in r.name.lower():
continue
repo = {
"type": "repo",
"id": r.id,
"owner": email,
"owner_name": owner_name,
"owner_contact_email": owner_contact_email,
"name": r.name,
"mtime": r.last_modify,
"modifier_email": r.last_modifier,
"modifier_contact_email": contact_email_dict.get(r.last_modifier, ''),
"modifier_name": nickname_dict.get(r.last_modifier, ''),
"mtime_relative": translate_seahub_time(r.last_modify),
"size": r.size,
"size_formatted": filesizeformat(r.size),
"encrypted": r.encrypted,
"permission": 'rw', # Always have read-write permission to owned repo
"virtual": False,
"root": '',
"head_commit_id": r.head_cmmt_id,
"version": r.version,
}
if is_pro_version() and ENABLE_STORAGE_CLASSES:
repo['storage_name'] = r.storage_name
repo['storage_id'] = r.storage_id
repos_json.append(repo)
if filter_by['shared']:
if is_org_context(request):
org_id = request.user.org.org_id
shared_repos = seafile_api.get_org_share_in_repo_list(org_id,
email, -1, -1)
else:
shared_repos = seafile_api.get_share_in_repo_list(
email, -1, -1)
repos_with_admin_share_to = ExtraSharePermission.objects.\
get_repos_with_admin_permission(email)
# Reduce memcache fetch ops.
owners_set = set([x.user for x in shared_repos])
modifiers_set = set([x.last_modifier for x in shared_repos])
for e in owners_set | modifiers_set:
if e not in contact_email_dict:
contact_email_dict[e] = email2contact_email(e)
if e not in nickname_dict:
nickname_dict[e] = email2nickname(e)
shared_repos.sort(lambda x, y: cmp(y.last_modify, x.last_modify))
for r in shared_repos:
if q and q.lower() not in r.name.lower():
continue
library_group_name = ''
if '@seafile_group' in r.user:
library_group_id = get_group_id_by_repo_owner(r.user)
library_group_name= group_id_to_name(library_group_id)
if parse_repo_perm(r.permission).can_download is False:
if not is_web_request(request):
continue
r.password_need = is_passwd_set(r.repo_id, email)
repo = {
"type": "srepo",
"id": r.repo_id,
"owner": r.user,
"owner_name": nickname_dict.get(r.user, ''),
"owner_contact_email": contact_email_dict.get(r.user, ''),
"name": r.repo_name,
"owner_nickname": nickname_dict.get(r.user, ''),
"owner_name": nickname_dict.get(r.user, ''),
"mtime": r.last_modify,
"mtime_relative": translate_seahub_time(r.last_modify),
"modifier_email": r.last_modifier,
"modifier_contact_email": contact_email_dict.get(r.last_modifier, ''),
"modifier_name": nickname_dict.get(r.last_modifier, ''),
"size": r.size,
"size_formatted": filesizeformat(r.size),
"encrypted": r.encrypted,
"permission": r.permission,
"share_type": r.share_type,
"root": '',
"head_commit_id": r.head_cmmt_id,
"version": r.version,
"group_name": library_group_name,
}
if r.repo_id in repos_with_admin_share_to:
repo['is_admin'] = True
else:
repo['is_admin'] = False
repos_json.append(repo)
if filter_by['group']:
if is_org_context(request):
org_id = request.user.org.org_id
group_repos = seafile_api.get_org_group_repos_by_user(email,
org_id)
else:
group_repos = seafile_api.get_group_repos_by_user(email)
group_repos.sort(lambda x, y: cmp(y.last_modify, x.last_modify))
# Reduce memcache fetch ops.
share_from_set = set([x.user for x in group_repos])
modifiers_set = set([x.last_modifier for x in group_repos])
for e in modifiers_set | share_from_set:
if e not in contact_email_dict:
contact_email_dict[e] = email2contact_email(e)
if e not in nickname_dict:
nickname_dict[e] = email2nickname(e)
for r in group_repos:
if q and q.lower() not in r.name.lower():
continue
if parse_repo_perm(r.permission).can_download is False:
if not is_web_request(request):
continue
repo = {
"type": "grepo",
"id": r.repo_id,
"name": r.repo_name,
"groupid": r.group_id,
"group_name": r.group_name,
"owner": r.group_name,
"mtime": r.last_modify,
"mtime_relative": translate_seahub_time(r.last_modify),
"modifier_email": r.last_modifier,
"modifier_name": nickname_dict.get(r.last_modifier, ''),
"modifier_contact_email": contact_email_dict.get(r.last_modifier, ''),
"size": r.size,
"encrypted": r.encrypted,
"permission": r.permission,
"root": '',
"head_commit_id": r.head_cmmt_id,
"version": r.version,
"share_from": r.user,
"share_from_name": nickname_dict.get(r.user, ''),
"share_from_contact_email": contact_email_dict.get(r.user, ''),
}
repos_json.append(repo)
if filter_by['org'] and request.user.permissions.can_view_org():
public_repos = list_inner_pub_repos(request)
# Reduce memcache fetch ops.
share_from_set = set([x.user for x in public_repos])
modifiers_set = set([x.last_modifier for x in public_repos])
for e in modifiers_set | share_from_set:
if e not in contact_email_dict:
contact_email_dict[e] = email2contact_email(e)
if e not in nickname_dict:
nickname_dict[e] = email2nickname(e)
for r in public_repos:
if q and q.lower() not in r.name.lower():
continue
repo = {
"type": "grepo",
"id": r.repo_id,
"name": r.repo_name,
"owner": "Organization",
"mtime": r.last_modified,
"mtime_relative": translate_seahub_time(r.last_modified),
"modifier_email": r.last_modifier,
"modifier_contact_email": contact_email_dict.get(r.last_modifier, ''),
"modifier_name": nickname_dict.get(r.last_modifier, ''),
"size": r.size,
"size_formatted": filesizeformat(r.size),
"encrypted": r.encrypted,
"permission": r.permission,
"share_from": r.user,
"share_from_name": nickname_dict.get(r.user, ''),
"share_from_contact_email": contact_email_dict.get(r.user, ''),
"share_type": r.share_type,
"root": '',
"head_commit_id": r.head_cmmt_id,
"version": r.version,
}
repos_json.append(repo)
utc_dt = datetime.datetime.utcnow()
timestamp = utc_dt.strftime('%Y-%m-%d %H:%M:%S')
org_id = -1
if is_org_context(request):
org_id = request.user.org.org_id
try:
send_message('seahub.stats', 'user-login\t%s\t%s\t%s' % (email, timestamp, org_id))
except Exception as e:
logger.error('Error when sending user-login message: %s' % str(e))
response = HttpResponse(json.dumps(repos_json), status=200,
content_type=json_content_type)
response["enable_encrypted_library"] = config.ENABLE_ENCRYPTED_LIBRARY
return response
def post(self, request, format=None):
if not request.user.permissions.can_add_repo():
return api_error(status.HTTP_403_FORBIDDEN,
'You do not have permission to create library.')
req_from = request.GET.get('from', "")
if req_from == 'web':
gen_sync_token = False # Do not generate repo sync token
else:
gen_sync_token = True
username = request.user.username
repo_name = request.data.get("name", None)
if not repo_name:
return api_error(status.HTTP_400_BAD_REQUEST,
'Library name is required.')
if not is_valid_dirent_name(repo_name):
return api_error(status.HTTP_400_BAD_REQUEST,
'name invalid.')
repo_desc = request.data.get("desc", '')
org_id = -1
if is_org_context(request):
org_id = request.user.org.org_id
repo_id = request.data.get('repo_id', '')
try:
if repo_id:
# client generates magic and random key
repo_id, error = self._create_enc_repo(request, repo_id, repo_name, repo_desc, username, org_id)
else:
repo_id, error = self._create_repo(request, repo_name, repo_desc, username, org_id)
except SearpcError as e:
logger.error(e)
return api_error(HTTP_520_OPERATION_FAILED,
'Failed to create library.')
if error is not None:
return error
if not repo_id:
return api_error(HTTP_520_OPERATION_FAILED,
'Failed to create library.')
else:
library_template = request.data.get("library_template", '')
repo_created.send(sender=None,
org_id=org_id,
creator=username,
repo_id=repo_id,
repo_name=repo_name,
library_template=library_template)
resp = repo_download_info(request, repo_id,
gen_sync_token=gen_sync_token)
# FIXME: according to the HTTP spec, need to return 201 code and
# with a corresponding location header
# resp['Location'] = reverse('api2-repo', args=[repo_id])
return resp
def _create_repo(self, request, repo_name, repo_desc, username, org_id):
passwd = request.data.get("passwd", None)
# to avoid 'Bad magic' error when create repo, passwd should be 'None'
# not an empty string when create unencrypted repo
if not passwd:
passwd = None
if (passwd is not None) and (not config.ENABLE_ENCRYPTED_LIBRARY):
return None, api_error(status.HTTP_403_FORBIDDEN,
'NOT allow to create encrypted library.')
if org_id > 0:
repo_id = seafile_api.create_org_repo(repo_name,
repo_desc, username, org_id, passwd,
enc_version=settings.ENCRYPTED_LIBRARY_VERSION)
else:
if is_pro_version() and ENABLE_STORAGE_CLASSES:
if STORAGE_CLASS_MAPPING_POLICY in ('USER_SELECT',
'ROLE_BASED'):
storages = get_library_storages(request)
storage_id = request.data.get("storage_id", None)
if storage_id and storage_id not in [s['storage_id'] for s in storages]:
error_msg = 'storage_id invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
repo_id = seafile_api.create_repo(repo_name,
repo_desc, username, passwd, storage_id,
enc_version=settings.ENCRYPTED_LIBRARY_VERSION)
else:
# STORAGE_CLASS_MAPPING_POLICY == 'REPO_ID_MAPPING'
repo_id = seafile_api.create_repo(repo_name,
repo_desc, username, passwd,
enc_version=settings.ENCRYPTED_LIBRARY_VERSION)
else:
repo_id = seafile_api.create_repo(repo_name,
repo_desc, username, passwd,
enc_version=settings.ENCRYPTED_LIBRARY_VERSION)
if passwd and ENABLE_RESET_ENCRYPTED_REPO_PASSWORD:
add_encrypted_repo_secret_key_to_database(repo_id, passwd)
return repo_id, None
def _create_enc_repo(self, request, repo_id, repo_name, repo_desc, username, org_id):
if not config.ENABLE_ENCRYPTED_LIBRARY:
return None, api_error(status.HTTP_403_FORBIDDEN, 'NOT allow to create encrypted library.')
if not _REPO_ID_PATTERN.match(repo_id):
return None, api_error(status.HTTP_400_BAD_REQUEST, 'Repo id must be a valid uuid')
magic = request.data.get('magic', '')
random_key = request.data.get('random_key', '')
try:
enc_version = int(request.data.get('enc_version', 0))
except ValueError:
return None, api_error(status.HTTP_400_BAD_REQUEST,
'Invalid enc_version param.')
if enc_version > settings.ENCRYPTED_LIBRARY_VERSION:
return None, api_error(status.HTTP_400_BAD_REQUEST,
'Invalid enc_version param.')
salt = None
if enc_version == 3 and settings.ENCRYPTED_LIBRARY_VERSION == 3:
salt = request.data.get('salt', '')
if not salt:
error_msg = 'salt invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
if len(magic) != 64 or len(random_key) != 96 or enc_version < 0:
return None, api_error(status.HTTP_400_BAD_REQUEST,
'You must provide magic, random_key and enc_version.')
if org_id > 0:
repo_id = seafile_api.create_org_enc_repo(repo_id, repo_name, repo_desc,
username, magic, random_key,
salt, enc_version, org_id)
else:
repo_id = seafile_api.create_enc_repo(
repo_id, repo_name, repo_desc, username,
magic, random_key, salt, enc_version)
return repo_id, None
class PubRepos(APIView):
authentication_classes = (TokenAuthentication, SessionAuthentication)
permission_classes = (IsAuthenticated,)
throttle_classes = (UserRateThrottle, )
def get(self, request, format=None):
# List public repos
if not request.user.permissions.can_view_org():
return api_error(status.HTTP_403_FORBIDDEN,
'You do not have permission to view public libraries.')
repos_json = []
public_repos = list_inner_pub_repos(request)
for r in public_repos:
repo = {
"id": r.repo_id,
"name": r.repo_name,
"owner": r.user,
"owner_nickname": email2nickname(r.user),
"owner_name": email2nickname(r.user),
"mtime": r.last_modified,
"mtime_relative": translate_seahub_time(r.last_modified),
"size": r.size,
"size_formatted": filesizeformat(r.size),
"encrypted": r.encrypted,
"permission": r.permission,
}
repos_json.append(repo)
return Response(repos_json)
def post(self, request, format=None):
# Create public repo
if not request.user.permissions.can_add_public_repo():
return api_error(status.HTTP_403_FORBIDDEN,
'You do not have permission to create library.')
username = request.user.username
repo_name = request.data.get("name", None)
if not repo_name:
return api_error(status.HTTP_400_BAD_REQUEST,
'Library name is required.')
repo_desc = request.data.get("desc", '')
passwd = request.data.get("passwd", None)
# to avoid 'Bad magic' error when create repo, passwd should be 'None'
# not an empty string when create unencrypted repo
if not passwd:
passwd = None
if (passwd is not None) and (not config.ENABLE_ENCRYPTED_LIBRARY):
return api_error(status.HTTP_403_FORBIDDEN,
'NOT allow to create encrypted library.')
permission = request.data.get("permission", 'r')
if permission != 'r' and permission != 'rw':
return api_error(status.HTTP_400_BAD_REQUEST, 'Invalid permission')
org_id = -1
if is_org_context(request):
org_id = request.user.org.org_id
repo_id = seafile_api.create_org_repo(repo_name, repo_desc,
username, org_id, passwd,
enc_version=settings.ENCRYPTED_LIBRARY_VERSION)
repo = seafile_api.get_repo(repo_id)
seafile_api.set_org_inner_pub_repo(org_id, repo.id, permission)
else:
if is_pro_version() and ENABLE_STORAGE_CLASSES:
if STORAGE_CLASS_MAPPING_POLICY in ('USER_SELECT',
'ROLE_BASED'):
storages = get_library_storages(request)
storage_id = request.data.get("storage_id", None)
if storage_id and storage_id not in [s['storage_id'] for s in storages]:
error_msg = 'storage_id invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
repo_id = seafile_api.create_repo(repo_name,
repo_desc, username, passwd, storage_id,
enc_version=settings.ENCRYPTED_LIBRARY_VERSION)
else:
# STORAGE_CLASS_MAPPING_POLICY == 'REPO_ID_MAPPING'
repo_id = seafile_api.create_repo(repo_name,
repo_desc, username, passwd,
enc_version=settings.ENCRYPTED_LIBRARY_VERSION)
else:
repo_id = seafile_api.create_repo(repo_name,
repo_desc, username, passwd,
enc_version=settings.ENCRYPTED_LIBRARY_VERSION)
repo = seafile_api.get_repo(repo_id)
seafile_api.add_inner_pub_repo(repo.id, permission)
try:
send_perm_audit_msg('add-repo-perm',
username, 'all', repo_id, '/', permission)
except Exception as e:
logger.error(e)
library_template = request.data.get("library_template", '')
repo_created.send(sender=None,
org_id=org_id,
creator=username,
repo_id=repo_id,
repo_name=repo_name,
library_template=library_template)
pub_repo = {
"id": repo.id,
"name": repo.name,
"desc": repo.desc,
"size": repo.size,
"size_formatted": filesizeformat(repo.size),
"mtime": repo.last_modify,
"mtime_relative": translate_seahub_time(repo.last_modify),
"encrypted": repo.encrypted,
"permission": 'rw', # Always have read-write permission to owned repo
"owner": username,
"owner_nickname": email2nickname(username),
"owner_name": email2nickname(username),
}
return Response(pub_repo, status=201)
def set_repo_password(request, repo, password):
assert password, 'password must not be none'
repo_id = repo.id
try:
seafile_api.set_passwd(repo_id, request.user.username, password)
if ENABLE_RESET_ENCRYPTED_REPO_PASSWORD:
add_encrypted_repo_secret_key_to_database(repo_id, password)
except SearpcError, e:
if e.msg == 'Bad arguments':
return api_error(status.HTTP_400_BAD_REQUEST, e.msg)
elif e.msg == 'Repo is not encrypted':
return api_error(status.HTTP_409_CONFLICT, e.msg)
elif e.msg == 'Incorrect password':
return api_error(status.HTTP_400_BAD_REQUEST, e.msg)
elif e.msg == 'Internal server error':
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, e.msg)
else:
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, e.msg)
def check_set_repo_password(request, repo):
if not check_permission(repo.id, request.user.username):
return api_error(status.HTTP_403_FORBIDDEN,
'You do not have permission to access this library.')
if repo.encrypted:
password = request.POST.get('password', default=None)
if not password:
return api_error(HTTP_440_REPO_PASSWD_REQUIRED,
'Library password is needed.')
return set_repo_password(request, repo, password)
class Repo(APIView):
authentication_classes = (TokenAuthentication, SessionAuthentication)
permission_classes = (IsAuthenticated, )
throttle_classes = (UserRateThrottle, )
def get(self, request, repo_id, format=None):
repo = get_repo(repo_id)
if not repo:
return api_error(status.HTTP_404_NOT_FOUND, 'Library not found.')
username = request.user.username
if not check_folder_permission(request, repo_id, '/'):
return api_error(status.HTTP_403_FORBIDDEN,
'You do not have permission to access this library.')
# check whether user is repo owner
if is_org_context(request):
repo_owner = seafile_api.get_org_repo_owner(repo.id)
else:
repo_owner = seafile_api.get_repo_owner(repo.id)
owner = "self" if username == repo_owner else "share"
last_commit = get_commits(repo.id, 0, 1)[0]
repo.latest_modify = last_commit.ctime if last_commit else None
# query repo infomation
repo.size = seafile_api.get_repo_size(repo_id)
current_commit = get_commits(repo_id, 0, 1)[0]
root_id = current_commit.root_id if current_commit else None
repo_json = {
"type":"repo",
"id":repo.id,
"owner":owner,
"name":repo.name,
"mtime":repo.latest_modify,
"size":repo.size,
"encrypted":repo.encrypted,
"root":root_id,
"permission": check_permission(repo.id, username),
"modifier_email": repo.last_modifier,
"modifier_contact_email": email2contact_email(repo.last_modifier),
"modifier_name": email2nickname(repo.last_modifier),
"file_count": repo.file_count,
}
if repo.encrypted:
repo_json["enc_version"] = repo.enc_version
repo_json["magic"] = repo.magic
repo_json["random_key"] = repo.random_key
return Response(repo_json)
def post(self, request, repo_id, format=None):
repo = get_repo(repo_id)
if not repo:
return api_error(status.HTTP_404_NOT_FOUND, 'Library not found.')
op = request.GET.get('op', 'setpassword')
if op == 'checkpassword':
magic = request.GET.get('magic', default=None)
if not magic:
return api_error(HTTP_441_REPO_PASSWD_MAGIC_REQUIRED,
'Library password magic is needed.')
if not check_folder_permission(request, repo_id, '/'):
return api_error(status.HTTP_403_FORBIDDEN, 'Permission denied.')
try:
seafile_api.check_passwd(repo.id, magic)
except SearpcError as e:
logger.error(e)
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR,
"SearpcError:" + e.msg)
return Response("success")
elif op == 'setpassword':
resp = check_set_repo_password(request, repo)
if resp:
return resp
return Response("success")
elif op == 'rename':
username = request.user.username
repo_name = request.POST.get('repo_name')
repo_desc = request.POST.get('repo_desc')
if not is_valid_dirent_name(repo_name):
return api_error(status.HTTP_400_BAD_REQUEST,
'name invalid.')
# check permission
if is_org_context(request):
repo_owner = seafile_api.get_org_repo_owner(repo.id)
else:
repo_owner = seafile_api.get_repo_owner(repo.id)
is_owner = True if username == repo_owner else False
if not is_owner:
return api_error(status.HTTP_403_FORBIDDEN,
'You do not have permission to rename this library.')
# check repo status
repo_status = repo.status
if repo_status != 0:
error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
if edit_repo(repo_id, repo_name, repo_desc, username):
return Response("success")
else:
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR,
"Unable to rename library")
return Response("unsupported operation")
def delete(self, request, repo_id, format=None):
repo = seafile_api.get_repo(repo_id)
if not repo:
error_msg = 'Library %s not found.' % repo_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
# check permission
org_id = None
if is_org_context(request):
org_id = request.user.org.org_id
repo_owner = seafile_api.get_org_repo_owner(repo.id)
else:
repo_owner = seafile_api.get_repo_owner(repo.id)
username = request.user.username
if username != repo_owner:
error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
try:
usernames = get_related_users_by_repo(repo_id, org_id)
except Exception as e:
logger.error(e)
usernames = []
# remove repo
seafile_api.remove_repo(repo_id)
repo_deleted.send(sender=None,
org_id=org_id,
operator=username,
usernames=usernames,
repo_owner=repo_owner,
repo_id=repo_id,
repo_name=repo.name)
return Response('success', status=status.HTTP_200_OK)
class RepoHistory(APIView):
authentication_classes = (TokenAuthentication, )
permission_classes = (IsAuthenticated,)
throttle_classes = (UserRateThrottle, )
def get(self, request, repo_id, format=None):
try:
current_page = int(request.GET.get('page', '1'))
per_page = int(request.GET.get('per_page', '25'))
except ValueError:
current_page = 1
per_page = 25
commits_all = get_commits(repo_id, per_page * (current_page - 1),
per_page + 1)
commits = commits_all[:per_page]
if len(commits_all) == per_page + 1:
page_next = True
else:
page_next = False
return HttpResponse(json.dumps({"commits": commits,
"page_next": page_next},
cls=SearpcObjEncoder),
status=200, content_type=json_content_type)
class RepoHistoryLimit(APIView):
authentication_classes = (TokenAuthentication, SessionAuthentication)
permission_classes = (IsAuthenticated,)
throttle_classes = (UserRateThrottle, )
def get(self, request, repo_id, format=None):
repo = seafile_api.get_repo(repo_id)
if not repo:
error_msg = 'Library %s not found.' % repo_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
# check permission
if is_org_context(request):
repo_owner = seafile_api.get_org_repo_owner(repo_id)
else:
repo_owner = seafile_api.get_repo_owner(repo_id)
username = request.user.username
# no settings for virtual repo
if repo.is_virtual:
error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
if '@seafile_group' in repo_owner:
group_id = get_group_id_by_repo_owner(repo_owner)
if not is_group_admin(group_id, username):
error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
else:
if username != repo_owner:
error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
try:
keep_days = seafile_api.get_repo_history_limit(repo_id)
return Response({'keep_days': keep_days})
except SearpcError as e:
logger.error(e)
error_msg = 'Internal Server Error'
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
def put(self, request, repo_id, format=None):
repo = seafile_api.get_repo(repo_id)
if not repo:
error_msg = 'Library %s not found.' % repo_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
# check permission
if is_org_context(request):
repo_owner = seafile_api.get_org_repo_owner(repo_id)
else:
repo_owner = seafile_api.get_repo_owner(repo_id)
username = request.user.username
# no settings for virtual repo
if repo.is_virtual or not config.ENABLE_REPO_HISTORY_SETTING:
error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
if '@seafile_group' in repo_owner:
group_id = get_group_id_by_repo_owner(repo_owner)
if not is_group_admin(group_id, username):
error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
else:
if username != repo_owner:
error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
# check arg validation
keep_days = request.data.get('keep_days', None)
if not keep_days:
error_msg = 'keep_days invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
try:
keep_days = int(keep_days)
except ValueError:
error_msg = 'keep_days invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
try:
# days <= -1, keep full history
# days = 0, not keep history
# days > 0, keep a period of days
res = seafile_api.set_repo_history_limit(repo_id, keep_days)
except SearpcError as e:
logger.error(e)
error_msg = 'Internal Server Error'
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
if res == 0:
new_limit = seafile_api.get_repo_history_limit(repo_id)
return Response({'keep_days': new_limit})
else:
error_msg = 'Failed to set library history limit.'
return api_error(status.HTTP_520_OPERATION_FAILED, error_msg)
class DownloadRepo(APIView):
authentication_classes = (TokenAuthentication, SessionAuthentication)
permission_classes = (IsAuthenticated, )
throttle_classes = (UserRateThrottle, )
def get(self, request, repo_id, format=None):
repo = seafile_api.get_repo(repo_id)
if not repo:
error_msg = 'Library %s not found.' % repo_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
perm = check_folder_permission(request, repo_id, '/')
if not perm:
return api_error(status.HTTP_403_FORBIDDEN,
'You do not have permission to access this library.')
username = request.user.username
if not seafile_api.is_repo_syncable(repo_id, username, perm):
return api_error(status.HTTP_403_FORBIDDEN,
'unsyncable share permission')
return repo_download_info(request, repo_id)
class RepoOwner(APIView):
authentication_classes = (TokenAuthentication, SessionAuthentication)
permission_classes = (IsAuthenticated, )
throttle_classes = (UserRateThrottle, )
def get(self, request, repo_id, format=None):
repo = get_repo(repo_id)
if not repo:
error_msg = 'Library %s not found.' % repo_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
org_id = None
if is_org_context(request):
org_id = request.user.org.org_id
# check permission
if org_id:
repo_owner = seafile_api.get_org_repo_owner(repo_id)
else:
repo_owner = seafile_api.get_repo_owner(repo_id)
if request.user.username != repo_owner:
error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
return HttpResponse(json.dumps({"owner": repo_owner}), status=200,
content_type=json_content_type)
def put(self, request, repo_id, format=None):
""" Currently only for transfer repo.
Permission checking:
1. only repo owner can transfer repo.
"""
org_id = None
if is_org_context(request):
org_id = request.user.org.org_id
# argument check
new_owner = request.data.get('owner', '').lower()
if not new_owner:
error_msg = 'owner invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
# resource check
repo = seafile_api.get_repo(repo_id)
if not repo:
error_msg = 'Library %s not found.' % repo_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
try:
new_owner_obj = User.objects.get(email=new_owner)
except User.DoesNotExist:
error_msg = 'User %s not found.' % new_owner
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
if org_id and not ccnet_api.org_user_exists(org_id, new_owner):
error_msg = _(u'User %s not found in organization.') % new_owner
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
# permission check
if org_id:
repo_owner = seafile_api.get_org_repo_owner(repo_id)
else:
repo_owner = seafile_api.get_repo_owner(repo_id)
username = request.user.username
if username != repo_owner:
error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
if not new_owner_obj.permissions.can_add_repo():
error_msg = _(u'Transfer failed: role of %s is %s, can not add library.') % \
(new_owner, new_owner_obj.role)
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
if new_owner == repo_owner:
error_msg = _(u"Library can not be transferred to owner.")
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
pub_repos = []
if org_id:
# get repo shared to user/group list
shared_users = seafile_api.list_org_repo_shared_to(org_id,
repo_owner, repo_id)
shared_groups = seafile_api.list_org_repo_shared_group(org_id,
repo_owner, repo_id)
# get all org pub repos
pub_repos = seaserv.seafserv_threaded_rpc.list_org_inner_pub_repos_by_owner(
org_id, repo_owner)
else:
# get repo shared to user/group list
shared_users = seafile_api.list_repo_shared_to(
repo_owner, repo_id)
shared_groups = seafile_api.list_repo_shared_group_by_user(
repo_owner, repo_id)
# get all pub repos
if not request.cloud_mode:
pub_repos = seafile_api.list_inner_pub_repos_by_owner(repo_owner)
# transfer repo
try:
if org_id:
if '@seafile_group' in new_owner:
group_id = int(new_owner.split('@')[0])
seafile_api.org_transfer_repo_to_group(repo_id, org_id, group_id, PERMISSION_READ_WRITE)
else:
seafile_api.set_org_repo_owner(org_id, repo_id, new_owner)
else:
if ccnet_api.get_orgs_by_user(new_owner):
# can not transfer library to organization user %s.
error_msg = 'Email %s invalid.' % new_owner
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
else:
if '@seafile_group' in new_owner:
group_id = int(new_owner.split('@')[0])
seafile_api.transfer_repo_to_group(repo_id, group_id, PERMISSION_READ_WRITE)
else:
seafile_api.set_repo_owner(repo_id, new_owner)
except SearpcError as e:
logger.error(e)
error_msg = 'Internal Server Error'
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
# reshare repo to user
for shared_user in shared_users:
shared_username = shared_user.user
if new_owner == shared_username:
continue
if org_id:
seaserv.seafserv_threaded_rpc.org_add_share(org_id, repo_id,
new_owner, shared_username, shared_user.perm)
else:
seafile_api.share_repo(repo_id, new_owner,
shared_username, shared_user.perm)
# reshare repo to group
for shared_group in shared_groups:
shared_group_id = shared_group.group_id
if ('@seafile_group' not in new_owner) and\
(not is_group_member(shared_group_id, new_owner)):
continue
if org_id:
seafile_api.add_org_group_repo(repo_id, org_id,
shared_group_id, new_owner, shared_group.perm)
else:
seafile_api.set_group_repo(repo_id, shared_group_id,
new_owner, shared_group.perm)
# reshare repo to links
try:
UploadLinkShare.objects.filter(username=username, repo_id=repo_id).update(username=new_owner)
FileShare.objects.filter(username=username, repo_id=repo_id).update(username=new_owner)
except Exception as e:
logger.error(e)
error_msg = 'Internal Server Error'
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
# check if current repo is pub-repo
# if YES, reshare current repo to public
for pub_repo in pub_repos:
if repo_id != pub_repo.id:
continue
if org_id:
seafile_api.set_org_inner_pub_repo(org_id, repo_id,
pub_repo.permission)
else:
seaserv.seafserv_threaded_rpc.set_inner_pub_repo(
repo_id, pub_repo.permission)
break
# send a signal when successfully transfered repo
try:
repo_transfer.send(sender=None, org_id=org_id,
repo_owner=repo_owner, to_user=new_owner, repo_id=repo_id,
repo_name=repo.name)
except Exception as e:
logger.error(e)
return HttpResponse(json.dumps({'success': True}),
content_type=json_content_type)
########## File related
class FileBlockDownloadLinkView(APIView):
authentication_classes = (TokenAuthentication, )
permission_classes = (IsAuthenticated, )
throttle_classes = (UserRateThrottle, )
def get(self, request, repo_id, file_id, block_id, format=None):
# recourse check
repo = seafile_api.get_repo(repo_id)
if not repo:
error_msg = 'Library %s not found.' % repo_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
parent_dir = request.GET.get('p', '/')
dir_id = seafile_api.get_dir_id_by_path(repo_id, parent_dir)
if not dir_id:
error_msg = 'Folder %s not found.' % parent_dir
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
# permission check
if check_folder_permission(request, repo_id, parent_dir) is None:
return api_error(status.HTTP_403_FORBIDDEN,
'You do not have permission to access this repo.')
if check_quota(repo_id) < 0:
return api_error(HTTP_443_ABOVE_QUOTA, _(u"Out of quota."))
token = seafile_api.get_fileserver_access_token(
repo_id, file_id, 'downloadblks', request.user.username)
if not token:
error_msg = 'Internal Server Error'
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
url = gen_block_get_url(token, block_id)
return Response(url)
class UploadLinkView(APIView):
authentication_classes = (TokenAuthentication, SessionAuthentication)
permission_classes = (IsAuthenticated,)
throttle_classes = (UserRateThrottle,)
def get(self, request, repo_id, format=None):
# recourse check
repo = seafile_api.get_repo(repo_id)
if not repo:
error_msg = 'Library %s not found.' % repo_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
parent_dir = request.GET.get('p', '/')
dir_id = seafile_api.get_dir_id_by_path(repo_id, parent_dir)
if not dir_id:
error_msg = 'Folder %s not found.' % parent_dir
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
# permission check
if check_folder_permission(request, repo_id, parent_dir) != 'rw':
return api_error(status.HTTP_403_FORBIDDEN,
'You do not have permission to access this folder.')
if check_quota(repo_id) < 0:
return api_error(HTTP_443_ABOVE_QUOTA, _(u"Out of quota."))
token = seafile_api.get_fileserver_access_token(repo_id,
'dummy', 'upload', request.user.username, use_onetime=False)
if not token:
error_msg = 'Internal Server Error'
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
req_from = request.GET.get('from', 'api')
if req_from == 'api':
try:
replace = to_python_boolean(request.GET.get('replace', '0'))
except ValueError:
replace = False
url = gen_file_upload_url(token, 'upload-api', replace)
elif req_from == 'web':
url = gen_file_upload_url(token, 'upload-aj')
else:
error_msg = 'from invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
return Response(url)
class UpdateLinkView(APIView):
authentication_classes = (TokenAuthentication, SessionAuthentication)
permission_classes = (IsAuthenticated,)
throttle_classes = (UserRateThrottle,)
def get(self, request, repo_id, format=None):
# recourse check
repo = seafile_api.get_repo(repo_id)
if not repo:
error_msg = 'Library %s not found.' % repo_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
parent_dir = request.GET.get('p', '/')
dir_id = seafile_api.get_dir_id_by_path(repo_id, parent_dir)
if not dir_id:
error_msg = 'Folder %s not found.' % parent_dir
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
# permission check
perm = check_folder_permission(request, repo_id, parent_dir)
if perm not in (PERMISSION_PREVIEW_EDIT, PERMISSION_READ_WRITE):
return api_error(status.HTTP_403_FORBIDDEN,
'You do not have permission to access this folder.')
if check_quota(repo_id) < 0:
return api_error(HTTP_443_ABOVE_QUOTA, _(u"Out of quota."))
token = seafile_api.get_fileserver_access_token(repo_id,
'dummy', 'update', request.user.username, use_onetime=False)
if not token:
error_msg = 'Internal Server Error'
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
req_from = request.GET.get('from', 'api')
if req_from == 'api':
url = gen_file_upload_url(token, 'update-api')
elif req_from == 'web':
url = gen_file_upload_url(token, 'update-aj')
else:
error_msg = 'from invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
return Response(url)
class UploadBlksLinkView(APIView):
authentication_classes = (TokenAuthentication, )
permission_classes = (IsAuthenticated, )
throttle_classes = (UserRateThrottle, )
def get(self, request, repo_id, format=None):
# recourse check
repo = seafile_api.get_repo(repo_id)
if not repo:
error_msg = 'Library %s not found.' % repo_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
parent_dir = request.GET.get('p', '/')
dir_id = seafile_api.get_dir_id_by_path(repo_id, parent_dir)
if not dir_id:
error_msg = 'Folder %s not found.' % parent_dir
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
# permission check
if check_folder_permission(request, repo_id, parent_dir) != 'rw':
return api_error(status.HTTP_403_FORBIDDEN,
'You do not have permission to access this folder.')
if check_quota(repo_id) < 0:
return api_error(HTTP_443_ABOVE_QUOTA, _(u"Out of quota."))
token = seafile_api.get_fileserver_access_token(repo_id,
'dummy', 'upload-blks-api', request.user.username, use_onetime=False)
if not token:
error_msg = 'Internal Server Error'
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
url = gen_file_upload_url(token, 'upload-blks-api')
return Response(url)
def get_blklist_missing(self, repo_id, blks):
if not blks:
return []
blklist = blks.split(',')
try:
return json.loads(seafile_api.check_repo_blocks_missing(
repo_id, json.dumps(blklist)))
except Exception as e:
pass
return blklist
def post(self, request, repo_id, format=None):
# recourse check
repo = seafile_api.get_repo(repo_id)
if not repo:
error_msg = 'Library %s not found.' % repo_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
parent_dir = request.GET.get('p', '/')
dir_id = seafile_api.get_dir_id_by_path(repo_id, parent_dir)
if not dir_id:
error_msg = 'Folder %s not found.' % parent_dir
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
# permission check
if check_folder_permission(request, repo_id, parent_dir) != 'rw':
return api_error(status.HTTP_403_FORBIDDEN,
'You do not have permission to access this folder.')
if check_quota(repo_id) < 0:
return api_error(HTTP_443_ABOVE_QUOTA, _(u"Out of quota."))
token = seafile_api.get_fileserver_access_token(repo_id,
'dummy', 'upload', request.user.username, use_onetime=False)
if not token:
error_msg = 'Internal Server Error'
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
blksurl = gen_file_upload_url(token, 'upload-raw-blks-api')
commiturl = '%s?commitonly=true&ret-json=true' % gen_file_upload_url(
token, 'upload-blks-api')
blks = request.POST.get('blklist', None)
blklist = self.get_blklist_missing(repo_id, blks)
res = {
'rawblksurl': blksurl,
'commiturl': commiturl,
'blklist': blklist
}
return HttpResponse(json.dumps(res), status=200,
content_type=json_content_type)
class UpdateBlksLinkView(APIView):
authentication_classes = (TokenAuthentication, )
permission_classes = (IsAuthenticated, )
throttle_classes = (UserRateThrottle, )
def get(self, request, repo_id, format=None):
# recourse check
repo = seafile_api.get_repo(repo_id)
if not repo:
error_msg = 'Library %s not found.' % repo_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
parent_dir = request.GET.get('p', '/')
dir_id = seafile_api.get_dir_id_by_path(repo_id, parent_dir)
if not dir_id:
error_msg = 'Folder %s not found.' % parent_dir
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
# permission check
if check_folder_permission(request, repo_id, parent_dir) != 'rw':
return api_error(status.HTTP_403_FORBIDDEN,
'You do not have permission to access this folder.')
if check_quota(repo_id) < 0:
return api_error(HTTP_443_ABOVE_QUOTA, _(u"Out of quota."))
token = seafile_api.get_fileserver_access_token(repo_id,
'dummy', 'update-blks-api', request.user.username, use_onetime=False)
if not token:
error_msg = 'Internal Server Error'
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
url = gen_file_upload_url(token, 'update-blks-api')
return Response(url)
def get_dir_file_recursively(username, repo_id, path, all_dirs):
is_pro = is_pro_version()
path_id = seafile_api.get_dir_id_by_path(repo_id, path)
dirs = seafile_api.list_dir_with_perm(repo_id, path,
path_id, username, -1, -1)
for dirent in dirs:
entry = {}
if stat.S_ISDIR(dirent.mode):
entry["type"] = 'dir'
else:
entry["type"] = 'file'
entry['modifier_email'] = dirent.modifier
entry["size"] = dirent.size
if is_pro:
entry["is_locked"] = dirent.is_locked
entry["lock_owner"] = dirent.lock_owner
if dirent.lock_owner:
entry["lock_owner_name"] = email2nickname(dirent.lock_owner)
entry["lock_time"] = dirent.lock_time
if username == dirent.lock_owner:
entry["locked_by_me"] = True
else:
entry["locked_by_me"] = False
entry["parent_dir"] = path
entry["id"] = dirent.obj_id
entry["name"] = dirent.obj_name
entry["mtime"] = dirent.mtime
entry["permission"] = dirent.permission
all_dirs.append(entry)
# Use dict to reduce memcache fetch cost in large for-loop.
file_list = [item for item in all_dirs if item['type'] == 'file']
contact_email_dict = {}
nickname_dict = {}
modifiers_set = set([x['modifier_email'] for x in file_list])
for e in modifiers_set:
if e not in contact_email_dict:
contact_email_dict[e] = email2contact_email(e)
if e not in nickname_dict:
nickname_dict[e] = email2nickname(e)
for e in file_list:
e['modifier_contact_email'] = contact_email_dict.get(e['modifier_email'], '')
e['modifier_name'] = nickname_dict.get(e['modifier_email'], '')
if stat.S_ISDIR(dirent.mode):
sub_path = posixpath.join(path, dirent.obj_name)
get_dir_file_recursively(username, repo_id, sub_path, all_dirs)
return all_dirs
def get_dir_entrys_by_id(request, repo, path, dir_id, request_type=None):
""" Get dirents in a dir
if request_type is 'f', only return file list,
if request_type is 'd', only return dir list,
else, return both.
"""
username = request.user.username
try:
dirs = seafile_api.list_dir_with_perm(repo.id, path, dir_id,
username, -1, -1)
dirs = dirs if dirs else []
except SearpcError, e:
logger.error(e)
return api_error(HTTP_520_OPERATION_FAILED,
"Failed to list dir.")
dir_list, file_list = [], []
for dirent in dirs:
entry = {}
if stat.S_ISDIR(dirent.mode):
dtype = "dir"
else:
dtype = "file"
entry['modifier_email'] = dirent.modifier
if repo.version == 0:
entry["size"] = get_file_size(repo.store_id, repo.version,
dirent.obj_id)
else:
entry["size"] = dirent.size
if is_pro_version():
entry["is_locked"] = dirent.is_locked
entry["lock_owner"] = dirent.lock_owner
if dirent.lock_owner:
entry["lock_owner_name"] = email2nickname(dirent.lock_owner)
entry["lock_time"] = dirent.lock_time
if username == dirent.lock_owner:
entry["locked_by_me"] = True
else:
entry["locked_by_me"] = False
entry["type"] = dtype
entry["name"] = dirent.obj_name
entry["id"] = dirent.obj_id
entry["mtime"] = dirent.mtime
entry["permission"] = dirent.permission
if dtype == 'dir':
dir_list.append(entry)
else:
file_list.append(entry)
# Use dict to reduce memcache fetch cost in large for-loop.
contact_email_dict = {}
nickname_dict = {}
modifiers_set = set([x['modifier_email'] for x in file_list])
for e in modifiers_set:
if e not in contact_email_dict:
contact_email_dict[e] = email2contact_email(e)
if e not in nickname_dict:
nickname_dict[e] = email2nickname(e)
starred_files = get_dir_starred_files(username, repo.id, path)
files_tags_in_dir = get_files_tags_in_dir(repo.id, path)
for e in file_list:
e['modifier_contact_email'] = contact_email_dict.get(e['modifier_email'], '')
e['modifier_name'] = nickname_dict.get(e['modifier_email'], '')
file_tags = files_tags_in_dir.get(e['name'])
if file_tags:
e['file_tags'] = []
for file_tag in file_tags:
e['file_tags'].append(file_tag)
file_path = posixpath.join(path, e['name'])
e['starred'] = False
if normalize_file_path(file_path) in starred_files:
e['starred'] = True
dir_list.sort(lambda x, y: cmp(x['name'].lower(), y['name'].lower()))
file_list.sort(lambda x, y: cmp(x['name'].lower(), y['name'].lower()))
if request_type == 'f':
dentrys = file_list
elif request_type == 'd':
dentrys = dir_list
else:
dentrys = dir_list + file_list
response = HttpResponse(json.dumps(dentrys), status=200,
content_type=json_content_type)
response["oid"] = dir_id
response["dir_perm"] = seafile_api.check_permission_by_path(repo.id, path, username)
return response
def get_shared_link(request, repo_id, path):
l = FileShare.objects.filter(repo_id=repo_id).filter(
username=request.user.username).filter(path=path)
token = None
if len(l) > 0:
fileshare = l[0]
token = fileshare.token
else:
token = gen_token(max_length=10)
fs = FileShare()
fs.username = request.user.username
fs.repo_id = repo_id
fs.path = path
fs.token = token
try:
fs.save()
except IntegrityError, e:
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, e.msg)
http_or_https = request.is_secure() and 'https' or 'http'
domain = get_current_site(request).domain
file_shared_link = '%s://%s%sf/%s/' % (http_or_https, domain,
settings.SITE_ROOT, token)
return file_shared_link
def get_repo_file(request, repo_id, file_id, file_name, op,
use_onetime=dj_settings.FILESERVER_TOKEN_ONCE_ONLY):
if op == 'download':
token = seafile_api.get_fileserver_access_token(repo_id,
file_id, op, request.user.username, use_onetime)
if not token:
error_msg = 'Internal Server Error'
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
redirect_url = gen_file_get_url(token, file_name)
response = HttpResponse(json.dumps(redirect_url), status=200,
content_type=json_content_type)
response["oid"] = file_id
return response
if op == 'downloadblks':
blklist = []
encrypted = False
enc_version = 0
if file_id != EMPTY_SHA1:
try:
blks = seafile_api.list_blocks_by_file_id(repo_id, file_id)
blklist = blks.split('\n')
except SearpcError as e:
logger.error(e)
return api_error(HTTP_520_OPERATION_FAILED,
'Failed to get file block list')
blklist = [i for i in blklist if len(i) == 40]
if len(blklist) > 0:
repo = get_repo(repo_id)
encrypted = repo.encrypted
enc_version = repo.enc_version
res = {
'file_id': file_id,
'blklist': blklist,
'encrypted': encrypted,
'enc_version': enc_version,
}
response = HttpResponse(json.dumps(res), status=200,
content_type=json_content_type)
response["oid"] = file_id
return response
if op == 'sharelink':
path = request.GET.get('p', None)
if path is None:
return api_error(status.HTTP_400_BAD_REQUEST, 'Path is missing.')
file_shared_link = get_shared_link(request, repo_id, path)
return Response(file_shared_link)
def reloaddir(request, repo, parent_dir):
try:
dir_id = seafile_api.get_dir_id_by_path(repo.id, parent_dir)
except SearpcError, e:
logger.error(e)
return api_error(HTTP_520_OPERATION_FAILED,
"Failed to get dir id by path")
if not dir_id:
return api_error(status.HTTP_404_NOT_FOUND, "Path does not exist")
return get_dir_entrys_by_id(request, repo, parent_dir, dir_id)
def reloaddir_if_necessary(request, repo, parent_dir, obj_info=None):
reload_dir = False
s = request.GET.get('reloaddir', None)
if s and s.lower() == 'true':
reload_dir = True
if not reload_dir:
if obj_info:
return Response(obj_info)
else:
return Response('success')
return reloaddir(request, repo, parent_dir)
# deprecated
class OpDeleteView(APIView):
"""
Delete files.
"""
authentication_classes = (TokenAuthentication, SessionAuthentication)
permission_classes = (IsAuthenticated, )
def post(self, request, repo_id, format=None):
parent_dir = request.GET.get('p')
file_names = request.POST.get("file_names")
if not parent_dir or not file_names:
return api_error(status.HTTP_404_NOT_FOUND,
'File or directory not found.')
repo = get_repo(repo_id)
if not repo:
return api_error(status.HTTP_404_NOT_FOUND, 'Library not found.')
username = request.user.username
if check_folder_permission(request, repo_id, parent_dir) != 'rw':
return api_error(status.HTTP_403_FORBIDDEN,
'You do not have permission to delete this file.')
allowed_file_names = []
locked_files = get_locked_files_by_dir(request, repo_id, parent_dir)
for file_name in file_names.split(':'):
if file_name not in locked_files.keys():
# file is not locked
allowed_file_names.append(file_name)
elif locked_files[file_name] == username:
# file is locked by current user
allowed_file_names.append(file_name)
try:
multi_files = "\t".join(allowed_file_names)
seafile_api.del_file(repo_id, parent_dir,
multi_files, username)
except SearpcError as e:
logger.error(e)
return api_error(HTTP_520_OPERATION_FAILED,
"Failed to delete file.")
return reloaddir_if_necessary(request, repo, parent_dir)
class OpMoveView(APIView):
"""
Move files.
"""
authentication_classes = (TokenAuthentication, SessionAuthentication)
permission_classes = (IsAuthenticated, )
def post(self, request, repo_id, format=None):
username = request.user.username
parent_dir = request.GET.get('p', '/')
dst_repo = request.POST.get('dst_repo', None)
dst_dir = request.POST.get('dst_dir', None)
obj_names = request.POST.get("file_names", None)
# argument check
if not parent_dir or not obj_names or not dst_repo or not dst_dir:
return api_error(status.HTTP_400_BAD_REQUEST,
'Missing argument.')
if repo_id == dst_repo and parent_dir == dst_dir:
return api_error(status.HTTP_400_BAD_REQUEST,
'The destination directory is the same as the source.')
# src resource check
repo = get_repo(repo_id)
if not repo:
error_msg = 'Library %s not found.' % repo_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
if not seafile_api.get_dir_id_by_path(repo_id, parent_dir):
error_msg = 'Folder %s not found.' % parent_dir
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
# dst resource check
if not get_repo(dst_repo):
error_msg = 'Library %s not found.' % dst_repo
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
if not seafile_api.get_dir_id_by_path(dst_repo, dst_dir):
error_msg = 'Folder %s not found.' % dst_dir
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
# permission check
if check_folder_permission(request, repo_id, parent_dir) != 'rw':
return api_error(status.HTTP_403_FORBIDDEN,
'You do not have permission to move file in this folder.')
if check_folder_permission(request, dst_repo, dst_dir) != 'rw':
return api_error(status.HTTP_403_FORBIDDEN,
'You do not have permission to move file to destination folder.')
allowed_obj_names = []
locked_files = get_locked_files_by_dir(request, repo_id, parent_dir)
for file_name in obj_names.split(':'):
if file_name not in locked_files.keys():
# file is not locked
allowed_obj_names.append(file_name)
elif locked_files[file_name] == username:
# file is locked by current user
allowed_obj_names.append(file_name)
# check if all file/dir existes
obj_names = allowed_obj_names
dirents = seafile_api.list_dir_by_path(repo_id, parent_dir)
exist_obj_names = [dirent.obj_name for dirent in dirents]
if not set(obj_names).issubset(exist_obj_names):
return api_error(status.HTTP_400_BAD_REQUEST,
'file_names invalid.')
# only check quota when move file/dir between different user's repo
if get_repo_owner(request, repo_id) != get_repo_owner(request, dst_repo):
# get total size of file/dir to be copied
total_size = 0
for obj_name in obj_names:
current_size = 0
current_path = posixpath.join(parent_dir, obj_name)
current_file_id = seafile_api.get_file_id_by_path(repo_id,
current_path)
if current_file_id:
current_size = seafile_api.get_file_size(repo.store_id,
repo.version, current_file_id)
current_dir_id = seafile_api.get_dir_id_by_path(repo_id,
current_path)
if current_dir_id:
current_size = seafile_api.get_dir_size(repo.store_id,
repo.version, current_dir_id)
total_size += current_size
# check if above quota for dst repo
if seafile_api.check_quota(dst_repo, total_size) < 0:
return api_error(HTTP_443_ABOVE_QUOTA, _(u"Out of quota."))
# make new name
dst_dirents = seafile_api.list_dir_by_path(dst_repo, dst_dir)
dst_obj_names = [dirent.obj_name for dirent in dst_dirents]
new_obj_names = []
for obj_name in obj_names:
new_obj_name = get_no_duplicate_obj_name(obj_name, dst_obj_names)
new_obj_names.append(new_obj_name)
# move file
try:
src_multi_objs = "\t".join(obj_names)
dst_multi_objs = "\t".join(new_obj_names)
seafile_api.move_file(repo_id, parent_dir, src_multi_objs,
dst_repo, dst_dir, dst_multi_objs, replace=False,
username=username, need_progress=0, synchronous=1)
except SearpcError as e:
logger.error(e)
return api_error(HTTP_520_OPERATION_FAILED,
"Failed to move file.")
obj_info_list = []
for new_obj_name in new_obj_names:
obj_info = {}
obj_info['repo_id'] = dst_repo
obj_info['parent_dir'] = dst_dir
obj_info['obj_name'] = new_obj_name
obj_info_list.append(obj_info)
return reloaddir_if_necessary(request, repo, parent_dir, obj_info_list)
class OpCopyView(APIView):
"""
Copy files.
"""
authentication_classes = (TokenAuthentication, SessionAuthentication)
permission_classes = (IsAuthenticated, )
def post(self, request, repo_id, format=None):
username = request.user.username
parent_dir = request.GET.get('p', '/')
dst_repo = request.POST.get('dst_repo', None)
dst_dir = request.POST.get('dst_dir', None)
obj_names = request.POST.get("file_names", None)
# argument check
if not parent_dir or not obj_names or not dst_repo or not dst_dir:
return api_error(status.HTTP_400_BAD_REQUEST,
'Missing argument.')
# src resource check
repo = get_repo(repo_id)
if not repo:
error_msg = 'Library %s not found.' % repo_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
if not seafile_api.get_dir_id_by_path(repo_id, parent_dir):
error_msg = 'Folder %s not found.' % parent_dir
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
# dst resource check
if not get_repo(dst_repo):
error_msg = 'Library %s not found.' % dst_repo
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
if not seafile_api.get_dir_id_by_path(dst_repo, dst_dir):
error_msg = 'Folder %s not found.' % dst_dir
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
# permission check
if parse_repo_perm(check_folder_permission(request, repo_id, parent_dir)).can_copy is False:
return api_error(status.HTTP_403_FORBIDDEN,
'You do not have permission to copy file of this folder.')
if check_folder_permission(request, dst_repo, dst_dir) != 'rw':
return api_error(status.HTTP_403_FORBIDDEN,
'You do not have permission to copy file to destination folder.')
# check if all file/dir existes
obj_names = obj_names.strip(':').split(':')
dirents = seafile_api.list_dir_by_path(repo_id, parent_dir)
exist_obj_names = [dirent.obj_name for dirent in dirents]
if not set(obj_names).issubset(exist_obj_names):
return api_error(status.HTTP_400_BAD_REQUEST,
'file_names invalid.')
# get total size of file/dir to be copied
total_size = 0
for obj_name in obj_names:
current_size = 0
current_path = posixpath.join(parent_dir, obj_name)
current_file_id = seafile_api.get_file_id_by_path(repo_id,
current_path)
if current_file_id:
current_size = seafile_api.get_file_size(repo.store_id,
repo.version, current_file_id)
current_dir_id = seafile_api.get_dir_id_by_path(repo_id,
current_path)
if current_dir_id:
current_size = seafile_api.get_dir_size(repo.store_id,
repo.version, current_dir_id)
total_size += current_size
# check if above quota for dst repo
if seafile_api.check_quota(dst_repo, total_size) < 0:
return api_error(HTTP_443_ABOVE_QUOTA, _(u"Out of quota."))
# make new name
dst_dirents = seafile_api.list_dir_by_path(dst_repo, dst_dir)
dst_obj_names = [dirent.obj_name for dirent in dst_dirents]
new_obj_names = []
for obj_name in obj_names:
new_obj_name = get_no_duplicate_obj_name(obj_name, dst_obj_names)
new_obj_names.append(new_obj_name)
# copy file
try:
src_multi_objs = "\t".join(obj_names)
dst_multi_objs = "\t".join(new_obj_names)
seafile_api.copy_file(repo_id, parent_dir, src_multi_objs,
dst_repo, dst_dir, dst_multi_objs, username, 0, synchronous=1)
except SearpcError as e:
logger.error(e)
return api_error(HTTP_520_OPERATION_FAILED,
"Failed to copy file.")
obj_info_list = []
for new_obj_name in new_obj_names:
obj_info = {}
obj_info['repo_id'] = dst_repo
obj_info['parent_dir'] = dst_dir
obj_info['obj_name'] = new_obj_name
obj_info_list.append(obj_info)
return reloaddir_if_necessary(request, repo, parent_dir, obj_info_list)
class StarredFileView(APIView):
"""
Support uniform interface for starred file operation,
including add/delete/list starred files.
"""
authentication_classes = (TokenAuthentication, SessionAuthentication)
permission_classes = (IsAuthenticated,)
throttle_classes = (UserRateThrottle, )
def get(self, request, format=None):
# list starred files
personal_files = UserStarredFiles.objects.get_starred_files_by_username(
request.user.username)
starred_files = prepare_starred_files(personal_files)
return Response(starred_files)
def post(self, request, format=None):
# add starred file
repo_id = request.POST.get('repo_id', '')
path = request.POST.get('p', '')
if not (repo_id and path):
return api_error(status.HTTP_400_BAD_REQUEST,
'Library ID or path is missing.')
if check_folder_permission(request, repo_id, path) is None:
return api_error(status.HTTP_403_FORBIDDEN, 'Permission denied')
try:
file_id = seafile_api.get_file_id_by_path(repo_id, path)
except SearpcError as e:
logger.error(e)
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, 'Internal error')
if not file_id:
return api_error(status.HTTP_404_NOT_FOUND, "File not found")
if path[-1] == '/': # Should not contain '/' at the end of path.
return api_error(status.HTTP_400_BAD_REQUEST, 'Invalid file path.')
star_file(request.user.username, repo_id, path, is_dir=False,
org_id=-1)
resp = Response('success', status=status.HTTP_201_CREATED)
resp['Location'] = reverse('starredfiles')
return resp
def delete(self, request, format=None):
# remove starred file
repo_id = request.GET.get('repo_id', '')
path = request.GET.get('p', '')
if not (repo_id and path):
return api_error(status.HTTP_400_BAD_REQUEST,
'Library ID or path is missing.')
if check_folder_permission(request, repo_id, path) is None:
return api_error(status.HTTP_403_FORBIDDEN, 'Permission denied')
try:
file_id = seafile_api.get_file_id_by_path(repo_id, path)
except SearpcError as e:
logger.error(e)
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, 'Internal error')
if not file_id:
return api_error(status.HTTP_404_NOT_FOUND, "File not found")
if path[-1] == '/': # Should not contain '/' at the end of path.
return api_error(status.HTTP_400_BAD_REQUEST, 'Invalid file path.')
unstar_file(request.user.username, repo_id, path)
return Response('success', status=status.HTTP_200_OK)
class OwaFileView(APIView):
authentication_classes = (TokenAuthentication, SessionAuthentication)
permission_classes = (IsAuthenticated, )
throttle_classes = (UserRateThrottle, )
def get(self, request, repo_id, format=None):
""" Get action url and access token when view file through Office Web App
"""
# check args
repo = get_repo(repo_id)
if not repo:
error_msg = 'Library %s not found.' % repo_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
action = request.GET.get('action', 'view')
if action not in ('view', 'edit'):
error_msg = 'action invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
path = request.GET.get('path', None)
if not path:
error_msg = 'path invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
try:
file_id = seafile_api.get_file_id_by_path(repo_id, path)
except SearpcError as e:
logger.error(e)
error_msg = 'Internal Server Error'
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
if not file_id:
error_msg = 'File %s not found.' % path
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
# check permission
if not is_pro_version():
error_msg = 'Office Web App feature only supported in professional edition.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
if check_folder_permission(request, repo_id, path) is None:
error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
if repo.encrypted:
error_msg = 'Library encrypted.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
if not ENABLE_OFFICE_WEB_APP:
error_msg = 'Office Web App feature not enabled.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
filename = os.path.basename(path)
filetype, fileext = get_file_type_and_ext(filename)
if fileext not in OFFICE_WEB_APP_FILE_EXTENSION:
error_msg = 'path invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
# get wopi dict
username = request.user.username
wopi_dict = get_wopi_dict(username, repo_id, path,
action_name=action, language_code=request.LANGUAGE_CODE)
# send stats message
send_file_access_msg(request, repo, path, 'api')
return Response(wopi_dict)
class DevicesView(APIView):
authentication_classes = (TokenAuthentication, SessionAuthentication)
permission_classes = (IsAuthenticated,)
throttle_classes = (UserRateThrottle, )
def get(self, request, format=None):
""" List user's devices.
Permission checking:
1. All authenticated users.
"""
username = request.user.username
devices = TokenV2.objects.get_user_devices(username)
for device in devices:
device['last_accessed'] = datetime_to_isoformat_timestr(device['last_accessed'])
device['is_desktop_client'] = False
if device['platform'] in DESKTOP_PLATFORMS:
device['is_desktop_client'] = True
return Response(devices)
def delete(self, request, format=None):
platform = request.data.get('platform', '')
device_id = request.data.get('device_id', '')
remote_wipe = request.data.get('wipe_device', '')
if not platform:
error_msg = 'platform invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
if not device_id:
error_msg = 'device_id invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
remote_wipe = True if remote_wipe == 'true' else False
try:
do_unlink_device(request.user.username,
platform,
device_id,
remote_wipe=remote_wipe)
except SearpcError as e:
logger.error(e)
error_msg = 'Internal Server Error'
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
return Response({'success': True})
class FileMetaDataView(APIView):
authentication_classes = (TokenAuthentication, SessionAuthentication)
permission_classes = (IsAuthenticated, )
throttle_classes = (UserRateThrottle, )
def get(self, request, repo_id, format=None):
# file metadata
repo = get_repo(repo_id)
if not repo:
return api_error(status.HTTP_404_NOT_FOUND, 'Library not found.')
path = request.GET.get('p', None)
if not path:
return api_error(status.HTTP_400_BAD_REQUEST, 'Path is missing.')
parent_dir = os.path.dirname(path)
if check_folder_permission(request, repo_id, parent_dir) is None:
return api_error(status.HTTP_403_FORBIDDEN,
'You do not have permission to access this file.')
file_id = None
try:
file_id = seafile_api.get_file_id_by_path(repo_id, path)
except SearpcError as e:
logger.error(e)
return api_error(HTTP_520_OPERATION_FAILED,
"Failed to get file id by path.")
if not file_id:
return api_error(status.HTTP_404_NOT_FOUND, "File not found")
return Response({
'id': file_id,
})
class FileView(APIView):
"""
Support uniform interface for file related operations,
including create/delete/rename/view, etc.
"""
authentication_classes = (TokenAuthentication, SessionAuthentication)
permission_classes = (IsAuthenticated, )
throttle_classes = (UserRateThrottle, )
def get(self, request, repo_id, format=None):
# view file
repo = get_repo(repo_id)
if not repo:
return api_error(status.HTTP_404_NOT_FOUND, 'Library not found.')
path = request.GET.get('p', None)
if not path:
return api_error(status.HTTP_400_BAD_REQUEST, 'Path is missing.')
parent_dir = os.path.dirname(path)
if check_folder_permission(request, repo_id, parent_dir) is None:
return api_error(status.HTTP_403_FORBIDDEN,
'You do not have permission to access this file.')
file_id = None
try:
file_id = seafile_api.get_file_id_by_path(repo_id, path)
except SearpcError as e:
logger.error(e)
return api_error(HTTP_520_OPERATION_FAILED,
"Failed to get file id by path.")
if not file_id:
return api_error(status.HTTP_404_NOT_FOUND, "File not found")
# send stats message
send_file_access_msg(request, repo, path, 'api')
file_name = os.path.basename(path)
op = request.GET.get('op', 'download')
reuse = request.GET.get('reuse', '0')
if reuse not in ('1', '0'):
return api_error(status.HTTP_400_BAD_REQUEST,
"If you want to reuse file server access token for download file, you should set 'reuse' argument as '1'.")
use_onetime = False if reuse == '1' else True
return get_repo_file(request, repo_id, file_id,
file_name, op, use_onetime)
def post(self, request, repo_id, format=None):
# rename, move, copy or create file
repo = get_repo(repo_id)
if not repo:
return api_error(status.HTTP_404_NOT_FOUND, 'Library not found.')
path = request.GET.get('p', '')
if not path or path[0] != '/':
return api_error(status.HTTP_400_BAD_REQUEST,
'Path is missing or invalid.')
username = request.user.username
parent_dir = os.path.dirname(path)
operation = request.POST.get('operation', '')
is_draft = request.POST.get('is_draft', '')
file_info = {}
if operation.lower() == 'rename':
if check_folder_permission(request, repo_id, parent_dir) != 'rw':
return api_error(status.HTTP_403_FORBIDDEN,
'You do not have permission to rename file.')
newname = request.POST.get('newname', '')
if not newname:
return api_error(status.HTTP_400_BAD_REQUEST,
'New name is missing')
if len(newname) > settings.MAX_UPLOAD_FILE_NAME_LEN:
return api_error(status.HTTP_400_BAD_REQUEST, 'New name is too long')
if not seafile_api.is_valid_filename('fake_repo_id', newname):
error_msg = 'File name invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
oldname = os.path.basename(path)
if oldname == newname:
return api_error(status.HTTP_409_CONFLICT,
'The new name is the same to the old')
newname = check_filename_with_rename(repo_id, parent_dir, newname)
try:
seafile_api.rename_file(repo_id, parent_dir, oldname, newname,
username)
except SearpcError,e:
return api_error(HTTP_520_OPERATION_FAILED,
"Failed to rename file: %s" % e)
if request.GET.get('reloaddir', '').lower() == 'true':
return reloaddir(request, repo, parent_dir)
else:
resp = Response('success', status=status.HTTP_301_MOVED_PERMANENTLY)
uri = reverse('FileView', args=[repo_id], request=request)
resp['Location'] = uri + '?p=' + quote(parent_dir.encode('utf-8')) + quote(newname.encode('utf-8'))
return resp
elif operation.lower() == 'move':
if check_folder_permission(request, repo_id, parent_dir) != 'rw':
return api_error(status.HTTP_403_FORBIDDEN,
'You do not have permission to move file.')
src_dir = os.path.dirname(path)
src_repo_id = repo_id
dst_repo_id = request.POST.get('dst_repo', '')
dst_dir = request.POST.get('dst_dir', '')
if dst_dir[-1] != '/': # Append '/' to the end of directory if necessary
dst_dir += '/'
# obj_names = request.POST.get('obj_names', '')
if not (dst_repo_id and dst_dir):
return api_error(status.HTTP_400_BAD_REQUEST, 'Missing arguments.')
if src_repo_id == dst_repo_id and src_dir == dst_dir:
return Response('success', status=status.HTTP_200_OK)
if check_folder_permission(request, dst_repo_id, dst_dir) != 'rw':
return api_error(status.HTTP_403_FORBIDDEN,
'You do not have permission to move file.')
filename = os.path.basename(path)
new_filename = check_filename_with_rename(dst_repo_id, dst_dir, filename)
try:
seafile_api.move_file(src_repo_id, src_dir,
filename, dst_repo_id,
dst_dir, new_filename,
replace=False, username=username,
need_progress=0, synchronous=1)
except SearpcError, e:
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR,
"SearpcError:" + e.msg)
dst_repo = get_repo(dst_repo_id)
if not dst_repo:
return api_error(status.HTTP_404_NOT_FOUND, 'Library not found.')
if request.GET.get('reloaddir', '').lower() == 'true':
return reloaddir(request, dst_repo, dst_dir)
else:
file_info['repo_id'] = dst_repo_id
file_info['parent_dir'] = dst_dir
file_info['obj_name'] = new_filename
resp = Response(file_info, status=status.HTTP_301_MOVED_PERMANENTLY)
uri = reverse('FileView', args=[dst_repo_id], request=request)
resp['Location'] = uri + '?p=' + quote(dst_dir.encode('utf-8')) + quote(new_filename.encode('utf-8'))
return resp
elif operation.lower() == 'copy':
src_repo_id = repo_id
src_dir = os.path.dirname(path)
dst_repo_id = request.POST.get('dst_repo', '')
dst_dir = request.POST.get('dst_dir', '')
if dst_dir[-1] != '/': # Append '/' to the end of directory if necessary
dst_dir += '/'
if not (dst_repo_id and dst_dir):
return api_error(status.HTTP_400_BAD_REQUEST, 'Missing arguments.')
# check src folder permission
if parse_repo_perm(check_folder_permission(request, repo_id, src_dir)).can_copy is False:
return api_error(status.HTTP_403_FORBIDDEN,
'You do not have permission to copy file.')
# check dst folder permission
if check_folder_permission(request, dst_repo_id, dst_dir) != 'rw':
return api_error(status.HTTP_403_FORBIDDEN,
'You do not have permission to copy file.')
filename = os.path.basename(path)
new_filename = check_filename_with_rename(dst_repo_id, dst_dir, filename)
try:
seafile_api.copy_file(src_repo_id, src_dir,
filename, dst_repo_id,
dst_dir, new_filename,
username, 0, synchronous=1)
except SearpcError as e:
logger.error(e)
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR,
"SearpcError:" + e.msg)
if request.GET.get('reloaddir', '').lower() == 'true':
return reloaddir(request, dst_repo, dst_dir)
else:
file_info['repo_id'] = dst_repo_id
file_info['parent_dir'] = dst_dir
file_info['obj_name'] = new_filename
resp = Response(file_info, status=status.HTTP_200_OK)
uri = reverse('FileView', args=[dst_repo_id], request=request)
resp['Location'] = uri + '?p=' + quote(dst_dir.encode('utf-8')) + quote(new_filename.encode('utf-8'))
return resp
elif operation.lower() == 'create':
if check_folder_permission(request, repo_id, parent_dir) != 'rw':
return api_error(status.HTTP_403_FORBIDDEN,
'You do not have permission to create file.')
if is_draft.lower() == 'true':
file_name = os.path.basename(path)
file_dir = os.path.dirname(path)
draft_type = os.path.splitext(file_name)[0][-7:]
file_type = os.path.splitext(file_name)[-1]
if draft_type != '(draft)':
f = os.path.splitext(file_name)[0]
path = file_dir + '/' + f + '(draft)' + file_type
new_file_name = os.path.basename(path)
if not seafile_api.is_valid_filename('fake_repo_id', new_file_name):
error_msg = 'File name invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
new_file_name = check_filename_with_rename(repo_id, parent_dir, new_file_name)
try:
seafile_api.post_empty_file(repo_id, parent_dir,
new_file_name, username)
except SearpcError, e:
return api_error(HTTP_520_OPERATION_FAILED,
'Failed to create file.')
if is_draft.lower() == 'true':
Draft.objects.add(username, repo, path, file_exist=False)
if request.GET.get('reloaddir', '').lower() == 'true':
return reloaddir(request, repo, parent_dir)
else:
resp = Response('success', status=status.HTTP_201_CREATED)
uri = reverse('FileView', args=[repo_id], request=request)
resp['Location'] = uri + '?p=' + quote(parent_dir.encode('utf-8')) + \
quote(new_file_name.encode('utf-8'))
return resp
else:
return api_error(status.HTTP_400_BAD_REQUEST,
"Operation can only be rename, create or move.")
def put(self, request, repo_id, format=None):
repo = get_repo(repo_id)
if not repo:
return api_error(status.HTTP_404_NOT_FOUND, 'Library not found.')
path = request.data.get('p', '')
file_id = seafile_api.get_file_id_by_path(repo_id, path)
if not path or not file_id:
return api_error(status.HTTP_400_BAD_REQUEST,
'Path is missing or invalid.')
username = request.user.username
# check file access permission
parent_dir = os.path.dirname(path)
if check_folder_permission(request, repo_id, parent_dir) != 'rw':
return api_error(status.HTTP_403_FORBIDDEN, 'Permission denied.')
# check file lock
try:
is_locked, locked_by_me = check_file_lock(repo_id, path, username)
except Exception as e:
logger.error(e)
error_msg = 'Internal Server Error'
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
operation = request.data.get('operation', '')
if operation.lower() == 'lock':
if is_locked:
return api_error(status.HTTP_403_FORBIDDEN, 'File is already locked')
# lock file
expire = request.data.get('expire', FILE_LOCK_EXPIRATION_DAYS)
try:
seafile_api.lock_file(repo_id, path.lstrip('/'), username, expire)
return Response('success', status=status.HTTP_200_OK)
except SearpcError, e:
logger.error(e)
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, 'Internal error')
if operation.lower() == 'unlock':
if not is_locked:
return api_error(status.HTTP_403_FORBIDDEN, 'File is not locked')
if not locked_by_me:
return api_error(status.HTTP_403_FORBIDDEN, 'You can not unlock this file')
# unlock file
try:
seafile_api.unlock_file(repo_id, path.lstrip('/'))
return Response('success', status=status.HTTP_200_OK)
except SearpcError, e:
logger.error(e)
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, 'Internal error')
else:
return api_error(status.HTTP_400_BAD_REQUEST,
"Operation can only be lock or unlock")
def delete(self, request, repo_id, format=None):
# delete file
repo = get_repo(repo_id)
if not repo:
return api_error(status.HTTP_404_NOT_FOUND, 'Library not found.')
path = request.GET.get('p', None)
if not path:
return api_error(status.HTTP_400_BAD_REQUEST, 'Path is missing.')
parent_dir = os.path.dirname(path)
if check_folder_permission(request, repo_id, parent_dir) != 'rw':
return api_error(status.HTTP_403_FORBIDDEN, 'Permission denied.')
parent_dir = os.path.dirname(path)
file_name = os.path.basename(path)
try:
seafile_api.del_file(repo_id, parent_dir,
file_name, request.user.username)
except SearpcError as e:
logger.error(e)
return api_error(HTTP_520_OPERATION_FAILED,
"Failed to delete file.")
return reloaddir_if_necessary(request, repo, parent_dir)
class FileDetailView(APIView):
authentication_classes = (TokenAuthentication, SessionAuthentication)
permission_classes = (IsAuthenticated,)
throttle_classes = (UserRateThrottle,)
def get(self, request, repo_id, format=None):
# argument check
path = request.GET.get('p', None)
if not path:
error_msg = 'p invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
path = normalize_file_path(path)
# resource check
repo = seafile_api.get_repo(repo_id)
if not repo:
error_msg = 'Library %s not found.' % repo_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
commit_id = request.GET.get('commit_id', None)
try:
if commit_id:
obj_id = seafile_api.get_file_id_by_commit_and_path(repo_id,
commit_id, path)
else:
obj_id = seafile_api.get_file_id_by_path(repo_id, path)
except Exception as e:
logger.error(e)
error_msg = 'Internal Server Error'
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
if not obj_id:
error_msg = 'File %s not found.' % path
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
# permission check
parent_dir = os.path.dirname(path)
permission = check_folder_permission(request, repo_id, parent_dir)
if not permission:
error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
# get real path for sub repo
if repo.is_virtual:
real_path = posixpath.join(repo.origin_path, path.lstrip('/'))
real_repo_id = repo.origin_repo_id
else:
real_path = path
real_repo_id = repo_id
file_name = os.path.basename(path)
entry = {}
entry["type"] = "file"
entry["id"] = obj_id
entry["name"] = file_name
entry["permission"] = permission
file_type, file_ext = get_file_type_and_ext(file_name)
if file_type == MARKDOWN:
is_draft = is_draft_file(repo_id, path)
has_draft = False
if not is_draft:
has_draft = has_draft_file(repo_id, path)
draft = get_file_draft(repo_id, path, is_draft, has_draft)
entry['is_draft'] = is_draft
entry['has_draft'] = has_draft
entry['draft_file_path'] = draft['draft_file_path']
entry['draft_id'] = draft['draft_id']
# fetch file contributors and latest contributor
try:
# get real path for sub repo
dirent = seafile_api.get_dirent_by_path(real_repo_id, real_path)
except Exception as e:
logger.error(e)
dirent = None
last_modified = dirent.mtime if dirent else ''
latest_contributor = dirent.modifier if dirent else ''
entry["mtime"] = last_modified
entry["last_modified"] = timestamp_to_isoformat_timestr(last_modified)
entry["last_modifier_email"] = latest_contributor
entry["last_modifier_name"] = email2nickname(latest_contributor)
entry["last_modifier_contact_email"] = email2contact_email(latest_contributor)
try:
file_size = get_file_size(real_repo_id, repo.version, obj_id)
except Exception as e:
logger.error(e)
file_size = 0
entry["size"] = file_size
starred_files = UserStarredFiles.objects.filter(repo_id=repo_id,
path=path)
entry["starred"] = True if len(starred_files) > 0 else False
file_comments = FileComment.objects.get_by_file_path(repo_id, path)
comment_total = file_comments.count()
entry["comment_total"] = comment_total
entry["can_edit"], _ = can_edit_file(file_name, file_size, repo)
return Response(entry)
class FileRevert(APIView):
authentication_classes = (TokenAuthentication, SessionAuthentication)
permission_classes = (IsAuthenticated,)
throttle_classes = (UserRateThrottle, )
def put(self, request, repo_id, format=None):
path = request.data.get('p', None)
commit_id = request.data.get('commit_id', None)
if not path:
error_msg = 'path invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
if not commit_id:
error_msg = 'commit_id invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
if not seafile_api.get_repo(repo_id):
error_msg = 'library %s not found.' % repo_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
if not seafile_api.get_file_id_by_commit_and_path(repo_id, commit_id, path):
error_msg = 'file %s not found.' % path
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
if check_folder_permission(request, repo_id, '/') != 'rw':
error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
username = request.user.username
try:
seafile_api.revert_file(repo_id, commit_id, path, username)
except SearpcError as e:
logger.error(e)
error_msg = 'Internal Server Error'
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
return Response({'success': True})
class FileRevision(APIView):
authentication_classes = (TokenAuthentication, SessionAuthentication)
permission_classes = (IsAuthenticated,)
throttle_classes = (UserRateThrottle, )
def get(self, request, repo_id, format=None):
path = request.GET.get('p', None)
if path is None:
return api_error(status.HTTP_400_BAD_REQUEST, 'Path is missing.')
file_name = os.path.basename(path)
commit_id = request.GET.get('commit_id', None)
try:
obj_id = seafserv_threaded_rpc.get_file_id_by_commit_and_path(
repo_id, commit_id, path)
except:
return api_error(status.HTTP_404_NOT_FOUND, 'Revision not found.')
return get_repo_file(request, repo_id, obj_id, file_name, 'download')
class FileHistory(APIView):
authentication_classes = (TokenAuthentication,)
permission_classes = (IsAuthenticated,)
throttle_classes = (UserRateThrottle,)
def get(self, request, repo_id, format=None):
""" Get file history.
"""
path = request.GET.get('p', None)
if path is None:
error_msg = 'p invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
repo = seafile_api.get_repo(repo_id)
if not repo:
error_msg = 'Library %s not found.' % repo_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
file_id = seafile_api.get_file_id_by_path(repo_id, path)
if not file_id:
error_msg = 'File %s not found.' % path
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
permission = check_folder_permission(request, repo_id, path)
if permission not in get_available_repo_perms():
error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
try:
commits = get_file_revisions_after_renamed(repo_id, path)
except Exception as e:
logger.error(e)
error_msg = 'Internal Server Error'
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
for commit in commits:
creator_name = commit.creator_name
user_info = {}
user_info['email'] = creator_name
user_info['name'] = email2nickname(creator_name)
user_info['contact_email'] = Profile.objects.get_contact_email_by_user(creator_name)
commit._dict['user_info'] = user_info
return HttpResponse(json.dumps({"commits": commits},
cls=SearpcObjEncoder), status=200, content_type=json_content_type)
class FileSharedLinkView(APIView):
"""
Support uniform interface for file shared link.
"""
authentication_classes = (TokenAuthentication, SessionAuthentication)
permission_classes = (IsAuthenticated, )
throttle_classes = (UserRateThrottle, )
def put(self, request, repo_id, format=None):
repo = seaserv.get_repo(repo_id)
if not repo:
return api_error(status.HTTP_404_NOT_FOUND, "Library does not exist")
if repo.encrypted:
error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
path = request.data.get('p', None)
if not path:
return api_error(status.HTTP_400_BAD_REQUEST, 'Path is missing')
username = request.user.username
password = request.data.get('password', None)
share_type = request.data.get('share_type', 'download')
if password and len(password) < config.SHARE_LINK_PASSWORD_MIN_LENGTH:
return api_error(status.HTTP_400_BAD_REQUEST, 'Password is too short')
if share_type.lower() == 'download':
if parse_repo_perm(check_folder_permission(request, repo_id, path)).can_download is False:
return api_error(status.HTTP_403_FORBIDDEN, 'Permission denied')
if not request.user.permissions.can_generate_share_link():
error_msg = 'Can not generate share link.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
try:
expire_days = int(request.data.get('expire', 0))
except ValueError:
error_msg = 'expire invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
if expire_days <= 0:
if SHARE_LINK_EXPIRE_DAYS_DEFAULT > 0:
expire_days = SHARE_LINK_EXPIRE_DAYS_DEFAULT
if SHARE_LINK_EXPIRE_DAYS_MIN > 0:
if expire_days < SHARE_LINK_EXPIRE_DAYS_MIN:
error_msg = _('Expire days should be greater or equal to %s') % \
SHARE_LINK_EXPIRE_DAYS_MIN
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
if SHARE_LINK_EXPIRE_DAYS_MAX > 0:
if expire_days > SHARE_LINK_EXPIRE_DAYS_MAX:
error_msg = _('Expire days should be less than or equal to %s') % \
SHARE_LINK_EXPIRE_DAYS_MAX
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
if expire_days <= 0:
expire_date = None
else:
expire_date = timezone.now() + relativedelta(days=expire_days)
is_dir = False
if path == '/':
is_dir = True
else:
try:
real_path = repo.origin_path + path if repo.origin_path else path
dirent = seafile_api.get_dirent_by_path(repo.store_id, real_path)
except SearpcError as e:
logger.error(e)
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, "Internal error")
if not dirent:
return api_error(status.HTTP_400_BAD_REQUEST, 'Invalid path')
if stat.S_ISDIR(dirent.mode):
is_dir = True
if is_dir:
# generate dir download link
fs = FileShare.objects.get_dir_link_by_path(username, repo_id, path)
if fs is None:
fs = FileShare.objects.create_dir_link(username, repo_id, path,
password, expire_date)
if is_org_context(request):
org_id = request.user.org.org_id
OrgFileShare.objects.set_org_file_share(org_id, fs)
else:
# generate file download link
fs = FileShare.objects.get_file_link_by_path(username, repo_id, path)
if fs is None:
fs = FileShare.objects.create_file_link(username, repo_id, path,
password, expire_date)
if is_org_context(request):
org_id = request.user.org.org_id
OrgFileShare.objects.set_org_file_share(org_id, fs)
token = fs.token
shared_link = gen_shared_link(token, fs.s_type)
elif share_type.lower() == 'upload':
if not seafile_api.get_dir_id_by_path(repo_id, path):
return api_error(status.HTTP_400_BAD_REQUEST, 'Invalid path')
if check_folder_permission(request, repo_id, path) != 'rw':
return api_error(status.HTTP_403_FORBIDDEN, 'Permission denied')
if not request.user.permissions.can_generate_upload_link():
error_msg = 'Can not generate upload link.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
# generate upload link
uls = UploadLinkShare.objects.get_upload_link_by_path(username, repo_id, path)
if uls is None:
uls = UploadLinkShare.objects.create_upload_link_share(
username, repo_id, path, password)
token = uls.token
shared_link = gen_shared_upload_link(token)
else:
return api_error(status.HTTP_400_BAD_REQUEST,
"Operation can only be download or upload.")
resp = Response(status=status.HTTP_201_CREATED)
resp['Location'] = shared_link
return resp
########## Directory related
class DirMetaDataView(APIView):
authentication_classes = (TokenAuthentication, SessionAuthentication)
permission_classes = (IsAuthenticated, )
throttle_classes = (UserRateThrottle, )
def get(self, request, repo_id, format=None):
# recource check
repo = seafile_api.get_repo(repo_id)
if not repo:
error_msg = 'Library %s not found.' % repo_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
path = request.GET.get('p', '/')
path = normalize_dir_path(path)
dir_id = seafile_api.get_dir_id_by_path(repo_id, path)
if not dir_id:
error_msg = 'Folder %s not found.' % path
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
# permission check
permission = check_folder_permission(request, repo_id, path)
if not permission:
error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
return Response({
'id': dir_id,
})
class DirView(APIView):
"""
Support uniform interface for directory operations, including
create/delete/rename/list, etc.
"""
authentication_classes = (TokenAuthentication, SessionAuthentication)
permission_classes = (IsAuthenticated, )
throttle_classes = (UserRateThrottle, )
def get(self, request, repo_id, format=None):
# argument check
recursive = request.GET.get('recursive', '0')
if recursive not in ('1', '0'):
error_msg = "If you want to get recursive dir entries, you should set 'recursive' argument as '1'."
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
request_type = request.GET.get('t', '')
if request_type and request_type not in ('f', 'd'):
error_msg = "'t'(type) should be 'f' or 'd'."
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
# recource check
repo = seafile_api.get_repo(repo_id)
if not repo:
error_msg = 'Library %s not found.' % repo_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
path = request.GET.get('p', '/')
path = normalize_dir_path(path)
dir_id = seafile_api.get_dir_id_by_path(repo_id, path)
if not dir_id:
error_msg = 'Folder %s not found.' % path
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
# permission check
permission = check_folder_permission(request, repo_id, path)
if parse_repo_perm(permission).can_download is False and \
not is_web_request(request):
# preview only repo and this request does not came from web brower
error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
old_oid = request.GET.get('oid', None)
if old_oid and old_oid == dir_id:
response = HttpResponse(json.dumps("uptodate"), status=200,
content_type=json_content_type)
response["oid"] = dir_id
return response
if recursive == '1':
result = []
username = request.user.username
dir_file_list = get_dir_file_recursively(username, repo_id, path, [])
if request_type == 'f':
for item in dir_file_list:
if item['type'] == 'file':
result.append(item)
elif request_type == 'd':
for item in dir_file_list:
if item['type'] == 'dir':
result.append(item)
else:
result = dir_file_list
response = HttpResponse(json.dumps(result), status=200,
content_type=json_content_type)
response["oid"] = dir_id
response["dir_perm"] = permission
return response
return get_dir_entrys_by_id(request, repo, path, dir_id, request_type)
def post(self, request, repo_id, format=None):
# new dir
repo = get_repo(repo_id)
if not repo:
return api_error(status.HTTP_404_NOT_FOUND, 'Library not found.')
path = request.GET.get('p', '')
if not path or path[0] != '/':
return api_error(status.HTTP_400_BAD_REQUEST, "Path is missing.")
if path == '/': # Can not make or rename root dir.
return api_error(status.HTTP_400_BAD_REQUEST, "Path is invalid.")
if path[-1] == '/': # Cut out last '/' if possible.
path = path[:-1]
username = request.user.username
operation = request.POST.get('operation', '')
parent_dir = os.path.dirname(path)
if operation.lower() == 'mkdir':
new_dir_name = os.path.basename(path)
if not seafile_api.is_valid_filename('fake_repo_id', new_dir_name):
error_msg = 'Folder name invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
create_parents = request.POST.get('create_parents', '').lower() in ('true', '1')
if not create_parents:
# check whether parent dir exists
if not seafile_api.get_dir_id_by_path(repo_id, parent_dir):
error_msg = 'Folder %s not found.' % parent_dir
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
if check_folder_permission(request, repo_id, parent_dir) != 'rw':
error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
retry_count = 0
while retry_count < 10:
new_dir_name = check_filename_with_rename(repo_id,
parent_dir, new_dir_name)
try:
seafile_api.post_dir(repo_id,
parent_dir, new_dir_name, username)
break
except SearpcError as e:
if str(e) == 'file already exists':
retry_count += 1
else:
logger.error(e)
return api_error(HTTP_520_OPERATION_FAILED,
'Failed to make directory.')
else:
if check_folder_permission(request, repo_id, '/') != 'rw':
error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
try:
seafile_api.mkdir_with_parents(repo_id, '/',
path[1:], username)
except SearpcError as e:
logger.error(e)
return api_error(HTTP_520_OPERATION_FAILED,
'Failed to make directory.')
if request.GET.get('reloaddir', '').lower() == 'true':
resp = reloaddir(request, repo, parent_dir)
else:
resp = Response('success', status=status.HTTP_201_CREATED)
uri = reverse('DirView', args=[repo_id], request=request)
resp['Location'] = uri + '?p=' + quote(
parent_dir.encode('utf-8') + '/' + new_dir_name.encode('utf-8'))
return resp
elif operation.lower() == 'rename':
if not seafile_api.get_dir_id_by_path(repo_id, path):
error_msg = 'Folder %s not found.' % path
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
if check_folder_permission(request, repo.id, path) != 'rw':
error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
old_dir_name = os.path.basename(path)
newname = request.POST.get('newname', '')
if not newname:
return api_error(status.HTTP_400_BAD_REQUEST, "New name is mandatory.")
if newname == old_dir_name:
return Response('success', status=status.HTTP_200_OK)
try:
# rename duplicate name
checked_newname = check_filename_with_rename(
repo_id, parent_dir, newname)
# rename dir
seafile_api.rename_file(repo_id, parent_dir, old_dir_name,
checked_newname, username)
return Response('success', status=status.HTTP_200_OK)
except SearpcError, e:
logger.error(e)
return api_error(HTTP_520_OPERATION_FAILED,
'Failed to rename folder.')
# elif operation.lower() == 'move':
# pass
else:
return api_error(status.HTTP_400_BAD_REQUEST,
"Operation not supported.")
def delete(self, request, repo_id, format=None):
# delete dir or file
path = request.GET.get('p', None)
if not path:
error_msg = 'p invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
repo = get_repo(repo_id)
if not repo:
error_msg = 'Library %s not found.' % repo_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
if not seafile_api.get_dir_id_by_path(repo_id, path):
error_msg = 'Folder %s not found.' % path
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
if check_folder_permission(request, repo_id, path) != 'rw':
error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
if path == '/': # Can not delete root path.
return api_error(status.HTTP_400_BAD_REQUEST, 'Path is invalid.')
if path[-1] == '/': # Cut out last '/' if possible.
path = path[:-1]
parent_dir = os.path.dirname(path)
file_name = os.path.basename(path)
username = request.user.username
try:
seafile_api.del_file(repo_id, parent_dir,
file_name, username)
except SearpcError as e:
logger.error(e)
return api_error(HTTP_520_OPERATION_FAILED,
"Failed to delete file.")
return reloaddir_if_necessary(request, repo, parent_dir)
class DirRevert(APIView):
authentication_classes = (TokenAuthentication, SessionAuthentication)
permission_classes = (IsAuthenticated,)
throttle_classes = (UserRateThrottle, )
def put(self, request, repo_id):
path = request.data.get('p', None)
commit_id = request.data.get('commit_id', None)
if not path:
error_msg = 'path invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
if not commit_id:
error_msg = 'commit_id invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
if not seafile_api.get_repo(repo_id):
error_msg = 'library %s not found.' % repo_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
if not seafile_api.get_dir_id_by_commit_and_path(repo_id, commit_id, path):
error_msg = 'folder %s not found.' % path
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
if check_folder_permission(request, repo_id, '/') != 'rw':
error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
username = request.user.username
try:
seafile_api.revert_dir(repo_id, commit_id, path, username)
except SearpcError as e:
logger.error(e)
error_msg = 'Internal Server Error'
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
return Response({'success': True})
class DirSubRepoView(APIView):
authentication_classes = (TokenAuthentication, SessionAuthentication)
permission_classes = (IsAuthenticated,)
throttle_classes = (UserRateThrottle,)
def get(self, request, repo_id, format=None):
""" Create sub-repo for folder
Permission checking:
1. user with `r` or `rw` permission.
2. password correct for encrypted repo.
"""
# argument check
path = request.GET.get('p', None)
if not path:
error_msg = 'p invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
name = request.GET.get('name', None)
if not name:
error_msg = 'name invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
# recourse check
repo = get_repo(repo_id)
if not repo:
error_msg = 'Library %s not found.' % repo_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
# permission check
if not check_folder_permission(request, repo_id, path):
error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
username = request.user.username
password = request.GET.get('password', '')
if repo.encrypted:
# check password for encrypted repo
if not password:
error_msg = 'password invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
else:
try:
seafile_api.set_passwd(repo_id, username, password)
except SearpcError as e:
if e.msg == 'Bad arguments':
error_msg = 'Bad arguments'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
elif e.msg == 'Incorrect password':
error_msg = _(u'Wrong password')
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
elif e.msg == 'Internal server error':
error_msg = _(u'Internal server error')
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
else:
error_msg = _(u'Decrypt library error')
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
# create sub-lib for encrypted repo
try:
if is_org_context(request):
org_id = request.user.org.org_id
sub_repo_id = seafile_api.create_org_virtual_repo(
org_id, repo_id, path, name, name, username, password)
else:
sub_repo_id = seafile_api.create_virtual_repo(
repo_id, path, name, name, username, password)
except SearpcError as e:
logger.error(e)
error_msg = 'Internal Server Error'
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
else:
# create sub-lib for common repo
try:
if is_org_context(request):
org_id = request.user.org.org_id
sub_repo_id = seafile_api.create_org_virtual_repo(
org_id, repo_id, path, name, name, username)
else:
sub_repo_id = seafile_api.create_virtual_repo(
repo_id, path, name, name, username)
except SearpcError as e:
logger.error(e)
error_msg = 'Internal Server Error'
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
return Response({'sub_repo_id': sub_repo_id})
########## Sharing
class SharedRepos(APIView):
"""
List repos that a user share to others/groups/public.
"""
authentication_classes = (TokenAuthentication, )
permission_classes = (IsAuthenticated, )
throttle_classes = (UserRateThrottle, )
def get(self, request, format=None):
username = request.user.username
shared_repos = []
shared_repos += list_share_repos(username, 'from_email', -1, -1)
shared_repos += get_group_repos_by_owner(username)
if not CLOUD_MODE:
shared_repos += seafile_api.list_inner_pub_repos_by_owner(username)
return HttpResponse(json.dumps(shared_repos, cls=SearpcObjEncoder),
status=200, content_type=json_content_type)
class BeSharedRepos(APIView):
"""
List repos that others/groups share to user.
"""
authentication_classes = (TokenAuthentication, SessionAuthentication )
permission_classes = (IsAuthenticated, )
throttle_classes = (UserRateThrottle, )
def get(self, request, format=None):
username = request.user.username
shared_repos = []
shared_repos += seafile_api.get_share_in_repo_list(username, -1, -1)
joined_groups = get_personal_groups_by_user(username)
for grp in joined_groups:
# Get group repos, and for each group repos...
for r_id in get_group_repoids(grp.id):
# No need to list my own repo
if seafile_api.is_repo_owner(username, r_id):
continue
# Convert repo properties due to the different collumns in Repo
# and SharedRepo
r = get_repo(r_id)
if not r:
continue
r.repo_id = r.id
r.repo_name = r.name
r.repo_desc = r.desc
cmmts = get_commits(r_id, 0, 1)
last_commit = cmmts[0] if cmmts else None
r.last_modified = last_commit.ctime if last_commit else 0
r._dict['share_type'] = 'group'
r.user = seafile_api.get_repo_owner(r_id)
r.user_perm = check_permission(r_id, username)
shared_repos.append(r)
if not CLOUD_MODE:
shared_repos += seaserv.list_inner_pub_repos(username)
return HttpResponse(json.dumps(shared_repos, cls=SearpcObjEncoder),
status=200, content_type=json_content_type)
class SharedFileView(APIView):
# Anyone should be able to access a Shared File assuming they have the token
throttle_classes = (UserRateThrottle, )
def get(self, request, token, format=None):
assert token is not None # Checked by URLconf
try:
fileshare = FileShare.objects.get(token=token)
except FileShare.DoesNotExist:
return api_error(status.HTTP_404_NOT_FOUND, "Token not found")
repo_id = fileshare.repo_id
repo = get_repo(repo_id)
if not repo:
return api_error(status.HTTP_404_NOT_FOUND, "Library not found")
path = fileshare.path.rstrip('/') # Normalize file path
file_name = os.path.basename(path)
file_id = None
try:
file_id = seafile_api.get_file_id_by_path(repo_id, path)
except SearpcError as e:
logger.error(e)
return api_error(HTTP_520_OPERATION_FAILED,
"Failed to get file id by path.")
if not file_id:
return api_error(status.HTTP_404_NOT_FOUND, "File not found")
# Increase file shared link view_cnt, this operation should be atomic
fileshare.view_cnt = F('view_cnt') + 1
fileshare.save()
op = request.GET.get('op', 'download')
return get_repo_file(request, repo_id, file_id, file_name, op)
class SharedFileDetailView(APIView):
throttle_classes = (UserRateThrottle, )
def get(self, request, token, format=None):
assert token is not None # Checked by URLconf
try:
fileshare = FileShare.objects.get(token=token)
except FileShare.DoesNotExist:
return api_error(status.HTTP_404_NOT_FOUND, "Token not found")
if fileshare.is_encrypted():
password = request.GET.get('password', '')
if not password:
return api_error(status.HTTP_403_FORBIDDEN, "Password is required")
if not check_password(password, fileshare.password):
return api_error(status.HTTP_403_FORBIDDEN, "Invalid Password")
repo_id = fileshare.repo_id
repo = get_repo(repo_id)
if not repo:
return api_error(status.HTTP_404_NOT_FOUND, "Library not found")
path = fileshare.path.rstrip('/') # Normalize file path
file_name = os.path.basename(path)
file_id = None
try:
file_id = seafile_api.get_file_id_by_path(repo_id, path)
commits = get_file_revisions_after_renamed(repo_id, path)
c = commits[0]
except SearpcError, e:
return api_error(HTTP_520_OPERATION_FAILED,
"Failed to get file id by path.")
if not file_id:
return api_error(status.HTTP_404_NOT_FOUND, "File not found")
entry = {}
try:
entry["size"] = get_file_size(repo.store_id, repo.version, file_id)
except Exception as e:
logger.error(e)
entry["size"] = 0
entry["type"] = "file"
entry["name"] = file_name
entry["id"] = file_id
entry["mtime"] = c.ctime
entry["repo_id"] = repo_id
entry["path"] = path
return HttpResponse(json.dumps(entry), status=200,
content_type=json_content_type)
class FileShareEncoder(json.JSONEncoder):
def default(self, obj):
if not isinstance(obj, FileShare):
return None
return {'username':obj.username, 'repo_id':obj.repo_id,
'path':obj.path, 'token':obj.token,
'ctime':obj.ctime, 'view_cnt':obj.view_cnt,
's_type':obj.s_type}
class SharedLinksView(APIView):
authentication_classes = (TokenAuthentication, SessionAuthentication )
permission_classes = (IsAuthenticated,)
throttle_classes = (UserRateThrottle, )
def get(self, request, format=None):
username = request.user.username
fileshares = FileShare.objects.filter(username=username)
p_fileshares = [] # personal file share
for fs in fileshares:
if is_personal_repo(fs.repo_id): # only list files in personal repos
r = seafile_api.get_repo(fs.repo_id)
if not r:
fs.delete()
continue
if fs.s_type == 'f':
if seafile_api.get_file_id_by_path(r.id, fs.path) is None:
fs.delete()
continue
fs.filename = os.path.basename(fs.path)
fs.shared_link = gen_file_share_link(fs.token)
else:
if seafile_api.get_dir_id_by_path(r.id, fs.path) is None:
fs.delete()
continue
fs.filename = os.path.basename(fs.path.rstrip('/'))
fs.shared_link = gen_dir_share_link(fs.token)
fs.repo = r
p_fileshares.append(fs)
return HttpResponse(json.dumps({"fileshares": p_fileshares}, cls=FileShareEncoder), status=200, content_type=json_content_type)
def delete(self, request, format=None):
token = request.GET.get('t', None)
if not token:
return api_error(status.HTTP_400_BAD_REQUEST, 'Token is missing')
username = request.user.username
share = FileShare.objects.filter(token=token).filter(username=username) or \
UploadLinkShare.objects.filter(token=token).filter(username=username)
if not share:
return api_error(status.HTTP_400_BAD_REQUEST, 'Invalid token')
share.delete()
return HttpResponse(json.dumps({}), status=200, content_type=json_content_type)
class SharedDirView(APIView):
throttle_classes = (UserRateThrottle, )
def get(self, request, token, format=None):
"""List dirents in dir download shared link
"""
fileshare = FileShare.objects.get_valid_dir_link_by_token(token)
if not fileshare:
return api_error(status.HTTP_400_BAD_REQUEST, "Invalid token")
repo_id = fileshare.repo_id
repo = get_repo(repo_id)
if not repo:
return api_error(status.HTTP_400_BAD_REQUEST, "Invalid token")
if fileshare.is_encrypted():
password = request.GET.get('password', '')
if not password:
return api_error(status.HTTP_403_FORBIDDEN, "Password is required")
if not check_password(password, fileshare.password):
return api_error(status.HTTP_403_FORBIDDEN, "Invalid Password")
req_path = request.GET.get('p', '/')
if req_path[-1] != '/':
req_path += '/'
if req_path == '/':
real_path = fileshare.path
else:
real_path = posixpath.join(fileshare.path, req_path.lstrip('/'))
if real_path[-1] != '/': # Normalize dir path
real_path += '/'
dir_id = seafile_api.get_dir_id_by_path(repo_id, real_path)
if not dir_id:
return api_error(status.HTTP_400_BAD_REQUEST, "Invalid path")
username = fileshare.username
try:
dirs = seafserv_threaded_rpc.list_dir_with_perm(repo_id, real_path, dir_id,
username, -1, -1)
dirs = dirs if dirs else []
except SearpcError, e:
logger.error(e)
return api_error(HTTP_520_OPERATION_FAILED, "Failed to list dir.")
dir_list, file_list = [], []
for dirent in dirs:
dtype = "file"
entry = {}
if stat.S_ISDIR(dirent.mode):
dtype = "dir"
else:
if repo.version == 0:
entry["size"] = get_file_size(repo.store_id, repo.version,
dirent.obj_id)
else:
entry["size"] = dirent.size
entry["type"] = dtype
entry["name"] = dirent.obj_name
entry["id"] = dirent.obj_id
entry["mtime"] = dirent.mtime
if dtype == 'dir':
dir_list.append(entry)
else:
file_list.append(entry)
dir_list.sort(lambda x, y: cmp(x['name'].lower(), y['name'].lower()))
file_list.sort(lambda x, y: cmp(x['name'].lower(), y['name'].lower()))
dentrys = dir_list + file_list
content_type = 'application/json; charset=utf-8'
return HttpResponse(json.dumps(dentrys), status=200, content_type=content_type)
class DefaultRepoView(APIView):
"""
Get user's default library.
"""
authentication_classes = (TokenAuthentication, SessionAuthentication)
permission_classes = (IsAuthenticated, )
throttle_classes = (UserRateThrottle, )
def get(self, request, format=None):
username = request.user.username
repo_id = UserOptions.objects.get_default_repo(username)
if repo_id is None or (get_repo(repo_id) is None):
json = {
'exists': False,
}
return Response(json)
else:
return self.default_repo_info(repo_id)
def default_repo_info(self, repo_id):
repo_json = {
'exists': False,
}
if repo_id is not None:
repo_json['exists'] = True
repo_json['repo_id'] = repo_id
return Response(repo_json)
def post(self, request):
if not request.user.permissions.can_add_repo():
return api_error(status.HTTP_403_FORBIDDEN,
'You do not have permission to create library.')
username = request.user.username
repo_id = UserOptions.objects.get_default_repo(username)
if repo_id and (get_repo(repo_id) is not None):
return self.default_repo_info(repo_id)
repo_id = create_default_library(request)
return self.default_repo_info(repo_id)
class SharedRepo(APIView):
"""
Support uniform interface for shared libraries.
"""
authentication_classes = (TokenAuthentication, SessionAuthentication )
permission_classes = (IsAuthenticated, )
throttle_classes = (UserRateThrottle, )
def delete(self, request, repo_id, format=None):
"""
Unshare a library.
Repo owner and system admin can perform this operation.
"""
repo = get_repo(repo_id)
if not repo:
return api_error(status.HTTP_404_NOT_FOUND, 'Library not found.')
username = request.user.username
if is_org_context(request):
repo_owner = seafile_api.get_org_repo_owner(repo_id)
else:
repo_owner = seafile_api.get_repo_owner(repo_id)
if not request.user.is_staff and not username == repo_owner:
return api_error(status.HTTP_403_FORBIDDEN,
'You do not have permission to unshare library.')
share_type = request.GET.get('share_type', '')
if not share_type:
return api_error(status.HTTP_400_BAD_REQUEST,
'Share type is required.')
if share_type == 'personal':
user = request.GET.get('user', '')
if not user:
return api_error(status.HTTP_400_BAD_REQUEST,
'User is required.')
if not is_valid_username(user):
return api_error(status.HTTP_400_BAD_REQUEST,
'User is not valid')
remove_share(repo_id, username, user)
elif share_type == 'group':
group_id = request.GET.get('group_id', '')
if not group_id:
return api_error(status.HTTP_400_BAD_REQUEST,
'Group ID is required.')
try:
group_id = int(group_id)
except ValueError:
return api_error(status.HTTP_400_BAD_REQUEST,
'Group ID is not valid.')
seafile_api.unset_group_repo(repo_id, int(group_id), username)
elif share_type == 'public':
if is_org_context(request):
org_id = request.user.org.org_id
seaserv.seafserv_threaded_rpc.unset_org_inner_pub_repo(org_id, repo_id)
else:
seafile_api.remove_inner_pub_repo(repo_id)
else:
return api_error(status.HTTP_400_BAD_REQUEST,
'Share type can only be personal or group or public.')
return Response('success', status=status.HTTP_200_OK)
def put(self, request, repo_id, format=None):
"""
Share a repo to users/groups/public.
"""
# argument check
share_type = request.GET.get('share_type')
permission = request.GET.get('permission')
if permission not in get_available_repo_perms():
error_msg = 'permission invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
if share_type not in ('personal', 'group', 'public'):
error_msg = 'share_type invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
# recourse check
repo = seafile_api.get_repo(repo_id)
if not repo:
error_msg = 'Library %s not found.' % repo_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
# permission check
username = request.user.username
repo_owner = get_repo_owner(request, repo_id)
if username != repo_owner:
error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
if share_type == 'personal':
user = request.GET.get('user')
users = request.GET.get('users')
if not user and not users:
return api_error(status.HTTP_400_BAD_REQUEST,
'User or users (comma separated are mandatory) are not provided')
usernames = []
if user:
usernames += user.split(",")
if users:
usernames += users.split(",")
shared_users = []
invalid_users = []
notexistent_users = []
notsharable_errors = []
for u in usernames:
if not u:
continue
if not is_valid_username(u):
invalid_users.append(u)
continue
if not is_registered_user(u):
notexistent_users.append(u)
continue
try:
seafile_api.share_repo(repo_id, username, u, permission)
shared_users.append(u)
except SearpcError, e:
logger.error(e)
notsharable_errors.append(e)
try:
send_perm_audit_msg('add-repo-perm',
username, u, repo_id, '/', permission)
except Exception as e:
logger.error(e)
if invalid_users or notexistent_users or notsharable_errors:
# removing already created share
for s_user in shared_users:
try:
remove_share(repo_id, username, s_user)
except SearpcError, e:
# ignoring this error, go to next unsharing
continue
if invalid_users:
return api_error(status.HTTP_400_BAD_REQUEST,
'Some users are not valid, sharing rolled back')
if notexistent_users:
return api_error(status.HTTP_400_BAD_REQUEST,
'Some users are not existent, sharing rolled back')
if notsharable_errors:
# show the first sharing error
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR,
'Internal error occurs, sharing rolled back')
if share_type == 'group':
group_id = request.GET.get('group_id')
if not group_id:
error_msg = 'group_id invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
try:
group_id = int(group_id)
except ValueError:
return api_error(status.HTTP_400_BAD_REQUEST,
'Group ID must be integer.')
group = get_group(group_id)
if not group:
return api_error(status.HTTP_400_BAD_REQUEST,
'Group does not exist .')
try:
seafile_api.set_group_repo(repo_id,
group_id, username, permission)
except SearpcError, e:
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR,
"Searpc Error: " + e.msg)
try:
send_perm_audit_msg('add-repo-perm',
username, group_id, repo_id, '/', permission)
except Exception as e:
logger.error(e)
if share_type == 'public':
try:
if is_org_context(request):
org_id = request.user.org.org_id
seafile_api.set_org_inner_pub_repo(org_id, repo_id, permission)
else:
if not request.user.permissions.can_add_public_repo():
error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
seafile_api.add_inner_pub_repo(repo_id, permission)
except Exception as e:
logger.error(e)
error_msg = 'Internal Server Error'
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
try:
send_perm_audit_msg('add-repo-perm',
username, 'all', repo_id, '/', permission)
except Exception as e:
logger.error(e)
return Response('success', status=status.HTTP_200_OK)
class EventsView(APIView):
authentication_classes = (TokenAuthentication, SessionAuthentication)
permission_classes = (IsAuthenticated,)
throttle_classes = (UserRateThrottle, )
def get(self, request, format=None):
if not EVENTS_ENABLED:
events = None
return api_error(status.HTTP_404_NOT_FOUND, 'Events not enabled.')
start = request.GET.get('start', '')
if not start:
start = 0
else:
try:
start = int(start)
except ValueError:
return api_error(status.HTTP_400_BAD_REQUEST, 'Start id must be integer')
email = request.user.username
events_count = 15
if is_org_context(request):
org_id = request.user.org.org_id
events, events_more_offset = get_org_user_events(org_id, email,
start,
events_count)
else:
events, events_more_offset = get_user_events(email, start,
events_count)
events_more = True if len(events) == events_count else False
l = []
for e in events:
d = dict(etype=e.etype)
l.append(d)
if e.etype == 'repo-update':
d['author'] = e.commit.creator_name
d['time'] = e.commit.ctime
d['desc'] = e.commit.desc
d['repo_id'] = e.repo.id
d['repo_name'] = e.repo.name
d['commit_id'] = e.commit.id
d['converted_cmmt_desc'] = translate_commit_desc_escape(convert_cmmt_desc_link(e.commit))
d['more_files'] = e.commit.more_files
d['repo_encrypted'] = e.repo.encrypted
elif e.etype == 'clean-up-repo-trash':
d['repo_id'] = e.repo_id
d['author'] = e.username
d['time'] = datetime_to_timestamp(e.timestamp)
d['days'] = e.days
d['repo_name'] = e.repo_name
d['etype'] = e.etype
else:
d['repo_id'] = e.repo_id
d['repo_name'] = e.repo_name
if e.etype == 'repo-create':
d['author'] = e.creator
else:
d['author'] = e.repo_owner
d['time'] = datetime_to_timestamp(e.timestamp)
size = request.GET.get('size', 36)
url, is_default, date_uploaded = api_avatar_url(d['author'], size)
d['nick'] = email2nickname(d['author'])
d['name'] = email2nickname(d['author'])
d['avatar'] = avatar(d['author'], size)
d['avatar_url'] = url
d['time_relative'] = translate_seahub_time(utc_to_local(e.timestamp))
d['date'] = utc_to_local(e.timestamp).strftime("%Y-%m-%d")
ret = {
'events': l,
'more': events_more,
'more_offset': events_more_offset,
}
return Response(ret)
class UnseenMessagesCountView(APIView):
authentication_classes = (TokenAuthentication, )
permission_classes = (IsAuthenticated,)
throttle_classes = (UserRateThrottle, )
def get(self, request, format=None):
username = request.user.username
ret = { 'count' : UserNotification.objects.count_unseen_user_notifications(username)
}
return Response(ret)
########## Groups related
class Groups(APIView):
authentication_classes = (TokenAuthentication, SessionAuthentication)
permission_classes = (IsAuthenticated,)
throttle_classes = (UserRateThrottle, )
def get(self, request, format=None):
size = request.GET.get('size', 36)
limit = int(request.GET.get('limit', 8))
with_msg = request.GET.get('with_msg', 'true')
# To not broken the old API, we need to make with_msg default
if with_msg == 'true':
group_json, replynum = get_groups(request.user.username)
res = {"groups": group_json, "replynum": replynum}
return Response(res)
else:
groups_json = []
joined_groups = get_personal_groups_by_user(request.user.username)
for g in joined_groups:
if limit <= 0:
break;
group = {
"id": g.id,
"name": g.group_name,
"creator": g.creator_name,
"ctime": g.timestamp,
"avatar": grp_avatar(g.id, int(size)),
}
groups_json.append(group)
limit = limit - 1
return Response(groups_json)
def put(self, request, format=None):
# modified slightly from groups/views.py::group_list
"""
Add a new group.
"""
result = {}
content_type = 'application/json; charset=utf-8'
username = request.user.username
if not request.user.permissions.can_add_group():
return api_error(status.HTTP_403_FORBIDDEN,
'You do not have permission to create group.')
# check plan
num_of_groups = getattr(request.user, 'num_of_groups', -1)
if num_of_groups > 0:
current_groups = len(get_personal_groups_by_user(username))
if current_groups > num_of_groups:
result['error'] = 'You can only create %d groups.' % num_of_groups
return HttpResponse(json.dumps(result), status=500,
content_type=content_type)
group_name = request.data.get('group_name', None)
group_name = group_name.strip()
if not validate_group_name(group_name):
result['error'] = 'Failed to rename group, group name can only contain letters, numbers, blank, hyphen or underscore.'
return HttpResponse(json.dumps(result), status=403,
content_type=content_type)
# Check whether group name is duplicated.
if request.cloud_mode:
checked_groups = get_personal_groups_by_user(username)
else:
checked_groups = get_personal_groups(-1, -1)
for g in checked_groups:
if g.group_name == group_name:
result['error'] = 'There is already a group with that name.'
return HttpResponse(json.dumps(result), status=400,
content_type=content_type)
# Group name is valid, create that group.
try:
group_id = ccnet_api.create_group(group_name, username)
return HttpResponse(json.dumps({'success': True, 'group_id': group_id}),
content_type=content_type)
except SearpcError, e:
result['error'] = e.msg
return HttpResponse(json.dumps(result), status=500,
content_type=content_type)
def delete(self, request, group_id, format=None):
try:
group_id = int(group_id)
except ValueError:
return api_error(status.HTTP_400_BAD_REQUEST, 'Bad group id format')
group = seaserv.get_group(group_id)
if not group:
return api_error(status.HTTP_404_NOT_FOUND, 'Group not found')
# permission check
username = request.user.username
if not seaserv.check_group_staff(group_id, username):
return api_error(status.HTTP_403_FORBIDDEN, 'You do not have permission to delete group')
# delete group
if is_org_context(request):
org_id = request.user.org.org_id
else:
org_id = None
try:
remove_group_common(group.id, username, org_id=org_id)
except SearpcError as e:
logger.error(e)
return api_error(HTTP_520_OPERATION_FAILED,
'Failed to remove group.')
return Response('success', status=status.HTTP_200_OK)
def post(self, request, group_id, format=None):
group = seaserv.get_group(group_id)
if not group:
return api_error(status.HTTP_404_NOT_FOUND, 'Group not found')
# permission check
username = request.user.username
if not seaserv.check_group_staff(group.id, username):
return api_error(status.HTTP_403_FORBIDDEN, 'You do not have permission to rename group')
operation = request.POST.get('operation', '')
if operation.lower() == 'rename':
newname = request.POST.get('newname', '')
if not newname:
return api_error(status.HTTP_400_BAD_REQUEST,
'New name is missing')
try:
rename_group_with_new_name(request, group.id, newname)
except BadGroupNameError:
return api_error(status.HTTP_400_BAD_REQUEST,
'Group name is not valid.')
except ConflictGroupNameError:
return api_error(status.HTTP_400_BAD_REQUEST,
'There is already a group with that name.')
return Response('success', status=status.HTTP_200_OK)
else:
return api_error(status.HTTP_400_BAD_REQUEST,
"Operation can only be rename.")
class GroupMembers(APIView):
authentication_classes = (TokenAuthentication, SessionAuthentication)
permission_classes = (IsAuthenticated,)
throttle_classes = (UserRateThrottle,)
def put(self, request, group_id, format=None):
"""
Add group members.
"""
try:
group_id_int = int(group_id)
except ValueError:
return api_error(status.HTTP_400_BAD_REQUEST, 'Invalid group ID')
group = get_group(group_id_int)
if not group:
return api_error(status.HTTP_404_NOT_FOUND, 'Group not found')
if not is_group_staff(group, request.user):
return api_error(status.HTTP_403_FORBIDDEN, 'Only administrators can add group members')
user_name = request.data.get('user_name', None)
if not is_registered_user(user_name):
return api_error(status.HTTP_400_BAD_REQUEST, 'Not a valid user')
try:
ccnet_threaded_rpc.group_add_member(group.id, request.user.username, user_name)
except SearpcError, e:
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, 'Unable to add user to group')
return HttpResponse(json.dumps({'success': True}), status=200, content_type=json_content_type)
def delete(self, request, group_id, format=None):
"""
Delete group members.
"""
try:
group_id_int = int(group_id)
except ValueError:
return api_error(status.HTTP_400_BAD_REQUEST, 'Invalid group ID')
group = get_group(group_id_int)
if not group:
return api_error(status.HTTP_404_NOT_FOUND, 'Group not found')
if not is_group_staff(group, request.user):
return api_error(status.HTTP_403_FORBIDDEN, 'Only administrators can remove group members')
user_name = request.data.get('user_name', None)
try:
ccnet_threaded_rpc.group_remove_member(group.id, request.user.username, user_name)
except SearpcError, e:
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, 'Unable to add user to group')
return HttpResponse(json.dumps({'success': True}), status=200, content_type=json_content_type)
class GroupRepos(APIView):
authentication_classes = (TokenAuthentication, SessionAuthentication)
permission_classes = (IsAuthenticated,)
throttle_classes = (UserRateThrottle, )
@api_group_check
def post(self, request, group, format=None):
# add group repo
username = request.user.username
repo_name = request.data.get("name", None)
repo_desc = request.data.get("desc", '')
passwd = request.data.get("passwd", None)
# to avoid 'Bad magic' error when create repo, passwd should be 'None'
# not an empty string when create unencrypted repo
if not passwd:
passwd = None
if (passwd is not None) and (not config.ENABLE_ENCRYPTED_LIBRARY):
return api_error(status.HTTP_403_FORBIDDEN,
'NOT allow to create encrypted library.')
permission = request.data.get("permission", 'r')
if permission not in get_available_repo_perms():
return api_error(status.HTTP_400_BAD_REQUEST, 'Invalid permission')
org_id = -1
if is_org_context(request):
org_id = request.user.org.org_id
repo_id = seafile_api.create_org_repo(repo_name, repo_desc,
username, org_id, passwd,
enc_version=settings.ENCRYPTED_LIBRARY_VERSION)
repo = seafile_api.get_repo(repo_id)
seafile_api.add_org_group_repo(repo_id, org_id, group.id,
username, permission)
else:
if is_pro_version() and ENABLE_STORAGE_CLASSES:
if STORAGE_CLASS_MAPPING_POLICY in ('USER_SELECT',
'ROLE_BASED'):
storages = get_library_storages(request)
storage_id = request.data.get("storage_id", None)
if storage_id and storage_id not in [s['storage_id'] for s in storages]:
error_msg = 'storage_id invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
repo_id = seafile_api.create_repo(repo_name,
repo_desc, username, passwd, storage_id,
enc_version=settings.ENCRYPTED_LIBRARY_VERSION)
else:
# STORAGE_CLASS_MAPPING_POLICY == 'REPO_ID_MAPPING'
repo_id = seafile_api.create_repo(repo_name,
repo_desc, username, passwd,
enc_version=settings.ENCRYPTED_LIBRARY_VERSION)
else:
repo_id = seafile_api.create_repo(repo_name,
repo_desc, username, passwd,
enc_version=settings.ENCRYPTED_LIBRARY_VERSION)
repo = seafile_api.get_repo(repo_id)
seafile_api.set_group_repo(repo.id, group.id, username, permission)
library_template = request.data.get("library_template", '')
repo_created.send(sender=None,
org_id=org_id,
creator=username,
repo_id=repo_id,
repo_name=repo_name,
library_template=library_template)
group_repo = {
"id": repo.id,
"name": repo.name,
"desc": repo.desc,
"size": repo.size,
"size_formatted": filesizeformat(repo.size),
"mtime": repo.last_modified,
"mtime_relative": translate_seahub_time(repo.last_modified),
"encrypted": repo.encrypted,
"permission": permission,
"owner": username,
"owner_nickname": email2nickname(username),
"owner_name": email2nickname(username),
"share_from_me": True,
"modifier_email": repo.last_modifier,
"modifier_contact_email": email2contact_email(repo.last_modifier),
"modifier_name": email2nickname(repo.last_modifier),
}
return Response(group_repo, status=200)
@api_group_check
def get(self, request, group, format=None):
username = request.user.username
if group.is_pub:
if not request.user.is_staff and not is_group_member(group.id, username):
return api_error(status.HTTP_403_FORBIDDEN, 'Permission denied.')
if is_org_context(request):
org_id = request.user.org.org_id
repos = seafile_api.get_org_group_repos(org_id, group.id)
else:
repos = seafile_api.get_repos_by_group(group.id)
repos.sort(lambda x, y: cmp(y.last_modified, x.last_modified))
group.is_staff = is_group_staff(group, request.user)
# Use dict to reduce memcache fetch cost in large for-loop.
contact_email_dict = {}
nickname_dict = {}
owner_set = set([x.user for x in repos])
modifiers_set = set([x.modifier for x in repos])
for e in owner_set | modifiers_set:
if e not in contact_email_dict:
contact_email_dict[e] = email2contact_email(e)
if e not in nickname_dict:
nickname_dict[e] = email2nickname(e)
# Get repos that is admin permission in group.
admin_repos = ExtraGroupsSharePermission.objects.\
get_repos_with_admin_permission(group.id)
repos_json = []
for r in repos:
group_name_of_address_book_library = ''
if '@seafile_group' in r.user:
group_id_of_address_book_library = get_group_id_by_repo_owner(r.user)
group_name_of_address_book_library = group_id_to_name(group_id_of_address_book_library)
repo = {
"id": r.id,
"name": r.name,
"size": r.size,
"size_formatted": filesizeformat(r.size),
"mtime": r.last_modified,
"mtime_relative": translate_seahub_time(r.last_modified),
"encrypted": r.encrypted,
"permission": r.permission,
"owner": r.user,
"owner_nickname": nickname_dict.get(r.user, ''),
"owner_name": nickname_dict.get(r.user, ''),
"share_from_me": True if username == r.user else False,
"modifier_email": r.last_modifier,
"modifier_contact_email": contact_email_dict.get(r.last_modifier, ''),
"modifier_name": nickname_dict.get(r.last_modifier, ''),
"is_admin": r.id in admin_repos,
"group_name": group_name_of_address_book_library,
}
repos_json.append(repo)
req_from = request.GET.get('from', "")
if req_from == 'web':
return Response({"is_staff": group.is_staff, "repos": repos_json})
else:
return Response(repos_json)
class GroupRepo(APIView):
authentication_classes = (TokenAuthentication, SessionAuthentication)
permission_classes = (IsAuthenticated,)
throttle_classes = (UserRateThrottle, )
@api_group_check
def delete(self, request, group, repo_id, format=None):
username = request.user.username
group_id = group.id
# only admin or owner can delete share record.
repo_owner = get_repo_owner(request, repo_id)
if not group.is_staff and repo_owner != username and not is_repo_admin(username, repo_id):
return api_error(status.HTTP_403_FORBIDDEN, 'Permission denied.')
is_org = seaserv.is_org_group(group_id)
repo = seafile_api.get_group_shared_repo_by_path(repo_id, None, group_id, is_org)
permission = check_group_share_in_permission(repo_id, group_id, is_org)
if is_org:
org_id = seaserv.get_org_id_by_group(group_id)
seaserv.del_org_group_repo(repo_id, org_id, group_id)
else:
seafile_api.unset_group_repo(repo_id, group_id, username)
# delete extra share permission
ExtraGroupsSharePermission.objects.delete_share_permission(repo_id, group_id)
if repo.is_virtual:
send_perm_audit_msg('delete-repo-perm', username, group_id,
repo.origin_repo_id, repo.origin_path, permission)
else:
send_perm_audit_msg('delete-repo-perm', username, group_id,
repo_id, '/', permission)
return HttpResponse(json.dumps({'success': True}), status=200,
content_type=json_content_type)
class UserAvatarView(APIView):
authentication_classes = (TokenAuthentication, SessionAuthentication)
permission_classes = (IsAuthenticated,)
throttle_classes = (UserRateThrottle, )
def get(self, request, user, size, format=None):
url, is_default, date_uploaded = api_avatar_url(user, int(size))
ret = {
"url": url,
"is_default": is_default,
"mtime": get_timestamp(date_uploaded) }
return Response(ret)
class GroupAvatarView(APIView):
authentication_classes = (TokenAuthentication, )
permission_classes = (IsAuthenticated,)
throttle_classes = (UserRateThrottle, )
def get(self, request, group_id, size, format=None):
url, is_default, date_uploaded = api_grp_avatar_url(group_id, int(size))
ret = {
"url": request.build_absolute_uri(url),
"is_default": is_default,
"mtime": get_timestamp(date_uploaded)}
return Response(ret)
class RepoHistoryChange(APIView):
authentication_classes = (TokenAuthentication, )
permission_classes = (IsAuthenticated,)
throttle_classes = (UserRateThrottle, )
def get(self, request, repo_id, format=None):
repo = get_repo(repo_id)
if not repo:
return HttpResponse(json.dumps({"err": 'Library does not exist'}),
status=400,
content_type=json_content_type)
if not check_folder_permission(request, repo_id, '/'):
return api_error(status.HTTP_403_FORBIDDEN, 'Permission denied.')
commit_id = request.GET.get('commit_id', '')
if not commit_id:
return HttpResponse(json.dumps({"err": 'Invalid argument'}),
status=400,
content_type=json_content_type)
details = get_diff_details(repo_id, '', commit_id)
return HttpResponse(json.dumps(details),
content_type=json_content_type)
# based on views/file.py::office_convert_query_status
class OfficeConvertQueryStatus(APIView):
authentication_classes = (TokenAuthentication, )
permission_classes = (IsAuthenticated, )
throttle_classes = (UserRateThrottle, )
def get(self, request, format=None):
if not HAS_OFFICE_CONVERTER:
return api_error(status.HTTP_404_NOT_FOUND, 'Office converter not enabled.')
content_type = 'application/json; charset=utf-8'
ret = {'success': False}
file_id = request.GET.get('file_id', '')
if len(file_id) != 40:
ret['error'] = 'invalid param'
else:
try:
d = query_office_convert_status(file_id)
if d.error:
ret['error'] = d.error
else:
ret['success'] = True
ret['status'] = d.status
except Exception, e:
logging.exception('failed to call query_office_convert_status')
ret['error'] = str(e)
return HttpResponse(json.dumps(ret), content_type=content_type)
# based on views/file.py::view_file and views/file.py::handle_document
class OfficeGenerateView(APIView):
authentication_classes = (TokenAuthentication, )
permission_classes = (IsAuthenticated, )
throttle_classes = (UserRateThrottle, )
def get(self, request, repo_id, format=None):
username = request.user.username
# check arguments
repo = get_repo(repo_id)
if not repo:
return api_error(status.HTTP_404_NOT_FOUND, 'Library not found.')
path = request.GET.get('p', '/').rstrip('/')
commit_id = request.GET.get('commit_id', None)
if commit_id:
try:
obj_id = seafserv_threaded_rpc.get_file_id_by_commit_and_path(
repo.id, commit_id, path)
except:
return api_error(status.HTTP_404_NOT_FOUND, 'Revision not found.')
else:
try:
obj_id = seafile_api.get_file_id_by_path(repo_id, path)
except:
return api_error(status.HTTP_404_NOT_FOUND, 'File not found.')
if not obj_id:
return api_error(status.HTTP_404_NOT_FOUND, 'File not found.')
# Check whether user has permission to view file and get file raw path,
# render error page if permission deny.
raw_path, inner_path, user_perm = get_file_view_path_and_perm(request,
repo_id,
obj_id, path)
if not user_perm:
return api_error(status.HTTP_403_FORBIDDEN, 'You do not have permission to view this file.')
u_filename = os.path.basename(path)
filetype, fileext = get_file_type_and_ext(u_filename)
if filetype != DOCUMENT:
return api_error(status.HTTP_400_BAD_REQUEST, 'File is not a convertable document')
ret_dict = {}
if HAS_OFFICE_CONVERTER:
err = prepare_converted_html(inner_path, obj_id, fileext, ret_dict)
# populate return value dict
ret_dict['err'] = err
ret_dict['obj_id'] = obj_id
else:
ret_dict['filetype'] = 'Unknown'
return HttpResponse(json.dumps(ret_dict), status=200, content_type=json_content_type)
class ThumbnailView(APIView):
authentication_classes = (TokenAuthentication,)
permission_classes = (IsAuthenticated,)
throttle_classes = (UserRateThrottle, )
def get(self, request, repo_id):
repo = get_repo(repo_id)
if not repo:
return api_error(status.HTTP_404_NOT_FOUND, 'Library not found.')
size = request.GET.get('size', None)
if size is None:
return api_error(status.HTTP_400_BAD_REQUEST, 'Size is missing.')
try:
size = int(size)
except ValueError as e:
logger.error(e)
return api_error(status.HTTP_400_BAD_REQUEST, 'Invalid size.')
path = request.GET.get('p', None)
obj_id = get_file_id_by_path(repo_id, path)
if path is None or obj_id is None:
return api_error(status.HTTP_400_BAD_REQUEST, 'Wrong path.')
if repo.encrypted or not ENABLE_THUMBNAIL or \
check_folder_permission(request, repo_id, path) is None:
return api_error(status.HTTP_403_FORBIDDEN, 'Permission denied.')
success, status_code = generate_thumbnail(request, repo_id, size, path)
if success:
thumbnail_dir = os.path.join(THUMBNAIL_ROOT, str(size))
thumbnail_file = os.path.join(thumbnail_dir, obj_id)
try:
with open(thumbnail_file, 'rb') as f:
thumbnail = f.read()
return HttpResponse(thumbnail, 'image/' + THUMBNAIL_EXTENSION)
except IOError as e:
logger.error(e)
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, 'Failed to get thumbnail.')
else:
if status_code == 400:
return api_error(status.HTTP_400_BAD_REQUEST, "Invalid argument")
if status_code == 403:
return api_error(status.HTTP_403_FORBIDDEN, 'Forbidden')
if status_code == 500:
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, 'Failed to generate thumbnail.')
_REPO_ID_PATTERN = re.compile(r'[-0-9a-f]{36}')
class RepoTokensView(APIView):
authentication_classes = (TokenAuthentication,)
permission_classes = (IsAuthenticated,)
throttle_classes = (UserRateThrottle,)
@json_response
def get(self, request, format=None):
repos_id_str = request.GET.get('repos', None)
if not repos_id_str:
return api_error(status.HTTP_400_BAD_REQUEST, "You must specify libaries ids")
repos_id = [repo_id for repo_id in repos_id_str.split(',') if repo_id]
if any([not _REPO_ID_PATTERN.match(repo_id) for repo_id in repos_id]):
return api_error(status.HTTP_400_BAD_REQUEST, "Libraries ids are invalid")
tokens = {}
for repo_id in repos_id:
repo = seafile_api.get_repo(repo_id)
if not repo:
continue
if not check_folder_permission(request, repo.id, '/'):
continue
tokens[repo_id] = seafile_api.generate_repo_token(repo_id, request.user.username)
return tokens
class OrganizationView(APIView):
authentication_classes = (TokenAuthentication, )
permission_classes = (IsAdminUser, )
throttle_classes = (UserRateThrottle, )
def post(self, request, format=None):
if not CLOUD_MODE or not MULTI_TENANCY:
error_msg = 'Feature is not enabled.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
username = request.POST.get('username', None)
password = request.POST.get('password', None)
org_name = request.POST.get('org_name', None)
prefix = request.POST.get('prefix', None)
quota = request.POST.get('quota', None)
member_limit = request.POST.get('member_limit', ORG_MEMBER_QUOTA_DEFAULT)
if not org_name or not username or not password or \
not prefix or not quota or not member_limit:
return api_error(status.HTTP_400_BAD_REQUEST, "Missing argument")
if not is_valid_username(username):
return api_error(status.HTTP_400_BAD_REQUEST, "Email is not valid")
try:
quota_mb = int(quota)
except ValueError as e:
logger.error(e)
return api_error(status.HTTP_400_BAD_REQUEST, "Quota is not valid")
try:
User.objects.get(email = username)
user_exist = True
except User.DoesNotExist:
user_exist = False
if user_exist:
return api_error(status.HTTP_400_BAD_REQUEST, "A user with this email already exists")
slug_re = re.compile(r'^[-a-zA-Z0-9_]+$')
if not slug_re.match(prefix):
return api_error(status.HTTP_400_BAD_REQUEST, "URL prefix can only be letters(a-z), numbers, and the underscore character")
if ccnet_threaded_rpc.get_org_by_url_prefix(prefix):
return api_error(status.HTTP_400_BAD_REQUEST, "An organization with this prefix already exists")
try:
User.objects.create_user(username, password, is_staff=False, is_active=True)
create_org(org_name, prefix, username)
org = ccnet_threaded_rpc.get_org_by_url_prefix(prefix)
org_id = org.org_id
# set member limit
from seahub_extra.organizations.models import OrgMemberQuota
OrgMemberQuota.objects.set_quota(org_id, member_limit)
# set quota
quota = quota_mb * get_file_size_unit('MB')
seafserv_threaded_rpc.set_org_quota(org_id, quota)
org_info = {}
org_info['org_id'] = org_id
org_info['org_name'] = org.org_name
org_info['ctime'] = timestamp_to_isoformat_timestr(org.ctime)
org_info['org_url_prefix'] = org.url_prefix
creator = org.creator
org_info['creator_email'] = creator
org_info['creator_name'] = email2nickname(creator)
org_info['creator_contact_email'] = email2contact_email(creator)
return Response(org_info, status=status.HTTP_201_CREATED)
except Exception as e:
logger.error(e)
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, "Internal error")
class RepoDownloadSharedLinks(APIView):
authentication_classes = (TokenAuthentication, SessionAuthentication)
permission_classes = (IsAuthenticated, )
throttle_classes = (UserRateThrottle, )
def get(self, request, repo_id, format=None):
repo = get_repo(repo_id)
if not repo:
error_msg = 'Library %s not found.' % repo_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
org_id = None
if is_org_context(request):
org_id = request.user.org.org_id
# check permission
if org_id:
repo_owner = seafile_api.get_org_repo_owner(repo_id)
else:
repo_owner = seafile_api.get_repo_owner(repo_id)
if request.user.username != repo_owner or repo.is_virtual:
error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
shared_links = []
fileshares = FileShare.objects.filter(repo_id=repo_id)
for fs in fileshares:
size = None
shared_link = {}
if fs.is_file_share_link():
path = fs.path.rstrip('/') # Normalize file path
if seafile_api.get_file_id_by_path(repo.id, fs.path) is None:
continue
obj_id = seafile_api.get_file_id_by_path(repo_id, path)
size = seafile_api.get_file_size(repo.store_id, repo.version, obj_id)
else:
path = fs.path
if path[-1] != '/': # Normalize dir path
path += '/'
if seafile_api.get_dir_id_by_path(repo.id, fs.path) is None:
continue
shared_link['create_by'] = fs.username
shared_link['creator_name'] = email2nickname(fs.username)
shared_link['create_time'] = datetime_to_isoformat_timestr(fs.ctime)
shared_link['token'] = fs.token
shared_link['path'] = path
shared_link['name'] = os.path.basename(path.rstrip('/')) if path != '/' else '/'
shared_link['view_count'] = fs.view_cnt
shared_link['share_type'] = fs.s_type
shared_link['size'] = size if size else ''
shared_links.append(shared_link)
return Response(shared_links)
class RepoDownloadSharedLink(APIView):
authentication_classes = (TokenAuthentication, SessionAuthentication)
permission_classes = (IsAuthenticated, )
throttle_classes = (UserRateThrottle, )
def delete(self, request, repo_id, token, format=None):
repo = get_repo(repo_id)
if not repo:
error_msg = 'Library %s not found.' % repo_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
org_id = None
if is_org_context(request):
org_id = request.user.org.org_id
# check permission
if org_id:
repo_owner = seafile_api.get_org_repo_owner(repo_id)
else:
repo_owner = seafile_api.get_repo_owner(repo_id)
if request.user.username != repo_owner or repo.is_virtual:
error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
try:
link = FileShare.objects.get(token=token)
except FileShare.DoesNotExist:
error_msg = 'Link %s not found.' % token
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
link.delete()
result = {'success': True}
return Response(result)
class RepoUploadSharedLinks(APIView):
authentication_classes = (TokenAuthentication, SessionAuthentication)
permission_classes = (IsAuthenticated, )
throttle_classes = (UserRateThrottle, )
def get(self, request, repo_id, format=None):
repo = get_repo(repo_id)
if not repo:
error_msg = 'Library %s not found.' % repo_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
org_id = None
if is_org_context(request):
org_id = request.user.org.org_id
# check permission
if org_id:
repo_owner = seafile_api.get_org_repo_owner(repo_id)
else:
repo_owner = seafile_api.get_repo_owner(repo_id)
if request.user.username != repo_owner or repo.is_virtual:
error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
shared_links = []
fileshares = UploadLinkShare.objects.filter(repo_id=repo_id)
for fs in fileshares:
shared_link = {}
path = fs.path
if path[-1] != '/': # Normalize dir path
path += '/'
if seafile_api.get_dir_id_by_path(repo.id, fs.path) is None:
continue
shared_link['create_by'] = fs.username
shared_link['creator_name'] = email2nickname(fs.username)
shared_link['create_time'] = datetime_to_isoformat_timestr(fs.ctime)
shared_link['token'] = fs.token
shared_link['path'] = path
shared_link['name'] = os.path.basename(path.rstrip('/')) if path != '/' else '/'
shared_link['view_count'] = fs.view_cnt
shared_links.append(shared_link)
return Response(shared_links)
class RepoUploadSharedLink(APIView):
authentication_classes = (TokenAuthentication, SessionAuthentication)
permission_classes = (IsAuthenticated, )
throttle_classes = (UserRateThrottle, )
def delete(self, request, repo_id, token, format=None):
repo = get_repo(repo_id)
if not repo:
error_msg = 'Library %s not found.' % repo_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
org_id = None
if is_org_context(request):
org_id = request.user.org.org_id
# check permission
if org_id:
repo_owner = seafile_api.get_org_repo_owner(repo_id)
else:
repo_owner = seafile_api.get_repo_owner(repo_id)
if request.user.username != repo_owner or repo.is_virtual:
error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
try:
link = UploadLinkShare.objects.get(token=token)
except FileShare.DoesNotExist:
error_msg = 'Link %s not found.' % token
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
link.delete()
result = {'success': True}
return Response(result)
class RepoUserFolderPerm(APIView):
authentication_classes = (TokenAuthentication, SessionAuthentication)
permission_classes = (IsAuthenticated,)
throttle_classes = (UserRateThrottle,)
def _get_user_folder_perm_info(self, email, repo_id, path, perm):
result = {}
if email and repo_id and path and perm:
result['repo_id'] = repo_id
result['user_email'] = email
result['user_name'] = email2nickname(email)
result['folder_path'] = path
result['folder_name'] = path if path == '/' else os.path.basename(path.rstrip('/'))
result['permission'] = perm
return result
def get(self, request, repo_id, format=None):
""" List repo user folder perms (by folder_path).
Permission checking:
1. ( repo owner | admin ) & pro edition & enable folder perm.
"""
# resource check
repo = seafile_api.get_repo(repo_id)
if not repo:
error_msg = 'Library %s not found.' % repo_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
# permission check
if is_org_context(request):
repo_owner = seafile_api.get_org_repo_owner(repo_id)
else:
repo_owner = seafile_api.get_repo_owner(repo_id)
username = request.user.username
if not (is_pro_version() and can_set_folder_perm_by_user(username, repo, repo_owner)):
error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
# get perm list
results = []
path = request.GET.get('folder_path', None)
folder_perms = seafile_api.list_folder_user_perm_by_repo(repo_id)
for perm in folder_perms:
result = {}
if path:
if path == perm.path:
result = self._get_user_folder_perm_info(
perm.user, perm.repo_id, perm.path, perm.permission)
else:
result = self._get_user_folder_perm_info(
perm.user, perm.repo_id, perm.path, perm.permission)
if result:
results.append(result)
return Response(results)
def post(self, request, repo_id, format=None):
""" Add repo user folder perm.
Permission checking:
1. ( repo owner | admin ) & pro edition & enable folder perm.
"""
# argument check
path = request.data.get('folder_path', None)
if not path:
error_msg = 'folder_path invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
perm = request.data.get('permission', None)
if not perm or perm not in get_available_repo_perms():
error_msg = 'permission invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
# resource check
repo = seafile_api.get_repo(repo_id)
if not repo:
error_msg = 'Library %s not found.' % repo_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
path = path.rstrip('/') if path != '/' else path
if not seafile_api.get_dir_id_by_path(repo_id, path):
error_msg = 'Folder %s not found.' % path
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
# permission check
if is_org_context(request):
repo_owner = seafile_api.get_org_repo_owner(repo_id)
else:
repo_owner = seafile_api.get_repo_owner(repo_id)
username = request.user.username
if not (is_pro_version() and can_set_folder_perm_by_user(username, repo, repo_owner)):
error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
# add repo user folder perm
result = {}
result['failed'] = []
result['success'] = []
users = request.data.getlist('user_email')
for user in users:
if not is_valid_username(user):
result['failed'].append({
'user_email': user,
'error_msg': 'user_email invalid.'
})
continue
try:
User.objects.get(email=user)
except User.DoesNotExist:
result['failed'].append({
'user_email': user,
'error_msg': 'User %s not found.' % user
})
continue
permission = seafile_api.get_folder_user_perm(repo_id, path, user)
if permission:
result['failed'].append({
'user_email': user,
'error_msg': 'Permission already exists.'
})
continue
try:
seafile_api.add_folder_user_perm(repo_id, path, perm, user)
send_perm_audit_msg('add-repo-perm', username, user, repo_id, path, perm)
except SearpcError as e:
logger.error(e)
result['failed'].append({
'user_email': user,
'error_msg': 'Internal Server Error'
})
new_perm = seafile_api.get_folder_user_perm(repo_id, path, user)
new_perm_info = self._get_user_folder_perm_info(
user, repo_id, path, new_perm)
result['success'].append(new_perm_info)
return Response(result)
def put(self, request, repo_id, format=None):
""" Modify repo user folder perm.
Permission checking:
1. ( repo owner | admin ) & pro edition & enable folder perm.
"""
# argument check
path = request.data.get('folder_path', None)
if not path:
error_msg = 'folder_path invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
perm = request.data.get('permission', None)
if not perm or perm not in get_available_repo_perms():
error_msg = 'permission invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
user = request.data.get('user_email', None)
if not user:
error_msg = 'user_email invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
# resource check
repo = seafile_api.get_repo(repo_id)
if not repo:
error_msg = 'Library %s not found.' % repo_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
path = path.rstrip('/') if path != '/' else path
if not seafile_api.get_dir_id_by_path(repo_id, path):
error_msg = 'Folder %s not found.' % path
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
try:
User.objects.get(email=user)
except User.DoesNotExist:
error_msg = 'User %s not found.' % user
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
# permission check
if is_org_context(request):
repo_owner = seafile_api.get_org_repo_owner(repo_id)
else:
repo_owner = seafile_api.get_repo_owner(repo_id)
username = request.user.username
if not (is_pro_version() and can_set_folder_perm_by_user(username, repo, repo_owner)):
error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
permission = seafile_api.get_folder_user_perm(repo_id, path, user)
if not permission:
error_msg = 'Folder permission not found.'
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
# modify permission
try:
seafile_api.set_folder_user_perm(repo_id, path, perm, user)
send_perm_audit_msg('modify-repo-perm', username, user, repo_id, path, perm)
new_perm = seafile_api.get_folder_user_perm(repo_id, path, user)
result = self._get_user_folder_perm_info(user, repo_id, path, new_perm)
return Response(result)
except SearpcError as e:
logger.error(e)
error_msg = 'Internal Server Error'
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
def delete(self, request, repo_id, format=None):
""" Remove repo user folder perms.
Permission checking:
1. ( repo owner | admin ) & pro edition & enable folder perm.
"""
# argument check
user = request.data.get('user_email', None)
path = request.data.get('folder_path', None)
if not user:
error_msg = 'user_email invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
if not path:
error_msg = 'folder_path invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
# resource check
repo = seafile_api.get_repo(repo_id)
if not repo:
error_msg = 'Library %s not found.' % repo_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
try:
User.objects.get(email=user)
except User.DoesNotExist:
error_msg = 'User %s not found.' % user
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
# permission check
if is_org_context(request):
repo_owner = seafile_api.get_org_repo_owner(repo_id)
else:
repo_owner = seafile_api.get_repo_owner(repo_id)
username = request.user.username
if not (is_pro_version() and can_set_folder_perm_by_user(username, repo, repo_owner)):
error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
# delete permission
path = path.rstrip('/') if path != '/' else path
permission = seafile_api.get_folder_user_perm(repo_id, path, user)
if not permission:
return Response({'success': True})
try:
seafile_api.rm_folder_user_perm(repo_id, path, user)
send_perm_audit_msg('delete-repo-perm', username,
user, repo_id, path, permission)
return Response({'success': True})
except SearpcError as e:
logger.error(e)
error_msg = 'Internal Server Error'
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
class RepoGroupFolderPerm(APIView):
authentication_classes = (TokenAuthentication, SessionAuthentication)
permission_classes = (IsAuthenticated,)
throttle_classes = (UserRateThrottle,)
def _get_group_folder_perm_info(self, group_id, repo_id, path, perm):
result = {}
if group_id and repo_id and path and perm:
group = ccnet_api.get_group(group_id)
result['repo_id'] = repo_id
result['group_id'] = group_id
result['group_name'] = group.group_name
result['folder_path'] = path
result['folder_name'] = path if path == '/' else os.path.basename(path.rstrip('/'))
result['permission'] = perm
return result
def get(self, request, repo_id, format=None):
""" List repo group folder perms (by folder_path).
Permission checking:
1. ( repo owner | admin ) & pro edition & enable folder perm.
"""
# resource check
repo = seafile_api.get_repo(repo_id)
if not repo:
error_msg = 'Library %s not found.' % repo_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
# permission check
if is_org_context(request):
repo_owner = seafile_api.get_org_repo_owner(repo_id)
else:
repo_owner = seafile_api.get_repo_owner(repo_id)
username = request.user.username
if not (is_pro_version() and can_set_folder_perm_by_user(username, repo, repo_owner)):
error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
results = []
path = request.GET.get('folder_path', None)
group_folder_perms = seafile_api.list_folder_group_perm_by_repo(repo_id)
for perm in group_folder_perms:
result = {}
if path:
if path == perm.path:
result = self._get_group_folder_perm_info(
perm.group_id, perm.repo_id, perm.path,
perm.permission)
else:
result = self._get_group_folder_perm_info(
perm.group_id, perm.repo_id, perm.path,
perm.permission)
if result:
results.append(result)
return Response(results)
def post(self, request, repo_id, format=None):
""" Add repo group folder perm.
Permission checking:
1. ( repo owner | admin ) & pro edition & enable folder perm.
"""
# argument check
path = request.data.get('folder_path', None)
if not path:
error_msg = 'folder_path invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
perm = request.data.get('permission', None)
if not perm or perm not in get_available_repo_perms():
error_msg = 'permission invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
# resource check
repo = seafile_api.get_repo(repo_id)
if not repo:
error_msg = 'Library %s not found.' % repo_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
path = path.rstrip('/') if path != '/' else path
if not seafile_api.get_dir_id_by_path(repo_id, path):
error_msg = 'Folder %s not found.' % path
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
# permission check
if is_org_context(request):
repo_owner = seafile_api.get_org_repo_owner(repo_id)
else:
repo_owner = seafile_api.get_repo_owner(repo_id)
username = request.user.username
if not (is_pro_version() and can_set_folder_perm_by_user(username, repo, repo_owner)):
error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
result = {}
result['failed'] = []
result['success'] = []
group_ids = request.data.getlist('group_id')
for group_id in group_ids:
try:
group_id = int(group_id)
except ValueError:
result['failed'].append({
'group_id': group_id,
'error_msg': 'group_id invalid.'
})
continue
if not ccnet_api.get_group(group_id):
result['failed'].append({
'group_id': group_id,
'error_msg': 'Group %s not found.' % group_id
})
continue
permission = seafile_api.get_folder_group_perm(repo_id, path, group_id)
if permission:
result['failed'].append({
'group_id': group_id,
'error_msg': 'Permission already exists.'
})
continue
try:
seafile_api.add_folder_group_perm(repo_id, path, perm, group_id)
send_perm_audit_msg('add-repo-perm', username, group_id, repo_id, path, perm)
except SearpcError as e:
logger.error(e)
result['failed'].append({
'group_id': group_id,
'error_msg': 'Internal Server Error'
})
new_perm = seafile_api.get_folder_group_perm(repo_id, path, group_id)
new_perm_info = self._get_group_folder_perm_info(
group_id, repo_id, path, new_perm)
result['success'].append(new_perm_info)
return Response(result)
def put(self, request, repo_id, format=None):
""" Modify repo group folder perm.
Permission checking:
1. ( repo owner | admin ) & pro edition & enable folder perm.
"""
# argument check
path = request.data.get('folder_path', None)
if not path:
error_msg = 'folder_path invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
perm = request.data.get('permission', None)
if not perm or perm not in get_available_repo_perms():
error_msg = 'permission invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
group_id = request.data.get('group_id')
if not group_id:
error_msg = 'group_id invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
try:
group_id = int(group_id)
except ValueError:
error_msg = 'group_id invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
# resource check
repo = seafile_api.get_repo(repo_id)
if not repo:
error_msg = 'Library %s not found.' % repo_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
path = path.rstrip('/') if path != '/' else path
if not seafile_api.get_dir_id_by_path(repo_id, path):
error_msg = 'Folder %s not found.' % path
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
if not ccnet_api.get_group(group_id):
error_msg = 'Group %s not found.' % group_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
# permission check
if is_org_context(request):
repo_owner = seafile_api.get_org_repo_owner(repo_id)
else:
repo_owner = seafile_api.get_repo_owner(repo_id)
username = request.user.username
if not (is_pro_version() and can_set_folder_perm_by_user(username, repo, repo_owner)):
error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
permission = seafile_api.get_folder_group_perm(repo_id, path, group_id)
if not permission:
error_msg = 'Folder permission not found.'
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
# modify permission
try:
seafile_api.set_folder_group_perm(repo_id, path, perm, group_id)
send_perm_audit_msg('modify-repo-perm', username, group_id, repo_id, path, perm)
new_perm = seafile_api.get_folder_group_perm(repo_id, path, group_id)
result = self._get_group_folder_perm_info(group_id, repo_id, path, new_perm)
return Response(result)
except SearpcError as e:
logger.error(e)
error_msg = 'Internal Server Error'
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
def delete(self, request, repo_id, format=None):
""" Remove repo group folder perm.
Permission checking:
1. ( repo owner | admin ) & pro edition & enable folder perm.
"""
# arguments check
group_id = request.data.get('group_id', None)
path = request.data.get('folder_path', None)
if not group_id:
error_msg = 'group_id invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
if not path:
error_msg = 'folder_path invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
try:
group_id = int(group_id)
except ValueError:
error_msg = 'group_id invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
# resource check
if not ccnet_api.get_group(group_id):
error_msg = 'Group %s not found.' % group_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
repo = seafile_api.get_repo(repo_id)
if not repo:
error_msg = 'Library %s not found.' % repo_id
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
# permission check
if is_org_context(request):
repo_owner = seafile_api.get_org_repo_owner(repo_id)
else:
repo_owner = seafile_api.get_repo_owner(repo_id)
username = request.user.username
if not (is_pro_version() and can_set_folder_perm_by_user(username, repo, repo_owner)):
error_msg = 'Permission denied.'
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
# delete permission
path = path.rstrip('/') if path != '/' else path
permission = seafile_api.get_folder_group_perm(repo_id, path, group_id)
if not permission:
return Response({'success': True})
try:
seafile_api.rm_folder_group_perm(repo_id, path, group_id)
send_perm_audit_msg('delete-repo-perm', username, group_id,
repo_id, path, permission)
return Response({'success': True})
except SearpcError as e:
logger.error(e)
error_msg = 'Internal Server Error'
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
class RemoteWipeReportView(APIView):
throttle_classes = (UserRateThrottle,)
@json_response
def post(self, request):
token = request.data.get('token', '')
if not token or len(token) != 40:
error_msg = 'token invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
try:
entry = TokenV2.objects.get(key=token)
except TokenV2.DoesNotExist:
error_msg = 'token %s not found.' % token
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
else:
if not entry.wiped_at:
return api_error(status.HTTP_400_BAD_REQUEST, "invalid device token")
entry.delete()
return {}
| 39.667849
| 135
| 0.598256
|
7951d9c8c972c19b2e97a69a430ace6f9261baea
| 806
|
py
|
Python
|
d22/d22.py
|
panaC/aoc2020
|
f56557dace7ffb127dd5cb65aaaa9545be3aa7fb
|
[
"MIT"
] | null | null | null |
d22/d22.py
|
panaC/aoc2020
|
f56557dace7ffb127dd5cb65aaaa9545be3aa7fb
|
[
"MIT"
] | null | null | null |
d22/d22.py
|
panaC/aoc2020
|
f56557dace7ffb127dd5cb65aaaa9545be3aa7fb
|
[
"MIT"
] | null | null | null |
#! /usr/local/bin/python3
import operator
import sys
from collections import deque
from math import prod
#lns = map(lambda x: map(lambda y: int(y), filter(len, x.split('\n')[1:])), sys.stdin.read().split('\n\n'))
lns = [[int(y) for y in filter(len, x.split('\n')[1:])] for x in sys.stdin.read().split('\n\n')]
print(list(map(list, lns)))
q1 = deque(lns[0])
q2 = deque(lns[1])
while q1 and q2:
v1 = q1.popleft();
v2 = q2.popleft();
if (v1 > v2):
q1.extend([v1, v2])
else:
q2.extend([v2, v1])
print(q1, q2)
q1.reverse()
q2.reverse()
r = [i for i in q1] + [i for i in q2]
r = q1 or q2
z = list(zip(r, range(1, len(r) + 1)))
c = sum(list(map(lambda x: x[0] * x[1], z)))
b = sum(list(map(prod, z)))
v = sum(list(map(prod, enumerate(r, 1))))
print(c == v == b)
print(v)
| 20.666667
| 107
| 0.575682
|
7951d9ded3475ce2adc6a0fdbd7020e128cf4134
| 593
|
py
|
Python
|
ex028.py
|
erikamaylim/Python-CursoemVideo
|
5a6809818c4c55a02ec52379d95f3d20c833df2e
|
[
"MIT"
] | null | null | null |
ex028.py
|
erikamaylim/Python-CursoemVideo
|
5a6809818c4c55a02ec52379d95f3d20c833df2e
|
[
"MIT"
] | null | null | null |
ex028.py
|
erikamaylim/Python-CursoemVideo
|
5a6809818c4c55a02ec52379d95f3d20c833df2e
|
[
"MIT"
] | null | null | null |
'''Escreva um programa que faça o computador "pensar" em um número inteiro entre 0 e 5
e peça para o usuário tentar descobrir qual foi o número escolhido pelo computador.
O programa deve escrever na tela se o usuário venceu ou perdeu.'''
from random import randint
from time import sleep
num = randint(0, 5)
aposta = int(input('Estou pensando em um número de 0 a 5. Qual você acha que é? '))
print(f'{aposta}? Será que vc acertou? Hum, vamos ver...')
sleep(3) #Faz uma pausa de n segundos.
print('AÊ, ACERTOU!' if aposta == num else f'ERROU! Eu pensei no {num}, não no {aposta}, zé ruela!')
| 45.615385
| 100
| 0.726813
|
7951dabb30665d047982d3204f0b912aa2e81695
| 1,913
|
py
|
Python
|
build_scripts/run_tests.py
|
Jrryy/pytype
|
2d2855dc97d5ccee22ad233a83524616c17c44c9
|
[
"Apache-2.0"
] | 3,882
|
2015-03-22T12:17:15.000Z
|
2022-03-31T17:13:20.000Z
|
build_scripts/run_tests.py
|
Jrryy/pytype
|
2d2855dc97d5ccee22ad233a83524616c17c44c9
|
[
"Apache-2.0"
] | 638
|
2015-11-03T06:34:44.000Z
|
2022-03-31T23:41:48.000Z
|
build_scripts/run_tests.py
|
Jrryy/pytype
|
2d2855dc97d5ccee22ad233a83524616c17c44c9
|
[
"Apache-2.0"
] | 301
|
2015-08-14T10:21:17.000Z
|
2022-03-08T11:03:40.000Z
|
#! /usr/bin/python
"""Script to run PyType tests.
Usage:
$> python run_tests.py [TARGET] [TARGET] ...
A TARGET is a fully qualified name of a test target within the PyType
source tree. If no target is specified, all test targets listed in the
CMake files will be run.
"""
import argparse
import sys
import build_utils
def parse_args():
"""Parse the args to this script and return them."""
parser = argparse.ArgumentParser()
parser.add_argument("targets", metavar="TARGET", nargs="*",
help="List of test targets to run.")
parser.add_argument("--fail_fast", "-f", action="store_true", default=False,
help="Fail as soon as one build target fails.")
parser.add_argument("--debug", "-d", action="store_true", default=False,
help="Build targets in the debug mode.")
parser.add_argument("--verbose", "-v", action="store_true", default=False,
help="Print failing test logs to stderr.")
args = parser.parse_args()
for target in args.targets:
if "." in target:
_, target_name = target.rsplit(".", 1)
else:
target_name = target
if not (target_name.startswith("test_") or target_name.endswith("_test")):
sys.exit("The name '%s' is not a valid test target name." % target)
return args
def main():
opts = parse_args()
targets = opts.targets or ["test_all"]
if not build_utils.run_cmake(log_output=True, debug_build=opts.debug):
sys.exit(1)
fail_collector = build_utils.FailCollector()
print("Running tests (build steps will be executed as required) ...\n")
if not build_utils.run_ninja(
targets, fail_collector, opts.fail_fast, opts.verbose):
fail_collector.print_report(opts.verbose)
sys.exit(1)
print("!!! All tests passed !!!\n"
"Some tests might not have been run because they were already passing.")
if __name__ == "__main__":
main()
| 33.561404
| 80
| 0.667015
|
7951db75238c3fc612a364b23507e674aa0d63e8
| 2,121
|
py
|
Python
|
pos_core/urls.py
|
ardzix/pos_cooperative
|
3d85884d50e501a50b6cd1c421d427a0b9373413
|
[
"MIT"
] | 2
|
2018-04-29T19:59:04.000Z
|
2020-01-29T10:32:28.000Z
|
pos_core/urls.py
|
ardzix/pos_cooperative
|
3d85884d50e501a50b6cd1c421d427a0b9373413
|
[
"MIT"
] | 1
|
2020-01-29T10:32:09.000Z
|
2020-01-29T10:32:09.000Z
|
pos_core/urls.py
|
ardzix/pos_cooperative
|
3d85884d50e501a50b6cd1c421d427a0b9373413
|
[
"MIT"
] | null | null | null |
from django.conf.urls import url
from pos_core.views.role import *
from pos_core.views.profile import *
from pos_core.views.investor import *
from pos_core.views.brand import *
from pos_core.views.product import *
from pos_core.views.stock import *
from pos_core.views.discount import *
from pos_core.views.sale import *
from pos_core.views.report import *
urlpatterns = [
url(r'^role/$', RoleView.as_view(), name='role'),
url(r'^role/form/$', RoleFormView.as_view(), name='role-form'),
url(r'^profile/$', ProfileView.as_view(), name='profile'),
url(r'^profile/form/$', ProfileFormView.as_view(), name='profile-form'),
url(r'^investor/$', InvestorView.as_view(), name='investor'),
url(r'^investor/form/$', InvestorFormView.as_view(), name='investor-form'),
url(r'^brand/$', BrandView.as_view(), name='brand'),
url(r'^brand/form/$', BrandFormView.as_view(), name='brand-form'),
url(r'^product/$', ProductView.as_view(), name='product'),
url(r'^product/form/$', ProductFormView.as_view(), name='product-form'),
url(r'^product/ajax/$', ProductAjaxView.as_view(), name='product-ajax'),
url(r'^stock/$', StockView.as_view(), name='stock'),
url(r'^stock/form/$', StockFormView.as_view(), name='stock-form'),
url(r'^discount/$', DiscountView.as_view(), name='discount'),
url(r'^discount/form/$', DiscountFormView.as_view(), name='discount-form'),
url(r'^discount-product/$', DiscountProductView.as_view(), name='discount-product'),
url(r'^discount-product/form/$', DiscountProductFormView.as_view(), name='discount-product-form'),
url(r'^sale/$', SaleView.as_view(), name='sale'),
url(r'^sale/ajax/$', SaleAjaxView.as_view(), name='sale-ajax'),
url(r'^report/$', ReportView.as_view(), name='report'),
url(r'^report/download/$', ReportXLSView.as_view(), name='report-download'),
url(r'^cashback/$', CashbackView.as_view(), name='cashback'),
url(r'^cashback/ajax/$', CashbackAjaxView.as_view(), name='cashback-ajax'),
url(r'^investor/download/$', ReportInvestorXLSView.as_view(), name='investor-download'),
]
| 46.108696
| 102
| 0.677982
|
7951db96c4e6c2507f8f82ea752089e91d4e8438
| 1,928
|
py
|
Python
|
configs/app.default.py
|
lanPN85/flask-template
|
231699db7561a87a92777adfa1d90c8ad69bda19
|
[
"MIT"
] | null | null | null |
configs/app.default.py
|
lanPN85/flask-template
|
231699db7561a87a92777adfa1d90c8ad69bda19
|
[
"MIT"
] | null | null | null |
configs/app.default.py
|
lanPN85/flask-template
|
231699db7561a87a92777adfa1d90c8ad69bda19
|
[
"MIT"
] | null | null | null |
from datetime import timedelta
# This will not affect gunicorn config
HOST = '0.0.0.0'
PORT = 5000
DEBUG = False
PROPAGATE_EXCEPTIONS = True
JWT_ACCESS_TOKEN_EXPIRES = timedelta(minutes=30)
JWT_REFRESH_TOKEN_EXPIRES = timedelta(days=15)
LOGCONFIG = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'request': {
'()': 'logging.Formatter',
'format': '[%(asctime)s]: %(message)s'
},
'standard': {
'()': 'logging.Formatter',
'format': '[%(levelname)s] [%(asctime)s]: %(message)s'
}
},
'handlers': {
'console': {
'class': 'logging.StreamHandler',
'level': 'DEBUG',
'formatter': 'standard',
'stream': 'ext://sys.stderr'
},
'request': {
'class': 'logging.handlers.RotatingFileHandler',
'filename': 'logs/requests.log',
'mode': 'a',
'maxBytes': 5*1024*1024,
'backupCount': 5,
'formatter': 'request'
},
'app': {
'class': 'logging.FileHandler',
'filename': 'logs/app.log',
'mode': 'w',
'formatter': 'standard'
},
'error': {
'class': 'logging.FileHandler',
'filename': 'logs/errors.log',
'mode': 'w',
'formatter': 'standard'
}
},
'loggers': {
'app': {
'handlers': ['console', 'app'],
'level': 'DEBUG'
},
'flask.request': {
'handlers': ['request'],
'level': 'INFO'
},
'flask.error': {
'handlers': ['console', 'app', 'error'],
'level': 'ERROR'
}
}
}
LOGCONFIG_QUEUE = ['flask.request']
LOGCONFIG_REQUESTS_ENABLED = True
LOGCONFIG_REQUESTS_LOGGER = 'flask.request'
LOGCONFIG_REQUESTS_LEVEL = logging.INFO
| 25.706667
| 66
| 0.48444
|
7951db9b0b54d09bcbf7622cc0d71249c576f240
| 543
|
py
|
Python
|
src/discord/operations/abs.py
|
Colk-tech/discoplug
|
76ae4a71d78d6709e8e393958f3f444cb501759c
|
[
"MIT"
] | null | null | null |
src/discord/operations/abs.py
|
Colk-tech/discoplug
|
76ae4a71d78d6709e8e393958f3f444cb501759c
|
[
"MIT"
] | 1
|
2022-03-24T08:30:10.000Z
|
2022-03-24T09:15:11.000Z
|
src/discord/operations/abs.py
|
Colk-tech/discoplug
|
76ae4a71d78d6709e8e393958f3f444cb501759c
|
[
"MIT"
] | null | null | null |
from typing import Dict
from abc import ABCMeta, abstractmethod
from discord import Message
class AbstractOperation(metaclass=ABCMeta):
MY_INDEX: str = ""
IS_AUTHORIZATION_NEEDED: bool = False
@abstractmethod
def __init__(self, message: Message, context: Dict):
self.__message: Message = message
self.__context: Dict = context
@abstractmethod
def is_authorized(self) -> bool:
raise NotImplementedError()
@abstractmethod
async def execute(self):
raise NotImplementedError()
| 23.608696
| 56
| 0.705341
|
7951dbd66d9142601fbddca9af139599d1468a21
| 4,044
|
py
|
Python
|
test/Removed/SourceSignatures/Old/basic.py
|
Valkatraz/scons
|
5e70c65f633dcecc035751c9f0c6f894088df8a0
|
[
"MIT"
] | 1,403
|
2017-11-23T14:24:01.000Z
|
2022-03-30T20:59:39.000Z
|
test/Removed/SourceSignatures/Old/basic.py
|
Valkatraz/scons
|
5e70c65f633dcecc035751c9f0c6f894088df8a0
|
[
"MIT"
] | 3,708
|
2017-11-27T13:47:12.000Z
|
2022-03-29T17:21:17.000Z
|
test/Removed/SourceSignatures/Old/basic.py
|
Valkatraz/scons
|
5e70c65f633dcecc035751c9f0c6f894088df8a0
|
[
"MIT"
] | 281
|
2017-12-01T23:48:38.000Z
|
2022-03-31T15:25:44.000Z
|
#!/usr/bin/env python
#
# __COPYRIGHT__
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
import os
import re
import TestSCons
test = TestSCons.TestSCons(match = TestSCons.match_re_dotall)
base_sconstruct_contents = """\
SetOption('warn', 'deprecated-source-signatures')
def build(env, target, source):
with open(str(target[0]), 'wt') as ofp, open(str(source[0]), 'rt') as ifp:
ofp.write(ifp.read())
B = Builder(action = build)
env = Environment(BUILDERS = { 'B' : B })
env.B(target = 'f1.out', source = 'f1.in')
env.B(target = 'f2.out', source = 'f2.in')
env.B(target = 'f3.out', source = 'f3.in')
env.B(target = 'f4.out', source = 'f4.in')
"""
def write_SConstruct(test, sigtype):
contents = base_sconstruct_contents
if sigtype:
contents = contents + ("\nSourceSignatures('%s')\n" % sigtype)
test.write('SConstruct', contents)
expect = TestSCons.re_escape("""
scons: warning: The env.SourceSignatures() method is deprecated;
\tconvert your build to use the env.Decider() method instead.
""") + TestSCons.file_expr
write_SConstruct(test, 'timestamp')
test.write('f1.in', "f1.in\n")
test.write('f2.in', "f2.in\n")
test.write('f3.in', "f3.in\n")
test.write('f4.in', "f4.in\n")
test.run(arguments = 'f1.out f3.out', stderr = expect)
test.run(arguments = 'f1.out f2.out f3.out f4.out',
stdout = re.escape(test.wrap_stdout("""\
scons: `f1.out' is up to date.
build(["f2.out"], ["f2.in"])
scons: `f3.out' is up to date.
build(["f4.out"], ["f4.in"])
""")),
stderr = expect)
os.utime(test.workpath('f1.in'),
(os.path.getatime(test.workpath('f1.in')),
os.path.getmtime(test.workpath('f1.in'))+10))
os.utime(test.workpath('f3.in'),
(os.path.getatime(test.workpath('f3.in')),
os.path.getmtime(test.workpath('f3.in'))+10))
test.run(arguments = 'f1.out f2.out f3.out f4.out',
stdout = re.escape(test.wrap_stdout("""\
build(["f1.out"], ["f1.in"])
scons: `f2.out' is up to date.
build(["f3.out"], ["f3.in"])
scons: `f4.out' is up to date.
""")),
stderr = expect)
# Switching to content signatures from timestamps should rebuild,
# because we didn't record the content signatures last time.
write_SConstruct(test, 'MD5')
test.not_up_to_date(arguments = 'f1.out f2.out f3.out f4.out', stderr = expect)
test.sleep()
test.write('f1.in', "f1.in\n")
test.write('f2.in', "f2.in\n")
test.write('f3.in', "f3.in\n")
test.write('f4.in', "f4.in\n")
test.up_to_date(arguments = 'f1.out f2.out f3.out f4.out', stderr = None)
test.touch('f1.in', os.path.getmtime(test.workpath('f1.in'))+10)
test.touch('f3.in', os.path.getmtime(test.workpath('f3.in'))+10)
test.up_to_date(arguments = 'f1.out f2.out f3.out f4.out', stderr = None)
write_SConstruct(test, None)
test.up_to_date(arguments = 'f1.out f2.out f3.out f4.out', stderr = None)
test.pass_test()
# Local Variables:
# tab-width:4
# indent-tabs-mode:nil
# End:
# vim: set expandtab tabstop=4 shiftwidth=4:
| 30.636364
| 79
| 0.689664
|
7951dbef69fa032ffab349df72b6cd9c2246c57c
| 12,192
|
py
|
Python
|
tensorflow_graphics/geometry/transformation/tests/euler_test.py
|
ghosalsattam/graphics
|
946aa03b5178d2fc557a81045b84df24af322afd
|
[
"Apache-2.0"
] | null | null | null |
tensorflow_graphics/geometry/transformation/tests/euler_test.py
|
ghosalsattam/graphics
|
946aa03b5178d2fc557a81045b84df24af322afd
|
[
"Apache-2.0"
] | null | null | null |
tensorflow_graphics/geometry/transformation/tests/euler_test.py
|
ghosalsattam/graphics
|
946aa03b5178d2fc557a81045b84df24af322afd
|
[
"Apache-2.0"
] | 1
|
2020-06-04T23:24:40.000Z
|
2020-06-04T23:24:40.000Z
|
# Copyright 2020 The TensorFlow Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Tests for euler-related utiliy functions."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from absl.testing import flagsaver
from absl.testing import parameterized
import numpy as np
import tensorflow as tf
from tensorflow_graphics.geometry.transformation import axis_angle
from tensorflow_graphics.geometry.transformation import euler
from tensorflow_graphics.geometry.transformation import quaternion
from tensorflow_graphics.geometry.transformation import rotation_matrix_3d
from tensorflow_graphics.geometry.transformation.tests import test_data as td
from tensorflow_graphics.geometry.transformation.tests import test_helpers
from tensorflow_graphics.util import test_case
class EulerTest(test_case.TestCase):
@parameterized.parameters(
((3,), (1,)),
((None, 3), (None, 1)),
)
def test_from_axis_angle_exception_not_raised(self, *shapes):
"""Tests that the shape exceptions are not raised."""
self.assert_exception_is_not_raised(euler.from_axis_angle, shapes)
@parameterized.parameters(
("must have exactly 3 dimensions", (None,), (1,)),
("must have exactly 1 dimensions", (3,), (None,)),
)
def test_from_axis_angle_exception_raised(self, error_msg, *shape):
"""Tests that the shape exceptions are raised."""
self.assert_exception_is_raised(euler.from_axis_angle, error_msg, shape)
@flagsaver.flagsaver(tfg_add_asserts_to_graph=False)
def test_from_axis_angle_jacobian_preset(self):
"""Test the Jacobian of the from_axis_angle function."""
x_axis_init, x_angle_init = test_helpers.generate_preset_test_axis_angle()
self.assert_jacobian_is_finite_fn(euler.from_axis_angle,
[x_axis_init, x_angle_init])
@flagsaver.flagsaver(tfg_add_asserts_to_graph=False)
def test_from_axis_angle_jacobian_random(self):
"""Test the Jacobian of the from_axis_angle function."""
x_axis_init, x_angle_init = test_helpers.generate_random_test_axis_angle()
self.assert_jacobian_is_finite_fn(euler.from_axis_angle,
[x_axis_init, x_angle_init])
def test_from_axis_angle_random(self):
"""Checks that Euler angles can be retrieved from an axis-angle."""
random_euler_angles = test_helpers.generate_random_test_euler_angles()
random_matrix = rotation_matrix_3d.from_euler(random_euler_angles)
random_axis, random_angle = axis_angle.from_euler(random_euler_angles)
predicted_matrix = rotation_matrix_3d.from_axis_angle(
random_axis, random_angle)
self.assertAllClose(random_matrix, predicted_matrix, atol=1e-3)
def test_from_axis_angle_preset(self):
"""Checks that Euler angles can be retrieved from axis-angle."""
preset_euler_angles = test_helpers.generate_preset_test_euler_angles()
random_matrix = rotation_matrix_3d.from_euler(preset_euler_angles)
random_axis, random_angle = axis_angle.from_euler(preset_euler_angles)
predicted_matrix = rotation_matrix_3d.from_axis_angle(
random_axis, random_angle)
self.assertAllClose(random_matrix, predicted_matrix, atol=1e-3)
@parameterized.parameters(
(td.ANGLE_90,),
(-td.ANGLE_90,),
)
def test_from_axis_angle_gimbal(self, gimbal_configuration):
"""Checks that from_axis_angle works when Ry = pi/2 or -pi/2."""
random_euler_angles = test_helpers.generate_random_test_euler_angles()
random_euler_angles[..., 1] = gimbal_configuration
random_matrix = rotation_matrix_3d.from_euler(random_euler_angles)
random_axis, random_angle = axis_angle.from_euler(random_euler_angles)
predicted_random_angles = euler.from_axis_angle(random_axis, random_angle)
reconstructed_random_matrices = rotation_matrix_3d.from_euler(
predicted_random_angles)
self.assertAllClose(reconstructed_random_matrices, random_matrix, atol=1e-3)
@parameterized.parameters(
((4,),),
((None, 4),),
)
def test_from_quaternion_exception_not_raised(self, *shape):
"""Tests that the shape exceptions are not raised."""
self.assert_exception_is_not_raised(euler.from_quaternion, shape)
@parameterized.parameters(
("must have exactly 4 dimensions", (None,)),)
def test_from_quaternion_exception_raised(self, error_msg, *shape):
"""Tests that the shape exceptions are raised."""
self.assert_exception_is_raised(euler.from_quaternion, error_msg, shape)
@flagsaver.flagsaver(tfg_add_asserts_to_graph=False)
def test_from_quaternion_jacobian_preset(self):
"""Test the Jacobian of the from_quaternion function."""
x_init = test_helpers.generate_preset_test_quaternions()
self.assert_jacobian_is_finite_fn(euler.from_quaternion, [x_init])
@flagsaver.flagsaver(tfg_add_asserts_to_graph=False)
def test_from_quaternion_jacobian_random(self):
"""Test the Jacobian of the from_quaternion function."""
x_init = test_helpers.generate_random_test_quaternions()
self.assert_jacobian_is_finite_fn(euler.from_quaternion, [x_init])
@parameterized.parameters(
(td.ANGLE_90,),
(-td.ANGLE_90,),
)
def test_from_quaternion_gimbal(self, gimbal_configuration):
"""Checks that from_quaternion works when Ry = pi/2 or -pi/2."""
random_euler_angles = test_helpers.generate_random_test_euler_angles()
random_euler_angles[..., 1] = gimbal_configuration
random_quaternion = quaternion.from_euler(random_euler_angles)
random_matrix = rotation_matrix_3d.from_euler(random_euler_angles)
reconstructed_random_matrices = rotation_matrix_3d.from_quaternion(
random_quaternion)
self.assertAllClose(reconstructed_random_matrices, random_matrix, atol=2e-3)
def test_from_quaternion_preset(self):
"""Checks that Euler angles can be retrieved from quaternions."""
preset_euler_angles = test_helpers.generate_preset_test_euler_angles()
preset_matrix = rotation_matrix_3d.from_euler(preset_euler_angles)
preset_quaternion = quaternion.from_euler(preset_euler_angles)
predicted_matrix = rotation_matrix_3d.from_quaternion(preset_quaternion)
self.assertAllClose(preset_matrix, predicted_matrix, atol=2e-3)
def test_from_quaternion_random(self):
"""Checks that Euler angles can be retrieved from quaternions."""
random_euler_angles = test_helpers.generate_random_test_euler_angles()
random_matrix = rotation_matrix_3d.from_euler(random_euler_angles)
random_quaternion = quaternion.from_rotation_matrix(random_matrix)
predicted_angles = euler.from_quaternion(random_quaternion)
predicted_matrix = rotation_matrix_3d.from_euler(predicted_angles)
self.assertAllClose(random_matrix, predicted_matrix, atol=2e-3)
@parameterized.parameters(
((3, 3),),
((None, 3, 3),),
)
def test_from_rotation_matrix_exception_not_raised(self, *shapes):
"""Tests that the shape exceptions are not raised."""
self.assert_exception_is_not_raised(euler.from_rotation_matrix, shapes)
@parameterized.parameters(
("must have a rank greater than 1", (3,)),
("must have exactly 3 dimensions", (None, 3)),
("must have exactly 3 dimensions", (3, None)),
)
def test_from_rotation_matrix_exception_raised(self, error_msg, *shape):
"""Tests that the shape exceptions are raised."""
self.assert_exception_is_raised(euler.from_rotation_matrix, error_msg,
shape)
@flagsaver.flagsaver(tfg_add_asserts_to_graph=False)
def test_from_rotation_matrix_jacobian_preset(self):
"""Test the Jacobian of the from_rotation_matrix function."""
x_init = test_helpers.generate_preset_test_rotation_matrices_3d()
x = tf.convert_to_tensor(value=x_init)
y = euler.from_rotation_matrix(x)
self.assert_jacobian_is_finite(x, x_init, y)
@flagsaver.flagsaver(tfg_add_asserts_to_graph=False)
def test_from_rotation_matrix_jacobian_random(self):
"""Test the Jacobian of the from_rotation_matrix function."""
x_init = test_helpers.generate_random_test_rotation_matrix_3d()
self.assert_jacobian_is_finite_fn(euler.from_rotation_matrix, [x_init])
def test_from_rotation_matrix_gimbal(self):
"""Testing that Euler angles can be retrieved in Gimbal lock."""
angles = test_helpers.generate_random_test_euler_angles()
angles[..., 1] = np.pi / 2.
matrix = rotation_matrix_3d.from_euler(angles)
predicted_angles = euler.from_rotation_matrix(matrix)
reconstructed_matrices = rotation_matrix_3d.from_euler(predicted_angles)
self.assertAllClose(reconstructed_matrices, matrix, rtol=1e-3)
angles[..., 1] = -np.pi / 2.
matrix = rotation_matrix_3d.from_euler(angles)
predicted_angles = euler.from_rotation_matrix(matrix)
reconstructed_matrices = rotation_matrix_3d.from_euler(predicted_angles)
self.assertAllClose(reconstructed_matrices, matrix, rtol=1e-3)
def test_from_rotation_matrix_preset(self):
"""Tests that Euler angles can be retrieved from rotation matrices."""
matrix = test_helpers.generate_preset_test_rotation_matrices_3d()
predicted_angles = euler.from_rotation_matrix(matrix)
reconstructed_matrices = rotation_matrix_3d.from_euler(predicted_angles)
self.assertAllClose(reconstructed_matrices, matrix, rtol=1e-3)
def test_from_rotation_matrix_random(self):
"""Tests that Euler angles can be retrieved from rotation matrices."""
matrix = test_helpers.generate_random_test_rotation_matrix_3d()
predicted_angles = euler.from_rotation_matrix(matrix)
# There is not a unique mapping from rotation matrices to Euler angles. The
# following constructs the rotation matrices from the `predicted_angles` and
# compares them with `matrix`.
reconstructed_matrices = rotation_matrix_3d.from_euler(predicted_angles)
self.assertAllClose(reconstructed_matrices, matrix, rtol=1e-3)
@parameterized.parameters(
((3,),),
((None, 3),),
)
def test_inverse_exception_not_raised(self, *shape):
"""Tests that the shape exceptions are not raised."""
self.assert_exception_is_not_raised(euler.inverse, shape)
@parameterized.parameters(
("must have exactly 3 dimensions", (None,)),)
def test_inverse_exception_raised(self, error_msg, *shape):
"""Tests that the shape exceptions are raised."""
self.assert_exception_is_raised(euler.inverse, error_msg, shape)
@flagsaver.flagsaver(tfg_add_asserts_to_graph=False)
def test_inverse_jacobian_preset(self):
"""Test the Jacobian of the inverse function."""
x_init = test_helpers.generate_preset_test_euler_angles()
self.assert_jacobian_is_correct_fn(euler.inverse, [x_init])
@flagsaver.flagsaver(tfg_add_asserts_to_graph=False)
def test_inverse_jacobian_random(self):
"""Test the Jacobian of the inverse function."""
x_init = test_helpers.generate_random_test_euler_angles()
self.assert_jacobian_is_correct_fn(euler.inverse, [x_init])
def test_inverse_preset(self):
"""Checks that inverse works as intended."""
preset_euler_angles = test_helpers.generate_preset_test_euler_angles()
prediction = euler.inverse(preset_euler_angles)
groundtruth = -preset_euler_angles
self.assertAllClose(prediction, groundtruth, rtol=1e-3)
def test_inverse_random(self):
"""Checks that inverse works as intended."""
random_euler_angles = test_helpers.generate_random_test_euler_angles()
prediction = euler.inverse(random_euler_angles)
groundtruth = -random_euler_angles
self.assertAllClose(prediction, groundtruth, rtol=1e-3)
if __name__ == "__main__":
test_case.main()
| 41.469388
| 80
| 0.769275
|
7951dc50c257171cefd8de04e4939ea1006573c7
| 1,024
|
py
|
Python
|
award_explore.py
|
diatomsRcool/NSF_awards
|
2943629d68339f24f85e1badb8abf85ee8775839
|
[
"MIT"
] | null | null | null |
award_explore.py
|
diatomsRcool/NSF_awards
|
2943629d68339f24f85e1badb8abf85ee8775839
|
[
"MIT"
] | null | null | null |
award_explore.py
|
diatomsRcool/NSF_awards
|
2943629d68339f24f85e1badb8abf85ee8775839
|
[
"MIT"
] | null | null | null |
import pandas as pd
import numpy as np
data = []
f = range(1,75,1)
for n in f:
print(n)
in_file = open('/Users/annethessen/NSF_awards/award_data/' + str(n) + '.txt', 'r')
next(in_file)
for line in in_file:
line.strip('\n')
row = line.split('\t')
#print(row[0:24])
data.append(row[0:24])
arr = np.array(data) #dtype=['U7','U150','U25','U50','M8','M8','U25','U25','U25','U25','U25','M8','f8','U25','U25','U25','U25','U25','U25','U25','U25','U25','U25','f8','U500'])
labels = ['AwardNumber','Title','NSFOrganization','Program(s)','StartDate','LastAmendmentDate','PrincipalInvestigator','State','Organization','AwardInstrument','ProgramManager','EndDate','AwardedAmountToDate','Co-PIName(s)','PIEmailAddress','OrganizationStreet','OrganizationCity','OrganizationState','OrganizationZip','OrganizationPhone','NSFDirectorate','ProgramElementCode(s)','ProgramReferenceCode(s)','ARRAAmount','Abstract']
df = pd.DataFrame(arr, columns=labels, index=['AwardNumber'])
print('complete')
| 53.894737
| 430
| 0.664063
|
7951dd26439b3a60e35d81d369020f2a56685724
| 5,737
|
py
|
Python
|
twitchbot/modloader.py
|
jostster/PythonTwitchBotFramework
|
931fdac9226b0086b37a011fd7c0265580c87ef0
|
[
"MIT"
] | null | null | null |
twitchbot/modloader.py
|
jostster/PythonTwitchBotFramework
|
931fdac9226b0086b37a011fd7c0265580c87ef0
|
[
"MIT"
] | null | null | null |
twitchbot/modloader.py
|
jostster/PythonTwitchBotFramework
|
931fdac9226b0086b37a011fd7c0265580c87ef0
|
[
"MIT"
] | null | null | null |
import os
import traceback
from inspect import isclass
from typing import Dict
from .util import temp_syspath, get_py_files, get_file_name
from .channel import Channel
from .command import Command
from .config import cfg
from .enums import Event
from .message import Message
from .disabled_mods import is_mod_disabled
from importlib import import_module
__all__ = ('ensure_mods_folder_exists', 'Mod', 'register_mod', 'trigger_mod_event', 'mods',
'load_mods_from_directory', 'mod_exists')
# noinspection PyMethodMayBeStatic
class Mod:
name = 'DEFAULT'
# region events
async def on_enable(self, channel: str):
"""
triggered when the mod is enabled
:param channel: the channel the mod is enabled in
"""
async def on_disable(self, channel: str):
"""
triggered when the mod is disabled
:param channel: the channel the mod is disabled in
"""
async def on_connected(self):
"""
triggered when the bot connects to all the channels specified in the config file
"""
async def on_raw_message(self, msg: Message):
"""
triggered the instant a message is received,
this message can be any message received,
including twitches messages that do not have any useful information
"""
async def on_privmsg_sent(self, msg: str, channel: str, sender: str):
"""
triggered when the bot sends a privmsg
"""
async def on_privmsg_received(self, msg: Message):
"""
triggered when a privmsg is received, is not triggered if the msg is a command
"""
async def on_whisper_sent(self, msg: str, receiver: str, sender: str):
"""
triggered when the bot sends a whisper to someone
"""
async def on_whisper_received(self, msg: Message):
"""
triggered when a user sends the bot a whisper
"""
async def on_permission_check(self, msg: Message, cmd: Command) -> bool:
"""
triggered when a command permission check is requested
:param msg: the message the command was found from
:param cmd: the command that was found
:return: bool indicating if the user has permission to call the command, True = yes, False = no
"""
return True
async def on_before_command_execute(self, msg: Message, cmd: Command) -> bool:
"""
triggered before a command is executed
:return bool, if return value is False, then the command will not be executed
"""
return True
async def on_after_command_execute(self, msg: Message, cmd: Command):
"""
triggered after a command has executed
"""
async def on_bits_donated(self, msg: Message, bits: int):
"""
triggered when a bit donation is posted in chat
"""
async def on_channel_joined(self, channel: Channel):
"""
triggered when the bot joins a channel
"""
async def on_channel_subscription(self, channel: Channel, msg: Message):
"""
triggered when a user subscribes
"""
# endregion
mods: Dict[str, Mod] = {}
def register_mod(mod: Mod) -> bool:
"""
registers a mod globally
:param mod: the mod to register
:return: if registration was successful
"""
if mod.name in mods:
return False
mods[mod.name] = mod
return True
async def trigger_mod_event(event: Event, *args, channel: str = None) -> list:
"""
triggers a event on all mods
if the channel is passed, the it is checked if the mod is enabled for that channel,
if not, the event for that mod is skipped
:param event: the event to raise on all the mods
:param args: the args to pass to the event
:param channel: the channel the event is being raised from
:return: the result of all the mod event calls in a list
"""
async def _missing_function(*ignored):
pass
output = []
for mod in mods.values():
if channel and is_mod_disabled(channel, mod.name):
continue
try:
output.append(await getattr(mod, event.value, _missing_function)(*args))
except Exception as e:
print(f'\nerror has occurred while triggering a event on a mod, details:\n'
f'mod: {mod.name}\n'
f'event: {event}\n'
f'error: {type(e)}\n'
f'reason: {e}\n'
f'stack trace:')
traceback.print_exc()
return output
def ensure_mods_folder_exists():
"""
creates the mod folder if it does not exists
"""
if not os.path.exists(cfg.mods_folder):
os.mkdir(cfg.mods_folder)
def load_mods_from_directory(fullpath):
"""
loads all mods from the given directory, only .py files are loaded
:param fullpath: the path to search for mods to load
"""
print('loading mods from:', fullpath)
with temp_syspath(fullpath):
for file in get_py_files(fullpath):
# we need to import the module to get its attributes
module = import_module(get_file_name(file))
for obj in module.__dict__.values():
# verify the obj is a class, is a subclass of Mod, and is not Mod class itself
if not isclass(obj) or not issubclass(obj, Mod) or obj is Mod:
continue
# create a instance of the mod subclass, then register it
register_mod(obj())
def mod_exists(mod: str) -> bool:
"""
returns of a mod exists
:param mod: the mod to check for
:return: bool indicating if the mod exists
"""
return mod in mods
| 30.194737
| 103
| 0.626286
|
7951dd5f5116d68ccca7ba7459698db48cd15a77
| 357
|
py
|
Python
|
brokenCalculator/BrokenCalc.py
|
evansMeja/Leetcode
|
dac2e00090afad47eb02b30e56848fbc0ea8b57f
|
[
"MIT"
] | null | null | null |
brokenCalculator/BrokenCalc.py
|
evansMeja/Leetcode
|
dac2e00090afad47eb02b30e56848fbc0ea8b57f
|
[
"MIT"
] | null | null | null |
brokenCalculator/BrokenCalc.py
|
evansMeja/Leetcode
|
dac2e00090afad47eb02b30e56848fbc0ea8b57f
|
[
"MIT"
] | null | null | null |
class Solution:
def brokenCalc(self, X: 'int', Y: 'int') -> 'int':
if X>=Y:
return X-Y
else:
result = 0
while Y>X:
if Y%2==1:
result += 1
Y+=1
result += 1
Y//=2
result += X-Y
return result
| 23.8
| 54
| 0.319328
|
7951ddea308e0236295e35828a0c3f72b24ef4a3
| 637
|
py
|
Python
|
app.py
|
LinggarM/Priority-Task-Selection-Using-Evolutionary-Programming
|
f0d5b6a127deddff8632cc8fbcfb3ddf3419f798
|
[
"MIT"
] | null | null | null |
app.py
|
LinggarM/Priority-Task-Selection-Using-Evolutionary-Programming
|
f0d5b6a127deddff8632cc8fbcfb3ddf3419f798
|
[
"MIT"
] | null | null | null |
app.py
|
LinggarM/Priority-Task-Selection-Using-Evolutionary-Programming
|
f0d5b6a127deddff8632cc8fbcfb3ddf3419f798
|
[
"MIT"
] | null | null | null |
from flask import Flask, request, render_template
import knapsack
app = Flask(__name__)
@app.route('/', methods=['GET', 'POST'])
def index():
if request.method == 'POST':
jumlah_tugas = request.form['jumlah_tugas']
nama_tugas = request.form['nama_tugas']
skala_prioritas = request.form['skala_prioritas']
waktu_pengerjaan = request.form['waktu_pengerjaan']
waktu = request.form['waktu']
return render_template('index.html', data=knapsack.kalkulasi(jumlah_tugas, nama_tugas, skala_prioritas, waktu_pengerjaan, waktu))
return render_template("index.html", data="")
if __name__ == "__main__":
app.run()
| 35.388889
| 132
| 0.720565
|
7951df96f7e3265e07d9f097bebe2245764edf5e
| 2,261
|
py
|
Python
|
parsl/tests/test_data/test_file_apps.py
|
daheise/parsl
|
22fa8c75cdce782a0fa832692d8f19d7f57c25ab
|
[
"Apache-2.0"
] | null | null | null |
parsl/tests/test_data/test_file_apps.py
|
daheise/parsl
|
22fa8c75cdce782a0fa832692d8f19d7f57c25ab
|
[
"Apache-2.0"
] | null | null | null |
parsl/tests/test_data/test_file_apps.py
|
daheise/parsl
|
22fa8c75cdce782a0fa832692d8f19d7f57c25ab
|
[
"Apache-2.0"
] | null | null | null |
import os
import pytest
import parsl
from parsl.app.app import App
from parsl.data_provider.files import File
from parsl.tests.configs.local_threads import config
@App('bash')
def cat(inputs=[], outputs=[], stdout=None, stderr=None):
infiles = ' '.join([i.filepath for i in inputs])
return """echo {i}
cat {i} &> {o}
""".format(i=infiles, o=outputs[0])
@pytest.mark.usefixtures('setup_data')
@pytest.mark.issue363
def test_files():
if os.path.exists('cat_out.txt'):
os.remove('cat_out.txt')
fs = [File('data/' + f) for f in os.listdir('data')]
x = cat(inputs=fs, outputs=[File('cat_out.txt')],
stdout='f_app.out', stderr='f_app.err')
d_x = x.outputs[0]
print(x.result())
print(d_x, type(d_x))
@App('bash')
def increment(inputs=[], outputs=[], stdout=None, stderr=None):
# Place double braces to avoid python complaining about missing keys for {item = $1}
return """
x=$(cat {i})
echo $(($x+1)) > {o}
""".format(i=inputs[0], o=outputs[0])
@pytest.mark.usefixtures('setup_data')
def test_increment(depth=5):
"""Test simple pipeline A->B...->N
"""
# Create the first file
open("test0.txt", 'w').write('0\n')
# Create the first entry in the dictionary holding the futures
prev = File("test0.txt")
futs = {}
for i in range(1, depth):
print("Launching {0} with {1}".format(i, prev))
if os.path.exists('test{0}.txt'.format(i)):
os.remove('test{0}.txt'.format(i))
fu = increment(inputs=[prev], # Depend on the future from previous call
# Name the file to be created here
outputs=[File("test{0}.txt".format(i))],
stdout="incr{0}.out".format(i),
stderr="incr{0}.err".format(i))
[prev] = fu.outputs
futs[i] = prev
print(prev.filepath)
for key in futs:
if key > 0:
fu = futs[key]
data = open(fu.result().filepath, 'r').read().strip()
assert data == str(
key), "[TEST] incr failed for key:{0} got:{1}".format(key, data)
if __name__ == '__main__':
parsl.clear()
parsl.load(config)
test_files()
test_increment()
| 27.573171
| 88
| 0.574967
|
7951e090988cbaf47c039d2a5b9194dce6ac9539
| 17,624
|
py
|
Python
|
code/Managed Software Update/munki.py
|
zdw/munki
|
df2028a946c182f8ce39b11ec4dff49953281fb5
|
[
"Apache-2.0"
] | 2
|
2015-02-28T11:01:44.000Z
|
2017-01-29T14:54:42.000Z
|
code/Managed Software Update/munki.py
|
zdw/munki
|
df2028a946c182f8ce39b11ec4dff49953281fb5
|
[
"Apache-2.0"
] | null | null | null |
code/Managed Software Update/munki.py
|
zdw/munki
|
df2028a946c182f8ce39b11ec4dff49953281fb5
|
[
"Apache-2.0"
] | null | null | null |
# encoding: utf-8
#
# munki.py
# Managed Software Update
#
# Created by Greg Neagle on 2/11/10.
# Copyright 2010-2011 Greg Neagle.
#
# 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.
'''munki-specific code for use with Managed Software Update'''
import errno
import logging
import os
import stat
import subprocess
import random
import FoundationPlist
import Foundation
from Foundation import NSDate
from Foundation import NSFileManager
from Foundation import CFPreferencesCopyAppValue
from Foundation import CFPreferencesAppSynchronize
INSTALLATLOGOUTFILE = "/private/tmp/com.googlecode.munki.installatlogout"
UPDATECHECKLAUNCHFILE = \
"/private/tmp/.com.googlecode.munki.updatecheck.launchd"
MSULOGDIR = \
"/Users/Shared/.com.googlecode.munki.ManagedSoftwareUpdate.logs"
MSULOGFILE = "%s.log"
MSULOGENABLED = False
class FleetingFileHandler(logging.FileHandler):
"""File handler which opens/closes the log file only during log writes."""
def __init__(self, filename, mode='a', encoding=None, delay=True):
if hasattr(self, '_open'): # if py2.6+ ...
logging.FileHandler.__init__(self, filename, mode, encoding, delay)
else:
logging.FileHandler.__init__(self, filename, mode, encoding)
# lots of py <=2.5 fixes to support delayed open and immediate
# close.
self.encoding = encoding
self._open = self.__open
self.flush = self.__flush
self._close()
def __open(self):
"""Open the log file."""
if self.encoding is None:
stream = open(self.baseFilename, self.mode)
else:
stream = logging.codecs.open(
self.baseFilename, self.mode, self.encoding)
return stream
def __flush(self):
"""Flush the stream if it is open."""
if self.stream:
self.stream.flush()
def _close(self):
"""Close the log file if it is open."""
if self.stream:
self.flush()
if hasattr(self.stream, 'close'):
self.stream.close()
self.stream = None
def close(self):
"""Close the entire handler if it is open."""
if self.stream:
return logging.FileHandler.close(self)
def emit(self, record):
"""Open the log, emit a record and close the log."""
if self.stream is None:
self.stream = self._open()
logging.FileHandler.emit(self, record)
self._close()
def call(cmd):
'''Convenience function; works around an issue with subprocess.call
in PyObjC in Snow Leopard'''
proc = subprocess.Popen(cmd, bufsize=1, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
(output, err) = proc.communicate()
return proc.returncode
BUNDLE_ID = 'ManagedInstalls'
def reload_prefs():
"""Uses CFPreferencesAppSynchronize(BUNDLE_ID)
to make sure we have the latest prefs. Call this
if another process may have modified ManagedInstalls.plist,
this needs to be run after returning from MunkiStatus"""
CFPreferencesAppSynchronize(BUNDLE_ID)
def pref(pref_name):
"""Return a preference. Since this uses CFPreferencesCopyAppValue,
Preferences can be defined several places. Precedence is:
- MCX
- ~/Library/Preferences/ManagedInstalls.plist
- /Library/Preferences/ManagedInstalls.plist
- default_prefs defined here.
"""
default_prefs = {
'ManagedInstallDir': '/Library/Managed Installs',
'InstallAppleSoftwareUpdates': False,
'ShowRemovalDetail': False,
'InstallRequiresLogout': False
}
pref_value = CFPreferencesCopyAppValue(pref_name, BUNDLE_ID)
if pref_value == None:
pref_value = default_prefs.get(pref_name)
if type(pref_value).__name__ in ['__NSCFDate', '__NSDate', '__CFDate']:
# convert NSDate/CFDates to strings
pref_value = str(pref_value)
return pref_value
def readSelfServiceManifest():
'''Read the SelfServeManifest if it exists'''
# read our working copy if it exists
SelfServeManifest = "/Users/Shared/.SelfServeManifest"
if not os.path.exists(SelfServeManifest):
# no working copy, look for system copy
managedinstallbase = pref('ManagedInstallDir')
SelfServeManifest = os.path.join(managedinstallbase, "manifests",
"SelfServeManifest")
if os.path.exists(SelfServeManifest):
try:
return FoundationPlist.readPlist(SelfServeManifest)
except FoundationPlist.NSPropertyListSerializationException:
return {}
else:
return {}
def writeSelfServiceManifest(optional_install_choices):
'''Write out our self-serve manifest
so managedsoftwareupdate can use it'''
usermanifest = "/Users/Shared/.SelfServeManifest"
try:
FoundationPlist.writePlist(optional_install_choices, usermanifest)
except FoundationPlist.FoundationPlistException:
pass
def getRemovalDetailPrefs():
'''Returns preference to control display of removal detail'''
return pref('ShowRemovalDetail')
def installRequiresLogout():
'''Returns preference to force logout for all installs'''
return pref('InstallRequiresLogout')
def getInstallInfo():
'''Returns the dictionary describing the managed installs and removals'''
managedinstallbase = pref('ManagedInstallDir')
plist = {}
installinfo = os.path.join(managedinstallbase, 'InstallInfo.plist')
if os.path.exists(installinfo):
try:
plist = FoundationPlist.readPlist(installinfo)
except FoundationPlist.NSPropertyListSerializationException:
pass
return plist
def thereAreUpdatesToBeForcedSoon(hours=72):
'''Return True if any updates need to be installed within the next
X hours, false otherwise'''
installinfo = getInstallInfo()
if installinfo:
now = NSDate.date()
now_xhours = NSDate.dateWithTimeIntervalSinceNow_(hours * 3600)
for item in installinfo.get('managed_installs', []):
force_install_after_date = item.get('force_install_after_date')
if force_install_after_date:
force_install_after_date = discardTimeZoneFromDate(
force_install_after_date)
if now_xhours >= force_install_after_date:
return True
return False
def earliestForceInstallDate():
"""Check installable packages for force_install_after_dates
Returns None or earliest force_install_after_date converted to local time
"""
earliest_date = None
installinfo = getInstallInfo()
for install in installinfo.get('managed_installs', []):
this_force_install_date = install.get('force_install_after_date')
if this_force_install_date:
this_force_install_date = discardTimeZoneFromDate(
this_force_install_date)
if not earliest_date or this_force_install_date < earliest_date:
earliest_date = this_force_install_date
return earliest_date
def discardTimeZoneFromDate(the_date):
"""Input: NSDate object
Output: NSDate object with same date and time as the UTC.
In PDT, '2011-06-20T12:00:00Z' becomes '2011-06-20 12:00:00 -0700'"""
# get local offset
(unused_date, unused_time, offset) = str(the_date).split()
hour_offset = int(offset[0:3])
minute_offset = int(offset[0] + offset[3:])
seconds_offset = 60 * 60 * hour_offset + 60 * minute_offset
# return new NSDate minus local_offset
return the_date.dateByAddingTimeInterval_(-seconds_offset)
def stringFromDate(nsdate):
"""Input: NSDate object
Output: unicode object, date and time formatted per system locale.
"""
df = Foundation.NSDateFormatter.alloc().init()
df.setFormatterBehavior_(Foundation.NSDateFormatterBehavior10_4)
df.setDateStyle_(Foundation.kCFDateFormatterLongStyle)
df.setTimeStyle_(Foundation.kCFDateFormatterShortStyle)
return unicode(df.stringForObjectValue_(nsdate))
def startUpdateCheck():
'''Does launchd magic to run managedsoftwareupdate as root.'''
result = call(["/usr/bin/touch", UPDATECHECKLAUNCHFILE])
return result
def getAppleUpdates():
'''Returns any available Apple updates'''
managedinstallbase = pref('ManagedInstallDir')
plist = {}
appleUpdatesFile = os.path.join(managedinstallbase, 'AppleUpdates.plist')
if (os.path.exists(appleUpdatesFile) and
pref('InstallAppleSoftwareUpdates')):
try:
plist = FoundationPlist.readPlist(appleUpdatesFile)
except FoundationPlist.NSPropertyListSerializationException:
pass
return plist
def humanReadable(kbytes):
"""Returns sizes in human-readable units."""
units = [(" KB", 2**10), (" MB", 2**20), (" GB", 2**30), (" TB", 2**40)]
for suffix, limit in units:
if kbytes > limit:
continue
else:
return str(round(kbytes/float(limit/2**10), 1)) + suffix
def trimVersionString(version_string):
"""Trims all lone trailing zeros in the version string after major/minor.
Examples:
10.0.0.0 -> 10.0
10.0.0.1 -> 10.0.0.1
10.0.0-abc1 -> 10.0.0-abc1
10.0.0-abc1.0 -> 10.0.0-abc1
"""
if version_string == None or version_string == '':
return ''
version_parts = version_string.split('.')
# strip off all trailing 0's in the version, while over 2 parts.
while len(version_parts) > 2 and version_parts[-1] == '0':
del(version_parts[-1])
return '.'.join(version_parts)
def getconsoleuser():
from SystemConfiguration import SCDynamicStoreCopyConsoleUser
cfuser = SCDynamicStoreCopyConsoleUser( None, None, None )
return cfuser[0]
def currentGUIusers():
'''Gets a list of GUI users by parsing the output of /usr/bin/who'''
gui_users = []
proc = subprocess.Popen("/usr/bin/who", shell=False,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(output, err) = proc.communicate()
lines = str(output).splitlines()
for line in lines:
if "console" in line:
parts = line.split()
gui_users.append(parts[0])
return gui_users
def logoutNow():
'''Uses oscascript to run an AppleScript
to tell loginwindow to logout.
Ugly, but it works.'''
script = """
ignoring application responses
tell application "loginwindow"
«event aevtrlgo»
end tell
end ignoring
"""
cmd = ["/usr/bin/osascript"]
for line in script.splitlines():
line = line.rstrip().lstrip()
if line:
cmd.append("-e")
cmd.append(line)
result = call(cmd)
def logoutAndUpdate():
'''Touch a flag so the process that runs after
logout knows it's OK to install everything'''
try:
if not os.path.exists(INSTALLATLOGOUTFILE):
f = open(INSTALLATLOGOUTFILE, 'w')
f.close()
logoutNow()
except (OSError, IOError):
return 1
def justUpdate():
'''Trigger managedinstaller via launchd KeepAlive path trigger
We touch a file that launchd is is watching
launchd, in turn,
launches managedsoftwareupdate --installwithnologout as root'''
cmd = ["/usr/bin/touch",
"/private/tmp/.com.googlecode.munki.managedinstall.launchd"]
return call(cmd)
def getRunningProcesses():
"""Returns a list of paths of running processes"""
proc = subprocess.Popen(['/bin/ps', '-axo' 'comm='],
shell=False, stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
(output, unused_err) = proc.communicate()
if proc.returncode == 0:
proc_list = [item for item in output.splitlines()
if item.startswith('/')]
LaunchCFMApp = ('/System/Library/Frameworks/Carbon.framework'
'/Versions/A/Support/LaunchCFMApp')
if LaunchCFMApp in proc_list:
# we have a really old Carbon app
proc = subprocess.Popen(['/bin/ps', '-axwwwo' 'args='],
shell=False, stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
(output, unused_err) = proc.communicate()
if proc.returncode == 0:
carbon_apps = [item[len(LaunchCFMApp)+1:]
for item in output.splitlines()
if item.startswith(LaunchCFMApp)]
if carbon_apps:
proc_list.extend(carbon_apps)
return proc_list
else:
return []
def getRunningBlockingApps(appnames):
"""Given a list of app names, return a list of friendly names
for apps in the list that are running"""
proc_list = getRunningProcesses()
running_apps = []
filemanager = NSFileManager.alloc().init()
for appname in appnames:
matching_items = []
if appname.endswith('.app'):
# search by filename
matching_items = [item for item in proc_list
if '/'+ appname + '/' in item]
else:
# check executable name
matching_items = [item for item in proc_list
if item.endswith('/' + appname)]
if not matching_items:
# try adding '.app' to the name and check again
matching_items = [item for item in proc_list
if '/'+ appname + '.app/' in item]
matching_items = set(matching_items)
for path in matching_items:
while '/Contents/' in path or path.endswith('/Contents'):
path = os.path.dirname(path)
# ask NSFileManager for localized name since end-users
# will see this name
running_apps.append(filemanager.displayNameAtPath_(path))
return list(set(running_apps))
def setupLogging(username=None):
"""Setup logging module.
Args:
username: str, optional, current login name
"""
global MSULOGENABLED
if (logging.root.handlers and
logging.root.handlers[0].__class__ is FleetingFileHandler):
return
if pref('MSULogEnabled'):
MSULOGENABLED = True
if not MSULOGENABLED:
return
if username is None:
username = os.getlogin() or 'UID%d' % os.getuid()
if not os.path.exists(MSULOGDIR):
try:
os.mkdir(MSULOGDIR, 01777)
except OSError, e:
logging.error('mkdir(%s): %s' % (MSULOGDIR, str(e)))
return
if not os.path.isdir(MSULOGDIR):
logging.error('%s is not a directory' % MSULOGDIR)
return
# freshen permissions, if possible.
try:
os.chmod(MSULOGDIR, 01777)
except OSError:
pass
# find a safe log file to write to for this user
filename = os.path.join(MSULOGDIR, MSULOGFILE % username)
t = 0
ours = False
while t < 10:
try:
f = os.open(filename, os.O_RDWR|os.O_CREAT|os.O_NOFOLLOW, 0600)
st = os.fstat(f)
ours = stat.S_ISREG(st.st_mode) and st.st_uid == os.getuid()
os.close(f)
if ours:
break
except (OSError, IOError):
pass # permission denied, symlink, ...
# avoid creating many separate log files by using one static suffix
# as the first alternative. if unsuccessful, switch to totally
# randomly suffixed files.
if t == 0:
random.seed(hash(username))
elif t == 1:
random.seed()
filename = os.path.join(
MSULOGDIR, MSULOGFILE % (
'%s_%d' % (username, random.randint(0, 2**32))))
t += 1
if not ours:
logging.error('No logging is possible')
return
# setup log handler
log_format = '%(created)f %(levelname)s ' + username + ' : %(message)s'
ffh = None
try:
ffh = FleetingFileHandler(filename)
except IOError, e:
logging.error('Error opening log file %s: %s' % (filename, str(e)))
ffh.setFormatter(logging.Formatter(log_format, None))
logging.root.addHandler(ffh)
logging.getLogger().setLevel(logging.INFO)
def log(source, event, msg=None, *args):
"""Log an event from a source.
Args:
source: str, like "MSU" or "user"
event: str, like "exit"
msg: str, optional, additional log output
args: list, optional, arguments supplied to msg as format args
"""
if not MSULOGENABLED:
return
if msg:
if args:
logging.info('@@%s:%s@@ ' + msg, source, event, *args)
else:
logging.info('@@%s:%s@@ %s', source, event, msg)
else:
logging.info('@@%s:%s@@', source, event)
| 33.065666
| 79
| 0.631241
|
7951e0b174f01128a0ca47a35e49aa73ea3a0317
| 15
|
py
|
Python
|
projects/pyside6/test.py
|
on-nix/python-on-nix
|
d8a7fa21b76ac3b8a1a3fedb41e86352769b09ed
|
[
"Unlicense"
] | 25
|
2021-10-30T19:54:59.000Z
|
2022-03-29T06:11:02.000Z
|
projects/pyside6/test.py
|
on-nix/python-on-nix
|
d8a7fa21b76ac3b8a1a3fedb41e86352769b09ed
|
[
"Unlicense"
] | 21
|
2021-10-19T01:09:38.000Z
|
2022-03-24T16:08:53.000Z
|
projects/pyside6/test.py
|
on-nix/python
|
d8a7fa21b76ac3b8a1a3fedb41e86352769b09ed
|
[
"Unlicense"
] | 3
|
2022-01-25T20:25:13.000Z
|
2022-03-08T02:58:50.000Z
|
import PySide6
| 7.5
| 14
| 0.866667
|
7951e21c5aad283fe69321c988c2fc46c6d778ee
| 5,049
|
py
|
Python
|
tests/unit/test_extensionregistry.py
|
temoctzin/radish
|
1d904b9a7bf9eb5b263c86e3fc3a996956747ecc
|
[
"MIT"
] | null | null | null |
tests/unit/test_extensionregistry.py
|
temoctzin/radish
|
1d904b9a7bf9eb5b263c86e3fc3a996956747ecc
|
[
"MIT"
] | null | null | null |
tests/unit/test_extensionregistry.py
|
temoctzin/radish
|
1d904b9a7bf9eb5b263c86e3fc3a996956747ecc
|
[
"MIT"
] | null | null | null |
# -*- coding: utf-8 -*-
"""
radish
~~~~~~
Behavior Driven Development tool for Python - the root from red to green
Copyright: MIT, Timo Furrer <tuxtimo@gmail.com>
"""
import pytest
from radish.extensionregistry import extension
import radish.exceptions as errors
def test_register_simple_extension_class(extensionregistry):
"""
Test registering simple Extension class
"""
# given
class SimpleExtension(object):
pass
# when
extensionregistry.register(SimpleExtension)
# then
assert len(extensionregistry.extensions) == 1
assert extensionregistry.extensions[0] == SimpleExtension
assert len(extensionregistry.loaded_extensions) == 0
def test_register_simple_extension_class_using_decorator(extensionregistry):
"""
Test registering simple Extension class using the extension decorator
"""
# given & when
@extension
class SimpleExtension(object):
pass
# then
assert len(extensionregistry.extensions) == 1
assert extensionregistry.extensions[0] == SimpleExtension
assert len(extensionregistry.loaded_extensions) == 0
def test_loading_simple_extension(extensionregistry, mocker):
"""
Test loading simple extension
"""
# given
@extension
class SimpleExtension(object):
LOAD_IF = staticmethod(lambda config: True)
# when
extensionregistry.load(mocker.MagicMock())
# then
assert len(extensionregistry.extensions) == 1
assert extensionregistry.extensions[0] == SimpleExtension
assert len(extensionregistry.loaded_extensions) == 1
assert isinstance(extensionregistry.loaded_extensions[0], SimpleExtension)
# FIXME(TF): wrong behavior?!
def test_loading_invalid_extension(extensionregistry, mocker):
"""
Test loading an invalid extension
"""
# given
@extension
class SimpleExtension(object):
pass
# when
extensionregistry.load(mocker.MagicMock())
# then
assert len(extensionregistry.extensions) == 1
assert len(extensionregistry.loaded_extensions) == 0
def test_loading_extension_which_raises_exceptions_init(extensionregistry, mocker):
"""
Test loading extension which raises exceptions in init
"""
# given
@extension
class SimpleExtension(object):
LOAD_IF = staticmethod(lambda config: True)
def __init__(self):
raise AssertionError('some error')
# when
with pytest.raises(AssertionError) as exc:
extensionregistry.load(mocker.MagicMock())
# then
assert str(exc.value) == 'some error'
def test_loading_simple_extension_if_wanted(extensionregistry, mocker):
"""
Test loading extension if wanted by config
"""
# given
@extension
class WantedExtension(object):
LOAD_IF = staticmethod(lambda config: True)
@extension
class UnwantedExtension(object):
LOAD_IF = staticmethod(lambda config: False)
# when
extensionregistry.load(mocker.MagicMock())
# then
assert len(extensionregistry.extensions) == 2
assert len(extensionregistry.loaded_extensions) == 1
assert isinstance(extensionregistry.loaded_extensions[0], WantedExtension)
def test_extension_loading_order(extensionregistry, mocker):
"""
Test the loading order of extensions
"""
# given
@extension
class SecondExtension(object):
LOAD_IF = staticmethod(lambda config: True)
# default prio = 1000
@extension
class FirstExtension(object):
LOAD_IF = staticmethod(lambda config: True)
LOAD_PRIORITY = 1
@extension
class ThirdExtension(object):
LOAD_IF = staticmethod(lambda config: True)
LOAD_PRIORITY = 10000
# when
extensionregistry.load(mocker.MagicMock())
# then
assert len(extensionregistry.loaded_extensions) == 3
assert isinstance(extensionregistry.loaded_extensions[0], FirstExtension)
assert isinstance(extensionregistry.loaded_extensions[1], SecondExtension)
assert isinstance(extensionregistry.loaded_extensions[2], ThirdExtension)
def test_getting_extension_options(extensionregistry, mocker):
"""
Test getting command line options from extensions
"""
# given
@extension
class FooExtension(object):
OPTIONS = [('--foo', 'enable foo power')]
@extension
class BarExtension(object):
OPTIONS = [
('--bar', 'enable bar power'),
('--bar-pow', 'enable magnitude of bar power')
]
@extension
class BlaExtension(object):
pass
# when
options = extensionregistry.get_options()
option_description = extensionregistry.get_option_description()
# then
assert options == """[--foo]
[--bar]
[--bar-pow]"""
assert option_description == """--foo enable foo power
--bar enable bar power
--bar-pow enable magnitude of bar power"""
| 26.573684
| 96
| 0.673005
|
7951e2eab5140a66f76f6dc992f486b6f302f99d
| 465
|
py
|
Python
|
{{ cookiecutter.repo_name }}/{{ cookiecutter.project_name }}/utils/models.py
|
anthonyalmarza/django-rest-sqlite-template
|
2313d8b49fb11ad53f75cd8d09de4107287dca6c
|
[
"MIT"
] | null | null | null |
{{ cookiecutter.repo_name }}/{{ cookiecutter.project_name }}/utils/models.py
|
anthonyalmarza/django-rest-sqlite-template
|
2313d8b49fb11ad53f75cd8d09de4107287dca6c
|
[
"MIT"
] | null | null | null |
{{ cookiecutter.repo_name }}/{{ cookiecutter.project_name }}/utils/models.py
|
anthonyalmarza/django-rest-sqlite-template
|
2313d8b49fb11ad53f75cd8d09de4107287dca6c
|
[
"MIT"
] | null | null | null |
from django.db import models
from django.utils.translation import gettext_lazy as _
class TimeStampedModel(models.Model):
"""
TimeStampedModel is the base abstract class to be used for all models with
this project.
"""
created = models.DateTimeField(_("Created"), auto_now_add=True)
modified = models.DateTimeField(_("Modified"), auto_now=True)
class Meta:
abstract = True
def __str__(self):
return f"{self.pk}"
| 24.473684
| 78
| 0.692473
|
7951e2eee3ff931cb13f2b9c78fa3f359f42163e
| 4,111
|
py
|
Python
|
NYRegentsPrep/settings.py
|
WalterSchaertl/NYRP
|
bd9554fba80ed11f9c8efbc6c19b5a5cb987e3b6
|
[
"MIT"
] | 1
|
2018-09-27T01:44:48.000Z
|
2018-09-27T01:44:48.000Z
|
NYRegentsPrep/settings.py
|
WalterSchaertl/NYRP
|
bd9554fba80ed11f9c8efbc6c19b5a5cb987e3b6
|
[
"MIT"
] | 5
|
2021-04-08T18:23:14.000Z
|
2021-09-22T17:37:53.000Z
|
NYRegentsPrep/settings.py
|
WalterSchaertl/NYRP
|
bd9554fba80ed11f9c8efbc6c19b5a5cb987e3b6
|
[
"MIT"
] | null | null | null |
"""
Django settings for NYRegentsPrep project.
Generated by 'django-admin startproject' using Django 1.11.2.
For more information on this file, see
https://docs.djangoproject.com/en/1.11/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.11/ref/settings/
"""
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
# No, this is not the secrete key used in production
SECRET_KEY = os.environ.get("DJANGO_SECRET_KEY", "4q(0g93r5v*9^deglxa#@*p)68%wmif=kr1izytss!u0!nu%1+")
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
ALLOWED_HOSTS = ["*"]
# Application definition
INSTALLED_APPS = [
"whitenoise.runserver_nostatic",
"NYRP.apps.NyrpConfig",
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"widget_tweaks",
]
MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"whitenoise.middleware.WhiteNoiseMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
]
ROOT_URLCONF = "NYRegentsPrep.urls"
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.template.context_processors.debug",
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
],
},
},
]
WSGI_APPLICATION = "NYRegentsPrep.wsgi.application"
# Database
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": os.path.join(BASE_DIR, "db.sqlite3"),
}
}
# Password validation
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
},
{
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
},
{
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
},
{
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
},
]
# Internationalization
# https://docs.djangoproject.com/en/1.11/topics/i18n/
LANGUAGE_CODE = "en-us"
TIME_ZONE = "America/New_York"
USE_I18N = True
USE_L10N = True
USE_TZ = True
# These three
#CSRF_COOKIE_SECURE = True
#SESSION_COOKIE_SECURE = True
#X_FRAME_OPTIONS = "DENY"
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.11/howto/static-files/
# The absolute path to the directory where collectstatic will collect static files for deployment.
STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles")
STATIC_URL = "/static/"
MEDIA_URL = ""
# List of subjects implemented or to be implemented
SUBJECTS = (("CHEM", "Chemistry"),
("USHG", "US History And Government"),
("ALG1", "Algebra I"),
("ALG2", "Algebra II Common Core"),
("GHGE", "Global History And Geography"),
("PHYS", "Physics"),
("ERRO", "Error: no subject"))
# Heroku: Update database configuration from $DATABASE_URL.
import dj_database_url
db_from_env = dj_database_url.config(conn_max_age=500)
DATABASES["default"].update(db_from_env)
STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"
| 27.590604
| 103
| 0.722209
|
7951e428732decda63bbe6550801ebb268fa5dcc
| 969
|
py
|
Python
|
tests/regressions.py
|
Coddo-Python/spotify-downloader
|
c3016df81caacc3c7e1969077caecaacf6d008f1
|
[
"MIT"
] | null | null | null |
tests/regressions.py
|
Coddo-Python/spotify-downloader
|
c3016df81caacc3c7e1969077caecaacf6d008f1
|
[
"MIT"
] | null | null | null |
tests/regressions.py
|
Coddo-Python/spotify-downloader
|
c3016df81caacc3c7e1969077caecaacf6d008f1
|
[
"MIT"
] | null | null | null |
import sys
from spotdl.__main__ import console_entry_point
from spotdl.download import ffmpeg
SONGS = {
"https://open.spotify.com/track/6CN3e26iQSj1N5lomh0mfO": "Eminem - Like Toy Soldiers.mp3",
"https://open.spotify.com/track/3bNv3VuUOKgrf5hu3YcuRo": "Adele - Someone Like You.mp3",
"https://open.spotify.com/track/6Y0VCyjVZ7waMVgDMJffu4?si=l0KG65FgRValiq3YQHEYDg": "Jay Park - 119 REMIX.mp3",
}
def test_regressions(monkeypatch, tmpdir):
"""
Download songs that caused problems in the past, to make sure they won't happen again.
"""
monkeypatch.chdir(tmpdir)
monkeypatch.setattr(sys, "argv", ["dummy", *SONGS.keys()])
monkeypatch.setattr(ffmpeg, "has_correct_version", lambda *_: True)
console_entry_point()
assert sorted(
[
file.basename
for file in tmpdir.listdir()
if file.isfile() and file.basename.startswith(".") is False
]
) == sorted([*SONGS.values()])
| 32.3
| 114
| 0.680083
|
7951e67228bca5f588e84a15608c00c429ed8d47
| 1,831
|
py
|
Python
|
tests/asm_store/test_asm_sta.py
|
CyberZHG/mos-6502-restricted-assembler
|
a492a82dc9cc30225264fe777180aad5d0b4201a
|
[
"MIT"
] | null | null | null |
tests/asm_store/test_asm_sta.py
|
CyberZHG/mos-6502-restricted-assembler
|
a492a82dc9cc30225264fe777180aad5d0b4201a
|
[
"MIT"
] | null | null | null |
tests/asm_store/test_asm_sta.py
|
CyberZHG/mos-6502-restricted-assembler
|
a492a82dc9cc30225264fe777180aad5d0b4201a
|
[
"MIT"
] | null | null | null |
from unittest import TestCase
from asm_6502 import Assembler, AssembleError
class TestAssembleSTA(TestCase):
def setUp(self) -> None:
self.assembler = Assembler()
def test_sta_error_immediate(self):
code = "STA #$00"
with self.assertRaises(AssembleError) as e:
self.assembler.assemble(code)
self.assertEqual("AssembleError: Immediate addressing is not allowed for `STA` at line 1",
str(e.exception))
def test_sta_zero_page(self):
code = "STA $00"
results = self.assembler.assemble(code, add_entry=False)
self.assertEqual([
(0x0000, [0x85, 0x00]),
], results)
def test_sta_zero_page_x(self):
code = "STA $10,X"
results = self.assembler.assemble(code, add_entry=False)
self.assertEqual([
(0x0000, [0x95, 0x10]),
], results)
def test_sta_absolute(self):
code = "STA $ABCD"
results = self.assembler.assemble(code, add_entry=False)
self.assertEqual([
(0x0000, [0x8D, 0xCD, 0xAB]),
], results)
def test_sta_absolute_indexed(self):
code = "STA $ABCD,X\n" \
"STA $ABCD,Y"
results = self.assembler.assemble(code, add_entry=False)
self.assertEqual([
(0x0000, [0x9D, 0xCD, 0xAB, 0x99, 0xCD, 0xAB]),
], results)
def test_sta_indexed_indirect(self):
code = "STA ($40,X)"
results = self.assembler.assemble(code, add_entry=False)
self.assertEqual([
(0x0000, [0x81, 0x40]),
], results)
def test_sta_indirect_indexed(self):
code = "STA ($40),Y"
results = self.assembler.assemble(code, add_entry=False)
self.assertEqual([
(0x0000, [0x91, 0x40]),
], results)
| 30.516667
| 98
| 0.586019
|
7951e763760589cefbf1dbcc9c53a57a6944ced7
| 4,846
|
py
|
Python
|
sample/astfile.py
|
RiS3-Lab/FICS-
|
82c8abef52ca943946b7e82a16998cf67f1d2049
|
[
"Apache-2.0"
] | 37
|
2020-12-04T09:15:50.000Z
|
2022-03-28T13:33:29.000Z
|
sample/astfile.py
|
RiS3-Lab/FICS-
|
82c8abef52ca943946b7e82a16998cf67f1d2049
|
[
"Apache-2.0"
] | 7
|
2020-12-03T08:14:31.000Z
|
2021-11-24T14:14:03.000Z
|
sample/astfile.py
|
RiS3-Lab/FICS-
|
82c8abef52ca943946b7e82a16998cf67f1d2049
|
[
"Apache-2.0"
] | 19
|
2020-12-04T08:43:31.000Z
|
2022-03-28T13:33:27.000Z
|
from collections import Counter
import networkx as nx
from learning.similarity import counter_cosine_similarity
class ASTFile:
def __init__(self, ast_file, arguments, ast=None, feature_type=''):
self.ast_file = ast_file
self.arguments = arguments
self.ast = ast
if self.ast is None:
try:
self.ast = nx.read_graphml(self.ast_file)
# self.ast = self.index.read(self.ast_file)
except Exception, e:
print e
print self.ast_file
self.functions_root_nodes = []
self.features = []
self.functions_features_counters = []
self.function_names = []
self.feature_type = feature_type
def extract_features(self):
self.functions_root_nodes = [x for x, y in self.ast.nodes(data=True)
if 'type' in y and y['type'] == '"FUNCTION_DECL"']
for root_node in self.functions_root_nodes:
# print root_node
self.extract_potential_features(root_node)
self.functions_features_counters.append(Counter(self.features))
self.function_names.append(self.ast.node[root_node]['spelling'].replace('"', ''))
def extract_potential_features(self, root_node):
# self.print_graph(root_node)
s = list(nx.dfs_preorder_nodes(self.ast, root_node))
self.features = []
feature_types = self.feature_type.split('+')
for feature_type in feature_types:
if feature_type == 'MR':
self.extract_members(s)
elif feature_type == 'C':
self.extract_calls(s)
elif feature_type == 'NT':
self.extract_node_types(s)
def extract_members(self, s):
for item in s:
node_type = self.ast.node[item]['type'].replace('"', '')
if node_type == 'MEMBER_REF_EXPR' or node_type == 'MEMBER_REF':
node_spelling = self.ast.node[item]['spelling'].replace('"', '')
if node_spelling != '':
self.features.append('{}_{}'.format(node_type, node_spelling))
def extract_calls(self, s):
for item in s:
node_type = self.ast.node[item]['type'].replace('"', '')
if node_type == 'CALL_EXPR':
node_spelling = self.ast.node[item]['spelling'].replace('"', '')
if node_spelling != '':
self.features.append('{}_{}'.format(node_type, node_spelling))
def extract_node_types(self, s):
for item in s:
node_type = self.ast.node[item]['type'].replace('"', '')
self.features.append('NODE_TYPE_{}'.format(node_type))
def print_graph(self, root_node):
if self.ast.node[root_node]['spelling'].replace('"', '') in \
['X509v3_addr_get_afi', 'ssl3_get_record', 'aes_gcm_ctrl']:
print root_node, self.ast.node[root_node]['spelling']
s = list(nx.dfs_preorder_nodes(self.ast, root_node))
for item in s:
print self.ast.node[item]
def compute_functions_similarities(self):
functions_similarities = []
for i in range(len(self.functions_features_counters) - 1):
for j in range(len(self.functions_features_counters)):
if i == i + j:
continue
if i + j >= len(self.functions_features_counters):
continue
functions_similarities.append({'func1': self.ast.node[self.functions_root_nodes[i]]['spelling'],
'func2': self.ast.node[self.functions_root_nodes[i + j]]['spelling'],
'score': counter_cosine_similarity(self.functions_features_counters[i],
self.functions_features_counters[i +
j])})
return sorted(functions_similarities, key=lambda k: k['score'], reverse=True)
def extract_backup_features(self, root_node):
# self.print_graph(root_node)
s = list(nx.dfs_preorder_nodes(self.ast, root_node))
features = []
for item in s:
node_type = self.ast.node[item]['type'].replace('"', '')
features.append(node_type)
if node_type == 'MEMBER_REF_EXPR' or node_type == 'MEMBER_REF' or node_type =='TYPEDEF_DECL':
node_spelling = self.ast.node[item]['spelling'].replace('"', '')
if node_spelling != '':
features.append(node_spelling)
# print features
return features
| 42.884956
| 120
| 0.5487
|
7951e819e6bff90875989c969eb6d84671758e24
| 1,318
|
py
|
Python
|
var/spack/repos/builtin/packages/heppdt/package.py
|
kkauder/spack
|
6ae8d5c380c1f42094b05d38be26b03650aafb39
|
[
"ECL-2.0",
"Apache-2.0",
"MIT-0",
"MIT"
] | 2,360
|
2017-11-06T08:47:01.000Z
|
2022-03-31T14:45:33.000Z
|
var/spack/repos/builtin/packages/heppdt/package.py
|
kkauder/spack
|
6ae8d5c380c1f42094b05d38be26b03650aafb39
|
[
"ECL-2.0",
"Apache-2.0",
"MIT-0",
"MIT"
] | 13,838
|
2017-11-04T07:49:45.000Z
|
2022-03-31T23:38:39.000Z
|
var/spack/repos/builtin/packages/heppdt/package.py
|
kkauder/spack
|
6ae8d5c380c1f42094b05d38be26b03650aafb39
|
[
"ECL-2.0",
"Apache-2.0",
"MIT-0",
"MIT"
] | 1,793
|
2017-11-04T07:45:50.000Z
|
2022-03-30T14:31:53.000Z
|
# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from spack import *
class Heppdt(AutotoolsPackage):
"""The HepPID library contains translation methods for particle ID's
to and from various Monte Carlo generators and the PDG standard
numbering scheme. We realize that the generators adhere closely
to the standard, but there are occasional differences."""
homepage = "https://cdcvs.fnal.gov/redmine/projects/heppdt/wiki"
url = "https://lcgpackages.web.cern.ch/lcgpackages/tarFiles/sources/HepPDT-2.06.01.tar.gz"
tags = ['hep']
version('3.04.01', sha256='2c1c39eb91295d3ded69e0d3f1a38b1cb55bc3f0cde37b725ffd5d722f63c0f6')
version('3.04.00', sha256='c5f0eefa19dbbae99f2b6a2ab1ad8fd5d5f844fbbbf96e62f0ddb68cc6a7d5f3')
version('3.03.02', sha256='409d940badbec672c139cb8972c88847b3f9a2476a336f4f7ee6924f8d08426c')
version('3.03.01', sha256='1aabb0add1a26dcb010f99bfb24e666a881cb03f796503220c93d3d4434b4e32')
version('3.03.00', sha256='c9fab0f7983234137d67e83d3e94e194856fc5f8994f11c6283194ce60010840')
version('2.06.01', sha256='12a1b6ffdd626603fa3b4d70f44f6e95a36f8f3b6d4fd614bac14880467a2c2e', preferred=True)
| 50.692308
| 113
| 0.786039
|
7951e827326f5622a1e3e40e5ec7eff2321153be
| 526,474
|
py
|
Python
|
sympy/integrals/rubi/rubi_tests/tests/test_miscellaneous_algebra.py
|
utkarshdeorah/sympy
|
dcdf59bbc6b13ddbc329431adf72fcee294b6389
|
[
"BSD-3-Clause"
] | 1
|
2022-01-31T16:02:46.000Z
|
2022-01-31T16:02:46.000Z
|
sympy/integrals/rubi/rubi_tests/tests/test_miscellaneous_algebra.py
|
utkarshdeorah/sympy
|
dcdf59bbc6b13ddbc329431adf72fcee294b6389
|
[
"BSD-3-Clause"
] | 3
|
2022-02-04T14:45:16.000Z
|
2022-02-04T14:45:45.000Z
|
sympy/integrals/rubi/rubi_tests/tests/test_miscellaneous_algebra.py
|
utkarshdeorah/sympy
|
dcdf59bbc6b13ddbc329431adf72fcee294b6389
|
[
"BSD-3-Clause"
] | 1
|
2022-02-04T13:50:29.000Z
|
2022-02-04T13:50:29.000Z
|
import sys
from sympy.external import import_module
matchpy = import_module("matchpy")
if not matchpy:
#bin/test will not execute any tests now
disabled = True
if sys.version_info[:2] < (3, 6):
disabled = True
from sympy.integrals.rubi.rubimain import rubi_integrate
from sympy.functions import log, sqrt, exp, cos, sin, tan, sec, csc, cot
from sympy.functions.elementary.hyperbolic import atanh
from sympy.functions.elementary.hyperbolic import asinh
from sympy.functions.elementary.hyperbolic import acosh
from sympy.functions.elementary.trigonometric import atan
from sympy.functions.elementary.trigonometric import asin
from sympy.functions.elementary.trigonometric import acos
from sympy.integrals.rubi.utility_function import (EllipticE, EllipticF,
hypergeom, rubi_test, AppellF1, EllipticPi, Log, Sqrt, ArcTan, ArcTanh, ArcSin, ArcCos, Hypergeometric2F1)
from sympy.core.numbers import (I, pi as Pi)
from sympy.core.singleton import S
from sympy.core.symbol import symbols
from sympy.functions.elementary.exponential import exp_polar
from sympy.functions.special.elliptic_integrals import (elliptic_e, elliptic_f, elliptic_pi)
from sympy.functions.special.hyper import hyper
from sympy.simplify.simplify import simplify
from sympy.testing.pytest import SKIP
from sympy.functions.elementary.hyperbolic import acsch as arccsch
from sympy.functions.elementary.trigonometric import acsc as arccsc
a, b, c, d, e, f, m, n, x, u , k, p, r, s, t= symbols('a b c d e f m n x u k p r s t')
A, B, C, D, a, b, c, d, e, f, g, h, y, z, m, n, p, q, u, v, w, F = symbols('A B C D a b c d e f g h y z m n p q u v w F',)
def test_1():
# difference in apart assert rubi_test(rubi_integrate(S(1)/(S(2)*sqrt(S(3))*b**(S(3)/2) - S(9)*b*x + S(9)*x**S(3)), x), x, -log(sqrt(b) - sqrt(S(3))*x)/(S(27)*b) + log(S(2)*sqrt(b) + sqrt(S(3))*x)/(S(27)*b) + sqrt(S(3))/(S(9)*sqrt(b)*(sqrt(S(3))*sqrt(b) - S(3)*x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(3) + S(3)*a**S(2)*b*x + S(3)*a*b**S(2)*x**S(2) + b**S(3)*x**S(3))**p, x), x, (a + b*x)*(a**S(3) + S(3)*a**S(2)*b*x + S(3)*a*b**S(2)*x**S(2) + b**S(3)*x**S(3))**p/(b*(S(3)*p + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(3) + S(3)*a**S(2)*b*x + S(3)*a*b**S(2)*x**S(2) + b**S(3)*x**S(3))**S(3), x), x, (a + b*x)**S(10)/(S(10)*b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(3) + S(3)*a**S(2)*b*x + S(3)*a*b**S(2)*x**S(2) + b**S(3)*x**S(3))**S(2), x), x, (a + b*x)**S(7)/(S(7)*b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(a**S(3) + S(3)*a**S(2)*b*x + S(3)*a*b**S(2)*x**S(2) + b**S(3)*x**S(3), x), x, a**S(3)*x + S(3)*a**S(2)*b*x**S(2)/S(2) + a*b**S(2)*x**S(3) + b**S(3)*x**S(4)/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(a**S(3) + S(3)*a**S(2)*b*x + S(3)*a*b**S(2)*x**S(2) + b**S(3)*x**S(3)), x), x, -S(1)/(S(2)*b*(a + b*x)**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(3) + S(3)*a**S(2)*b*x + S(3)*a*b**S(2)*x**S(2) + b**S(3)*x**S(3))**(S(-2)), x), x, -S(1)/(S(5)*b*(a + b*x)**S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(3) + S(3)*a**S(2)*b*x + S(3)*a*b**S(2)*x**S(2) + b**S(3)*x**S(3))**(S(-3)), x), x, -S(1)/(S(8)*b*(a + b*x)**S(8)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(3)*a*b + S(3)*b**S(2)*x + S(3)*b*c*x**S(2) + c**S(2)*x**S(3))**S(3), x), x, -b**S(3)*x*(-S(3)*a*c + b**S(2))**S(3)/c**S(3) + S(3)*b**S(2)*(b + c*x)**S(4)*(-S(3)*a*c + b**S(2))**S(2)/(S(4)*c**S(4)) - S(3)*b*(b + c*x)**S(7)*(-S(3)*a*c + b**S(2))/(S(7)*c**S(4)) + (b + c*x)**S(10)/(S(10)*c**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(3)*a*b + S(3)*b**S(2)*x + S(3)*b*c*x**S(2) + c**S(2)*x**S(3))**S(2), x), x, b**S(2)*x*(-S(3)*a*c + b**S(2))**S(2)/c**S(2) - b*(b + c*x)**S(4)*(-S(3)*a*c + b**S(2))/(S(2)*c**S(3)) + (b + c*x)**S(7)/(S(7)*c**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(3)*a*b + S(3)*b**S(2)*x + S(3)*b*c*x**S(2) + c**S(2)*x**S(3), x), x, S(3)*a*b*x + S(3)*b**S(2)*x**S(2)/S(2) + b*c*x**S(3) + c**S(2)*x**S(4)/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(S(3)*a*b + S(3)*b**S(2)*x + S(3)*b*c*x**S(2) + c**S(2)*x**S(3)), x), x, log(b**(S(1)/3)*(-S(3)*a*c + b**S(2))**(S(1)/3) - b - c*x)/(S(3)*b**(S(2)/3)*(-S(3)*a*c + b**S(2))**(S(2)/3)) - log(b**(S(2)/3)*(-S(3)*a*c + b**S(2))**(S(2)/3) + b**(S(1)/3)*(b + c*x)*(-S(3)*a*c + b**S(2))**(S(1)/3) + (b + c*x)**S(2))/(S(6)*b**(S(2)/3)*(-S(3)*a*c + b**S(2))**(S(2)/3)) - sqrt(S(3))*atan(sqrt(S(3))*(b**(S(1)/3) + (S(2)*b + S(2)*c*x)/(-S(3)*a*c + b**S(2))**(S(1)/3))/(S(3)*b**(S(1)/3)))/(S(3)*b**(S(2)/3)*(-S(3)*a*c + b**S(2))**(S(2)/3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(3)*a*b + S(3)*b**S(2)*x + S(3)*b*c*x**S(2) + c**S(2)*x**S(3))**(S(-2)), x), x, c*(b + c*x)/(S(3)*b*(-S(3)*a*c + b**S(2))*(b*(-S(3)*a*c + b**S(2)) - (b + c*x)**S(3))) - S(2)*c*log(b**(S(1)/3)*(-S(3)*a*c + b**S(2))**(S(1)/3) - b - c*x)/(S(9)*b**(S(5)/3)*(-S(3)*a*c + b**S(2))**(S(5)/3)) + c*log(b**(S(2)/3)*(-S(3)*a*c + b**S(2))**(S(2)/3) + b**(S(1)/3)*(b + c*x)*(-S(3)*a*c + b**S(2))**(S(1)/3) + (b + c*x)**S(2))/(S(9)*b**(S(5)/3)*(-S(3)*a*c + b**S(2))**(S(5)/3)) + S(2)*sqrt(S(3))*c*atan(sqrt(S(3))*(b**(S(1)/3) + (S(2)*b + S(2)*c*x)/(-S(3)*a*c + b**S(2))**(S(1)/3))/(S(3)*b**(S(1)/3)))/(S(9)*b**(S(5)/3)*(-S(3)*a*c + b**S(2))**(S(5)/3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(3)*a*b + S(3)*b**S(2)*x + S(3)*b*c*x**S(2) + c**S(2)*x**S(3))**(S(-3)), x), x, -c**S(2)*(b + c*x)/(S(6)*b*(-S(3)*a*c + b**S(2))*(b*(-S(3)*a*c + b**S(2)) - (b + c*x)**S(3))**S(2)) - S(5)*c**S(2)*(b + c*x)/(S(18)*b**S(2)*(-S(3)*a*c + b**S(2))**S(2)*(b*(-S(3)*a*c + b**S(2)) - (b + c*x)**S(3))) + S(5)*c**S(2)*log(b**(S(1)/3)*(-S(3)*a*c + b**S(2))**(S(1)/3) - b - c*x)/(S(27)*b**(S(8)/3)*(-S(3)*a*c + b**S(2))**(S(8)/3)) - S(5)*c**S(2)*log(b**(S(2)/3)*(-S(3)*a*c + b**S(2))**(S(2)/3) + b**(S(1)/3)*(b + c*x)*(-S(3)*a*c + b**S(2))**(S(1)/3) + (b + c*x)**S(2))/(S(54)*b**(S(8)/3)*(-S(3)*a*c + b**S(2))**(S(8)/3)) - S(5)*sqrt(S(3))*c**S(2)*atan(sqrt(S(3))*(b**(S(1)/3) + (S(2)*b + S(2)*c*x)/(-S(3)*a*c + b**S(2))**(S(1)/3))/(S(3)*b**(S(1)/3)))/(S(27)*b**(S(8)/3)*(-S(3)*a*c + b**S(2))**(S(8)/3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*c*e + b*d*f*x**S(3) + x**S(2)*(a*d*f + b*c*f + b*d*e) + x*(a*c*f + a*d*e + b*c*e))**S(3), x), x, a**S(3)*c**S(3)*e**S(3)*x + S(3)*a**S(2)*c**S(2)*e**S(2)*x**S(2)*(a*c*f + a*d*e + b*c*e)/S(2) + a*c*e*x**S(3)*(a**S(2)*(c**S(2)*f**S(2) + S(3)*c*d*e*f + d**S(2)*e**S(2)) + S(3)*a*b*c*e*(c*f + d*e) + b**S(2)*c**S(2)*e**S(2)) + b**S(3)*d**S(3)*f**S(3)*x**S(10)/S(10) + b**S(2)*d**S(2)*f**S(2)*x**S(9)*(a*d*f + b*c*f + b*d*e)/S(3) + S(3)*b*d*f*x**S(8)*(a**S(2)*d**S(2)*f**S(2) + S(3)*a*b*d*f*(c*f + d*e) + b**S(2)*(c**S(2)*f**S(2) + S(3)*c*d*e*f + d**S(2)*e**S(2)))/S(8) + x**S(7)*(a**S(3)*d**S(3)*f**S(3)/S(7) + S(9)*a**S(2)*b*d**S(2)*f**S(2)*(c*f + d*e)/S(7) + S(9)*a*b**S(2)*d*f*(c**S(2)*f**S(2) + S(3)*c*d*e*f + d**S(2)*e**S(2))/S(7) + b**S(3)*(c**S(3)*f**S(3) + S(9)*c**S(2)*d*e*f**S(2) + S(9)*c*d**S(2)*e**S(2)*f + d**S(3)*e**S(3))/S(7)) + x**S(6)*(a**S(3)*d**S(2)*f**S(2)*(c*f + d*e)/S(2) + S(3)*a**S(2)*b*d*f*(c**S(2)*f**S(2) + S(3)*c*d*e*f + d**S(2)*e**S(2))/S(2) + a*b**S(2)*(c**S(3)*f**S(3) + S(9)*c**S(2)*d*e*f**S(2) + S(9)*c*d**S(2)*e**S(2)*f + d**S(3)*e**S(3))/S(2) + b**S(3)*c*e*(c**S(2)*f**S(2) + S(3)*c*d*e*f + d**S(2)*e**S(2))/S(2)) + x**S(5)*(S(3)*a**S(3)*d*f*(c**S(2)*f**S(2) + S(3)*c*d*e*f + d**S(2)*e**S(2))/S(5) + S(3)*a**S(2)*b*(c**S(3)*f**S(3) + S(9)*c**S(2)*d*e*f**S(2) + S(9)*c*d**S(2)*e**S(2)*f + d**S(3)*e**S(3))/S(5) + S(9)*a*b**S(2)*c*e*(c**S(2)*f**S(2) + S(3)*c*d*e*f + d**S(2)*e**S(2))/S(5) + S(3)*b**S(3)*c**S(2)*e**S(2)*(c*f + d*e)/S(5)) + x**S(4)*(a**S(3)*(c**S(3)*f**S(3) + S(9)*c**S(2)*d*e*f**S(2) + S(9)*c*d**S(2)*e**S(2)*f + d**S(3)*e**S(3))/S(4) + S(9)*a**S(2)*b*c*e*(c**S(2)*f**S(2) + S(3)*c*d*e*f + d**S(2)*e**S(2))/S(4) + S(9)*a*b**S(2)*c**S(2)*e**S(2)*(c*f + d*e)/S(4) + b**S(3)*c**S(3)*e**S(3)/S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*c*e + b*d*f*x**S(3) + x**S(2)*(a*d*f + b*c*f + b*d*e) + x*(a*c*f + a*d*e + b*c*e))**S(2), x), x, a**S(2)*c**S(2)*e**S(2)*x + a*c*e*x**S(2)*(a*c*f + a*d*e + b*c*e) + b**S(2)*d**S(2)*f**S(2)*x**S(7)/S(7) + b*d*f*x**S(6)*(a*d*f + b*c*f + b*d*e)/S(3) + x**S(5)*(a**S(2)*d**S(2)*f**S(2)/S(5) + S(4)*a*b*d*f*(c*f + d*e)/S(5) + b**S(2)*(c**S(2)*f**S(2) + S(4)*c*d*e*f + d**S(2)*e**S(2))/S(5)) + x**S(4)*(a**S(2)*d*f*(c*f + d*e)/S(2) + a*b*(c**S(2)*f**S(2) + S(4)*c*d*e*f + d**S(2)*e**S(2))/S(2) + b**S(2)*c*e*(c*f + d*e)/S(2)) + x**S(3)*(a**S(2)*(c**S(2)*f**S(2) + S(4)*c*d*e*f + d**S(2)*e**S(2))/S(3) + S(4)*a*b*c*e*(c*f + d*e)/S(3) + b**S(2)*c**S(2)*e**S(2)/S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(a*c*e + b*d*f*x**S(3) + x**S(2)*(a*d*f + b*c*f + b*d*e) + x*(a*c*f + a*d*e + b*c*e), x), x, a*c*e*x + b*d*f*x**S(4)/S(4) + x**S(3)*(a*d*f/S(3) + b*c*f/S(3) + b*d*e/S(3)) + x**S(2)*(a*c*f/S(2) + a*d*e/S(2) + b*c*e/S(2)), expand=True, _diff=True, _numerical=True)
'''taking a long time
assert rubi_test(rubi_integrate(S(1)/(a*c*e + b*d*f*x**S(3) + x**S(2)*(a*d*f + b*c*f + b*d*e) + x*(a*c*f + a*d*e + b*c*e)), x), x, b*log(a + b*x)/((-a*d + b*c)*(-a*f + b*e)) - d*log(c + d*x)/((-a*d + b*c)*(-c*f + d*e)) + f*log(e + f*x)/((-a*f + b*e)*(-c*f + d*e)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*c*e + b*d*f*x**S(3) + x**S(2)*(a*d*f + b*c*f + b*d*e) + x*(a*c*f + a*d*e + b*c*e))**(S(-2)), x), x, -S(2)*b**S(3)*(-S(2)*a*d*f + b*c*f + b*d*e)*log(a + b*x)/((-a*d + b*c)**S(3)*(-a*f + b*e)**S(3)) - b**S(3)/((a + b*x)*(-a*d + b*c)**S(2)*(-a*f + b*e)**S(2)) + S(2)*d**S(3)*(a*d*f - S(2)*b*c*f + b*d*e)*log(c + d*x)/((-a*d + b*c)**S(3)*(-c*f + d*e)**S(3)) - d**S(3)/((c + d*x)*(-a*d + b*c)**S(2)*(-c*f + d*e)**S(2)) + S(2)*f**S(3)*(-a*d*f - b*c*f + S(2)*b*d*e)*log(e + f*x)/((-a*f + b*e)**S(3)*(-c*f + d*e)**S(3)) - f**S(3)/((e + f*x)*(-a*f + b*e)**S(2)*(-c*f + d*e)**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*c*e + b*d*f*x**S(3) + x**S(2)*(a*d*f + b*c*f + b*d*e) + x*(a*c*f + a*d*e + b*c*e))**(S(-3)), x), x, S(3)*b**S(5)*(S(7)*a**S(2)*d**S(2)*f**S(2) - S(7)*a*b*d*f*(c*f + d*e) + b**S(2)*(S(2)*c**S(2)*f**S(2) + S(3)*c*d*e*f + S(2)*d**S(2)*e**S(2)))*log(a + b*x)/((-a*d + b*c)**S(5)*(-a*f + b*e)**S(5)) + S(3)*b**S(5)*(-S(2)*a*d*f + b*c*f + b*d*e)/((a + b*x)*(-a*d + b*c)**S(4)*(-a*f + b*e)**S(4)) - b**S(5)/(S(2)*(a + b*x)**S(2)*(-a*d + b*c)**S(3)*(-a*f + b*e)**S(3)) - S(3)*d**S(5)*(S(2)*a**S(2)*d**S(2)*f**S(2) + a*b*d*f*(-S(7)*c*f + S(3)*d*e) + b**S(2)*(S(7)*c**S(2)*f**S(2) - S(7)*c*d*e*f + S(2)*d**S(2)*e**S(2)))*log(c + d*x)/((-a*d + b*c)**S(5)*(-c*f + d*e)**S(5)) + S(3)*d**S(5)*(a*d*f - S(2)*b*c*f + b*d*e)/((c + d*x)*(-a*d + b*c)**S(4)*(-c*f + d*e)**S(4)) + d**S(5)/(S(2)*(c + d*x)**S(2)*(-a*d + b*c)**S(3)*(-c*f + d*e)**S(3)) + S(3)*f**S(5)*(S(2)*a**S(2)*d**S(2)*f**S(2) - a*b*d*f*(-S(3)*c*f + S(7)*d*e) + b**S(2)*(S(2)*c**S(2)*f**S(2) - S(7)*c*d*e*f + S(7)*d**S(2)*e**S(2)))*log(e + f*x)/((-a*f + b*e)**S(5)*(-c*f + d*e)**S(5)) - S(3)*f**S(5)*(-a*d*f - b*c*f + S(2)*b*d*e)/((e + f*x)*(-a*f + b*e)**S(4)*(-c*f + d*e)**S(4)) - f**S(5)/(S(2)*(e + f*x)**S(2)*(-a*f + b*e)**S(3)*(-c*f + d*e)**S(3)), expand=True, _diff=True, _numerical=True)
'''
'''matchpy and mathematica difference
assert rubi_test(rubi_integrate(S(1)/(S(16)*x**S(3) - S(4)*x**S(2) + S(4)*x + S(-1)), x), x, log(-S(4)*x + S(1))/S(5) - log(S(4)*x**S(2) + S(1))/S(10) - atan(S(2)*x)/S(10), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3) + x**S(2) + x + S(1)), x), x, log(x + S(1))/S(2) - log(x**S(2) + S(1))/S(4) + atan(x)/S(2), expand=True, _diff=True, _numerical=True)
'''
assert rubi_test(rubi_integrate(S(1)/(d*x**S(3)), x), x, -S(1)/(S(2)*d*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(c*x**S(2) + d*x**S(3)), x), x, -S(1)/(c*x) - d*log(x)/c**S(2) + d*log(c + d*x)/c**S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(b*x + d*x**S(3)), x), x, log(x)/b - log(b + d*x**S(2))/(S(2)*b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(b*x + c*x**S(2) + d*x**S(3)), x), x, c*atanh((c + S(2)*d*x)/sqrt(-S(4)*b*d + c**S(2)))/(b*sqrt(-S(4)*b*d + c**S(2))) + log(x)/b - log(b + c*x + d*x**S(2))/(S(2)*b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(a + d*x**S(3)), x), x, log(a**(S(1)/3) + d**(S(1)/3)*x)/(S(3)*a**(S(2)/3)*d**(S(1)/3)) - log(a**(S(2)/3) - a**(S(1)/3)*d**(S(1)/3)*x + d**(S(2)/3)*x**S(2))/(S(6)*a**(S(2)/3)*d**(S(1)/3)) - sqrt(S(3))*atan(sqrt(S(3))*(a**(S(1)/3) - S(2)*d**(S(1)/3)*x)/(S(3)*a**(S(1)/3)))/(S(3)*a**(S(2)/3)*d**(S(1)/3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x**S(3))**n, x), x, x*(d*x**S(3))**n/(S(3)*n + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2) + d*x**S(3))**n, x), x, x*(S(1) + d*x/c)**(-n)*(c*x**S(2) + d*x**S(3))**n*hyper((-n, S(2)*n + S(1)), (S(2)*n + S(2),), -d*x/c)/(S(2)*n + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x + d*x**S(3))**n, x), x, x*(b + d*x**S(2))*(b*x + d*x**S(3))**n*hyper((S(1), S(3)*n/S(2) + S(3)/2), (n/S(2) + S(3)/2,), -d*x**S(2)/b)/(b*(n + S(1))), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate((b*x + d*x**S(3))**n, x), x, x*(S(1) + d*x**S(2)/b)**(-n)*(b*x + d*x**S(3))**n*hyper((-n, n/S(2) + S(1)/2), (n/S(2) + S(3)/2,), -d*x**S(2)/b)/(n + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x + c*x**S(2) + d*x**S(3))**n, x), x, x*(S(2)*d*x/(c - sqrt(-S(4)*b*d + c**S(2))) + S(1))**(-n)*(S(2)*d*x/(c + sqrt(-S(4)*b*d + c**S(2))) + S(1))**(-n)*(b*x + c*x**S(2) + d*x**S(3))**n*AppellF1(n + S(1), -n, -n, n + S(2), -S(2)*d*x/(c - sqrt(-S(4)*b*d + c**S(2))), -S(2)*d*x/(c + sqrt(-S(4)*b*d + c**S(2))))/(n + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + d*x**S(3))**n, x), x, x*(a + d*x**S(3))**(n + S(1))*hyper((S(1), n + S(4)/3), (S(4)/3,), -d*x**S(3)/a)/a, expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate((a + d*x**S(3))**n, x), x, x*(S(1) + d*x**S(3)/a)**(-n)*(a + d*x**S(3))**n*hyper((S(1)/3, -n), (S(4)/3,), -d*x**S(3)/a), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(5) + S(5)*a**S(4)*b*x + S(10)*a**S(3)*b**S(2)*x**S(2) + S(10)*a**S(2)*b**S(3)*x**S(3) + S(5)*a*b**S(4)*x**S(4) + b**S(5)*x**S(5))**S(3), x), x, (a + b*x)**S(16)/(S(16)*b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(5) + S(5)*a**S(4)*b*x + S(10)*a**S(3)*b**S(2)*x**S(2) + S(10)*a**S(2)*b**S(3)*x**S(3) + S(5)*a*b**S(4)*x**S(4) + b**S(5)*x**S(5))**S(2), x), x, (a + b*x)**S(11)/(S(11)*b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(a**S(5) + S(5)*a**S(4)*b*x + S(10)*a**S(3)*b**S(2)*x**S(2) + S(10)*a**S(2)*b**S(3)*x**S(3) + S(5)*a*b**S(4)*x**S(4) + b**S(5)*x**S(5), x), x, (a + b*x)**S(6)/(S(6)*b), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(a**S(5) + S(5)*a**S(4)*b*x + S(10)*a**S(3)*b**S(2)*x**S(2) + S(10)*a**S(2)*b**S(3)*x**S(3) + S(5)*a*b**S(4)*x**S(4) + b**S(5)*x**S(5), x), x, a**S(5)*x + S(5)*a**S(4)*b*x**S(2)/S(2) + S(10)*a**S(3)*b**S(2)*x**S(3)/S(3) + S(5)*a**S(2)*b**S(3)*x**S(4)/S(2) + a*b**S(4)*x**S(5) + b**S(5)*x**S(6)/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(a**S(5) + S(5)*a**S(4)*b*x + S(10)*a**S(3)*b**S(2)*x**S(2) + S(10)*a**S(2)*b**S(3)*x**S(3) + S(5)*a*b**S(4)*x**S(4) + b**S(5)*x**S(5)), x), x, -S(1)/(S(4)*b*(a + b*x)**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(5) + S(5)*a**S(4)*b*x + S(10)*a**S(3)*b**S(2)*x**S(2) + S(10)*a**S(2)*b**S(3)*x**S(3) + S(5)*a*b**S(4)*x**S(4) + b**S(5)*x**S(5))**(S(-2)), x), x, -S(1)/(S(9)*b*(a + b*x)**S(9)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(5) + S(5)*a**S(4)*b*x + S(10)*a**S(3)*b**S(2)*x**S(2) + S(10)*a**S(2)*b**S(3)*x**S(3) + S(5)*a*b**S(4)*x**S(4) + b**S(5)*x**S(5))**(S(-3)), x), x, -S(1)/(S(14)*b*(a + b*x)**S(14)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(c + (a + b*x)**S(2)), x), x, -S(3)*a*x/b**S(3) - a*(a**S(2) - S(3)*c)*atan((a + b*x)/sqrt(c))/(b**S(4)*sqrt(c)) + (a + b*x)**S(2)/(S(2)*b**S(4)) + (S(3)*a**S(2)/S(2) - c/S(2))*log(c + (a + b*x)**S(2))/b**S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(c + (a + b*x)**S(2)), x), x, -a*log(c + (a + b*x)**S(2))/b**S(3) + x/b**S(2) + (a**S(2) - c)*atan((a + b*x)/sqrt(c))/(b**S(3)*sqrt(c)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(c + (a + b*x)**S(2)), x), x, -a*atan((a + b*x)/sqrt(c))/(b**S(2)*sqrt(c)) + log(c + (a + b*x)**S(2))/(S(2)*b**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(c + (a + b*x)**S(2)), x), x, atan((a + b*x)/sqrt(c))/(b*sqrt(c)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(c + (a + b*x)**S(2))), x), x, -a*atan((a + b*x)/sqrt(c))/(sqrt(c)*(a**S(2) + c)) + log(x)/(a**S(2) + c) - log(c + (a + b*x)**S(2))/(S(2)*(a**S(2) + c)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(c + (a + b*x)**S(2))), x), x, -S(2)*a*b*log(x)/(a**S(2) + c)**S(2) + a*b*log(c + (a + b*x)**S(2))/(a**S(2) + c)**S(2) + b*(a**S(2) - c)*atan((a + b*x)/sqrt(c))/(sqrt(c)*(a**S(2) + c)**S(2)) - S(1)/(x*(a**S(2) + c)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*(c + (a + b*x)**S(2))), x), x, -a*b**S(2)*(a**S(2) - S(3)*c)*atan((a + b*x)/sqrt(c))/(sqrt(c)*(a**S(2) + c)**S(3)) + S(2)*a*b/(x*(a**S(2) + c)**S(2)) + b**S(2)*(S(3)*a**S(2) - c)*log(x)/(a**S(2) + c)**S(3) - b**S(2)*(S(3)*a**S(2) - c)*log(c + (a + b*x)**S(2))/(S(2)*(a**S(2) + c)**S(3)) - S(1)/(S(2)*x**S(2)*(a**S(2) + c)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(a + b*(c + d*x)**S(2)), x), x, atan(sqrt(b)*(c + d*x)/sqrt(a))/(sqrt(a)*sqrt(b)*d), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*(c + d*x)**S(2))**(S(-2)), x), x, (c/S(2) + d*x/S(2))/(a*d*(a + b*(c + d*x)**S(2))) + atan(sqrt(b)*(c + d*x)/sqrt(a))/(S(2)*a**(S(3)/2)*sqrt(b)*d), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*(c + d*x)**S(2))**(S(-3)), x), x, (c/S(4) + d*x/S(4))/(a*d*(a + b*(c + d*x)**S(2))**S(2)) + (S(3)*c/S(8) + S(3)*d*x/S(8))/(a**S(2)*d*(a + b*(c + d*x)**S(2))) + S(3)*atan(sqrt(b)*(c + d*x)/sqrt(a))/(S(8)*a**(S(5)/2)*sqrt(b)*d), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(b*(c + d*x)**S(2) + sqrt(-a)), x), x, atan(sqrt(b)*(c + d*x)/(-a)**(S(1)/4))/(sqrt(b)*d*(-a)**(S(1)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((c + d*x)**S(2) + S(1)), x), x, atan(c + d*x)/d, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(((c + d*x)**S(2) + S(1))**(S(-2)), x), x, (c/S(2) + d*x/S(2))/(d*((c + d*x)**S(2) + S(1))) + atan(c + d*x)/(S(2)*d), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(((c + d*x)**S(2) + S(1))**(S(-3)), x), x, (c/S(4) + d*x/S(4))/(d*((c + d*x)**S(2) + S(1))**S(2)) + (S(3)*c/S(8) + S(3)*d*x/S(8))/(d*((c + d*x)**S(2) + S(1))) + S(3)*atan(c + d*x)/(S(8)*d), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(-(c + d*x)**S(2) + S(1)), x), x, atanh(c + d*x)/d, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-(c + d*x)**S(2) + S(1))**(S(-2)), x), x, (c/S(2) + d*x/S(2))/(d*(-(c + d*x)**S(2) + S(1))) + atanh(c + d*x)/(S(2)*d), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-(c + d*x)**S(2) + S(1))**(S(-3)), x), x, (c/S(4) + d*x/S(4))/(d*(-(c + d*x)**S(2) + S(1))**S(2)) + (S(3)*c/S(8) + S(3)*d*x/S(8))/(d*(-(c + d*x)**S(2) + S(1))) + S(3)*atanh(c + d*x)/(S(8)*d), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(-(x + S(1))**S(2) + S(1)), x), x, atanh(x + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-(x + S(1))**S(2) + S(1))**(S(-2)), x), x, (x/S(2) + S(1)/2)/(-(x + S(1))**S(2) + S(1)) + atanh(x + S(1))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-(x + S(1))**S(2) + S(1))**(S(-3)), x), x, (x/S(4) + S(1)/4)/(-(x + S(1))**S(2) + S(1))**S(2) + (S(3)*x/S(8) + S(3)/8)/(-(x + S(1))**S(2) + S(1)) + S(3)*atanh(x + S(1))/S(8), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(((a + b*x)**S(2) + S(1))**S(2)/x, x), x, a*b*x*(a**S(2) + S(2)) + a*(a + b*x)**S(3)/S(3) + (a + b*x)**S(4)/S(4) + (a + b*x)**S(2)*(a**S(2)/S(2) + S(1)) + (a**S(2) + S(1))**S(2)*log(x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/((x + S(-1))**S(2) + S(1)), x), x, x + log((x + S(-1))**S(2) + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/sqrt(-(x + S(1))**S(2) + S(1)), x), x, -x*sqrt(-(x + S(1))**S(2) + S(1))/S(2) + S(3)*sqrt(-(x + S(1))**S(2) + S(1))/S(2) + S(3)*asin(x + S(1))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/sqrt(-(a + b*x)**S(2) + S(1)), x), x, S(3)*a*sqrt(-(a + b*x)**S(2) + S(1))/(S(2)*b**S(3)) - x*sqrt(-(a + b*x)**S(2) + S(1))/(S(2)*b**S(2)) + (a**S(2) + S(1)/2)*asin(a + b*x)/b**S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/sqrt((a + b*x)**S(2) + S(1)), x), x, -S(3)*a*sqrt((a + b*x)**S(2) + S(1))/(S(2)*b**S(3)) + x*sqrt((a + b*x)**S(2) + S(1))/(S(2)*b**S(2)) + (a**S(2) + S(-1)/2)*asinh(a + b*x)/b**S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x + C*x**S(2) + D*x**S(3))/(a*x**S(4) + a + b*x**S(3) + b*x + c*x**S(2)), x), x, -(D*(b - sqrt(S(8)*a**S(2) - S(4)*a*c + b**S(2))) + S(2)*a*(A - C))*log(S(2)*a*x**S(2) + S(2)*a + x*(b - sqrt(S(8)*a**S(2) - S(4)*a*c + b**S(2))))/(S(4)*a*sqrt(S(8)*a**S(2) - S(4)*a*c + b**S(2))) + (D*(b + sqrt(S(8)*a**S(2) - S(4)*a*c + b**S(2))) + S(2)*a*(A - C))*log(S(2)*a*x**S(2) + S(2)*a + x*(b + sqrt(S(8)*a**S(2) - S(4)*a*c + b**S(2))))/(S(4)*a*sqrt(S(8)*a**S(2) - S(4)*a*c + b**S(2))) - sqrt(S(2))*(S(4)*B*a**S(2) + D*b*(b + sqrt(S(8)*a**S(2) - S(4)*a*c + b**S(2))) - a*(A*(b + sqrt(S(8)*a**S(2) - S(4)*a*c + b**S(2))) + C*b + C*sqrt(S(8)*a**S(2) - S(4)*a*c + b**S(2)) + S(2)*D*c))*atan(sqrt(S(2))*(S(4)*a*x + b + sqrt(S(8)*a**S(2) - S(4)*a*c + b**S(2)))/(S(2)*sqrt(S(4)*a**S(2) + S(2)*a*c - b*(b + sqrt(S(8)*a**S(2) - S(4)*a*c + b**S(2))))))/(S(2)*a*sqrt(S(4)*a**S(2) + S(2)*a*c - b*(b + sqrt(S(8)*a**S(2) - S(4)*a*c + b**S(2))))*sqrt(S(8)*a**S(2) - S(4)*a*c + b**S(2))) + sqrt(S(2))*(S(4)*B*a**S(2) + D*b*(b - sqrt(S(8)*a**S(2) - S(4)*a*c + b**S(2))) - a*(A*(b - sqrt(S(8)*a**S(2) - S(4)*a*c + b**S(2))) + C*b - C*sqrt(S(8)*a**S(2) - S(4)*a*c + b**S(2)) + S(2)*D*c))*atan(sqrt(S(2))*(S(4)*a*x + b - sqrt(S(8)*a**S(2) - S(4)*a*c + b**S(2)))/(S(2)*sqrt(S(4)*a**S(2) + S(2)*a*c - b*(b - sqrt(S(8)*a**S(2) - S(4)*a*c + b**S(2))))))/(S(2)*a*sqrt(S(4)*a**S(2) + S(2)*a*c - b*(b - sqrt(S(8)*a**S(2) - S(4)*a*c + b**S(2))))*sqrt(S(8)*a**S(2) - S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)*(S(2)*x**S(3) + S(3)*x**S(2) + x + S(5))/(S(2)*x**S(4) + x**S(3) + S(3)*x**S(2) + x + S(2)), x), x, x**S(4)/S(4) + x**S(3)/S(3) - S(3)*x**S(2)/S(4) + S(5)*x/S(4) + log(x**S(2) + x + S(1))/S(3) - S(13)*log(S(2)*x**S(2) - x + S(2))/S(48) + sqrt(S(15))*atan(sqrt(S(15))*(-S(4)*x + S(1))/S(15))/S(72) - S(10)*sqrt(S(3))*atan(sqrt(S(3))*(S(2)*x + S(1))/S(3))/S(9), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(S(2)*x**S(3) + S(3)*x**S(2) + x + S(5))/(S(2)*x**S(4) + x**S(3) + S(3)*x**S(2) + x + S(2)), x), x, x**S(3)/S(3) + x**S(2)/S(2) - S(3)*x/S(2) + S(2)*log(x**S(2) + x + S(1))/S(3) - log(S(2)*x**S(2) - x + S(2))/S(24) + S(5)*sqrt(S(15))*atan(sqrt(S(15))*(-S(4)*x + S(1))/S(15))/S(36) + S(8)*sqrt(S(3))*atan(sqrt(S(3))*(S(2)*x + S(1))/S(3))/S(9), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(S(2)*x**S(3) + S(3)*x**S(2) + x + S(5))/(S(2)*x**S(4) + x**S(3) + S(3)*x**S(2) + x + S(2)), x), x, x**S(2)/S(2) + x - log(x**S(2) + x + S(1)) + log(S(2)*x**S(2) - x + S(2))/S(4) + sqrt(S(15))*atan(sqrt(S(15))*(-S(4)*x + S(1))/S(15))/S(18) + S(2)*sqrt(S(3))*atan(sqrt(S(3))*(S(2)*x + S(1))/S(3))/S(9), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(S(2)*x**S(3) + S(3)*x**S(2) + x + S(5))/(S(2)*x**S(4) + x**S(3) + S(3)*x**S(2) + x + S(2)), x), x, x + log(x**S(2) + x + S(1))/S(3) + log(S(2)*x**S(2) - x + S(2))/S(6) - sqrt(S(15))*atan(sqrt(S(15))*(-S(4)*x + S(1))/S(15))/S(9) - S(10)*sqrt(S(3))*atan(sqrt(S(3))*(S(2)*x + S(1))/S(3))/S(9), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x**S(3) + S(3)*x**S(2) + x + S(5))/(S(2)*x**S(4) + x**S(3) + S(3)*x**S(2) + x + S(2)), x), x, S(2)*log(x**S(2) + x + S(1))/S(3) - log(S(2)*x**S(2) - x + S(2))/S(6) - sqrt(S(15))*atan(sqrt(S(15))*(-S(4)*x + S(1))/S(15))/S(9) + S(8)*sqrt(S(3))*atan(sqrt(S(3))*(S(2)*x + S(1))/S(3))/S(9), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x**S(3) + S(3)*x**S(2) + x + S(5))/(x*(S(2)*x**S(4) + x**S(3) + S(3)*x**S(2) + x + S(2))), x), x, S(5)*log(x)/S(2) - log(x**S(2) + x + S(1)) - log(S(2)*x**S(2) - x + S(2))/S(4) + sqrt(S(15))*atan(sqrt(S(15))*(-S(4)*x + S(1))/S(15))/S(18) + S(2)*sqrt(S(3))*atan(sqrt(S(3))*(S(2)*x + S(1))/S(3))/S(9), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x**S(3) + S(3)*x**S(2) + x + S(5))/(x**S(2)*(S(2)*x**S(4) + x**S(3) + S(3)*x**S(2) + x + S(2))), x), x, -S(3)*log(x)/S(4) + log(x**S(2) + x + S(1))/S(3) + log(S(2)*x**S(2) - x + S(2))/S(24) + S(5)*sqrt(S(15))*atan(sqrt(S(15))*(-S(4)*x + S(1))/S(15))/S(36) - S(10)*sqrt(S(3))*atan(sqrt(S(3))*(S(2)*x + S(1))/S(3))/S(9) - S(5)/(S(2)*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x**S(3) + S(3)*x**S(2) + x + S(5))/(x**S(3)*(S(2)*x**S(4) + x**S(3) + S(3)*x**S(2) + x + S(2))), x), x, -S(15)*log(x)/S(8) + S(2)*log(x**S(2) + x + S(1))/S(3) + S(13)*log(S(2)*x**S(2) - x + S(2))/S(48) + sqrt(S(15))*atan(sqrt(S(15))*(-S(4)*x + S(1))/S(15))/S(72) + S(8)*sqrt(S(3))*atan(sqrt(S(3))*(S(2)*x + S(1))/S(3))/S(9) + S(3)/(S(4)*x) - S(5)/(S(4)*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(S(2)*x**S(3) + S(3)*x**S(2) + x + S(5))/(S(2)*x**S(4) + x**S(3) + S(5)*x**S(2) + x + S(2)), x), x, x**S(3)*(S(7) - S(5)*sqrt(S(7))*I)/S(42) + x**S(3)*(S(7) + S(5)*sqrt(S(7))*I)/S(42) + x**S(2)*(S(7) - S(5)*sqrt(S(7))*I)/S(28) + x**S(2)*(S(7) + S(5)*sqrt(S(7))*I)/S(28) - x*(S(35) + S(9)*sqrt(S(7))*I)/S(28) - x*(S(35) - S(9)*sqrt(S(7))*I)/S(28) + S(3)*(S(7) - S(11)*sqrt(S(7))*I)*log(S(4)*x**S(2) + x*(S(1) - sqrt(S(7))*I) + S(4))/S(112) + S(3)*(S(7) + S(11)*sqrt(S(7))*I)*log(S(4)*x**S(2) + x*(S(1) + sqrt(S(7))*I) + S(4))/S(112) - S(11)*(-S(5)*sqrt(S(7)) + S(9)*I)*atan((S(8)*x + S(1) + sqrt(S(7))*I)/sqrt(S(70) - S(2)*sqrt(S(7))*I))/(S(4)*sqrt(S(490) - S(14)*sqrt(S(7))*I)) + S(11)*(S(5)*sqrt(S(7)) + S(9)*I)*atan((S(8)*x + S(1) - sqrt(S(7))*I)/sqrt(S(70) + S(2)*sqrt(S(7))*I))/(S(4)*sqrt(S(490) + S(14)*sqrt(S(7))*I)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(S(2)*x**S(3) + S(3)*x**S(2) + x + S(5))/(S(2)*x**S(4) + x**S(3) + S(5)*x**S(2) + x + S(2)), x), x, x**S(2)*(S(7) - S(5)*sqrt(S(7))*I)/S(28) + x**S(2)*(S(7) + S(5)*sqrt(S(7))*I)/S(28) + x*(S(7) - S(5)*sqrt(S(7))*I)/S(14) + x*(S(7) + S(5)*sqrt(S(7))*I)/S(14) - (S(35) + S(9)*sqrt(S(7))*I)*log(S(4)*x**S(2) + x*(S(1) - sqrt(S(7))*I) + S(4))/S(56) - (S(35) - S(9)*sqrt(S(7))*I)*log(S(4)*x**S(2) + x*(S(1) + sqrt(S(7))*I) + S(4))/S(56) + (-sqrt(S(7)) + S(53)*I)*atan((S(8)*x + S(1) + sqrt(S(7))*I)/sqrt(S(70) - S(2)*sqrt(S(7))*I))/(S(2)*sqrt(S(490) - S(14)*sqrt(S(7))*I)) - (sqrt(S(7)) + S(53)*I)*atan((S(8)*x + S(1) - sqrt(S(7))*I)/sqrt(S(70) + S(2)*sqrt(S(7))*I))/(S(2)*sqrt(S(490) + S(14)*sqrt(S(7))*I)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(S(2)*x**S(3) + S(3)*x**S(2) + x + S(5))/(S(2)*x**S(4) + x**S(3) + S(5)*x**S(2) + x + S(2)), x), x, x*(S(7) - S(5)*sqrt(S(7))*I)/S(14) + x*(S(7) + S(5)*sqrt(S(7))*I)/S(14) + (S(7) + S(5)*sqrt(S(7))*I)*log(S(4)*x**S(2) + x*(S(1) - sqrt(S(7))*I) + S(4))/S(28) + (S(7) - S(5)*sqrt(S(7))*I)*log(S(4)*x**S(2) + x*(S(1) + sqrt(S(7))*I) + S(4))/S(28) + (-S(7)*sqrt(S(7)) + S(19)*I)*atan((S(8)*x + S(1) + sqrt(S(7))*I)/sqrt(S(70) - S(2)*sqrt(S(7))*I))/sqrt(S(490) - S(14)*sqrt(S(7))*I) - (S(7)*sqrt(S(7)) + S(19)*I)*atan((S(8)*x + S(1) - sqrt(S(7))*I)/sqrt(S(70) + S(2)*sqrt(S(7))*I))/sqrt(S(490) + S(14)*sqrt(S(7))*I), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x**S(3) + S(3)*x**S(2) + x + S(5))/(S(2)*x**S(4) + x**S(3) + S(5)*x**S(2) + x + S(2)), x), x, (S(7) + S(5)*sqrt(S(7))*I)*log(S(4)*x**S(2) + x*(S(1) - sqrt(S(7))*I) + S(4))/S(28) + (S(7) - S(5)*sqrt(S(7))*I)*log(S(4)*x**S(2) + x*(S(1) + sqrt(S(7))*I) + S(4))/S(28) - (-S(7)*sqrt(S(7)) + S(19)*I)*atan((S(8)*x + S(1) + sqrt(S(7))*I)/sqrt(S(70) - S(2)*sqrt(S(7))*I))/sqrt(S(490) - S(14)*sqrt(S(7))*I) + (S(7)*sqrt(S(7)) + S(19)*I)*atan((S(8)*x + S(1) - sqrt(S(7))*I)/sqrt(S(70) + S(2)*sqrt(S(7))*I))/sqrt(S(490) + S(14)*sqrt(S(7))*I), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x**S(3) + S(3)*x**S(2) + x + S(5))/(x*(S(2)*x**S(4) + x**S(3) + S(5)*x**S(2) + x + S(2))), x), x, (S(35) - S(9)*sqrt(S(7))*I)*log(x)/S(28) + (S(35) + S(9)*sqrt(S(7))*I)*log(x)/S(28) - (S(35) + S(9)*sqrt(S(7))*I)*log(S(4)*x**S(2) + x*(S(1) - sqrt(S(7))*I) + S(4))/S(56) - (S(35) - S(9)*sqrt(S(7))*I)*log(S(4)*x**S(2) + x*(S(1) + sqrt(S(7))*I) + S(4))/S(56) - (-sqrt(S(7)) + S(53)*I)*atan((S(8)*x + S(1) + sqrt(S(7))*I)/sqrt(S(70) - S(2)*sqrt(S(7))*I))/(S(2)*sqrt(S(490) - S(14)*sqrt(S(7))*I)) + (sqrt(S(7)) + S(53)*I)*atan((S(8)*x + S(1) - sqrt(S(7))*I)/sqrt(S(70) + S(2)*sqrt(S(7))*I))/(S(2)*sqrt(S(490) + S(14)*sqrt(S(7))*I)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x**S(3) + S(3)*x**S(2) + x + S(5))/(x**S(2)*(S(2)*x**S(4) + x**S(3) + S(5)*x**S(2) + x + S(2))), x), x, -S(3)*(S(7) + S(11)*sqrt(S(7))*I)*log(x)/S(56) - S(3)*(S(7) - S(11)*sqrt(S(7))*I)*log(x)/S(56) + S(3)*(S(7) + S(11)*sqrt(S(7))*I)*log(S(4)*I*x**S(2) + x*(-sqrt(S(7)) + I) + S(4)*I)/S(112) + S(3)*(S(7) - S(11)*sqrt(S(7))*I)*log(S(4)*I*x**S(2) + x*(sqrt(S(7)) + I) + S(4)*I)/S(112) + S(11)*(S(9) + S(5)*sqrt(S(7))*I)*atanh((S(8)*I*x - sqrt(S(7)) + I)/sqrt(S(70) - S(2)*sqrt(S(7))*I))/(S(4)*sqrt(S(490) - S(14)*sqrt(S(7))*I)) - S(11)*(S(9) - S(5)*sqrt(S(7))*I)*atanh((S(8)*I*x + sqrt(S(7)) + I)/sqrt(S(70) + S(2)*sqrt(S(7))*I))/(S(4)*sqrt(S(490) + S(14)*sqrt(S(7))*I)) + (S(-5)/4 - S(9)*sqrt(S(7))*I/S(28))/x + (S(-5)/4 + S(9)*sqrt(S(7))*I/S(28))/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x**S(3) + S(3)*x**S(2) + x + S(5))/(x**S(3)*(S(2)*x**S(4) + x**S(3) + S(5)*x**S(2) + x + S(2))), x), x, -(S(35) + S(9)*sqrt(S(7))*I)*log(x)/S(16) - (S(35) - S(9)*sqrt(S(7))*I)*log(x)/S(16) + (S(35) - S(9)*sqrt(S(7))*I)*log(S(4)*I*x**S(2) + x*(-sqrt(S(7)) + I) + S(4)*I)/S(32) + (S(35) + S(9)*sqrt(S(7))*I)*log(S(4)*I*x**S(2) + x*(sqrt(S(7)) + I) + S(4)*I)/S(32) + (S(355) - S(73)*sqrt(S(7))*I)*atanh((S(8)*I*x - sqrt(S(7)) + I)/sqrt(S(70) - S(2)*sqrt(S(7))*I))/(S(8)*sqrt(S(490) - S(14)*sqrt(S(7))*I)) - (S(355) + S(73)*sqrt(S(7))*I)*atanh((S(8)*I*x + sqrt(S(7)) + I)/sqrt(S(70) + S(2)*sqrt(S(7))*I))/(S(8)*sqrt(S(490) + S(14)*sqrt(S(7))*I)) + (S(3)/8 - S(33)*sqrt(S(7))*I/S(56))/x + (S(3)/8 + S(33)*sqrt(S(7))*I/S(56))/x + (S(-5)/8 - S(9)*sqrt(S(7))*I/S(56))/x**S(2) + (S(-5)/8 + S(9)*sqrt(S(7))*I/S(56))/x**S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(3) + S(3)*x**S(2) + x + S(9))/((x**S(2) + S(1))*(x**S(2) + S(3))), x), x, log(x**S(2) + S(3))/S(2) + S(3)*atan(x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(3) + x**S(2) + x + S(3))/((x**S(2) + S(1))*(x**S(2) + S(3))), x), x, log(x**S(2) + S(3))/S(2) + atan(x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(3)*x**S(3) - x**S(2) + S(6)*x + S(-4))/((x**S(2) + S(1))*(x**S(2) + S(2))), x), x, S(3)*log(x**S(2) + S(1))/S(2) - S(3)*atan(x) + sqrt(S(2))*atan(sqrt(S(2))*x/S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-S(3)*x**S(4) + S(1))/((x + S(-2))*(x**S(2) + S(1))**S(2)), x), x, (S(2)*x/S(5) + S(-1)/5)/(x**S(2) + S(1)) - S(47)*log(-x + S(2))/S(25) - S(14)*log(x**S(2) + S(1))/S(25) - S(46)*atan(x)/S(25), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x**S(2) - S(9)*x + S(-9))/(x**S(3) - S(9)*x), x), x, log(x) - log(-x + S(3)) + S(2)*log(x + S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(5) + S(2)*x**S(2) + S(1))/(x**S(3) - x), x), x, x**S(3)/S(3) + x - log(x) + S(2)*log(-x + S(1)) + log(x + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x**S(2) + S(3))/(x*(x + S(-1))**S(2)), x), x, S(3)*log(x) - log(-x + S(1)) + S(5)/(-x + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x**S(2) + S(-1))/((S(4)*x + S(-1))*(x**S(2) + S(1))), x), x, -S(7)*log(-S(4)*x + S(1))/S(34) + S(6)*log(x**S(2) + S(1))/S(17) + S(3)*atan(x)/S(17), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(3) - S(3)*x**S(2) + S(2)*x + S(-3))/(x**S(2) + S(1)), x), x, x**S(2)/S(2) - S(3)*x + log(x**S(2) + S(1))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(4) + S(6)*x**S(3) + S(10)*x**S(2) + x)/(x**S(2) + S(6)*x + S(10)), x), x, x**S(3)/S(3) + log(x**S(2) + S(6)*x + S(10))/S(2) - S(3)*atan(x + S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(4) - S(3)*x**S(3) - S(7)*x**S(2) + S(27)*x + S(-18)), x), x, log(-x + S(1))/S(8) - log(-x + S(2))/S(5) + log(-x + S(3))/S(12) - log(x + S(3))/S(120), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(3) + S(1))/(x + S(-2)), x), x, x**S(3)/S(3) + x**S(2) + S(4)*x + S(9)*log(-x + S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(3)*x**S(3) - S(4)*x**S(2) + S(3)*x)/(x**S(2) + S(1)), x), x, S(3)*x**S(2)/S(2) - S(4)*x + S(4)*atan(x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(3)*x + S(5))/(x**S(3) - x**S(2) - x + S(1)), x), x, atanh(x) + S(4)/(-x + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(4) - x**S(3) - x + S(-1))/(x**S(3) - x**S(2)), x), x, x**S(2)/S(2) + S(2)*log(x) - S(2)*log(-x + S(1)) - S(1)/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(3) + x**S(2) + x + S(2))/(x**S(4) + S(3)*x**S(2) + S(2)), x), x, log(x**S(2) + S(2))/S(2) + atan(x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(5) - x**S(4) + S(4)*x**S(3) - S(4)*x**S(2) + S(8)*x + S(-4))/(x**S(2) + S(2))**S(3), x), x, log(x**S(2) + S(2))/S(2) - sqrt(S(2))*atan(sqrt(S(2))*x/S(2))/S(2) - S(1)/(x**S(2) + S(2))**S(2), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate((x**S(5) - x**S(4) + S(4)*x**S(3) - S(4)*x**S(2) + S(8)*x + S(-4))/(x**S(2) + S(2))**S(3), x), x, x**S(2)/(S(4)*(x**S(2) + S(2))) + x**S(2)/(S(2)*(x**S(2) + S(2))**S(2)) + log(x**S(2) + S(2))/S(2) - sqrt(S(2))*atan(sqrt(S(2))*x/S(2))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) - S(3)*x + S(-1))/(x**S(3) + x**S(2) - S(2)*x), x), x, log(x)/S(2) - log(-x + S(1)) + S(3)*log(x + S(2))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(4) - S(2)*x**S(3) + S(3)*x**S(2) - x + S(3))/(x**S(3) - S(2)*x**S(2) + S(3)*x), x), x, x**S(2)/S(2) + log(x) - log(x**S(2) - S(2)*x + S(3))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(3) + x + S(-1))/(x**S(2) + S(1))**S(2), x), x, -x/(S(2)*(x**S(2) + S(1))) + log(x**S(2) + S(1))/S(2) - atan(x)/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(4) + S(8)*x**S(3) - x**S(2) + S(2)*x + S(1))/((x**S(2) + x)*(x**S(3) + S(1))), x), x, log(x) - S(2)*log(x + S(1)) + log(x**S(2) - x + S(1)) - S(2)*sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x + S(1))/S(3))/S(3) - S(3)/(x + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(3) + x**S(2) - S(5)*x + S(15))/((x**S(2) + S(5))*(x**S(2) + S(2)*x + S(3))), x), x, log(x**S(2) + S(2)*x + S(3))/S(2) + S(5)*sqrt(S(2))*atan(sqrt(S(2))*(x + S(1))/S(2))/S(2) - sqrt(S(5))*atan(sqrt(S(5))*x/S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(6) + S(7)*x**S(5) + S(15)*x**S(4) + S(32)*x**S(3) + S(23)*x**S(2) + S(25)*x + S(-3))/((x**S(2) + S(1))**S(2)*(x**S(2) + x + S(2))**S(2)), x), x, log(x**S(2) + S(1)) - log(x**S(2) + x + S(2)) + S(1)/(x**S(2) + x + S(2)) - S(3)/(x**S(2) + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((x**S(2) + S(1))*(x**S(2) + S(4))), x), x, -atan(x/S(2))/S(6) + atan(x)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(3))/(x**S(2) + S(1)), x), x, a*atan(x) + b*x**S(2)/S(2) - b*log(x**S(2) + S(1))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) + x)/((x + S(4))*(x**S(2) + S(-4))), x), x, log(x + S(4)) - atanh(x/S(2))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) + S(4))/((x**S(2) + S(1))*(x**S(2) + S(2))), x), x, S(3)*atan(x) - sqrt(S(2))*atan(sqrt(S(2))*x/S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(4) + S(3)*x**S(2) - S(4)*x + S(5))/((x + S(-1))**S(2)*(x**S(2) + S(1))), x), x, x + log(-x + S(1))/S(2) + S(3)*log(x**S(2) + S(1))/S(4) + S(2)*atan(x) + S(5)/(S(2)*(-x + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(4) + S(1))/(x**S(2) + S(2)), x), x, x**S(3)/S(3) - S(2)*x + S(5)*sqrt(S(2))*atan(sqrt(S(2))*x/S(2))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(4) + S(2)*x + S(2))/(x**S(5) + x**S(4)), x), x, log(x + S(1)) - S(2)/(S(3)*x**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x**S(2) - S(5)*x + S(-1))/(x**S(3) - S(2)*x**S(2) - x + S(2)), x), x, S(2)*log(-x + S(1)) - log(-x + S(2)) + log(x + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(3) + x + S(2))/(x**S(4) + S(2)*x**S(2) + S(1)), x), x, x/(x**S(2) + S(1)) + log(x**S(2) + S(1))/S(2) + atan(x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(3) + x**S(2) + S(2)*x + S(1))/(x**S(4) + S(2)*x**S(2) + S(1)), x), x, log(x**S(2) + S(1))/S(2) + atan(x) - S(1)/(S(2)*(x**S(2) + S(1))), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate((x**S(3) + x**S(2) + S(2)*x + S(1))/(x**S(4) + S(2)*x**S(2) + S(1)), x), x, x**S(2)/(S(2)*(x**S(2) + S(1))) + log(x**S(2) + S(1))/S(2) + atan(x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(4)*x + S(3))/((x**S(2) + S(1))*(x**S(2) + S(2))), x), x, S(2)*log(x**S(2) + S(1)) - S(2)*log(x**S(2) + S(2)) + S(3)*atan(x) - S(3)*sqrt(S(2))*atan(sqrt(S(2))*x/S(2))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x + S(2))/((x**S(2) + S(1))*(x**S(2) + S(4))), x), x, log(x**S(2) + S(1))/S(6) - log(x**S(2) + S(4))/S(6) - atan(x/S(2))/S(3) + S(2)*atan(x)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(3) - x + S(2))/(x**S(2) - S(6)*x + S(-7)), x), x, x**S(2)/S(2) + S(6)*x + S(169)*log(-x + S(7))/S(4) - log(x + S(1))/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(5) + S(-1))/(x**S(2) + S(-1)), x), x, x**S(4)/S(4) + x**S(2)/S(2) + log(x + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(3) - x**S(2) + S(2)*x + S(5))/(x**S(2) + x + S(1)), x), x, x**S(2)/S(2) - S(2)*x + S(3)*log(x**S(2) + x + S(1))/S(2) + S(11)*sqrt(S(3))*atan(sqrt(S(3))*(S(2)*x + S(1))/S(3))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(4) - S(2)*x**S(3) + x + S(-3))/(S(2)*x**S(2) - S(8)*x + S(10)), x), x, x**S(3)/S(6) + x**S(2)/S(2) + S(3)*x/S(2) + S(3)*log(x**S(2) - S(4)*x + S(5))/S(4) - S(6)*atan(x + S(-2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(3) + S(3)*x**S(2) + S(2)*x + S(1))/((x + S(-3))*(x + S(-2))*(x + S(-1))), x), x, x + S(7)*log(-x + S(1))/S(2) - S(25)*log(-x + S(2)) + S(61)*log(-x + S(3))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(4) - x**S(3) + x**S(2) - S(7)*x + S(2))/(x**S(3) + x**S(2) - S(14)*x + S(-24)), x), x, x**S(2)/S(2) - S(2)*x + S(13)*log(-x + S(4))/S(3) - S(22)*log(x + S(2))/S(3) + S(20)*log(x + S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) + S(2))/(x*(x + S(-1))**S(2)*(x + S(1))), x), x, S(2)*log(x) - S(5)*log(-x + S(1))/S(4) - S(3)*log(x + S(1))/S(4) + S(3)/(S(2)*(-x + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(3) + x**S(2) + S(3))/(x**S(2) + S(2))**S(2), x), x, (x/S(4) + S(1))/(x**S(2) + S(2)) + log(x**S(2) + S(2))/S(2) + S(5)*sqrt(S(2))*atan(sqrt(S(2))*x/S(2))/S(8), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate((x**S(3) + x**S(2) + S(3))/(x**S(2) + S(2))**S(2), x), x, x*(-x/S(2) + S(1)/4)/(x**S(2) + S(2)) + log(x**S(2) + S(2))/S(2) + S(5)*sqrt(S(2))*atan(sqrt(S(2))*x/S(2))/S(8), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x**S(3) - S(4)*x**S(2) + S(70)*x + S(-35))/((x**S(2) - S(10)*x + S(26))*(x**S(2) - S(2)*x + S(17))), x), x, S(1003)*log(x**S(2) - S(10)*x + S(26))/S(1025) + S(22)*log(x**S(2) - S(2)*x + S(17))/S(1025) - S(4607)*atan(x/S(4) + S(-1)/4)/S(4100) + S(15033)*atan(x + S(-5))/S(1025), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) + S(2))/((x + S(-5))*(x + S(-3))*(x + S(4))), x), x, -S(11)*log(-x + S(3))/S(14) + S(3)*log(-x + S(5))/S(2) + S(2)*log(x + S(4))/S(7), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/((x + S(-1))*(x**S(2) + S(2))), x), x, x**S(2)/S(2) + x + log(-x + S(1))/S(3) - S(2)*log(x**S(2) + S(2))/S(3) - S(2)*sqrt(S(2))*atan(sqrt(S(2))*x/S(2))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x**S(2) + S(7)*x + S(-1))/(x**S(3) + x**S(2) - x + S(-1)), x), x, S(2)*log(-x + S(1)) - S(3)/(x + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x + S(1))/(x**S(3) - S(3)*x**S(2) + S(3)*x + S(-1)), x), x, -(S(2)*x + S(1))**S(2)/(S(6)*(-x + S(1))**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(3) + S(7)*x**S(2) - S(5)*x + S(5))/((x + S(-1))**S(2)*(x + S(1))**S(3)), x), x, -S(2)/(x + S(1))**S(2) + S(1)/(-x + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(3)*x**S(2) + S(3)*x + S(1))/(x**S(3) + S(2)*x**S(2) + S(2)*x + S(1)), x), x, log(x + S(1)) + log(x**S(2) + x + S(1)) - S(2)*sqrt(S(3))*atan(sqrt(S(3))*(S(2)*x + S(1))/S(3))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) + S(2)*x + S(-1))/(S(2)*x**S(3) + S(3)*x**S(2) - S(2)*x), x), x, log(x)/S(2) + log(-S(2)*x + S(1))/S(10) - log(x + S(2))/S(10), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(4) - S(2)*x**S(2) + S(4)*x + S(1))/(x**S(3) - x**S(2) - x + S(1)), x), x, x**S(2)/S(2) + x - S(2)*atanh(x) + S(2)/(-x + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x**S(2) - x + S(4))/(x**S(3) + S(4)*x), x), x, log(x) + log(x**S(2) + S(4))/S(2) - atan(x/S(2))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(3) + x**S(2) + S(1))/(x*(x + S(-1))*(x**S(2) + S(1))**S(3)*(x**S(2) + x + S(1))), x), x, S(3)*x/(S(16)*(x**S(2) + S(1))) - (-S(3)*x/S(8) + S(3)/8)/(x**S(2) + S(1)) + (x/S(8) + S(1)/8)/(x**S(2) + S(1))**S(2) - log(x) + log(-x + S(1))/S(8) + S(15)*log(x**S(2) + S(1))/S(16) - log(x**S(2) + x + S(1))/S(2) + S(7)*atan(x)/S(16) - sqrt(S(3))*atan(sqrt(S(3))*(S(2)*x + S(1))/S(3))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-x**S(3) + S(2)*x**S(2) - S(3)*x + S(1))/(x**S(2) + S(1))**S(2), x), x, (-x/S(2) + S(1))/(x**S(2) + S(1)) - log(x**S(2) + S(1))/S(2) + S(3)*atan(x)/S(2), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate((-x**S(3) + S(2)*x**S(2) - S(3)*x + S(1))/(x**S(2) + S(1))**S(2), x), x, -x*(S(2)*x + S(1))/(S(2)*(x**S(2) + S(1))) - log(x**S(2) + S(1))/S(2) + S(3)*atan(x)/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-x**S(3) + S(2)*x**S(2) - S(3)*x + S(1))/(x*(x**S(2) + S(1))**S(2)), x), x, (-x + S(-1)/2)/(x**S(2) + S(1)) + log(x) - log(x**S(2) + S(1))/S(2) - S(2)*atan(x), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate((-x**S(3) + S(2)*x**S(2) - S(3)*x + S(1))/(x*(x**S(2) + S(1))**S(2)), x), x, x*(x/S(2) + S(-1))/(x**S(2) + S(1)) + log(x) - log(x**S(2) + S(1))/S(2) - S(2)*atan(x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(4) + x**S(3) - x**S(2) - x + S(1))/(x**S(3) - x), x), x, x**S(2)/S(2) + x - log(x) + log(-x**S(2) + S(1))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(3) - S(4)*x**S(2) + S(2))/((x**S(2) + S(1))*(x**S(2) + S(2))), x), x, -log(x**S(2) + S(1))/S(2) + log(x**S(2) + S(2)) + S(6)*atan(x) - S(5)*sqrt(S(2))*atan(sqrt(S(2))*x/S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(4) + x**S(2) + S(1))/((x**S(2) + S(1))*(x**S(2) + S(4))**S(2)), x), x, -S(13)*x/(S(24)*(x**S(2) + S(4))) + S(25)*atan(x/S(2))/S(144) + atan(x)/S(9), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(3) + x**S(2) + S(1))/(x**S(4) + x**S(3) + S(2)*x**S(2)), x), x, -log(x)/S(4) + S(5)*log(x**S(2) + x + S(2))/S(8) + sqrt(S(7))*atan(sqrt(S(7))*(S(2)*x + S(1))/S(7))/S(28) - S(1)/(S(2)*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(3) + x**S(2) - S(12)*x + S(1))/(x**S(2) + x + S(-12)), x), x, x**S(2)/S(2) - S(2)*atanh(S(2)*x/S(7) + S(1)/7)/S(7), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate((x**S(3) + x**S(2) - S(12)*x + S(1))/(x**S(2) + x + S(-12)), x), x, x**S(2)/S(2) + log(-x + S(3))/S(7) - log(x + S(4))/S(7), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(6)*x**S(2) + S(5)*x + S(-3))/(x**S(3) + S(2)*x**S(2) - S(3)*x), x), x, log(x) + S(2)*log(-x + S(1)) + S(3)*log(x + S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(5)*x**S(2) + S(3)*x + S(-2))/(x**S(3) + S(2)*x**S(2)), x), x, S(2)*log(x) + S(3)*log(x + S(2)) + S(1)/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-S(4)*x**S(2) - S(2)*x + S(18))/(x**S(3) + S(4)*x**S(2) + x + S(-6)), x), x, log(-x + S(1)) - S(2)*log(x + S(2)) - S(3)*log(x + S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(3) - S(2)*x**S(2) + x + S(1))/(x**S(4) + S(5)*x**S(2) + S(4)), x), x, log(x**S(2) + S(4))/S(2) - S(3)*atan(x/S(2))/S(2) + atan(x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(4)*x**S(3) - S(27)*x**S(2) + S(5)*x + S(-32))/(S(30)*x**S(5) - S(13)*x**S(4) + S(50)*x**S(3) - S(286)*x**S(2) - S(299)*x + S(-70)), x), x, -S(3146)*log(-S(3)*x + S(7))/S(80155) - S(334)*log(S(2)*x + S(1))/S(323) + S(4822)*log(S(5)*x + S(2))/S(4879) + S(11049)*log(x**S(2) + x + S(5))/S(260015) + S(3988)*sqrt(S(19))*atan(sqrt(S(19))*(S(2)*x + S(1))/S(19))/S(260015), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(12)*x**S(5) - S(7)*x**S(3) - S(13)*x**S(2) + S(8))/(S(100)*x**S(6) - S(80)*x**S(5) + S(116)*x**S(4) - S(80)*x**S(3) + S(41)*x**S(2) - S(20)*x + S(4)), x), x, (-S(251)*x/S(726) + S(-313)/1452)/(S(2)*x**S(2) + S(1)) - S(59096)*log(-S(5)*x + S(2))/S(99825) + S(2843)*log(S(2)*x**S(2) + S(1))/S(7986) + S(503)*sqrt(S(2))*atan(sqrt(S(2))*x)/S(15972) + S(5828)/(S(9075)*(-S(5)*x + S(2))), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate((S(12)*x**S(5) - S(7)*x**S(3) - S(13)*x**S(2) + S(8))/(S(100)*x**S(6) - S(80)*x**S(5) + S(116)*x**S(4) - S(80)*x**S(3) + S(41)*x**S(2) - S(20)*x + S(4)), x), x, (-S(251)*x/S(726) + S(-313)/1452)/(S(2)*x**S(2) + S(1)) - S(59096)*log(-S(5)*x + S(2))/S(99825) + S(2843)*log(S(2)*x**S(2) + S(1))/S(7986) + S(503)*sqrt(S(2))*atan(sqrt(S(2))*x)/S(15972) + S(5828)/(S(9075)*(-S(5)*x + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(4) + S(9))/(x**S(2)*(x**S(2) + S(9))), x), x, x - S(10)*atan(x/S(3))/S(3) - S(1)/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(4) + S(2)*x)/(x**S(2) + S(1)), x), x, x**S(3)/S(3) - x + log(x**S(2) + S(1)) + atan(x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(3) - x)/((x + S(-1))**S(2)*(x**S(2) + S(1))), x), x, log(-x + S(1)) + atan(x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x**S(3) + S(3)*x**S(2) + S(5)*x + S(2))/(x**S(2) + x + S(1)), x), x, x**S(2) + x + log(x**S(2) + x + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(3)*x**S(3) - S(5)*x**S(2) - S(4)*x + S(3))/(x**S(3)*(x**S(2) + x + S(-1))), x), x, S(3)*log(x) - (sqrt(S(5)) + S(15))*log(S(2)*x + S(1) + sqrt(S(5)))/S(10) - (-sqrt(S(5)) + S(15))*log(S(2)*x - sqrt(S(5)) + S(1))/S(10) - S(1)/x + S(3)/(S(2)*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x**S(3) + S(5)*x**S(2) + S(8)*x + S(4))/(x**S(2) + S(2)*x + S(2))**S(2), x), x, log(x**S(2) + S(2)*x + S(2)) - atan(x + S(1)) - S(1)/(x**S(2) + S(2)*x + S(2)), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate((S(2)*x**S(3) + S(5)*x**S(2) + S(8)*x + S(4))/(x**S(2) + S(2)*x + S(2))**S(2), x), x, x*(x + S(2))/(S(2)*(x**S(2) + S(2)*x + S(2))) + log(x**S(2) + S(2)*x + S(2)) - atan(x + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)*(x + S(-1))**S(4)/(x**S(2) + S(1)), x), x, x**S(7)/S(7) - S(2)*x**S(6)/S(3) + x**S(5) - S(4)*x**S(3)/S(3) + S(4)*x - S(4)*atan(x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(4)*x**S(2) - S(20)*x)/(x**S(4) - S(10)*x**S(2) + S(9)), x), x, log(-x + S(1)) - log(-x + S(3))/S(2) + S(3)*log(x + S(1))/S(2) - S(2)*log(x + S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(4)*x**S(3) + x + S(-1))/(x**S(2)*(x + S(-1))*(x**S(2) + S(1))), x), x, S(2)*log(-x + S(1)) - log(x**S(2) + S(1)) + atan(x) - S(1)/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(4) - S(4)*x**S(3) + S(2)*x**S(2) - S(3)*x + S(1))/(x**S(2) + S(1))**S(3), x), x, atan(x) - (S(4)*x**S(2) + S(3))**S(2)/(S(4)*(x**S(2) + S(1))**S(2)), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate((x**S(4) - S(4)*x**S(3) + S(2)*x**S(2) - S(3)*x + S(1))/(x**S(2) + S(1))**S(3), x), x, x**S(2)/(S(4)*(x**S(2) + S(1))**S(2)) + atan(x) + S(7)/(S(4)*(x**S(2) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(4) - S(4)*x**S(3) + S(2)*x**S(2) - S(3)*x + S(1))/(x**S(6) + S(3)*x**S(4) + S(3)*x**S(2) + S(1)), x), x, atan(x) + S(2)/(x**S(2) + S(1)) - S(1)/(S(4)*(x**S(2) + S(1))**S(2)), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate((x**S(4) - S(4)*x**S(3) + S(2)*x**S(2) - S(3)*x + S(1))/(x**S(6) + S(3)*x**S(4) + S(3)*x**S(2) + S(1)), x), x, x**S(2)/(S(4)*(x**S(2) + S(1))**S(2)) + atan(x) + S(7)/(S(4)*(x**S(2) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x**S(3) + S(2)*x**S(2) + x + S(1))/(x**S(4) + x**S(3) + x**S(2)), x), x, log(x**S(2) + x + S(1)) - S(1)/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((x**S(2) - S(4)*x + S(4))*(x**S(2) - S(4)*x + S(5))), x), x, -atan(x + S(-2)) + S(1)/(-x + S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) + x + S(-3))/(x**S(2)*(x + S(-3))), x), x, log(-x + S(3)) - S(1)/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(4)*x**S(2) + x + S(1))/(S(4)*x**S(3) + x), x), x, log(x) + atan(S(2)*x)/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(3)*x**S(2) - x + S(1))/(x**S(3) - x**S(2)), x), x, S(3)*log(-x + S(1)) + S(1)/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) + S(3)*x + S(4))/(x**S(2) + x), x), x, x + S(4)*log(x) - S(2)*log(x + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(3)*x**S(2) + x + S(4))/(x**S(3) + x), x), x, S(4)*log(x) - log(x**S(2) + S(1))/S(2) + atan(x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(8)*x**S(2) - S(4)*x + S(7))/((S(4)*x + S(1))*(x**S(2) + S(1))), x), x, S(2)*log(S(4)*x + S(1)) - atan(x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/((x + S(-1))*(x**S(2) + S(2)*x + S(1))), x), x, log(-x + S(1))/S(4) + S(3)*log(x + S(1))/S(4) + S(1)/(S(2)*(x + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) + S(3)*x + S(-4))/((S(2)*x + S(-1))**S(2)*(S(2)*x + S(3))), x), x, S(41)*log(-S(2)*x + S(1))/S(128) - S(25)*log(S(2)*x + S(3))/S(128) - S(9)/(S(32)*(-S(2)*x + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(3)*x**S(2) - S(4)*x + S(5))/((x + S(-1))*(x**S(2) + S(1))), x), x, S(2)*log(-x + S(1)) + log(x**S(2) + S(1))/S(2) - S(3)*atan(x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) - S(2)*x + S(-1))/((x + S(-1))**S(2)*(x**S(2) + S(1))), x), x, log(-x + S(1)) - log(x**S(2) + S(1))/S(2) + atan(x) + S(1)/(x + S(-1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(3) + S(5))/((x**S(2) - S(6)*x + S(10))*(x**S(2) - x + S(1)/2)), x), x, S(56)*log(x**S(2) - S(6)*x + S(10))/S(221) + S(109)*log(S(2)*x**S(2) - S(2)*x + S(1))/S(442) + S(1026)*atan(x + S(-3))/S(221) + S(261)*atan(S(2)*x + S(-1))/S(221), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) + S(3)*x + S(4))/((x + S(-3))*(x + S(-2))*(x + S(-1))), x), x, S(4)*log(-x + S(1)) - S(14)*log(-x + S(2)) + S(11)*log(-x + S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(16)*x + S(1))/((x + S(5))**S(2)*(S(2)*x + S(-3))*(x**S(2) + x + S(1))), x), x, S(200)*log(-S(2)*x + S(3))/S(3211) + S(2731)*log(x + S(5))/S(24843) - S(481)*log(x**S(2) + x + S(1))/S(5586) + S(451)*sqrt(S(3))*atan(sqrt(S(3))*(S(2)*x + S(1))/S(3))/S(8379) - S(79)/(S(273)*(x + S(5))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(3) + S(-1))/(x**S(2) + x + S(1)), x), x, x**S(2)/S(2) - x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(3) + S(-3))/(x**S(2) - S(6)*x + S(-7)), x), x, x**S(2)/S(2) + S(6)*x + S(85)*log(-x + S(7))/S(2) + log(x + S(1))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(3) + S(1))/(x**S(2) + S(4)*x + S(13))**S(2), x), x, (S(47)*x/S(18) + S(67)/18)/(x**S(2) + S(4)*x + S(13)) + log(x**S(2) + S(4)*x + S(13))/S(2) - S(61)*atan(x/S(3) + S(2)/3)/S(54), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(3)*x**S(5) - S(10)*x**S(4) + S(21)*x**S(3) - S(42)*x**S(2) + S(36)*x + S(-32))/(x*(x**S(2) + S(1))*(x**S(2) + S(4))**S(2)), x), x, -S(2)*log(x) + log(x**S(2) + S(4)) + atan(x/S(2))/S(2) + S(2)*atan(x) + S(1)/(x**S(2) + S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(9) + S(7)*x**S(5) + x**S(4) + S(-1))/(x**S(8) + S(6)*x**S(4) + S(-7)), x), x, x**S(2)/S(2) - sqrt(S(2))*S(7)**(S(1)/4)*log(x**S(2) - sqrt(S(2))*S(7)**(S(1)/4)*x + sqrt(S(7)))/S(56) + sqrt(S(2))*S(7)**(S(1)/4)*log(x**S(2) + sqrt(S(2))*S(7)**(S(1)/4)*x + sqrt(S(7)))/S(56) + sqrt(S(2))*S(7)**(S(1)/4)*atan(sqrt(S(2))*S(7)**(S(3)/4)*x/S(7) + S(-1))/S(28) + sqrt(S(2))*S(7)**(S(1)/4)*atan(sqrt(S(2))*S(7)**(S(3)/4)*x/S(7) + S(1))/S(28) - atanh(x**S(2))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(6) + x**S(3) + S(1))/(x**S(5) + x), x), x, x**S(2)/S(2) + log(x) - log(x**S(4) + S(1))/S(4) + sqrt(S(2))*log(x**S(2) - sqrt(S(2))*x + S(1))/S(8) - sqrt(S(2))*log(x**S(2) + sqrt(S(2))*x + S(1))/S(8) - atan(x**S(2))/S(2) + sqrt(S(2))*atan(sqrt(S(2))*x + S(-1))/S(4) + sqrt(S(2))*atan(sqrt(S(2))*x + S(1))/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) + S(1))/(x**S(2) - x), x), x, x - log(x) + S(2)*log(-x + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(3) + S(1))/(x**S(3) - x), x), x, x - log(x) + log(-x + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(3) + S(1))/(x**S(3) - x**S(2)), x), x, x - log(x) + S(2)*log(-x + S(1)) + S(1)/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(5) + S(-1))/(x**S(3) - x), x), x, x**S(3)/S(3) + x + log(x) - log(x + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(4) + S(1))/(x**S(5) + x**S(3)), x), x, -log(x) + log(x**S(2) + S(1)) - S(1)/(S(2)*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) + S(1))/(x**S(3) + S(2)*x**S(2) + x), x), x, log(x) + S(2)/(x + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(5) + S(1))/(x**S(3) - S(3)*x**S(2) - S(10)*x), x), x, x**S(3)/S(3) + S(3)*x**S(2)/S(2) + S(19)*x - log(x)/S(10) + S(3126)*log(-x + S(5))/S(35) - S(31)*log(x + S(2))/S(14), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(3) + x**S(2) - S(5)*x + S(15))/((x**S(2) + S(5))*(x**S(2) + S(2)*x + S(3))), x), x, log(x**S(2) + S(2)*x + S(3))/S(2) + S(5)*sqrt(S(2))*atan(sqrt(S(2))*(x + S(1))/S(2))/S(2) - sqrt(S(5))*atan(sqrt(S(5))*x/S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((x**S(2) + S(1))*(S(10)*x/(x**S(2) + S(1)) + S(3))), x), x, -log(x + S(3))/S(8) + log(S(3)*x + S(1))/S(8), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(S(15)*x + S(13) + S(2)/x), x), x, x**S(3)/S(45) - S(13)*x**S(2)/S(450) + S(139)*x/S(3375) - S(16)*log(S(3)*x + S(2))/S(567) + log(S(5)*x + S(1))/S(4375), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(S(15)*x + S(13) + S(2)/x), x), x, x**S(2)/S(30) - S(13)*x/S(225) + S(8)*log(S(3)*x + S(2))/S(189) - log(S(5)*x + S(1))/S(875), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(S(15)*x + S(13) + S(2)/x), x), x, x/S(15) - S(4)*log(S(3)*x + S(2))/S(63) + log(S(5)*x + S(1))/S(175), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(S(15)*x + S(13) + S(2)/x), x), x, S(2)*log(S(3)*x + S(2))/S(21) - log(S(5)*x + S(1))/S(35), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(S(15)*x + S(13) + S(2)/x)), x), x, -log(S(3)*x + S(2))/S(7) + log(S(5)*x + S(1))/S(7), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(S(15)*x + S(13) + S(2)/x)), x), x, log(x)/S(2) + S(3)*log(S(3)*x + S(2))/S(14) - S(5)*log(S(5)*x + S(1))/S(7), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*(S(15)*x + S(13) + S(2)/x)), x), x, -S(13)*log(x)/S(4) - S(9)*log(S(3)*x + S(2))/S(28) + S(25)*log(S(5)*x + S(1))/S(7) - S(1)/(S(2)*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(4)*(S(15)*x + S(13) + S(2)/x)), x), x, S(139)*log(x)/S(8) + S(27)*log(S(3)*x + S(2))/S(56) - S(125)*log(S(5)*x + S(1))/S(7) + S(13)/(S(4)*x) - S(1)/(S(4)*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(5)*(S(15)*x + S(13) + S(2)/x)), x), x, -S(1417)*log(x)/S(16) - S(81)*log(S(3)*x + S(2))/S(112) + S(625)*log(S(5)*x + S(1))/S(7) - S(139)/(S(8)*x) + S(13)/(S(8)*x**S(2)) - S(1)/(S(6)*x**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-x**S(2) + S(1))/(a + b*(-x**S(2) + S(1))**S(4)), x), x, -atanh(b**(S(1)/8)*x/sqrt(b**(S(1)/4) + I*(-a)**(S(1)/4)))/(S(4)*b**(S(3)/8)*sqrt(-a)*sqrt(b**(S(1)/4) + I*(-a)**(S(1)/4))) + atanh(b**(S(1)/8)*x/sqrt(b**(S(1)/4) + (-a)**(S(1)/4)))/(S(4)*b**(S(3)/8)*sqrt(-a)*sqrt(b**(S(1)/4) + (-a)**(S(1)/4))) + atan(b**(S(1)/8)*x/sqrt(-b**(S(1)/4) + I*(-a)**(S(1)/4)))/(S(4)*b**(S(3)/8)*sqrt(-a)*sqrt(-b**(S(1)/4) + I*(-a)**(S(1)/4))) - atan(b**(S(1)/8)*x/sqrt(-b**(S(1)/4) + (-a)**(S(1)/4)))/(S(4)*b**(S(3)/8)*sqrt(-a)*sqrt(-b**(S(1)/4) + (-a)**(S(1)/4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-x**S(2) + S(1))/(a + b*(x**S(2) + S(-1))**S(4)), x), x, -atanh(b**(S(1)/8)*x/sqrt(b**(S(1)/4) + I*(-a)**(S(1)/4)))/(S(4)*b**(S(3)/8)*sqrt(-a)*sqrt(b**(S(1)/4) + I*(-a)**(S(1)/4))) + atanh(b**(S(1)/8)*x/sqrt(b**(S(1)/4) + (-a)**(S(1)/4)))/(S(4)*b**(S(3)/8)*sqrt(-a)*sqrt(b**(S(1)/4) + (-a)**(S(1)/4))) + atan(b**(S(1)/8)*x/sqrt(-b**(S(1)/4) + I*(-a)**(S(1)/4)))/(S(4)*b**(S(3)/8)*sqrt(-a)*sqrt(-b**(S(1)/4) + I*(-a)**(S(1)/4))) - atan(b**(S(1)/8)*x/sqrt(-b**(S(1)/4) + (-a)**(S(1)/4)))/(S(4)*b**(S(3)/8)*sqrt(-a)*sqrt(-b**(S(1)/4) + (-a)**(S(1)/4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(4)*x**S(5) + S(-1))/(x**S(5) + x + S(1))**S(2), x), x, -x/(x**S(5) + x + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-a*d - S(2)*a*e*x - S(3)*a*f*x**S(2) + b*c - b*e*x**S(2) - S(2)*b*f*x**S(3))/(c + d*x + e*x**S(2) + f*x**S(3))**S(2), x), x, a/(c + d*x + e*x**S(2) + f*x**S(3)) + b*x/(c + d*x + e*x**S(2) + f*x**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-S(39)*x**S(8) + S(26)*x**S(6) + S(24)*x**S(5) + S(174)*x**S(4) - S(18)*x**S(2) - S(40)*x + S(9))/(x**S(4) + S(2)*x**S(2) + S(3))**S(3), x), x, S(13)*x/(x**S(4) + S(2)*x**S(2) + S(3)) + (-S(26)*x**S(3) - S(4)*x**S(2) - S(36)*x + S(2))/(x**S(4) + S(2)*x**S(2) + S(3))**S(2), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate((-S(39)*x**S(8) + S(26)*x**S(6) + S(24)*x**S(5) + S(174)*x**S(4) - S(18)*x**S(2) - S(40)*x + S(9))/(x**S(4) + S(2)*x**S(2) + S(3))**S(3), x), x, x*(-S(2)*x**S(3) - S(4)*x + S(117))/(S(9)*(x**S(4) + S(2)*x**S(2) + S(3))) - S(2)*x*(x**S(3) + S(39)*x**S(2) + S(8)*x + S(54))/(S(3)*(x**S(4) + S(2)*x**S(2) + S(3))**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(30)*x**S(9) - S(8)*x**S(7) - S(15)*x**S(6) - S(140)*x**S(5) + S(34)*x**S(4) - S(12)*x**S(3) - S(5)*x**S(2) + S(36)*x + S(-15))/(x**S(4) + x + S(3))**S(4), x), x, -S(5)*x**S(6)/(x**S(4) + x + S(3))**S(3) + x**S(4)/(x**S(4) + x + S(3))**S(3) + S(5)*x**S(2)/(x**S(4) + x + S(3))**S(3) - S(3)*x/(x**S(4) + x + S(3))**S(3) + S(2)/(x**S(4) + x + S(3))**S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(30)*x/(x**S(4) + x + S(3))**S(2) + (-S(8)*x**S(3) - S(75)*x**S(2) - S(320)*x + S(42))/(x**S(4) + x + S(3))**S(3) + (S(57)*x**S(3) + S(360)*x**S(2) + S(684)*x + S(-141))/(x**S(4) + x + S(3))**S(4), x), x, (-S(5)*x**S(6) + x**S(4) + S(5)*x**S(2) - S(3)*x + S(2))/(x**S(4) + x + S(3))**S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(-(S(12)*x**S(3) + S(3))*(-S(5)*x**S(6) + x**S(4) + S(5)*x**S(2) - S(3)*x + S(2))/(x**S(4) + x + S(3))**S(4) + (-S(30)*x**S(5) + S(4)*x**S(3) + S(10)*x + S(-3))/(x**S(4) + x + S(3))**S(3), x), x, (-S(5)*x**S(6) + x**S(4) + S(5)*x**S(2) - S(3)*x + S(2))/(x**S(4) + x + S(3))**S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x + S(-1))/(x**S(2) - x + S(1)), x), x, log(x**S(2) - x + S(1))/S(2) + sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x + S(1))/S(3))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) + S(-1))/(x**S(3) + S(1)), x), x, log(x**S(2) - x + S(1))/S(2) + sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x + S(1))/S(3))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(3)*x + S(-4))/(x**S(2) - S(2)*x + S(4)), x), x, S(3)*log(x**S(2) - S(2)*x + S(4))/S(2) + sqrt(S(3))*atan(sqrt(S(3))*(-x + S(1))/S(3))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(3)*x**S(2) + S(2)*x + S(-8))/(x**S(3) + S(8)), x), x, S(3)*log(x**S(2) - S(2)*x + S(4))/S(2) + sqrt(S(3))*atan(sqrt(S(3))*(-x + S(1))/S(3))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(4)*x + S(4))/(x**S(2)*(x**S(2) + S(1))), x), x, S(4)*log(x) - S(2)*log(x**S(2) + S(1)) - S(4)*atan(x) - S(4)/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(8)*x + S(24))/(x*(x**S(2) + S(-4))), x), x, -S(6)*log(x) + S(5)*log(-x + S(2)) + log(x + S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) + S(-1))/(x**S(3) - S(2)*x), x), x, log(x)/S(2) + log(-x**S(2) + S(2))/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) + S(1))/(x**S(3) + S(3)*x), x), x, log(x)/S(3) + log(x**S(2) + S(3))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + S(3)*b*x**S(2))/(a*x + b*x**S(3)), x), x, log(x) + log(a + b*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(4)*x + S(-2))/(x**S(3) - x), x), x, S(2)*log(x) + log(-x + S(1)) - S(3)*log(x + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x + S(4))/(x**S(3) + S(4)*x), x), x, log(x) - log(x**S(2) + S(4))/S(2) + atan(x/S(2))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x**S(3) - x)/(x**S(4) - x**S(2) + S(1)), x), x, log(x**S(4) - x**S(2) + S(1))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x + S(-3))/(x**S(3) + S(3)*x**S(2) + S(2)*x), x), x, -S(3)*log(x)/S(2) + S(4)*log(x + S(1)) - S(5)*log(x + S(2))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(4)*x + S(2))/(x**S(4) + S(2)*x**S(3) + x**S(2)), x), x, -S(2)/(x*(x + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x + S(1))/(x**S(3) + x**S(2) - S(6)*x), x), x, -log(x)/S(6) + S(3)*log(-x + S(2))/S(10) - S(2)*log(x + S(3))/S(15), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(3) + S(4)*x**S(2))/(x**S(3) + x), x), x, x + S(2)*log(x**S(2) + S(1)) - atan(x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x**S(3) + x)/(x**S(4) + x**S(2))**S(3), x), x, -S(1)/(S(4)*x**S(4)*(x**S(2) + S(1))**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*x**S(2) + b*x**S(3))/(c*x**S(2) + d*x**S(3)), x), x, b*x/d - (-a*d + b*c)*log(c + d*x)/d**S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) + x)/(x**S(3) - x**S(2) - S(2)*x), x), x, log(-x + S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-S(5)*x**S(2) + S(1))/(x**S(3)*(x**S(2) + S(1))), x), x, -S(6)*log(x) + S(3)*log(x**S(2) + S(1)) - S(1)/(S(2)*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(2)*x/((x + S(-1))*(x**S(2) + S(5))), x), x, log(-x + S(1))/S(3) - log(x**S(2) + S(5))/S(6) + sqrt(S(5))*atan(sqrt(S(5))*x/S(5))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) + S(2))/(x + S(2)), x), x, x**S(2)/S(2) - S(2)*x + S(6)*log(x + S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((x + S(-3))*(x**S(2) + S(4))), x), x, log(-x + S(3))/S(13) - log(x**S(2) + S(4))/S(26) - S(3)*atan(x/S(2))/S(26), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(3)*x**S(6) + S(-2))/(x*(S(2)*x**S(6) + S(5))), x), x, -S(2)*log(x)/S(5) + S(19)*log(S(2)*x**S(6) + S(5))/S(60), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x + S(3))/((x + S(-2))*(x + S(5))), x), x, log(-x + S(2)) + log(x + S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/(x**S(4) + S(5)*x**S(2) + S(4)), x), x, x - S(8)*atan(x/S(2))/S(3) + atan(x)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((x + S(1))*(x + S(2))**S(2)*(x + S(3))**S(3)), x), x, log(x + S(1))/S(8) + S(2)*log(x + S(2)) - S(17)*log(x + S(3))/S(8) + S(5)/(S(4)*(x + S(3))) + S(1)/(S(4)*(x + S(3))**S(2)) + S(1)/(x + S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(x**S(2) + S(-1)), x), x, log(-x**S(2) + S(1))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) + S(-1))**(S(-2)), x), x, x/(S(2)*(-x**S(2) + S(1))) + atanh(x)/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(x**S(2) + S(1))**S(2), x), x, -x/(S(2)*(x**S(2) + S(1))) + atan(x)/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(S(3)*x + S(2)), x), x, log(S(3)*x + S(2))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(a**S(2) + x**S(2)), x), x, atan(x/a)/a, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(a + b*x**S(2)), x), x, atan(sqrt(b)*x/sqrt(a))/(sqrt(a)*sqrt(b)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2) - x + S(2)), x), x, -S(2)*sqrt(S(7))*atan(sqrt(S(7))*(-S(2)*x + S(1))/S(7))/S(7), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(-x**S(2) + S(4))**S(2), x), x, x**S(7)/S(7) - S(8)*x**S(5)/S(5) + S(16)*x**S(3)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(-x**S(3) + S(1))**S(2), x), x, x**S(8)/S(8) - S(2)*x**S(5)/S(5) + x**S(2)/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(3) + S(5)*x**S(2) + S(-4))/x**S(2), x), x, x**S(2)/S(2) + S(5)*x + S(4)/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x + S(-1))/(S(3)*x**S(2) - S(4)*x + S(3)), x), x, log(S(3)*x**S(2) - S(4)*x + S(3))/S(6) + sqrt(S(5))*atan(sqrt(S(5))*(-S(3)*x + S(2))/S(5))/S(15), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(3) + S(2))**S(2), x), x, x**S(7)/S(7) + x**S(4) + S(4)*x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) + S(-4))/(x + S(2)), x), x, x**S(2)/S(2) - S(2)*x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((x + S(2))*(x**S(2) + S(1))), x), x, log(x + S(2))/S(5) - log(x**S(2) + S(1))/S(10) + S(2)*atan(x)/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((x + S(1))*(x**S(2) + S(1))), x), x, log(x + S(1))/S(2) - log(x**S(2) + S(1))/S(4) + atan(x)/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/((x + S(1))*(x**S(2) + S(1))), x), x, -log(x + S(1))/S(2) + log(x**S(2) + S(1))/S(4) + atan(x)/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) + S(2)*x)/(x + S(1))**S(2), x), x, (x + S(2))**S(2)/(x + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) + S(-10))/(S(2)*x**S(4) + S(9)*x**S(2) + S(4)), x), x, atan(x/S(2)) - S(3)*sqrt(S(2))*atan(sqrt(S(2))*x)/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(5)*x + S(31))/(S(3)*x**S(2) - S(4)*x + S(11)), x), x, S(5)*log(S(3)*x**S(2) - S(4)*x + S(11))/S(6) - S(103)*sqrt(S(29))*atan(sqrt(S(29))*(-S(3)*x + S(2))/S(29))/S(87), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(3) + x**S(2) + S(-2))/x**S(4), x), x, log(x) - S(1)/x + S(2)/(S(3)*x**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(3) + x + S(1))/x**S(2), x), x, x**S(2)/S(2) + log(x) - S(1)/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) + S(-2))/(x*(x**S(2) + S(2))), x), x, -log(x) + log(x**S(2) + S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x + S(-3))*(S(4)*x**S(2) + S(-7)), x), x, x**S(4) - S(4)*x**S(3) - S(7)*x**S(2)/S(2) + S(21)*x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(7)*x + S(-2))**S(3), x), x, (-S(7)*x + S(2))**S(4)/S(28), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(4)*x**S(2) + S(-7))/(S(2)*x + S(3)), x), x, x**S(2) - S(3)*x + log(S(2)*x + S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x + S(1))/(x**S(2)*(x + S(-1))), x), x, -S(2)*log(x) + S(2)*log(-x + S(1)) + S(1)/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(4) + S(4)*x**S(3) + S(4)*x**S(2)), x), x, atanh(x + S(1))/S(2) - S(1)/(S(4)*(x + S(2))) - S(1)/(S(4)*x), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(S(1)/(x**S(4) + S(4)*x**S(3) + S(4)*x**S(2)), x), x, -log(x)/S(4) + log(x + S(2))/S(4) - S(1)/(S(4)*(x + S(2))) - S(1)/(S(4)*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) + S(1))/(x + S(1)), x), x, x**S(2)/S(2) - x + S(2)*log(x + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(3) - S(3)*x**S(2) + S(3)*x + S(-1))/x**S(2), x), x, x**S(2)/S(2) - S(3)*x + S(3)*log(x) + S(1)/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x + S(3)/2 + sqrt(S(37))/S(2))*(x - sqrt(S(37))/S(2) + S(3)/2), x), x, x**S(3)/S(3) + S(3)*x**S(2)/S(2) - S(7)*x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x**S(3) + S(3)*x**S(2) + S(4))/(x + S(1))**S(4), x), x, S(2)*log(x + S(1)) + S(3)/(x + S(1)) - S(5)/(S(3)*(x + S(1))**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/((x + S(1))**S(2)*(x**S(2) + S(1))), x), x, atan(x)/S(2) + S(1)/(S(2)*(x + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(4) - x**S(3) + S(3)*x**S(2) - S(2)*x + S(7))/(x + S(2)), x), x, x**S(4)/S(4) - x**S(3) + S(9)*x**S(2)/S(2) - S(20)*x + S(47)*log(x + S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(3) + S(-1))/(x + S(-1)), x), x, x**S(3)/S(3) + x**S(2)/S(2) + x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x + S(2))/((x + S(-1))**S(3)*(x**S(2) + S(1))), x), x, atan(x) + S(1)/(x + S(-1)) - S(1)/(-x + S(1))**S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(b*x + c*(d + e*x)**S(2)), x), x, -S(2)*atanh((b + S(2)*c*d*e + S(2)*c*e**S(2)*x)/(sqrt(b)*sqrt(b + S(4)*c*d*e)))/(sqrt(b)*sqrt(b + S(4)*c*d*e)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(a + b*x + c*(d + e*x)**S(2)), x), x, -S(2)*atanh((b + S(2)*c*d*e + S(2)*c*e**S(2)*x)/sqrt(-S(4)*a*c*e**S(2) + b**S(2) + S(4)*b*c*d*e))/sqrt(-S(4)*a*c*e**S(2) + b**S(2) + S(4)*b*c*d*e), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/((x**S(2) + S(-1))**S(2) + S(1)), x), x, log(x**S(2) - x*sqrt(S(2) + S(2)*sqrt(S(2))) + sqrt(S(2)))/(S(4)*sqrt(S(2) + S(2)*sqrt(S(2)))) - log(x**S(2) + x*sqrt(S(2) + S(2)*sqrt(S(2))) + sqrt(S(2)))/(S(4)*sqrt(S(2) + S(2)*sqrt(S(2)))) - sqrt(S(1)/2 + sqrt(S(2))/S(2))*atan((-S(2)*x + sqrt(S(2) + S(2)*sqrt(S(2))))/sqrt(S(-2) + S(2)*sqrt(S(2))))/S(2) + sqrt(S(1)/2 + sqrt(S(2))/S(2))*atan((S(2)*x + sqrt(S(2) + S(2)*sqrt(S(2))))/sqrt(S(-2) + S(2)*sqrt(S(2))))/S(2), expand=True, _diff=True, _numerical=True)
def test_2():
assert rubi_test(rubi_integrate(x**S(5)*(a + b*x**S(2))/(sqrt(-c + d*x)*sqrt(c + d*x)), x), x, b*x**S(6)*sqrt(-c + d*x)*sqrt(c + d*x)/(S(7)*d**S(2)) + S(8)*c**S(4)*sqrt(-c + d*x)*sqrt(c + d*x)*(S(7)*a*d**S(2) + S(6)*b*c**S(2))/(S(105)*d**S(8)) + S(4)*c**S(2)*x**S(2)*sqrt(-c + d*x)*sqrt(c + d*x)*(S(7)*a*d**S(2) + S(6)*b*c**S(2))/(S(105)*d**S(6)) + x**S(4)*sqrt(-c + d*x)*sqrt(c + d*x)*(S(7)*a*d**S(2) + S(6)*b*c**S(2))/(S(35)*d**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)*(a + b*x**S(2))/(sqrt(-c + d*x)*sqrt(c + d*x)), x), x, b*x**S(5)*sqrt(-c + d*x)*sqrt(c + d*x)/(S(6)*d**S(2)) + c**S(4)*(S(6)*a*d**S(2) + S(5)*b*c**S(2))*atanh(sqrt(-c + d*x)/sqrt(c + d*x))/(S(8)*d**S(7)) + c**S(2)*x*sqrt(-c + d*x)*sqrt(c + d*x)*(S(6)*a*d**S(2) + S(5)*b*c**S(2))/(S(16)*d**S(6)) + x**S(3)*sqrt(-c + d*x)*sqrt(c + d*x)*(S(6)*a*d**S(2) + S(5)*b*c**S(2))/(S(24)*d**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(a + b*x**S(2))/(sqrt(-c + d*x)*sqrt(c + d*x)), x), x, b*x**S(4)*sqrt(-c + d*x)*sqrt(c + d*x)/(S(5)*d**S(2)) + S(2)*c**S(2)*sqrt(-c + d*x)*sqrt(c + d*x)*(S(5)*a*d**S(2) + S(4)*b*c**S(2))/(S(15)*d**S(6)) + x**S(2)*sqrt(-c + d*x)*sqrt(c + d*x)*(S(5)*a*d**S(2) + S(4)*b*c**S(2))/(S(15)*d**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(a + b*x**S(2))/(sqrt(-c + d*x)*sqrt(c + d*x)), x), x, b*x**S(3)*sqrt(-c + d*x)*sqrt(c + d*x)/(S(4)*d**S(2)) + c**S(2)*(S(4)*a*d**S(2) + S(3)*b*c**S(2))*atanh(sqrt(-c + d*x)/sqrt(c + d*x))/(S(4)*d**S(5)) + x*sqrt(-c + d*x)*sqrt(c + d*x)*(S(4)*a*d**S(2) + S(3)*b*c**S(2))/(S(8)*d**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a + b*x**S(2))/(sqrt(-c + d*x)*sqrt(c + d*x)), x), x, b*x**S(2)*sqrt(-c + d*x)*sqrt(c + d*x)/(S(3)*d**S(2)) + sqrt(-c + d*x)*sqrt(c + d*x)*(S(3)*a*d**S(2) + S(2)*b*c**S(2))/(S(3)*d**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2))/(sqrt(-c + d*x)*sqrt(c + d*x)), x), x, b*x*sqrt(-c + d*x)*sqrt(c + d*x)/(S(2)*d**S(2)) + (S(2)*a*d**S(2) + b*c**S(2))*atanh(sqrt(-c + d*x)/sqrt(c + d*x))/d**S(3), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate((a + b*x**S(2))/(sqrt(-c + d*x)*sqrt(c + d*x)), x), x, S(2)*a*atanh(sqrt(-c + d*x)/sqrt(c + d*x))/d + b*c**S(2)*atanh(sqrt(-c + d*x)/sqrt(c + d*x))/d**S(3) + b*x*sqrt(-c + d*x)*sqrt(c + d*x)/(S(2)*d**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2))/(x*sqrt(-c + d*x)*sqrt(c + d*x)), x), x, a*atan(sqrt(-c + d*x)*sqrt(c + d*x)/c)/c + b*sqrt(-c + d*x)*sqrt(c + d*x)/d**S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2))/(x**S(2)*sqrt(-c + d*x)*sqrt(c + d*x)), x), x, a*sqrt(-c + d*x)*sqrt(c + d*x)/(c**S(2)*x) + S(2)*b*atanh(sqrt(-c + d*x)/sqrt(c + d*x))/d, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2))/(x**S(3)*sqrt(-c + d*x)*sqrt(c + d*x)), x), x, a*sqrt(-c + d*x)*sqrt(c + d*x)/(S(2)*c**S(2)*x**S(2)) + (a*d**S(2) + S(2)*b*c**S(2))*atan(sqrt(-c + d*x)*sqrt(c + d*x)/c)/(S(2)*c**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2))/(x**S(4)*sqrt(-c + d*x)*sqrt(c + d*x)), x), x, a*sqrt(-c + d*x)*sqrt(c + d*x)/(S(3)*c**S(2)*x**S(3)) + sqrt(-c + d*x)*sqrt(c + d*x)*(S(2)*a*d**S(2) + S(3)*b*c**S(2))/(S(3)*c**S(4)*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2))/(x**S(5)*sqrt(-c + d*x)*sqrt(c + d*x)), x), x, a*sqrt(-c + d*x)*sqrt(c + d*x)/(S(4)*c**S(2)*x**S(4)) + sqrt(-c + d*x)*sqrt(c + d*x)*(S(3)*a*d**S(2) + S(4)*b*c**S(2))/(S(8)*c**S(4)*x**S(2)) + d**S(2)*(S(3)*a*d**S(2) + S(4)*b*c**S(2))*atan(sqrt(-c + d*x)*sqrt(c + d*x)/c)/(S(8)*c**S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2))/(x**S(6)*sqrt(-c + d*x)*sqrt(c + d*x)), x), x, a*sqrt(-c + d*x)*sqrt(c + d*x)/(S(5)*c**S(2)*x**S(5)) + sqrt(-c + d*x)*sqrt(c + d*x)*(S(4)*a*d**S(2) + S(5)*b*c**S(2))/(S(15)*c**S(4)*x**S(3)) + S(2)*d**S(2)*sqrt(-c + d*x)*sqrt(c + d*x)*(S(4)*a*d**S(2) + S(5)*b*c**S(2))/(S(15)*c**S(6)*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)*(a + b*x**S(2))/((-c + d*x)**(S(3)/2)*(c + d*x)**(S(3)/2)), x), x, b*x**S(6)/(S(5)*d**S(2)*sqrt(-c + d*x)*sqrt(c + d*x)) + S(8)*c**S(2)*sqrt(-c + d*x)*sqrt(c + d*x)*(S(5)*a*d**S(2) + S(6)*b*c**S(2))/(S(15)*d**S(8)) - x**S(4)*(S(5)*a*d**S(2) + S(6)*b*c**S(2))/(S(5)*d**S(4)*sqrt(-c + d*x)*sqrt(c + d*x)) + x**S(2)*sqrt(-c + d*x)*sqrt(c + d*x)*(S(20)*a*d**S(2) + S(24)*b*c**S(2))/(S(15)*d**S(6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)*(a + b*x**S(2))/((-c + d*x)**(S(3)/2)*(c + d*x)**(S(3)/2)), x), x, b*x**S(5)/(S(4)*d**S(2)*sqrt(-c + d*x)*sqrt(c + d*x)) + S(3)*c**S(2)*(S(4)*a*d**S(2) + S(5)*b*c**S(2))*atanh(sqrt(-c + d*x)/sqrt(c + d*x))/(S(4)*d**S(7)) - x**S(3)*(S(4)*a*d**S(2) + S(5)*b*c**S(2))/(S(4)*d**S(4)*sqrt(-c + d*x)*sqrt(c + d*x)) + x*sqrt(-c + d*x)*sqrt(c + d*x)*(S(12)*a*d**S(2) + S(15)*b*c**S(2))/(S(8)*d**S(6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(a + b*x**S(2))/((-c + d*x)**(S(3)/2)*(c + d*x)**(S(3)/2)), x), x, b*x**S(4)/(S(3)*d**S(2)*sqrt(-c + d*x)*sqrt(c + d*x)) - x**S(2)*(S(3)*a*d**S(2) + S(4)*b*c**S(2))/(S(3)*d**S(4)*sqrt(-c + d*x)*sqrt(c + d*x)) + sqrt(-c + d*x)*sqrt(c + d*x)*(S(6)*a*d**S(2) + S(8)*b*c**S(2))/(S(3)*d**S(6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(a + b*x**S(2))/((-c + d*x)**(S(3)/2)*(c + d*x)**(S(3)/2)), x), x, b*x**S(3)/(S(2)*d**S(2)*sqrt(-c + d*x)*sqrt(c + d*x)) - c*(S(2)*a*d**S(2) + S(3)*b*c**S(2))/(S(2)*d**S(5)*sqrt(-c + d*x)*sqrt(c + d*x)) - sqrt(-c + d*x)*(S(2)*a*d**S(2) + S(3)*b*c**S(2))/(S(2)*d**S(5)*sqrt(c + d*x)) + (S(2)*a*d**S(2) + S(3)*b*c**S(2))*atanh(sqrt(-c + d*x)/sqrt(c + d*x))/d**S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a + b*x**S(2))/((-c + d*x)**(S(3)/2)*(c + d*x)**(S(3)/2)), x), x, -x**S(2)*(a/c**S(2) + b/d**S(2))/(sqrt(-c + d*x)*sqrt(c + d*x)) + sqrt(-c + d*x)*sqrt(c + d*x)*(a*d**S(2) + S(2)*b*c**S(2))/(c**S(2)*d**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2))/((-c + d*x)**(S(3)/2)*(c + d*x)**(S(3)/2)), x), x, -a*x/(c**S(2)*sqrt(-c + d*x)*sqrt(c + d*x)) - b*c/(d**S(3)*sqrt(-c + d*x)*sqrt(c + d*x)) - b*sqrt(-c + d*x)/(d**S(3)*sqrt(c + d*x)) + S(2)*b*atanh(sqrt(-c + d*x)/sqrt(c + d*x))/d**S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2))/(x*(-c + d*x)**(S(3)/2)*(c + d*x)**(S(3)/2)), x), x, -a*atan(sqrt(-c + d*x)*sqrt(c + d*x)/c)/c**S(3) - (a/c**S(2) + b/d**S(2))/(sqrt(-c + d*x)*sqrt(c + d*x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2))/(x**S(2)*(-c + d*x)**(S(3)/2)*(c + d*x)**(S(3)/2)), x), x, a/(c**S(2)*x*sqrt(-c + d*x)*sqrt(c + d*x)) - x*(S(2)*a*d**S(2) + b*c**S(2))/(c**S(4)*sqrt(-c + d*x)*sqrt(c + d*x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2))/(x**S(3)*(-c + d*x)**(S(3)/2)*(c + d*x)**(S(3)/2)), x), x, a/(S(2)*c**S(2)*x**S(2)*sqrt(-c + d*x)*sqrt(c + d*x)) - (S(3)*a*d**S(2) + S(2)*b*c**S(2))/(S(2)*c**S(4)*sqrt(-c + d*x)*sqrt(c + d*x)) - (S(3)*a*d**S(2) + S(2)*b*c**S(2))*atan(sqrt(-c + d*x)*sqrt(c + d*x)/c)/(S(2)*c**S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2))/(x**S(4)*(-c + d*x)**(S(3)/2)*(c + d*x)**(S(3)/2)), x), x, a/(S(3)*c**S(2)*x**S(3)*sqrt(-c + d*x)*sqrt(c + d*x)) + (S(4)*a*d**S(2) + S(3)*b*c**S(2))/(S(3)*c**S(4)*x*sqrt(-c + d*x)*sqrt(c + d*x)) - S(2)*d**S(2)*x*(S(4)*a*d**S(2) + S(3)*b*c**S(2))/(S(3)*c**S(6)*sqrt(-c + d*x)*sqrt(c + d*x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2))/(x**S(5)*(-c + d*x)**(S(3)/2)*(c + d*x)**(S(3)/2)), x), x, a/(S(4)*c**S(2)*x**S(4)*sqrt(-c + d*x)*sqrt(c + d*x)) + (S(5)*a*d**S(2) + S(4)*b*c**S(2))/(S(8)*c**S(4)*x**S(2)*sqrt(-c + d*x)*sqrt(c + d*x)) - S(3)*d**S(2)*(S(5)*a*d**S(2) + S(4)*b*c**S(2))/(S(8)*c**S(6)*sqrt(-c + d*x)*sqrt(c + d*x)) - S(3)*d**S(2)*(S(5)*a*d**S(2) + S(4)*b*c**S(2))*atan(sqrt(-c + d*x)*sqrt(c + d*x)/c)/(S(8)*c**S(7)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2))/(x**S(6)*(-c + d*x)**(S(3)/2)*(c + d*x)**(S(3)/2)), x), x, a/(S(5)*c**S(2)*x**S(5)*sqrt(-c + d*x)*sqrt(c + d*x)) + (S(6)*a*d**S(2) + S(5)*b*c**S(2))/(S(15)*c**S(4)*x**S(3)*sqrt(-c + d*x)*sqrt(c + d*x)) + S(4)*d**S(2)*(S(6)*a*d**S(2) + S(5)*b*c**S(2))/(S(15)*c**S(6)*x*sqrt(-c + d*x)*sqrt(c + d*x)) - S(8)*d**S(4)*x*(S(6)*a*d**S(2) + S(5)*b*c**S(2))/(S(15)*c**S(8)*sqrt(-c + d*x)*sqrt(c + d*x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c**S(2)*x**S(2) + S(1))/(x*sqrt(c*x + S(-1))*sqrt(c*x + S(1))), x), x, sqrt(c*x + S(-1))*sqrt(c*x + S(1)) + atan(sqrt(c*x + S(-1))*sqrt(c*x + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(a + b*x)**n*(c + d*x**S(3)), x), x, S(10)*a**S(2)*d*(a + b*x)**(n + S(4))/(b**S(6)*(n + S(4))) + a**S(2)*(a + b*x)**(n + S(1))*(-a**S(3)*d + b**S(3)*c)/(b**S(6)*(n + S(1))) - S(5)*a*d*(a + b*x)**(n + S(5))/(b**S(6)*(n + S(5))) - a*(a + b*x)**(n + S(2))*(-S(5)*a**S(3)*d + S(2)*b**S(3)*c)/(b**S(6)*(n + S(2))) + d*(a + b*x)**(n + S(6))/(b**S(6)*(n + S(6))) + (a + b*x)**(n + S(3))*(-S(10)*a**S(3)*d + b**S(3)*c)/(b**S(6)*(n + S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a + b*x)**n*(c + d*x**S(3)), x), x, S(6)*a**S(2)*d*(a + b*x)**(n + S(3))/(b**S(5)*(n + S(3))) - S(4)*a*d*(a + b*x)**(n + S(4))/(b**S(5)*(n + S(4))) - a*(a + b*x)**(n + S(1))*(-a**S(3)*d + b**S(3)*c)/(b**S(5)*(n + S(1))) + d*(a + b*x)**(n + S(5))/(b**S(5)*(n + S(5))) + (a + b*x)**(n + S(2))*(-S(4)*a**S(3)*d + b**S(3)*c)/(b**S(5)*(n + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x)**n*(c + d*x**S(3)), x), x, S(3)*a**S(2)*d*(a + b*x)**(n + S(2))/(b**S(4)*(n + S(2))) - S(3)*a*d*(a + b*x)**(n + S(3))/(b**S(4)*(n + S(3))) + d*(a + b*x)**(n + S(4))/(b**S(4)*(n + S(4))) + (a + b*x)**(n + S(1))*(-a**S(3)*d + b**S(3)*c)/(b**S(4)*(n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x)**n*(c + d*x**S(3))/x, x), x, a**S(2)*d*(a + b*x)**(n + S(1))/(b**S(3)*(n + S(1))) - S(2)*a*d*(a + b*x)**(n + S(2))/(b**S(3)*(n + S(2))) + d*(a + b*x)**(n + S(3))/(b**S(3)*(n + S(3))) - c*(a + b*x)**(n + S(1))*hyper((S(1), n + S(1)), (n + S(2),), S(1) + b*x/a)/(a*(n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(a + b*x)**n*(c + d*x**S(3))**S(2), x), x, S(28)*a**S(2)*d**S(2)*(a + b*x)**(n + S(7))/(b**S(9)*(n + S(7))) + S(4)*a**S(2)*d*(a + b*x)**(n + S(4))*(-S(14)*a**S(3)*d + S(5)*b**S(3)*c)/(b**S(9)*(n + S(4))) + a**S(2)*(a + b*x)**(n + S(1))*(-a**S(3)*d + b**S(3)*c)**S(2)/(b**S(9)*(n + S(1))) - S(8)*a*d**S(2)*(a + b*x)**(n + S(8))/(b**S(9)*(n + S(8))) - S(10)*a*d*(a + b*x)**(n + S(5))*(-S(7)*a**S(3)*d + b**S(3)*c)/(b**S(9)*(n + S(5))) - S(2)*a*(a + b*x)**(n + S(2))*(-S(4)*a**S(3)*d + b**S(3)*c)*(-a**S(3)*d + b**S(3)*c)/(b**S(9)*(n + S(2))) + d**S(2)*(a + b*x)**(n + S(9))/(b**S(9)*(n + S(9))) + S(2)*d*(a + b*x)**(n + S(6))*(-S(28)*a**S(3)*d + b**S(3)*c)/(b**S(9)*(n + S(6))) + (a + b*x)**(n + S(3))*(S(28)*a**S(6)*d**S(2) - S(20)*a**S(3)*b**S(3)*c*d + b**S(6)*c**S(2))/(b**S(9)*(n + S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a + b*x)**n*(c + d*x**S(3))**S(2), x), x, S(21)*a**S(2)*d**S(2)*(a + b*x)**(n + S(6))/(b**S(8)*(n + S(6))) + S(3)*a**S(2)*d*(a + b*x)**(n + S(3))*(-S(7)*a**S(3)*d + S(4)*b**S(3)*c)/(b**S(8)*(n + S(3))) - S(7)*a*d**S(2)*(a + b*x)**(n + S(7))/(b**S(8)*(n + S(7))) - a*d*(a + b*x)**(n + S(4))*(-S(35)*a**S(3)*d + S(8)*b**S(3)*c)/(b**S(8)*(n + S(4))) - a*(a + b*x)**(n + S(1))*(-a**S(3)*d + b**S(3)*c)**S(2)/(b**S(8)*(n + S(1))) + d**S(2)*(a + b*x)**(n + S(8))/(b**S(8)*(n + S(8))) + d*(a + b*x)**(n + S(5))*(-S(35)*a**S(3)*d + S(2)*b**S(3)*c)/(b**S(8)*(n + S(5))) + (a + b*x)**(n + S(2))*(-S(7)*a**S(3)*d + b**S(3)*c)*(-a**S(3)*d + b**S(3)*c)/(b**S(8)*(n + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x)**n*(c + d*x**S(3))**S(2), x), x, S(15)*a**S(2)*d**S(2)*(a + b*x)**(n + S(5))/(b**S(7)*(n + S(5))) + S(6)*a**S(2)*d*(a + b*x)**(n + S(2))*(-a**S(3)*d + b**S(3)*c)/(b**S(7)*(n + S(2))) - S(6)*a*d**S(2)*(a + b*x)**(n + S(6))/(b**S(7)*(n + S(6))) - S(3)*a*d*(a + b*x)**(n + S(3))*(-S(5)*a**S(3)*d + S(2)*b**S(3)*c)/(b**S(7)*(n + S(3))) + d**S(2)*(a + b*x)**(n + S(7))/(b**S(7)*(n + S(7))) + S(2)*d*(a + b*x)**(n + S(4))*(-S(10)*a**S(3)*d + b**S(3)*c)/(b**S(7)*(n + S(4))) + (a + b*x)**(n + S(1))*(-a**S(3)*d + b**S(3)*c)**S(2)/(b**S(7)*(n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x)**n*(c + d*x**S(3))**S(2)/x, x), x, S(10)*a**S(2)*d**S(2)*(a + b*x)**(n + S(4))/(b**S(6)*(n + S(4))) + a**S(2)*d*(a + b*x)**(n + S(1))*(-a**S(3)*d + S(2)*b**S(3)*c)/(b**S(6)*(n + S(1))) - S(5)*a*d**S(2)*(a + b*x)**(n + S(5))/(b**S(6)*(n + S(5))) - a*d*(a + b*x)**(n + S(2))*(-S(5)*a**S(3)*d + S(4)*b**S(3)*c)/(b**S(6)*(n + S(2))) + d**S(2)*(a + b*x)**(n + S(6))/(b**S(6)*(n + S(6))) + S(2)*d*(a + b*x)**(n + S(3))*(-S(5)*a**S(3)*d + b**S(3)*c)/(b**S(6)*(n + S(3))) - c**S(2)*(a + b*x)**(n + S(1))*hyper((S(1), n + S(1)), (n + S(2),), S(1) + b*x/a)/(a*(n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(a + b*x)**n*(c + d*x**S(3))**S(3), x), x, S(55)*a**S(2)*d**S(3)*(a + b*x)**(n + S(10))/(b**S(12)*(n + S(10))) + S(42)*a**S(2)*d**S(2)*(a + b*x)**(n + S(7))*(-S(11)*a**S(3)*d + S(2)*b**S(3)*c)/(b**S(12)*(n + S(7))) + S(3)*a**S(2)*d*(a + b*x)**(n + S(4))*(S(55)*a**S(6)*d**S(2) - S(56)*a**S(3)*b**S(3)*c*d + S(10)*b**S(6)*c**S(2))/(b**S(12)*(n + S(4))) + a**S(2)*(a + b*x)**(n + S(1))*(-a**S(3)*d + b**S(3)*c)**S(3)/(b**S(12)*(n + S(1))) - S(11)*a*d**S(3)*(a + b*x)**(n + S(11))/(b**S(12)*(n + S(11))) - S(6)*a*d**S(2)*(a + b*x)**(n + S(8))*(-S(55)*a**S(3)*d + S(4)*b**S(3)*c)/(b**S(12)*(n + S(8))) - S(15)*a*d*(a + b*x)**(n + S(5))*(S(22)*a**S(6)*d**S(2) - S(14)*a**S(3)*b**S(3)*c*d + b**S(6)*c**S(2))/(b**S(12)*(n + S(5))) - a*(a + b*x)**(n + S(2))*(-S(11)*a**S(3)*d + S(2)*b**S(3)*c)*(-a**S(3)*d + b**S(3)*c)**S(2)/(b**S(12)*(n + S(2))) + d**S(3)*(a + b*x)**(n + S(12))/(b**S(12)*(n + S(12))) + S(3)*d**S(2)*(a + b*x)**(n + S(9))*(-S(55)*a**S(3)*d + b**S(3)*c)/(b**S(12)*(n + S(9))) + S(3)*d*(a + b*x)**(n + S(6))*(S(154)*a**S(6)*d**S(2) - S(56)*a**S(3)*b**S(3)*c*d + b**S(6)*c**S(2))/(b**S(12)*(n + S(6))) + (a + b*x)**(n + S(3))*(-a**S(3)*d + b**S(3)*c)*(S(55)*a**S(6)*d**S(2) - S(29)*a**S(3)*b**S(3)*c*d + b**S(6)*c**S(2))/(b**S(12)*(n + S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a + b*x)**n*(c + d*x**S(3))**S(3), x), x, S(45)*a**S(2)*d**S(3)*(a + b*x)**(n + S(9))/(b**S(11)*(n + S(9))) + S(63)*a**S(2)*d**S(2)*(a + b*x)**(n + S(6))*(-S(4)*a**S(3)*d + b**S(3)*c)/(b**S(11)*(n + S(6))) + S(9)*a**S(2)*d*(a + b*x)**(n + S(3))*(-S(5)*a**S(3)*d + S(2)*b**S(3)*c)*(-a**S(3)*d + b**S(3)*c)/(b**S(11)*(n + S(3))) - S(10)*a*d**S(3)*(a + b*x)**(n + S(10))/(b**S(11)*(n + S(10))) - S(21)*a*d**S(2)*(a + b*x)**(n + S(7))*(-S(10)*a**S(3)*d + b**S(3)*c)/(b**S(11)*(n + S(7))) - S(3)*a*d*(a + b*x)**(n + S(4))*(S(40)*a**S(6)*d**S(2) - S(35)*a**S(3)*b**S(3)*c*d + S(4)*b**S(6)*c**S(2))/(b**S(11)*(n + S(4))) - a*(a + b*x)**(n + S(1))*(-a**S(3)*d + b**S(3)*c)**S(3)/(b**S(11)*(n + S(1))) + d**S(3)*(a + b*x)**(n + S(11))/(b**S(11)*(n + S(11))) + S(3)*d**S(2)*(a + b*x)**(n + S(8))*(-S(40)*a**S(3)*d + b**S(3)*c)/(b**S(11)*(n + S(8))) + S(3)*d*(a + b*x)**(n + S(5))*(S(70)*a**S(6)*d**S(2) - S(35)*a**S(3)*b**S(3)*c*d + b**S(6)*c**S(2))/(b**S(11)*(n + S(5))) + (a + b*x)**(n + S(2))*(-S(10)*a**S(3)*d + b**S(3)*c)*(-a**S(3)*d + b**S(3)*c)**S(2)/(b**S(11)*(n + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x)**n*(c + d*x**S(3))**S(3), x), x, S(36)*a**S(2)*d**S(3)*(a + b*x)**(n + S(8))/(b**S(10)*(n + S(8))) + S(9)*a**S(2)*d**S(2)*(a + b*x)**(n + S(5))*(-S(14)*a**S(3)*d + S(5)*b**S(3)*c)/(b**S(10)*(n + S(5))) + S(9)*a**S(2)*d*(a + b*x)**(n + S(2))*(-a**S(3)*d + b**S(3)*c)**S(2)/(b**S(10)*(n + S(2))) - S(9)*a*d**S(3)*(a + b*x)**(n + S(9))/(b**S(10)*(n + S(9))) - S(18)*a*d**S(2)*(a + b*x)**(n + S(6))*(-S(7)*a**S(3)*d + b**S(3)*c)/(b**S(10)*(n + S(6))) - S(9)*a*d*(a + b*x)**(n + S(3))*(-S(4)*a**S(3)*d + b**S(3)*c)*(-a**S(3)*d + b**S(3)*c)/(b**S(10)*(n + S(3))) + d**S(3)*(a + b*x)**(n + S(10))/(b**S(10)*(n + S(10))) + S(3)*d**S(2)*(a + b*x)**(n + S(7))*(-S(28)*a**S(3)*d + b**S(3)*c)/(b**S(10)*(n + S(7))) + S(3)*d*(a + b*x)**(n + S(4))*(S(28)*a**S(6)*d**S(2) - S(20)*a**S(3)*b**S(3)*c*d + b**S(6)*c**S(2))/(b**S(10)*(n + S(4))) + (a + b*x)**(n + S(1))*(-a**S(3)*d + b**S(3)*c)**S(3)/(b**S(10)*(n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x)**n*(c + d*x**S(3))**S(3)/x, x), x, S(28)*a**S(2)*d**S(3)*(a + b*x)**(n + S(7))/(b**S(9)*(n + S(7))) + S(2)*a**S(2)*d**S(2)*(a + b*x)**(n + S(4))*(-S(28)*a**S(3)*d + S(15)*b**S(3)*c)/(b**S(9)*(n + S(4))) + a**S(2)*d*(a + b*x)**(n + S(1))*(a**S(6)*d**S(2) - S(3)*a**S(3)*b**S(3)*c*d + S(3)*b**S(6)*c**S(2))/(b**S(9)*(n + S(1))) - S(8)*a*d**S(3)*(a + b*x)**(n + S(8))/(b**S(9)*(n + S(8))) - S(5)*a*d**S(2)*(a + b*x)**(n + S(5))*(-S(14)*a**S(3)*d + S(3)*b**S(3)*c)/(b**S(9)*(n + S(5))) - a*d*(a + b*x)**(n + S(2))*(S(8)*a**S(6)*d**S(2) - S(15)*a**S(3)*b**S(3)*c*d + S(6)*b**S(6)*c**S(2))/(b**S(9)*(n + S(2))) + d**S(3)*(a + b*x)**(n + S(9))/(b**S(9)*(n + S(9))) + d**S(2)*(a + b*x)**(n + S(6))*(-S(56)*a**S(3)*d + S(3)*b**S(3)*c)/(b**S(9)*(n + S(6))) + d*(a + b*x)**(n + S(3))*(S(28)*a**S(6)*d**S(2) - S(30)*a**S(3)*b**S(3)*c*d + S(3)*b**S(6)*c**S(2))/(b**S(9)*(n + S(3))) - c**S(3)*(a + b*x)**(n + S(1))*hyper((S(1), n + S(1)), (n + S(2),), S(1) + b*x/a)/(a*(n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**m*(e + f*x)**n/(a + b*x**S(3)), x), x, x**(m + S(1))*(S(1) + f*x/e)**(-n)*(e + f*x)**n*AppellF1(m + S(1), -n, S(1), m + S(2), -f*x/e, -b**(S(1)/3)*x/a**(S(1)/3))/(S(3)*a*(m + S(1))) + x**(m + S(1))*(S(1) + f*x/e)**(-n)*(e + f*x)**n*AppellF1(m + S(1), -n, S(1), m + S(2), -f*x/e, (S(-1))**(S(1)/3)*b**(S(1)/3)*x/a**(S(1)/3))/(S(3)*a*(m + S(1))) + x**(m + S(1))*(S(1) + f*x/e)**(-n)*(e + f*x)**n*AppellF1(m + S(1), -n, S(1), m + S(2), -f*x/e, -(S(-1))**(S(2)/3)*b**(S(1)/3)*x/a**(S(1)/3))/(S(3)*a*(m + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)*(e + f*x)**n/(a + b*x**S(3)), x), x, a*(e + f*x)**(n + S(1))*hyper((S(1), n + S(1)), (n + S(2),), b**(S(1)/3)*(e + f*x)/(-(S(-1))**(S(2)/3)*a**(S(1)/3)*f + b**(S(1)/3)*e))/(S(3)*b**(S(5)/3)*(n + S(1))*(-(S(-1))**(S(2)/3)*a**(S(1)/3)*f + b**(S(1)/3)*e)) + a*(e + f*x)**(n + S(1))*hyper((S(1), n + S(1)), (n + S(2),), b**(S(1)/3)*(e + f*x)/((S(-1))**(S(1)/3)*a**(S(1)/3)*f + b**(S(1)/3)*e))/(S(3)*b**(S(5)/3)*(n + S(1))*((S(-1))**(S(1)/3)*a**(S(1)/3)*f + b**(S(1)/3)*e)) + a*(e + f*x)**(n + S(1))*hyper((S(1), n + S(1)), (n + S(2),), b**(S(1)/3)*(e + f*x)/(-a**(S(1)/3)*f + b**(S(1)/3)*e))/(S(3)*b**(S(5)/3)*(n + S(1))*(-a**(S(1)/3)*f + b**(S(1)/3)*e)) + e**S(2)*(e + f*x)**(n + S(1))/(b*f**S(3)*(n + S(1))) - S(2)*e*(e + f*x)**(n + S(2))/(b*f**S(3)*(n + S(2))) + (e + f*x)**(n + S(3))/(b*f**S(3)*(n + S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)*(e + f*x)**n/(a + b*x**S(3)), x), x, (S(-1))**(S(2)/3)*a**(S(2)/3)*(e + f*x)**(n + S(1))*hyper((S(1), n + S(1)), (n + S(2),), (S(-1))**(S(1)/3)*b**(S(1)/3)*(e + f*x)/(a**(S(1)/3)*f + (S(-1))**(S(1)/3)*b**(S(1)/3)*e))/(S(3)*b**(S(4)/3)*(n + S(1))*(a**(S(1)/3)*f + (S(-1))**(S(1)/3)*b**(S(1)/3)*e)) + (S(-1))**(S(1)/3)*a**(S(2)/3)*(e + f*x)**(n + S(1))*hyper((S(1), n + S(1)), (n + S(2),), (S(-1))**(S(2)/3)*b**(S(1)/3)*(e + f*x)/(-a**(S(1)/3)*f + (S(-1))**(S(2)/3)*b**(S(1)/3)*e))/(S(3)*b**(S(4)/3)*(n + S(1))*(-a**(S(1)/3)*f + (S(-1))**(S(2)/3)*b**(S(1)/3)*e)) - a**(S(2)/3)*(e + f*x)**(n + S(1))*hyper((S(1), n + S(1)), (n + S(2),), b**(S(1)/3)*(e + f*x)/(-a**(S(1)/3)*f + b**(S(1)/3)*e))/(S(3)*b**(S(4)/3)*(n + S(1))*(-a**(S(1)/3)*f + b**(S(1)/3)*e)) - e*(e + f*x)**(n + S(1))/(b*f**S(2)*(n + S(1))) + (e + f*x)**(n + S(2))/(b*f**S(2)*(n + S(2))), expand=True, _diff=True, _numerical=True)
# difference in simplify assert rubi_test(rubi_integrate(x**S(3)*(e + f*x)**n/(a + b*x**S(3)), x), x, -a**(S(1)/3)*(e + f*x)**(n + S(1))*hyper((S(1), n + S(1)), (n + S(2),), (S(-1))**(S(1)/3)*b**(S(1)/3)*(e + f*x)/(a**(S(1)/3)*f + (S(-1))**(S(1)/3)*b**(S(1)/3)*e))/(S(3)*b*(n + S(1))*(a**(S(1)/3)*f + (S(-1))**(S(1)/3)*b**(S(1)/3)*e)) + a**(S(1)/3)*(e + f*x)**(n + S(1))*hyper((S(1), n + S(1)), (n + S(2),), (S(-1))**(S(2)/3)*b**(S(1)/3)*(e + f*x)/(-a**(S(1)/3)*f + (S(-1))**(S(2)/3)*b**(S(1)/3)*e))/(S(3)*b*(n + S(1))*(-a**(S(1)/3)*f + (S(-1))**(S(2)/3)*b**(S(1)/3)*e)) + a**(S(1)/3)*(e + f*x)**(n + S(1))*hyper((S(1), n + S(1)), (n + S(2),), b**(S(1)/3)*(e + f*x)/(-a**(S(1)/3)*f + b**(S(1)/3)*e))/(S(3)*b*(n + S(1))*(-a**(S(1)/3)*f + b**(S(1)/3)*e)) + (e + f*x)**(n + S(1))/(b*f*(n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(e + f*x)**n/(a + b*x**S(3)), x), x, -(e + f*x)**(n + S(1))*hyper((S(1), n + S(1)), (n + S(2),), b**(S(1)/3)*(e + f*x)/(-(S(-1))**(S(2)/3)*a**(S(1)/3)*f + b**(S(1)/3)*e))/(S(3)*b**(S(2)/3)*(n + S(1))*(-(S(-1))**(S(2)/3)*a**(S(1)/3)*f + b**(S(1)/3)*e)) - (e + f*x)**(n + S(1))*hyper((S(1), n + S(1)), (n + S(2),), b**(S(1)/3)*(e + f*x)/((S(-1))**(S(1)/3)*a**(S(1)/3)*f + b**(S(1)/3)*e))/(S(3)*b**(S(2)/3)*(n + S(1))*((S(-1))**(S(1)/3)*a**(S(1)/3)*f + b**(S(1)/3)*e)) - (e + f*x)**(n + S(1))*hyper((S(1), n + S(1)), (n + S(2),), b**(S(1)/3)*(e + f*x)/(-a**(S(1)/3)*f + b**(S(1)/3)*e))/(S(3)*b**(S(2)/3)*(n + S(1))*(-a**(S(1)/3)*f + b**(S(1)/3)*e)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(e + f*x)**n/(a + b*x**S(3)), x), x, -(S(-1))**(S(2)/3)*(e + f*x)**(n + S(1))*hyper((S(1), n + S(1)), (n + S(2),), (S(-1))**(S(1)/3)*b**(S(1)/3)*(e + f*x)/(a**(S(1)/3)*f + (S(-1))**(S(1)/3)*b**(S(1)/3)*e))/(S(3)*a**(S(1)/3)*b**(S(1)/3)*(n + S(1))*(a**(S(1)/3)*f + (S(-1))**(S(1)/3)*b**(S(1)/3)*e)) - (S(-1))**(S(1)/3)*(e + f*x)**(n + S(1))*hyper((S(1), n + S(1)), (n + S(2),), (S(-1))**(S(2)/3)*b**(S(1)/3)*(e + f*x)/(-a**(S(1)/3)*f + (S(-1))**(S(2)/3)*b**(S(1)/3)*e))/(S(3)*a**(S(1)/3)*b**(S(1)/3)*(n + S(1))*(-a**(S(1)/3)*f + (S(-1))**(S(2)/3)*b**(S(1)/3)*e)) + (e + f*x)**(n + S(1))*hyper((S(1), n + S(1)), (n + S(2),), b**(S(1)/3)*(e + f*x)/(-a**(S(1)/3)*f + b**(S(1)/3)*e))/(S(3)*a**(S(1)/3)*b**(S(1)/3)*(n + S(1))*(-a**(S(1)/3)*f + b**(S(1)/3)*e)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((e + f*x)**n/(a + b*x**S(3)), x), x, (e + f*x)**(n + S(1))*hyper((S(1), n + S(1)), (n + S(2),), (S(-1))**(S(1)/3)*b**(S(1)/3)*(e + f*x)/(a**(S(1)/3)*f + (S(-1))**(S(1)/3)*b**(S(1)/3)*e))/(S(3)*a**(S(2)/3)*(n + S(1))*(a**(S(1)/3)*f + (S(-1))**(S(1)/3)*b**(S(1)/3)*e)) - (e + f*x)**(n + S(1))*hyper((S(1), n + S(1)), (n + S(2),), (S(-1))**(S(2)/3)*b**(S(1)/3)*(e + f*x)/(-a**(S(1)/3)*f + (S(-1))**(S(2)/3)*b**(S(1)/3)*e))/(S(3)*a**(S(2)/3)*(n + S(1))*(-a**(S(1)/3)*f + (S(-1))**(S(2)/3)*b**(S(1)/3)*e)) - (e + f*x)**(n + S(1))*hyper((S(1), n + S(1)), (n + S(2),), b**(S(1)/3)*(e + f*x)/(-a**(S(1)/3)*f + b**(S(1)/3)*e))/(S(3)*a**(S(2)/3)*(n + S(1))*(-a**(S(1)/3)*f + b**(S(1)/3)*e)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((e + f*x)**n/(x*(a + b*x**S(3))), x), x, b**(S(1)/3)*(e + f*x)**(n + S(1))*hyper((S(1), n + S(1)), (n + S(2),), b**(S(1)/3)*(e + f*x)/(-(S(-1))**(S(2)/3)*a**(S(1)/3)*f + b**(S(1)/3)*e))/(S(3)*a*(n + S(1))*(-(S(-1))**(S(2)/3)*a**(S(1)/3)*f + b**(S(1)/3)*e)) + b**(S(1)/3)*(e + f*x)**(n + S(1))*hyper((S(1), n + S(1)), (n + S(2),), b**(S(1)/3)*(e + f*x)/((S(-1))**(S(1)/3)*a**(S(1)/3)*f + b**(S(1)/3)*e))/(S(3)*a*(n + S(1))*((S(-1))**(S(1)/3)*a**(S(1)/3)*f + b**(S(1)/3)*e)) + b**(S(1)/3)*(e + f*x)**(n + S(1))*hyper((S(1), n + S(1)), (n + S(2),), b**(S(1)/3)*(e + f*x)/(-a**(S(1)/3)*f + b**(S(1)/3)*e))/(S(3)*a*(n + S(1))*(-a**(S(1)/3)*f + b**(S(1)/3)*e)) - (e + f*x)**(n + S(1))*hyper((S(1), n + S(1)), (n + S(2),), S(1) + f*x/e)/(a*e*(n + S(1))), expand=True, _diff=True, _numerical=True)
# large time in rubi_test assert rubi_test(rubi_integrate((e + f*x)**n/(x**S(2)*(a + b*x**S(3))), x), x, f*(e + f*x)**(n + S(1))*hyper((S(2), n + S(1)), (n + S(2),), S(1) + f*x/e)/(a*e**S(2)*(n + S(1))) + (S(-1))**(S(2)/3)*b**(S(2)/3)*(e + f*x)**(n + S(1))*hyper((S(1), n + S(1)), (n + S(2),), (S(-1))**(S(1)/3)*b**(S(1)/3)*(e + f*x)/(a**(S(1)/3)*f + (S(-1))**(S(1)/3)*b**(S(1)/3)*e))/(S(3)*a**(S(4)/3)*(n + S(1))*(a**(S(1)/3)*f + (S(-1))**(S(1)/3)*b**(S(1)/3)*e)) + (S(-1))**(S(1)/3)*b**(S(2)/3)*(e + f*x)**(n + S(1))*hyper((S(1), n + S(1)), (n + S(2),), (S(-1))**(S(2)/3)*b**(S(1)/3)*(e + f*x)/(-a**(S(1)/3)*f + (S(-1))**(S(2)/3)*b**(S(1)/3)*e))/(S(3)*a**(S(4)/3)*(n + S(1))*(-a**(S(1)/3)*f + (S(-1))**(S(2)/3)*b**(S(1)/3)*e)) - b**(S(2)/3)*(e + f*x)**(n + S(1))*hyper((S(1), n + S(1)), (n + S(2),), b**(S(1)/3)*(e + f*x)/(-a**(S(1)/3)*f + b**(S(1)/3)*e))/(S(3)*a**(S(4)/3)*(n + S(1))*(-a**(S(1)/3)*f + b**(S(1)/3)*e)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(c + d*x)**(n + S(1))/(a + b*x**S(3)), x), x, -(c + d*x)**(n + S(2))*hyper((S(1), n + S(2)), (n + S(3),), b**(S(1)/3)*(c + d*x)/(-(S(-1))**(S(2)/3)*a**(S(1)/3)*d + b**(S(1)/3)*c))/(S(3)*b**(S(2)/3)*(n + S(2))*(-(S(-1))**(S(2)/3)*a**(S(1)/3)*d + b**(S(1)/3)*c)) - (c + d*x)**(n + S(2))*hyper((S(1), n + S(2)), (n + S(3),), b**(S(1)/3)*(c + d*x)/((S(-1))**(S(1)/3)*a**(S(1)/3)*d + b**(S(1)/3)*c))/(S(3)*b**(S(2)/3)*(n + S(2))*((S(-1))**(S(1)/3)*a**(S(1)/3)*d + b**(S(1)/3)*c)) - (c + d*x)**(n + S(2))*hyper((S(1), n + S(2)), (n + S(3),), b**(S(1)/3)*(c + d*x)/(-a**(S(1)/3)*d + b**(S(1)/3)*c))/(S(3)*b**(S(2)/3)*(n + S(2))*(-a**(S(1)/3)*d + b**(S(1)/3)*c)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(c + d*x)**n/(a + b*x**S(4)), x), x, -(c + d*x)**(n + S(1))*hyper((S(1), n + S(1)), (n + S(2),), b**(S(1)/4)*(c + d*x)/(b**(S(1)/4)*c + I*d*(-a)**(S(1)/4)))/(S(4)*b**(S(3)/4)*(n + S(1))*(b**(S(1)/4)*c + I*d*(-a)**(S(1)/4))) - (c + d*x)**(n + S(1))*hyper((S(1), n + S(1)), (n + S(2),), b**(S(1)/4)*(c + d*x)/(b**(S(1)/4)*c - I*d*(-a)**(S(1)/4)))/(S(4)*b**(S(3)/4)*(n + S(1))*(b**(S(1)/4)*c - I*d*(-a)**(S(1)/4))) - (c + d*x)**(n + S(1))*hyper((S(1), n + S(1)), (n + S(2),), b**(S(1)/4)*(c + d*x)/(b**(S(1)/4)*c + d*(-a)**(S(1)/4)))/(S(4)*b**(S(3)/4)*(n + S(1))*(b**(S(1)/4)*c + d*(-a)**(S(1)/4))) - (c + d*x)**(n + S(1))*hyper((S(1), n + S(1)), (n + S(2),), b**(S(1)/4)*(c + d*x)/(b**(S(1)/4)*c - d*(-a)**(S(1)/4)))/(S(4)*b**(S(3)/4)*(n + S(1))*(b**(S(1)/4)*c - d*(-a)**(S(1)/4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(c + d*x)**(n + S(1))/(a + b*x**S(4)), x), x, -(c + d*x)**(n + S(2))*hyper((S(1), n + S(2)), (n + S(3),), b**(S(1)/4)*(c + d*x)/(b**(S(1)/4)*c + I*d*(-a)**(S(1)/4)))/(S(4)*b**(S(3)/4)*(n + S(2))*(b**(S(1)/4)*c + I*d*(-a)**(S(1)/4))) - (c + d*x)**(n + S(2))*hyper((S(1), n + S(2)), (n + S(3),), b**(S(1)/4)*(c + d*x)/(b**(S(1)/4)*c - I*d*(-a)**(S(1)/4)))/(S(4)*b**(S(3)/4)*(n + S(2))*(b**(S(1)/4)*c - I*d*(-a)**(S(1)/4))) - (c + d*x)**(n + S(2))*hyper((S(1), n + S(2)), (n + S(3),), b**(S(1)/4)*(c + d*x)/(b**(S(1)/4)*c + d*(-a)**(S(1)/4)))/(S(4)*b**(S(3)/4)*(n + S(2))*(b**(S(1)/4)*c + d*(-a)**(S(1)/4))) - (c + d*x)**(n + S(2))*hyper((S(1), n + S(2)), (n + S(3),), b**(S(1)/4)*(c + d*x)/(b**(S(1)/4)*c - d*(-a)**(S(1)/4)))/(S(4)*b**(S(3)/4)*(n + S(2))*(b**(S(1)/4)*c - d*(-a)**(S(1)/4))), expand=True, _diff=True, _numerical=True)
# large time in rubi_test assert rubi_test(rubi_integrate(S(1)/(sqrt(a + b*x**S(4))*(c + d*x + e*x**S(2))), x), x, sqrt(S(2))*e**S(2)*atanh(sqrt(S(2))*(S(4)*a*e**S(2) + b*x**S(2)*(d + sqrt(-S(4)*c*e + d**S(2)))**S(2))/(S(4)*sqrt(a + b*x**S(4))*sqrt(S(2)*a*e**S(4) + S(2)*b*c**S(2)*e**S(2) - S(4)*b*c*d**S(2)*e + b*d**S(4) + b*d*sqrt(-S(4)*c*e + d**S(2))*(-S(2)*c*e + d**S(2)))))/(S(2)*sqrt(-S(4)*c*e + d**S(2))*sqrt(S(2)*a*e**S(4) + S(2)*b*c**S(2)*e**S(2) - S(4)*b*c*d**S(2)*e + b*d**S(4) + b*d*sqrt(-S(4)*c*e + d**S(2))*(-S(2)*c*e + d**S(2)))) - sqrt(S(2))*e**S(2)*atanh(sqrt(S(2))*(S(4)*a*e**S(2) + b*x**S(2)*(d - sqrt(-S(4)*c*e + d**S(2)))**S(2))/(S(4)*sqrt(a + b*x**S(4))*sqrt(S(2)*a*e**S(4) + S(2)*b*c**S(2)*e**S(2) - S(4)*b*c*d**S(2)*e + b*d**S(4) - b*d*sqrt(-S(4)*c*e + d**S(2))*(-S(2)*c*e + d**S(2)))))/(S(2)*sqrt(-S(4)*c*e + d**S(2))*sqrt(S(2)*a*e**S(4) + S(2)*b*c**S(2)*e**S(2) - S(4)*b*c*d**S(2)*e + b*d**S(4) - b*d*sqrt(-S(4)*c*e + d**S(2))*(-S(2)*c*e + d**S(2)))) - S(2)*e*atan(x*sqrt(-(S(16)*a*e**S(4) + b*(d + sqrt(-S(4)*c*e + d**S(2)))**S(4))/(e**S(2)*(d + sqrt(-S(4)*c*e + d**S(2)))**S(2)))/(S(2)*sqrt(a + b*x**S(4))))/(sqrt(-(S(16)*a*e**S(4) + b*(d + sqrt(-S(4)*c*e + d**S(2)))**S(4))/(e**S(2)*(d + sqrt(-S(4)*c*e + d**S(2)))**S(2)))*(d + sqrt(-S(4)*c*e + d**S(2)))*sqrt(-S(4)*c*e + d**S(2))) + S(2)*e*atan(x*sqrt(-(S(16)*a*e**S(4) + b*(d - sqrt(-S(4)*c*e + d**S(2)))**S(4))/(e**S(2)*(d - sqrt(-S(4)*c*e + d**S(2)))**S(2)))/(S(2)*sqrt(a + b*x**S(4))))/(sqrt(-(S(16)*a*e**S(4) + b*(d - sqrt(-S(4)*c*e + d**S(2)))**S(4))/(e**S(2)*(d - sqrt(-S(4)*c*e + d**S(2)))**S(2)))*(d - sqrt(-S(4)*c*e + d**S(2)))*sqrt(-S(4)*c*e + d**S(2))) - e*sqrt((a + b*x**S(4))/(sqrt(a) + sqrt(b)*x**S(2))**S(2))*(sqrt(a) + sqrt(b)*x**S(2))*(S(4)*e**S(2) - sqrt(b)*(d + sqrt(-S(4)*c*e + d**S(2)))**S(2)/sqrt(a))*elliptic_pi(sqrt(a)*(S(4)*e**S(2) + sqrt(b)*(d + sqrt(-S(4)*c*e + d**S(2)))**S(2)/sqrt(a))**S(2)/(S(16)*sqrt(b)*e**S(2)*(d + sqrt(-S(4)*c*e + d**S(2)))**S(2)), S(2)*atan(b**(S(1)/4)*x/a**(S(1)/4)), S(1)/2)/(S(2)*a**(S(1)/4)*b**(S(1)/4)*sqrt(a + b*x**S(4))*(d + sqrt(-S(4)*c*e + d**S(2)))*(S(4)*e**S(2) + sqrt(b)*(d + sqrt(-S(4)*c*e + d**S(2)))**S(2)/sqrt(a))*sqrt(-S(4)*c*e + d**S(2))) + e*sqrt((a + b*x**S(4))/(sqrt(a) + sqrt(b)*x**S(2))**S(2))*(sqrt(a) + sqrt(b)*x**S(2))*(S(4)*e**S(2) - sqrt(b)*(d - sqrt(-S(4)*c*e + d**S(2)))**S(2)/sqrt(a))*elliptic_pi(sqrt(a)*(S(4)*e**S(2) + sqrt(b)*(d - sqrt(-S(4)*c*e + d**S(2)))**S(2)/sqrt(a))**S(2)/(S(16)*sqrt(b)*e**S(2)*(d - sqrt(-S(4)*c*e + d**S(2)))**S(2)), S(2)*atan(b**(S(1)/4)*x/a**(S(1)/4)), S(1)/2)/(S(2)*a**(S(1)/4)*b**(S(1)/4)*sqrt(a + b*x**S(4))*(d - sqrt(-S(4)*c*e + d**S(2)))*(S(4)*e**S(2) + sqrt(b)*(d - sqrt(-S(4)*c*e + d**S(2)))**S(2)/sqrt(a))*sqrt(-S(4)*c*e + d**S(2))) + b**(S(1)/4)*e*sqrt((a + b*x**S(4))/(sqrt(a) + sqrt(b)*x**S(2))**S(2))*(sqrt(a) + sqrt(b)*x**S(2))*(d - sqrt(-S(4)*c*e + d**S(2)))*elliptic_f(S(2)*atan(b**(S(1)/4)*x/a**(S(1)/4)), S(1)/2)/(a**(S(3)/4)*sqrt(a + b*x**S(4))*(S(4)*e**S(2) + sqrt(b)*(d - sqrt(-S(4)*c*e + d**S(2)))**S(2)/sqrt(a))*sqrt(-S(4)*c*e + d**S(2))) - b**(S(1)/4)*e*sqrt((a + b*x**S(4))/(sqrt(a) + sqrt(b)*x**S(2))**S(2))*(sqrt(a) + sqrt(b)*x**S(2))*(d + sqrt(-S(4)*c*e + d**S(2)))*elliptic_f(S(2)*atan(b**(S(1)/4)*x/a**(S(1)/4)), S(1)/2)/(a**(S(3)/4)*sqrt(a + b*x**S(4))*(S(4)*e**S(2) + sqrt(b)*(d + sqrt(-S(4)*c*e + d**S(2)))**S(2)/sqrt(a))*sqrt(-S(4)*c*e + d**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*(c*x**n)**(S(1)/n))**p, x), x, x*(c*x**n)**(-S(1)/n)*(a + b*(c*x**n)**(S(1)/n))**(p + S(1))/(b*(p + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*(c*x**n)**(S(1)/n))**S(3), x), x, x*(c*x**n)**(-S(1)/n)*(a + b*(c*x**n)**(S(1)/n))**S(4)/(S(4)*b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*(c*x**n)**(S(1)/n))**S(2), x), x, x*(c*x**n)**(-S(1)/n)*(a + b*(c*x**n)**(S(1)/n))**S(3)/(S(3)*b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(a + b*(c*x**n)**(S(1)/n), x), x, a*x + b*x*(c*x**n)**(S(1)/n)/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(a + b*(c*x**n)**(S(1)/n)), x), x, x*(c*x**n)**(-S(1)/n)*log(a + b*(c*x**n)**(S(1)/n))/b, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*(c*x**n)**(S(1)/n))**(S(-2)), x), x, x/(a**S(2) + a*b*(c*x**n)**(S(1)/n)), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate((a + b*(c*x**n)**(S(1)/n))**(S(-2)), x), x, -x*(c*x**n)**(-S(1)/n)/(b*(a + b*(c*x**n)**(S(1)/n))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*(c*x**n)**(S(1)/n))**(S(-3)), x), x, -x*(c*x**n)**(-S(1)/n)/(S(2)*b*(a + b*(c*x**n)**(S(1)/n))**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*(c*x**n)**(S(2)/n))**S(3), x), x, a**S(3)*x + a**S(2)*b*x*(c*x**n)**(S(2)/n) + S(3)*a*b**S(2)*x*(c*x**n)**(S(4)/n)/S(5) + b**S(3)*x*(c*x**n)**(S(6)/n)/S(7), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*(c*x**n)**(S(2)/n))**S(2), x), x, a**S(2)*x + S(2)*a*b*x*(c*x**n)**(S(2)/n)/S(3) + b**S(2)*x*(c*x**n)**(S(4)/n)/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(a + b*(c*x**n)**(S(2)/n), x), x, a*x + b*x*(c*x**n)**(S(2)/n)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(a + b*(c*x**n)**(S(2)/n)), x), x, x*(c*x**n)**(-S(1)/n)*atan(sqrt(b)*(c*x**n)**(S(1)/n)/sqrt(a))/(sqrt(a)*sqrt(b)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*(c*x**n)**(S(2)/n))**(S(-2)), x), x, x/(S(2)*a*(a + b*(c*x**n)**(S(2)/n))) + x*(c*x**n)**(-S(1)/n)*atan(sqrt(b)*(c*x**n)**(S(1)/n)/sqrt(a))/(S(2)*a**(S(3)/2)*sqrt(b)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*(c*x**n)**(S(2)/n))**(S(-3)), x), x, x/(S(4)*a*(a + b*(c*x**n)**(S(2)/n))**S(2)) + S(3)*x/(S(8)*a**S(2)*(a + b*(c*x**n)**(S(2)/n))) + S(3)*x*(c*x**n)**(-S(1)/n)*atan(sqrt(b)*(c*x**n)**(S(1)/n)/sqrt(a))/(S(8)*a**(S(5)/2)*sqrt(b)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*(c*x**n)**(S(3)/n))**S(3), x), x, a**S(3)*x + S(3)*a**S(2)*b*x*(c*x**n)**(S(3)/n)/S(4) + S(3)*a*b**S(2)*x*(c*x**n)**(S(6)/n)/S(7) + b**S(3)*x*(c*x**n)**(S(9)/n)/S(10), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*(c*x**n)**(S(3)/n))**S(2), x), x, a**S(2)*x + a*b*x*(c*x**n)**(S(3)/n)/S(2) + b**S(2)*x*(c*x**n)**(S(6)/n)/S(7), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(a + b*(c*x**n)**(S(3)/n), x), x, a*x + b*x*(c*x**n)**(S(3)/n)/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(a + b*(c*x**n)**(S(3)/n)), x), x, x*(c*x**n)**(-S(1)/n)*log(a**(S(1)/3) + b**(S(1)/3)*(c*x**n)**(S(1)/n))/(S(3)*a**(S(2)/3)*b**(S(1)/3)) - x*(c*x**n)**(-S(1)/n)*log(a**(S(2)/3) - a**(S(1)/3)*b**(S(1)/3)*(c*x**n)**(S(1)/n) + b**(S(2)/3)*(c*x**n)**(S(2)/n))/(S(6)*a**(S(2)/3)*b**(S(1)/3)) - sqrt(S(3))*x*(c*x**n)**(-S(1)/n)*atan(sqrt(S(3))*(a**(S(1)/3) - S(2)*b**(S(1)/3)*(c*x**n)**(S(1)/n))/(S(3)*a**(S(1)/3)))/(S(3)*a**(S(2)/3)*b**(S(1)/3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*(c*x**n)**(S(3)/n))**(S(-2)), x), x, x/(S(3)*a*(a + b*(c*x**n)**(S(3)/n))) + S(2)*x*(c*x**n)**(-S(1)/n)*log(a**(S(1)/3) + b**(S(1)/3)*(c*x**n)**(S(1)/n))/(S(9)*a**(S(5)/3)*b**(S(1)/3)) - x*(c*x**n)**(-S(1)/n)*log(a**(S(2)/3) - a**(S(1)/3)*b**(S(1)/3)*(c*x**n)**(S(1)/n) + b**(S(2)/3)*(c*x**n)**(S(2)/n))/(S(9)*a**(S(5)/3)*b**(S(1)/3)) - S(2)*sqrt(S(3))*x*(c*x**n)**(-S(1)/n)*atan(sqrt(S(3))*(a**(S(1)/3) - S(2)*b**(S(1)/3)*(c*x**n)**(S(1)/n))/(S(3)*a**(S(1)/3)))/(S(9)*a**(S(5)/3)*b**(S(1)/3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*(c*x**n)**(S(3)/n))**(S(-3)), x), x, x/(S(6)*a*(a + b*(c*x**n)**(S(3)/n))**S(2)) + S(5)*x/(S(18)*a**S(2)*(a + b*(c*x**n)**(S(3)/n))) + S(5)*x*(c*x**n)**(-S(1)/n)*log(a**(S(1)/3) + b**(S(1)/3)*(c*x**n)**(S(1)/n))/(S(27)*a**(S(8)/3)*b**(S(1)/3)) - S(5)*x*(c*x**n)**(-S(1)/n)*log(a**(S(2)/3) - a**(S(1)/3)*b**(S(1)/3)*(c*x**n)**(S(1)/n) + b**(S(2)/3)*(c*x**n)**(S(2)/n))/(S(54)*a**(S(8)/3)*b**(S(1)/3)) - S(5)*sqrt(S(3))*x*(c*x**n)**(-S(1)/n)*atan(sqrt(S(3))*(a**(S(1)/3) - S(2)*b**(S(1)/3)*(c*x**n)**(S(1)/n))/(S(3)*a**(S(1)/3)))/(S(27)*a**(S(8)/3)*b**(S(1)/3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((x**S(3))**(S(2)/3) + S(1)), x), x, x*atan((x**S(3))**(S(1)/3))/(x**S(3))**(S(1)/3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((x**S(2))**(S(3)/2) + S(1)), x), x, x*log(sqrt(x**S(2)) + S(1))/(S(3)*sqrt(x**S(2))) - x*log(x**S(2) - sqrt(x**S(2)) + S(1))/(S(6)*sqrt(x**S(2))) - sqrt(S(3))*x*atan(sqrt(S(3))*(-S(2)*sqrt(x**S(2)) + S(1))/S(3))/(S(3)*sqrt(x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(S(4)*sqrt(x**S(4)) + S(1)), x), x, x*atan(S(2)*(x**S(4))**(S(1)/4))/(S(2)*(x**S(4))**(S(1)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(-S(4)*sqrt(x**S(4)) + S(1)), x), x, x*atanh(S(2)*(x**S(4))**(S(1)/4))/(S(2)*(x**S(4))**(S(1)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(S(4)*(x**S(6))**(S(1)/3) + S(1)), x), x, x*atan(S(2)*(x**S(6))**(S(1)/6))/(S(2)*(x**S(6))**(S(1)/6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(-S(4)*(x**S(6))**(S(1)/3) + S(1)), x), x, x*atanh(S(2)*(x**S(6))**(S(1)/6))/(S(2)*(x**S(6))**(S(1)/6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(S(4)*(x**(S(2)*n))**(S(1)/n) + S(1)), x), x, x*(x**(S(2)*n))**(-S(1)/(S(2)*n))*atan(S(2)*(x**(S(2)*n))**(S(1)/(S(2)*n)))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(-S(4)*(x**(S(2)*n))**(S(1)/n) + S(1)), x), x, x*(x**(S(2)*n))**(-S(1)/(S(2)*n))*atanh(S(2)*(x**(S(2)*n))**(S(1)/(S(2)*n)))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(a + b*(c*x**n)**(S(1)/n)), x), x, -a**S(3)*x**S(4)*(c*x**n)**(-S(4)/n)*log(a + b*(c*x**n)**(S(1)/n))/b**S(4) + a**S(2)*x**S(4)*(c*x**n)**(-S(3)/n)/b**S(3) - a*x**S(4)*(c*x**n)**(-S(2)/n)/(S(2)*b**S(2)) + x**S(4)*(c*x**n)**(-S(1)/n)/(S(3)*b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(a + b*(c*x**n)**(S(1)/n)), x), x, a**S(2)*x**S(3)*(c*x**n)**(-S(3)/n)*log(a + b*(c*x**n)**(S(1)/n))/b**S(3) - a*x**S(3)*(c*x**n)**(-S(2)/n)/b**S(2) + x**S(3)*(c*x**n)**(-S(1)/n)/(S(2)*b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(a + b*(c*x**n)**(S(1)/n)), x), x, -a*x**S(2)*(c*x**n)**(-S(2)/n)*log(a + b*(c*x**n)**(S(1)/n))/b**S(2) + x**S(2)*(c*x**n)**(-S(1)/n)/b, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(a + b*(c*x**n)**(S(1)/n)), x), x, x*(c*x**n)**(-S(1)/n)*log(a + b*(c*x**n)**(S(1)/n))/b, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(a + b*(c*x**n)**(S(1)/n))), x), x, log(x)/a - log(a + b*(c*x**n)**(S(1)/n))/a, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(a + b*(c*x**n)**(S(1)/n))), x), x, -S(1)/(a*x) - b*(c*x**n)**(S(1)/n)*log(x)/(a**S(2)*x) + b*(c*x**n)**(S(1)/n)*log(a + b*(c*x**n)**(S(1)/n))/(a**S(2)*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*(a + b*(c*x**n)**(S(1)/n))), x), x, -S(1)/(S(2)*a*x**S(2)) + b*(c*x**n)**(S(1)/n)/(a**S(2)*x**S(2)) + b**S(2)*(c*x**n)**(S(2)/n)*log(x)/(a**S(3)*x**S(2)) - b**S(2)*(c*x**n)**(S(2)/n)*log(a + b*(c*x**n)**(S(1)/n))/(a**S(3)*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(a + b*(c*x**n)**(S(1)/n))**S(2), x), x, a**S(3)*x**S(4)*(c*x**n)**(-S(4)/n)/(b**S(4)*(a + b*(c*x**n)**(S(1)/n))) + S(3)*a**S(2)*x**S(4)*(c*x**n)**(-S(4)/n)*log(a + b*(c*x**n)**(S(1)/n))/b**S(4) - S(2)*a*x**S(4)*(c*x**n)**(-S(3)/n)/b**S(3) + x**S(4)*(c*x**n)**(-S(2)/n)/(S(2)*b**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(a + b*(c*x**n)**(S(1)/n))**S(2), x), x, -a**S(2)*x**S(3)*(c*x**n)**(-S(3)/n)/(b**S(3)*(a + b*(c*x**n)**(S(1)/n))) - S(2)*a*x**S(3)*(c*x**n)**(-S(3)/n)*log(a + b*(c*x**n)**(S(1)/n))/b**S(3) + x**S(3)*(c*x**n)**(-S(2)/n)/b**S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(a + b*(c*x**n)**(S(1)/n))**S(2), x), x, a*x**S(2)*(c*x**n)**(-S(2)/n)/(b**S(2)*(a + b*(c*x**n)**(S(1)/n))) + x**S(2)*(c*x**n)**(-S(2)/n)*log(a + b*(c*x**n)**(S(1)/n))/b**S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*(c*x**n)**(S(1)/n))**(S(-2)), x), x, -x*(c*x**n)**(-S(1)/n)/(b*(a + b*(c*x**n)**(S(1)/n))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(a + b*(c*x**n)**(S(1)/n))**S(2)), x), x, S(1)/(a*(a + b*(c*x**n)**(S(1)/n))) + log(x)/a**S(2) - log(a + b*(c*x**n)**(S(1)/n))/a**S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(a + b*(c*x**n)**(S(1)/n))**S(2)), x), x, -b*(c*x**n)**(S(1)/n)/(a**S(2)*x*(a + b*(c*x**n)**(S(1)/n))) - S(1)/(a**S(2)*x) - S(2)*b*(c*x**n)**(S(1)/n)*log(x)/(a**S(3)*x) + S(2)*b*(c*x**n)**(S(1)/n)*log(a + b*(c*x**n)**(S(1)/n))/(a**S(3)*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*(a + b*(c*x**n)**(S(1)/n))**S(2)), x), x, -S(1)/(S(2)*a**S(2)*x**S(2)) + b**S(2)*(c*x**n)**(S(2)/n)/(a**S(3)*x**S(2)*(a + b*(c*x**n)**(S(1)/n))) + S(2)*b*(c*x**n)**(S(1)/n)/(a**S(3)*x**S(2)) + S(3)*b**S(2)*(c*x**n)**(S(2)/n)*log(x)/(a**S(4)*x**S(2)) - S(3)*b**S(2)*(c*x**n)**(S(2)/n)*log(a + b*(c*x**n)**(S(1)/n))/(a**S(4)*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(a + b*(c*x**n)**(S(1)/n))**p, x), x, -a**S(3)*x**S(4)*(c*x**n)**(-S(4)/n)*(a + b*(c*x**n)**(S(1)/n))**(p + S(1))/(b**S(4)*(p + S(1))) + S(3)*a**S(2)*x**S(4)*(c*x**n)**(-S(4)/n)*(a + b*(c*x**n)**(S(1)/n))**(p + S(2))/(b**S(4)*(p + S(2))) - S(3)*a*x**S(4)*(c*x**n)**(-S(4)/n)*(a + b*(c*x**n)**(S(1)/n))**(p + S(3))/(b**S(4)*(p + S(3))) + x**S(4)*(c*x**n)**(-S(4)/n)*(a + b*(c*x**n)**(S(1)/n))**(p + S(4))/(b**S(4)*(p + S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(a + b*(c*x**n)**(S(1)/n))**p, x), x, a**S(2)*x**S(3)*(c*x**n)**(-S(3)/n)*(a + b*(c*x**n)**(S(1)/n))**(p + S(1))/(b**S(3)*(p + S(1))) - S(2)*a*x**S(3)*(c*x**n)**(-S(3)/n)*(a + b*(c*x**n)**(S(1)/n))**(p + S(2))/(b**S(3)*(p + S(2))) + x**S(3)*(c*x**n)**(-S(3)/n)*(a + b*(c*x**n)**(S(1)/n))**(p + S(3))/(b**S(3)*(p + S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a + b*(c*x**n)**(S(1)/n))**p, x), x, -a*x**S(2)*(c*x**n)**(-S(2)/n)*(a + b*(c*x**n)**(S(1)/n))**(p + S(1))/(b**S(2)*(p + S(1))) + x**S(2)*(c*x**n)**(-S(2)/n)*(a + b*(c*x**n)**(S(1)/n))**(p + S(2))/(b**S(2)*(p + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*(c*x**n)**(S(1)/n))**p, x), x, x*(c*x**n)**(-S(1)/n)*(a + b*(c*x**n)**(S(1)/n))**(p + S(1))/(b*(p + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*(c*x**n)**(S(1)/n))**p/x, x), x, -(a + b*(c*x**n)**(S(1)/n))**(p + S(1))*hyper((S(1), p + S(1)), (p + S(2),), S(1) + b*(c*x**n)**(S(1)/n)/a)/(a*(p + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/((x**n)**(S(1)/n) + S(1))**S(2), x), x, x**S(2)*(x**n)**(-S(2)/n)*log((x**n)**(S(1)/n) + S(1)) + x**S(2)*(x**n)**(-S(2)/n)/((x**n)**(S(1)/n) + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**m*(a*(b*x**n)**p)**q, x), x, x**(m + S(1))*(a*(b*x**n)**p)**q/(m + n*p*q + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(a*(b*x**n)**p)**q, x), x, x**S(3)*(a*(b*x**n)**p)**q/(n*p*q + S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a*(b*x**n)**p)**q, x), x, x**S(2)*(a*(b*x**n)**p)**q/(n*p*q + S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*(b*x**n)**p)**q, x), x, x*(a*(b*x**n)**p)**q/(n*p*q + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*(b*x**n)**p)**q/x, x), x, (a*(b*x**n)**p)**q/(n*p*q), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*(b*x**n)**p)**q/x**S(2), x), x, -(a*(b*x**n)**p)**q/(x*(-n*p*q + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*(b*x**n)**p)**q/x**S(3), x), x, -(a*(b*x**n)**p)**q/(x**S(2)*(-n*p*q + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(a*(b*x**m)**n)**(-S(1)/(m*n)), x), x, x**S(3)*(a*(b*x**m)**n)**(-S(1)/(m*n))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a*(b*x**m)**n)**(-S(1)/(m*n)), x), x, x**S(2)*(a*(b*x**m)**n)**(-S(1)/(m*n)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*(b*x**m)**n)**(-S(1)/(m*n)), x), x, x*(a*(b*x**m)**n)**(-S(1)/(m*n))*log(x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*(b*x**m)**n)**(-S(1)/(m*n))/x, x), x, -(a*(b*x**m)**n)**(-S(1)/(m*n)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*(b*x**m)**n)**(-S(1)/(m*n))/x**S(2), x), x, -(a*(b*x**m)**n)**(-S(1)/(m*n))/(S(2)*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(-n*p*q + S(2))*(a*(b*x**n)**p)**q, x), x, x**(-n*p*q + S(3))*(a*(b*x**n)**p)**q/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(-n*p*q + S(1))*(a*(b*x**n)**p)**q, x), x, x**(-n*p*q + S(2))*(a*(b*x**n)**p)**q/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(-n*p*q)*(a*(b*x**n)**p)**q, x), x, x**(-n*p*q + S(1))*(a*(b*x**n)**p)**q, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(-n*p*q + S(-1))*(a*(b*x**n)**p)**q, x), x, x**(-n*p*q)*(a*(b*x**n)**p)**q*log(x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(-n*p*q + S(-2))*(a*(b*x**n)**p)**q, x), x, -x**(-n*p*q + S(-1))*(a*(b*x**n)**p)**q, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*sqrt(c*x**S(2))*(a + b*x)**n, x), x, -a**S(3)*sqrt(c*x**S(2))*(a + b*x)**(n + S(1))/(b**S(4)*x*(n + S(1))) + S(3)*a**S(2)*sqrt(c*x**S(2))*(a + b*x)**(n + S(2))/(b**S(4)*x*(n + S(2))) - S(3)*a*sqrt(c*x**S(2))*(a + b*x)**(n + S(3))/(b**S(4)*x*(n + S(3))) + sqrt(c*x**S(2))*(a + b*x)**(n + S(4))/(b**S(4)*x*(n + S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*sqrt(c*x**S(2))*(a + b*x)**n, x), x, a**S(2)*sqrt(c*x**S(2))*(a + b*x)**(n + S(1))/(b**S(3)*x*(n + S(1))) - S(2)*a*sqrt(c*x**S(2))*(a + b*x)**(n + S(2))/(b**S(3)*x*(n + S(2))) + sqrt(c*x**S(2))*(a + b*x)**(n + S(3))/(b**S(3)*x*(n + S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(c*x**S(2))*(a + b*x)**n, x), x, -a*sqrt(c*x**S(2))*(a + b*x)**(n + S(1))/(b**S(2)*x*(n + S(1))) + sqrt(c*x**S(2))*(a + b*x)**(n + S(2))/(b**S(2)*x*(n + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(c*x**S(2))*(a + b*x)**n/x, x), x, sqrt(c*x**S(2))*(a + b*x)**(n + S(1))/(b*x*(n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(c*x**S(2))*(a + b*x)**n/x**S(2), x), x, -sqrt(c*x**S(2))*(a + b*x)**(n + S(1))*hyper((S(1), n + S(1)), (n + S(2),), S(1) + b*x/a)/(a*x*(n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(c*x**S(2))*(a + b*x)**n/x**S(3), x), x, b*sqrt(c*x**S(2))*(a + b*x)**(n + S(1))*hyper((S(2), n + S(1)), (n + S(2),), S(1) + b*x/a)/(a**S(2)*x*(n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(c*x**S(2))*(a + b*x)**n/x**S(4), x), x, -b**S(2)*sqrt(c*x**S(2))*(a + b*x)**(n + S(1))*hyper((S(3), n + S(1)), (n + S(2),), S(1) + b*x/a)/(a**S(3)*x*(n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(c*x**S(2))**(S(3)/2)*(a + b*x)**n, x), x, a**S(4)*c*sqrt(c*x**S(2))*(a + b*x)**(n + S(1))/(b**S(5)*x*(n + S(1))) - S(4)*a**S(3)*c*sqrt(c*x**S(2))*(a + b*x)**(n + S(2))/(b**S(5)*x*(n + S(2))) + S(6)*a**S(2)*c*sqrt(c*x**S(2))*(a + b*x)**(n + S(3))/(b**S(5)*x*(n + S(3))) - S(4)*a*c*sqrt(c*x**S(2))*(a + b*x)**(n + S(4))/(b**S(5)*x*(n + S(4))) + c*sqrt(c*x**S(2))*(a + b*x)**(n + S(5))/(b**S(5)*x*(n + S(5))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(3)/2)*(a + b*x)**n, x), x, -a**S(3)*c*sqrt(c*x**S(2))*(a + b*x)**(n + S(1))/(b**S(4)*x*(n + S(1))) + S(3)*a**S(2)*c*sqrt(c*x**S(2))*(a + b*x)**(n + S(2))/(b**S(4)*x*(n + S(2))) - S(3)*a*c*sqrt(c*x**S(2))*(a + b*x)**(n + S(3))/(b**S(4)*x*(n + S(3))) + c*sqrt(c*x**S(2))*(a + b*x)**(n + S(4))/(b**S(4)*x*(n + S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(3)/2)*(a + b*x)**n/x, x), x, a**S(2)*c*sqrt(c*x**S(2))*(a + b*x)**(n + S(1))/(b**S(3)*x*(n + S(1))) - S(2)*a*c*sqrt(c*x**S(2))*(a + b*x)**(n + S(2))/(b**S(3)*x*(n + S(2))) + c*sqrt(c*x**S(2))*(a + b*x)**(n + S(3))/(b**S(3)*x*(n + S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(3)/2)*(a + b*x)**n/x**S(2), x), x, -a*c*sqrt(c*x**S(2))*(a + b*x)**(n + S(1))/(b**S(2)*x*(n + S(1))) + c*sqrt(c*x**S(2))*(a + b*x)**(n + S(2))/(b**S(2)*x*(n + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(3)/2)*(a + b*x)**n/x**S(3), x), x, c*sqrt(c*x**S(2))*(a + b*x)**(n + S(1))/(b*x*(n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(3)/2)*(a + b*x)**n/x**S(4), x), x, -c*sqrt(c*x**S(2))*(a + b*x)**(n + S(1))*hyper((S(1), n + S(1)), (n + S(2),), S(1) + b*x/a)/(a*x*(n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(3)/2)*(a + b*x)**n/x**S(5), x), x, b*c*sqrt(c*x**S(2))*(a + b*x)**(n + S(1))*hyper((S(2), n + S(1)), (n + S(2),), S(1) + b*x/a)/(a**S(2)*x*(n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(3)/2)*(a + b*x)**n/x**S(6), x), x, -b**S(2)*c*sqrt(c*x**S(2))*(a + b*x)**(n + S(1))*hyper((S(3), n + S(1)), (n + S(2),), S(1) + b*x/a)/(a**S(3)*x*(n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(5)/2)*(a + b*x)**n, x), x, -a**S(5)*c**S(2)*sqrt(c*x**S(2))*(a + b*x)**(n + S(1))/(b**S(6)*x*(n + S(1))) + S(5)*a**S(4)*c**S(2)*sqrt(c*x**S(2))*(a + b*x)**(n + S(2))/(b**S(6)*x*(n + S(2))) - S(10)*a**S(3)*c**S(2)*sqrt(c*x**S(2))*(a + b*x)**(n + S(3))/(b**S(6)*x*(n + S(3))) + S(10)*a**S(2)*c**S(2)*sqrt(c*x**S(2))*(a + b*x)**(n + S(4))/(b**S(6)*x*(n + S(4))) - S(5)*a*c**S(2)*sqrt(c*x**S(2))*(a + b*x)**(n + S(5))/(b**S(6)*x*(n + S(5))) + c**S(2)*sqrt(c*x**S(2))*(a + b*x)**(n + S(6))/(b**S(6)*x*(n + S(6))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(5)/2)*(a + b*x)**n/x, x), x, a**S(4)*c**S(2)*sqrt(c*x**S(2))*(a + b*x)**(n + S(1))/(b**S(5)*x*(n + S(1))) - S(4)*a**S(3)*c**S(2)*sqrt(c*x**S(2))*(a + b*x)**(n + S(2))/(b**S(5)*x*(n + S(2))) + S(6)*a**S(2)*c**S(2)*sqrt(c*x**S(2))*(a + b*x)**(n + S(3))/(b**S(5)*x*(n + S(3))) - S(4)*a*c**S(2)*sqrt(c*x**S(2))*(a + b*x)**(n + S(4))/(b**S(5)*x*(n + S(4))) + c**S(2)*sqrt(c*x**S(2))*(a + b*x)**(n + S(5))/(b**S(5)*x*(n + S(5))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(5)/2)*(a + b*x)**n/x**S(2), x), x, -a**S(3)*c**S(2)*sqrt(c*x**S(2))*(a + b*x)**(n + S(1))/(b**S(4)*x*(n + S(1))) + S(3)*a**S(2)*c**S(2)*sqrt(c*x**S(2))*(a + b*x)**(n + S(2))/(b**S(4)*x*(n + S(2))) - S(3)*a*c**S(2)*sqrt(c*x**S(2))*(a + b*x)**(n + S(3))/(b**S(4)*x*(n + S(3))) + c**S(2)*sqrt(c*x**S(2))*(a + b*x)**(n + S(4))/(b**S(4)*x*(n + S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(5)/2)*(a + b*x)**n/x**S(3), x), x, a**S(2)*c**S(2)*sqrt(c*x**S(2))*(a + b*x)**(n + S(1))/(b**S(3)*x*(n + S(1))) - S(2)*a*c**S(2)*sqrt(c*x**S(2))*(a + b*x)**(n + S(2))/(b**S(3)*x*(n + S(2))) + c**S(2)*sqrt(c*x**S(2))*(a + b*x)**(n + S(3))/(b**S(3)*x*(n + S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(5)/2)*(a + b*x)**n/x**S(4), x), x, -a*c**S(2)*sqrt(c*x**S(2))*(a + b*x)**(n + S(1))/(b**S(2)*x*(n + S(1))) + c**S(2)*sqrt(c*x**S(2))*(a + b*x)**(n + S(2))/(b**S(2)*x*(n + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(5)/2)*(a + b*x)**n/x**S(5), x), x, c**S(2)*sqrt(c*x**S(2))*(a + b*x)**(n + S(1))/(b*x*(n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(5)/2)*(a + b*x)**n/x**S(6), x), x, -c**S(2)*sqrt(c*x**S(2))*(a + b*x)**(n + S(1))*hyper((S(1), n + S(1)), (n + S(2),), S(1) + b*x/a)/(a*x*(n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(5)/2)*(a + b*x)**n/x**S(7), x), x, b*c**S(2)*sqrt(c*x**S(2))*(a + b*x)**(n + S(1))*hyper((S(2), n + S(1)), (n + S(2),), S(1) + b*x/a)/(a**S(2)*x*(n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)*(a + b*x)**n/sqrt(c*x**S(2)), x), x, -a**S(3)*x*(a + b*x)**(n + S(1))/(b**S(4)*sqrt(c*x**S(2))*(n + S(1))) + S(3)*a**S(2)*x*(a + b*x)**(n + S(2))/(b**S(4)*sqrt(c*x**S(2))*(n + S(2))) - S(3)*a*x*(a + b*x)**(n + S(3))/(b**S(4)*sqrt(c*x**S(2))*(n + S(3))) + x*(a + b*x)**(n + S(4))/(b**S(4)*sqrt(c*x**S(2))*(n + S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(a + b*x)**n/sqrt(c*x**S(2)), x), x, a**S(2)*x*(a + b*x)**(n + S(1))/(b**S(3)*sqrt(c*x**S(2))*(n + S(1))) - S(2)*a*x*(a + b*x)**(n + S(2))/(b**S(3)*sqrt(c*x**S(2))*(n + S(2))) + x*(a + b*x)**(n + S(3))/(b**S(3)*sqrt(c*x**S(2))*(n + S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(a + b*x)**n/sqrt(c*x**S(2)), x), x, -a*sqrt(c*x**S(2))*(a + b*x)**(n + S(1))/(b**S(2)*c*x*(n + S(1))) + sqrt(c*x**S(2))*(a + b*x)**(n + S(2))/(b**S(2)*c*x*(n + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a + b*x)**n/sqrt(c*x**S(2)), x), x, x*(a + b*x)**(n + S(1))/(b*sqrt(c*x**S(2))*(n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x)**n/sqrt(c*x**S(2)), x), x, -x*(a + b*x)**(n + S(1))*hyper((S(1), n + S(1)), (n + S(2),), S(1) + b*x/a)/(a*sqrt(c*x**S(2))*(n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x)**n/(x*sqrt(c*x**S(2))), x), x, b*x*(a + b*x)**(n + S(1))*hyper((S(2), n + S(1)), (n + S(2),), S(1) + b*x/a)/(a**S(2)*sqrt(c*x**S(2))*(n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x)**n/(x**S(2)*sqrt(c*x**S(2))), x), x, -b**S(2)*x*(a + b*x)**(n + S(1))*hyper((S(3), n + S(1)), (n + S(2),), S(1) + b*x/a)/(a**S(3)*sqrt(c*x**S(2))*(n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x)**n/(x**S(3)*sqrt(c*x**S(2))), x), x, b**S(3)*x*(a + b*x)**(n + S(1))*hyper((S(4), n + S(1)), (n + S(2),), S(1) + b*x/a)/(a**S(4)*sqrt(c*x**S(2))*(n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(6)*(a + b*x)**n/(c*x**S(2))**(S(3)/2), x), x, -a**S(3)*x*(a + b*x)**(n + S(1))/(b**S(4)*c*sqrt(c*x**S(2))*(n + S(1))) + S(3)*a**S(2)*x*(a + b*x)**(n + S(2))/(b**S(4)*c*sqrt(c*x**S(2))*(n + S(2))) - S(3)*a*x*(a + b*x)**(n + S(3))/(b**S(4)*c*sqrt(c*x**S(2))*(n + S(3))) + x*(a + b*x)**(n + S(4))/(b**S(4)*c*sqrt(c*x**S(2))*(n + S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)*(a + b*x)**n/(c*x**S(2))**(S(3)/2), x), x, a**S(2)*x*(a + b*x)**(n + S(1))/(b**S(3)*c*sqrt(c*x**S(2))*(n + S(1))) - S(2)*a*x*(a + b*x)**(n + S(2))/(b**S(3)*c*sqrt(c*x**S(2))*(n + S(2))) + x*(a + b*x)**(n + S(3))/(b**S(3)*c*sqrt(c*x**S(2))*(n + S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)*(a + b*x)**n/(c*x**S(2))**(S(3)/2), x), x, -a*x*(a + b*x)**(n + S(1))/(b**S(2)*c*sqrt(c*x**S(2))*(n + S(1))) + x*(a + b*x)**(n + S(2))/(b**S(2)*c*sqrt(c*x**S(2))*(n + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(a + b*x)**n/(c*x**S(2))**(S(3)/2), x), x, x*(a + b*x)**(n + S(1))/(b*c*sqrt(c*x**S(2))*(n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(a + b*x)**n/(c*x**S(2))**(S(3)/2), x), x, -x*(a + b*x)**(n + S(1))*hyper((S(1), n + S(1)), (n + S(2),), S(1) + b*x/a)/(a*c*sqrt(c*x**S(2))*(n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a + b*x)**n/(c*x**S(2))**(S(3)/2), x), x, b*x*(a + b*x)**(n + S(1))*hyper((S(2), n + S(1)), (n + S(2),), S(1) + b*x/a)/(a**S(2)*c*sqrt(c*x**S(2))*(n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x)**n/(c*x**S(2))**(S(3)/2), x), x, -b**S(2)*x*(a + b*x)**(n + S(1))*hyper((S(3), n + S(1)), (n + S(2),), S(1) + b*x/a)/(a**S(3)*c*sqrt(c*x**S(2))*(n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x)**n/(x*(c*x**S(2))**(S(3)/2)), x), x, b**S(3)*x*(a + b*x)**(n + S(1))*hyper((S(4), n + S(1)), (n + S(2),), S(1) + b*x/a)/(a**S(4)*c*sqrt(c*x**S(2))*(n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(8)*(a + b*x)**n/(c*x**S(2))**(S(5)/2), x), x, -a**S(3)*x*(a + b*x)**(n + S(1))/(b**S(4)*c**S(2)*sqrt(c*x**S(2))*(n + S(1))) + S(3)*a**S(2)*x*(a + b*x)**(n + S(2))/(b**S(4)*c**S(2)*sqrt(c*x**S(2))*(n + S(2))) - S(3)*a*x*(a + b*x)**(n + S(3))/(b**S(4)*c**S(2)*sqrt(c*x**S(2))*(n + S(3))) + x*(a + b*x)**(n + S(4))/(b**S(4)*c**S(2)*sqrt(c*x**S(2))*(n + S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(7)*(a + b*x)**n/(c*x**S(2))**(S(5)/2), x), x, a**S(2)*x*(a + b*x)**(n + S(1))/(b**S(3)*c**S(2)*sqrt(c*x**S(2))*(n + S(1))) - S(2)*a*x*(a + b*x)**(n + S(2))/(b**S(3)*c**S(2)*sqrt(c*x**S(2))*(n + S(2))) + x*(a + b*x)**(n + S(3))/(b**S(3)*c**S(2)*sqrt(c*x**S(2))*(n + S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(6)*(a + b*x)**n/(c*x**S(2))**(S(5)/2), x), x, -a*x*(a + b*x)**(n + S(1))/(b**S(2)*c**S(2)*sqrt(c*x**S(2))*(n + S(1))) + x*(a + b*x)**(n + S(2))/(b**S(2)*c**S(2)*sqrt(c*x**S(2))*(n + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)*(a + b*x)**n/(c*x**S(2))**(S(5)/2), x), x, x*(a + b*x)**(n + S(1))/(b*c**S(2)*sqrt(c*x**S(2))*(n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)*(a + b*x)**n/(c*x**S(2))**(S(5)/2), x), x, -x*(a + b*x)**(n + S(1))*hyper((S(1), n + S(1)), (n + S(2),), S(1) + b*x/a)/(a*c**S(2)*sqrt(c*x**S(2))*(n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(a + b*x)**n/(c*x**S(2))**(S(5)/2), x), x, b*x*(a + b*x)**(n + S(1))*hyper((S(2), n + S(1)), (n + S(2),), S(1) + b*x/a)/(a**S(2)*c**S(2)*sqrt(c*x**S(2))*(n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(a + b*x)**n/(c*x**S(2))**(S(5)/2), x), x, -b**S(2)*x*(a + b*x)**(n + S(1))*hyper((S(3), n + S(1)), (n + S(2),), S(1) + b*x/a)/(a**S(3)*c**S(2)*sqrt(c*x**S(2))*(n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a + b*x)**n/(c*x**S(2))**(S(5)/2), x), x, b**S(3)*x*(a + b*x)**(n + S(1))*hyper((S(4), n + S(1)), (n + S(2),), S(1) + b*x/a)/(a**S(4)*c**S(2)*sqrt(c*x**S(2))*(n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**m*sqrt(c*x**S(2))*(a + b*x), x), x, a*x**(m + S(1))*sqrt(c*x**S(2))/(m + S(2)) + b*x**(m + S(2))*sqrt(c*x**S(2))/(m + S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*sqrt(c*x**S(2))*(a + b*x), x), x, a*x**S(4)*sqrt(c*x**S(2))/S(5) + b*x**S(5)*sqrt(c*x**S(2))/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*sqrt(c*x**S(2))*(a + b*x), x), x, a*x**S(3)*sqrt(c*x**S(2))/S(4) + b*x**S(4)*sqrt(c*x**S(2))/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*sqrt(c*x**S(2))*(a + b*x), x), x, a*x**S(2)*sqrt(c*x**S(2))/S(3) + b*x**S(3)*sqrt(c*x**S(2))/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(c*x**S(2))*(a + b*x), x), x, a*x*sqrt(c*x**S(2))/S(2) + b*x**S(2)*sqrt(c*x**S(2))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(c*x**S(2))*(a + b*x)/x, x), x, a*sqrt(c*x**S(2)) + b*x*sqrt(c*x**S(2))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(c*x**S(2))*(a + b*x)/x**S(2), x), x, a*sqrt(c*x**S(2))*log(x)/x + b*sqrt(c*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(c*x**S(2))*(a + b*x)/x**S(3), x), x, -a*sqrt(c*x**S(2))/x**S(2) + b*sqrt(c*x**S(2))*log(x)/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(c*x**S(2))*(a + b*x)/x**S(4), x), x, -a*sqrt(c*x**S(2))/(S(2)*x**S(3)) - b*sqrt(c*x**S(2))/x**S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**m*(c*x**S(2))**(S(3)/2)*(a + b*x), x), x, a*c*x**(m + S(3))*sqrt(c*x**S(2))/(m + S(4)) + b*c*x**(m + S(4))*sqrt(c*x**S(2))/(m + S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(c*x**S(2))**(S(3)/2)*(a + b*x), x), x, a*c*x**S(6)*sqrt(c*x**S(2))/S(7) + b*c*x**S(7)*sqrt(c*x**S(2))/S(8), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(c*x**S(2))**(S(3)/2)*(a + b*x), x), x, a*c*x**S(5)*sqrt(c*x**S(2))/S(6) + b*c*x**S(6)*sqrt(c*x**S(2))/S(7), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(c*x**S(2))**(S(3)/2)*(a + b*x), x), x, a*c*x**S(4)*sqrt(c*x**S(2))/S(5) + b*c*x**S(5)*sqrt(c*x**S(2))/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(3)/2)*(a + b*x), x), x, a*c*x**S(3)*sqrt(c*x**S(2))/S(4) + b*c*x**S(4)*sqrt(c*x**S(2))/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(3)/2)*(a + b*x)/x, x), x, a*c*x**S(2)*sqrt(c*x**S(2))/S(3) + b*c*x**S(3)*sqrt(c*x**S(2))/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(3)/2)*(a + b*x)/x**S(2), x), x, a*c*x*sqrt(c*x**S(2))/S(2) + b*c*x**S(2)*sqrt(c*x**S(2))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(3)/2)*(a + b*x)/x**S(3), x), x, a*c*sqrt(c*x**S(2)) + b*c*x*sqrt(c*x**S(2))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(3)/2)*(a + b*x)/x**S(4), x), x, a*c*sqrt(c*x**S(2))*log(x)/x + b*c*sqrt(c*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**m*(c*x**S(2))**(S(5)/2)*(a + b*x), x), x, a*c**S(2)*x**(m + S(5))*sqrt(c*x**S(2))/(m + S(6)) + b*c**S(2)*x**(m + S(6))*sqrt(c*x**S(2))/(m + S(7)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(c*x**S(2))**(S(5)/2)*(a + b*x), x), x, a*c**S(2)*x**S(8)*sqrt(c*x**S(2))/S(9) + b*c**S(2)*x**S(9)*sqrt(c*x**S(2))/S(10), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(c*x**S(2))**(S(5)/2)*(a + b*x), x), x, a*c**S(2)*x**S(7)*sqrt(c*x**S(2))/S(8) + b*c**S(2)*x**S(8)*sqrt(c*x**S(2))/S(9), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(c*x**S(2))**(S(5)/2)*(a + b*x), x), x, a*c**S(2)*x**S(6)*sqrt(c*x**S(2))/S(7) + b*c**S(2)*x**S(7)*sqrt(c*x**S(2))/S(8), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(5)/2)*(a + b*x), x), x, a*c**S(2)*x**S(5)*sqrt(c*x**S(2))/S(6) + b*c**S(2)*x**S(6)*sqrt(c*x**S(2))/S(7), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(5)/2)*(a + b*x)/x, x), x, a*c**S(2)*x**S(4)*sqrt(c*x**S(2))/S(5) + b*c**S(2)*x**S(5)*sqrt(c*x**S(2))/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(5)/2)*(a + b*x)/x**S(2), x), x, a*c**S(2)*x**S(3)*sqrt(c*x**S(2))/S(4) + b*c**S(2)*x**S(4)*sqrt(c*x**S(2))/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(5)/2)*(a + b*x)/x**S(3), x), x, a*c**S(2)*x**S(2)*sqrt(c*x**S(2))/S(3) + b*c**S(2)*x**S(3)*sqrt(c*x**S(2))/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(5)/2)*(a + b*x)/x**S(4), x), x, a*c**S(2)*x*sqrt(c*x**S(2))/S(2) + b*c**S(2)*x**S(2)*sqrt(c*x**S(2))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**m*(a + b*x)/sqrt(c*x**S(2)), x), x, a*x**(m + S(1))/(m*sqrt(c*x**S(2))) + b*x**(m + S(2))/(sqrt(c*x**S(2))*(m + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(a + b*x)/sqrt(c*x**S(2)), x), x, a*x**S(4)/(S(3)*sqrt(c*x**S(2))) + b*x**S(5)/(S(4)*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(a + b*x)/sqrt(c*x**S(2)), x), x, a*x*sqrt(c*x**S(2))/(S(2)*c) + b*x**S(2)*sqrt(c*x**S(2))/(S(3)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a + b*x)/sqrt(c*x**S(2)), x), x, a*x**S(2)/sqrt(c*x**S(2)) + b*x**S(3)/(S(2)*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x)/sqrt(c*x**S(2)), x), x, a*x*log(x)/sqrt(c*x**S(2)) + b*x**S(2)/sqrt(c*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x)/(x*sqrt(c*x**S(2))), x), x, -a/sqrt(c*x**S(2)) + b*x*log(x)/sqrt(c*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x)/(x**S(2)*sqrt(c*x**S(2))), x), x, -a/(S(2)*x*sqrt(c*x**S(2))) - b/sqrt(c*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x)/(x**S(3)*sqrt(c*x**S(2))), x), x, -a/(S(3)*x**S(2)*sqrt(c*x**S(2))) - b/(S(2)*x*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x)/(x**S(4)*sqrt(c*x**S(2))), x), x, -a/(S(4)*x**S(3)*sqrt(c*x**S(2))) - b/(S(3)*x**S(2)*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**m*(a + b*x)/(c*x**S(2))**(S(3)/2), x), x, -a*x**(m + S(-1))/(c*sqrt(c*x**S(2))*(-m + S(2))) - b*x**m/(c*sqrt(c*x**S(2))*(-m + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(a + b*x)/(c*x**S(2))**(S(3)/2), x), x, a*x**S(2)/(c*sqrt(c*x**S(2))) + b*x**S(3)/(S(2)*c*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(a + b*x)/(c*x**S(2))**(S(3)/2), x), x, a*x*log(x)/(c*sqrt(c*x**S(2))) + b*x**S(2)/(c*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a + b*x)/(c*x**S(2))**(S(3)/2), x), x, -a/(c*sqrt(c*x**S(2))) + b*x*log(x)/(c*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x)/(c*x**S(2))**(S(3)/2), x), x, -a/(S(2)*c*x*sqrt(c*x**S(2))) - b/(c*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x)/(x*(c*x**S(2))**(S(3)/2)), x), x, -a/(S(3)*c*x**S(2)*sqrt(c*x**S(2))) - b/(S(2)*c*x*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x)/(x**S(2)*(c*x**S(2))**(S(3)/2)), x), x, -a/(S(4)*c*x**S(3)*sqrt(c*x**S(2))) - b/(S(3)*c*x**S(2)*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x)/(x**S(3)*(c*x**S(2))**(S(3)/2)), x), x, -a/(S(5)*c*x**S(4)*sqrt(c*x**S(2))) - b/(S(4)*c*x**S(3)*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x)/(x**S(4)*(c*x**S(2))**(S(3)/2)), x), x, -a/(S(6)*c*x**S(5)*sqrt(c*x**S(2))) - b/(S(5)*c*x**S(4)*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**m*(a + b*x)/(c*x**S(2))**(S(5)/2), x), x, -a*x**(m + S(-3))/(c**S(2)*sqrt(c*x**S(2))*(-m + S(4))) - b*x**(m + S(-2))/(c**S(2)*sqrt(c*x**S(2))*(-m + S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(a + b*x)/(c*x**S(2))**(S(5)/2), x), x, -a/(c**S(2)*sqrt(c*x**S(2))) + b*x*log(x)/(c**S(2)*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(a + b*x)/(c*x**S(2))**(S(5)/2), x), x, -a/(S(2)*c**S(2)*x*sqrt(c*x**S(2))) - b/(c**S(2)*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a + b*x)/(c*x**S(2))**(S(5)/2), x), x, -a/(S(3)*c**S(2)*x**S(2)*sqrt(c*x**S(2))) - b/(S(2)*c**S(2)*x*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x)/(c*x**S(2))**(S(5)/2), x), x, -a/(S(4)*c**S(2)*x**S(3)*sqrt(c*x**S(2))) - b/(S(3)*c**S(2)*x**S(2)*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x)/(x*(c*x**S(2))**(S(5)/2)), x), x, -a/(S(5)*c**S(2)*x**S(4)*sqrt(c*x**S(2))) - b/(S(4)*c**S(2)*x**S(3)*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x)/(x**S(2)*(c*x**S(2))**(S(5)/2)), x), x, -a/(S(6)*c**S(2)*x**S(5)*sqrt(c*x**S(2))) - b/(S(5)*c**S(2)*x**S(4)*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x)/(x**S(3)*(c*x**S(2))**(S(5)/2)), x), x, -a/(S(7)*c**S(2)*x**S(6)*sqrt(c*x**S(2))) - b/(S(6)*c**S(2)*x**S(5)*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x)/(x**S(4)*(c*x**S(2))**(S(5)/2)), x), x, -a/(S(8)*c**S(2)*x**S(7)*sqrt(c*x**S(2))) - b/(S(7)*c**S(2)*x**S(6)*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**m*sqrt(c*x**S(2))*(a + b*x)**S(2), x), x, a**S(2)*x**(m + S(1))*sqrt(c*x**S(2))/(m + S(2)) + S(2)*a*b*x**(m + S(2))*sqrt(c*x**S(2))/(m + S(3)) + b**S(2)*x**(m + S(3))*sqrt(c*x**S(2))/(m + S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*sqrt(c*x**S(2))*(a + b*x)**S(2), x), x, a**S(2)*x**S(4)*sqrt(c*x**S(2))/S(5) + a*b*x**S(5)*sqrt(c*x**S(2))/S(3) + b**S(2)*x**S(6)*sqrt(c*x**S(2))/S(7), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*sqrt(c*x**S(2))*(a + b*x)**S(2), x), x, a**S(2)*x**S(3)*sqrt(c*x**S(2))/S(4) + S(2)*a*b*x**S(4)*sqrt(c*x**S(2))/S(5) + b**S(2)*x**S(5)*sqrt(c*x**S(2))/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*sqrt(c*x**S(2))*(a + b*x)**S(2), x), x, a**S(2)*x**S(2)*sqrt(c*x**S(2))/S(3) + a*b*x**S(3)*sqrt(c*x**S(2))/S(2) + b**S(2)*x**S(4)*sqrt(c*x**S(2))/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(c*x**S(2))*(a + b*x)**S(2), x), x, a**S(2)*x*sqrt(c*x**S(2))/S(2) + S(2)*a*b*x**S(2)*sqrt(c*x**S(2))/S(3) + b**S(2)*x**S(3)*sqrt(c*x**S(2))/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(c*x**S(2))*(a + b*x)**S(2)/x, x), x, sqrt(c*x**S(2))*(a + b*x)**S(3)/(S(3)*b*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(c*x**S(2))*(a + b*x)**S(2)/x**S(2), x), x, a**S(2)*sqrt(c*x**S(2))*log(x)/x + S(2)*a*b*sqrt(c*x**S(2)) + b**S(2)*x*sqrt(c*x**S(2))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(c*x**S(2))*(a + b*x)**S(2)/x**S(3), x), x, -a**S(2)*sqrt(c*x**S(2))/x**S(2) + S(2)*a*b*sqrt(c*x**S(2))*log(x)/x + b**S(2)*sqrt(c*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(c*x**S(2))*(a + b*x)**S(2)/x**S(4), x), x, -a**S(2)*sqrt(c*x**S(2))/(S(2)*x**S(3)) - S(2)*a*b*sqrt(c*x**S(2))/x**S(2) + b**S(2)*sqrt(c*x**S(2))*log(x)/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**m*(c*x**S(2))**(S(3)/2)*(a + b*x)**S(2), x), x, a**S(2)*c*x**(m + S(3))*sqrt(c*x**S(2))/(m + S(4)) + S(2)*a*b*c*x**(m + S(4))*sqrt(c*x**S(2))/(m + S(5)) + b**S(2)*c*x**(m + S(5))*sqrt(c*x**S(2))/(m + S(6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(c*x**S(2))**(S(3)/2)*(a + b*x)**S(2), x), x, a**S(2)*c*x**S(6)*sqrt(c*x**S(2))/S(7) + a*b*c*x**S(7)*sqrt(c*x**S(2))/S(4) + b**S(2)*c*x**S(8)*sqrt(c*x**S(2))/S(9), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(c*x**S(2))**(S(3)/2)*(a + b*x)**S(2), x), x, a**S(2)*c*x**S(5)*sqrt(c*x**S(2))/S(6) + S(2)*a*b*c*x**S(6)*sqrt(c*x**S(2))/S(7) + b**S(2)*c*x**S(7)*sqrt(c*x**S(2))/S(8), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(c*x**S(2))**(S(3)/2)*(a + b*x)**S(2), x), x, a**S(2)*c*x**S(4)*sqrt(c*x**S(2))/S(5) + a*b*c*x**S(5)*sqrt(c*x**S(2))/S(3) + b**S(2)*c*x**S(6)*sqrt(c*x**S(2))/S(7), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(3)/2)*(a + b*x)**S(2), x), x, a**S(2)*c*x**S(3)*sqrt(c*x**S(2))/S(4) + S(2)*a*b*c*x**S(4)*sqrt(c*x**S(2))/S(5) + b**S(2)*c*x**S(5)*sqrt(c*x**S(2))/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(3)/2)*(a + b*x)**S(2)/x, x), x, a**S(2)*c*x**S(2)*sqrt(c*x**S(2))/S(3) + a*b*c*x**S(3)*sqrt(c*x**S(2))/S(2) + b**S(2)*c*x**S(4)*sqrt(c*x**S(2))/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(3)/2)*(a + b*x)**S(2)/x**S(2), x), x, a**S(2)*c*x*sqrt(c*x**S(2))/S(2) + S(2)*a*b*c*x**S(2)*sqrt(c*x**S(2))/S(3) + b**S(2)*c*x**S(3)*sqrt(c*x**S(2))/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(3)/2)*(a + b*x)**S(2)/x**S(3), x), x, c*sqrt(c*x**S(2))*(a + b*x)**S(3)/(S(3)*b*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(3)/2)*(a + b*x)**S(2)/x**S(4), x), x, a**S(2)*c*sqrt(c*x**S(2))*log(x)/x + S(2)*a*b*c*sqrt(c*x**S(2)) + b**S(2)*c*x*sqrt(c*x**S(2))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**m*(c*x**S(2))**(S(5)/2)*(a + b*x)**S(2), x), x, a**S(2)*c**S(2)*x**(m + S(5))*sqrt(c*x**S(2))/(m + S(6)) + S(2)*a*b*c**S(2)*x**(m + S(6))*sqrt(c*x**S(2))/(m + S(7)) + b**S(2)*c**S(2)*x**(m + S(7))*sqrt(c*x**S(2))/(m + S(8)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(c*x**S(2))**(S(5)/2)*(a + b*x)**S(2), x), x, a**S(2)*c**S(2)*x**S(8)*sqrt(c*x**S(2))/S(9) + a*b*c**S(2)*x**S(9)*sqrt(c*x**S(2))/S(5) + b**S(2)*c**S(2)*x**S(10)*sqrt(c*x**S(2))/S(11), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(c*x**S(2))**(S(5)/2)*(a + b*x)**S(2), x), x, a**S(2)*c**S(2)*x**S(7)*sqrt(c*x**S(2))/S(8) + S(2)*a*b*c**S(2)*x**S(8)*sqrt(c*x**S(2))/S(9) + b**S(2)*c**S(2)*x**S(9)*sqrt(c*x**S(2))/S(10), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(c*x**S(2))**(S(5)/2)*(a + b*x)**S(2), x), x, a**S(2)*c**S(2)*x**S(6)*sqrt(c*x**S(2))/S(7) + a*b*c**S(2)*x**S(7)*sqrt(c*x**S(2))/S(4) + b**S(2)*c**S(2)*x**S(8)*sqrt(c*x**S(2))/S(9), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(5)/2)*(a + b*x)**S(2), x), x, a**S(2)*c**S(2)*x**S(5)*sqrt(c*x**S(2))/S(6) + S(2)*a*b*c**S(2)*x**S(6)*sqrt(c*x**S(2))/S(7) + b**S(2)*c**S(2)*x**S(7)*sqrt(c*x**S(2))/S(8), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(5)/2)*(a + b*x)**S(2)/x, x), x, a**S(2)*c**S(2)*x**S(4)*sqrt(c*x**S(2))/S(5) + a*b*c**S(2)*x**S(5)*sqrt(c*x**S(2))/S(3) + b**S(2)*c**S(2)*x**S(6)*sqrt(c*x**S(2))/S(7), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(5)/2)*(a + b*x)**S(2)/x**S(2), x), x, a**S(2)*c**S(2)*x**S(3)*sqrt(c*x**S(2))/S(4) + S(2)*a*b*c**S(2)*x**S(4)*sqrt(c*x**S(2))/S(5) + b**S(2)*c**S(2)*x**S(5)*sqrt(c*x**S(2))/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(5)/2)*(a + b*x)**S(2)/x**S(3), x), x, a**S(2)*c**S(2)*x**S(2)*sqrt(c*x**S(2))/S(3) + a*b*c**S(2)*x**S(3)*sqrt(c*x**S(2))/S(2) + b**S(2)*c**S(2)*x**S(4)*sqrt(c*x**S(2))/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(5)/2)*(a + b*x)**S(2)/x**S(4), x), x, a**S(2)*c**S(2)*x*sqrt(c*x**S(2))/S(2) + S(2)*a*b*c**S(2)*x**S(2)*sqrt(c*x**S(2))/S(3) + b**S(2)*c**S(2)*x**S(3)*sqrt(c*x**S(2))/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**m*(a + b*x)**S(2)/sqrt(c*x**S(2)), x), x, a**S(2)*x**(m + S(1))/(m*sqrt(c*x**S(2))) + S(2)*a*b*x**(m + S(2))/(sqrt(c*x**S(2))*(m + S(1))) + b**S(2)*x**(m + S(3))/(sqrt(c*x**S(2))*(m + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(a + b*x)**S(2)/sqrt(c*x**S(2)), x), x, a**S(2)*x**S(4)/(S(3)*sqrt(c*x**S(2))) + a*b*x**S(5)/(S(2)*sqrt(c*x**S(2))) + b**S(2)*x**S(6)/(S(5)*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(a + b*x)**S(2)/sqrt(c*x**S(2)), x), x, a**S(2)*x*sqrt(c*x**S(2))/(S(2)*c) + S(2)*a*b*x**S(2)*sqrt(c*x**S(2))/(S(3)*c) + b**S(2)*x**S(3)*sqrt(c*x**S(2))/(S(4)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a + b*x)**S(2)/sqrt(c*x**S(2)), x), x, x*(a + b*x)**S(3)/(S(3)*b*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x)**S(2)/sqrt(c*x**S(2)), x), x, a**S(2)*x*log(x)/sqrt(c*x**S(2)) + S(2)*a*b*x**S(2)/sqrt(c*x**S(2)) + b**S(2)*x**S(3)/(S(2)*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x)**S(2)/(x*sqrt(c*x**S(2))), x), x, -a**S(2)/sqrt(c*x**S(2)) + S(2)*a*b*x*log(x)/sqrt(c*x**S(2)) + b**S(2)*x**S(2)/sqrt(c*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x)**S(2)/(x**S(2)*sqrt(c*x**S(2))), x), x, -a**S(2)/(S(2)*x*sqrt(c*x**S(2))) - S(2)*a*b/sqrt(c*x**S(2)) + b**S(2)*x*log(x)/sqrt(c*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x)**S(2)/(x**S(3)*sqrt(c*x**S(2))), x), x, -(a + b*x)**S(3)/(S(3)*a*x**S(2)*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x)**S(2)/(x**S(4)*sqrt(c*x**S(2))), x), x, -a**S(2)/(S(4)*x**S(3)*sqrt(c*x**S(2))) - S(2)*a*b/(S(3)*x**S(2)*sqrt(c*x**S(2))) - b**S(2)/(S(2)*x*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**m*(a + b*x)**S(2)/(c*x**S(2))**(S(3)/2), x), x, -a**S(2)*x**(m + S(-1))/(c*sqrt(c*x**S(2))*(-m + S(2))) - S(2)*a*b*x**m/(c*sqrt(c*x**S(2))*(-m + S(1))) + b**S(2)*x**(m + S(1))/(c*m*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(a + b*x)**S(2)/(c*x**S(2))**(S(3)/2), x), x, x*(a + b*x)**S(3)/(S(3)*b*c*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(a + b*x)**S(2)/(c*x**S(2))**(S(3)/2), x), x, a**S(2)*x*log(x)/(c*sqrt(c*x**S(2))) + S(2)*a*b*x**S(2)/(c*sqrt(c*x**S(2))) + b**S(2)*x**S(3)/(S(2)*c*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a + b*x)**S(2)/(c*x**S(2))**(S(3)/2), x), x, -a**S(2)/(c*sqrt(c*x**S(2))) + S(2)*a*b*x*log(x)/(c*sqrt(c*x**S(2))) + b**S(2)*x**S(2)/(c*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x)**S(2)/(c*x**S(2))**(S(3)/2), x), x, -a**S(2)/(S(2)*c*x*sqrt(c*x**S(2))) - S(2)*a*b/(c*sqrt(c*x**S(2))) + b**S(2)*x*log(x)/(c*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x)**S(2)/(x*(c*x**S(2))**(S(3)/2)), x), x, -(a + b*x)**S(3)/(S(3)*a*c*x**S(2)*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x)**S(2)/(x**S(2)*(c*x**S(2))**(S(3)/2)), x), x, -a**S(2)/(S(4)*c*x**S(3)*sqrt(c*x**S(2))) - S(2)*a*b/(S(3)*c*x**S(2)*sqrt(c*x**S(2))) - b**S(2)/(S(2)*c*x*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x)**S(2)/(x**S(3)*(c*x**S(2))**(S(3)/2)), x), x, -a**S(2)/(S(5)*c*x**S(4)*sqrt(c*x**S(2))) - a*b/(S(2)*c*x**S(3)*sqrt(c*x**S(2))) - b**S(2)/(S(3)*c*x**S(2)*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x)**S(2)/(x**S(4)*(c*x**S(2))**(S(3)/2)), x), x, -a**S(2)/(S(6)*c*x**S(5)*sqrt(c*x**S(2))) - S(2)*a*b/(S(5)*c*x**S(4)*sqrt(c*x**S(2))) - b**S(2)/(S(4)*c*x**S(3)*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**m*(a + b*x)**S(2)/(c*x**S(2))**(S(5)/2), x), x, -a**S(2)*x**(m + S(-3))/(c**S(2)*sqrt(c*x**S(2))*(-m + S(4))) - S(2)*a*b*x**(m + S(-2))/(c**S(2)*sqrt(c*x**S(2))*(-m + S(3))) - b**S(2)*x**(m + S(-1))/(c**S(2)*sqrt(c*x**S(2))*(-m + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(a + b*x)**S(2)/(c*x**S(2))**(S(5)/2), x), x, -a**S(2)/(c**S(2)*sqrt(c*x**S(2))) + S(2)*a*b*x*log(x)/(c**S(2)*sqrt(c*x**S(2))) + b**S(2)*x**S(2)/(c**S(2)*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(a + b*x)**S(2)/(c*x**S(2))**(S(5)/2), x), x, -a**S(2)/(S(2)*c**S(2)*x*sqrt(c*x**S(2))) - S(2)*a*b/(c**S(2)*sqrt(c*x**S(2))) + b**S(2)*x*log(x)/(c**S(2)*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a + b*x)**S(2)/(c*x**S(2))**(S(5)/2), x), x, -(a + b*x)**S(3)/(S(3)*a*c**S(2)*x**S(2)*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x)**S(2)/(c*x**S(2))**(S(5)/2), x), x, -a**S(2)/(S(4)*c**S(2)*x**S(3)*sqrt(c*x**S(2))) - S(2)*a*b/(S(3)*c**S(2)*x**S(2)*sqrt(c*x**S(2))) - b**S(2)/(S(2)*c**S(2)*x*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x)**S(2)/(x*(c*x**S(2))**(S(5)/2)), x), x, -a**S(2)/(S(5)*c**S(2)*x**S(4)*sqrt(c*x**S(2))) - a*b/(S(2)*c**S(2)*x**S(3)*sqrt(c*x**S(2))) - b**S(2)/(S(3)*c**S(2)*x**S(2)*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x)**S(2)/(x**S(2)*(c*x**S(2))**(S(5)/2)), x), x, -a**S(2)/(S(6)*c**S(2)*x**S(5)*sqrt(c*x**S(2))) - S(2)*a*b/(S(5)*c**S(2)*x**S(4)*sqrt(c*x**S(2))) - b**S(2)/(S(4)*c**S(2)*x**S(3)*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x)**S(2)/(x**S(3)*(c*x**S(2))**(S(5)/2)), x), x, -a**S(2)/(S(7)*c**S(2)*x**S(6)*sqrt(c*x**S(2))) - a*b/(S(3)*c**S(2)*x**S(5)*sqrt(c*x**S(2))) - b**S(2)/(S(5)*c**S(2)*x**S(4)*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x)**S(2)/(x**S(4)*(c*x**S(2))**(S(5)/2)), x), x, -a**S(2)/(S(8)*c**S(2)*x**S(7)*sqrt(c*x**S(2))) - S(2)*a*b/(S(7)*c**S(2)*x**S(6)*sqrt(c*x**S(2))) - b**S(2)/(S(6)*c**S(2)*x**S(5)*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*sqrt(c*x**S(2))/(a + b*x), x), x, a**S(4)*sqrt(c*x**S(2))*log(a + b*x)/(b**S(5)*x) - a**S(3)*sqrt(c*x**S(2))/b**S(4) + a**S(2)*x*sqrt(c*x**S(2))/(S(2)*b**S(3)) - a*x**S(2)*sqrt(c*x**S(2))/(S(3)*b**S(2)) + x**S(3)*sqrt(c*x**S(2))/(S(4)*b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*sqrt(c*x**S(2))/(a + b*x), x), x, -a**S(3)*sqrt(c*x**S(2))*log(a + b*x)/(b**S(4)*x) + a**S(2)*sqrt(c*x**S(2))/b**S(3) - a*x*sqrt(c*x**S(2))/(S(2)*b**S(2)) + x**S(2)*sqrt(c*x**S(2))/(S(3)*b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*sqrt(c*x**S(2))/(a + b*x), x), x, a**S(2)*sqrt(c*x**S(2))*log(a + b*x)/(b**S(3)*x) - a*sqrt(c*x**S(2))/b**S(2) + x*sqrt(c*x**S(2))/(S(2)*b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(c*x**S(2))/(a + b*x), x), x, -a*sqrt(c*x**S(2))*log(a + b*x)/(b**S(2)*x) + sqrt(c*x**S(2))/b, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(c*x**S(2))/(x*(a + b*x)), x), x, sqrt(c*x**S(2))*log(a + b*x)/(b*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(c*x**S(2))/(x**S(2)*(a + b*x)), x), x, sqrt(c*x**S(2))*log(x)/(a*x) - sqrt(c*x**S(2))*log(a + b*x)/(a*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(c*x**S(2))/(x**S(3)*(a + b*x)), x), x, -sqrt(c*x**S(2))/(a*x**S(2)) - b*sqrt(c*x**S(2))*log(x)/(a**S(2)*x) + b*sqrt(c*x**S(2))*log(a + b*x)/(a**S(2)*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(c*x**S(2))/(x**S(4)*(a + b*x)), x), x, -sqrt(c*x**S(2))/(S(2)*a*x**S(3)) + b*sqrt(c*x**S(2))/(a**S(2)*x**S(2)) + b**S(2)*sqrt(c*x**S(2))*log(x)/(a**S(3)*x) - b**S(2)*sqrt(c*x**S(2))*log(a + b*x)/(a**S(3)*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(c*x**S(2))**(S(3)/2)/(a + b*x), x), x, a**S(4)*c*sqrt(c*x**S(2))*log(a + b*x)/(b**S(5)*x) - a**S(3)*c*sqrt(c*x**S(2))/b**S(4) + a**S(2)*c*x*sqrt(c*x**S(2))/(S(2)*b**S(3)) - a*c*x**S(2)*sqrt(c*x**S(2))/(S(3)*b**S(2)) + c*x**S(3)*sqrt(c*x**S(2))/(S(4)*b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(3)/2)/(a + b*x), x), x, -a**S(3)*c*sqrt(c*x**S(2))*log(a + b*x)/(b**S(4)*x) + a**S(2)*c*sqrt(c*x**S(2))/b**S(3) - a*c*x*sqrt(c*x**S(2))/(S(2)*b**S(2)) + c*x**S(2)*sqrt(c*x**S(2))/(S(3)*b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(3)/2)/(x*(a + b*x)), x), x, a**S(2)*c*sqrt(c*x**S(2))*log(a + b*x)/(b**S(3)*x) - a*c*sqrt(c*x**S(2))/b**S(2) + c*x*sqrt(c*x**S(2))/(S(2)*b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(3)/2)/(x**S(2)*(a + b*x)), x), x, -a*c*sqrt(c*x**S(2))*log(a + b*x)/(b**S(2)*x) + c*sqrt(c*x**S(2))/b, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(3)/2)/(x**S(3)*(a + b*x)), x), x, c*sqrt(c*x**S(2))*log(a + b*x)/(b*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(3)/2)/(x**S(4)*(a + b*x)), x), x, c*sqrt(c*x**S(2))*log(x)/(a*x) - c*sqrt(c*x**S(2))*log(a + b*x)/(a*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(3)/2)/(x**S(5)*(a + b*x)), x), x, -c*sqrt(c*x**S(2))/(a*x**S(2)) - b*c*sqrt(c*x**S(2))*log(x)/(a**S(2)*x) + b*c*sqrt(c*x**S(2))*log(a + b*x)/(a**S(2)*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(3)/2)/(x**S(6)*(a + b*x)), x), x, -c*sqrt(c*x**S(2))/(S(2)*a*x**S(3)) + b*c*sqrt(c*x**S(2))/(a**S(2)*x**S(2)) + b**S(2)*c*sqrt(c*x**S(2))*log(x)/(a**S(3)*x) - b**S(2)*c*sqrt(c*x**S(2))*log(a + b*x)/(a**S(3)*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(3)/2)/(x**S(7)*(a + b*x)), x), x, -c*sqrt(c*x**S(2))/(S(3)*a*x**S(4)) + b*c*sqrt(c*x**S(2))/(S(2)*a**S(2)*x**S(3)) - b**S(2)*c*sqrt(c*x**S(2))/(a**S(3)*x**S(2)) - b**S(3)*c*sqrt(c*x**S(2))*log(x)/(a**S(4)*x) + b**S(3)*c*sqrt(c*x**S(2))*log(a + b*x)/(a**S(4)*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(5)/2)/(a + b*x), x), x, -a**S(5)*c**S(2)*sqrt(c*x**S(2))*log(a + b*x)/(b**S(6)*x) + a**S(4)*c**S(2)*sqrt(c*x**S(2))/b**S(5) - a**S(3)*c**S(2)*x*sqrt(c*x**S(2))/(S(2)*b**S(4)) + a**S(2)*c**S(2)*x**S(2)*sqrt(c*x**S(2))/(S(3)*b**S(3)) - a*c**S(2)*x**S(3)*sqrt(c*x**S(2))/(S(4)*b**S(2)) + c**S(2)*x**S(4)*sqrt(c*x**S(2))/(S(5)*b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(5)/2)/(x*(a + b*x)), x), x, a**S(4)*c**S(2)*sqrt(c*x**S(2))*log(a + b*x)/(b**S(5)*x) - a**S(3)*c**S(2)*sqrt(c*x**S(2))/b**S(4) + a**S(2)*c**S(2)*x*sqrt(c*x**S(2))/(S(2)*b**S(3)) - a*c**S(2)*x**S(2)*sqrt(c*x**S(2))/(S(3)*b**S(2)) + c**S(2)*x**S(3)*sqrt(c*x**S(2))/(S(4)*b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(5)/2)/(x**S(2)*(a + b*x)), x), x, -a**S(3)*c**S(2)*sqrt(c*x**S(2))*log(a + b*x)/(b**S(4)*x) + a**S(2)*c**S(2)*sqrt(c*x**S(2))/b**S(3) - a*c**S(2)*x*sqrt(c*x**S(2))/(S(2)*b**S(2)) + c**S(2)*x**S(2)*sqrt(c*x**S(2))/(S(3)*b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(5)/2)/(x**S(3)*(a + b*x)), x), x, a**S(2)*c**S(2)*sqrt(c*x**S(2))*log(a + b*x)/(b**S(3)*x) - a*c**S(2)*sqrt(c*x**S(2))/b**S(2) + c**S(2)*x*sqrt(c*x**S(2))/(S(2)*b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(5)/2)/(x**S(4)*(a + b*x)), x), x, -a*c**S(2)*sqrt(c*x**S(2))*log(a + b*x)/(b**S(2)*x) + c**S(2)*sqrt(c*x**S(2))/b, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(5)/2)/(x**S(5)*(a + b*x)), x), x, c**S(2)*sqrt(c*x**S(2))*log(a + b*x)/(b*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(5)/2)/(x**S(6)*(a + b*x)), x), x, c**S(2)*sqrt(c*x**S(2))*log(x)/(a*x) - c**S(2)*sqrt(c*x**S(2))*log(a + b*x)/(a*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(5)/2)/(x**S(7)*(a + b*x)), x), x, -c**S(2)*sqrt(c*x**S(2))/(a*x**S(2)) - b*c**S(2)*sqrt(c*x**S(2))*log(x)/(a**S(2)*x) + b*c**S(2)*sqrt(c*x**S(2))*log(a + b*x)/(a**S(2)*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/(sqrt(c*x**S(2))*(a + b*x)), x), x, -a**S(3)*x*log(a + b*x)/(b**S(4)*sqrt(c*x**S(2))) + a**S(2)*x**S(2)/(b**S(3)*sqrt(c*x**S(2))) - a*x**S(3)/(S(2)*b**S(2)*sqrt(c*x**S(2))) + x**S(4)/(S(3)*b*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(sqrt(c*x**S(2))*(a + b*x)), x), x, a**S(2)*x*log(a + b*x)/(b**S(3)*sqrt(c*x**S(2))) - a*x**S(2)/(b**S(2)*sqrt(c*x**S(2))) + x**S(3)/(S(2)*b*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(sqrt(c*x**S(2))*(a + b*x)), x), x, -a*sqrt(c*x**S(2))*log(a + b*x)/(b**S(2)*c*x) + sqrt(c*x**S(2))/(b*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(sqrt(c*x**S(2))*(a + b*x)), x), x, x*log(a + b*x)/(b*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(c*x**S(2))*(a + b*x)), x), x, x*log(x)/(a*sqrt(c*x**S(2))) - x*log(a + b*x)/(a*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*sqrt(c*x**S(2))*(a + b*x)), x), x, -S(1)/(a*sqrt(c*x**S(2))) - b*x*log(x)/(a**S(2)*sqrt(c*x**S(2))) + b*x*log(a + b*x)/(a**S(2)*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*sqrt(c*x**S(2))*(a + b*x)), x), x, -S(1)/(S(2)*a*x*sqrt(c*x**S(2))) + b/(a**S(2)*sqrt(c*x**S(2))) + b**S(2)*x*log(x)/(a**S(3)*sqrt(c*x**S(2))) - b**S(2)*x*log(a + b*x)/(a**S(3)*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*sqrt(c*x**S(2))*(a + b*x)), x), x, -S(1)/(S(3)*a*x**S(2)*sqrt(c*x**S(2))) + b/(S(2)*a**S(2)*x*sqrt(c*x**S(2))) - b**S(2)/(a**S(3)*sqrt(c*x**S(2))) - b**S(3)*x*log(x)/(a**S(4)*sqrt(c*x**S(2))) + b**S(3)*x*log(a + b*x)/(a**S(4)*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(6)/((c*x**S(2))**(S(3)/2)*(a + b*x)), x), x, -a**S(3)*x*log(a + b*x)/(b**S(4)*c*sqrt(c*x**S(2))) + a**S(2)*x**S(2)/(b**S(3)*c*sqrt(c*x**S(2))) - a*x**S(3)/(S(2)*b**S(2)*c*sqrt(c*x**S(2))) + x**S(4)/(S(3)*b*c*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)/((c*x**S(2))**(S(3)/2)*(a + b*x)), x), x, a**S(2)*x*log(a + b*x)/(b**S(3)*c*sqrt(c*x**S(2))) - a*x**S(2)/(b**S(2)*c*sqrt(c*x**S(2))) + x**S(3)/(S(2)*b*c*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/((c*x**S(2))**(S(3)/2)*(a + b*x)), x), x, -a*x*log(a + b*x)/(b**S(2)*c*sqrt(c*x**S(2))) + x**S(2)/(b*c*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/((c*x**S(2))**(S(3)/2)*(a + b*x)), x), x, x*log(a + b*x)/(b*c*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/((c*x**S(2))**(S(3)/2)*(a + b*x)), x), x, x*log(x)/(a*c*sqrt(c*x**S(2))) - x*log(a + b*x)/(a*c*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/((c*x**S(2))**(S(3)/2)*(a + b*x)), x), x, -S(1)/(a*c*sqrt(c*x**S(2))) - b*x*log(x)/(a**S(2)*c*sqrt(c*x**S(2))) + b*x*log(a + b*x)/(a**S(2)*c*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((c*x**S(2))**(S(3)/2)*(a + b*x)), x), x, -S(1)/(S(2)*a*c*x*sqrt(c*x**S(2))) + b/(a**S(2)*c*sqrt(c*x**S(2))) + b**S(2)*x*log(x)/(a**S(3)*c*sqrt(c*x**S(2))) - b**S(2)*x*log(a + b*x)/(a**S(3)*c*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(c*x**S(2))**(S(3)/2)*(a + b*x)), x), x, -S(1)/(S(3)*a*c*x**S(2)*sqrt(c*x**S(2))) + b/(S(2)*a**S(2)*c*x*sqrt(c*x**S(2))) - b**S(2)/(a**S(3)*c*sqrt(c*x**S(2))) - b**S(3)*x*log(x)/(a**S(4)*c*sqrt(c*x**S(2))) + b**S(3)*x*log(a + b*x)/(a**S(4)*c*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*sqrt(c*x**S(2))/(a + b*x)**S(2), x), x, -a**S(4)*sqrt(c*x**S(2))/(b**S(5)*x*(a + b*x)) - S(4)*a**S(3)*sqrt(c*x**S(2))*log(a + b*x)/(b**S(5)*x) + S(3)*a**S(2)*sqrt(c*x**S(2))/b**S(4) - a*x*sqrt(c*x**S(2))/b**S(3) + x**S(2)*sqrt(c*x**S(2))/(S(3)*b**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*sqrt(c*x**S(2))/(a + b*x)**S(2), x), x, a**S(3)*sqrt(c*x**S(2))/(b**S(4)*x*(a + b*x)) + S(3)*a**S(2)*sqrt(c*x**S(2))*log(a + b*x)/(b**S(4)*x) - S(2)*a*sqrt(c*x**S(2))/b**S(3) + x*sqrt(c*x**S(2))/(S(2)*b**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*sqrt(c*x**S(2))/(a + b*x)**S(2), x), x, -a**S(2)*sqrt(c*x**S(2))/(b**S(3)*x*(a + b*x)) - S(2)*a*sqrt(c*x**S(2))*log(a + b*x)/(b**S(3)*x) + sqrt(c*x**S(2))/b**S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(c*x**S(2))/(a + b*x)**S(2), x), x, a*sqrt(c*x**S(2))/(b**S(2)*x*(a + b*x)) + sqrt(c*x**S(2))*log(a + b*x)/(b**S(2)*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(c*x**S(2))/(x*(a + b*x)**S(2)), x), x, -sqrt(c*x**S(2))/(b*x*(a + b*x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(c*x**S(2))/(x**S(2)*(a + b*x)**S(2)), x), x, sqrt(c*x**S(2))/(a*x*(a + b*x)) + sqrt(c*x**S(2))*log(x)/(a**S(2)*x) - sqrt(c*x**S(2))*log(a + b*x)/(a**S(2)*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(c*x**S(2))/(x**S(3)*(a + b*x)**S(2)), x), x, -b*sqrt(c*x**S(2))/(a**S(2)*x*(a + b*x)) - sqrt(c*x**S(2))/(a**S(2)*x**S(2)) - S(2)*b*sqrt(c*x**S(2))*log(x)/(a**S(3)*x) + S(2)*b*sqrt(c*x**S(2))*log(a + b*x)/(a**S(3)*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(c*x**S(2))/(x**S(4)*(a + b*x)**S(2)), x), x, -sqrt(c*x**S(2))/(S(2)*a**S(2)*x**S(3)) + b**S(2)*sqrt(c*x**S(2))/(a**S(3)*x*(a + b*x)) + S(2)*b*sqrt(c*x**S(2))/(a**S(3)*x**S(2)) + S(3)*b**S(2)*sqrt(c*x**S(2))*log(x)/(a**S(4)*x) - S(3)*b**S(2)*sqrt(c*x**S(2))*log(a + b*x)/(a**S(4)*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(c*x**S(2))**(S(3)/2)/(a + b*x)**S(2), x), x, -a**S(4)*c*sqrt(c*x**S(2))/(b**S(5)*x*(a + b*x)) - S(4)*a**S(3)*c*sqrt(c*x**S(2))*log(a + b*x)/(b**S(5)*x) + S(3)*a**S(2)*c*sqrt(c*x**S(2))/b**S(4) - a*c*x*sqrt(c*x**S(2))/b**S(3) + c*x**S(2)*sqrt(c*x**S(2))/(S(3)*b**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(3)/2)/(a + b*x)**S(2), x), x, a**S(3)*c*sqrt(c*x**S(2))/(b**S(4)*x*(a + b*x)) + S(3)*a**S(2)*c*sqrt(c*x**S(2))*log(a + b*x)/(b**S(4)*x) - S(2)*a*c*sqrt(c*x**S(2))/b**S(3) + c*x*sqrt(c*x**S(2))/(S(2)*b**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(3)/2)/(x*(a + b*x)**S(2)), x), x, -a**S(2)*c*sqrt(c*x**S(2))/(b**S(3)*x*(a + b*x)) - S(2)*a*c*sqrt(c*x**S(2))*log(a + b*x)/(b**S(3)*x) + c*sqrt(c*x**S(2))/b**S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(3)/2)/(x**S(2)*(a + b*x)**S(2)), x), x, a*c*sqrt(c*x**S(2))/(b**S(2)*x*(a + b*x)) + c*sqrt(c*x**S(2))*log(a + b*x)/(b**S(2)*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(3)/2)/(x**S(3)*(a + b*x)**S(2)), x), x, -c*sqrt(c*x**S(2))/(b*x*(a + b*x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(3)/2)/(x**S(4)*(a + b*x)**S(2)), x), x, c*sqrt(c*x**S(2))/(a*x*(a + b*x)) + c*sqrt(c*x**S(2))*log(x)/(a**S(2)*x) - c*sqrt(c*x**S(2))*log(a + b*x)/(a**S(2)*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(3)/2)/(x**S(5)*(a + b*x)**S(2)), x), x, -b*c*sqrt(c*x**S(2))/(a**S(2)*x*(a + b*x)) - c*sqrt(c*x**S(2))/(a**S(2)*x**S(2)) - S(2)*b*c*sqrt(c*x**S(2))*log(x)/(a**S(3)*x) + S(2)*b*c*sqrt(c*x**S(2))*log(a + b*x)/(a**S(3)*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**(S(3)/2)/(x**S(6)*(a + b*x)**S(2)), x), x, -c*sqrt(c*x**S(2))/(S(2)*a**S(2)*x**S(3)) + b**S(2)*c*sqrt(c*x**S(2))/(a**S(3)*x*(a + b*x)) + S(2)*b*c*sqrt(c*x**S(2))/(a**S(3)*x**S(2)) + S(3)*b**S(2)*c*sqrt(c*x**S(2))*log(x)/(a**S(4)*x) - S(3)*b**S(2)*c*sqrt(c*x**S(2))*log(a + b*x)/(a**S(4)*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)/(sqrt(c*x**S(2))*(a + b*x)**S(2)), x), x, -a**S(4)*x/(b**S(5)*sqrt(c*x**S(2))*(a + b*x)) - S(4)*a**S(3)*x*log(a + b*x)/(b**S(5)*sqrt(c*x**S(2))) + S(3)*a**S(2)*x**S(2)/(b**S(4)*sqrt(c*x**S(2))) - a*x**S(3)/(b**S(3)*sqrt(c*x**S(2))) + x**S(4)/(S(3)*b**S(2)*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/(sqrt(c*x**S(2))*(a + b*x)**S(2)), x), x, a**S(3)*x/(b**S(4)*sqrt(c*x**S(2))*(a + b*x)) + S(3)*a**S(2)*x*log(a + b*x)/(b**S(4)*sqrt(c*x**S(2))) - S(2)*a*x**S(2)/(b**S(3)*sqrt(c*x**S(2))) + x**S(3)/(S(2)*b**S(2)*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(sqrt(c*x**S(2))*(a + b*x)**S(2)), x), x, -a**S(2)*x/(b**S(3)*sqrt(c*x**S(2))*(a + b*x)) - S(2)*a*x*log(a + b*x)/(b**S(3)*sqrt(c*x**S(2))) + x**S(2)/(b**S(2)*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(sqrt(c*x**S(2))*(a + b*x)**S(2)), x), x, a*sqrt(c*x**S(2))/(b**S(2)*c*x*(a + b*x)) + sqrt(c*x**S(2))*log(a + b*x)/(b**S(2)*c*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(sqrt(c*x**S(2))*(a + b*x)**S(2)), x), x, -x/(b*sqrt(c*x**S(2))*(a + b*x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(c*x**S(2))*(a + b*x)**S(2)), x), x, x/(a*sqrt(c*x**S(2))*(a + b*x)) + x*log(x)/(a**S(2)*sqrt(c*x**S(2))) - x*log(a + b*x)/(a**S(2)*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*sqrt(c*x**S(2))*(a + b*x)**S(2)), x), x, -b*x/(a**S(2)*sqrt(c*x**S(2))*(a + b*x)) - S(1)/(a**S(2)*sqrt(c*x**S(2))) - S(2)*b*x*log(x)/(a**S(3)*sqrt(c*x**S(2))) + S(2)*b*x*log(a + b*x)/(a**S(3)*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*sqrt(c*x**S(2))*(a + b*x)**S(2)), x), x, -S(1)/(S(2)*a**S(2)*x*sqrt(c*x**S(2))) + b**S(2)*x/(a**S(3)*sqrt(c*x**S(2))*(a + b*x)) + S(2)*b/(a**S(3)*sqrt(c*x**S(2))) + S(3)*b**S(2)*x*log(x)/(a**S(4)*sqrt(c*x**S(2))) - S(3)*b**S(2)*x*log(a + b*x)/(a**S(4)*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)/((c*x**S(2))**(S(3)/2)*(a + b*x)**S(2)), x), x, -a**S(2)*x/(b**S(3)*c*sqrt(c*x**S(2))*(a + b*x)) - S(2)*a*x*log(a + b*x)/(b**S(3)*c*sqrt(c*x**S(2))) + x**S(2)/(b**S(2)*c*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/((c*x**S(2))**(S(3)/2)*(a + b*x)**S(2)), x), x, a*x/(b**S(2)*c*sqrt(c*x**S(2))*(a + b*x)) + x*log(a + b*x)/(b**S(2)*c*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/((c*x**S(2))**(S(3)/2)*(a + b*x)**S(2)), x), x, -x/(b*c*sqrt(c*x**S(2))*(a + b*x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/((c*x**S(2))**(S(3)/2)*(a + b*x)**S(2)), x), x, x/(a*c*sqrt(c*x**S(2))*(a + b*x)) + x*log(x)/(a**S(2)*c*sqrt(c*x**S(2))) - x*log(a + b*x)/(a**S(2)*c*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/((c*x**S(2))**(S(3)/2)*(a + b*x)**S(2)), x), x, -b*x/(a**S(2)*c*sqrt(c*x**S(2))*(a + b*x)) - S(1)/(a**S(2)*c*sqrt(c*x**S(2))) - S(2)*b*x*log(x)/(a**S(3)*c*sqrt(c*x**S(2))) + S(2)*b*x*log(a + b*x)/(a**S(3)*c*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((c*x**S(2))**(S(3)/2)*(a + b*x)**S(2)), x), x, -S(1)/(S(2)*a**S(2)*c*x*sqrt(c*x**S(2))) + b**S(2)*x/(a**S(3)*c*sqrt(c*x**S(2))*(a + b*x)) + S(2)*b/(a**S(3)*c*sqrt(c*x**S(2))) + S(3)*b**S(2)*x*log(x)/(a**S(4)*c*sqrt(c*x**S(2))) - S(3)*b**S(2)*x*log(a + b*x)/(a**S(4)*c*sqrt(c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**m*(c*x**S(2))**p*(a + b*x)**(-m - S(2)*p + S(-2)), x), x, x**(m + S(1))*(c*x**S(2))**p*(a + b*x)**(-m - S(2)*p + S(-1))/(a*(m + S(2)*p + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(c*x**S(2))**p*(a + b*x)**(-S(2)*p + S(-5)), x), x, x**S(4)*(c*x**S(2))**p*(a + b*x)**(-S(2)*p + S(-4))/(S(2)*a*(p + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(c*x**S(2))**p*(a + b*x)**(-S(2)*p + S(-4)), x), x, x**S(3)*(c*x**S(2))**p*(a + b*x)**(-S(2)*p + S(-3))/(a*(S(2)*p + S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(c*x**S(2))**p*(a + b*x)**(-S(2)*p + S(-3)), x), x, x**S(2)*(c*x**S(2))**p*(a + b*x)**(-S(2)*p + S(-2))/(S(2)*a*(p + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**p*(a + b*x)**(-S(2)*p + S(-2)), x), x, x*(c*x**S(2))**p*(a + b*x)**(-S(2)*p + S(-1))/(a*(S(2)*p + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**p*(a + b*x)**(-S(2)*p + S(-1))/x, x), x, (c*x**S(2))**p*(a + b*x)**(-S(2)*p)/(S(2)*a*p), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**p*(a + b*x)**(-S(2)*p)/x**S(2), x), x, -(c*x**S(2))**p*(a + b*x)**(-S(2)*p + S(1))/(a*x*(-S(2)*p + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**p*(a + b*x)**(-S(2)*p + S(1))/x**S(3), x), x, -(c*x**S(2))**p*(a + b*x)**(-S(2)*p + S(2))/(S(2)*a*x**S(2)*(-p + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**S(2))**p*(a + b*x)**(-S(2)*p + S(2))/x**S(4), x), x, -(c*x**S(2))**p*(a + b*x)**(-S(2)*p + S(3))/(a*x**S(3)*(-S(2)*p + S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a*x**S(23))/sqrt(x**S(5) + S(1)), x), x, sqrt(a*x**S(23))*sqrt(x**S(5) + S(1))/(S(10)*x**S(4)) - S(3)*sqrt(a*x**S(23))*sqrt(x**S(5) + S(1))/(S(20)*x**S(9)) + S(3)*sqrt(a*x**S(23))*asinh(x**(S(5)/2))/(S(20)*x**(S(23)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a*x**S(13))/sqrt(x**S(5) + S(1)), x), x, sqrt(a*x**S(13))*sqrt(x**S(5) + S(1))/(S(5)*x**S(4)) - sqrt(a*x**S(13))*asinh(x**(S(5)/2))/(S(5)*x**(S(13)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a*x**S(3))/sqrt(x**S(5) + S(1)), x), x, S(2)*sqrt(a*x**S(3))*asinh(x**(S(5)/2))/(S(5)*x**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a/x**S(7))/sqrt(x**S(5) + S(1)), x), x, -S(2)*x*sqrt(a/x**S(7))*sqrt(x**S(5) + S(1))/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a/x**S(17))/sqrt(x**S(5) + S(1)), x), x, S(4)*x**S(6)*sqrt(a/x**S(17))*sqrt(x**S(5) + S(1))/S(15) - S(2)*x*sqrt(a/x**S(17))*sqrt(x**S(5) + S(1))/S(15), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a*x**S(6))/(x*(-x**S(4) + S(1))), x), x, -sqrt(a*x**S(6))*atan(x)/(S(2)*x**S(3)) + sqrt(a*x**S(6))*atanh(x)/(S(2)*x**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a*x**S(6))/(-x**S(5) + x), x), x, -sqrt(a*x**S(6))*atan(x)/(S(2)*x**S(3)) + sqrt(a*x**S(6))*atanh(x)/(S(2)*x**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*x**S(6))**(S(3)/2)/(x*(-x**S(4) + S(1))), x), x, -a*x**S(2)*sqrt(a*x**S(6))/S(5) - a*sqrt(a*x**S(6))/x**S(2) + a*sqrt(a*x**S(6))*atan(x)/(S(2)*x**S(3)) + a*sqrt(a*x**S(6))*atanh(x)/(S(2)*x**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(-x**S(4) + S(1)) - sqrt(a*x**S(6))/(x*(-x**S(4) + S(1))), x), x, atan(x)/S(2) + atanh(x)/S(2) + sqrt(a*x**S(6))*atan(x)/(S(2)*x**S(3)) - sqrt(a*x**S(6))*atanh(x)/(S(2)*x**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(-sqrt(a*x**S(6))/(-x**S(5) + x) + S(1)/(-x**S(4) + S(1)), x), x, atan(x)/S(2) + atanh(x)/S(2) + sqrt(a*x**S(6))*atan(x)/(S(2)*x**S(3)) - sqrt(a*x**S(6))*atanh(x)/(S(2)*x**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a*x**S(3))/(-x**S(3) + x), x), x, -sqrt(a*x**S(3))*atan(sqrt(x))/x**(S(3)/2) + sqrt(a*x**S(3))*atanh(sqrt(x))/x**(S(3)/2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a*x**S(4))/sqrt(x**S(2) + S(1)), x), x, sqrt(a*x**S(4))*sqrt(x**S(2) + S(1))/(S(2)*x) - sqrt(a*x**S(4))*asinh(x)/(S(2)*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a*x**S(3))/sqrt(x**S(2) + S(1)), x), x, S(2)*sqrt(a*x**S(3))*sqrt(x**S(2) + S(1))/(S(3)*x) - sqrt(a*x**S(3))*sqrt((x**S(2) + S(1))/(x + S(1))**S(2))*(x + S(1))*elliptic_f(S(2)*atan(sqrt(x)), S(1)/2)/(S(3)*x**(S(3)/2)*sqrt(x**S(2) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a*x**S(2))/sqrt(x**S(2) + S(1)), x), x, sqrt(a*x**S(2))*sqrt(x**S(2) + S(1))/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a*x)/sqrt(x**S(2) + S(1)), x), x, -S(2)*sqrt(a)*sqrt((x**S(2) + S(1))/(x + S(1))**S(2))*(x + S(1))*elliptic_e(S(2)*atan(sqrt(a*x)/sqrt(a)), S(1)/2)/sqrt(x**S(2) + S(1)) + sqrt(a)*sqrt((x**S(2) + S(1))/(x + S(1))**S(2))*(x + S(1))*elliptic_f(S(2)*atan(sqrt(a*x)/sqrt(a)), S(1)/2)/sqrt(x**S(2) + S(1)) + S(2)*sqrt(a*x)*sqrt(x**S(2) + S(1))/(x + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a/x)/sqrt(x**S(2) + S(1)), x), x, sqrt(x)*sqrt(a/x)*sqrt((x**S(2) + S(1))/(x + S(1))**S(2))*(x + S(1))*elliptic_f(S(2)*atan(sqrt(x)), S(1)/2)/sqrt(x**S(2) + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a/x**S(2))/sqrt(x**S(2) + S(1)), x), x, -x*sqrt(a/x**S(2))*atanh(sqrt(x**S(2) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a/x**S(3))/sqrt(x**S(2) + S(1)), x), x, -S(2)*x**(S(3)/2)*sqrt(a/x**S(3))*sqrt((x**S(2) + S(1))/(x + S(1))**S(2))*(x + S(1))*elliptic_e(S(2)*atan(sqrt(x)), S(1)/2)/sqrt(x**S(2) + S(1)) + x**(S(3)/2)*sqrt(a/x**S(3))*sqrt((x**S(2) + S(1))/(x + S(1))**S(2))*(x + S(1))*elliptic_f(S(2)*atan(sqrt(x)), S(1)/2)/sqrt(x**S(2) + S(1)) + S(2)*x**S(2)*sqrt(a/x**S(3))*sqrt(x**S(2) + S(1))/(x + S(1)) - S(2)*x*sqrt(a/x**S(3))*sqrt(x**S(2) + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a/x**S(4))/sqrt(x**S(2) + S(1)), x), x, -x*sqrt(a/x**S(4))*sqrt(x**S(2) + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a*x**S(4))/sqrt(x**S(3) + S(1)), x), x, S(2)*sqrt(a*x**S(4))*sqrt(x**S(3) + S(1))/(S(3)*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a*x**S(3))/sqrt(x**S(3) + S(1)), x), x, -S(3)**(S(1)/4)*sqrt(a*x**S(3))*sqrt((x**S(2) - x + S(1))/(x*(S(1) + sqrt(S(3))) + S(1))**S(2))*(x + S(1))*elliptic_e(acos((x*(-sqrt(S(3)) + S(1)) + S(1))/(x*(S(1) + sqrt(S(3))) + S(1))), sqrt(S(3))/S(4) + S(1)/2)/(x*sqrt(x*(x + S(1))/(x*(S(1) + sqrt(S(3))) + S(1))**S(2))*sqrt(x**S(3) + S(1))) - S(3)**(S(3)/4)*sqrt(a*x**S(3))*sqrt((x**S(2) - x + S(1))/(x*(S(1) + sqrt(S(3))) + S(1))**S(2))*(-sqrt(S(3)) + S(1))*(x + S(1))*elliptic_f(acos((x*(-sqrt(S(3)) + S(1)) + S(1))/(x*(S(1) + sqrt(S(3))) + S(1))), sqrt(S(3))/S(4) + S(1)/2)/(S(6)*x*sqrt(x*(x + S(1))/(x*(S(1) + sqrt(S(3))) + S(1))**S(2))*sqrt(x**S(3) + S(1))) + sqrt(a*x**S(3))*(S(1) + sqrt(S(3)))*sqrt(x**S(3) + S(1))/(x*(x*(S(1) + sqrt(S(3))) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a*x**S(2))/sqrt(x**S(3) + S(1)), x), x, S(2)*sqrt(a*x**S(2))*sqrt(x**S(3) + S(1))/(x*(x + S(1) + sqrt(S(3)))) - S(3)**(S(1)/4)*sqrt(a*x**S(2))*sqrt((x**S(2) - x + S(1))/(x + S(1) + sqrt(S(3)))**S(2))*sqrt(-sqrt(S(3)) + S(2))*(x + S(1))*elliptic_e(asin((x - sqrt(S(3)) + S(1))/(x + S(1) + sqrt(S(3)))), S(-7) - S(4)*sqrt(S(3)))/(x*sqrt((x + S(1))/(x + S(1) + sqrt(S(3)))**S(2))*sqrt(x**S(3) + S(1))) + S(2)*sqrt(S(2))*S(3)**(S(3)/4)*sqrt(a*x**S(2))*sqrt((x**S(2) - x + S(1))/(x + S(1) + sqrt(S(3)))**S(2))*(x + S(1))*elliptic_f(asin((x - sqrt(S(3)) + S(1))/(x + S(1) + sqrt(S(3)))), S(-7) - S(4)*sqrt(S(3)))/(S(3)*x*sqrt((x + S(1))/(x + S(1) + sqrt(S(3)))**S(2))*sqrt(x**S(3) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a*x)/sqrt(x**S(3) + S(1)), x), x, S(2)*sqrt(a)*asinh((a*x)**(S(3)/2)/a**(S(3)/2))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a/x)/sqrt(x**S(3) + S(1)), x), x, S(3)**(S(3)/4)*x*sqrt(a/x)*sqrt((x**S(2) - x + S(1))/(x*(S(1) + sqrt(S(3))) + S(1))**S(2))*(x + S(1))*elliptic_f(acos((x*(-sqrt(S(3)) + S(1)) + S(1))/(x*(S(1) + sqrt(S(3))) + S(1))), sqrt(S(3))/S(4) + S(1)/2)/(S(3)*sqrt(x*(x + S(1))/(x*(S(1) + sqrt(S(3))) + S(1))**S(2))*sqrt(x**S(3) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a/x**S(2))/sqrt(x**S(3) + S(1)), x), x, -S(2)*x*sqrt(a/x**S(2))*atanh(sqrt(x**S(3) + S(1)))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a/x**S(3))/sqrt(x**S(3) + S(1)), x), x, -S(2)*S(3)**(S(1)/4)*x**S(2)*sqrt(a/x**S(3))*sqrt((x**S(2) - x + S(1))/(x*(S(1) + sqrt(S(3))) + S(1))**S(2))*(x + S(1))*elliptic_e(acos((x*(-sqrt(S(3)) + S(1)) + S(1))/(x*(S(1) + sqrt(S(3))) + S(1))), sqrt(S(3))/S(4) + S(1)/2)/(sqrt(x*(x + S(1))/(x*(S(1) + sqrt(S(3))) + S(1))**S(2))*sqrt(x**S(3) + S(1))) - S(3)**(S(3)/4)*x**S(2)*sqrt(a/x**S(3))*sqrt((x**S(2) - x + S(1))/(x*(S(1) + sqrt(S(3))) + S(1))**S(2))*(-sqrt(S(3)) + S(1))*(x + S(1))*elliptic_f(acos((x*(-sqrt(S(3)) + S(1)) + S(1))/(x*(S(1) + sqrt(S(3))) + S(1))), sqrt(S(3))/S(4) + S(1)/2)/(S(3)*sqrt(x*(x + S(1))/(x*(S(1) + sqrt(S(3))) + S(1))**S(2))*sqrt(x**S(3) + S(1))) + x**S(2)*sqrt(a/x**S(3))*(S(2) + S(2)*sqrt(S(3)))*sqrt(x**S(3) + S(1))/(x*(S(1) + sqrt(S(3))) + S(1)) - S(2)*x*sqrt(a/x**S(3))*sqrt(x**S(3) + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a/x**S(4))/sqrt(x**S(3) + S(1)), x), x, x**S(2)*sqrt(a/x**S(4))*sqrt(x**S(3) + S(1))/(x + S(1) + sqrt(S(3))) - S(3)**(S(1)/4)*x**S(2)*sqrt(a/x**S(4))*sqrt((x**S(2) - x + S(1))/(x + S(1) + sqrt(S(3)))**S(2))*sqrt(-sqrt(S(3)) + S(2))*(x + S(1))*elliptic_e(asin((x - sqrt(S(3)) + S(1))/(x + S(1) + sqrt(S(3)))), S(-7) - S(4)*sqrt(S(3)))/(S(2)*sqrt((x + S(1))/(x + S(1) + sqrt(S(3)))**S(2))*sqrt(x**S(3) + S(1))) + sqrt(S(2))*S(3)**(S(3)/4)*x**S(2)*sqrt(a/x**S(4))*sqrt((x**S(2) - x + S(1))/(x + S(1) + sqrt(S(3)))**S(2))*(x + S(1))*elliptic_f(asin((x - sqrt(S(3)) + S(1))/(x + S(1) + sqrt(S(3)))), S(-7) - S(4)*sqrt(S(3)))/(S(3)*sqrt((x + S(1))/(x + S(1) + sqrt(S(3)))**S(2))*sqrt(x**S(3) + S(1))) - x*sqrt(a/x**S(4))*sqrt(x**S(3) + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a*x**(S(2)*n))/sqrt(x**n + S(1)), x), x, x*sqrt(a*x**(S(2)*n))*hyper((S(1)/2, S(1) + S(1)/n), (S(2) + S(1)/n,), -x**n)/(n + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a*x**n)/sqrt(x**n + S(1)), x), x, S(2)*x*sqrt(a*x**n)*hyper((S(1)/2, S(1)/2 + S(1)/n), (S(3)/2 + S(1)/n,), -x**n)/(n + S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a*x**(n/S(2)))/sqrt(x**n + S(1)), x), x, S(4)*x*sqrt(a*x**(n/S(2)))*hyper((S(1)/2, S(1)/4 + S(1)/n), (S(5)/4 + S(1)/n,), -x**n)/(n + S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a*x**(S(2)*n))/sqrt(x**n + S(1)) + S(2)*x**(-n)*sqrt(a*x**(S(2)*n))/((n + S(2))*sqrt(x**n + S(1))), x), x, S(2)*x**(-n + S(1))*sqrt(a*x**(S(2)*n))*sqrt(x**n + S(1))/(n + S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a*x)/(sqrt(d + e*x)*sqrt(e + f*x)), x), x, S(2)*sqrt(a*x)*sqrt(e*(e + f*x)/(-d*f + e**S(2)))*sqrt(d*f - e**S(2))*elliptic_e(asin(sqrt(f)*sqrt(d + e*x)/sqrt(d*f - e**S(2))), S(1) - e**S(2)/(d*f))/(e*sqrt(f)*sqrt(-e*x/d)*sqrt(e + f*x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*x**m)**r, x), x, x*(a*x**m)**r/(m*r + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*x**m)**r*(b*x**n)**s, x), x, x*(a*x**m)**r*(b*x**n)**s/(m*r + n*s + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*x**m)**r*(b*x**n)**s*(c*x**p)**t, x), x, x*(a*x**m)**r*(b*x**n)**s*(c*x**p)**t/(m*r + n*s + p*t + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**n)**(S(1)/n)*(a + b*(c*x**n)**(S(1)/n))**p, x), x, -a*x*(c*x**n)**(-S(1)/n)*(a + b*(c*x**n)**(S(1)/n))**(p + S(1))/(b**S(2)*(p + S(1))) + x*(c*x**n)**(-S(1)/n)*(a + b*(c*x**n)**(S(1)/n))**(p + S(2))/(b**S(2)*(p + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**n)**(S(1)/n)*(a + b*(c*x**n)**(S(1)/n))**S(3), x), x, -a*x*(c*x**n)**(-S(1)/n)*(a + b*(c*x**n)**(S(1)/n))**S(4)/(S(4)*b**S(2)) + x*(c*x**n)**(-S(1)/n)*(a + b*(c*x**n)**(S(1)/n))**S(5)/(S(5)*b**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**n)**(S(1)/n)*(a + b*(c*x**n)**(S(1)/n))**S(2), x), x, a**S(2)*x*(c*x**n)**(S(1)/n)/S(2) + S(2)*a*b*x*(c*x**n)**(S(2)/n)/S(3) + b**S(2)*x*(c*x**n)**(S(3)/n)/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**n)**(S(1)/n)*(a + b*(c*x**n)**(S(1)/n)), x), x, a*x*(c*x**n)**(S(1)/n)/S(2) + b*x*(c*x**n)**(S(2)/n)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**n)**(S(1)/n)/(a + b*(c*x**n)**(S(1)/n)), x), x, -a*x*(c*x**n)**(-S(1)/n)*log(a + b*(c*x**n)**(S(1)/n))/b**S(2) + x/b, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**n)**(S(1)/n)/(a + b*(c*x**n)**(S(1)/n))**S(2), x), x, a*x*(c*x**n)**(-S(1)/n)/(b**S(2)*(a + b*(c*x**n)**(S(1)/n))) + x*(c*x**n)**(-S(1)/n)*log(a + b*(c*x**n)**(S(1)/n))/b**S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**n)**(S(1)/n)/(a + b*(c*x**n)**(S(1)/n))**S(3), x), x, x*(c*x**n)**(S(1)/n)/(S(2)*a*(a + b*(c*x**n)**(S(1)/n))**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**n)**(S(1)/n)/(a + b*(c*x**n)**(S(1)/n))**S(4), x), x, a*x*(c*x**n)**(-S(1)/n)/(S(3)*b**S(2)*(a + b*(c*x**n)**(S(1)/n))**S(3)) - x*(c*x**n)**(-S(1)/n)/(S(2)*b**S(2)*(a + b*(c*x**n)**(S(1)/n))**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*x**n)**(S(1)/n)/(a + b*(c*x**n)**(S(1)/n))**S(5), x), x, a*x*(c*x**n)**(-S(1)/n)/(S(4)*b**S(2)*(a + b*(c*x**n)**(S(1)/n))**S(4)) - x*(c*x**n)**(-S(1)/n)/(S(3)*b**S(2)*(a + b*(c*x**n)**(S(1)/n))**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(sqrt(a + b*x) + sqrt(b*x + c)), x), x, S(2)*a**S(2)*(a + b*x)**(S(3)/2)/(S(3)*b**S(3)*(a - c)) - S(4)*a*(a + b*x)**(S(5)/2)/(S(5)*b**S(3)*(a - c)) - S(2)*c**S(2)*(b*x + c)**(S(3)/2)/(S(3)*b**S(3)*(a - c)) + S(4)*c*(b*x + c)**(S(5)/2)/(S(5)*b**S(3)*(a - c)) + S(2)*(a + b*x)**(S(7)/2)/(S(7)*b**S(3)*(a - c)) - S(2)*(b*x + c)**(S(7)/2)/(S(7)*b**S(3)*(a - c)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(sqrt(a + b*x) + sqrt(b*x + c)), x), x, -S(2)*a*(a + b*x)**(S(3)/2)/(S(3)*b**S(2)*(a - c)) + S(2)*c*(b*x + c)**(S(3)/2)/(S(3)*b**S(2)*(a - c)) + S(2)*(a + b*x)**(S(5)/2)/(S(5)*b**S(2)*(a - c)) - S(2)*(b*x + c)**(S(5)/2)/(S(5)*b**S(2)*(a - c)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(a + b*x) + sqrt(b*x + c)), x), x, S(2)*(a + b*x)**(S(3)/2)/(S(3)*b*(a - c)) - S(2)*(b*x + c)**(S(3)/2)/(S(3)*b*(a - c)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(sqrt(a + b*x) + sqrt(b*x + c))), x), x, -S(2)*sqrt(a)*atanh(sqrt(a + b*x)/sqrt(a))/(a - c) + S(2)*sqrt(c)*atanh(sqrt(b*x + c)/sqrt(c))/(a - c) + S(2)*sqrt(a + b*x)/(a - c) - S(2)*sqrt(b*x + c)/(a - c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(sqrt(a + b*x) + sqrt(b*x + c))), x), x, b*atanh(sqrt(b*x + c)/sqrt(c))/(sqrt(c)*(a - c)) - sqrt(a + b*x)/(x*(a - c)) + sqrt(b*x + c)/(x*(a - c)) - b*atanh(sqrt(a + b*x)/sqrt(a))/(sqrt(a)*(a - c)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(sqrt(a + b*x) + sqrt(b*x + c))**S(2), x), x, b*x**S(4)/(S(2)*(a - c)**S(2)) + x**S(3)*(a + c)/(S(3)*(a - c)**S(2)) - x*(a + b*x)**(S(3)/2)*(b*x + c)**(S(3)/2)/(S(2)*b**S(2)*(a - c)**S(2)) - (S(4)*a*c - S(5)*(a + c)**S(2))*atanh(sqrt(a + b*x)/sqrt(b*x + c))/(S(32)*b**S(3)) - sqrt(a + b*x)*(S(4)*a*c - S(5)*(a + c)**S(2))*sqrt(b*x + c)/(S(32)*b**S(3)*(a - c)) + (a + b*x)**(S(3)/2)*(S(5)*a + S(5)*c)*(b*x + c)**(S(3)/2)/(S(12)*b**S(3)*(a - c)**S(2)) + (a + b*x)**(S(3)/2)*(S(4)*a*c - S(5)*(a + c)**S(2))*sqrt(b*x + c)/(S(16)*b**S(3)*(a - c)**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(sqrt(a + b*x) + sqrt(b*x + c))**S(2), x), x, S(2)*b*x**S(3)/(S(3)*(a - c)**S(2)) + x**S(2)*(a + c)/(S(2)*(a - c)**S(2)) - (a + c)*atanh(sqrt(a + b*x)/sqrt(b*x + c))/(S(4)*b**S(2)) - (a + c)*sqrt(a + b*x)*sqrt(b*x + c)/(S(4)*b**S(2)*(a - c)) + (a + c)*(a + b*x)**(S(3)/2)*sqrt(b*x + c)/(S(2)*b**S(2)*(a - c)**S(2)) - S(2)*(a + b*x)**(S(3)/2)*(b*x + c)**(S(3)/2)/(S(3)*b**S(2)*(a - c)**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((sqrt(a + b*x) + sqrt(b*x + c))**(S(-2)), x), x, (a - c)**S(2)/(S(8)*b*(sqrt(a + b*x) + sqrt(b*x + c))**S(4)) + atanh(sqrt(a + b*x)/sqrt(b*x + c))/(S(2)*b), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate((sqrt(a + b*x) + sqrt(b*x + c))**(S(-2)), x), x, b*x**S(2)/(a - c)**S(2) + x*(a + c)/(a - c)**S(2) + atanh(sqrt(a + b*x)/sqrt(b*x + c))/(S(2)*b) + sqrt(a + b*x)*sqrt(b*x + c)/(S(2)*b*(a - c)) - (a + b*x)**(S(3)/2)*sqrt(b*x + c)/(b*(a - c)**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(sqrt(a + b*x) + sqrt(b*x + c))**S(2)), x), x, S(4)*sqrt(a)*sqrt(c)*atanh(sqrt(c)*sqrt(a + b*x)/(sqrt(a)*sqrt(b*x + c)))/(a - c)**S(2) + S(2)*b*x/(a - c)**S(2) + (a + c)*log(x)/(a - c)**S(2) - S(2)*sqrt(a + b*x)*sqrt(b*x + c)/(a - c)**S(2) - (S(2)*a + S(2)*c)*atanh(sqrt(a + b*x)/sqrt(b*x + c))/(a - c)**S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(sqrt(a + b*x) + sqrt(b*x + c))**S(2)), x), x, S(2)*b*log(x)/(a - c)**S(2) - S(4)*b*atanh(sqrt(a + b*x)/sqrt(b*x + c))/(a - c)**S(2) - (a + c)/(x*(a - c)**S(2)) + S(2)*sqrt(a + b*x)*sqrt(b*x + c)/(x*(a - c)**S(2)) + S(2)*b*(a + c)*atanh(sqrt(c)*sqrt(a + b*x)/(sqrt(a)*sqrt(b*x + c)))/(sqrt(a)*sqrt(c)*(a - c)**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(sqrt(a + b*x) + sqrt(b*x + c))**S(3), x), x, -S(8)*a**S(3)*(a + b*x)**(S(3)/2)/(S(3)*b**S(3)*(a - c)**S(3)) + S(2)*a**S(2)*(a + S(3)*c)*(a + b*x)**(S(3)/2)/(S(3)*b**S(3)*(a - c)**S(3)) + S(24)*a**S(2)*(a + b*x)**(S(5)/2)/(S(5)*b**S(3)*(a - c)**S(3)) - S(4)*a*(a + S(3)*c)*(a + b*x)**(S(5)/2)/(S(5)*b**S(3)*(a - c)**S(3)) - S(24)*a*(a + b*x)**(S(7)/2)/(S(7)*b**S(3)*(a - c)**S(3)) + S(8)*c**S(3)*(b*x + c)**(S(3)/2)/(S(3)*b**S(3)*(a - c)**S(3)) - S(2)*c**S(2)*(S(3)*a + c)*(b*x + c)**(S(3)/2)/(S(3)*b**S(3)*(a - c)**S(3)) - S(24)*c**S(2)*(b*x + c)**(S(5)/2)/(S(5)*b**S(3)*(a - c)**S(3)) + S(4)*c*(S(3)*a + c)*(b*x + c)**(S(5)/2)/(S(5)*b**S(3)*(a - c)**S(3)) + S(24)*c*(b*x + c)**(S(7)/2)/(S(7)*b**S(3)*(a - c)**S(3)) + S(8)*(a + b*x)**(S(9)/2)/(S(9)*b**S(3)*(a - c)**S(3)) + (a + b*x)**(S(7)/2)*(S(2)*a + S(6)*c)/(S(7)*b**S(3)*(a - c)**S(3)) - (S(6)*a + S(2)*c)*(b*x + c)**(S(7)/2)/(S(7)*b**S(3)*(a - c)**S(3)) - S(8)*(b*x + c)**(S(9)/2)/(S(9)*b**S(3)*(a - c)**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(sqrt(a + b*x) + sqrt(b*x + c))**S(3), x), x, S(8)*a**S(2)*(a + b*x)**(S(3)/2)/(S(3)*b**S(2)*(a - c)**S(3)) - S(2)*a*(a + S(3)*c)*(a + b*x)**(S(3)/2)/(S(3)*b**S(2)*(a - c)**S(3)) - S(16)*a*(a + b*x)**(S(5)/2)/(S(5)*b**S(2)*(a - c)**S(3)) - S(8)*c**S(2)*(b*x + c)**(S(3)/2)/(S(3)*b**S(2)*(a - c)**S(3)) + S(2)*c*(S(3)*a + c)*(b*x + c)**(S(3)/2)/(S(3)*b**S(2)*(a - c)**S(3)) + S(16)*c*(b*x + c)**(S(5)/2)/(S(5)*b**S(2)*(a - c)**S(3)) + S(8)*(a + b*x)**(S(7)/2)/(S(7)*b**S(2)*(a - c)**S(3)) + (a + b*x)**(S(5)/2)*(S(2)*a + S(6)*c)/(S(5)*b**S(2)*(a - c)**S(3)) - (S(6)*a + S(2)*c)*(b*x + c)**(S(5)/2)/(S(5)*b**S(2)*(a - c)**S(3)) - S(8)*(b*x + c)**(S(7)/2)/(S(7)*b**S(2)*(a - c)**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((sqrt(a + b*x) + sqrt(b*x + c))**(S(-3)), x), x, (a - c)**S(2)/(S(10)*b*(sqrt(a + b*x) + sqrt(b*x + c))**S(5)) - S(1)/(S(2)*b*(sqrt(a + b*x) + sqrt(b*x + c))), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate((sqrt(a + b*x) + sqrt(b*x + c))**(S(-3)), x), x, -S(8)*a*(a + b*x)**(S(3)/2)/(S(3)*b*(a - c)**S(3)) + S(8)*c*(b*x + c)**(S(3)/2)/(S(3)*b*(a - c)**S(3)) + S(8)*(a + b*x)**(S(5)/2)/(S(5)*b*(a - c)**S(3)) + (a + b*x)**(S(3)/2)*(S(2)*a + S(6)*c)/(S(3)*b*(a - c)**S(3)) - (S(6)*a + S(2)*c)*(b*x + c)**(S(3)/2)/(S(3)*b*(a - c)**S(3)) - S(8)*(b*x + c)**(S(5)/2)/(S(5)*b*(a - c)**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(sqrt(a + b*x) + sqrt(b*x + c))**S(3)), x), x, -S(2)*sqrt(a)*(a + S(3)*c)*atanh(sqrt(a + b*x)/sqrt(a))/(a - c)**S(3) + S(2)*sqrt(c)*(S(3)*a + c)*atanh(sqrt(b*x + c)/sqrt(c))/(a - c)**S(3) + S(8)*(a + b*x)**(S(3)/2)/(S(3)*(a - c)**S(3)) + sqrt(a + b*x)*(S(2)*a + S(6)*c)/(a - c)**S(3) - (S(6)*a + S(2)*c)*sqrt(b*x + c)/(a - c)**S(3) - S(8)*(b*x + c)**(S(3)/2)/(S(3)*(a - c)**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(sqrt(a + b*x) + sqrt(b*x + c))**S(3)), x), x, S(8)*b*sqrt(a + b*x)/(a - c)**S(3) - S(8)*b*sqrt(b*x + c)/(a - c)**S(3) - S(3)*b*(a + S(3)*c)*atanh(sqrt(b*x + c)/sqrt(c))/(sqrt(c)*(-a + c)**S(3)) - (a + S(3)*c)*sqrt(a + b*x)/(x*(a - c)**S(3)) + (S(3)*a + c)*sqrt(b*x + c)/(x*(a - c)**S(3)) - S(3)*b*(S(3)*a + c)*atanh(sqrt(a + b*x)/sqrt(a))/(sqrt(a)*(a - c)**S(3)), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(S(1)/(x**S(2)*(sqrt(a + b*x) + sqrt(b*x + c))**S(3)), x), x, -S(8)*sqrt(a)*b*atanh(sqrt(a + b*x)/sqrt(a))/(a - c)**S(3) + S(8)*b*sqrt(c)*atanh(sqrt(b*x + c)/sqrt(c))/(a - c)**S(3) + S(8)*b*sqrt(a + b*x)/(a - c)**S(3) - S(8)*b*sqrt(b*x + c)/(a - c)**S(3) + b*(S(3)*a + c)*atanh(sqrt(b*x + c)/sqrt(c))/(sqrt(c)*(a - c)**S(3)) - (a + S(3)*c)*sqrt(a + b*x)/(x*(a - c)**S(3)) + (S(3)*a + c)*sqrt(b*x + c)/(x*(a - c)**S(3)) - b*(a + S(3)*c)*atanh(sqrt(a + b*x)/sqrt(a))/(sqrt(a)*(a - c)**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(x) + sqrt(x + S(1))), x), x, -S(2)*x**(S(3)/2)/S(3) + S(2)*(x + S(1))**(S(3)/2)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(x) + sqrt(x + S(-1))), x), x, S(2)*x**(S(3)/2)/S(3) - S(2)*(x + S(-1))**(S(3)/2)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(x + S(-1)) + sqrt(x + S(1))), x), x, -(x + S(-1))**(S(3)/2)/S(3) + (x + S(1))**(S(3)/2)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(sqrt(-x + S(1)) + sqrt(x + S(1)))**S(2), x), x, x**S(4)/S(2) + S(2)*(-x**S(2) + S(1))**(S(5)/2)/S(5) - S(2)*(-x**S(2) + S(1))**(S(3)/2)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(sqrt(-x + S(1)) + sqrt(x + S(1)))**S(2), x), x, x**S(3)*sqrt(-x**S(2) + S(1))/S(2) + S(2)*x**S(3)/S(3) - x*sqrt(-x**S(2) + S(1))/S(4) + asin(x)/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(sqrt(-x + S(1)) + sqrt(x + S(1)))**S(2), x), x, x**S(2) - S(2)*(-x**S(2) + S(1))**(S(3)/2)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((sqrt(-x + S(1)) + sqrt(x + S(1)))**S(2), x), x, x*sqrt(-x**S(2) + S(1)) + S(2)*x + asin(x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((sqrt(-x + S(1)) + sqrt(x + S(1)))**S(2)/x, x), x, S(2)*sqrt(-x**S(2) + S(1)) + S(2)*log(x) - S(2)*atanh(sqrt(-x**S(2) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((sqrt(-x + S(1)) + sqrt(x + S(1)))**S(2)/x**S(2), x), x, -S(2)*asin(x) - S(2)*sqrt(-x**S(2) + S(1))/x - S(2)/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((sqrt(-x + S(1)) + sqrt(x + S(1)))**S(2)/x**S(3), x), x, atanh(sqrt(-x**S(2) + S(1))) - sqrt(-x**S(2) + S(1))/x**S(2) - S(1)/x**S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(sqrt(a + b*x) + sqrt(a + c*x)), x), x, -S(2)*a**S(2)*(a + c*x)**(S(3)/2)/(c**S(3)*(S(3)*b - S(3)*c)) + S(2)*a**S(2)*(a + b*x)**(S(3)/2)/(S(3)*b**S(3)*(b - c)) + S(4)*a*(a + c*x)**(S(5)/2)/(c**S(3)*(S(5)*b - S(5)*c)) - S(4)*a*(a + b*x)**(S(5)/2)/(S(5)*b**S(3)*(b - c)) - S(2)*(a + c*x)**(S(7)/2)/(c**S(3)*(S(7)*b - S(7)*c)) + S(2)*(a + b*x)**(S(7)/2)/(S(7)*b**S(3)*(b - c)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(sqrt(a + b*x) + sqrt(a + c*x)), x), x, S(2)*a*(a + c*x)**(S(3)/2)/(c**S(2)*(S(3)*b - S(3)*c)) - S(2)*a*(a + b*x)**(S(3)/2)/(S(3)*b**S(2)*(b - c)) - S(2)*(a + c*x)**(S(5)/2)/(c**S(2)*(S(5)*b - S(5)*c)) + S(2)*(a + b*x)**(S(5)/2)/(S(5)*b**S(2)*(b - c)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(sqrt(a + b*x) + sqrt(a + c*x)), x), x, -S(2)*(a + c*x)**(S(3)/2)/(c*(S(3)*b - S(3)*c)) + S(2)*(a + b*x)**(S(3)/2)/(S(3)*b*(b - c)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(a + b*x) + sqrt(a + c*x)), x), x, -S(2)*sqrt(a)*atanh(sqrt(a + b*x)/sqrt(a))/(b - c) + S(2)*sqrt(a)*atanh(sqrt(a + c*x)/sqrt(a))/(b - c) + S(2)*sqrt(a + b*x)/(b - c) - S(2)*sqrt(a + c*x)/(b - c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(sqrt(a + b*x) + sqrt(a + c*x))), x), x, -sqrt(a + b*x)/(x*(b - c)) + sqrt(a + c*x)/(x*(b - c)) - b*atanh(sqrt(a + b*x)/sqrt(a))/(sqrt(a)*(b - c)) + c*atanh(sqrt(a + c*x)/sqrt(a))/(sqrt(a)*(b - c)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(sqrt(a + b*x) + sqrt(a + c*x))), x), x, -sqrt(a + b*x)/(x**S(2)*(S(2)*b - S(2)*c)) + sqrt(a + c*x)/(x**S(2)*(S(2)*b - S(2)*c)) - b*sqrt(a + b*x)/(S(4)*a*x*(b - c)) + c*sqrt(a + c*x)/(S(4)*a*x*(b - c)) + b**S(2)*atanh(sqrt(a + b*x)/sqrt(a))/(S(4)*a**(S(3)/2)*(b - c)) - c**S(2)*atanh(sqrt(a + c*x)/sqrt(a))/(S(4)*a**(S(3)/2)*(b - c)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(sqrt(a + b*x) + sqrt(a + c*x))**S(2), x), x, -a**S(3)*(b + c)*atanh(sqrt(c)*sqrt(a + b*x)/(sqrt(b)*sqrt(a + c*x)))/(S(4)*b**(S(5)/2)*c**(S(5)/2)) + a**S(2)*sqrt(a + b*x)*sqrt(a + c*x)*(b + c)/(S(4)*b**S(2)*c**S(2)*(b - c)) + a*x**S(2)/(b - c)**S(2) + a*(a + b*x)**(S(3)/2)*sqrt(a + c*x)*(b + c)/(S(2)*b**S(2)*c*(b - c)**S(2)) + x**S(3)*(b + c)/(S(3)*(b - c)**S(2)) - S(2)*(a + b*x)**(S(3)/2)*(a + c*x)**(S(3)/2)/(S(3)*b*c*(b - c)**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(sqrt(a + b*x) + sqrt(a + c*x))**S(2), x), x, a**S(2)*atanh(sqrt(c)*sqrt(a + b*x)/(sqrt(b)*sqrt(a + c*x)))/(S(2)*b**(S(3)/2)*c**(S(3)/2)) + S(2)*a*x/(b - c)**S(2) - a*sqrt(a + b*x)*sqrt(a + c*x)/(S(2)*b*c*(b - c)) + x**S(2)*(b + c)/(S(2)*(b - c)**S(2)) - (a + b*x)**(S(3)/2)*sqrt(a + c*x)/(b*(b - c)**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(sqrt(a + b*x) + sqrt(a + c*x))**S(2), x), x, S(2)*a*log(x)/(b - c)**S(2) + S(4)*a*atanh(sqrt(a + b*x)/sqrt(a + c*x))/(b - c)**S(2) - S(2)*a*(b + c)*atanh(sqrt(c)*sqrt(a + b*x)/(sqrt(b)*sqrt(a + c*x)))/(sqrt(b)*sqrt(c)*(b - c)**S(2)) + x*(b + c)/(b - c)**S(2) - S(2)*sqrt(a + b*x)*sqrt(a + c*x)/(b - c)**S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((sqrt(a + b*x) + sqrt(a + c*x))**(S(-2)), x), x, -S(2)*a/(x*(b - c)**S(2)) - S(4)*sqrt(b)*sqrt(c)*atanh(sqrt(c)*sqrt(a + b*x)/(sqrt(b)*sqrt(a + c*x)))/(b - c)**S(2) + (b + c)*log(x)/(b - c)**S(2) + (S(2)*b + S(2)*c)*atanh(sqrt(a + b*x)/sqrt(a + c*x))/(b - c)**S(2) + S(2)*sqrt(a + b*x)*sqrt(a + c*x)/(x*(b - c)**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(sqrt(a + b*x) + sqrt(a + c*x))**S(2)), x), x, -a/(x**S(2)*(b - c)**S(2)) - (b + c)/(x*(b - c)**S(2)) - atanh(sqrt(a + b*x)/sqrt(a + c*x))/(S(2)*a) + sqrt(a + b*x)*sqrt(a + c*x)/(S(2)*a*x*(b - c)) + sqrt(a + b*x)*(a + c*x)**(S(3)/2)/(a*x**S(2)*(b - c)**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(sqrt(a + b*x) + sqrt(a + c*x))**S(2)), x), x, -S(2)*a/(S(3)*x**S(3)*(b - c)**S(2)) - (b + c)/(S(2)*x**S(2)*(b - c)**S(2)) + (b + c)*atanh(sqrt(a + b*x)/sqrt(a + c*x))/(S(4)*a**S(2)) - sqrt(a + b*x)*sqrt(a + c*x)*(b + c)/(S(4)*a**S(2)*x*(b - c)) - sqrt(a + b*x)*(a + c*x)**(S(3)/2)*(b + c)/(S(2)*a**S(2)*x**S(2)*(b - c)**S(2)) + S(2)*(a + b*x)**(S(3)/2)*(a + c*x)**(S(3)/2)/(S(3)*a**S(2)*x**S(3)*(b - c)**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/(sqrt(a + b*x) + sqrt(a + c*x))**S(3), x), x, S(8)*a**S(2)*(a + c*x)**(S(3)/2)/(S(3)*c**S(2)*(b - c)**S(3)) - S(2)*a**S(2)*(a + c*x)**(S(3)/2)*(S(3)*b + c)/(S(3)*c**S(3)*(b - c)**S(3)) - S(8)*a**S(2)*(a + b*x)**(S(3)/2)/(S(3)*b**S(2)*(b - c)**S(3)) + S(2)*a**S(2)*(a + b*x)**(S(3)/2)*(b + S(3)*c)/(S(3)*b**S(3)*(b - c)**S(3)) - S(8)*a*(a + c*x)**(S(5)/2)/(S(5)*c**S(2)*(b - c)**S(3)) + S(4)*a*(a + c*x)**(S(5)/2)*(S(3)*b + c)/(S(5)*c**S(3)*(b - c)**S(3)) + S(8)*a*(a + b*x)**(S(5)/2)/(S(5)*b**S(2)*(b - c)**S(3)) - S(4)*a*(a + b*x)**(S(5)/2)*(b + S(3)*c)/(S(5)*b**S(3)*(b - c)**S(3)) - (a + c*x)**(S(7)/2)*(S(6)*b + S(2)*c)/(S(7)*c**S(3)*(b - c)**S(3)) + (a + b*x)**(S(7)/2)*(S(2)*b + S(6)*c)/(S(7)*b**S(3)*(b - c)**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(sqrt(a + b*x) + sqrt(a + c*x))**S(3), x), x, -S(8)*a*(a + c*x)**(S(3)/2)/(S(3)*c*(b - c)**S(3)) + S(2)*a*(a + c*x)**(S(3)/2)*(S(3)*b + c)/(S(3)*c**S(2)*(b - c)**S(3)) + S(8)*a*(a + b*x)**(S(3)/2)/(S(3)*b*(b - c)**S(3)) - S(2)*a*(a + b*x)**(S(3)/2)*(b + S(3)*c)/(S(3)*b**S(2)*(b - c)**S(3)) - (a + c*x)**(S(5)/2)*(S(6)*b + S(2)*c)/(S(5)*c**S(2)*(b - c)**S(3)) + (a + b*x)**(S(5)/2)*(S(2)*b + S(6)*c)/(S(5)*b**S(2)*(b - c)**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(sqrt(a + b*x) + sqrt(a + c*x))**S(3), x), x, -S(8)*a**(S(3)/2)*atanh(sqrt(a + b*x)/sqrt(a))/(b - c)**S(3) + S(8)*a**(S(3)/2)*atanh(sqrt(a + c*x)/sqrt(a))/(b - c)**S(3) + S(8)*a*sqrt(a + b*x)/(b - c)**S(3) - S(8)*a*sqrt(a + c*x)/(b - c)**S(3) - (a + c*x)**(S(3)/2)*(S(6)*b + S(2)*c)/(S(3)*c*(b - c)**S(3)) + (a + b*x)**(S(3)/2)*(S(2)*b + S(6)*c)/(S(3)*b*(b - c)**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(sqrt(a + b*x) + sqrt(a + c*x))**S(3), x), x, -S(6)*sqrt(a)*(b + c)*atanh(sqrt(a + b*x)/sqrt(a))/(b - c)**S(3) + S(6)*sqrt(a)*(b + c)*atanh(sqrt(a + c*x)/sqrt(a))/(b - c)**S(3) - S(4)*a*sqrt(a + b*x)/(x*(b - c)**S(3)) + S(4)*a*sqrt(a + c*x)/(x*(b - c)**S(3)) + sqrt(a + b*x)*(S(2)*b + S(6)*c)/(b - c)**S(3) - sqrt(a + c*x)*(S(6)*b + S(2)*c)/(b - c)**S(3), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(x/(sqrt(a + b*x) + sqrt(a + c*x))**S(3), x), x, -S(4)*sqrt(a)*b*atanh(sqrt(a + b*x)/sqrt(a))/(b - c)**S(3) + S(4)*sqrt(a)*c*atanh(sqrt(a + c*x)/sqrt(a))/(b - c)**S(3) - S(2)*sqrt(a)*(b + S(3)*c)*atanh(sqrt(a + b*x)/sqrt(a))/(b - c)**S(3) + S(2)*sqrt(a)*(S(3)*b + c)*atanh(sqrt(a + c*x)/sqrt(a))/(b - c)**S(3) - S(4)*a*sqrt(a + b*x)/(x*(b - c)**S(3)) + S(4)*a*sqrt(a + c*x)/(x*(b - c)**S(3)) + sqrt(a + b*x)*(S(2)*b + S(6)*c)/(b - c)**S(3) - sqrt(a + c*x)*(S(6)*b + S(2)*c)/(b - c)**S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((sqrt(a + b*x) + sqrt(a + c*x))**(S(-3)), x), x, -S(2)*a*sqrt(a + b*x)/(x**S(2)*(b - c)**S(3)) + S(2)*a*sqrt(a + c*x)/(x**S(2)*(b - c)**S(3)) - sqrt(a + b*x)*(S(2)*b + S(3)*c)/(x*(b - c)**S(3)) + sqrt(a + c*x)*(S(3)*b + S(2)*c)/(x*(b - c)**S(3)) - S(3)*b*c*atanh(sqrt(a + b*x)/sqrt(a))/(sqrt(a)*(b - c)**S(3)) + S(3)*b*c*atanh(sqrt(a + c*x)/sqrt(a))/(sqrt(a)*(b - c)**S(3)), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate((sqrt(a + b*x) + sqrt(a + c*x))**(S(-3)), x), x, -S(2)*a*sqrt(a + b*x)/(x**S(2)*(b - c)**S(3)) + S(2)*a*sqrt(a + c*x)/(x**S(2)*(b - c)**S(3)) - b*sqrt(a + b*x)/(x*(b - c)**S(3)) + c*sqrt(a + c*x)/(x*(b - c)**S(3)) - sqrt(a + b*x)*(b + S(3)*c)/(x*(b - c)**S(3)) + sqrt(a + c*x)*(S(3)*b + c)/(x*(b - c)**S(3)) + b**S(2)*atanh(sqrt(a + b*x)/sqrt(a))/(sqrt(a)*(b - c)**S(3)) - b*(b + S(3)*c)*atanh(sqrt(a + b*x)/sqrt(a))/(sqrt(a)*(b - c)**S(3)) - c**S(2)*atanh(sqrt(a + c*x)/sqrt(a))/(sqrt(a)*(b - c)**S(3)) + c*(S(3)*b + c)*atanh(sqrt(a + c*x)/sqrt(a))/(sqrt(a)*(b - c)**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(-x + S(1))*(sqrt(-x + S(1)) + sqrt(x + S(1))), x), x, -x**S(2)/S(2) + x*sqrt(-x**S(2) + S(1))/S(2) + x + asin(x)/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(-sqrt(-x + S(1)) - sqrt(x + S(1)))*(sqrt(-x + S(1)) + sqrt(x + S(1))), x), x, -x**S(4)/S(2) - S(2)*(-x**S(2) + S(1))**(S(5)/2)/S(5) + S(2)*(-x**S(2) + S(1))**(S(3)/2)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(-sqrt(-x + S(1)) - sqrt(x + S(1)))*(sqrt(-x + S(1)) + sqrt(x + S(1))), x), x, -x**S(3)*sqrt(-x**S(2) + S(1))/S(2) - S(2)*x**S(3)/S(3) + x*sqrt(-x**S(2) + S(1))/S(4) - asin(x)/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(-sqrt(-x + S(1)) - sqrt(x + S(1)))*(sqrt(-x + S(1)) + sqrt(x + S(1))), x), x, -x**S(2) + S(2)*(-x**S(2) + S(1))**(S(3)/2)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-sqrt(-x + S(1)) - sqrt(x + S(1)))*(sqrt(-x + S(1)) + sqrt(x + S(1))), x), x, -x*sqrt(-x**S(2) + S(1)) - S(2)*x - asin(x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-sqrt(-x + S(1)) - sqrt(x + S(1)))*(sqrt(-x + S(1)) + sqrt(x + S(1)))/x, x), x, -S(2)*sqrt(-x**S(2) + S(1)) - S(2)*log(x) + S(2)*atanh(sqrt(-x**S(2) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-sqrt(-x + S(1)) - sqrt(x + S(1)))*(sqrt(-x + S(1)) + sqrt(x + S(1)))/x**S(2), x), x, S(2)*asin(x) + S(2)*sqrt(-x**S(2) + S(1))/x + S(2)/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-sqrt(-x + S(1)) - sqrt(x + S(1)))*(sqrt(-x + S(1)) + sqrt(x + S(1)))/x**S(3), x), x, -atanh(sqrt(-x**S(2) + S(1))) + sqrt(-x**S(2) + S(1))/x**S(2) + x**(S(-2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((sqrt(-x + S(1)) + sqrt(x + S(1)))/(-sqrt(-x + S(1)) + sqrt(x + S(1))), x), x, sqrt(-x**S(2) + S(1)) + log(x) - atanh(sqrt(-x**S(2) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-sqrt(x + S(-1)) + sqrt(x + S(1)))/(sqrt(x + S(-1)) + sqrt(x + S(1))), x), x, x**S(2)/S(2) - x*sqrt(x + S(-1))*sqrt(x + S(1))/S(2) + acosh(x)/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))**n, x), x, a*f**S(2)*(d + e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))**(n + S(1))*hyper((S(2), n + S(1)), (n + S(2),), (d + e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))/d)/(S(2)*d**S(2)*e*(n + S(1))) + (d + e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))**(n + S(1))/(S(2)*e*(n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))**S(3), x), x, -a*d**S(3)*f**S(2)/(S(2)*e*(e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))) + S(3)*a*d**S(2)*f**S(2)*log(e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))/(S(2)*e) + a*d*f**S(2)*(e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))/e + a*f**S(2)*(d + e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))**S(2)/(S(4)*e) + (d + e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))**S(4)/(S(8)*e), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))**S(2), x), x, -a*d**S(2)*f**S(2)/(S(2)*e*(e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))) + a*d*f**S(2)*log(e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))/e + a*f**S(2)*(e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))/(S(2)*e) + (d + e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))**S(3)/(S(6)*e), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(d + e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)), x), x, a*f**S(2)*atanh(e*x/(f*sqrt(a + e**S(2)*x**S(2)/f**S(2))))/(S(2)*e) + d*x + e*x**S(2)/S(2) + f*x*sqrt(a + e**S(2)*x**S(2)/f**S(2))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(d + e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2))), x), x, -a*f**S(2)/(S(2)*d*e*(e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))) - a*f**S(2)*log(e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))/(S(2)*d**S(2)*e) + (a*f**S(2)/d**S(2) + S(1))*log(d + e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))/(S(2)*e), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))**(S(-2)), x), x, -a*f**S(2)/(S(2)*d**S(2)*e*(e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))) - a*f**S(2)*log(e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))/(d**S(3)*e) + a*f**S(2)*log(d + e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))/(d**S(3)*e) - (a*f**S(2)/d**S(2) + S(1))/(S(2)*e*(d + e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))**(S(-3)), x), x, -a*f**S(2)/(d**S(3)*e*(d + e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))) - a*f**S(2)/(S(2)*d**S(3)*e*(e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))) - S(3)*a*f**S(2)*log(e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))/(S(2)*d**S(4)*e) + S(3)*a*f**S(2)*log(d + e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))/(S(2)*d**S(4)*e) - (a*f**S(2)/d**S(2) + S(1))/(S(4)*e*(d + e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))**(S(5)/2), x), x, -S(5)*a*d**(S(3)/2)*f**S(2)*atanh(sqrt(d + e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))/sqrt(d))/(S(2)*e) - a*d**S(2)*f**S(2)*sqrt(d + e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))/(S(2)*e*(e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))) + S(2)*a*d*f**S(2)*sqrt(d + e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))/e + a*f**S(2)*(d + e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))**(S(3)/2)/(S(3)*e) + (d + e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))**(S(7)/2)/(S(7)*e), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))**(S(3)/2), x), x, -S(3)*a*sqrt(d)*f**S(2)*atanh(sqrt(d + e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))/sqrt(d))/(S(2)*e) - a*d*f**S(2)*sqrt(d + e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))/(S(2)*e*(e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))) + a*f**S(2)*sqrt(d + e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))/e + (d + e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))**(S(5)/2)/(S(5)*e), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(d + e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2))), x), x, -a*f**S(2)*sqrt(d + e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))/(S(2)*e*(e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))) - a*f**S(2)*atanh(sqrt(d + e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))/sqrt(d))/(S(2)*sqrt(d)*e) + (d + e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))**(S(3)/2)/(S(3)*e), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(d + e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2))), x), x, -a*f**S(2)*sqrt(d + e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))/(S(2)*d*e*(e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))) + a*f**S(2)*atanh(sqrt(d + e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))/sqrt(d))/(S(2)*d**(S(3)/2)*e) + sqrt(d + e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))/e, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))**(S(-3)/2), x), x, -a*f**S(2)*sqrt(d + e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))/(S(2)*d**S(2)*e*(e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))) + S(3)*a*f**S(2)*atanh(sqrt(d + e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))/sqrt(d))/(S(2)*d**(S(5)/2)*e) - (a*f**S(2)/d**S(2) + S(1))/(e*sqrt(d + e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))**(S(-5)/2), x), x, -S(2)*a*f**S(2)/(d**S(3)*e*sqrt(d + e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))) - a*f**S(2)*sqrt(d + e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))/(S(2)*d**S(3)*e*(e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))) + S(5)*a*f**S(2)*atanh(sqrt(d + e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))/sqrt(d))/(S(2)*d**(S(7)/2)*e) - (a*f**S(2)/d**S(2) + S(1))/(S(3)*e*(d + e*x + f*sqrt(a + e**S(2)*x**S(2)/f**S(2)))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x - sqrt(x**S(2) + S(-4))), x), x, (x - sqrt(x**S(2) + S(-4)))**(S(3)/2)/S(3) + S(4)/sqrt(x - sqrt(x**S(2) + S(-4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a*x + b*sqrt(a**S(2)*x**S(2)/b**S(2) + c)), x), x, -b**S(2)*c/(a*sqrt(a*x + b*sqrt(a**S(2)*x**S(2)/b**S(2) + c))) + (a*x + b*sqrt(a**S(2)*x**S(2)/b**S(2) + c))**(S(3)/2)/(S(3)*a), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(sqrt(-x**S(2) + S(1)) + S(1)), x), x, -S(2)*x**S(3)/(S(3)*(sqrt(-x**S(2) + S(1)) + S(1))**(S(3)/2)) + S(2)*x/sqrt(sqrt(-x**S(2) + S(1)) + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(sqrt(x**S(2) + S(1)) + S(1)), x), x, S(2)*x**S(3)/(S(3)*(sqrt(x**S(2) + S(1)) + S(1))**(S(3)/2)) + S(2)*x/sqrt(sqrt(x**S(2) + S(1)) + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(sqrt(x**S(2) + S(25)) + S(5)), x), x, S(2)*x**S(3)/(S(3)*(sqrt(x**S(2) + S(25)) + S(5))**(S(3)/2)) + S(10)*x/sqrt(sqrt(x**S(2) + S(25)) + S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + b*sqrt(a**S(2)/b**S(2) + c*x**S(2))), x), x, S(2)*a*x/sqrt(a + b*sqrt(a**S(2)/b**S(2) + c*x**S(2))) + S(2)*b**S(2)*c*x**S(3)/(S(3)*(a + b*sqrt(a**S(2)/b**S(2) + c*x**S(2)))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2)))**n, x), x, f**S(2)*(S(4)*a*e**S(2) - b**S(2)*f**S(2))*(d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2)))**(n + S(1))*hyper((S(2), n + S(1)), (n + S(2),), S(2)*e*(d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2)))/(-b*f**S(2) + S(2)*d*e))/(S(2)*e*(n + S(1))*(-b*f**S(2) + S(2)*d*e)**S(2)) + (d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2)))**(n + S(1))/(S(2)*e*(n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2)))**S(3), x), x, (d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2)))**S(4)/(S(8)*e) + f**S(2)*(S(4)*a*e**S(2) - b**S(2)*f**S(2))*(d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2)))**S(2)/(S(16)*e**S(3)) + f**S(2)*(S(4)*a*e**S(2) - b**S(2)*f**S(2))*(-b*f**S(2) + S(2)*d*e)*(e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2)))/(S(8)*e**S(4)) + f**S(2)*(S(4)*a*e**S(2) - b**S(2)*f**S(2))*(-b*f**S(2) + S(2)*d*e)**S(3)/(S(32)*e**S(5)*(-b*f**S(2) + S(2)*d*e - S(2)*e*(d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2))))) + S(3)*f**S(2)*(S(4)*a*e**S(2) - b**S(2)*f**S(2))*(-b*f**S(2) + S(2)*d*e)**S(2)*log(-b*f**S(2) + S(2)*d*e - S(2)*e*(d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2))))/(S(32)*e**S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2)))**S(2), x), x, (d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2)))**S(3)/(S(6)*e) + f**S(2)*(S(4)*a*e**S(2) - b**S(2)*f**S(2))*(e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2)))/(S(8)*e**S(3)) + f**S(2)*(S(4)*a*e**S(2) - b**S(2)*f**S(2))*(-b*f**S(2) + S(2)*d*e)**S(2)/(S(16)*e**S(4)*(-b*f**S(2) + S(2)*d*e - S(2)*e*(d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2))))) + f**S(2)*(S(4)*a*e**S(2) - b**S(2)*f**S(2))*(-b*f**S(2) + S(2)*d*e)*log(-b*f**S(2) + S(2)*d*e - S(2)*e*(d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2))))/(S(8)*e**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2)), x), x, d*x + e*x**S(2)/S(2) + f*(b*f**S(2) + S(2)*e**S(2)*x)*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2))/(S(4)*e**S(2)) + f**S(2)*(S(4)*a*e**S(2) - b**S(2)*f**S(2))*atanh((b*f**S(2) + S(2)*e**S(2)*x)/(S(2)*e*f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2))))/(S(8)*e**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2))), x), x, (S(2)*a*e*f**S(2) - S(2)*b*d*f**S(2) + S(2)*d**S(2)*e)*log(d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2)))/(-b*f**S(2) + S(2)*d*e)**S(2) + f**S(2)*(S(4)*a*e**S(2) - b**S(2)*f**S(2))/(S(2)*e*(-b*f**S(2) + S(2)*d*e)*(-b*f**S(2) + S(2)*d*e - S(2)*e*(d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2))))) - f**S(2)*(S(4)*a*e**S(2) - b**S(2)*f**S(2))*log(-b*f**S(2) + S(2)*d*e - S(2)*e*(d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2))))/(S(2)*e*(-b*f**S(2) + S(2)*d*e)**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2)))**(S(-2)), x), x, f**S(2)*(S(4)*a*e**S(2) - b**S(2)*f**S(2))/((-b*f**S(2) + S(2)*d*e)**S(2)*(-b*f**S(2) + S(2)*d*e - S(2)*e*(d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2))))) + S(2)*f**S(2)*(S(4)*a*e**S(2) - b**S(2)*f**S(2))*log(d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2)))/(-b*f**S(2) + S(2)*d*e)**S(3) - S(2)*f**S(2)*(S(4)*a*e**S(2) - b**S(2)*f**S(2))*log(-b*f**S(2) + S(2)*d*e - S(2)*e*(d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2))))/(-b*f**S(2) + S(2)*d*e)**S(3) - (S(2)*a*e*f**S(2) - S(2)*b*d*f**S(2) + S(2)*d**S(2)*e)/((-b*f**S(2) + S(2)*d*e)**S(2)*(d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2)))**(S(-3)), x), x, S(2)*e*f**S(2)*(S(4)*a*e**S(2) - b**S(2)*f**S(2))/((-b*f**S(2) + S(2)*d*e)**S(3)*(-b*f**S(2) + S(2)*d*e - S(2)*e*(d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2))))) + S(6)*e*f**S(2)*(S(4)*a*e**S(2) - b**S(2)*f**S(2))*log(d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2)))/(-b*f**S(2) + S(2)*d*e)**S(4) - S(6)*e*f**S(2)*(S(4)*a*e**S(2) - b**S(2)*f**S(2))*log(-b*f**S(2) + S(2)*d*e - S(2)*e*(d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2))))/(-b*f**S(2) + S(2)*d*e)**S(4) - S(2)*f**S(2)*(S(4)*a*e**S(2) - b**S(2)*f**S(2))/((-b*f**S(2) + S(2)*d*e)**S(3)*(d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2)))) - (a*e*f**S(2) - b*d*f**S(2) + d**S(2)*e)/((-b*f**S(2) + S(2)*d*e)**S(2)*(d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2)))**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2)))**(S(5)/2), x), x, (d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2)))**(S(7)/2)/(S(7)*e) + f**S(2)*(S(4)*a*e**S(2) - b**S(2)*f**S(2))*(d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2)))**(S(3)/2)/(S(12)*e**S(3)) + f**S(2)*(S(4)*a*e**S(2) - b**S(2)*f**S(2))*(-b*f**S(2) + S(2)*d*e)**S(2)*sqrt(d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2)))/(S(16)*e**S(4)*(-b*f**S(2) + S(2)*d*e - S(2)*e*(d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2))))) + f**S(2)*(S(4)*a*e**S(2) - b**S(2)*f**S(2))*(-b*f**S(2) + S(2)*d*e)*sqrt(d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2)))/(S(4)*e**S(4)) - S(5)*sqrt(S(2))*f**S(2)*(S(4)*a*e**S(2) - b**S(2)*f**S(2))*(-b*f**S(2) + S(2)*d*e)**(S(3)/2)*atanh(sqrt(S(2))*sqrt(e)*sqrt(d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2)))/sqrt(-b*f**S(2) + S(2)*d*e))/(S(32)*e**(S(9)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2)))**(S(3)/2), x), x, (d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2)))**(S(5)/2)/(S(5)*e) + f**S(2)*(S(4)*a*e**S(2) - b**S(2)*f**S(2))*(-b*f**S(2) + S(2)*d*e)*sqrt(d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2)))/(S(8)*e**S(3)*(-b*f**S(2) + S(2)*d*e - S(2)*e*(d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2))))) + f**S(2)*(S(4)*a*e**S(2) - b**S(2)*f**S(2))*sqrt(d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2)))/(S(4)*e**S(3)) - S(3)*sqrt(S(2))*f**S(2)*(S(4)*a*e**S(2) - b**S(2)*f**S(2))*sqrt(-b*f**S(2) + S(2)*d*e)*atanh(sqrt(S(2))*sqrt(e)*sqrt(d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2)))/sqrt(-b*f**S(2) + S(2)*d*e))/(S(16)*e**(S(7)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2))), x), x, f**S(2)*(S(4)*a - b**S(2)*f**S(2)/e**S(2))*sqrt(d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2)))/(-S(4)*b*f**S(2) + S(8)*d*e - S(8)*e*(d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2)))) + (d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2)))**(S(3)/2)/(S(3)*e) - sqrt(S(2))*f**S(2)*(S(4)*a*e**S(2) - b**S(2)*f**S(2))*atanh(sqrt(S(2))*sqrt(e)*sqrt(d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2)))/sqrt(-b*f**S(2) + S(2)*d*e))/(S(8)*e**(S(5)/2)*sqrt(-b*f**S(2) + S(2)*d*e)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2))), x), x, f**S(2)*(S(4)*a*e**S(2) - b**S(2)*f**S(2))*sqrt(d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2)))/(S(2)*e*(-b*f**S(2) + S(2)*d*e)*(-b*f**S(2) + S(2)*d*e - S(2)*e*(d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2))))) + sqrt(d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2)))/e + sqrt(S(2))*f**S(2)*(S(4)*a*e**S(2) - b**S(2)*f**S(2))*atanh(sqrt(S(2))*sqrt(e)*sqrt(d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2)))/sqrt(-b*f**S(2) + S(2)*d*e))/(S(4)*e**(S(3)/2)*(-b*f**S(2) + S(2)*d*e)**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2)))**(S(-3)/2), x), x, f**S(2)*(S(4)*a*e**S(2) - b**S(2)*f**S(2))*sqrt(d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2)))/((-b*f**S(2) + S(2)*d*e)**S(2)*(-b*f**S(2) + S(2)*d*e - S(2)*e*(d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2))))) - (S(4)*a*e*f**S(2) - S(4)*b*d*f**S(2) + S(4)*d**S(2)*e)/((-b*f**S(2) + S(2)*d*e)**S(2)*sqrt(d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2)))) + S(3)*sqrt(S(2))*f**S(2)*(S(4)*a*e**S(2) - b**S(2)*f**S(2))*atanh(sqrt(S(2))*sqrt(e)*sqrt(d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2)))/sqrt(-b*f**S(2) + S(2)*d*e))/(S(2)*sqrt(e)*(-b*f**S(2) + S(2)*d*e)**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2)))**(S(-5)/2), x), x, S(5)*sqrt(S(2))*sqrt(e)*f**S(2)*(S(4)*a*e**S(2) - b**S(2)*f**S(2))*atanh(sqrt(S(2))*sqrt(e)*sqrt(d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2)))/sqrt(-b*f**S(2) + S(2)*d*e))/(-b*f**S(2) + S(2)*d*e)**(S(7)/2) + S(2)*e*f**S(2)*(S(4)*a*e**S(2) - b**S(2)*f**S(2))*sqrt(d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2)))/((-b*f**S(2) + S(2)*d*e)**S(3)*(-b*f**S(2) + S(2)*d*e - S(2)*e*(d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2))))) - S(4)*f**S(2)*(S(4)*a*e**S(2) - b**S(2)*f**S(2))/((-b*f**S(2) + S(2)*d*e)**S(3)*sqrt(d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2)))) - (S(4)*a*e*f**S(2) - S(4)*b*d*f**S(2) + S(4)*d**S(2)*e)/(S(3)*(-b*f**S(2) + S(2)*d*e)**S(2)*(d + e*x + f*sqrt(a + b*x + e**S(2)*x**S(2)/f**S(2)))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + x**S(2))**S(2)*(x + sqrt(a + x**S(2)))**n, x), x, -a**S(5)*(x + sqrt(a + x**S(2)))**(n + S(-5))/(-S(32)*n + S(160)) - S(5)*a**S(4)*(x + sqrt(a + x**S(2)))**(n + S(-3))/(-S(32)*n + S(96)) - S(5)*a**S(3)*(x + sqrt(a + x**S(2)))**(n + S(-1))/(-S(16)*n + S(16)) + S(5)*a**S(2)*(x + sqrt(a + x**S(2)))**(n + S(1))/(S(16)*n + S(16)) + S(5)*a*(x + sqrt(a + x**S(2)))**(n + S(3))/(S(32)*n + S(96)) + (x + sqrt(a + x**S(2)))**(n + S(5))/(S(32)*n + S(160)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + x**S(2))*(x + sqrt(a + x**S(2)))**n, x), x, -a**S(3)*(x + sqrt(a + x**S(2)))**(n + S(-3))/(-S(8)*n + S(24)) - S(3)*a**S(2)*(x + sqrt(a + x**S(2)))**(n + S(-1))/(-S(8)*n + S(8)) + S(3)*a*(x + sqrt(a + x**S(2)))**(n + S(1))/(S(8)*n + S(8)) + (x + sqrt(a + x**S(2)))**(n + S(3))/(S(8)*n + S(24)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x + sqrt(a + x**S(2)))**n, x), x, -a*(x + sqrt(a + x**S(2)))**(n + S(-1))/(-S(2)*n + S(2)) + (x + sqrt(a + x**S(2)))**(n + S(1))/(S(2)*n + S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x + sqrt(a + x**S(2)))**n/(a + x**S(2)), x), x, S(2)*(x + sqrt(a + x**S(2)))**(n + S(1))*hyper((S(1), n/S(2) + S(1)/2), (n/S(2) + S(3)/2,), -(x + sqrt(a + x**S(2)))**S(2)/a)/(a*(n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x + sqrt(a + x**S(2)))**n/(a + x**S(2))**S(2), x), x, S(8)*(x + sqrt(a + x**S(2)))**(n + S(3))*hyper((S(3), n/S(2) + S(3)/2), (n/S(2) + S(5)/2,), -(x + sqrt(a + x**S(2)))**S(2)/a)/(a**S(3)*(n + S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + x**S(2))**S(2)*(x - sqrt(a + x**S(2)))**n, x), x, -a**S(5)*(x - sqrt(a + x**S(2)))**(n + S(-5))/(-S(32)*n + S(160)) - S(5)*a**S(4)*(x - sqrt(a + x**S(2)))**(n + S(-3))/(-S(32)*n + S(96)) - S(5)*a**S(3)*(x - sqrt(a + x**S(2)))**(n + S(-1))/(-S(16)*n + S(16)) + S(5)*a**S(2)*(x - sqrt(a + x**S(2)))**(n + S(1))/(S(16)*n + S(16)) + S(5)*a*(x - sqrt(a + x**S(2)))**(n + S(3))/(S(32)*n + S(96)) + (x - sqrt(a + x**S(2)))**(n + S(5))/(S(32)*n + S(160)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + x**S(2))*(x - sqrt(a + x**S(2)))**n, x), x, -a**S(3)*(x - sqrt(a + x**S(2)))**(n + S(-3))/(-S(8)*n + S(24)) - S(3)*a**S(2)*(x - sqrt(a + x**S(2)))**(n + S(-1))/(-S(8)*n + S(8)) + S(3)*a*(x - sqrt(a + x**S(2)))**(n + S(1))/(S(8)*n + S(8)) + (x - sqrt(a + x**S(2)))**(n + S(3))/(S(8)*n + S(24)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x - sqrt(a + x**S(2)))**n, x), x, -a*(x - sqrt(a + x**S(2)))**(n + S(-1))/(-S(2)*n + S(2)) + (x - sqrt(a + x**S(2)))**(n + S(1))/(S(2)*n + S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x - sqrt(a + x**S(2)))**n/(a + x**S(2)), x), x, S(2)*(x - sqrt(a + x**S(2)))**(n + S(1))*hyper((S(1), n/S(2) + S(1)/2), (n/S(2) + S(3)/2,), -(x - sqrt(a + x**S(2)))**S(2)/a)/(a*(n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x - sqrt(a + x**S(2)))**n/(a + x**S(2))**S(2), x), x, S(8)*(x - sqrt(a + x**S(2)))**(n + S(3))*hyper((S(3), n/S(2) + S(3)/2), (n/S(2) + S(5)/2,), -(x - sqrt(a + x**S(2)))**S(2)/a)/(a**S(3)*(n + S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + x**S(2))**(S(5)/2)*(x + sqrt(a + x**S(2)))**n, x), x, -a**S(6)*(x + sqrt(a + x**S(2)))**(n + S(-6))/(-S(64)*n + S(384)) - S(3)*a**S(5)*(x + sqrt(a + x**S(2)))**(n + S(-4))/(-S(32)*n + S(128)) - S(15)*a**S(4)*(x + sqrt(a + x**S(2)))**(n + S(-2))/(-S(64)*n + S(128)) + S(5)*a**S(3)*(x + sqrt(a + x**S(2)))**n/(S(16)*n) + S(15)*a**S(2)*(x + sqrt(a + x**S(2)))**(n + S(2))/(S(64)*n + S(128)) + S(3)*a*(x + sqrt(a + x**S(2)))**(n + S(4))/(S(32)*n + S(128)) + (x + sqrt(a + x**S(2)))**(n + S(6))/(S(64)*n + S(384)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + x**S(2))**(S(3)/2)*(x + sqrt(a + x**S(2)))**n, x), x, -a**S(4)*(x + sqrt(a + x**S(2)))**(n + S(-4))/(-S(16)*n + S(64)) - a**S(3)*(x + sqrt(a + x**S(2)))**(n + S(-2))/(-S(4)*n + S(8)) + S(3)*a**S(2)*(x + sqrt(a + x**S(2)))**n/(S(8)*n) + a*(x + sqrt(a + x**S(2)))**(n + S(2))/(S(4)*n + S(8)) + (x + sqrt(a + x**S(2)))**(n + S(4))/(S(16)*n + S(64)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + x**S(2))*(x + sqrt(a + x**S(2)))**n, x), x, -a**S(2)*(x + sqrt(a + x**S(2)))**(n + S(-2))/(-S(4)*n + S(8)) + a*(x + sqrt(a + x**S(2)))**n/(S(2)*n) + (x + sqrt(a + x**S(2)))**(n + S(2))/(S(4)*n + S(8)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x + sqrt(a + x**S(2)))**n/sqrt(a + x**S(2)), x), x, (x + sqrt(a + x**S(2)))**n/n, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x + sqrt(a + x**S(2)))**n/(a + x**S(2))**(S(3)/2), x), x, S(4)*(x + sqrt(a + x**S(2)))**(n + S(2))*hyper((S(2), n/S(2) + S(1)), (n/S(2) + S(2),), -(x + sqrt(a + x**S(2)))**S(2)/a)/(a**S(2)*(n + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x + sqrt(a + x**S(2)))**n/(a + x**S(2))**(S(5)/2), x), x, S(16)*(x + sqrt(a + x**S(2)))**(n + S(4))*hyper((S(4), n/S(2) + S(2)), (n/S(2) + S(3),), -(x + sqrt(a + x**S(2)))**S(2)/a)/(a**S(4)*(n + S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + x**S(2))**(S(5)/2)*(x - sqrt(a + x**S(2)))**n, x), x, a**S(6)*(x - sqrt(a + x**S(2)))**(n + S(-6))/(-S(64)*n + S(384)) + S(3)*a**S(5)*(x - sqrt(a + x**S(2)))**(n + S(-4))/(-S(32)*n + S(128)) + S(15)*a**S(4)*(x - sqrt(a + x**S(2)))**(n + S(-2))/(-S(64)*n + S(128)) - S(5)*a**S(3)*(x - sqrt(a + x**S(2)))**n/(S(16)*n) - S(15)*a**S(2)*(x - sqrt(a + x**S(2)))**(n + S(2))/(S(64)*n + S(128)) - S(3)*a*(x - sqrt(a + x**S(2)))**(n + S(4))/(S(32)*n + S(128)) - (x - sqrt(a + x**S(2)))**(n + S(6))/(S(64)*n + S(384)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + x**S(2))**(S(3)/2)*(x - sqrt(a + x**S(2)))**n, x), x, a**S(4)*(x - sqrt(a + x**S(2)))**(n + S(-4))/(-S(16)*n + S(64)) + a**S(3)*(x - sqrt(a + x**S(2)))**(n + S(-2))/(-S(4)*n + S(8)) - S(3)*a**S(2)*(x - sqrt(a + x**S(2)))**n/(S(8)*n) - a*(x - sqrt(a + x**S(2)))**(n + S(2))/(S(4)*n + S(8)) - (x - sqrt(a + x**S(2)))**(n + S(4))/(S(16)*n + S(64)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + x**S(2))*(x - sqrt(a + x**S(2)))**n, x), x, a**S(2)*(x - sqrt(a + x**S(2)))**(n + S(-2))/(-S(4)*n + S(8)) - a*(x - sqrt(a + x**S(2)))**n/(S(2)*n) - (x - sqrt(a + x**S(2)))**(n + S(2))/(S(4)*n + S(8)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x - sqrt(a + x**S(2)))**n/sqrt(a + x**S(2)), x), x, -(x - sqrt(a + x**S(2)))**n/n, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x - sqrt(a + x**S(2)))**n/(a + x**S(2))**(S(3)/2), x), x, -S(4)*(x - sqrt(a + x**S(2)))**(n + S(2))*hyper((S(2), n/S(2) + S(1)), (n/S(2) + S(2),), -(x - sqrt(a + x**S(2)))**S(2)/a)/(a**S(2)*(n + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x - sqrt(a + x**S(2)))**n/(a + x**S(2))**(S(5)/2), x), x, -S(16)*(x - sqrt(a + x**S(2)))**(n + S(4))*hyper((S(4), n/S(2) + S(2)), (n/S(2) + S(3),), -(x - sqrt(a + x**S(2)))**S(2)/a)/(a**S(4)*(n + S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2))**S(2)*(d + e*x + f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)))**n, x), x, (d + e*x + f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)))**(n + S(5))/(S(32)*e*f**S(4)*(n + S(5))) - (-S(5)*a*f**S(2) + S(5)*d**S(2))*(d + e*x + f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)))**(n + S(3))/(S(32)*e*f**S(4)*(n + S(3))) + S(5)*(-a*f**S(2) + d**S(2))**S(2)*(d + e*x + f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)))**(n + S(1))/(S(16)*e*f**S(4)*(n + S(1))) + (-a*f**S(2) + d**S(2))**S(5)*(d + e*x + f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)))**(n + S(-5))/(S(32)*e*f**S(4)*(-n + S(5))) - S(5)*(-a*f**S(2) + d**S(2))**S(4)*(d + e*x + f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)))**(n + S(-3))/(S(32)*e*f**S(4)*(-n + S(3))) + S(5)*(-a*f**S(2) + d**S(2))**S(3)*(d + e*x + f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)))**(n + S(-1))/(S(16)*e*f**S(4)*(-n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2))*(d + e*x + f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)))**n, x), x, (d + e*x + f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)))**(n + S(3))/(S(8)*e*f**S(2)*(n + S(3))) - (-S(3)*a*f**S(2) + S(3)*d**S(2))*(d + e*x + f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)))**(n + S(1))/(S(8)*e*f**S(2)*(n + S(1))) + (-a*f**S(2) + d**S(2))**S(3)*(d + e*x + f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)))**(n + S(-3))/(S(8)*e*f**S(2)*(-n + S(3))) - S(3)*(-a*f**S(2) + d**S(2))**S(2)*(d + e*x + f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)))**(n + S(-1))/(S(8)*e*f**S(2)*(-n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)))**n, x), x, (d + e*x + f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)))**(n + S(1))/(S(2)*e*(n + S(1))) + (-a*f**S(2) + d**S(2))*(d + e*x + f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)))**(n + S(-1))/(S(2)*e*(-n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)))**n/(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)), x), x, -S(2)*f**S(2)*(d + e*x + f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)))**(n + S(1))*hyper((S(1), n/S(2) + S(1)/2), (n/S(2) + S(3)/2,), (d + e*x + f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)))**S(2)/(-a*f**S(2) + d**S(2)))/(e*(n + S(1))*(-a*f**S(2) + d**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)))**n/(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2))**S(2), x), x, -S(8)*f**S(4)*(d + e*x + f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)))**(n + S(3))*hyper((S(3), n/S(2) + S(3)/2), (n/S(2) + S(5)/2,), (d + e*x + f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)))**S(2)/(-a*f**S(2) + d**S(2)))/(e*(n + S(3))*(-a*f**S(2) + d**S(2))**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*sqrt((a*f**S(2) + e*x*(S(2)*d + e*x))/f**S(2)))**n, x), x, (d + e*x + f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)))**(n + S(1))/(S(2)*e*(n + S(1))) + (-a*f**S(2) + d**S(2))*(d + e*x + f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)))**(n + S(-1))/(S(2)*e*(-n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*sqrt((a*f**S(2) + e*x*(S(2)*d + e*x))/f**S(2)))**n/(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)), x), x, -S(2)*f**S(2)*(d + e*x + f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)))**(n + S(1))*hyper((S(1), n/S(2) + S(1)/2), (n/S(2) + S(3)/2,), (d + e*x + f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)))**S(2)/(-a*f**S(2) + d**S(2)))/(e*(n + S(1))*(-a*f**S(2) + d**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2))**(S(3)/2)*(d + e*x + f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)))**n, x), x, (d + e*x + f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)))**(n + S(4))/(S(16)*e*f**S(3)*(n + S(4))) - (-a*f**S(2) + d**S(2))*(d + e*x + f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)))**(n + S(2))/(S(4)*e*f**S(3)*(n + S(2))) - (-a*f**S(2) + d**S(2))**S(4)*(d + e*x + f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)))**(n + S(-4))/(S(16)*e*f**S(3)*(-n + S(4))) + (-a*f**S(2) + d**S(2))**S(3)*(d + e*x + f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)))**(n + S(-2))/(S(4)*e*f**S(3)*(-n + S(2))) + S(3)*(-a*f**S(2) + d**S(2))**S(2)*(d + e*x + f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)))**n/(S(8)*e*f**S(3)*n), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2))*(d + e*x + f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)))**n, x), x, (d + e*x + f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)))**(n + S(2))/(S(4)*e*f*(n + S(2))) - (-a*f**S(2) + d**S(2))**S(2)*(d + e*x + f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)))**(n + S(-2))/(S(4)*e*f*(-n + S(2))) - (-a*f**S(2) + d**S(2))*(d + e*x + f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)))**n/(S(2)*e*f*n), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)))**n/sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)), x), x, f*(d + e*x + f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)))**n/(e*n), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)))**n/(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2))**(S(3)/2), x), x, S(4)*f**S(3)*(d + e*x + f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)))**(n + S(2))*hyper((S(2), n/S(2) + S(1)), (n/S(2) + S(2),), (d + e*x + f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)))**S(2)/(-a*f**S(2) + d**S(2)))/(e*(n + S(2))*(-a*f**S(2) + d**S(2))**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*sqrt((a*f**S(2) + e*x*(S(2)*d + e*x))/f**S(2)))**n/sqrt((a*f**S(2) + e*x*(S(2)*d + e*x))/f**S(2)), x), x, f*(d + e*x + f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)))**n/(e*n), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)))**n*sqrt(a*g + S(2)*d*e*g*x/f**S(2) + e**S(2)*g*x**S(2)/f**S(2)), x), x, (d + e*x + f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)))**(n + S(2))*sqrt(a*g + S(2)*d*e*g*x/f**S(2) + e**S(2)*g*x**S(2)/f**S(2))/(S(4)*e*f*(n + S(2))*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2))) - (-a*f**S(2) + d**S(2))**S(2)*(d + e*x + f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)))**(n + S(-2))*sqrt(a*g + S(2)*d*e*g*x/f**S(2) + e**S(2)*g*x**S(2)/f**S(2))/(S(4)*e*f*(-n + S(2))*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2))) - (-a*f**S(2) + d**S(2))*(d + e*x + f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)))**n*sqrt(a*g + S(2)*d*e*g*x/f**S(2) + e**S(2)*g*x**S(2)/f**S(2))/(S(2)*e*f*n*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)))**n/sqrt(a*g + S(2)*d*e*g*x/f**S(2) + e**S(2)*g*x**S(2)/f**S(2)), x), x, f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2))*(d + e*x + f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)))**n/(e*n*sqrt(a*g + S(2)*d*e*g*x/f**S(2) + e**S(2)*g*x**S(2)/f**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)))**n/(a*g + S(2)*d*e*g*x/f**S(2) + e**S(2)*g*x**S(2)/f**S(2))**(S(3)/2), x), x, S(4)*f**S(3)*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2))*(d + e*x + f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)))**(n + S(2))*hyper((S(2), n/S(2) + S(1)), (n/S(2) + S(2),), (d + e*x + f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)))**S(2)/(-a*f**S(2) + d**S(2)))/(e*g*(n + S(2))*(-a*f**S(2) + d**S(2))**S(2)*sqrt(a*g + S(2)*d*e*g*x/f**S(2) + e**S(2)*g*x**S(2)/f**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*sqrt((a*f**S(2) + e*x*(S(2)*d + e*x))/f**S(2)))**n/sqrt((a*f**S(2)*g + e*g*x*(S(2)*d + e*x))/f**S(2)), x), x, f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2))*(d + e*x + f*sqrt(a + S(2)*d*e*x/f**S(2) + e**S(2)*x**S(2)/f**S(2)))**n/(e*n*sqrt(a*g + S(2)*d*e*g*x/f**S(2) + e**S(2)*g*x**S(2)/f**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(a + c*x**S(4))*(d + e*x)), x), x, -e*atanh((a*e**S(2) + c*d**S(2)*x**S(2))/(sqrt(a + c*x**S(4))*sqrt(a*e**S(4) + c*d**S(4))))/(S(2)*sqrt(a*e**S(4) + c*d**S(4))) + atan(x*sqrt(-(a*e**S(4) + c*d**S(4))/(d**S(2)*e**S(2)))/sqrt(a + c*x**S(4)))/(S(2)*d*sqrt(-(a*e**S(4) + c*d**S(4))/(d**S(2)*e**S(2)))) + c**(S(1)/4)*d*sqrt((a + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2)/(S(2)*a**(S(1)/4)*sqrt(a + c*x**S(4))*(sqrt(a)*e**S(2) + sqrt(c)*d**S(2))) - sqrt((a + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(-sqrt(a)*e**S(2) + sqrt(c)*d**S(2))*elliptic_pi((sqrt(a)*e**S(2) + sqrt(c)*d**S(2))**S(2)/(S(4)*sqrt(a)*sqrt(c)*d**S(2)*e**S(2)), S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2)/(S(4)*a**(S(1)/4)*c**(S(1)/4)*d*sqrt(a + c*x**S(4))*(sqrt(a)*e**S(2) + sqrt(c)*d**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(a + c*x**S(4))*(d + e*x)**S(2)), x), x, -a**(S(1)/4)*c**(S(1)/4)*e**S(2)*sqrt((a + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2)/(sqrt(a + c*x**S(4))*(a*e**S(4) + c*d**S(4))) - a**(S(1)/4)*c**(S(1)/4)*sqrt((a + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(-e**S(2) + sqrt(c)*d**S(2)/sqrt(a))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2)/(sqrt(a + c*x**S(4))*(S(2)*a*e**S(4) + S(2)*c*d**S(4))) + sqrt(c)*e**S(2)*x*sqrt(a + c*x**S(4))/((sqrt(a) + sqrt(c)*x**S(2))*(a*e**S(4) + c*d**S(4))) - c*d**S(3)*e*atanh((a*e**S(2) + c*d**S(2)*x**S(2))/(sqrt(a + c*x**S(4))*sqrt(a*e**S(4) + c*d**S(4))))/(a*e**S(4) + c*d**S(4))**(S(3)/2) - c*atan(x*sqrt(-(a*e**S(4) + c*d**S(4))/(d**S(2)*e**S(2)))/sqrt(a + c*x**S(4)))/(e**S(2)*(-(a*e**S(4) + c*d**S(4))/(d**S(2)*e**S(2)))**(S(3)/2)) - e**S(3)*sqrt(a + c*x**S(4))/((d + e*x)*(a*e**S(4) + c*d**S(4))) + c**(S(5)/4)*d**S(4)*sqrt((a + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2)/(a**(S(1)/4)*sqrt(a + c*x**S(4))*(sqrt(a)*e**S(2) + sqrt(c)*d**S(2))*(a*e**S(4) + c*d**S(4))) - c**(S(3)/4)*d**S(2)*sqrt((a + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(-sqrt(a)*e**S(2) + sqrt(c)*d**S(2))*elliptic_pi((sqrt(a)*e**S(2) + sqrt(c)*d**S(2))**S(2)/(S(4)*sqrt(a)*sqrt(c)*d**S(2)*e**S(2)), S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2)/(S(2)*a**(S(1)/4)*sqrt(a + c*x**S(4))*(sqrt(a)*e**S(2) + sqrt(c)*d**S(2))*(a*e**S(4) + c*d**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d + e*x)*sqrt(a + b*x**S(2) + c*x**S(4))), x), x, -e*atanh((S(2)*a*e**S(2) + b*d**S(2) + x**S(2)*(b*e**S(2) + S(2)*c*d**S(2)))/(S(2)*sqrt(a + b*x**S(2) + c*x**S(4))*sqrt(a*e**S(4) + b*d**S(2)*e**S(2) + c*d**S(4))))/(S(2)*sqrt(a*e**S(4) + b*d**S(2)*e**S(2) + c*d**S(4))) + atan(x*sqrt(-b - (a*e**S(4) + c*d**S(4))/(d**S(2)*e**S(2)))/sqrt(a + b*x**S(2) + c*x**S(4)))/(S(2)*d*sqrt(-b - (a*e**S(4) + c*d**S(4))/(d**S(2)*e**S(2)))) + c**(S(1)/4)*d*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(2)*a**(S(1)/4)*(sqrt(a)*e**S(2) + sqrt(c)*d**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))) - sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(-sqrt(a)*e**S(2) + sqrt(c)*d**S(2))*elliptic_pi((sqrt(a)*e**S(2) + sqrt(c)*d**S(2))**S(2)/(S(4)*sqrt(a)*sqrt(c)*d**S(2)*e**S(2)), S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(4)*a**(S(1)/4)*c**(S(1)/4)*d*(sqrt(a)*e**S(2) + sqrt(c)*d**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d + e*x)**S(2)*sqrt(a + b*x**S(2) + c*x**S(4))), x), x, -a**(S(1)/4)*c**(S(1)/4)*e**S(2)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(sqrt(a + b*x**S(2) + c*x**S(4))*(a*e**S(4) + b*d**S(2)*e**S(2) + c*d**S(4))) - a**(S(1)/4)*c**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(-e**S(2) + sqrt(c)*d**S(2)/sqrt(a))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(sqrt(a + b*x**S(2) + c*x**S(4))*(S(2)*a*e**S(4) + S(2)*b*d**S(2)*e**S(2) + S(2)*c*d**S(4))) + sqrt(c)*e**S(2)*x*sqrt(a + b*x**S(2) + c*x**S(4))/((sqrt(a) + sqrt(c)*x**S(2))*(a*e**S(4) + b*d**S(2)*e**S(2) + c*d**S(4))) - d*e*(b*e**S(2) + S(2)*c*d**S(2))*atanh((S(2)*a*e**S(2) + b*d**S(2) + x**S(2)*(b*e**S(2) + S(2)*c*d**S(2)))/(S(2)*sqrt(a + b*x**S(2) + c*x**S(4))*sqrt(a*e**S(4) + b*d**S(2)*e**S(2) + c*d**S(4))))/(S(2)*(a*e**S(4) + b*d**S(2)*e**S(2) + c*d**S(4))**(S(3)/2)) - e**S(3)*sqrt(a + b*x**S(2) + c*x**S(4))/((d + e*x)*(a*e**S(4) + b*d**S(2)*e**S(2) + c*d**S(4))) - (b*e**S(2) + S(2)*c*d**S(2))*atan(x*sqrt(-b - (a*e**S(4) + c*d**S(4))/(d**S(2)*e**S(2)))/sqrt(a + b*x**S(2) + c*x**S(4)))/(S(2)*d**S(2)*e**S(2)*(-b - (a*e**S(4) + c*d**S(4))/(d**S(2)*e**S(2)))**(S(3)/2)) + c**(S(1)/4)*d**S(2)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(b*e**S(2) + S(2)*c*d**S(2))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(2)*a**(S(1)/4)*(sqrt(a)*e**S(2) + sqrt(c)*d**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))*(a*e**S(4) + b*d**S(2)*e**S(2) + c*d**S(4))) - sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(-sqrt(a)*e**S(2) + sqrt(c)*d**S(2))*(b*e**S(2) + S(2)*c*d**S(2))*elliptic_pi((sqrt(a)*e**S(2) + sqrt(c)*d**S(2))**S(2)/(S(4)*sqrt(a)*sqrt(c)*d**S(2)*e**S(2)), S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(4)*a**(S(1)/4)*c**(S(1)/4)*(sqrt(a)*e**S(2) + sqrt(c)*d**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))*(a*e**S(4) + b*d**S(2)*e**S(2) + c*d**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + b*x**S(2) + c*x**S(4))/(a*d - c*d*x**S(4)), x), x, -sqrt(-S(2)*sqrt(a)*sqrt(c) + b)*atanh(x*sqrt(-S(2)*sqrt(a)*sqrt(c) + b)/sqrt(a + b*x**S(2) + c*x**S(4)))/(S(4)*sqrt(a)*sqrt(c)*d) + sqrt(S(2)*sqrt(a)*sqrt(c) + b)*atanh(x*sqrt(S(2)*sqrt(a)*sqrt(c) + b)/sqrt(a + b*x**S(2) + c*x**S(4)))/(S(4)*sqrt(a)*sqrt(c)*d), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + b*x**S(2) - c*x**S(4))/(a*d + c*d*x**S(4)), x), x, sqrt(S(2))*sqrt(-b + sqrt(S(4)*a*c + b**S(2)))*atanh(sqrt(S(2))*x*sqrt(-b + sqrt(S(4)*a*c + b**S(2)))*(b - S(2)*c*x**S(2) + sqrt(S(4)*a*c + b**S(2)))/(S(4)*sqrt(a)*sqrt(c)*sqrt(a + b*x**S(2) - c*x**S(4))))/(S(4)*sqrt(a)*sqrt(c)*d) - sqrt(S(2))*sqrt(b + sqrt(S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*x*sqrt(b + sqrt(S(4)*a*c + b**S(2)))*(b - S(2)*c*x**S(2) - sqrt(S(4)*a*c + b**S(2)))/(S(4)*sqrt(a)*sqrt(c)*sqrt(a + b*x**S(2) - c*x**S(4))))/(S(4)*sqrt(a)*sqrt(c)*d), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))*sqrt(c + d*x**S(2) + e*x), x), x, b*x**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))*(c + d*x**S(2) + e*x)**(S(3)/2)/(S(5)*d*(a + b*x**S(2))) - sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))*(c + d*x**S(2) + e*x)**(S(3)/2)*(-S(80)*a*d**S(2) + S(32)*b*c*d + S(42)*b*d*e*x - S(35)*b*e**S(2))/(S(240)*d**S(3)*(a + b*x**S(2))) + e*(S(2)*d*x + e)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))*sqrt(c + d*x**S(2) + e*x)*(-S(16)*a*d**S(2) + S(12)*b*c*d - S(7)*b*e**S(2))/(S(128)*d**S(4)*(a + b*x**S(2))) + e*(S(4)*c*d - e**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))*(-S(16)*a*d**S(2) + S(12)*b*c*d - S(7)*b*e**S(2))*atanh((S(2)*d*x + e)/(S(2)*sqrt(d)*sqrt(c + d*x**S(2) + e*x)))/(S(256)*d**(S(9)/2)*(a + b*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))*sqrt(c + d*x**S(2) + e*x), x), x, -b*(-S(6)*d*x + S(5)*e)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))*(c + d*x**S(2) + e*x)**(S(3)/2)/(S(24)*d**S(2)*(a + b*x**S(2))) - (S(2)*d*x + e)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))*sqrt(c + d*x**S(2) + e*x)*(-S(16)*a*d**S(2) + S(4)*b*c*d - S(5)*b*e**S(2))/(S(64)*d**S(3)*(a + b*x**S(2))) - (S(4)*c*d - e**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))*(-S(16)*a*d**S(2) + S(4)*b*c*d - S(5)*b*e**S(2))*atanh((S(2)*d*x + e)/(S(2)*sqrt(d)*sqrt(c + d*x**S(2) + e*x)))/(S(128)*d**(S(7)/2)*(a + b*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))*sqrt(c + d*x**S(2) + e*x)/x, x), x, -a*sqrt(c)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))*atanh((S(2)*c + e*x)/(S(2)*sqrt(c)*sqrt(c + d*x**S(2) + e*x)))/(a + b*x**S(2)) + b*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))*(c + d*x**S(2) + e*x)**(S(3)/2)/(S(3)*d*(a + b*x**S(2))) + sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))*sqrt(c + d*x**S(2) + e*x)*(S(8)*a*d**S(2) - S(2)*b*d*e*x - b*e**S(2))/(S(8)*d**S(2)*(a + b*x**S(2))) + e*(S(8)*a*d**S(2) - b*(S(4)*c*d - e**S(2)))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))*atanh((S(2)*d*x + e)/(S(2)*sqrt(d)*sqrt(c + d*x**S(2) + e*x)))/(S(16)*d**(S(5)/2)*(a + b*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))*sqrt(c + d*x**S(2) + e*x)/x**S(2), x), x, -a*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))*(c + d*x**S(2) + e*x)**(S(3)/2)/(c*x*(a + b*x**S(2))) - a*e*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))*atanh((S(2)*c + e*x)/(S(2)*sqrt(c)*sqrt(c + d*x**S(2) + e*x)))/(S(2)*sqrt(c)*(a + b*x**S(2))) + sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))*(S(8)*a*d**S(2) + S(4)*b*c*d - b*e**S(2))*atanh((S(2)*d*x + e)/(S(2)*sqrt(d)*sqrt(c + d*x**S(2) + e*x)))/(S(8)*d**(S(3)/2)*(a + b*x**S(2))) + (S(2)*d*x*(S(2)*a*d + b*c) + e*(S(4)*a*d + b*c))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))*sqrt(c + d*x**S(2) + e*x)/(S(4)*c*d*(a + b*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))*sqrt(c + d*x**S(2) + e*x)/x**S(3), x), x, -a*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))*(c + d*x**S(2) + e*x)**(S(3)/2)/(S(2)*c*x**S(2)*(a + b*x**S(2))) + b*e*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))*atanh((S(2)*d*x + e)/(S(2)*sqrt(d)*sqrt(c + d*x**S(2) + e*x)))/(S(2)*sqrt(d)*(a + b*x**S(2))) + (a*e + x*(S(2)*a*d + S(4)*b*c))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))*sqrt(c + d*x**S(2) + e*x)/(S(4)*c*x*(a + b*x**S(2))) - sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))*(S(4)*a*c*d - a*e**S(2) + S(8)*b*c**S(2))*atanh((S(2)*c + e*x)/(S(2)*sqrt(c)*sqrt(c + d*x**S(2) + e*x)))/(S(8)*c**(S(3)/2)*(a + b*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))*sqrt(c + d*x**S(2) + e*x)/x**S(4), x), x, -a*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))*(c + d*x**S(2) + e*x)**(S(3)/2)/(S(3)*c*x**S(3)*(a + b*x**S(2))) + b*sqrt(d)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))*atanh((S(2)*d*x + e)/(S(2)*sqrt(d)*sqrt(c + d*x**S(2) + e*x)))/(a + b*x**S(2)) + (S(2)*a*c*e - x*(-a*e**S(2) + S(8)*b*c**S(2)))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))*sqrt(c + d*x**S(2) + e*x)/(S(8)*c**S(2)*x**S(2)*(a + b*x**S(2))) - e*(-a*(S(4)*c*d - e**S(2)) + S(8)*b*c**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))*atanh((S(2)*c + e*x)/(S(2)*sqrt(c)*sqrt(c + d*x**S(2) + e*x)))/(S(16)*c**(S(5)/2)*(a + b*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((x + S(3))*sqrt(x**S(3) + S(1))), x), x, sqrt(S(26))*sqrt((x**S(2) - x + S(1))/(x + S(1) + sqrt(S(3)))**S(2))*(x + S(1))*atan(sqrt(S(2))*S(3)**(S(3)/4)*sqrt(S(1) - (x - sqrt(S(3)) + S(1))**S(2)/(x + S(1) + sqrt(S(3)))**S(2))*sqrt(-S(13)*sqrt(S(3)) + S(26))/(S(6)*sqrt(-S(4)*sqrt(S(3)) + S(7) + (x - sqrt(S(3)) + S(1))**S(2)/(x + S(1) + sqrt(S(3)))**S(2))))/(S(26)*sqrt((x + S(1))/(x + S(1) + sqrt(S(3)))**S(2))*sqrt(x**S(3) + S(1))) + S(2)*S(3)**(S(3)/4)*sqrt((x**S(2) - x + S(1))/(x + S(1) + sqrt(S(3)))**S(2))*sqrt(S(15)*sqrt(S(3)) + S(26))*(x + S(1))*elliptic_f(asin((x - sqrt(S(3)) + S(1))/(x + S(1) + sqrt(S(3)))), S(-7) - S(4)*sqrt(S(3)))/(S(3)*sqrt((x + S(1))/(x + S(1) + sqrt(S(3)))**S(2))*sqrt(x**S(3) + S(1))) - S(4)*S(3)**(S(1)/4)*sqrt((x**S(2) - x + S(1))/(x + S(1) + sqrt(S(3)))**S(2))*(x + S(1))*elliptic_pi(-S(56)*sqrt(S(3)) + S(97), asin((x - sqrt(S(3)) + S(1))/(x + S(1) + sqrt(S(3)))), S(-7) - S(4)*sqrt(S(3)))/(sqrt((x + S(1))/(x + S(1) + sqrt(S(3)))**S(2))*sqrt(-sqrt(S(3)) + S(2))*sqrt(x**S(3) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((x + S(3))*sqrt(-x**S(3) + S(1))), x), x, -sqrt(S(7))*sqrt((x**S(2) + x + S(1))/(-x + S(1) + sqrt(S(3)))**S(2))*(-x + S(1))*atanh(S(3)**(S(3)/4)*sqrt(S(1) - (-x - sqrt(S(3)) + S(1))**S(2)/(-x + S(1) + sqrt(S(3)))**S(2))*sqrt(-S(7)*sqrt(S(3)) + S(14))/(S(6)*sqrt(-S(4)*sqrt(S(3)) + S(7) + (-x - sqrt(S(3)) + S(1))**S(2)/(-x + S(1) + sqrt(S(3)))**S(2))))/(S(14)*sqrt((-x + S(1))/(-x + S(1) + sqrt(S(3)))**S(2))*sqrt(-x**S(3) + S(1))) - S(2)*S(3)**(S(3)/4)*sqrt((x**S(2) + x + S(1))/(-x + S(1) + sqrt(S(3)))**S(2))*sqrt(sqrt(S(3)) + S(2))*(-x + S(1))*elliptic_f(asin((-x - sqrt(S(3)) + S(1))/(-x + S(1) + sqrt(S(3)))), S(-7) - S(4)*sqrt(S(3)))/(S(3)*sqrt((-x + S(1))/(-x + S(1) + sqrt(S(3)))**S(2))*(sqrt(S(3)) + S(4))*sqrt(-x**S(3) + S(1))) - S(4)*S(3)**(S(1)/4)*sqrt((x**S(2) + x + S(1))/(-x + S(1) + sqrt(S(3)))**S(2))*sqrt(sqrt(S(3)) + S(2))*(-x + S(1))*elliptic_pi(S(304)*sqrt(S(3))/S(169) + S(553)/169, asin((-x - sqrt(S(3)) + S(1))/(-x + S(1) + sqrt(S(3)))), S(-7) - S(4)*sqrt(S(3)))/(S(13)*sqrt((-x + S(1))/(-x + S(1) + sqrt(S(3)))**S(2))*sqrt(-x**S(3) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((x + S(3))*sqrt(x**S(3) + S(-1))), x), x, -sqrt(S(7))*sqrt((x**S(2) + x + S(1))/(-x - sqrt(S(3)) + S(1))**S(2))*(-x + S(1))*atan(S(3)**(S(3)/4)*sqrt(S(7)*sqrt(S(3)) + S(14))*sqrt(-(-x + S(1) + sqrt(S(3)))**S(2)/(-x - sqrt(S(3)) + S(1))**S(2) + S(1))/(S(6)*sqrt((-x + S(1) + sqrt(S(3)))**S(2)/(-x - sqrt(S(3)) + S(1))**S(2) + S(4)*sqrt(S(3)) + S(7))))/(S(14)*sqrt(-(-x + S(1))/(-x - sqrt(S(3)) + S(1))**S(2))*sqrt(x**S(3) + S(-1))) - S(2)*S(3)**(S(3)/4)*sqrt((x**S(2) + x + S(1))/(-x - sqrt(S(3)) + S(1))**S(2))*sqrt(-S(3)*sqrt(S(3)) + S(14))*(-x + S(1))*elliptic_f(asin((-x + S(1) + sqrt(S(3)))/(-x - sqrt(S(3)) + S(1))), S(-7) + S(4)*sqrt(S(3)))/(S(39)*sqrt(-(-x + S(1))/(-x - sqrt(S(3)) + S(1))**S(2))*sqrt(x**S(3) + S(-1))) + S(4)*S(3)**(S(1)/4)*sqrt((x**S(2) + x + S(1))/(-x - sqrt(S(3)) + S(1))**S(2))*sqrt(-sqrt(S(3)) + S(2))*(-x + S(1))*elliptic_pi(-S(304)*sqrt(S(3))/S(169) + S(553)/169, asin((-x + S(1) + sqrt(S(3)))/(-x - sqrt(S(3)) + S(1))), S(-7) + S(4)*sqrt(S(3)))/(S(13)*sqrt(-(-x + S(1))/(-x - sqrt(S(3)) + S(1))**S(2))*sqrt(x**S(3) + S(-1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((x + S(3))*sqrt(-x**S(3) + S(-1))), x), x, sqrt(S(26))*sqrt((x**S(2) - x + S(1))/(x - sqrt(S(3)) + S(1))**S(2))*(x + S(1))*atanh(sqrt(S(2))*S(3)**(S(3)/4)*sqrt(S(13)*sqrt(S(3)) + S(26))*sqrt(-(x + S(1) + sqrt(S(3)))**S(2)/(x - sqrt(S(3)) + S(1))**S(2) + S(1))/(S(6)*sqrt((x + S(1) + sqrt(S(3)))**S(2)/(x - sqrt(S(3)) + S(1))**S(2) + S(4)*sqrt(S(3)) + S(7))))/(S(26)*sqrt(-(x + S(1))/(x - sqrt(S(3)) + S(1))**S(2))*sqrt(-x**S(3) + S(-1))) + S(2)*S(3)**(S(3)/4)*sqrt((x**S(2) - x + S(1))/(x - sqrt(S(3)) + S(1))**S(2))*sqrt(-S(15)*sqrt(S(3)) + S(26))*(x + S(1))*elliptic_f(asin((x + S(1) + sqrt(S(3)))/(x - sqrt(S(3)) + S(1))), S(-7) + S(4)*sqrt(S(3)))/(S(3)*sqrt(-(x + S(1))/(x - sqrt(S(3)) + S(1))**S(2))*sqrt(-x**S(3) + S(-1))) + S(4)*S(3)**(S(1)/4)*sqrt((x**S(2) - x + S(1))/(x - sqrt(S(3)) + S(1))**S(2))*(x + S(1))*elliptic_pi(S(56)*sqrt(S(3)) + S(97), asin((x + S(1) + sqrt(S(3)))/(x - sqrt(S(3)) + S(1))), S(-7) + S(4)*sqrt(S(3)))/(sqrt(-(x + S(1))/(x - sqrt(S(3)) + S(1))**S(2))*sqrt(sqrt(S(3)) + S(2))*sqrt(-x**S(3) + S(-1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/((x + S(3))*sqrt(x**S(3) + S(1))), x), x, -S(2)*S(3)**(S(3)/4)*sqrt((x**S(2) - x + S(1))/(x + S(1) + sqrt(S(3)))**S(2))*sqrt(S(112)*sqrt(S(3)) + S(194))*(x + S(1))*elliptic_f(asin((x - sqrt(S(3)) + S(1))/(x + S(1) + sqrt(S(3)))), S(-7) - S(4)*sqrt(S(3)))/(S(3)*sqrt((x + S(1))/(x + S(1) + sqrt(S(3)))**S(2))*sqrt(x**S(3) + S(1))) + S(12)*S(3)**(S(1)/4)*sqrt((x**S(2) - x + S(1))/(x + S(1) + sqrt(S(3)))**S(2))*(x + S(1))*elliptic_pi(-S(56)*sqrt(S(3)) + S(97), asin((x - sqrt(S(3)) + S(1))/(x + S(1) + sqrt(S(3)))), S(-7) - S(4)*sqrt(S(3)))/(sqrt((x + S(1))/(x + S(1) + sqrt(S(3)))**S(2))*sqrt(-sqrt(S(3)) + S(2))*sqrt(x**S(3) + S(1))) - sqrt(S(26))*sqrt((x**S(2) - x + S(1))/(x + S(1) + sqrt(S(3)))**S(2))*(S(3)*x + S(3))*atan(sqrt(S(2))*S(3)**(S(3)/4)*sqrt(S(1) - (x - sqrt(S(3)) + S(1))**S(2)/(x + S(1) + sqrt(S(3)))**S(2))*sqrt(-S(13)*sqrt(S(3)) + S(26))/(S(6)*sqrt(-S(4)*sqrt(S(3)) + S(7) + (x - sqrt(S(3)) + S(1))**S(2)/(x + S(1) + sqrt(S(3)))**S(2))))/(S(26)*sqrt((x + S(1))/(x + S(1) + sqrt(S(3)))**S(2))*sqrt(x**S(3) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/((x + S(3))*sqrt(-x**S(3) + S(1))), x), x, sqrt(S(7))*sqrt((x**S(2) + x + S(1))/(-x + S(1) + sqrt(S(3)))**S(2))*(-S(3)*x + S(3))*atanh(S(3)**(S(3)/4)*sqrt(S(1) - (-x - sqrt(S(3)) + S(1))**S(2)/(-x + S(1) + sqrt(S(3)))**S(2))*sqrt(-S(7)*sqrt(S(3)) + S(14))/(S(6)*sqrt(-S(4)*sqrt(S(3)) + S(7) + (-x - sqrt(S(3)) + S(1))**S(2)/(-x + S(1) + sqrt(S(3)))**S(2))))/(S(14)*sqrt((-x + S(1))/(-x + S(1) + sqrt(S(3)))**S(2))*sqrt(-x**S(3) + S(1))) - S(2)*S(3)**(S(3)/4)*sqrt((x**S(2) + x + S(1))/(-x + S(1) + sqrt(S(3)))**S(2))*sqrt(S(40)*sqrt(S(3)) + S(74))*(-x + S(1))*elliptic_f(asin((-x - sqrt(S(3)) + S(1))/(-x + S(1) + sqrt(S(3)))), S(-7) - S(4)*sqrt(S(3)))/(S(39)*sqrt((-x + S(1))/(-x + S(1) + sqrt(S(3)))**S(2))*sqrt(-x**S(3) + S(1))) + S(12)*S(3)**(S(1)/4)*sqrt((x**S(2) + x + S(1))/(-x + S(1) + sqrt(S(3)))**S(2))*sqrt(sqrt(S(3)) + S(2))*(-x + S(1))*elliptic_pi(S(304)*sqrt(S(3))/S(169) + S(553)/169, asin((-x - sqrt(S(3)) + S(1))/(-x + S(1) + sqrt(S(3)))), S(-7) - S(4)*sqrt(S(3)))/(S(13)*sqrt((-x + S(1))/(-x + S(1) + sqrt(S(3)))**S(2))*sqrt(-x**S(3) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/((x + S(3))*sqrt(x**S(3) + S(-1))), x), x, sqrt(S(7))*sqrt((x**S(2) + x + S(1))/(-x - sqrt(S(3)) + S(1))**S(2))*(-S(3)*x + S(3))*atan(S(3)**(S(3)/4)*sqrt(S(7)*sqrt(S(3)) + S(14))*sqrt(-(-x + S(1) + sqrt(S(3)))**S(2)/(-x - sqrt(S(3)) + S(1))**S(2) + S(1))/(S(6)*sqrt((-x + S(1) + sqrt(S(3)))**S(2)/(-x - sqrt(S(3)) + S(1))**S(2) + S(4)*sqrt(S(3)) + S(7))))/(S(14)*sqrt(-(-x + S(1))/(-x - sqrt(S(3)) + S(1))**S(2))*sqrt(x**S(3) + S(-1))) + S(2)*S(3)**(S(3)/4)*sqrt((x**S(2) + x + S(1))/(-x - sqrt(S(3)) + S(1))**S(2))*sqrt(-S(40)*sqrt(S(3)) + S(74))*(-x + S(1))*elliptic_f(asin((-x + S(1) + sqrt(S(3)))/(-x - sqrt(S(3)) + S(1))), S(-7) + S(4)*sqrt(S(3)))/(S(39)*sqrt(-(-x + S(1))/(-x - sqrt(S(3)) + S(1))**S(2))*sqrt(x**S(3) + S(-1))) - S(12)*S(3)**(S(1)/4)*sqrt((x**S(2) + x + S(1))/(-x - sqrt(S(3)) + S(1))**S(2))*sqrt(-sqrt(S(3)) + S(2))*(-x + S(1))*elliptic_pi(-S(304)*sqrt(S(3))/S(169) + S(553)/169, asin((-x + S(1) + sqrt(S(3)))/(-x - sqrt(S(3)) + S(1))), S(-7) + S(4)*sqrt(S(3)))/(S(13)*sqrt(-(-x + S(1))/(-x - sqrt(S(3)) + S(1))**S(2))*sqrt(x**S(3) + S(-1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/((x + S(3))*sqrt(-x**S(3) + S(-1))), x), x, S(2)*S(3)**(S(3)/4)*sqrt((x**S(2) - x + S(1))/(x - sqrt(S(3)) + S(1))**S(2))*sqrt(-S(112)*sqrt(S(3)) + S(194))*(x + S(1))*elliptic_f(asin((x + S(1) + sqrt(S(3)))/(x - sqrt(S(3)) + S(1))), S(-7) + S(4)*sqrt(S(3)))/(S(3)*sqrt(-(x + S(1))/(x - sqrt(S(3)) + S(1))**S(2))*sqrt(-x**S(3) + S(-1))) - S(12)*S(3)**(S(1)/4)*sqrt((x**S(2) - x + S(1))/(x - sqrt(S(3)) + S(1))**S(2))*(x + S(1))*elliptic_pi(S(56)*sqrt(S(3)) + S(97), asin((x + S(1) + sqrt(S(3)))/(x - sqrt(S(3)) + S(1))), S(-7) + S(4)*sqrt(S(3)))/(sqrt(-(x + S(1))/(x - sqrt(S(3)) + S(1))**S(2))*sqrt(sqrt(S(3)) + S(2))*sqrt(-x**S(3) + S(-1))) - sqrt(S(26))*sqrt((x**S(2) - x + S(1))/(x - sqrt(S(3)) + S(1))**S(2))*(S(3)*x + S(3))*atanh(sqrt(S(2))*S(3)**(S(3)/4)*sqrt(S(13)*sqrt(S(3)) + S(26))*sqrt(-(x + S(1) + sqrt(S(3)))**S(2)/(x - sqrt(S(3)) + S(1))**S(2) + S(1))/(S(6)*sqrt((x + S(1) + sqrt(S(3)))**S(2)/(x - sqrt(S(3)) + S(1))**S(2) + S(4)*sqrt(S(3)) + S(7))))/(S(26)*sqrt(-(x + S(1))/(x - sqrt(S(3)) + S(1))**S(2))*sqrt(-x**S(3) + S(-1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-S(3)*x + S(2))/((x + S(3))*sqrt(x**S(3) + S(1))), x), x, S(2)*S(3)**(S(3)/4)*sqrt((x**S(2) - x + S(1))/(x + S(1) + sqrt(S(3)))**S(2))*sqrt(S(1560)*sqrt(S(3)) + S(2702))*(x + S(1))*elliptic_f(asin((x - sqrt(S(3)) + S(1))/(x + S(1) + sqrt(S(3)))), S(-7) - S(4)*sqrt(S(3)))/(S(3)*sqrt((x + S(1))/(x + S(1) + sqrt(S(3)))**S(2))*sqrt(x**S(3) + S(1))) - S(44)*S(3)**(S(1)/4)*sqrt((x**S(2) - x + S(1))/(x + S(1) + sqrt(S(3)))**S(2))*(x + S(1))*elliptic_pi(-S(56)*sqrt(S(3)) + S(97), asin((x - sqrt(S(3)) + S(1))/(x + S(1) + sqrt(S(3)))), S(-7) - S(4)*sqrt(S(3)))/(sqrt((x + S(1))/(x + S(1) + sqrt(S(3)))**S(2))*sqrt(-sqrt(S(3)) + S(2))*sqrt(x**S(3) + S(1))) + sqrt(S(26))*sqrt((x**S(2) - x + S(1))/(x + S(1) + sqrt(S(3)))**S(2))*(S(11)*x + S(11))*atan(sqrt(S(2))*S(3)**(S(3)/4)*sqrt(S(1) - (x - sqrt(S(3)) + S(1))**S(2)/(x + S(1) + sqrt(S(3)))**S(2))*sqrt(-S(13)*sqrt(S(3)) + S(26))/(S(6)*sqrt(-S(4)*sqrt(S(3)) + S(7) + (x - sqrt(S(3)) + S(1))**S(2)/(x + S(1) + sqrt(S(3)))**S(2))))/(S(26)*sqrt((x + S(1))/(x + S(1) + sqrt(S(3)))**S(2))*sqrt(x**S(3) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-S(3)*x + S(2))/((x + S(3))*sqrt(-x**S(3) + S(1))), x), x, -sqrt(S(7))*sqrt((x**S(2) + x + S(1))/(-x + S(1) + sqrt(S(3)))**S(2))*(-S(11)*x + S(11))*atanh(S(3)**(S(3)/4)*sqrt(S(1) - (-x - sqrt(S(3)) + S(1))**S(2)/(-x + S(1) + sqrt(S(3)))**S(2))*sqrt(-S(7)*sqrt(S(3)) + S(14))/(S(6)*sqrt(-S(4)*sqrt(S(3)) + S(7) + (-x - sqrt(S(3)) + S(1))**S(2)/(-x + S(1) + sqrt(S(3)))**S(2))))/(S(14)*sqrt((-x + S(1))/(-x + S(1) + sqrt(S(3)))**S(2))*sqrt(-x**S(3) + S(1))) + S(2)*S(3)**(S(3)/4)*sqrt((x**S(2) + x + S(1))/(-x + S(1) + sqrt(S(3)))**S(2))*sqrt(S(168)*sqrt(S(3)) + S(446))*(-x + S(1))*elliptic_f(asin((-x - sqrt(S(3)) + S(1))/(-x + S(1) + sqrt(S(3)))), S(-7) - S(4)*sqrt(S(3)))/(S(39)*sqrt((-x + S(1))/(-x + S(1) + sqrt(S(3)))**S(2))*sqrt(-x**S(3) + S(1))) - S(44)*S(3)**(S(1)/4)*sqrt((x**S(2) + x + S(1))/(-x + S(1) + sqrt(S(3)))**S(2))*sqrt(sqrt(S(3)) + S(2))*(-x + S(1))*elliptic_pi(S(304)*sqrt(S(3))/S(169) + S(553)/169, asin((-x - sqrt(S(3)) + S(1))/(-x + S(1) + sqrt(S(3)))), S(-7) - S(4)*sqrt(S(3)))/(S(13)*sqrt((-x + S(1))/(-x + S(1) + sqrt(S(3)))**S(2))*sqrt(-x**S(3) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-S(3)*x + S(2))/((x + S(3))*sqrt(x**S(3) + S(-1))), x), x, -sqrt(S(7))*sqrt((x**S(2) + x + S(1))/(-x - sqrt(S(3)) + S(1))**S(2))*(-S(11)*x + S(11))*atan(S(3)**(S(3)/4)*sqrt(S(7)*sqrt(S(3)) + S(14))*sqrt(-(-x + S(1) + sqrt(S(3)))**S(2)/(-x - sqrt(S(3)) + S(1))**S(2) + S(1))/(S(6)*sqrt((-x + S(1) + sqrt(S(3)))**S(2)/(-x - sqrt(S(3)) + S(1))**S(2) + S(4)*sqrt(S(3)) + S(7))))/(S(14)*sqrt(-(-x + S(1))/(-x - sqrt(S(3)) + S(1))**S(2))*sqrt(x**S(3) + S(-1))) - S(2)*S(3)**(S(3)/4)*sqrt((x**S(2) + x + S(1))/(-x - sqrt(S(3)) + S(1))**S(2))*sqrt(-S(168)*sqrt(S(3)) + S(446))*(-x + S(1))*elliptic_f(asin((-x + S(1) + sqrt(S(3)))/(-x - sqrt(S(3)) + S(1))), S(-7) + S(4)*sqrt(S(3)))/(S(39)*sqrt(-(-x + S(1))/(-x - sqrt(S(3)) + S(1))**S(2))*sqrt(x**S(3) + S(-1))) + S(44)*S(3)**(S(1)/4)*sqrt((x**S(2) + x + S(1))/(-x - sqrt(S(3)) + S(1))**S(2))*sqrt(-sqrt(S(3)) + S(2))*(-x + S(1))*elliptic_pi(-S(304)*sqrt(S(3))/S(169) + S(553)/169, asin((-x + S(1) + sqrt(S(3)))/(-x - sqrt(S(3)) + S(1))), S(-7) + S(4)*sqrt(S(3)))/(S(13)*sqrt(-(-x + S(1))/(-x - sqrt(S(3)) + S(1))**S(2))*sqrt(x**S(3) + S(-1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-S(3)*x + S(2))/((x + S(3))*sqrt(-x**S(3) + S(-1))), x), x, -S(2)*S(3)**(S(3)/4)*sqrt((x**S(2) - x + S(1))/(x - sqrt(S(3)) + S(1))**S(2))*sqrt(-S(1560)*sqrt(S(3)) + S(2702))*(x + S(1))*elliptic_f(asin((x + S(1) + sqrt(S(3)))/(x - sqrt(S(3)) + S(1))), S(-7) + S(4)*sqrt(S(3)))/(S(3)*sqrt(-(x + S(1))/(x - sqrt(S(3)) + S(1))**S(2))*sqrt(-x**S(3) + S(-1))) + S(44)*S(3)**(S(1)/4)*sqrt((x**S(2) - x + S(1))/(x - sqrt(S(3)) + S(1))**S(2))*(x + S(1))*elliptic_pi(S(56)*sqrt(S(3)) + S(97), asin((x + S(1) + sqrt(S(3)))/(x - sqrt(S(3)) + S(1))), S(-7) + S(4)*sqrt(S(3)))/(sqrt(-(x + S(1))/(x - sqrt(S(3)) + S(1))**S(2))*sqrt(sqrt(S(3)) + S(2))*sqrt(-x**S(3) + S(-1))) + sqrt(S(26))*sqrt((x**S(2) - x + S(1))/(x - sqrt(S(3)) + S(1))**S(2))*(S(11)*x + S(11))*atanh(sqrt(S(2))*S(3)**(S(3)/4)*sqrt(S(13)*sqrt(S(3)) + S(26))*sqrt(-(x + S(1) + sqrt(S(3)))**S(2)/(x - sqrt(S(3)) + S(1))**S(2) + S(1))/(S(6)*sqrt((x + S(1) + sqrt(S(3)))**S(2)/(x - sqrt(S(3)) + S(1))**S(2) + S(4)*sqrt(S(3)) + S(7))))/(S(26)*sqrt(-(x + S(1))/(x - sqrt(S(3)) + S(1))**S(2))*sqrt(-x**S(3) + S(-1))), expand=True, _diff=True, _numerical=True)
# sympy and mathematica assert rubi_test(rubi_integrate((d**S(3) + e**S(3)*x**S(3))**p/(d + e*x), x), x, (S(1) + (S(2)*d + S(2)*e*x)/(d*(S(-3) + sqrt(S(3))*I)))**(-p)*(S(1) - (S(2)*d + S(2)*e*x)/(d*(S(3) + sqrt(S(3))*I)))**(-p)*(d**S(3) + e**S(3)*x**S(3))**p*AppellF1(p, -p, -p, p + S(1), -(S(2)*d + S(2)*e*x)/(d*(S(-3) + sqrt(S(3))*I)), (S(2)*d + S(2)*e*x)/(d*(S(3) + sqrt(S(3))*I)))/(e*p), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((a + b*x)*sqrt(c + d*x**S(2))*sqrt(e + f*x**S(2))), x), x, a*sqrt(e)*sqrt(f)*sqrt(c + d*x**S(2))*elliptic_f(atan(sqrt(f)*x/sqrt(e)), S(1) - d*e/(c*f))/(c*sqrt(e*(c + d*x**S(2))/(c*(e + f*x**S(2))))*sqrt(e + f*x**S(2))*(a**S(2)*f + b**S(2)*e)) - b*atanh(sqrt(c + d*x**S(2))*sqrt(a**S(2)*f + b**S(2)*e)/(sqrt(e + f*x**S(2))*sqrt(a**S(2)*d + b**S(2)*c)))/(sqrt(a**S(2)*d + b**S(2)*c)*sqrt(a**S(2)*f + b**S(2)*e)) + b**S(2)*e**(S(3)/2)*sqrt(c + d*x**S(2))*elliptic_pi(S(1) + b**S(2)*e/(a**S(2)*f), atan(sqrt(f)*x/sqrt(e)), S(1) - d*e/(c*f))/(a*c*sqrt(f)*sqrt(e*(c + d*x**S(2))/(c*(e + f*x**S(2))))*sqrt(e + f*x**S(2))*(a**S(2)*f + b**S(2)*e)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((e - S(2)*f*x**S(2))/(S(4)*d*f*x**S(2) + e**S(2) + S(4)*e*f*x**S(2) + S(4)*f**S(2)*x**S(4)), x), x, -log(e - S(2)*sqrt(f)*x*sqrt(-d) + S(2)*f*x**S(2))/(S(4)*sqrt(f)*sqrt(-d)) + log(e + S(2)*sqrt(f)*x*sqrt(-d) + S(2)*f*x**S(2))/(S(4)*sqrt(f)*sqrt(-d)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((e - S(2)*f*x**S(2))/(-S(4)*d*f*x**S(2) + e**S(2) + S(4)*e*f*x**S(2) + S(4)*f**S(2)*x**S(4)), x), x, -log(-S(2)*sqrt(d)*sqrt(f)*x + e + S(2)*f*x**S(2))/(S(4)*sqrt(d)*sqrt(f)) + log(S(2)*sqrt(d)*sqrt(f)*x + e + S(2)*f*x**S(2))/(S(4)*sqrt(d)*sqrt(f)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((e - S(4)*f*x**S(3))/(S(4)*d*f*x**S(2) + e**S(2) + S(4)*e*f*x**S(3) + S(4)*f**S(2)*x**S(6)), x), x, atan(S(2)*sqrt(d)*sqrt(f)*x/(e + S(2)*f*x**S(3)))/(S(2)*sqrt(d)*sqrt(f)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((e - S(4)*f*x**S(3))/(-S(4)*d*f*x**S(2) + e**S(2) + S(4)*e*f*x**S(3) + S(4)*f**S(2)*x**S(6)), x), x, atanh(S(2)*sqrt(d)*sqrt(f)*x/(e + S(2)*f*x**S(3)))/(S(2)*sqrt(d)*sqrt(f)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((e - S(2)*f*x**n*(n + S(-1)))/(S(4)*d*f*x**S(2) + e**S(2) + S(4)*e*f*x**n + S(4)*f**S(2)*x**(S(2)*n)), x), x, atan(S(2)*sqrt(d)*sqrt(f)*x/(e + S(2)*f*x**n))/(S(2)*sqrt(d)*sqrt(f)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((e - S(2)*f*x**n*(n + S(-1)))/(-S(4)*d*f*x**S(2) + e**S(2) + S(4)*e*f*x**n + S(4)*f**S(2)*x**(S(2)*n)), x), x, atanh(S(2)*sqrt(d)*sqrt(f)*x/(e + S(2)*f*x**n))/(S(2)*sqrt(d)*sqrt(f)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(S(4)*d*f*x**S(4) + e**S(2) + S(4)*e*f*x**S(2) + S(4)*f**S(2)*x**S(4)), x), x, atan(sqrt(f)*(e + x**S(2)*(S(2)*d + S(2)*f))/(sqrt(d)*e))/(S(4)*sqrt(d)*e*sqrt(f)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(-S(4)*d*f*x**S(4) + e**S(2) + S(4)*e*f*x**S(2) + S(4)*f**S(2)*x**S(4)), x), x, -atanh(sqrt(f)*(e - x**S(2)*(S(2)*d - S(2)*f))/(sqrt(d)*e))/(S(4)*sqrt(d)*e*sqrt(f)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(S(3)*e + S(2)*f*x**S(2))/(S(4)*d*f*x**S(6) + e**S(2) + S(4)*e*f*x**S(2) + S(4)*f**S(2)*x**S(4)), x), x, atan(S(2)*sqrt(d)*sqrt(f)*x**S(3)/(e + S(2)*f*x**S(2)))/(S(2)*sqrt(d)*sqrt(f)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(S(3)*e + S(2)*f*x**S(2))/(-S(4)*d*f*x**S(6) + e**S(2) + S(4)*e*f*x**S(2) + S(4)*f**S(2)*x**S(4)), x), x, atanh(S(2)*sqrt(d)*sqrt(f)*x**S(3)/(e + S(2)*f*x**S(2)))/(S(2)*sqrt(d)*sqrt(f)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**m*(e*(m + S(1)) + S(2)*f*x**S(2)*(m + S(-1)))/(S(4)*d*f*x**(S(2)*m + S(2)) + e**S(2) + S(4)*e*f*x**S(2) + S(4)*f**S(2)*x**S(4)), x), x, atan(S(2)*sqrt(d)*sqrt(f)*x**(m + S(1))/(e + S(2)*f*x**S(2)))/(S(2)*sqrt(d)*sqrt(f)), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(x**m*(e*(m + S(1)) + S(2)*f*x**S(2)*(m + S(-1)))/(S(4)*d*f*x**(S(2)*m + S(2)) + e**S(2) + S(4)*e*f*x**S(2) + S(4)*f**S(2)*x**S(4)), x), x, atan(S(2)*sqrt(d)*sqrt(f)*x**(m + S(1))*(-m**S(2) + S(1))/((e + S(2)*f*x**S(2))*(-m + S(1))*(m + S(1))))/(S(2)*sqrt(d)*sqrt(f)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**m*(e*(m + S(1)) + S(2)*f*x**S(2)*(m + S(-1)))/(-S(4)*d*f*x**(S(2)*m + S(2)) + e**S(2) + S(4)*e*f*x**S(2) + S(4)*f**S(2)*x**S(4)), x), x, atanh(S(2)*sqrt(d)*sqrt(f)*x**(m + S(1))/(e + S(2)*f*x**S(2)))/(S(2)*sqrt(d)*sqrt(f)), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(x**m*(e*(m + S(1)) + S(2)*f*x**S(2)*(m + S(-1)))/(-S(4)*d*f*x**(S(2)*m + S(2)) + e**S(2) + S(4)*e*f*x**S(2) + S(4)*f**S(2)*x**S(4)), x), x, atanh(S(2)*sqrt(d)*sqrt(f)*x**(m + S(1))*(-m**S(2) + S(1))/((e + S(2)*f*x**S(2))*(-m + S(1))*(m + S(1))))/(S(2)*sqrt(d)*sqrt(f)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(S(2)*e - S(2)*f*x**S(3))/(S(4)*d*f*x**S(4) + e**S(2) + S(4)*e*f*x**S(3) + S(4)*f**S(2)*x**S(6)), x), x, atan(S(2)*sqrt(d)*sqrt(f)*x**S(2)/(e + S(2)*f*x**S(3)))/(S(2)*sqrt(d)*sqrt(f)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(S(2)*e - S(2)*f*x**S(3))/(-S(4)*d*f*x**S(4) + e**S(2) + S(4)*e*f*x**S(3) + S(4)*f**S(2)*x**S(6)), x), x, atanh(S(2)*sqrt(d)*sqrt(f)*x**S(2)/(e + S(2)*f*x**S(3)))/(S(2)*sqrt(d)*sqrt(f)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(S(4)*d*f*x**S(6) + e**S(2) + S(4)*e*f*x**S(3) + S(4)*f**S(2)*x**S(6)), x), x, atan(sqrt(f)*(e + x**S(3)*(S(2)*d + S(2)*f))/(sqrt(d)*e))/(S(6)*sqrt(d)*e*sqrt(f)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(-S(4)*d*f*x**S(6) + e**S(2) + S(4)*e*f*x**S(3) + S(4)*f**S(2)*x**S(6)), x), x, -atanh(sqrt(f)*(e - x**S(3)*(S(2)*d - S(2)*f))/(sqrt(d)*e))/(S(6)*sqrt(d)*e*sqrt(f)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**m*(e*(m + S(1)) + S(2)*f*x**S(3)*(m + S(-2)))/(S(4)*d*f*x**(S(2)*m + S(2)) + e**S(2) + S(4)*e*f*x**S(3) + S(4)*f**S(2)*x**S(6)), x), x, atan(S(2)*sqrt(d)*sqrt(f)*x**(m + S(1))/(e + S(2)*f*x**S(3)))/(S(2)*sqrt(d)*sqrt(f)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**m*(e*(m + S(1)) + S(2)*f*x**S(3)*(m + S(-2)))/(-S(4)*d*f*x**(S(2)*m + S(2)) + e**S(2) + S(4)*e*f*x**S(3) + S(4)*f**S(2)*x**S(6)), x), x, atanh(S(2)*sqrt(d)*sqrt(f)*x**(m + S(1))/(e + S(2)*f*x**S(3)))/(S(2)*sqrt(d)*sqrt(f)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**m*(e*(m + S(1)) + S(2)*f*x**n*(m - n + S(1)))/(S(4)*d*f*x**(S(2)*m + S(2)) + e**S(2) + S(4)*e*f*x**n + S(4)*f**S(2)*x**(S(2)*n)), x), x, atan(S(2)*sqrt(d)*sqrt(f)*x**(m + S(1))/(e + S(2)*f*x**n))/(S(2)*sqrt(d)*sqrt(f)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**m*(e*(m + S(1)) + S(2)*f*x**n*(m - n + S(1)))/(-S(4)*d*f*x**(S(2)*m + S(2)) + e**S(2) + S(4)*e*f*x**n + S(4)*f**S(2)*x**(S(2)*n)), x), x, atanh(S(2)*sqrt(d)*sqrt(f)*x**(m + S(1))/(e + S(2)*f*x**n))/(S(2)*sqrt(d)*sqrt(f)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)/(a*c + b*c*x**S(2) + d*sqrt(a + b*x**S(2))), x), x, -x**S(2)*(S(2)*a*c**S(2) - d**S(2))/(S(2)*b**S(2)*c**S(3)) + (a + b*x**S(2))**S(2)/(S(4)*b**S(3)*c) - d*(a + b*x**S(2))**(S(3)/2)/(S(3)*b**S(3)*c**S(2)) + d*sqrt(a + b*x**S(2))*(S(2)*a*c**S(2) - d**S(2))/(b**S(3)*c**S(4)) + (a*c**S(2) - d**S(2))**S(2)*log(c*sqrt(a + b*x**S(2)) + d)/(b**S(3)*c**S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(a*c + b*c*x**S(2) + d*sqrt(a + b*x**S(2))), x), x, x**S(2)/(S(2)*b*c) - d*sqrt(a + b*x**S(2))/(b**S(2)*c**S(2)) - (a*c**S(2) - d**S(2))*log(c*sqrt(a + b*x**S(2)) + d)/(b**S(2)*c**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(a*c + b*c*x**S(2) + d*sqrt(a + b*x**S(2))), x), x, log(c*sqrt(a + b*x**S(2)) + d)/(b*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(a*c + b*c*x**S(2) + d*sqrt(a + b*x**S(2)))), x), x, c*log(x)/(a*c**S(2) - d**S(2)) - c*log(c*sqrt(a + b*x**S(2)) + d)/(a*c**S(2) - d**S(2)) + d*atanh(sqrt(a + b*x**S(2))/sqrt(a))/(sqrt(a)*(a*c**S(2) - d**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*(a*c + b*c*x**S(2) + d*sqrt(a + b*x**S(2)))), x), x, -b*c**S(3)*log(x)/(a*c**S(2) - d**S(2))**S(2) + b*c**S(3)*log(c*sqrt(a + b*x**S(2)) + d)/(a*c**S(2) - d**S(2))**S(2) - (a*c - d*sqrt(a + b*x**S(2)))/(S(2)*a*x**S(2)*(a*c**S(2) - d**S(2))) - b*d*(S(3)*a*c**S(2) - d**S(2))*atanh(sqrt(a + b*x**S(2))/sqrt(a))/(S(2)*a**(S(3)/2)*(a*c**S(2) - d**S(2))**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(a*c + b*c*x**S(2) + d*sqrt(a + b*x**S(2))), x), x, x/(b*c) - d*atanh(sqrt(b)*x/sqrt(a + b*x**S(2)))/(b**(S(3)/2)*c**S(2)) - sqrt(a*c**S(2) - d**S(2))*atan(sqrt(b)*c*x/sqrt(a*c**S(2) - d**S(2)))/(b**(S(3)/2)*c**S(2)) + sqrt(a*c**S(2) - d**S(2))*atan(sqrt(b)*d*x/(sqrt(a + b*x**S(2))*sqrt(a*c**S(2) - d**S(2))))/(b**(S(3)/2)*c**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(a*c + b*c*x**S(2) + d*sqrt(a + b*x**S(2))), x), x, atan(sqrt(b)*c*x/sqrt(a*c**S(2) - d**S(2)))/(sqrt(b)*sqrt(a*c**S(2) - d**S(2))) - atan(sqrt(b)*d*x/(sqrt(a + b*x**S(2))*sqrt(a*c**S(2) - d**S(2))))/(sqrt(b)*sqrt(a*c**S(2) - d**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(a*c + b*c*x**S(2) + d*sqrt(a + b*x**S(2)))), x), x, -sqrt(b)*c**S(2)*atan(sqrt(b)*c*x/sqrt(a*c**S(2) - d**S(2)))/(a*c**S(2) - d**S(2))**(S(3)/2) + sqrt(b)*c**S(2)*atan(sqrt(b)*d*x/(sqrt(a + b*x**S(2))*sqrt(a*c**S(2) - d**S(2))))/(a*c**S(2) - d**S(2))**(S(3)/2) - c/(x*(a*c**S(2) - d**S(2))) + d*sqrt(a + b*x**S(2))/(a*x*(a*c**S(2) - d**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(8)/(a*c + b*c*x**S(3) + d*sqrt(a + b*x**S(3))), x), x, -x**S(3)*(S(2)*a*c**S(2) - d**S(2))/(S(3)*b**S(2)*c**S(3)) + (a + b*x**S(3))**S(2)/(S(6)*b**S(3)*c) - S(2)*d*(a + b*x**S(3))**(S(3)/2)/(S(9)*b**S(3)*c**S(2)) + S(2)*d*sqrt(a + b*x**S(3))*(S(2)*a*c**S(2) - d**S(2))/(S(3)*b**S(3)*c**S(4)) + S(2)*(a*c**S(2) - d**S(2))**S(2)*log(c*sqrt(a + b*x**S(3)) + d)/(S(3)*b**S(3)*c**S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)/(a*c + b*c*x**S(3) + d*sqrt(a + b*x**S(3))), x), x, x**S(3)/(S(3)*b*c) - S(2)*d*sqrt(a + b*x**S(3))/(S(3)*b**S(2)*c**S(2)) - (S(2)*a*c**S(2) - S(2)*d**S(2))*log(c*sqrt(a + b*x**S(3)) + d)/(S(3)*b**S(2)*c**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(a*c + b*c*x**S(3) + d*sqrt(a + b*x**S(3))), x), x, S(2)*log(c*sqrt(a + b*x**S(3)) + d)/(S(3)*b*c), expand=True, _diff=True, _numerical=True)
# taking a long time assert rubi_test(rubi_integrate(S(1)/(x*(a*c + b*c*x**S(3) + d*sqrt(a + b*x**S(3)))), x), x, -S(2)*c*log(c*sqrt(a + b*x**S(3)) + d)/(S(3)*a*c**S(2) - S(3)*d**S(2)) + c*log(x)/(a*c**S(2) - d**S(2)) + S(2)*d*atanh(sqrt(a + b*x**S(3))/sqrt(a))/(S(3)*sqrt(a)*(a*c**S(2) - d**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(4)*(a*c + b*c*x**S(3) + d*sqrt(a + b*x**S(3)))), x), x, -b*c**S(3)*log(x)/(a*c**S(2) - d**S(2))**S(2) + S(2)*b*c**S(3)*log(c*sqrt(a + b*x**S(3)) + d)/(S(3)*(a*c**S(2) - d**S(2))**S(2)) - (a*c - d*sqrt(a + b*x**S(3)))/(S(3)*a*x**S(3)*(a*c**S(2) - d**S(2))) - b*d*(S(3)*a*c**S(2) - d**S(2))*atanh(sqrt(a + b*x**S(3))/sqrt(a))/(S(3)*a**(S(3)/2)*(a*c**S(2) - d**S(2))**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(a*c + b*c*x**S(3) + d*sqrt(a + b*x**S(3))), x), x, -d*x**S(4)*sqrt(S(1) + b*x**S(3)/a)*AppellF1(S(4)/3, S(1)/2, S(1), S(7)/3, -b*x**S(3)/a, -b*c**S(2)*x**S(3)/(a*c**S(2) - d**S(2)))/(sqrt(a + b*x**S(3))*(S(4)*a*c**S(2) - S(4)*d**S(2))) + x/(b*c) - (a*c**S(2) - d**S(2))**(S(1)/3)*log(b**(S(1)/3)*c**(S(2)/3)*x + (a*c**S(2) - d**S(2))**(S(1)/3))/(S(3)*b**(S(4)/3)*c**(S(5)/3)) + (a*c**S(2) - d**S(2))**(S(1)/3)*log(b**(S(2)/3)*c**(S(4)/3)*x**S(2) - b**(S(1)/3)*c**(S(2)/3)*x*(a*c**S(2) - d**S(2))**(S(1)/3) + (a*c**S(2) - d**S(2))**(S(2)/3))/(S(6)*b**(S(4)/3)*c**(S(5)/3)) + sqrt(S(3))*(a*c**S(2) - d**S(2))**(S(1)/3)*atan(sqrt(S(3))*(-S(2)*b**(S(1)/3)*c**(S(2)/3)*x/(a*c**S(2) - d**S(2))**(S(1)/3) + S(1))/S(3))/(S(3)*b**(S(4)/3)*c**(S(5)/3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(a*c + b*c*x**S(3) + d*sqrt(a + b*x**S(3))), x), x, -d*x**S(2)*sqrt(S(1) + b*x**S(3)/a)*AppellF1(S(2)/3, S(1)/2, S(1), S(5)/3, -b*x**S(3)/a, -b*c**S(2)*x**S(3)/(a*c**S(2) - d**S(2)))/(sqrt(a + b*x**S(3))*(S(2)*a*c**S(2) - S(2)*d**S(2))) - log(b**(S(1)/3)*c**(S(2)/3)*x + (a*c**S(2) - d**S(2))**(S(1)/3))/(S(3)*b**(S(2)/3)*c**(S(1)/3)*(a*c**S(2) - d**S(2))**(S(1)/3)) + log(b**(S(2)/3)*c**(S(4)/3)*x**S(2) - b**(S(1)/3)*c**(S(2)/3)*x*(a*c**S(2) - d**S(2))**(S(1)/3) + (a*c**S(2) - d**S(2))**(S(2)/3))/(S(6)*b**(S(2)/3)*c**(S(1)/3)*(a*c**S(2) - d**S(2))**(S(1)/3)) - sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*b**(S(1)/3)*c**(S(2)/3)*x/(a*c**S(2) - d**S(2))**(S(1)/3) + S(1))/S(3))/(S(3)*b**(S(2)/3)*c**(S(1)/3)*(a*c**S(2) - d**S(2))**(S(1)/3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(a*c + b*c*x**S(3) + d*sqrt(a + b*x**S(3))), x), x, -d*x*sqrt(S(1) + b*x**S(3)/a)*AppellF1(S(1)/3, S(1)/2, S(1), S(4)/3, -b*x**S(3)/a, -b*c**S(2)*x**S(3)/(a*c**S(2) - d**S(2)))/(sqrt(a + b*x**S(3))*(a*c**S(2) - d**S(2))) + c**(S(1)/3)*log(b**(S(1)/3)*c**(S(2)/3)*x + (a*c**S(2) - d**S(2))**(S(1)/3))/(S(3)*b**(S(1)/3)*(a*c**S(2) - d**S(2))**(S(2)/3)) - c**(S(1)/3)*log(b**(S(2)/3)*c**(S(4)/3)*x**S(2) - b**(S(1)/3)*c**(S(2)/3)*x*(a*c**S(2) - d**S(2))**(S(1)/3) + (a*c**S(2) - d**S(2))**(S(2)/3))/(S(6)*b**(S(1)/3)*(a*c**S(2) - d**S(2))**(S(2)/3)) - sqrt(S(3))*c**(S(1)/3)*atan(sqrt(S(3))*(-S(2)*b**(S(1)/3)*c**(S(2)/3)*x/(a*c**S(2) - d**S(2))**(S(1)/3) + S(1))/S(3))/(S(3)*b**(S(1)/3)*(a*c**S(2) - d**S(2))**(S(2)/3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(a*c + b*c*x**S(3) + d*sqrt(a + b*x**S(3)))), x), x, b**(S(1)/3)*c**(S(5)/3)*log(b**(S(1)/3)*c**(S(2)/3)*x + (a*c**S(2) - d**S(2))**(S(1)/3))/(S(3)*(a*c**S(2) - d**S(2))**(S(4)/3)) - b**(S(1)/3)*c**(S(5)/3)*log(b**(S(2)/3)*c**(S(4)/3)*x**S(2) - b**(S(1)/3)*c**(S(2)/3)*x*(a*c**S(2) - d**S(2))**(S(1)/3) + (a*c**S(2) - d**S(2))**(S(2)/3))/(S(6)*(a*c**S(2) - d**S(2))**(S(4)/3)) + sqrt(S(3))*b**(S(1)/3)*c**(S(5)/3)*atan(sqrt(S(3))*(-S(2)*b**(S(1)/3)*c**(S(2)/3)*x/(a*c**S(2) - d**S(2))**(S(1)/3) + S(1))/S(3))/(S(3)*(a*c**S(2) - d**S(2))**(S(4)/3)) - c/(x*(a*c**S(2) - d**S(2))) + d*sqrt(S(1) + b*x**S(3)/a)*AppellF1(S(-1)/3, S(1)/2, S(1), S(2)/3, -b*x**S(3)/a, -b*c**S(2)*x**S(3)/(a*c**S(2) - d**S(2)))/(x*sqrt(a + b*x**S(3))*(a*c**S(2) - d**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*(a*c + b*c*x**S(3) + d*sqrt(a + b*x**S(3)))), x), x, -b**(S(2)/3)*c**(S(7)/3)*log(b**(S(1)/3)*c**(S(2)/3)*x + (a*c**S(2) - d**S(2))**(S(1)/3))/(S(3)*(a*c**S(2) - d**S(2))**(S(5)/3)) + b**(S(2)/3)*c**(S(7)/3)*log(b**(S(2)/3)*c**(S(4)/3)*x**S(2) - b**(S(1)/3)*c**(S(2)/3)*x*(a*c**S(2) - d**S(2))**(S(1)/3) + (a*c**S(2) - d**S(2))**(S(2)/3))/(S(6)*(a*c**S(2) - d**S(2))**(S(5)/3)) + sqrt(S(3))*b**(S(2)/3)*c**(S(7)/3)*atan(sqrt(S(3))*(-S(2)*b**(S(1)/3)*c**(S(2)/3)*x/(a*c**S(2) - d**S(2))**(S(1)/3) + S(1))/S(3))/(S(3)*(a*c**S(2) - d**S(2))**(S(5)/3)) - c/(x**S(2)*(S(2)*a*c**S(2) - S(2)*d**S(2))) + d*sqrt(S(1) + b*x**S(3)/a)*AppellF1(S(-2)/3, S(1)/2, S(1), S(1)/3, -b*x**S(3)/a, -b*c**S(2)*x**S(3)/(a*c**S(2) - d**S(2)))/(x**S(2)*sqrt(a + b*x**S(3))*(S(2)*a*c**S(2) - S(2)*d**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(a*c + b*c*x**n + d*sqrt(a + b*x**n)), x), x, c*x*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -b*c**S(2)*x**n/(a*c**S(2) - d**S(2)))/(a*c**S(2) - d**S(2)) - d*x*sqrt(S(1) + b*x**n/a)*AppellF1(S(1)/n, S(1)/2, S(1), S(1) + S(1)/n, -b*x**n/a, -b*c**S(2)*x**n/(a*c**S(2) - d**S(2)))/(sqrt(a + b*x**n)*(a*c**S(2) - d**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**m/(a*c + b*c*x**n + d*sqrt(a + b*x**n)), x), x, c*x**(m + S(1))*hyper((S(1), (m + S(1))/n), ((m + n + S(1))/n,), -b*c**S(2)*x**n/(a*c**S(2) - d**S(2)))/((m + S(1))*(a*c**S(2) - d**S(2))) - d*x**(m + S(1))*sqrt(S(1) + b*x**n/a)*AppellF1((m + S(1))/n, S(1)/2, S(1), (m + n + S(1))/n, -b*x**n/a, -b*c**S(2)*x**n/(a*c**S(2) - d**S(2)))/(sqrt(a + b*x**n)*(m + S(1))*(a*c**S(2) - d**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(n + S(-1))/(a*c + b*c*x**n + d*sqrt(a + b*x**n)), x), x, S(2)*log(c*sqrt(a + b*x**n) + d)/(b*c*n), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(S(4)*x**(S(3)/2) + sqrt(x)), x), x, atan(S(2)*sqrt(x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(-x**(S(5)/2) + sqrt(x)), x), x, atan(sqrt(x)) + atanh(sqrt(x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(-x**(S(1)/4) + sqrt(x)), x), x, S(4)*x**(S(1)/4) + S(2)*sqrt(x) + S(4)*log(-x**(S(1)/4) + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**(S(1)/3) + sqrt(x)), x), x, S(6)*x**(S(1)/6) - S(3)*x**(S(1)/3) + S(2)*sqrt(x) - S(6)*log(x**(S(1)/6) + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**(S(1)/4) + sqrt(x)), x), x, -S(4)*x**(S(1)/4) + S(2)*sqrt(x) + S(4)*log(x**(S(1)/4) + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**(S(2)/3) - x**(S(1)/3)), x), x, S(3)*x**(S(1)/3) + S(3)*log(-x**(S(1)/3) + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(x) + x**(S(-1)/4)), x), x, S(2)*sqrt(x) + S(4)*log(x**(S(1)/4) + S(1))/S(3) - S(2)*log(-x**(S(1)/4) + sqrt(x) + S(1))/S(3) + S(4)*sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x**(S(1)/4) + S(1))/S(3))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**(S(1)/4) + x**(S(1)/3)), x), x, -S(12)*x**(S(7)/12)/S(7) - S(12)*x**(S(5)/12)/S(5) - S(12)*x**(S(1)/12) + S(6)*x**(S(1)/6) - S(4)*x**(S(1)/4) + S(3)*x**(S(2)/3)/S(2) + S(3)*x**(S(1)/3) + S(2)*sqrt(x) + S(12)*log(x**(S(1)/12) + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**(S(-1)/3) + x**(S(-1)/4)), x), x, S(12)*x**(S(13)/12)/S(13) + S(12)*x**(S(11)/12)/S(11) + S(12)*x**(S(7)/12)/S(7) + S(12)*x**(S(5)/12)/S(5) + S(12)*x**(S(1)/12) - S(6)*x**(S(7)/6)/S(7) - S(6)*x**(S(5)/6)/S(5) - S(6)*x**(S(1)/6) + S(4)*x**(S(5)/4)/S(5) + S(4)*x**(S(3)/4)/S(3) + S(4)*x**(S(1)/4) - S(3)*x**(S(2)/3)/S(2) - S(3)*x**(S(1)/3) - S(2)*sqrt(x) - x - S(12)*log(x**(S(1)/12) + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(x) - S(1)/x**(S(1)/3)), x), x, S(2)*sqrt(x) + S(6)*log(-x**(S(1)/6) + S(1))/S(5) - (-S(3)*sqrt(S(5))/S(10) + S(3)/10)*log(x**(S(1)/6) + sqrt(S(5))*x**(S(1)/6) + S(2)*x**(S(1)/3) + S(2)) - (S(3)/10 + S(3)*sqrt(S(5))/S(10))*log(-sqrt(S(5))*x**(S(1)/6) + x**(S(1)/6) + S(2)*x**(S(1)/3) + S(2)) - S(3)*sqrt(S(2)*sqrt(S(5)) + S(10))*atan(sqrt(sqrt(S(5))/S(10) + S(1)/2)*(S(4)*x**(S(1)/6) + S(1) + sqrt(S(5)))/S(2))/S(5) + S(3)*sqrt(-S(2)*sqrt(S(5)) + S(10))*atan((S(4)*x**(S(1)/6) - sqrt(S(5)) + S(1))/sqrt(S(2)*sqrt(S(5)) + S(10)))/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x)/(x**S(2) + x), x), x, S(2)*atan(sqrt(x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(S(4)*sqrt(x) + x), x), x, -S(8)*sqrt(x) + x + S(32)*log(sqrt(x) + S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x)/(x**(S(1)/3) + x), x), x, S(2)*sqrt(x) - S(3)*sqrt(S(2))*log(-sqrt(S(2))*x**(S(1)/6) + x**(S(1)/3) + S(1))/S(4) + S(3)*sqrt(S(2))*log(sqrt(S(2))*x**(S(1)/6) + x**(S(1)/3) + S(1))/S(4) - S(3)*sqrt(S(2))*atan(sqrt(S(2))*x**(S(1)/6) + S(-1))/S(2) - S(3)*sqrt(S(2))*atan(sqrt(S(2))*x**(S(1)/6) + S(1))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(1)/3)/(x**(S(1)/4) + sqrt(x)), x), x, -S(12)*x**(S(7)/12)/S(7) - S(12)*x**(S(1)/12) + S(6)*x**(S(5)/6)/S(5) + S(3)*x**(S(1)/3) + S(6)*log(x**(S(1)/12) + S(1)) - S(2)*log(x**(S(1)/4) + S(1)) - S(4)*sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x**(S(1)/12) + S(1))/S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x)/(x**(S(1)/4) + x**(S(1)/3)), x), x, -S(12)*x**(S(13)/12)/S(13) - S(12)*x**(S(11)/12)/S(11) - S(12)*x**(S(7)/12)/S(7) - S(12)*x**(S(5)/12)/S(5) - S(12)*x**(S(1)/12) + S(6)*x**(S(7)/6)/S(7) + S(6)*x**(S(5)/6)/S(5) + S(6)*x**(S(1)/6) - S(4)*x**(S(3)/4)/S(3) - S(4)*x**(S(1)/4) + S(3)*x**(S(2)/3)/S(2) + S(3)*x**(S(1)/3) + S(2)*sqrt(x) + x + S(12)*log(x**(S(1)/12) + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x)/(sqrt(x) - S(1)/x**(S(1)/3)), x), x, S(6)*x**(S(1)/6) + x + S(6)*log(-x**(S(1)/6) + S(1))/S(5) - (S(3)/10 + S(3)*sqrt(S(5))/S(10))*log(x**(S(1)/6) + sqrt(S(5))*x**(S(1)/6) + S(2)*x**(S(1)/3) + S(2)) - (-S(3)*sqrt(S(5))/S(10) + S(3)/10)*log(-sqrt(S(5))*x**(S(1)/6) + x**(S(1)/6) + S(2)*x**(S(1)/3) + S(2)) - S(3)*sqrt(-S(2)*sqrt(S(5)) + S(10))*atan(sqrt(sqrt(S(5))/S(10) + S(1)/2)*(S(4)*x**(S(1)/6) + S(1) + sqrt(S(5)))/S(2))/S(5) - S(3)*sqrt(S(2)*sqrt(S(5)) + S(10))*atan((S(4)*x**(S(1)/6) - sqrt(S(5)) + S(1))/sqrt(S(2)*sqrt(S(5)) + S(10)))/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(b*x**S(2) + sqrt(a + b**S(2)*x**S(4)))/sqrt(a + b**S(2)*x**S(4)), x), x, sqrt(S(2))*atanh(sqrt(S(2))*sqrt(b)*x/sqrt(b*x**S(2) + sqrt(a + b**S(2)*x**S(4))))/(S(2)*sqrt(b)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(-b*x**S(2) + sqrt(a + b**S(2)*x**S(4)))/sqrt(a + b**S(2)*x**S(4)), x), x, sqrt(S(2))*atan(sqrt(S(2))*sqrt(b)*x/sqrt(-b*x**S(2) + sqrt(a + b**S(2)*x**S(4))))/(S(2)*sqrt(b)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(S(2)*x**S(2) + sqrt(S(4)*x**S(4) + S(3)))/((c + d*x)*sqrt(S(4)*x**S(4) + S(3))), x), x, -(S(1)/2 + I/S(2))*atanh((-S(2)*I*c*x + sqrt(S(3))*d)/(sqrt(S(2)*I*c**S(2) + sqrt(S(3))*d**S(2))*sqrt(S(2)*I*x**S(2) + sqrt(S(3)))))/sqrt(S(2)*I*c**S(2) + sqrt(S(3))*d**S(2)) + (S(1)/2 - I/S(2))*atan((S(2)*I*c*x + sqrt(S(3))*d)/(sqrt(S(2)*I*c**S(2) - sqrt(S(3))*d**S(2))*sqrt(-S(2)*I*x**S(2) + sqrt(S(3)))))/sqrt(S(2)*I*c**S(2) - sqrt(S(3))*d**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(S(2)*x**S(2) + sqrt(S(4)*x**S(4) + S(3)))/((c + d*x)**S(2)*sqrt(S(4)*x**S(4) + S(3))), x), x, c*(S(1) - I)*atanh((-S(2)*I*c*x + sqrt(S(3))*d)/(sqrt(S(2)*I*c**S(2) + sqrt(S(3))*d**S(2))*sqrt(S(2)*I*x**S(2) + sqrt(S(3)))))/(S(2)*I*c**S(2) + sqrt(S(3))*d**S(2))**(S(3)/2) + c*(S(1) + I)*atan((S(2)*I*c*x + sqrt(S(3))*d)/(sqrt(S(2)*I*c**S(2) - sqrt(S(3))*d**S(2))*sqrt(-S(2)*I*x**S(2) + sqrt(S(3)))))/(S(2)*I*c**S(2) - sqrt(S(3))*d**S(2))**(S(3)/2) - d*(S(1)/2 + I/S(2))*sqrt(S(2)*I*x**S(2) + sqrt(S(3)))/((c + d*x)*(S(2)*I*c**S(2) + sqrt(S(3))*d**S(2))) + d*(S(1)/2 - I/S(2))*sqrt(-S(2)*I*x**S(2) + sqrt(S(3)))/((c + d*x)*(S(2)*I*c**S(2) - sqrt(S(3))*d**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x + S(-4))/(sqrt(x)*(x**(S(1)/3) + S(1))), x), x, S(6)*x**(S(7)/6)/S(7) - S(6)*x**(S(5)/6)/S(5) - S(30)*x**(S(1)/6) + S(2)*sqrt(x) + S(30)*atan(x**(S(1)/6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((sqrt(x) + S(1))/(x**(S(7)/6) + x**(S(5)/6)), x), x, S(3)*x**(S(1)/3) - S(3)*log(x**(S(1)/3) + S(1)) + S(6)*atan(x**(S(1)/6)), expand=True, _diff=True, _numerical=True)
# difference in simplify assert rubi_test(rubi_integrate((sqrt(x) + S(1))/(sqrt(x)*(x**(S(1)/3) + S(1))), x), x, S(6)*x**(S(1)/6) + S(3)*x**(S(2)/3)/S(2) - S(3)*x**(S(1)/3) + S(3)*log(x**(S(1)/3) + S(1)) - S(6)*atan(x**(S(1)/6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(b/x**S(2) + S(2))/(b + S(2)*x**S(2)), x), x, -acsch(sqrt(S(2))*x/sqrt(b))/sqrt(b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(-b/x**S(2) + S(2))/(-b + S(2)*x**S(2)), x), x, -acsc(sqrt(S(2))*x/sqrt(b))/sqrt(b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + c/x**S(2))/(d + e*x), x), x, sqrt(a)*atanh(sqrt(a + c/x**S(2))/sqrt(a))/e - sqrt(c)*atanh(sqrt(c)/(x*sqrt(a + c/x**S(2))))/d - sqrt(a*d**S(2) + c*e**S(2))*atanh((a*d - c*e/x)/(sqrt(a + c/x**S(2))*sqrt(a*d**S(2) + c*e**S(2))))/(d*e), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + b/x + c/x**S(2))/(d + e*x), x), x, sqrt(a)*atanh((S(2)*a + b/x)/(S(2)*sqrt(a)*sqrt(a + b/x + c/x**S(2))))/e - sqrt(c)*atanh((b + S(2)*c/x)/(S(2)*sqrt(c)*sqrt(a + b/x + c/x**S(2))))/d - sqrt(a*d**S(2) - e*(b*d - c*e))*atanh((S(2)*a*d - b*e + (b*d - S(2)*c*e)/x)/(S(2)*sqrt(a*d**S(2) - e*(b*d - c*e))*sqrt(a + b/x + c/x**S(2))))/(d*e), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**(S(1)/6) + (x**S(3))**(S(1)/5))/sqrt(x), x), x, S(3)*x**(S(2)/3)/S(2) + S(10)*sqrt(x)*(x**S(3))**(S(1)/5)/S(11), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x + S(2))/sqrt(-x**S(2) + S(4)*x), x), x, -sqrt(-x**S(2) + S(4)*x) + S(4)*asin(x/S(2) + S(-1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x + S(3))/(x**S(2) + S(6)*x)**(S(1)/3), x), x, S(3)*(x**S(2) + S(6)*x)**(S(2)/3)/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x + S(4))/(-x**S(2) + S(6)*x)**(S(3)/2), x), x, -(-S(7)*x + S(12))/(S(9)*sqrt(-x**S(2) + S(6)*x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((x + S(1))*sqrt(x**S(2) + S(2)*x)), x), x, atan(sqrt(x**S(2) + S(2)*x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((S(2)*x + S(1))*sqrt(x**S(2) + x)), x), x, atan(S(2)*sqrt(x**S(2) + x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x + S(-1))/sqrt(-x**S(2) + S(2)*x), x), x, -sqrt(-x**S(2) + S(2)*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(-x**S(2) + x)/(x + S(1)), x), x, sqrt(-x**S(2) + x) + S(3)*asin(S(2)*x + S(-1))/S(2) + sqrt(S(2))*atan(sqrt(S(2))*(-S(3)*x + S(1))/(S(4)*sqrt(-x**S(2) + x))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x**(S(1)/4) + x), x), x, x**(S(1)/4)*sqrt(x**(S(1)/4) + x)/S(3) + S(2)*x*sqrt(x**(S(1)/4) + x)/S(3) - atanh(sqrt(x)/sqrt(x**(S(1)/4) + x))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x**(S(3)/2) + x), x), x, -S(16)*(x**(S(3)/2) + x)**(S(3)/2)/(S(35)*x) + S(4)*(x**(S(3)/2) + x)**(S(3)/2)/(S(7)*sqrt(x)) + S(32)*(x**(S(3)/2) + x)**(S(3)/2)/(S(105)*x**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*sqrt(x**(S(3)/2) + x), x), x, S(4)*sqrt(x)*(x**(S(3)/2) + x)**(S(3)/2)/S(11) - S(32)*(x**(S(3)/2) + x)**(S(3)/2)/S(99) - S(256)*(x**(S(3)/2) + x)**(S(3)/2)/(S(1155)*x) + S(64)*(x**(S(3)/2) + x)**(S(3)/2)/(S(231)*sqrt(x)) + S(512)*(x**(S(3)/2) + x)**(S(3)/2)/(S(3465)*x**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-x**S(2) + S(1))*sqrt(S(1)/(-x**S(2) + S(2))), x), x, x/(S(2)*sqrt(S(1)/(-x**S(2) + S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(-x**S(4) + x**S(3) + x**S(2)), x), x, -(-S(2)*x + S(1))*sqrt(-x**S(4) + x**S(3) + x**S(2))/(S(8)*x) - (-x**S(2) + x + S(1))*sqrt(-x**S(4) + x**S(3) + x**S(2))/(S(3)*x) - S(5)*sqrt(-x**S(4) + x**S(3) + x**S(2))*asin(sqrt(S(5))*(-S(2)*x + S(1))/S(5))/(S(16)*x*sqrt(-x**S(2) + x + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt((a**S(2) + x**S(2))**S(3)), x), x, x*(a**S(2) + x**S(2))/(a**S(2)*sqrt((a**S(2) + x**S(2))**S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x)/(sqrt(x) + x + S(1)), x), x, S(2)*sqrt(x) - log(sqrt(x) + x + S(1)) - S(2)*sqrt(S(3))*atan(sqrt(S(3))*(S(2)*sqrt(x) + S(1))/S(3))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(sqrt(x) + x + S(1)), x), x, -S(2)*sqrt(x) + x + S(4)*sqrt(S(3))*atan(sqrt(S(3))*(S(2)*sqrt(x) + S(1))/S(3))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(x)*(sqrt(x) + x + S(1))**(S(7)/2)), x), x, (S(8)*sqrt(x) + S(4))/(S(15)*(sqrt(x) + x + S(1))**(S(5)/2)) + (S(128)*sqrt(x) + S(64))/(S(135)*(sqrt(x) + x + S(1))**(S(3)/2)) + (S(1024)*sqrt(x) + S(512))/(S(405)*sqrt(sqrt(x) + x + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x + S(-1))/(sqrt(x**S(2) + S(1)) + S(1)), x), x, sqrt(x**S(2) + S(1)) - log(sqrt(x**S(2) + S(1)) + S(1)) - asinh(x) + sqrt(x**S(2) + S(1))/x - S(1)/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((x + S(1))**(S(2)/3)*(x**S(2) + S(-1))**(S(2)/3)), x), x, S(3)*(x**S(2) + S(-1))**(S(1)/3)/(S(2)*(x + S(1))**(S(2)/3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*sqrt(-x**S(2) + S(1))/(x + S(1)), x), x, -sqrt(-x**S(2) + S(1))/S(2) - asin(x)/S(2) - (-x**S(2) + S(1))**(S(3)/2)/(S(2)*x + S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-x**S(6) + S(1))**(S(2)/3) + (-x**S(6) + S(1))**(S(2)/3)/x**S(6), x), x, x*(-x**S(6) + S(1))**(S(2)/3)/S(5) - (-x**S(6) + S(1))**(S(2)/3)/(S(5)*x**S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(m + S(-1))*(S(2)*a*m + b*x**n*(S(2)*m - n))/(S(2)*(a + b*x**n)**(S(3)/2)), x), x, x**m/sqrt(a + b*x**n), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-S(2)*x**S(3) + x)/sqrt(S(3)*x + S(2)), x), x, -S(4)*(S(3)*x + S(2))**(S(7)/2)/S(567) + S(8)*(S(3)*x + S(2))**(S(5)/2)/S(135) - S(10)*(S(3)*x + S(2))**(S(3)/2)/S(81) - S(4)*sqrt(S(3)*x + S(2))/S(81), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((x + S(1))**(S(1)/4) + sqrt(x + S(1))), x), x, -S(4)*(x + S(1))**(S(1)/4) + S(2)*sqrt(x + S(1)) + S(4)*log((x + S(1))**(S(1)/4) + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x + S(1))/sqrt(x**S(2) + x), x), x, S(2)*sqrt(x**S(2) + x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(S(2)*sqrt(x)*(x + S(1))), x), x, atan(sqrt(x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*sqrt(-x**S(2) + S(6)*x)), x), x, -sqrt(-x**S(2) + S(6)*x)/(S(3)*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x)*(sqrt(x) + S(1)), x), x, S(2)*x**(S(3)/2)/S(3) + x**S(2)/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-sqrt(x) + S(1))/x**(S(1)/3), x), x, -S(6)*x**(S(7)/6)/S(7) + S(3)*x**(S(2)/3)/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x)/(x**(S(1)/3) + S(1)), x), x, S(6)*x**(S(7)/6)/S(7) - S(6)*x**(S(5)/6)/S(5) - S(6)*x**(S(1)/6) + S(2)*sqrt(x) + S(6)*atan(x**(S(1)/6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((sqrt(x) + S(1))**(S(1)/3)/x, x), x, S(6)*(sqrt(x) + S(1))**(S(1)/3) - log(x)/S(2) + S(3)*log(-(sqrt(x) + S(1))**(S(1)/3) + S(1)) - S(2)*sqrt(S(3))*atan(sqrt(S(3))*(S(2)*(sqrt(x) + S(1))**(S(1)/3) + S(1))/S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(-sqrt(x) + S(1), x), x, -S(2)*x**(S(3)/2)/S(3) + x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(-x**(S(1)/4) + S(1), x), x, -S(4)*x**(S(5)/4)/S(5) + x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-sqrt(x) + S(1))/(x**(S(1)/4) + S(1)), x), x, -S(4)*x**(S(5)/4)/S(5) + x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt((a + b*x)*(c + d*x)), x), x, atanh((a*d + b*c + S(2)*b*d*x)/(S(2)*sqrt(b)*sqrt(d)*sqrt(a*c + b*d*x**S(2) + x*(a*d + b*c))))/(sqrt(b)*sqrt(d)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt((a + b*x)*(c - d*x)), x), x, -atan((-a*d + b*c - S(2)*b*d*x)/(S(2)*sqrt(b)*sqrt(d)*sqrt(a*c - b*d*x**S(2) + x*(-a*d + b*c))))/(sqrt(b)*sqrt(d)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(x)*(-x**S(2) + S(1))), x), x, atan(sqrt(x)) + atanh(sqrt(x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x)/(-x**S(3) + x), x), x, atan(sqrt(x)) + atanh(sqrt(x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(x**S(2) + x*(S(1) + sqrt(S(3))) - sqrt(S(3)) + S(2)), x), x, log(x**S(2) + x*(S(1) + sqrt(S(3))) - sqrt(S(3)) + S(2))/S(2) + sqrt(S(13)/23 + S(8)*sqrt(S(3))/S(23))*atanh((S(2)*x + S(1) + sqrt(S(3)))/sqrt(S(-4) + S(6)*sqrt(S(3)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x**S(3) + x**S(2)), x), x, S(2)*(x**S(3) + x**S(2))**(S(3)/2)/(S(5)*x**S(2)) - S(4)*(x**S(3) + x**S(2))**(S(3)/2)/(S(15)*x**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((x + S(1))*sqrt(x**S(2) + S(2)*x)), x), x, atan(sqrt(x**S(2) + S(2)*x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x)*sqrt(-sqrt(x) - x + S(1)), x), x, -sqrt(x)*(-sqrt(x) - x + S(1))**(S(3)/2)/S(2) + (S(9)*sqrt(x)/S(16) + S(9)/32)*sqrt(-sqrt(x) - x + S(1)) + S(5)*(-sqrt(x) - x + S(1))**(S(3)/2)/S(12) + S(45)*asin(sqrt(S(5))*(S(2)*sqrt(x) + S(1))/S(5))/S(64), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((sqrt(x + S(-3)) + S(1))**(S(1)/3), x), x, S(6)*(sqrt(x + S(-3)) + S(1))**(S(7)/3)/S(7) - S(3)*(sqrt(x + S(-3)) + S(1))**(S(4)/3)/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(sqrt(S(2)*x + S(-1)) + S(3)), x), x, S(2)*(sqrt(S(2)*x + S(-1)) + S(3))**(S(3)/2)/S(3) - S(6)*sqrt(sqrt(S(2)*x + S(-1)) + S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(-x + S(1))/(sqrt(x) + S(1)), x), x, -sqrt(-x + S(1)) - asin(sqrt(x)) - (-x + S(1))**(S(3)/2)/(sqrt(x) + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(-x + S(1))/(-sqrt(x) + S(1)), x), x, -sqrt(-x + S(1)) + asin(sqrt(x)) - (-x + S(1))**(S(3)/2)/(-sqrt(x) + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(x - sqrt(x**S(2) + S(1))), x), x, -x**S(3)/S(3) - (x**S(2) + S(1))**(S(3)/2)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(x - sqrt(-x**S(2) + S(1))), x), x, x/S(2) + sqrt(-x**S(2) + S(1))/S(2) - sqrt(S(2))*atanh(sqrt(S(2))*x)/S(4) - sqrt(S(2))*atanh(sqrt(S(2))*sqrt(-x**S(2) + S(1)))/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(x - sqrt(S(2)*x**S(2) + S(1))), x), x, -x - sqrt(S(2)*x**S(2) + S(1)) + atan(x) + atan(sqrt(S(2)*x**S(2) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x)*sqrt(sqrt(x) + x), x), x, sqrt(x)*(sqrt(x) + x)**(S(3)/2)/S(2) + (S(5)*sqrt(x)/S(16) + S(5)/32)*sqrt(sqrt(x) + x) - S(5)*(sqrt(x) + x)**(S(3)/2)/S(12) - S(5)*atanh(sqrt(x)/sqrt(sqrt(x) + x))/S(32), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**(S(1)/3) + S(1))/(sqrt(x) + S(1)), x), x, S(6)*x**(S(5)/6)/S(5) - S(3)*x**(S(1)/3) + S(2)*sqrt(x) - S(4)*log(x**(S(1)/6) + S(1)) - log(-x**(S(1)/6) + x**(S(1)/3) + S(1)) - S(2)*sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x**(S(1)/6) + S(1))/S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**(S(1)/3) + S(1))/(x**(S(1)/4) + S(1)), x), x, S(12)*x**(S(13)/12)/S(13) + S(12)*x**(S(7)/12)/S(7) + S(12)*x**(S(1)/12) - S(6)*x**(S(5)/6)/S(5) + S(4)*x**(S(3)/4)/S(3) + S(4)*x**(S(1)/4) - S(3)*x**(S(1)/3) - S(2)*sqrt(x) - S(8)*log(x**(S(1)/12) + S(1)) - S(2)*log(-x**(S(1)/12) + x**(S(1)/6) + S(1)) + S(4)*sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x**(S(1)/12) + S(1))/S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(x**S(2) + sqrt(-x**S(2) + S(1)) + S(-1)), x), x, x + asin(x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt((x + S(1))/x), x), x, x*sqrt(S(1) + S(1)/x) + atanh(sqrt(S(1) + S(1)/x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt((-x + S(1))/x), x), x, x*sqrt(S(-1) + S(1)/x) - atan(sqrt(S(-1) + S(1)/x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt((x + S(-1))/x), x), x, sqrt(x)*sqrt(x + S(-1)) - asinh(sqrt(x + S(-1))), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(sqrt((x + S(-1))/x), x), x, x*sqrt(S(1) - S(1)/x) - atanh(sqrt(S(1) - S(1)/x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt((x + S(1))/x)/x, x), x, -S(2)*sqrt(S(1) + S(1)/x) + S(2)*atanh(sqrt(S(1) + S(1)/x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x/(x + S(1))), x), x, sqrt(x)*sqrt(x + S(1)) - asinh(sqrt(x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt((-x + S(-1))/x), x), x, -x*sqrt(S(-1) - S(1)/x) + atan(sqrt(S(-1) - S(1)/x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x*(-x + S(4))), x), x, (x/S(2) + S(-1))*sqrt(-x**S(2) + S(4)*x) + S(2)*asin(x/S(2) + S(-1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(x*(-x + S(1))), x), x, asin(S(2)*x + S(-1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(x*(x + S(2)))**(S(3)/2), x), x, x/sqrt(x**S(2) + S(2)*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(S(1) + S(1)/x)/(-x**S(2) + S(1)), x), x, sqrt(S(2))*atanh(sqrt(S(2))*sqrt(S(1) + S(1)/x)/S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(-x**S(2) + sqrt(S(5))*x**S(2) + S(1) + sqrt(S(5))), x), x, atan(x*sqrt(-sqrt(S(5))/S(2) + S(3)/2))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt((-a + x)*(b - x)), x), x, -(a - b)**S(2)*atan((a + b - S(2)*x)/(S(2)*sqrt(-a*b - x**S(2) + x*(a + b))))/S(8) + (-a/S(4) - b/S(4) + x/S(2))*sqrt(-a*b - x**S(2) + x*(a + b)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt((-a + x)*(b - x)), x), x, -atan((a + b - S(2)*x)/(S(2)*sqrt(-a*b - x**S(2) + x*(a + b)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt((-x**S(2) + S(1))*(x**S(2) + S(3))), x), x, x*sqrt(-x**S(4) - S(2)*x**S(2) + S(3))/S(3) - S(2)*sqrt(S(3))*elliptic_e(asin(x), S(-1)/3)/S(3) + S(4)*sqrt(S(3))*elliptic_f(asin(x), S(-1)/3)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt((-x**S(2) + S(1))*(x**S(2) + S(3))), x), x, sqrt(S(3))*elliptic_f(asin(x), S(-1)/3)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(a*x + b*x**S(2)), x), x, S(2)*atanh(sqrt(b)*x/sqrt(a*x + b*x**S(2)))/sqrt(b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(x*(a + b*x)), x), x, S(2)*atanh(sqrt(b)*x/sqrt(a*x + b*x**S(2)))/sqrt(b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(x**S(2)*(a/x + b)), x), x, S(2)*atanh(sqrt(b)*x/sqrt(a*x + b*x**S(2)))/sqrt(b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(x**S(3)*(a/x**S(2) + b/x)), x), x, S(2)*atanh(sqrt(b)*x/sqrt(a*x + b*x**S(2)))/sqrt(b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt((a*x**S(2) + b*x**S(3))/x), x), x, S(2)*atanh(sqrt(b)*x/sqrt(a*x + b*x**S(2)))/sqrt(b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt((a*x**S(3) + b*x**S(4))/x**S(2)), x), x, S(2)*atanh(sqrt(b)*x/sqrt(a*x + b*x**S(2)))/sqrt(b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(a*c*x + b*c*x**S(2)), x), x, S(2)*atanh(sqrt(b)*sqrt(c)*x/sqrt(a*c*x + b*c*x**S(2)))/(sqrt(b)*sqrt(c)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(c*(a*x + b*x**S(2))), x), x, S(2)*atanh(sqrt(b)*sqrt(c)*x/sqrt(a*c*x + b*c*x**S(2)))/(sqrt(b)*sqrt(c)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(c*x*(a + b*x)), x), x, S(2)*atanh(sqrt(b)*sqrt(c)*x/sqrt(a*c*x + b*c*x**S(2)))/(sqrt(b)*sqrt(c)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(c*x**S(2)*(a/x + b)), x), x, S(2)*atanh(sqrt(b)*sqrt(c)*x/sqrt(a*c*x + b*c*x**S(2)))/(sqrt(b)*sqrt(c)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(-x**S(2) + x*sqrt(x**S(2) + S(-1)) + S(1)), x), x, (S(3)*x/S(4) + sqrt(x**S(2) + S(-1))/S(4))*sqrt(-x**S(2) + x*sqrt(x**S(2) + S(-1)) + S(1)) + S(3)*sqrt(S(2))*asin(x - sqrt(x**S(2) + S(-1)))/S(8), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(sqrt(x)*sqrt(x + S(1)) - x)/sqrt(x + S(1)), x), x, (sqrt(x)/S(2) + S(3)*sqrt(x + S(1))/S(2))*sqrt(sqrt(x)*sqrt(x + S(1)) - x) - S(3)*sqrt(S(2))*asin(sqrt(x) - sqrt(x + S(1)))/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(-(x + S(2)*sqrt(x**S(2) + S(1)))/(x**S(3) + x + sqrt(x**S(2) + S(1))), x), x, -sqrt(S(2) + S(2)*sqrt(S(5)))*atan(sqrt(S(-2) + sqrt(S(5)))*(x + sqrt(x**S(2) + S(1)))) + sqrt(S(-2) + S(2)*sqrt(S(5)))*atanh(sqrt(S(2) + sqrt(S(5)))*(x + sqrt(x**S(2) + S(1)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x + S(1))/((x**S(2) + S(1))*sqrt(x**S(2) + S(2)*x + S(2))), x), x, -sqrt(S(1)/2 + sqrt(S(5))/S(2))*atan((-x*(sqrt(S(5)) + S(5)) + S(2)*sqrt(S(5)))/(sqrt(S(10) + S(10)*sqrt(S(5)))*sqrt(x**S(2) + S(2)*x + S(2)))) - sqrt(S(-1)/2 + sqrt(S(5))/S(2))*atanh((x*(-sqrt(S(5)) + S(5)) + S(2)*sqrt(S(5)))/(sqrt(S(-10) + S(10)*sqrt(S(5)))*sqrt(x**S(2) + S(2)*x + S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(-x**S(2) + sqrt(x**S(4) + S(1)))*(x**S(4) + S(1))), x), x, atan(x/sqrt(-x**S(2) + sqrt(x**S(4) + S(1)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((a + b*x**S(4))*sqrt(c*x**S(2) + d*sqrt(a + b*x**S(4)))), x), x, atanh(sqrt(c)*x/sqrt(c*x**S(2) + d*sqrt(a + b*x**S(4))))/(a*sqrt(c)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((a + b*x**S(4))*sqrt(-c*x**S(2) + d*sqrt(a + b*x**S(4)))), x), x, atan(sqrt(c)*x/sqrt(-c*x**S(2) + d*sqrt(a + b*x**S(4))))/(a*sqrt(c)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/sqrt(a + b*c**S(4) + S(4)*b*c**S(3)*d*x + S(6)*b*c**S(2)*d**S(2)*x**S(2) + S(4)*b*c*d**S(3)*x**S(3) + b*d**S(4)*x**S(4)), x), x, atanh(sqrt(b)*d**S(2)*(c/d + x)**S(2)/sqrt(a + b*d**S(4)*(c/d + x)**S(4)))/(S(2)*sqrt(b)*d**S(2)) - c*sqrt((a + b*d**S(4)*(c/d + x)**S(4))/(sqrt(a) + sqrt(b)*d**S(2)*(c/d + x)**S(2))**S(2))*(sqrt(a) + sqrt(b)*d**S(2)*(c/d + x)**S(2))*elliptic_f(S(2)*atan(b**(S(1)/4)*d*(c/d + x)/a**(S(1)/4)), S(1)/2)/(S(2)*a**(S(1)/4)*b**(S(1)/4)*d**S(2)*sqrt(a + b*d**S(4)*(c/d + x)**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(a + b*c**S(4) + S(4)*b*c**S(3)*d*x + S(6)*b*c**S(2)*d**S(2)*x**S(2) + S(4)*b*c*d**S(3)*x**S(3) + b*d**S(4)*x**S(4)), x), x, sqrt((a + b*d**S(4)*(c/d + x)**S(4))/(sqrt(a) + sqrt(b)*d**S(2)*(c/d + x)**S(2))**S(2))*(sqrt(a) + sqrt(b)*d**S(2)*(c/d + x)**S(2))*elliptic_f(S(2)*atan(b**(S(1)/4)*d*(c/d + x)/a**(S(1)/4)), S(1)/2)/(S(2)*a**(S(1)/4)*b**(S(1)/4)*d*sqrt(a + b*d**S(4)*(c/d + x)**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a - c*x**S(4))/(sqrt(a + b*x**S(2) + c*x**S(4))*(a*d + a*e*x**S(2) + c*d*x**S(4))), x), x, atanh(x*sqrt(-a*e + b*d)/(sqrt(d)*sqrt(a + b*x**S(2) + c*x**S(4))))/(sqrt(d)*sqrt(-a*e + b*d)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a - c*x**S(4))/(sqrt(a - b*x**S(2) + c*x**S(4))*(a*d + a*e*x**S(2) + c*d*x**S(4))), x), x, atan(x*sqrt(a*e + b*d)/(sqrt(d)*sqrt(a - b*x**S(2) + c*x**S(4))))/(sqrt(d)*sqrt(a*e + b*d)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((x**S(3) + S(8))*sqrt(x**S(2) - S(2)*x + S(5))), x), x, -sqrt(S(3))*atan(sqrt(S(3))*(-x + S(1))/(S(3)*sqrt(x**S(2) - S(2)*x + S(5))))/S(12) - sqrt(S(13))*atanh(sqrt(S(13))*(-S(3)*x + S(7))/(S(13)*sqrt(x**S(2) - S(2)*x + S(5))))/S(156) + atanh(sqrt(x**S(2) - S(2)*x + S(5)))/S(12), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x**S(2)/(x**S(2) + S(1))), x), x, sqrt(x**S(2) + S(1))*sqrt(x**S(2))/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x**n/(x**n + S(1))), x), x, S(2)*x*sqrt(x**n)*hyper((S(1)/2, S(1)/2 + S(1)/n), (S(3)/2 + S(1)/n,), -x**n)/(n + S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-e*f*x**S(2) + e*f)/((a*d*x**S(2) + a*d + b*d*x)*sqrt(a*x**S(4) + a + b*x**S(3) + b*x + c*x**S(2))), x), x, e*f*atan((a*b*x**S(2) + a*b + x*(S(4)*a**S(2) - S(2)*a*c + b**S(2)))/(S(2)*a*sqrt(S(2)*a - c)*sqrt(a*x**S(4) + a + b*x**S(3) + b*x + c*x**S(2))))/(a*d*sqrt(S(2)*a - c)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-e*f*x**S(2) + e*f)/((-a*d*x**S(2) - a*d + b*d*x)*sqrt(-a*x**S(4) - a + b*x**S(3) + b*x + c*x**S(2))), x), x, e*f*atanh((a*b*x**S(2) + a*b - x*(S(4)*a**S(2) + S(2)*a*c + b**S(2)))/(S(2)*a*sqrt(S(2)*a + c)*sqrt(-a*x**S(4) - a + b*x**S(3) + b*x + c*x**S(2))))/(a*d*sqrt(S(2)*a + c)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a*x**S(2) + b*x*sqrt(a**S(2)*x**S(2)/b**S(2) - a/b**S(2)))/(x*sqrt(a**S(2)*x**S(2)/b**S(2) - a/b**S(2))), x), x, sqrt(S(2))*b*asinh((a*x + b*sqrt(a**S(2)*x**S(2)/b**S(2) - a/b**S(2)))/sqrt(a))/sqrt(a), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(-a*x**S(2) + b*x*sqrt(a**S(2)*x**S(2)/b**S(2) + a/b**S(2)))/(x*sqrt(a**S(2)*x**S(2)/b**S(2) + a/b**S(2))), x), x, sqrt(S(2))*b*asin((a*x - b*sqrt(a**S(2)*x**S(2)/b**S(2) + a/b**S(2)))/sqrt(a))/sqrt(a), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x*(a*x + b*sqrt(a**S(2)*x**S(2)/b**S(2) - a/b**S(2))))/(x*sqrt(a**S(2)*x**S(2)/b**S(2) - a/b**S(2))), x), x, sqrt(S(2))*b*asinh((a*x + b*sqrt(a**S(2)*x**S(2)/b**S(2) - a/b**S(2)))/sqrt(a))/sqrt(a), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x*(-a*x + b*sqrt(a**S(2)*x**S(2)/b**S(2) + a/b**S(2))))/(x*sqrt(a**S(2)*x**S(2)/b**S(2) + a/b**S(2))), x), x, sqrt(S(2))*b*asin((a*x - b*sqrt(a**S(2)*x**S(2)/b**S(2) + a/b**S(2)))/sqrt(a))/sqrt(a), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x*sqrt(x + S(-4)) + x*sqrt(x + S(-1)) - sqrt(x + S(-4)) - S(4)*sqrt(x + S(-1)))/((x**S(2) - S(5)*x + S(4))*(sqrt(x + S(-4)) + sqrt(x + S(-1)) + S(1))), x), x, S(2)*log(sqrt(x + S(-4)) + sqrt(x + S(-1)) + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(x**S(2) + S(3)*x + S(3))*(x**S(3) + S(3)*x**S(2) + S(3)*x + S(3))**(S(1)/3)), x), x, S(3)**(S(2)/3)*log(-S(3)**(S(1)/3)*(x + S(1))/((x + S(1))**S(3) + S(2))**(S(1)/3) + S(1))/S(9) - S(3)**(S(2)/3)*log(S(3)**(S(2)/3)*(x + S(1))**S(2)/((x + S(1))**S(3) + S(2))**(S(2)/3) + S(3)**(S(1)/3)*(x + S(1))/((x + S(1))**S(3) + S(2))**(S(1)/3) + S(1))/S(18) - S(3)**(S(1)/6)*atan(sqrt(S(3))*(S(2)*S(3)**(S(1)/3)*(x + S(1))/((x + S(1))**S(3) + S(2))**(S(1)/3) + S(1))/S(3))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-x**S(2) + S(1))/((-x**S(3) + S(1))**(S(2)/3)*(x**S(2) - x + S(1))), x), x, S(3)*S(2)**(S(1)/3)*log(S(2)**(S(1)/3)*(-x + S(1)) + (-x**S(3) + S(1))**(S(1)/3))/S(4) - S(2)**(S(1)/3)*log(-x**S(3) + S(2)*(-x + S(1))**S(3) + S(1))/S(4) + S(2)**(S(1)/3)*sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*S(2)**(S(1)/3)*(-x + S(1))/(-x**S(3) + S(1))**(S(1)/3) + S(1))/S(3))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(sqrt(x**S(4) + S(-1))*(x**S(4) + S(1))), x), x, -atan((x**S(2) + S(1))/(x*sqrt(x**S(4) + S(-1))))/S(4) - atanh((-x**S(2) + S(1))/(x*sqrt(x**S(4) + S(-1))))/S(4), expand=True, _diff=True, _numerical=True)
def test_3():
assert rubi_test(rubi_integrate(sqrt(x**S(2) + S(-1))/sqrt(x**S(4) + S(-1)), x), x, sqrt(x**S(2) + S(-1))*sqrt(x**S(2) + S(1))*asinh(x)/sqrt(x**S(4) + S(-1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x**S(2) + S(1))/sqrt(x**S(4) + S(-1)), x), x, -sqrt(x**S(4) + S(-1))*asin(x)/sqrt(-x**S(4) + S(1)), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(sqrt(x**S(2) + S(1))/sqrt(x**S(4) + S(-1)), x), x, sqrt(x**S(2) + S(-1))*sqrt(x**S(2) + S(1))*atanh(x/sqrt(x**S(2) + S(-1)))/sqrt(x**S(4) + S(-1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-sqrt(x**S(2) + S(-1)) + sqrt(x**S(2) + S(1)))/sqrt(x**S(4) + S(-1)), x), x, sqrt(x**S(2) + S(-1))*sqrt(x**S(4) + S(-1))*asinh(x)/((-x**S(2) + S(1))*sqrt(x**S(2) + S(1))) - sqrt(x**S(4) + S(-1))*asin(x)/(sqrt(-x**S(2) + S(1))*sqrt(x**S(2) + S(1))), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate((-sqrt(x**S(2) + S(-1)) + sqrt(x**S(2) + S(1)))/sqrt(x**S(4) + S(-1)), x), x, -sqrt(x**S(2) + S(-1))*sqrt(x**S(2) + S(1))*asinh(x)/sqrt(x**S(4) + S(-1)) + sqrt(x**S(2) + S(-1))*sqrt(x**S(2) + S(1))*atanh(x/sqrt(x**S(2) + S(-1)))/sqrt(x**S(4) + S(-1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(-x**S(2) + S(1))**S(5), x), x, S(1)/(S(8)*(-x**S(2) + S(1))**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(-S(5)/(S(256)*(x + S(1))**S(2)) - S(5)/(S(128)*(x + S(1))**S(3)) - S(3)/(S(64)*(x + S(1))**S(4)) - S(1)/(S(32)*(x + S(1))**S(5)) + S(5)/(S(256)*(x + S(-1))**S(2)) - S(5)/(S(128)*(x + S(-1))**S(3)) + S(3)/(S(64)*(x + S(-1))**S(4)) - S(1)/(S(32)*(x + S(-1))**S(5)), x), x, S(1)/(S(8)*(-x**S(2) + S(1))**S(4)), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(-S(5)/(S(256)*(x + S(1))**S(2)) - S(5)/(S(128)*(x + S(1))**S(3)) - S(3)/(S(64)*(x + S(1))**S(4)) - S(1)/(S(32)*(x + S(1))**S(5)) + S(5)/(S(256)*(x + S(-1))**S(2)) - S(5)/(S(128)*(x + S(-1))**S(3)) + S(3)/(S(64)*(x + S(-1))**S(4)) - S(1)/(S(32)*(x + S(-1))**S(5)), x), x, S(5)/(S(256)*(x + S(1))) + S(5)/(S(256)*(x + S(1))**S(2)) + S(1)/(S(64)*(x + S(1))**S(3)) + S(1)/(S(128)*(x + S(1))**S(4)) + S(5)/(S(256)*(-x + S(1))) + S(5)/(S(256)*(-x + S(1))**S(2)) + S(1)/(S(64)*(-x + S(1))**S(3)) + S(1)/(S(128)*(-x + S(1))**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x + S(2))/(x**S(2) + S(2)*x + S(-1)), x), x, (-sqrt(S(2)) + S(2))*log(x + S(1) + sqrt(S(2)))/S(4) + (sqrt(S(2)) + S(2))*log(x - sqrt(S(2)) + S(1))/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) + S(-4))/(x**S(3) - S(5)*x + S(2)), x), x, (-sqrt(S(2)) + S(2))*log(x + S(1) + sqrt(S(2)))/S(4) + (sqrt(S(2)) + S(2))*log(x - sqrt(S(2)) + S(1))/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x**S(8) + S(1))/(x*(x**S(8) + S(1))**(S(3)/2)), x), x, -atanh(sqrt(x**S(8) + S(1)))/S(4) - S(1)/(S(4)*sqrt(x**S(8) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x**S(8) + S(1))*(S(2)*x**S(8) + S(1))/(x**S(17) + S(2)*x**S(9) + x), x), x, -atanh(sqrt(x**S(8) + S(1)))/S(4) - S(1)/(S(4)*sqrt(x**S(8) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(-S(9)*x**S(2) + x/sqrt(-S(9)*x**S(2) + S(1)) + S(1), x), x, -S(3)*x**S(3) + x - sqrt(-S(9)*x**S(2) + S(1))/S(9), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x + (-S(9)*x**S(2) + S(1))**(S(3)/2))/sqrt(-S(9)*x**S(2) + S(1)), x), x, -S(3)*x**S(3) + x - sqrt(-S(9)*x**S(2) + S(1))/S(9), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-S(3)*sqrt(x) + x)**(S(2)/3)*(S(2)*sqrt(x) + S(-3))/sqrt(x), x), x, S(6)*(-S(3)*sqrt(x) + x)**(S(5)/3)/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-S(9)*sqrt(x) + S(2)*x + S(9))/(-S(3)*sqrt(x) + x)**(S(1)/3), x), x, S(6)*(-S(3)*sqrt(x) + x)**(S(5)/3)/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(2)/(S(4)*x**S(2) + S(-1)), x), x, -atanh(S(2)*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(-S(1)/(S(2)*x + S(1)) + S(1)/(S(2)*x + S(-1)), x), x, log(-S(2)*x + S(1))/S(2) - log(S(2)*x + S(1))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(9)*x**S(2) + S(4)), x), x, asin(S(3)*x/S(2))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(-S(3)*x + S(2))*sqrt(S(3)*x + S(2))), x), x, asin(S(3)*x/S(2))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt((-S(3)*x + S(2))*(S(3)*x + S(2))), x), x, asin(S(3)*x/S(2))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-x**S(2) - S(2)*x + S(15)), x), x, asin(x/S(4) + S(1)/4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(-x + S(3))*sqrt(x + S(5))), x), x, asin(x/S(4) + S(1)/4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt((-x + S(3))*(x + S(5))), x), x, asin(x/S(4) + S(1)/4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-x**S(2) - S(8)*x + S(-15)), x), x, asin(x + S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(-x + S(-3))*sqrt(x + S(5))), x), x, asin(x + S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt((-x + S(-3))*(x + S(5))), x), x, asin(x + S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(-sqrt(x) + S(1), x), x, -S(2)*x**(S(3)/2)/S(3) + x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-x + S(1))/(sqrt(x) + S(1)), x), x, -S(2)*x**(S(3)/2)/S(3) + x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(S(1)/(-x**S(2) + S(1))), x), x, sqrt(-x**S(2) + S(1))*sqrt(S(1)/(-x**S(2) + S(1)))*asin(x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt((x**S(2) + S(1))/(-x**S(4) + S(1))), x), x, sqrt(-x**S(2) + S(1))*sqrt(S(1)/(-x**S(2) + S(1)))*asin(x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(S(1)/(x**S(2) + S(-1))), x), x, sqrt(x**S(2) + S(-1))*sqrt(S(1)/(x**S(2) + S(-1)))*atanh(x/sqrt(x**S(2) + S(-1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt((x**S(2) + S(1))/(x**S(4) + S(-1))), x), x, sqrt(x**S(2) + S(-1))*sqrt(S(1)/(x**S(2) + S(-1)))*atanh(x/sqrt(x**S(2) + S(-1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(6) + S(1))/(x**S(6) + S(-1)), x), x, x + log(x**S(2) - x + S(1))/S(6) - log(x**S(2) + x + S(1))/S(6) + sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x + S(1))/S(3))/S(3) - sqrt(S(3))*atan(sqrt(S(3))*(S(2)*x + S(1))/S(3))/S(3) - S(2)*atanh(x)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(3) + x**(S(-3)))/(x**S(3) - S(1)/x**S(3)), x), x, x + log(x**S(2) - x + S(1))/S(6) - log(x**S(2) + x + S(1))/S(6) + sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x + S(1))/S(3))/S(3) - sqrt(S(3))*atan(sqrt(S(3))*(S(2)*x + S(1))/S(3))/S(3) - S(2)*atanh(x)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-x + S(1)), x), x, -S(2)*sqrt(-x + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x + S(1))/sqrt(-x**S(2) + S(1)), x), x, -S(2)*sqrt(-x + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(x + S(1)), x), x, S(2)*sqrt(x + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(-x + S(1))/sqrt(-x**S(2) + S(1)), x), x, S(2)*sqrt(x + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(-x + S(1)), x), x, -S(2)*(-x + S(1))**(S(3)/2)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(-x**S(2) + S(1))/sqrt(x + S(1)), x), x, -S(2)*(-x + S(1))**(S(3)/2)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x + S(1)), x), x, S(2)*(x + S(1))**(S(3)/2)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(-x**S(2) + S(1))/sqrt(-x + S(1)), x), x, S(2)*(x + S(1))**(S(3)/2)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(S(3)*x + S(2))/sqrt(x + S(1)), x), x, sqrt(x + S(1))*sqrt(S(3)*x + S(2)) - sqrt(S(3))*asinh(sqrt(S(3)*x + S(2)))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(-x + S(1))*sqrt(S(3)*x + S(2))/sqrt(-x**S(2) + S(1)), x), x, sqrt(x + S(1))*sqrt(S(3)*x + S(2)) - sqrt(S(3))*asinh(sqrt(S(3)*x + S(2)))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x + S(1))**(S(3)/2)/(x*(-x + S(1))**(S(3)/2)), x), x, -asin(x) - atanh(sqrt(-x + S(1))*sqrt(x + S(1))) + S(4)*sqrt(x + S(1))/sqrt(-x + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x + S(1))**S(3)/(x*(-x**S(2) + S(1))**(S(3)/2)), x), x, -asin(x) - atanh(sqrt(-x**S(2) + S(1))) + S(4)*sqrt(-x**S(2) + S(1))/(-x + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*x + S(1))**(S(3)/2)/(x*(-a*x + S(1))**(S(3)/2)), x), x, -asin(a*x) - atanh(sqrt(-a*x + S(1))*sqrt(a*x + S(1))) + S(4)*sqrt(a*x + S(1))/sqrt(-a*x + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*x + S(1))**S(3)/(x*(-a**S(2)*x**S(2) + S(1))**(S(3)/2)), x), x, -asin(a*x) - atanh(sqrt(-a**S(2)*x**S(2) + S(1))) + S(4)*sqrt(-a**S(2)*x**S(2) + S(1))/(-a*x + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-x**S(2) + S(1)), x), x, asin(x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x**S(2) + S(1))/sqrt(-x**S(4) + S(1)), x), x, asin(x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(x**S(2) + S(1)), x), x, asinh(x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(-x**S(2) + S(1))/sqrt(-x**S(4) + S(1)), x), x, asinh(x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(-x**S(2) + S(1)), x), x, x*sqrt(-x**S(2) + S(1))/S(2) + asin(x)/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(-x**S(4) + S(1))/sqrt(x**S(2) + S(1)), x), x, x*sqrt(-x**S(2) + S(1))/S(2) + asin(x)/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x**S(2) + S(1)), x), x, x*sqrt(x**S(2) + S(1))/S(2) + asinh(x)/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(-x**S(4) + S(1))/sqrt(-x**S(2) + S(1)), x), x, x*sqrt(x**S(2) + S(1))/S(2) + asinh(x)/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2)*c + a**S(2)*d*x + S(2)*a*b*c*x**S(2) + S(2)*a*b*d*x**S(3) + b**S(2)*c*x**S(4) + b**S(2)*d*x**S(5))/(c + d*x), x), x, a**S(2)*x + S(2)*a*b*x**S(3)/S(3) + b**S(2)*x**S(5)/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2)*c + a**S(2)*d*x + S(2)*a*b*c*x**S(2) + S(2)*a*b*d*x**S(3) + b**S(2)*c*x**S(4) + b**S(2)*d*x**S(5))/(c + d*x)**S(2), x), x, -b**S(2)*c*x**S(3)/(S(3)*d**S(2)) + b**S(2)*x**S(4)/(S(4)*d) - b*c*x*(S(2)*a*d**S(2) + b*c**S(2))/d**S(4) + b*x**S(2)*(S(2)*a*d**S(2) + b*c**S(2))/(S(2)*d**S(3)) + (a*d**S(2) + b*c**S(2))**S(2)*log(c + d*x)/d**S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2)*c + a**S(2)*d*x + S(2)*a*b*c*x**S(2) + S(2)*a*b*d*x**S(3) + b**S(2)*c*x**S(4) + b**S(2)*d*x**S(5))/(a + b*x**S(2)), x), x, a*c*x + a*d*x**S(2)/S(2) + b*c*x**S(3)/S(3) + b*d*x**S(4)/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2)*c + a**S(2)*d*x + S(2)*a*b*c*x**S(2) + S(2)*a*b*d*x**S(3) + b**S(2)*c*x**S(4) + b**S(2)*d*x**S(5))/(a + b*x**S(2))**S(2), x), x, c*x + d*x**S(2)/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2)*c + a**S(2)*d*x + S(2)*a*b*c*x**S(2) + S(2)*a*b*d*x**S(3) + b**S(2)*c*x**S(4) + b**S(2)*d*x**S(5))/(a + b*x**S(2))**S(3), x), x, d*log(a + b*x**S(2))/(S(2)*b) + c*atan(sqrt(b)*x/sqrt(a))/(sqrt(a)*sqrt(b)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(((a + b + c*x**S(2))/d)**m, x), x, d*x*(c*x**S(2)/d + (a + b)/d)**(m + S(1))*hyper((S(1), m + S(3)/2), (S(3)/2,), -c*x**S(2)/(a + b))/(a + b), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(((a + b + c*x**S(2))/d)**m, x), x, x*(c*x**S(2)/d + (a + b)/d)**m*(c*x**S(2)/(a + b) + S(1))**(-m)*hyper((S(1)/2, -m), (S(3)/2,), -c*x**S(2)/(a + b)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x - sqrt(x**S(2) + S(1))), x), x, -x**S(2)/S(2) - x*sqrt(x**S(2) + S(1))/S(2) - asinh(x)/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x - sqrt(-x**S(2) + S(1))), x), x, log(-S(2)*x**S(2) + S(1))/S(4) - asin(x)/S(2) - atanh(x/sqrt(-x**S(2) + S(1)))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x - sqrt(S(2)*x**S(2) + S(1))), x), x, -log(x**S(2) + S(1))/S(2) - sqrt(S(2))*asinh(sqrt(S(2))*x) + atanh(x/sqrt(S(2)*x**S(2) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-x**S(3) + x**S(2)*sqrt(-x**S(2) + S(2)) + S(2)*x)/(S(2)*x**S(2) + S(-2)), x), x, -x**S(2)/S(4) + x*sqrt(-x**S(2) + S(2))/S(4) + log(-x**S(2) + S(1))/S(4) - atanh(x/sqrt(-x**S(2) + S(2)))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*sqrt(-x**S(2) + S(2))/(x - sqrt(-x**S(2) + S(2))), x), x, -x**S(2)/S(4) + x*sqrt(-x**S(2) + S(2))/S(4) + log(-x + S(1))/S(4) + log(x + S(1))/S(4) - atanh(x/sqrt(-x**S(2) + S(2)))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(-x + sqrt(-x**S(2) + S(2)*x)), x), x, -x/S(2) - sqrt(-x**S(2) + S(2)*x)/S(2) - log(-x + S(1))/S(2) + atanh(sqrt(-x**S(2) + S(2)*x))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x + sqrt(-x**S(2) + S(2)*x))/(-S(2)*x + S(2)), x), x, -x/S(2) - sqrt(-x**S(2) + S(2)*x)/S(2) - log(-x + S(1))/S(2) + atanh(sqrt(-x**S(2) + S(2)*x))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((sqrt(x)*sqrt(-x + S(2)) + x)/(-S(2)*x + S(2)), x), x, -x/S(2) - sqrt(-x**S(2) + S(2)*x)/S(2) - log(-x + S(1))/S(2) + atanh(sqrt(-x**S(2) + S(2)*x))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x)/(-sqrt(x) + sqrt(-x + S(2))), x), x, -sqrt(x)*sqrt(-x + S(2))/S(2) - x/S(2) - log(-x + S(1))/S(2) + atanh(sqrt(x)*sqrt(-x + S(2)))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*sqrt(-x + S(3)) + S(3)/sqrt(x + S(1)))**S(2)/x, x), x, -S(4)*x + S(21)*log(x) - S(9)*log(x + S(1)) - S(12)*asin(x/S(2) + S(-1)/2) - S(24)*sqrt(S(3))*atanh(sqrt(S(3))*sqrt(x + S(1))/sqrt(-x + S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) + x + S(-1))/(sqrt(x**S(2) + S(1)) + S(1)), x), x, x*sqrt(x**S(2) + S(1))/S(2) - x + sqrt(x**S(2) + S(1)) - log(sqrt(x**S(2) + S(1)) + S(1)) - asinh(x)/S(2) + sqrt(x**S(2) + S(1))/x - S(1)/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) + x + S(-1))/(x + sqrt(x**S(2) + S(1)) + S(1)), x), x, x**S(3)/S(6) + x**S(2)/S(2) + sqrt(x**S(2) + S(1))*(-S(2)*x**S(2) - S(3)*x + S(4))/S(12) - log(sqrt(x**S(2) + S(1)) + S(1))/S(2) - asinh(x)/S(4), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate((x**S(2) + x + S(-1))/(x + sqrt(x**S(2) + S(1)) + S(1)), x), x, x**S(3)/S(6) + x**S(2)/S(2) - x*sqrt(x**S(2) + S(1))/S(4) + x/S(2) - (x**S(2) + S(1))**(S(3)/2)/S(6) + log(x + sqrt(x**S(2) + S(1)))/S(2) - log(x + sqrt(x**S(2) + S(1)) + S(1)) - asinh(x)/S(4) + S(1)/(S(2)*(x + sqrt(x**S(2) + S(1)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x + S(2)*sqrt(x + S(-1)))/(x*sqrt(x + S(-1))), x), x, S(2)*sqrt(x + S(-1)) + S(2)*log(x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**(S(2)/3) + c*sqrt(x))**S(2), x), x, a**S(2)*x + S(6)*a*b*x**(S(5)/3)/S(5) + S(4)*a*c*x**(S(3)/2)/S(3) + S(3)*b**S(2)*x**(S(7)/3)/S(7) + S(12)*b*c*x**(S(13)/6)/S(13) + c**S(2)*x**S(2)/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**(S(2)/3) + c*sqrt(x))**S(3), x), x, a**S(3)*x + S(9)*a**S(2)*b*x**(S(5)/3)/S(5) + S(2)*a**S(2)*c*x**(S(3)/2) + S(9)*a*b**S(2)*x**(S(7)/3)/S(7) + S(36)*a*b*c*x**(S(13)/6)/S(13) + S(3)*a*c**S(2)*x**S(2)/S(2) + b**S(3)*x**S(3)/S(3) + S(18)*b**S(2)*c*x**(S(17)/6)/S(17) + S(9)*b*c**S(2)*x**(S(8)/3)/S(8) + S(2)*c**S(3)*x**(S(5)/2)/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) + S(-1))/(x**S(3)*sqrt(a - b + b/x**S(2))), x), x, atanh(sqrt(a - b + b/x**S(2))/sqrt(a - b))/sqrt(a - b) + sqrt(a - b + b/x**S(2))/b, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) + S(-1))/(x**S(3)*sqrt(a + b*(S(-1) + x**(S(-2))))), x), x, atanh(sqrt(a - b + b/x**S(2))/sqrt(a - b))/sqrt(a - b) + sqrt(a - b + b/x**S(2))/b, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(c + d*x)**S(2)/(a + b*x**S(3)), x), x, -a**(S(1)/3)*d*(-a**(S(1)/3)*d + S(2)*b**(S(1)/3)*c)*log(a**(S(1)/3) + b**(S(1)/3)*x)/(S(3)*b**(S(5)/3)) + a**(S(1)/3)*d*(-a**(S(1)/3)*d + S(2)*b**(S(1)/3)*c)*log(a**(S(2)/3) - a**(S(1)/3)*b**(S(1)/3)*x + b**(S(2)/3)*x**S(2))/(S(6)*b**(S(5)/3)) + sqrt(S(3))*a**(S(1)/3)*d*(a**(S(1)/3)*d + S(2)*b**(S(1)/3)*c)*atan(sqrt(S(3))*(a**(S(1)/3) - S(2)*b**(S(1)/3)*x)/(S(3)*a**(S(1)/3)))/(S(3)*b**(S(5)/3)) + c**S(2)*log(a + b*x**S(3))/(S(3)*b) + S(2)*c*d*x/b + d**S(2)*x**S(2)/(S(2)*b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x + S(1))/((x**S(2) + S(4))*sqrt(x**S(2) + S(9))), x), x, sqrt(S(5))*atan(sqrt(S(5))*x/(S(2)*sqrt(x**S(2) + S(9))))/S(10) - sqrt(S(5))*atanh(sqrt(S(5))*sqrt(x**S(2) + S(9))/S(5))/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(sqrt(-x**S(2) + S(1)) + S(1)), x), x, x**S(2)/S(2) - (-x**S(2) + S(1))**(S(3)/2)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(sqrt(-x + S(1))*sqrt(x + S(1)) + S(1)), x), x, x**S(2)/S(2) - (-x**S(2) + S(1))**(S(3)/2)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(S(1) + S(1)/(sqrt(x + S(2))*sqrt(x + S(3)))), x), x, x**S(2)/S(2) + sqrt(x + S(2))*sqrt(x + S(3)) - S(5)*asinh(sqrt(x + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x - sqrt(x**S(6)))/(x*(-x**S(4) + S(1))), x), x, atan(x)/S(2) + atanh(x)/S(2) + sqrt(x**S(6))*atan(x)/(S(2)*x**S(3)) - sqrt(x**S(6))*atanh(x)/(S(2)*x**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(1) - sqrt(x**S(6))/x)/(-x**S(4) + S(1)), x), x, atan(x)/S(2) + atanh(x)/S(2) + sqrt(x**S(6))*atan(x)/(S(2)*x**S(3)) - sqrt(x**S(6))*atanh(x)/(S(2)*x**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x - sqrt(x**S(6)))/(-x**S(5) + x), x), x, atan(x)/S(2) + atanh(x)/S(2) + sqrt(x**S(6))*atan(x)/(S(2)*x**S(3)) - sqrt(x**S(6))*atanh(x)/(S(2)*x**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(x + sqrt(x**S(6))), x), x, atan(x)/S(2) + atanh(x)/S(2) + sqrt(x**S(6))*atan(x)/(S(2)*x**S(3)) - sqrt(x**S(6))*atanh(x)/(S(2)*x**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((sqrt(x) - sqrt(x**S(3)))/(-x**S(3) + x), x), x, atan(sqrt(x)) + atanh(sqrt(x)) + sqrt(x**S(3))*atan(sqrt(x))/x**(S(3)/2) - sqrt(x**S(3))*atanh(sqrt(x))/x**(S(3)/2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(x) + sqrt(x**S(3))), x), x, atan(sqrt(x)) + atanh(sqrt(x)) + sqrt(x**S(3))*atan(sqrt(x))/x**(S(3)/2) - sqrt(x**S(3))*atanh(sqrt(x))/x**(S(3)/2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(x + S(-1)) + sqrt((x + S(-1))**S(3))), x), x, atan(sqrt(x + S(-1))) + atanh(sqrt(x + S(-1))) + sqrt((x + S(-1))**S(3))*atan(sqrt(x + S(-1)))/(x + S(-1))**(S(3)/2) - sqrt((x + S(-1))**S(3))*atanh(sqrt(x + S(-1)))/(x + S(-1))**(S(3)/2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-S(4)*x + S(-5))/((S(5)*x + S(4))**S(2)*sqrt(-x**S(2) + S(1))) - S(3)/(S(5)*x + S(4))**S(2), x), x, sqrt(-x**S(2) + S(1))/(S(5)*x + S(4)) + S(3)/(S(5)*(S(5)*x + S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-S(4)*x - S(3)*sqrt(-x**S(2) + S(1)) + S(-5))/((S(5)*x + S(4))**S(2)*sqrt(-x**S(2) + S(1))), x), x, sqrt(-x**S(2) + S(1))/(S(5)*x + S(4)) + S(3)/(S(5)*(S(5)*x + S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(-S(3)*x**S(2) + (-S(4)*x + S(-5))*sqrt(-x**S(2) + S(1)) + S(3)), x), x, sqrt(-x**S(2) + S(1))/(S(5)*x + S(4)) + S(3)/(S(5)*(S(5)*x + S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(-S(3)*x**S(2) - S(4)*x*sqrt(-x**S(2) + S(1)) - S(5)*sqrt(-x**S(2) + S(1)) + S(3)), x), x, sqrt(-x**S(2) + S(1))/(S(5)*x + S(4)) + S(3)/(S(5)*(S(5)*x + S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((sqrt(-x**S(2) + S(1)) + S(-1))/(sqrt(-x**S(2) + S(1))*(x - S(2)*sqrt(-x**S(2) + S(1)) + S(2))**S(2)), x), x, sqrt(-x**S(2) + S(1))/(S(5)*x + S(4)) + S(3)/(S(5)*(S(5)*x + S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**(n + S(-1)))/(c*x + d*x**n), x), x, b*log(x)/d - (-a*d + b*c)*log(c*x**(-n + S(1)) + d)/(c*d*(-n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(4)*x**S(5) + S(2)*x**S(3) - x)/(x**S(4) + S(2)*x**S(2) + S(3))**S(2), x), x, (-S(7)*x**S(2)/S(8) + S(5)/8)/(x**S(4) + S(2)*x**S(2) + S(3)) + S(9)*sqrt(S(2))*atan(sqrt(S(2))*(x**S(2) + S(1))/S(2))/S(16), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(5) + x)/(S(2)*x**S(4) + S(2)*x**S(2) + S(1))**S(3), x), x, (x**S(2)/S(4) + S(3)/16)/(S(2)*x**S(4) + S(2)*x**S(2) + S(1))**S(2) + (x**S(2) + S(1)/2)/(S(2)*x**S(4) + S(2)*x**S(2) + S(1)) + atan(S(2)*x**S(2) + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x + c*x**S(2))/(d + e*x**S(2) + f*x**S(4)), x), x, -b*atanh((e + S(2)*f*x**S(2))/sqrt(-S(4)*d*f + e**S(2)))/sqrt(-S(4)*d*f + e**S(2)) + sqrt(S(2))*(c + (-S(2)*a*f + c*e)/sqrt(-S(4)*d*f + e**S(2)))*atan(sqrt(S(2))*sqrt(f)*x/sqrt(e + sqrt(-S(4)*d*f + e**S(2))))/(S(2)*sqrt(f)*sqrt(e + sqrt(-S(4)*d*f + e**S(2)))) + sqrt(S(2))*(c + (S(2)*a*f - c*e)/sqrt(-S(4)*d*f + e**S(2)))*atan(sqrt(S(2))*sqrt(f)*x/sqrt(e - sqrt(-S(4)*d*f + e**S(2))))/(S(2)*sqrt(f)*sqrt(e - sqrt(-S(4)*d*f + e**S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x)**S(2)/(a + b*x**S(2) + c*x**S(4)), x), x, -S(2)*d*e*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/sqrt(-S(4)*a*c + b**S(2)) + sqrt(S(2))*(e**S(2) + (b*e**S(2) - S(2)*c*d**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(c)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))) + sqrt(S(2))*(e**S(2) + (-b*e**S(2) + S(2)*c*d**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(c)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(S(2)*x**S(2) + S(1))/(sqrt(S(2)*x**S(2) + S(1)) + S(1)), x), x, x - sqrt(S(2))*asinh(sqrt(S(2))*x)/S(2) + sqrt(S(2)*x**S(2) + S(1))/(S(2)*x) - S(1)/(S(2)*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(S(4)*x**S(2) + S(-1))/(x + sqrt(S(4)*x**S(2) + S(-1))), x), x, S(4)*x/S(3) - sqrt(S(4)*x**S(2) + S(-1))/S(3) - sqrt(S(3))*atanh(sqrt(S(3))*x)/S(9) + sqrt(S(3))*atanh(sqrt(S(3))*sqrt(S(4)*x**S(2) + S(-1)))/S(9), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/((a + b*x)*(c + d*x)), x), x, a**S(2)*log(a + b*x)/(b**S(2)*(-a*d + b*c)) - c**S(2)*log(c + d*x)/(d**S(2)*(-a*d + b*c)) + x/(b*d), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/((a + b*x**S(2))*(c + d*x)), x), x, -sqrt(a)*c*atan(sqrt(b)*x/sqrt(a))/(sqrt(b)*(a*d**S(2) + b*c**S(2))) + a*d*log(a + b*x**S(2))/(S(2)*b*(a*d**S(2) + b*c**S(2))) + c**S(2)*log(c + d*x)/(d*(a*d**S(2) + b*c**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/((a + b*x**S(3))*(c + d*x)), x), x, a**(S(1)/3)*d*(a**(S(1)/3)*d + b**(S(1)/3)*c)*log(a**(S(1)/3) + b**(S(1)/3)*x)/(S(3)*b**(S(2)/3)*(-a*d**S(3) + b*c**S(3))) - a**(S(1)/3)*d*(a**(S(1)/3)*d + b**(S(1)/3)*c)*log(a**(S(2)/3) - a**(S(1)/3)*b**(S(1)/3)*x + b**(S(2)/3)*x**S(2))/(S(6)*b**(S(2)/3)*(-a*d**S(3) + b*c**S(3))) - sqrt(S(3))*a**(S(1)/3)*d*atan(sqrt(S(3))*(a**(S(1)/3) - S(2)*b**(S(1)/3)*x)/(S(3)*a**(S(1)/3)))/(S(3)*b**(S(2)/3)*(a**(S(2)/3)*d**S(2) + a**(S(1)/3)*b**(S(1)/3)*c*d + b**(S(2)/3)*c**S(2))) + c**S(2)*log(a + b*x**S(3))/(S(3)*(-a*d**S(3) + b*c**S(3))) - c**S(2)*log(c + d*x)/(-a*d**S(3) + b*c**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/((a + b*x**S(4))*(c + d*x)), x), x, sqrt(a)*d**S(3)*atan(sqrt(b)*x**S(2)/sqrt(a))/(S(2)*sqrt(b)*(a*d**S(4) + b*c**S(4))) - c**S(2)*d*log(a + b*x**S(4))/(S(4)*(a*d**S(4) + b*c**S(4))) + c**S(2)*d*log(c + d*x)/(a*d**S(4) + b*c**S(4)) - sqrt(S(2))*c*(-sqrt(a)*d**S(2) + sqrt(b)*c**S(2))*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*x/a**(S(1)/4))/(S(4)*a**(S(1)/4)*b**(S(1)/4)*(a*d**S(4) + b*c**S(4))) + sqrt(S(2))*c*(-sqrt(a)*d**S(2) + sqrt(b)*c**S(2))*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*x/a**(S(1)/4))/(S(4)*a**(S(1)/4)*b**(S(1)/4)*(a*d**S(4) + b*c**S(4))) + sqrt(S(2))*c*(sqrt(a)*d**S(2) + sqrt(b)*c**S(2))*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*x + sqrt(a) + sqrt(b)*x**S(2))/(S(8)*a**(S(1)/4)*b**(S(1)/4)*(a*d**S(4) + b*c**S(4))) - sqrt(S(2))*c*(sqrt(a)*d**S(2) + sqrt(b)*c**S(2))*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*x + sqrt(a) + sqrt(b)*x**S(2))/(S(8)*a**(S(1)/4)*b**(S(1)/4)*(a*d**S(4) + b*c**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/((-x + S(1))*(x + S(1))**S(2)), x), x, atanh(x)/S(2) + S(1)/(S(2)*(x + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/((-x**S(2) + S(1))*(x**S(2) + S(1))**S(2)), x), x, -x/(S(4)*(x**S(2) + S(1))) + atanh(x)/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/((-x**S(3) + S(1))*(x**S(3) + S(1))**S(2)), x), x, -x/(S(6)*(x**S(3) + S(1))) - log(-x + S(1))/S(12) - log(x + S(1))/S(36) + log(x**S(2) - x + S(1))/S(72) + log(x**S(2) + x + S(1))/S(24) + sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x + S(1))/S(3))/S(36) + sqrt(S(3))*atan(sqrt(S(3))*(S(2)*x + S(1))/S(3))/S(12), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x + c*x**S(2))/((d + e*x)**S(3)*sqrt(x**S(2) + S(-1))), x), x, (a*(S(2)*d**S(2) + e**S(2))/S(2) - S(3)*b*d*e/S(2) + c*(d**S(2) + S(2)*e**S(2))/S(2))*atanh((d*x + e)/(sqrt(d**S(2) - e**S(2))*sqrt(x**S(2) + S(-1))))/(d**S(2) - e**S(2))**(S(5)/2) + sqrt(x**S(2) + S(-1))*(c*(d**S(3) - S(4)*d*e**S(2))/S(2) - e*(S(3)*a*d*e - b*(d**S(2) + S(2)*e**S(2)))/S(2))/(e*(d + e*x)*(d**S(2) - e**S(2))**S(2)) - sqrt(x**S(2) + S(-1))*(a*e**S(2)/S(2) - b*d*e/S(2) + c*d**S(2)/S(2))/(e*(d + e*x)**S(2)*(d**S(2) - e**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x + c*x**S(2))/((d + e*x)**S(3)*sqrt(x + S(-1))*sqrt(x + S(1))), x), x, (-S(3)*b*d*e + d**S(2)*(S(2)*a + c) + e**S(2)*(a + S(2)*c))*atanh(sqrt(d + e)*sqrt(x + S(1))/(sqrt(d - e)*sqrt(x + S(-1))))/((d - e)**(S(5)/2)*(d + e)**(S(5)/2)) + sqrt(x + S(-1))*sqrt(x + S(1))*(b*d**S(2)*e/S(2) + b*e**S(3) + c*d**S(3)/S(2) - d*e**S(2)*(S(3)*a + S(4)*c)/S(2))/(e*(d + e*x)*(d**S(2) - e**S(2))**S(2)) - sqrt(x + S(-1))*sqrt(x + S(1))*(a*e**S(2)/S(2) - b*d*e/S(2) + c*d**S(2)/S(2))/(e*(d + e*x)**S(2)*(d**S(2) - e**S(2))), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate((a + b*x + c*x**S(2))/((d + e*x)**S(3)*sqrt(x + S(-1))*sqrt(x + S(1))), x), x, S(2)*c*atanh(sqrt(d + e)*sqrt(x + S(1))/(sqrt(d - e)*sqrt(x + S(-1))))/(e**S(2)*sqrt(d - e)*sqrt(d + e)) - S(3)*d*sqrt(x + S(-1))*sqrt(x + S(1))*(a*e**S(2) - b*d*e + c*d**S(2))/(S(2)*e*(d + e*x)*(d**S(2) - e**S(2))**S(2)) - S(2)*d*(-b*e + S(2)*c*d)*atanh(sqrt(d + e)*sqrt(x + S(1))/(sqrt(d - e)*sqrt(x + S(-1))))/(e**S(2)*(d - e)**(S(3)/2)*(d + e)**(S(3)/2)) + sqrt(x + S(-1))*sqrt(x + S(1))*(-b*e + S(2)*c*d)/(e*(d + e*x)*(d**S(2) - e**S(2))) - sqrt(x + S(-1))*sqrt(x + S(1))*(a*e**S(2)/S(2) - b*d*e/S(2) + c*d**S(2)/S(2))/(e*(d + e*x)**S(2)*(d**S(2) - e**S(2))) + (S(2)*d**S(2) + e**S(2))*(a*e**S(2) - b*d*e + c*d**S(2))*atanh(sqrt(d + e)*sqrt(x + S(1))/(sqrt(d - e)*sqrt(x + S(-1))))/(e**S(2)*(d - e)**(S(5)/2)*(d + e)**(S(5)/2)), expand=True, _diff=True, _numerical=True)
def test_4():
assert rubi_test(rubi_integrate((b + S(2)*c*x + S(3)*d*x**S(2))*(a + b*x + c*x**S(2) + d*x**S(3))**n, x), x, (a + b*x + c*x**S(2) + d*x**S(3))**(n + S(1))/(n + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b + S(2)*c*x + S(3)*d*x**S(2))*(b*x + c*x**S(2) + d*x**S(3))**n, x), x, (b*x + c*x**S(2) + d*x**S(3))**(n + S(1))/(n + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**n*(b + c*x + d*x**S(2))**n*(b + S(2)*c*x + S(3)*d*x**S(2)), x), x, x**(n + S(1))*(b + c*x + d*x**S(2))**(n + S(1))/(n + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b + S(3)*d*x**S(2))*(a + b*x + d*x**S(3))**n, x), x, (a + b*x + d*x**S(3))**(n + S(1))/(n + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b + S(3)*d*x**S(2))*(b*x + d*x**S(3))**n, x), x, (b*x + d*x**S(3))**(n + S(1))/(n + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**n*(b + d*x**S(2))**n*(b + S(3)*d*x**S(2)), x), x, x**(n + S(1))*(b + d*x**S(2))**(n + S(1))/(n + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*c*x + S(3)*d*x**S(2))*(a + c*x**S(2) + d*x**S(3))**n, x), x, (a + c*x**S(2) + d*x**S(3))**(n + S(1))/(n + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*c*x + S(3)*d*x**S(2))*(c*x**S(2) + d*x**S(3))**n, x), x, (c*x**S(2) + d*x**S(3))**(n + S(1))/(n + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**n*(c*x + d*x**S(2))**n*(S(2)*c*x + S(3)*d*x**S(2)), x), x, x**(n + S(1))*(c*x + d*x**S(2))**(n + S(1))/(n + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(2)*n)*(c + d*x)**n*(S(2)*c*x + S(3)*d*x**S(2)), x), x, x**(S(2)*n + S(2))*(c + d*x)**(n + S(1))/(n + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(S(2)*c + S(3)*d*x)*(a + c*x**S(2) + d*x**S(3))**n, x), x, (a + c*x**S(2) + d*x**S(3))**(n + S(1))/(n + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(S(2)*c + S(3)*d*x)*(c*x**S(2) + d*x**S(3))**n, x), x, (c*x**S(2) + d*x**S(3))**(n + S(1))/(n + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b + S(2)*c*x + S(3)*d*x**S(2))*(a + b*x + c*x**S(2) + d*x**S(3))**S(7), x), x, (a + b*x + c*x**S(2) + d*x**S(3))**S(8)/S(8), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b + S(2)*c*x + S(3)*d*x**S(2))*(b*x + c*x**S(2) + d*x**S(3))**S(7), x), x, x**S(8)*(b + c*x + d*x**S(2))**S(8)/S(8), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(7)*(b + c*x + d*x**S(2))**S(7)*(b + S(2)*c*x + S(3)*d*x**S(2)), x), x, x**S(8)*(b + c*x + d*x**S(2))**S(8)/S(8), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b + S(3)*d*x**S(2))*(a + b*x + d*x**S(3))**S(7), x), x, (a + b*x + d*x**S(3))**S(8)/S(8), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(7)*(b + d*x**S(2))**S(7)*(b + S(3)*d*x**S(2)), x), x, x**S(8)*(b + d*x**S(2))**S(8)/S(8), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b + S(3)*d*x**S(2))*(b*x + d*x**S(3))**S(7), x), x, x**S(8)*(b + d*x**S(2))**S(8)/S(8), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*c*x + S(3)*d*x**S(2))*(a + c*x**S(2) + d*x**S(3))**S(7), x), x, (a + c*x**S(2) + d*x**S(3))**S(8)/S(8), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*c*x + S(3)*d*x**S(2))*(c*x**S(2) + d*x**S(3))**S(7), x), x, x**S(16)*(c + d*x)**S(8)/S(8), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(7)*(c*x + d*x**S(2))**S(7)*(S(2)*c*x + S(3)*d*x**S(2)), x), x, x**S(16)*(c + d*x)**S(8)/S(8), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(14)*(c + d*x)**S(7)*(S(2)*c*x + S(3)*d*x**S(2)), x), x, x**S(16)*(c + d*x)**S(8)/S(8), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(S(2)*c + S(3)*d*x)*(a + c*x**S(2) + d*x**S(3))**S(7), x), x, (a + c*x**S(2) + d*x**S(3))**S(8)/S(8), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(S(2)*c + S(3)*d*x)*(c*x**S(2) + d*x**S(3))**S(7), x), x, x**S(16)*(c + d*x)**S(8)/S(8), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(8)*(S(2)*c + S(3)*d*x)*(c*x + d*x**S(2))**S(7), x), x, x**S(16)*(c + d*x)**S(8)/S(8), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(15)*(c + d*x)**S(7)*(S(2)*c + S(3)*d*x), x), x, x**S(16)*(c + d*x)**S(8)/S(8), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x)*((a*x + b*x**S(2)/S(2))**S(4) + S(1)), x), x, a*x + b*x**S(2)/S(2) + (a*x + b*x**S(2)/S(2))**S(5)/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x)*((a*x + b*x**S(2)/S(2) + c)**S(4) + S(1)), x), x, a*x + b*x**S(2)/S(2) + (a*x + b*x**S(2)/S(2) + c)**S(5)/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x)*((a*x + b*x**S(2)/S(2))**n + S(1)), x), x, a*x + b*x**S(2)/S(2) + (a*x + b*x**S(2)/S(2))**(n + S(1))/(n + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x)*((a*x + b*x**S(2)/S(2) + c)**n + S(1)), x), x, a*x + b*x**S(2)/S(2) + (a*x + b*x**S(2)/S(2) + c)**(n + S(1))/(n + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + c*x**S(2))*((a*x + c*x**S(3)/S(3))**S(5) + S(1)), x), x, a*x + c*x**S(3)/S(3) + (a*x + c*x**S(3)/S(3))**S(6)/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + c*x**S(2))*((a*x + c*x**S(3)/S(3) + d)**S(5) + S(1)), x), x, a*x + c*x**S(3)/S(3) + (a*x + c*x**S(3)/S(3) + d)**S(6)/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x + c*x**S(2))*((b*x**S(2)/S(2) + c*x**S(3)/S(3))**S(5) + S(1)), x), x, b*x**S(2)/S(2) + c*x**S(3)/S(3) + (b*x**S(2)/S(2) + c*x**S(3)/S(3))**S(6)/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x + c*x**S(2))*((b*x**S(2)/S(2) + c*x**S(3)/S(3) + d)**S(5) + S(1)), x), x, b*x**S(2)/S(2) + c*x**S(3)/S(3) + (b*x**S(2)/S(2) + c*x**S(3)/S(3) + d)**S(6)/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(((a*x + b*x**S(2)/S(2) + c*x**S(3)/S(3))**S(5) + S(1))*(a + b*x + c*x**S(2)), x), x, a*x + b*x**S(2)/S(2) + c*x**S(3)/S(3) + (a*x + b*x**S(2)/S(2) + c*x**S(3)/S(3))**S(6)/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(((a*x + b*x**S(2)/S(2) + c*x**S(3)/S(3) + d)**S(5) + S(1))*(a + b*x + c*x**S(2)), x), x, a*x + b*x**S(2)/S(2) + c*x**S(3)/S(3) + (a*x + b*x**S(2)/S(2) + c*x**S(3)/S(3) + d)**S(6)/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + c*x**S(2))*((a*x + c*x**S(3)/S(3))**n + S(1)), x), x, a*x + c*x**S(3)/S(3) + (a*x + c*x**S(3)/S(3))**(n + S(1))/(n + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x + c*x**S(2))*((b*x**S(2)/S(2) + c*x**S(3)/S(3))**n + S(1)), x), x, b*x**S(2)/S(2) + c*x**S(3)/S(3) + (b*x**S(2)/S(2) + c*x**S(3)/S(3))**(n + S(1))/(n + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(((a*x + b*x**S(2)/S(2) + c*x**S(3)/S(3))**n + S(1))*(a + b*x + c*x**S(2)), x), x, a*x + b*x**S(2)/S(2) + c*x**S(3)/S(3) + (a*x + b*x**S(2)/S(2) + c*x**S(3)/S(3))**(n + S(1))/(n + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b + S(2)*c*x)*(b*x + c*x**S(2))**S(13), x), x, (b*x + c*x**S(2))**S(14)/S(14), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(14)*(b + S(2)*c*x**S(2))*(b*x + c*x**S(3))**S(13), x), x, x**S(28)*(b + c*x**S(2))**S(14)/S(28), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(28)*(b + S(2)*c*x**S(3))*(b*x + c*x**S(4))**S(13), x), x, x**S(42)*(b + c*x**S(3))**S(14)/S(42), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(14)*n + S(-14))*(b + S(2)*c*x**n)*(b*x + c*x**(n + S(1)))**S(13), x), x, x**(S(14)*n)*(b + c*x**n)**S(14)/(S(14)*n), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b + S(2)*c*x)/(b*x + c*x**S(2)), x), x, log(b*x + c*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b + S(2)*c*x**S(2))/(b*x + c*x**S(3)), x), x, log(x) + log(b + c*x**S(2))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b + S(2)*c*x**S(3))/(b*x + c*x**S(4)), x), x, log(x) + log(b + c*x**S(3))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b + S(2)*c*x**n)/(b*x + c*x**(n + S(1))), x), x, log(x) + log(b + c*x**n)/n, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b + S(2)*c*x)/(b*x + c*x**S(2))**S(8), x), x, -S(1)/(S(7)*(b*x + c*x**S(2))**S(7)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b + S(2)*c*x**S(2))/(x**S(7)*(b*x + c*x**S(3))**S(8)), x), x, -S(1)/(S(14)*x**S(14)*(b + c*x**S(2))**S(7)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b + S(2)*c*x**S(3))/(x**S(14)*(b*x + c*x**S(4))**S(8)), x), x, -S(1)/(S(21)*x**S(21)*(b + c*x**S(3))**S(7)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(-S(7)*n + S(7))*(b + S(2)*c*x**n)/(b*x + c*x**(n + S(1)))**S(8), x), x, -x**(-S(7)*n)/(S(7)*n*(b + c*x**n)**S(7)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b + S(2)*c*x)*(b*x + c*x**S(2))**p, x), x, (b*x + c*x**S(2))**(p + S(1))/(p + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(p + S(1))*(b + S(2)*c*x**S(2))*(b*x + c*x**S(3))**p, x), x, x**(p + S(1))*(b*x + c*x**S(3))**(p + S(1))/(S(2)*p + S(2)), expand=True, _diff=True, _numerical=True)
# fails in mathematica too assert rubi_test(rubi_integrate(b*x**(p + S(1))*(b*x + c*x**S(3))**p + S(2)*c*x**(p + S(3))*(b*x + c*x**S(3))**p, x), x, x**(p + S(1))*(b*x + c*x**S(3))**(p + S(1))/(S(2)*p + S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(2)*p + S(2))*(b + S(2)*c*x**S(3))*(b*x + c*x**S(4))**p, x), x, x**(S(2)*p + S(2))*(b*x + c*x**S(4))**(p + S(1))/(S(3)*p + S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**((n + S(-1))*(p + S(1)))*(b + S(2)*c*x**n)*(b*x + c*x**(n + S(1)))**p, x), x, x**(-(-n + S(1))*(p + S(1)))*(b*x + c*x**(n + S(1)))**(p + S(1))/(n*(p + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) + S(4)*x + S(-4))*(x**S(3) + S(6)*x**S(2) - S(12)*x + S(5)), x), x, (x**S(3) + S(6)*x**S(2) - S(12)*x + S(5))**S(2)/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(3) + S(2)*x)*(x**S(4) + S(4)*x**S(2) + S(1)), x), x, (x**S(4) + S(4)*x**S(2) + S(1))**S(2)/S(8), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x + S(1))*(x**S(2) + x)**S(3)*(S(7)*(x**S(2) + x)**S(3) + S(-18))**S(2), x), x, S(49)*x**S(10)*(x + S(1))**S(10)/S(10) - S(36)*x**S(7)*(x + S(1))**S(7) + S(81)*x**S(4)*(x + S(1))**S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(x + S(1))**S(3)*(S(2)*x + S(1))*(S(7)*x**S(3)*(x + S(1))**S(3) + S(-18))**S(2), x), x, S(49)*x**S(10)*(x + S(1))**S(10)/S(10) - S(36)*x**S(7)*(x + S(1))**S(7) + S(81)*x**S(4)*(x + S(1))**S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-x**S(2) + S(2))/(x**S(3) - S(6)*x + S(1))**S(5), x), x, S(1)/(S(12)*(x**S(3) - S(6)*x + S(1))**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) + S(2)*x)/(x**S(3) + S(3)*x**S(2) + S(4)), x), x, log(x**S(3) + S(3)*x**S(2) + S(4))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(3) + x + S(1))/(x**S(4) + S(2)*x**S(2) + S(4)*x), x), x, log(x*(x**S(3) + S(2)*x + S(4)))/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(3) + S(-1))/(x**S(4) - S(4)*x)**(S(2)/3), x), x, S(3)*(x**S(4) - S(4)*x)**(S(1)/3)/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-x**S(2) + S(2))*(-x**S(3) + S(6)*x)**(S(1)/4), x), x, S(4)*(-x**S(3) + S(6)*x)**(S(5)/4)/S(15), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(4) + S(1))*sqrt(x**S(5) + S(5)*x), x), x, S(2)*(x**S(5) + S(5)*x)**(S(3)/2)/S(15), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(5)*x**S(4) + S(2))*sqrt(x**S(5) + S(2)*x), x), x, S(2)*(x**S(5) + S(2)*x)**(S(3)/2)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(3)*x**S(2) + x)/sqrt(S(2)*x**S(3) + x**S(2)), x), x, sqrt(S(2)*x**S(3) + x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(((-S(5)*x + S(1))**(S(1)/3) + S(2))/((-S(5)*x + S(1))**(S(1)/3) + S(3)), x), x, x + S(3)*(-S(5)*x + S(1))**(S(2)/3)/S(10) - S(9)*(-S(5)*x + S(1))**(S(1)/3)/S(5) + S(27)*log((-S(5)*x + S(1))**(S(1)/3) + S(3))/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((sqrt(x) + S(1))/(sqrt(x) + S(-1)), x), x, S(4)*sqrt(x) + x + S(4)*log(-sqrt(x) + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-sqrt(S(3)*x + S(2)) + S(1))/(sqrt(S(3)*x + S(2)) + S(1)), x), x, -x + S(4)*sqrt(S(3)*x + S(2))/S(3) - S(4)*log(sqrt(S(3)*x + S(2)) + S(1))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((sqrt(a + b*x) + S(-1))/(sqrt(a + b*x) + S(1)), x), x, x - S(4)*sqrt(a + b*x)/b + S(4)*log(sqrt(a + b*x) + S(1))/b, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*n*x**(n + S(-1)))/(a*x + b*x**n), x), x, log(a*x + b*x**n), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate((a + b*n*x**(n + S(-1)))/(a*x + b*x**n), x), x, n*log(x) + log(a*x**(-n + S(1)) + b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(-n)*(a + b*n*x**(n + S(-1)))/(a*x**(-n + S(1)) + b), x), x, n*log(x) + log(a*x**(-n + S(1)) + b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(a + b*(c + d*x)**S(3)), x), x, -c*log(a + b*(c + d*x)**S(3))/(b*d**S(4)) + x/(b*d**S(3)) + sqrt(S(3))*(-S(3)*a**(S(1)/3)*b**(S(2)/3)*c**S(2) + a + b*c**S(3))*atan(sqrt(S(3))*(a**(S(1)/3) - S(2)*b**(S(1)/3)*(c + d*x))/(S(3)*a**(S(1)/3)))/(S(3)*a**(S(2)/3)*b**(S(4)/3)*d**S(4)) - (S(3)*a**(S(1)/3)*b**(S(2)/3)*c**S(2) + a + b*c**S(3))*log(a**(S(1)/3) + b**(S(1)/3)*(c + d*x))/(S(3)*a**(S(2)/3)*b**(S(4)/3)*d**S(4)) + (S(3)*a**(S(1)/3)*b**(S(2)/3)*c**S(2) + a + b*c**S(3))*log(a**(S(2)/3) - a**(S(1)/3)*b**(S(1)/3)*(c + d*x) + b**(S(2)/3)*(c + d*x)**S(2))/(S(6)*a**(S(2)/3)*b**(S(4)/3)*d**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(a + b*(c + d*x)**S(3)), x), x, log(a + b*(c + d*x)**S(3))/(S(3)*b*d**S(3)) + sqrt(S(3))*c*(S(2)*a**(S(1)/3) - b**(S(1)/3)*c)*atan(sqrt(S(3))*(a**(S(1)/3) - S(2)*b**(S(1)/3)*(c + d*x))/(S(3)*a**(S(1)/3)))/(S(3)*a**(S(2)/3)*b**(S(2)/3)*d**S(3)) + c*(S(2)*a**(S(1)/3) + b**(S(1)/3)*c)*log(a**(S(1)/3) + b**(S(1)/3)*(c + d*x))/(S(3)*a**(S(2)/3)*b**(S(2)/3)*d**S(3)) - c*(S(2)*a**(S(1)/3) + b**(S(1)/3)*c)*log(a**(S(2)/3) - a**(S(1)/3)*b**(S(1)/3)*(c + d*x) + b**(S(2)/3)*(c + d*x)**S(2))/(S(6)*a**(S(2)/3)*b**(S(2)/3)*d**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(a + b*(c + d*x)**S(3)), x), x, -sqrt(S(3))*(a**(S(1)/3) - b**(S(1)/3)*c)*atan(sqrt(S(3))*(a**(S(1)/3) - S(2)*b**(S(1)/3)*(c + d*x))/(S(3)*a**(S(1)/3)))/(S(3)*a**(S(2)/3)*b**(S(2)/3)*d**S(2)) - (a**(S(1)/3) + b**(S(1)/3)*c)*log(a**(S(1)/3) + b**(S(1)/3)*(c + d*x))/(S(3)*a**(S(2)/3)*b**(S(2)/3)*d**S(2)) + (a**(S(1)/3) + b**(S(1)/3)*c)*log(a**(S(2)/3) - a**(S(1)/3)*b**(S(1)/3)*(c + d*x) + b**(S(2)/3)*(c + d*x)**S(2))/(S(6)*a**(S(2)/3)*b**(S(2)/3)*d**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(a + b*(c + d*x)**S(3)), x), x, log(a**(S(1)/3) + b**(S(1)/3)*(c + d*x))/(S(3)*a**(S(2)/3)*b**(S(1)/3)*d) - log(a**(S(2)/3) - a**(S(1)/3)*b**(S(1)/3)*(c + d*x) + b**(S(2)/3)*(c + d*x)**S(2))/(S(6)*a**(S(2)/3)*b**(S(1)/3)*d) - sqrt(S(3))*atan(sqrt(S(3))*(a**(S(1)/3) - S(2)*b**(S(1)/3)*(c + d*x))/(S(3)*a**(S(1)/3)))/(S(3)*a**(S(2)/3)*b**(S(1)/3)*d), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(a + b*(c + d*x)**S(3))), x), x, log(x)/(a + b*c**S(3)) + sqrt(S(3))*b**(S(1)/3)*c*atan(sqrt(S(3))*(a**(S(1)/3) - S(2)*b**(S(1)/3)*(c + d*x))/(S(3)*a**(S(1)/3)))/(S(3)*a**(S(2)/3)*(a**(S(2)/3) - a**(S(1)/3)*b**(S(1)/3)*c + b**(S(2)/3)*c**S(2))) - (S(2)*a**(S(1)/3) - b**(S(1)/3)*c)*log(a**(S(2)/3) - a**(S(1)/3)*b**(S(1)/3)*(c + d*x) + b**(S(2)/3)*(c + d*x)**S(2))/(S(6)*a**(S(2)/3)*(a**(S(2)/3) - a**(S(1)/3)*b**(S(1)/3)*c + b**(S(2)/3)*c**S(2))) - log(a**(S(1)/3) + b**(S(1)/3)*(c + d*x))/(S(3)*a**(S(2)/3)*(a**(S(1)/3) + b**(S(1)/3)*c)), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(S(1)/(x*(a + b*(c + d*x)**S(3))), x), x, -log(a + b*(c + d*x)**S(3))/(S(3)*a + S(3)*b*c**S(3)) + log(x)/(a + b*c**S(3)) + b**(S(1)/3)*c*(a**(S(1)/3) - b**(S(1)/3)*c)*log(a**(S(1)/3) + b**(S(1)/3)*(c + d*x))/(S(3)*a**(S(2)/3)*(a + b*c**S(3))) - b**(S(1)/3)*c*(a**(S(1)/3) - b**(S(1)/3)*c)*log(a**(S(2)/3) - a**(S(1)/3)*b**(S(1)/3)*(c + d*x) + b**(S(2)/3)*(c + d*x)**S(2))/(S(6)*a**(S(2)/3)*(a + b*c**S(3))) + sqrt(S(3))*b**(S(1)/3)*c*(a**(S(1)/3) + b**(S(1)/3)*c)*atan(sqrt(S(3))*(a**(S(1)/3) - S(2)*b**(S(1)/3)*(c + d*x))/(S(3)*a**(S(1)/3)))/(S(3)*a**(S(2)/3)*(a + b*c**S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(a + b*(c + d*x)**S(3))), x), x, -S(3)*b*c**S(2)*d*log(x)/(a + b*c**S(3))**S(2) + b*c**S(2)*d*log(a + b*(c + d*x)**S(3))/(a + b*c**S(3))**S(2) - S(1)/(x*(a + b*c**S(3))) + sqrt(S(3))*b**(S(1)/3)*d*(a**(S(1)/3) - b**(S(1)/3)*c)*(a**(S(1)/3) + b**(S(1)/3)*c)**S(3)*atan(sqrt(S(3))*(a**(S(1)/3) - S(2)*b**(S(1)/3)*(c + d*x))/(S(3)*a**(S(1)/3)))/(S(3)*a**(S(2)/3)*(a + b*c**S(3))**S(2)) + b**(S(1)/3)*d*(a**(S(1)/3)*(a - S(2)*b*c**S(3)) - b**(S(1)/3)*(S(2)*a*c - b*c**S(4)))*log(a**(S(1)/3) + b**(S(1)/3)*(c + d*x))/(S(3)*a**(S(2)/3)*(a + b*c**S(3))**S(2)) - b**(S(1)/3)*d*(a**(S(1)/3)*(a - S(2)*b*c**S(3)) - b**(S(1)/3)*(S(2)*a*c - b*c**S(4)))*log(a**(S(2)/3) - a**(S(1)/3)*b**(S(1)/3)*(c + d*x) + b**(S(2)/3)*(c + d*x)**S(2))/(S(6)*a**(S(2)/3)*(a + b*c**S(3))**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*(a + b*(c + d*x)**S(3))), x), x, S(3)*b*c**S(2)*d/(x*(a + b*c**S(3))**S(2)) - S(3)*b*c*d**S(2)*(a - S(2)*b*c**S(3))*log(x)/(a + b*c**S(3))**S(3) + b*c*d**S(2)*(a - S(2)*b*c**S(3))*log(a + b*(c + d*x)**S(3))/(a + b*c**S(3))**S(3) - S(1)/(x**S(2)*(S(2)*a + S(2)*b*c**S(3))) + sqrt(S(3))*b**(S(2)/3)*d**S(2)*(a**(S(1)/3) + b**(S(1)/3)*c)**S(3)*(-S(3)*a**(S(2)/3)*b**(S(1)/3)*c + a + b*c**S(3))*atan(sqrt(S(3))*(a**(S(1)/3) - S(2)*b**(S(1)/3)*(c + d*x))/(S(3)*a**(S(1)/3)))/(S(3)*a**(S(2)/3)*(a + b*c**S(3))**S(3)) - b**(S(2)/3)*d**S(2)*(S(6)*a**(S(4)/3)*b**(S(2)/3)*c**S(2) - S(3)*a**(S(1)/3)*b**(S(5)/3)*c**S(5) + a**S(2) - S(7)*a*b*c**S(3) + b**S(2)*c**S(6))*log(a**(S(1)/3) + b**(S(1)/3)*(c + d*x))/(S(3)*a**(S(2)/3)*(a + b*c**S(3))**S(3)) + b**(S(2)/3)*d**S(2)*(S(6)*a**(S(4)/3)*b**(S(2)/3)*c**S(2) - S(3)*a**(S(1)/3)*b**(S(5)/3)*c**S(5) + a**S(2) - S(7)*a*b*c**S(3) + b**S(2)*c**S(6))*log(a**(S(2)/3) - a**(S(1)/3)*b**(S(1)/3)*(c + d*x) + b**(S(2)/3)*(c + d*x)**S(2))/(S(6)*a**(S(2)/3)*(a + b*c**S(3))**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(a + b*(c + d*x)**S(4)), x), x, log(a + b*(c + d*x)**S(4))/(S(4)*b*d**S(4)) + S(3)*c**S(2)*atan(sqrt(b)*(c + d*x)**S(2)/sqrt(a))/(S(2)*sqrt(a)*sqrt(b)*d**S(4)) - sqrt(S(2))*c*(S(3)*sqrt(a) - sqrt(b)*c**S(2))*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*(c + d*x) + sqrt(a) + sqrt(b)*(c + d*x)**S(2))/(S(8)*a**(S(3)/4)*b**(S(3)/4)*d**S(4)) + sqrt(S(2))*c*(S(3)*sqrt(a) - sqrt(b)*c**S(2))*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*(c + d*x) + sqrt(a) + sqrt(b)*(c + d*x)**S(2))/(S(8)*a**(S(3)/4)*b**(S(3)/4)*d**S(4)) + sqrt(S(2))*c*(S(3)*sqrt(a) + sqrt(b)*c**S(2))*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*(c + d*x)/a**(S(1)/4))/(S(4)*a**(S(3)/4)*b**(S(3)/4)*d**S(4)) - sqrt(S(2))*c*(S(3)*sqrt(a) + sqrt(b)*c**S(2))*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*(c + d*x)/a**(S(1)/4))/(S(4)*a**(S(3)/4)*b**(S(3)/4)*d**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(a + b*(c + d*x)**S(4)), x), x, -c*atan(sqrt(b)*(c + d*x)**S(2)/sqrt(a))/(sqrt(a)*sqrt(b)*d**S(3)) + sqrt(S(2))*(sqrt(a) - sqrt(b)*c**S(2))*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*(c + d*x) + sqrt(a) + sqrt(b)*(c + d*x)**S(2))/(S(8)*a**(S(3)/4)*b**(S(3)/4)*d**S(3)) - sqrt(S(2))*(sqrt(a) - sqrt(b)*c**S(2))*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*(c + d*x) + sqrt(a) + sqrt(b)*(c + d*x)**S(2))/(S(8)*a**(S(3)/4)*b**(S(3)/4)*d**S(3)) - sqrt(S(2))*(sqrt(a) + sqrt(b)*c**S(2))*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*(c + d*x)/a**(S(1)/4))/(S(4)*a**(S(3)/4)*b**(S(3)/4)*d**S(3)) + sqrt(S(2))*(sqrt(a) + sqrt(b)*c**S(2))*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*(c + d*x)/a**(S(1)/4))/(S(4)*a**(S(3)/4)*b**(S(3)/4)*d**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(a + b*(c + d*x)**S(4)), x), x, atan(sqrt(b)*(c + d*x)**S(2)/sqrt(a))/(S(2)*sqrt(a)*sqrt(b)*d**S(2)) + sqrt(S(2))*c*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*(c + d*x) + sqrt(a) + sqrt(b)*(c + d*x)**S(2))/(S(8)*a**(S(3)/4)*b**(S(1)/4)*d**S(2)) - sqrt(S(2))*c*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*(c + d*x) + sqrt(a) + sqrt(b)*(c + d*x)**S(2))/(S(8)*a**(S(3)/4)*b**(S(1)/4)*d**S(2)) + sqrt(S(2))*c*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*(c + d*x)/a**(S(1)/4))/(S(4)*a**(S(3)/4)*b**(S(1)/4)*d**S(2)) - sqrt(S(2))*c*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*(c + d*x)/a**(S(1)/4))/(S(4)*a**(S(3)/4)*b**(S(1)/4)*d**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(a + b*(c + d*x)**S(4)), x), x, -sqrt(S(2))*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*(c + d*x) + sqrt(a) + sqrt(b)*(c + d*x)**S(2))/(S(8)*a**(S(3)/4)*b**(S(1)/4)*d) + sqrt(S(2))*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*(c + d*x) + sqrt(a) + sqrt(b)*(c + d*x)**S(2))/(S(8)*a**(S(3)/4)*b**(S(1)/4)*d) - sqrt(S(2))*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*(c + d*x)/a**(S(1)/4))/(S(4)*a**(S(3)/4)*b**(S(1)/4)*d) + sqrt(S(2))*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*(c + d*x)/a**(S(1)/4))/(S(4)*a**(S(3)/4)*b**(S(1)/4)*d), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(a + b*(c + d*x)**S(4))), x), x, -log(a + b*(c + d*x)**S(4))/(S(4)*a + S(4)*b*c**S(4)) + log(x)/(a + b*c**S(4)) - sqrt(b)*c**S(2)*atan(sqrt(b)*(c + d*x)**S(2)/sqrt(a))/(S(2)*sqrt(a)*(a + b*c**S(4))) - sqrt(S(2))*b**(S(1)/4)*c*(sqrt(a) - sqrt(b)*c**S(2))*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*(c + d*x) + sqrt(a) + sqrt(b)*(c + d*x)**S(2))/(S(8)*a**(S(3)/4)*(a + b*c**S(4))) + sqrt(S(2))*b**(S(1)/4)*c*(sqrt(a) - sqrt(b)*c**S(2))*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*(c + d*x) + sqrt(a) + sqrt(b)*(c + d*x)**S(2))/(S(8)*a**(S(3)/4)*(a + b*c**S(4))) + sqrt(S(2))*b**(S(1)/4)*c*(sqrt(a) + sqrt(b)*c**S(2))*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*(c + d*x)/a**(S(1)/4))/(S(4)*a**(S(3)/4)*(a + b*c**S(4))) - sqrt(S(2))*b**(S(1)/4)*c*(sqrt(a) + sqrt(b)*c**S(2))*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*(c + d*x)/a**(S(1)/4))/(S(4)*a**(S(3)/4)*(a + b*c**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(a + b*(c + d*x)**S(4))), x), x, -S(4)*b*c**S(3)*d*log(x)/(a + b*c**S(4))**S(2) + b*c**S(3)*d*log(a + b*(c + d*x)**S(4))/(a + b*c**S(4))**S(2) - S(1)/(x*(a + b*c**S(4))) - sqrt(b)*c*d*(a - b*c**S(4))*atan(sqrt(b)*(c + d*x)**S(2)/sqrt(a))/(sqrt(a)*(a + b*c**S(4))**S(2)) + sqrt(S(2))*b**(S(1)/4)*d*(sqrt(a)*(a - S(3)*b*c**S(4)) + sqrt(b)*c**S(2)*(S(3)*a - b*c**S(4)))*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*(c + d*x)/a**(S(1)/4))/(S(4)*a**(S(3)/4)*(a + b*c**S(4))**S(2)) - sqrt(S(2))*b**(S(1)/4)*d*(sqrt(a)*(a - S(3)*b*c**S(4)) + sqrt(b)*c**S(2)*(S(3)*a - b*c**S(4)))*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*(c + d*x)/a**(S(1)/4))/(S(4)*a**(S(3)/4)*(a + b*c**S(4))**S(2)) - sqrt(S(2))*b**(S(1)/4)*d*(a**(S(3)/2) - S(3)*sqrt(a)*b*c**S(4) - S(3)*a*sqrt(b)*c**S(2) + b**(S(3)/2)*c**S(6))*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*(c + d*x) + sqrt(a) + sqrt(b)*(c + d*x)**S(2))/(S(8)*a**(S(3)/4)*(a + b*c**S(4))**S(2)) + sqrt(S(2))*b**(S(1)/4)*d*(a**(S(3)/2) - S(3)*sqrt(a)*b*c**S(4) - S(3)*a*sqrt(b)*c**S(2) + b**(S(3)/2)*c**S(6))*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*(c + d*x) + sqrt(a) + sqrt(b)*(c + d*x)**S(2))/(S(8)*a**(S(3)/4)*(a + b*c**S(4))**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(a + b*sqrt(c + d*x))**S(2), x), x, -a**S(2)*c**S(3)*x/d**S(3) - S(4)*a*b*c**S(3)*(c + d*x)**(S(3)/2)/(S(3)*d**S(4)) + S(12)*a*b*c**S(2)*(c + d*x)**(S(5)/2)/(S(5)*d**S(4)) - S(12)*a*b*c*(c + d*x)**(S(7)/2)/(S(7)*d**S(4)) + S(4)*a*b*(c + d*x)**(S(9)/2)/(S(9)*d**S(4)) + b**S(2)*(c + d*x)**S(5)/(S(5)*d**S(4)) + c**S(2)*(S(3)*a**S(2) - b**S(2)*c)*(c + d*x)**S(2)/(S(2)*d**S(4)) - c*(a**S(2) - b**S(2)*c)*(c + d*x)**S(3)/d**S(4) + (a**S(2) - S(3)*b**S(2)*c)*(c + d*x)**S(4)/(S(4)*d**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(a + b*sqrt(c + d*x))**S(2), x), x, a**S(2)*c**S(2)*x/d**S(2) + S(4)*a*b*c**S(2)*(c + d*x)**(S(3)/2)/(S(3)*d**S(3)) - S(8)*a*b*c*(c + d*x)**(S(5)/2)/(S(5)*d**S(3)) + S(4)*a*b*(c + d*x)**(S(7)/2)/(S(7)*d**S(3)) + b**S(2)*(c + d*x)**S(4)/(S(4)*d**S(3)) - c*(S(2)*a**S(2) - b**S(2)*c)*(c + d*x)**S(2)/(S(2)*d**S(3)) + (a**S(2) - S(2)*b**S(2)*c)*(c + d*x)**S(3)/(S(3)*d**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a + b*sqrt(c + d*x))**S(2), x), x, -a**S(2)*c*x/d - S(4)*a*b*c*(c + d*x)**(S(3)/2)/(S(3)*d**S(2)) + S(4)*a*b*(c + d*x)**(S(5)/2)/(S(5)*d**S(2)) + b**S(2)*(c + d*x)**S(3)/(S(3)*d**S(2)) + (a**S(2) - b**S(2)*c)*(c + d*x)**S(2)/(S(2)*d**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*sqrt(c + d*x))**S(2), x), x, a**S(2)*x + S(4)*a*b*(c + d*x)**(S(3)/2)/(S(3)*d) + b**S(2)*(c + d*x)**S(2)/(S(2)*d), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*sqrt(c + d*x))**S(2)/x, x), x, -S(4)*a*b*sqrt(c)*atanh(sqrt(c + d*x)/sqrt(c)) + S(4)*a*b*sqrt(c + d*x) + b**S(2)*d*x + (a**S(2) + b**S(2)*c)*log(x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*sqrt(c + d*x))**S(2)/x**S(2), x), x, -S(2)*a*b*d*atanh(sqrt(c + d*x)/sqrt(c))/sqrt(c) + b**S(2)*d*log(x) - (a + b*sqrt(c + d*x))**S(2)/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*sqrt(c + d*x))**S(2)/x**S(3), x), x, a*b*d**S(2)*atanh(sqrt(c + d*x)/sqrt(c))/(S(2)*c**(S(3)/2)) - b*d*(a*sqrt(c + d*x) + b*c)/(S(2)*c*x) - (a + b*sqrt(c + d*x))**S(2)/(S(2)*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*sqrt(a + b*sqrt(c + d*x)), x), x, -S(28)*a*(a + b*sqrt(c + d*x))**(S(15)/2)/(S(15)*b**S(8)*d**S(4)) - S(20)*a*(a + b*sqrt(c + d*x))**(S(11)/2)*(S(7)*a**S(2) - S(3)*b**S(2)*c)/(S(11)*b**S(8)*d**S(4)) - S(12)*a*(a + b*sqrt(c + d*x))**(S(7)/2)*(a**S(2) - b**S(2)*c)*(S(7)*a**S(2) - S(3)*b**S(2)*c)/(S(7)*b**S(8)*d**S(4)) - S(4)*a*(a + b*sqrt(c + d*x))**(S(3)/2)*(a**S(2) - b**S(2)*c)**S(3)/(S(3)*b**S(8)*d**S(4)) + S(4)*(a + b*sqrt(c + d*x))**(S(17)/2)/(S(17)*b**S(8)*d**S(4)) + (a + b*sqrt(c + d*x))**(S(13)/2)*(S(84)*a**S(2) - S(12)*b**S(2)*c)/(S(13)*b**S(8)*d**S(4)) + (a + b*sqrt(c + d*x))**(S(9)/2)*(S(140)*a**S(4) - S(120)*a**S(2)*b**S(2)*c + S(12)*b**S(4)*c**S(2))/(S(9)*b**S(8)*d**S(4)) + S(4)*(a + b*sqrt(c + d*x))**(S(5)/2)*(a**S(2) - b**S(2)*c)**S(2)*(S(7)*a**S(2) - b**S(2)*c)/(S(5)*b**S(8)*d**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*sqrt(a + b*sqrt(c + d*x)), x), x, -S(20)*a*(a + b*sqrt(c + d*x))**(S(11)/2)/(S(11)*b**S(6)*d**S(3)) - S(8)*a*(a + b*sqrt(c + d*x))**(S(7)/2)*(S(5)*a**S(2) - S(3)*b**S(2)*c)/(S(7)*b**S(6)*d**S(3)) - S(4)*a*(a + b*sqrt(c + d*x))**(S(3)/2)*(a**S(2) - b**S(2)*c)**S(2)/(S(3)*b**S(6)*d**S(3)) + S(4)*(a + b*sqrt(c + d*x))**(S(13)/2)/(S(13)*b**S(6)*d**S(3)) + (a + b*sqrt(c + d*x))**(S(9)/2)*(S(40)*a**S(2) - S(8)*b**S(2)*c)/(S(9)*b**S(6)*d**S(3)) + (a + b*sqrt(c + d*x))**(S(5)/2)*(S(20)*a**S(4) - S(24)*a**S(2)*b**S(2)*c + S(4)*b**S(4)*c**S(2))/(S(5)*b**S(6)*d**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*sqrt(a + b*sqrt(c + d*x)), x), x, -S(12)*a*(a + b*sqrt(c + d*x))**(S(7)/2)/(S(7)*b**S(4)*d**S(2)) - S(4)*a*(a + b*sqrt(c + d*x))**(S(3)/2)*(a**S(2) - b**S(2)*c)/(S(3)*b**S(4)*d**S(2)) + S(4)*(a + b*sqrt(c + d*x))**(S(9)/2)/(S(9)*b**S(4)*d**S(2)) + (a + b*sqrt(c + d*x))**(S(5)/2)*(S(12)*a**S(2) - S(4)*b**S(2)*c)/(S(5)*b**S(4)*d**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + b*sqrt(c + d*x)), x), x, -S(4)*a*(a + b*sqrt(c + d*x))**(S(3)/2)/(S(3)*b**S(2)*d) + S(4)*(a + b*sqrt(c + d*x))**(S(5)/2)/(S(5)*b**S(2)*d), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + b*sqrt(c + d*x))/x, x), x, -S(2)*sqrt(a - b*sqrt(c))*atanh(sqrt(a + b*sqrt(c + d*x))/sqrt(a - b*sqrt(c))) - S(2)*sqrt(a + b*sqrt(c))*atanh(sqrt(a + b*sqrt(c + d*x))/sqrt(a + b*sqrt(c))) + S(4)*sqrt(a + b*sqrt(c + d*x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + b*sqrt(c + d*x))/x**S(2), x), x, -b*d*atanh(sqrt(a + b*sqrt(c + d*x))/sqrt(a + b*sqrt(c)))/(S(2)*sqrt(c)*sqrt(a + b*sqrt(c))) + b*d*atanh(sqrt(a + b*sqrt(c + d*x))/sqrt(a - b*sqrt(c)))/(S(2)*sqrt(c)*sqrt(a - b*sqrt(c))) - sqrt(a + b*sqrt(c + d*x))/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + b*sqrt(c + d*x))/x**S(3), x), x, b*d*sqrt(a + b*sqrt(c + d*x))*(-a*sqrt(c + d*x) + b*c)/(S(8)*c*x*(a**S(2) - b**S(2)*c)) + b*d**S(2)*(S(2)*a + S(3)*b*sqrt(c))*atanh(sqrt(a + b*sqrt(c + d*x))/sqrt(a + b*sqrt(c)))/(S(16)*c**(S(3)/2)*(a + b*sqrt(c))**(S(3)/2)) - b*d**S(2)*(S(2)*a - S(3)*b*sqrt(c))*atanh(sqrt(a + b*sqrt(c + d*x))/sqrt(a - b*sqrt(c)))/(S(16)*c**(S(3)/2)*(a - b*sqrt(c))**(S(3)/2)) - sqrt(a + b*sqrt(c + d*x))/(S(2)*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(a + b*sqrt(c + d*x)), x), x, -a*(c + d*x)**S(3)/(S(3)*b**S(2)*d**S(4)) - a*(a**S(2) - S(3)*b**S(2)*c)*(c + d*x)**S(2)/(S(2)*b**S(4)*d**S(4)) - a*x*(a**S(4) - S(3)*a**S(2)*b**S(2)*c + S(3)*b**S(4)*c**S(2))/(b**S(6)*d**S(3)) - S(2)*a*(a**S(2) - b**S(2)*c)**S(3)*log(a + b*sqrt(c + d*x))/(b**S(8)*d**S(4)) + S(2)*(c + d*x)**(S(7)/2)/(S(7)*b*d**S(4)) + (S(2)*a**S(2) - S(6)*b**S(2)*c)*(c + d*x)**(S(5)/2)/(S(5)*b**S(3)*d**S(4)) + (c + d*x)**(S(3)/2)*(S(2)*a**S(4) - S(6)*a**S(2)*b**S(2)*c + S(6)*b**S(4)*c**S(2))/(S(3)*b**S(5)*d**S(4)) + S(2)*(a**S(2) - b**S(2)*c)**S(3)*sqrt(c + d*x)/(b**S(7)*d**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(a + b*sqrt(c + d*x)), x), x, -a*(c + d*x)**S(2)/(S(2)*b**S(2)*d**S(3)) - a*x*(a**S(2) - S(2)*b**S(2)*c)/(b**S(4)*d**S(2)) - S(2)*a*(a**S(2) - b**S(2)*c)**S(2)*log(a + b*sqrt(c + d*x))/(b**S(6)*d**S(3)) + S(2)*(c + d*x)**(S(5)/2)/(S(5)*b*d**S(3)) + (S(2)*a**S(2) - S(4)*b**S(2)*c)*(c + d*x)**(S(3)/2)/(S(3)*b**S(3)*d**S(3)) + S(2)*(a**S(2) - b**S(2)*c)**S(2)*sqrt(c + d*x)/(b**S(5)*d**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(a + b*sqrt(c + d*x)), x), x, -a*x/(b**S(2)*d) - S(2)*a*(a**S(2) - b**S(2)*c)*log(a + b*sqrt(c + d*x))/(b**S(4)*d**S(2)) + S(2)*(c + d*x)**(S(3)/2)/(S(3)*b*d**S(2)) + (S(2)*a**S(2) - S(2)*b**S(2)*c)*sqrt(c + d*x)/(b**S(3)*d**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(a + b*sqrt(c + d*x)), x), x, -S(2)*a*log(a + b*sqrt(c + d*x))/(b**S(2)*d) + S(2)*sqrt(c + d*x)/(b*d), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(a + b*sqrt(c + d*x))), x), x, a*log(x)/(a**S(2) - b**S(2)*c) - S(2)*a*log(a + b*sqrt(c + d*x))/(a**S(2) - b**S(2)*c) + S(2)*b*sqrt(c)*atanh(sqrt(c + d*x)/sqrt(c))/(a**S(2) - b**S(2)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(a + b*sqrt(c + d*x))), x), x, a*b**S(2)*d*log(x)/(a**S(2) - b**S(2)*c)**S(2) - S(2)*a*b**S(2)*d*log(a + b*sqrt(c + d*x))/(a**S(2) - b**S(2)*c)**S(2) + b*d*(a**S(2) + b**S(2)*c)*atanh(sqrt(c + d*x)/sqrt(c))/(sqrt(c)*(a**S(2) - b**S(2)*c)**S(2)) - (a - b*sqrt(c + d*x))/(x*(a**S(2) - b**S(2)*c)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*(a + b*sqrt(c + d*x))), x), x, a*b**S(4)*d**S(2)*log(x)/(a**S(2) - b**S(2)*c)**S(3) - S(2)*a*b**S(4)*d**S(2)*log(a + b*sqrt(c + d*x))/(a**S(2) - b**S(2)*c)**S(3) - b*d*(S(4)*a*b*c - (a**S(2) + S(3)*b**S(2)*c)*sqrt(c + d*x))/(S(4)*c*x*(a**S(2) - b**S(2)*c)**S(2)) - b*d**S(2)*(a**S(4) - S(6)*a**S(2)*b**S(2)*c - S(3)*b**S(4)*c**S(2))*atanh(sqrt(c + d*x)/sqrt(c))/(S(4)*c**(S(3)/2)*(a**S(2) - b**S(2)*c)**S(3)) - (a - b*sqrt(c + d*x))/(x**S(2)*(S(2)*a**S(2) - S(2)*b**S(2)*c)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(a + b*sqrt(c + d*x))**S(2), x), x, -S(4)*a*(c + d*x)**(S(5)/2)/(S(5)*b**S(3)*d**S(4)) - S(4)*a*(S(2)*a**S(2) - S(3)*b**S(2)*c)*(c + d*x)**(S(3)/2)/(S(3)*b**S(5)*d**S(4)) - S(12)*a*(a**S(2) - b**S(2)*c)**S(2)*sqrt(c + d*x)/(b**S(7)*d**S(4)) + S(2)*a*(a**S(2) - b**S(2)*c)**S(3)/(b**S(8)*d**S(4)*(a + b*sqrt(c + d*x))) + (c + d*x)**S(3)/(S(3)*b**S(2)*d**S(4)) + (S(3)*a**S(2) - S(3)*b**S(2)*c)*(c + d*x)**S(2)/(S(2)*b**S(4)*d**S(4)) + x*(S(5)*a**S(4) - S(9)*a**S(2)*b**S(2)*c + S(3)*b**S(4)*c**S(2))/(b**S(6)*d**S(3)) + S(2)*(a**S(2) - b**S(2)*c)**S(2)*(S(7)*a**S(2) - b**S(2)*c)*log(a + b*sqrt(c + d*x))/(b**S(8)*d**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(a + b*sqrt(c + d*x))**S(2), x), x, -S(4)*a*(c + d*x)**(S(3)/2)/(S(3)*b**S(3)*d**S(3)) - S(8)*a*(a**S(2) - b**S(2)*c)*sqrt(c + d*x)/(b**S(5)*d**S(3)) + S(2)*a*(a**S(2) - b**S(2)*c)**S(2)/(b**S(6)*d**S(3)*(a + b*sqrt(c + d*x))) + (c + d*x)**S(2)/(S(2)*b**S(2)*d**S(3)) + x*(S(3)*a**S(2) - S(2)*b**S(2)*c)/(b**S(4)*d**S(2)) + (S(10)*a**S(4) - S(12)*a**S(2)*b**S(2)*c + S(2)*b**S(4)*c**S(2))*log(a + b*sqrt(c + d*x))/(b**S(6)*d**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(a + b*sqrt(c + d*x))**S(2), x), x, -S(4)*a*sqrt(c + d*x)/(b**S(3)*d**S(2)) + S(2)*a*(a**S(2) - b**S(2)*c)/(b**S(4)*d**S(2)*(a + b*sqrt(c + d*x))) + x/(b**S(2)*d) + (S(6)*a**S(2) - S(2)*b**S(2)*c)*log(a + b*sqrt(c + d*x))/(b**S(4)*d**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*sqrt(c + d*x))**(S(-2)), x), x, S(2)*a/(b**S(2)*d*(a + b*sqrt(c + d*x))) + S(2)*log(a + b*sqrt(c + d*x))/(b**S(2)*d), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(a + b*sqrt(c + d*x))**S(2)), x), x, S(4)*a*b*sqrt(c)*atanh(sqrt(c + d*x)/sqrt(c))/(a**S(2) - b**S(2)*c)**S(2) + S(2)*a/((a + b*sqrt(c + d*x))*(a**S(2) - b**S(2)*c)) + (a**S(2) + b**S(2)*c)*log(x)/(a**S(2) - b**S(2)*c)**S(2) - (S(2)*a**S(2) + S(2)*b**S(2)*c)*log(a + b*sqrt(c + d*x))/(a**S(2) - b**S(2)*c)**S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(a + b*sqrt(c + d*x))**S(2)), x), x, S(4)*a*b**S(2)*d/((a + b*sqrt(c + d*x))*(a**S(2) - b**S(2)*c)**S(2)) + S(2)*a*b*d*(a**S(2) + S(3)*b**S(2)*c)*atanh(sqrt(c + d*x)/sqrt(c))/(sqrt(c)*(a**S(2) - b**S(2)*c)**S(3)) + b**S(2)*d*(S(3)*a**S(2) + b**S(2)*c)*log(x)/(a**S(2) - b**S(2)*c)**S(3) - S(2)*b**S(2)*d*(S(3)*a**S(2) + b**S(2)*c)*log(a + b*sqrt(c + d*x))/(a**S(2) - b**S(2)*c)**S(3) - (a - b*sqrt(c + d*x))/(x*(a + b*sqrt(c + d*x))*(a**S(2) - b**S(2)*c)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*(a + b*sqrt(c + d*x))**S(2)), x), x, a*b**S(2)*d**S(2)*(a**S(2) + S(11)*b**S(2)*c)/(S(2)*c*(a + b*sqrt(c + d*x))*(a**S(2) - b**S(2)*c)**S(3)) - a*b*d**S(2)*(a**S(4) - S(10)*a**S(2)*b**S(2)*c - S(15)*b**S(4)*c**S(2))*atanh(sqrt(c + d*x)/sqrt(c))/(S(2)*c**(S(3)/2)*(a**S(2) - b**S(2)*c)**S(4)) + b**S(4)*d**S(2)*(S(5)*a**S(2) + b**S(2)*c)*log(x)/(a**S(2) - b**S(2)*c)**S(4) - S(2)*b**S(4)*d**S(2)*(S(5)*a**S(2) + b**S(2)*c)*log(a + b*sqrt(c + d*x))/(a**S(2) - b**S(2)*c)**S(4) - b*d*(S(3)*a*b*c - (a**S(2) + S(2)*b**S(2)*c)*sqrt(c + d*x))/(S(2)*c*x*(a + b*sqrt(c + d*x))*(a**S(2) - b**S(2)*c)**S(2)) - (a - b*sqrt(c + d*x))/(x**S(2)*(a + b*sqrt(c + d*x))*(S(2)*a**S(2) - S(2)*b**S(2)*c)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/sqrt(a + b*sqrt(c + d*x)), x), x, -S(28)*a*(a + b*sqrt(c + d*x))**(S(13)/2)/(S(13)*b**S(8)*d**S(4)) - S(20)*a*(a + b*sqrt(c + d*x))**(S(9)/2)*(S(7)*a**S(2) - S(3)*b**S(2)*c)/(S(9)*b**S(8)*d**S(4)) - S(12)*a*(a + b*sqrt(c + d*x))**(S(5)/2)*(a**S(2) - b**S(2)*c)*(S(7)*a**S(2) - S(3)*b**S(2)*c)/(S(5)*b**S(8)*d**S(4)) - S(4)*a*sqrt(a + b*sqrt(c + d*x))*(a**S(2) - b**S(2)*c)**S(3)/(b**S(8)*d**S(4)) + S(4)*(a + b*sqrt(c + d*x))**(S(15)/2)/(S(15)*b**S(8)*d**S(4)) + (a + b*sqrt(c + d*x))**(S(11)/2)*(S(84)*a**S(2) - S(12)*b**S(2)*c)/(S(11)*b**S(8)*d**S(4)) + (a + b*sqrt(c + d*x))**(S(7)/2)*(S(140)*a**S(4) - S(120)*a**S(2)*b**S(2)*c + S(12)*b**S(4)*c**S(2))/(S(7)*b**S(8)*d**S(4)) + S(4)*(a + b*sqrt(c + d*x))**(S(3)/2)*(a**S(2) - b**S(2)*c)**S(2)*(S(7)*a**S(2) - b**S(2)*c)/(S(3)*b**S(8)*d**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/sqrt(a + b*sqrt(c + d*x)), x), x, -S(20)*a*(a + b*sqrt(c + d*x))**(S(9)/2)/(S(9)*b**S(6)*d**S(3)) - S(8)*a*(a + b*sqrt(c + d*x))**(S(5)/2)*(S(5)*a**S(2) - S(3)*b**S(2)*c)/(S(5)*b**S(6)*d**S(3)) - S(4)*a*sqrt(a + b*sqrt(c + d*x))*(a**S(2) - b**S(2)*c)**S(2)/(b**S(6)*d**S(3)) + S(4)*(a + b*sqrt(c + d*x))**(S(11)/2)/(S(11)*b**S(6)*d**S(3)) + (a + b*sqrt(c + d*x))**(S(7)/2)*(S(40)*a**S(2) - S(8)*b**S(2)*c)/(S(7)*b**S(6)*d**S(3)) + (a + b*sqrt(c + d*x))**(S(3)/2)*(S(20)*a**S(4) - S(24)*a**S(2)*b**S(2)*c + S(4)*b**S(4)*c**S(2))/(S(3)*b**S(6)*d**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/sqrt(a + b*sqrt(c + d*x)), x), x, -S(12)*a*(a + b*sqrt(c + d*x))**(S(5)/2)/(S(5)*b**S(4)*d**S(2)) - S(4)*a*sqrt(a + b*sqrt(c + d*x))*(a**S(2) - b**S(2)*c)/(b**S(4)*d**S(2)) + S(4)*(a + b*sqrt(c + d*x))**(S(7)/2)/(S(7)*b**S(4)*d**S(2)) + (a + b*sqrt(c + d*x))**(S(3)/2)*(S(12)*a**S(2) - S(4)*b**S(2)*c)/(S(3)*b**S(4)*d**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(a + b*sqrt(c + d*x)), x), x, -S(4)*a*sqrt(a + b*sqrt(c + d*x))/(b**S(2)*d) + S(4)*(a + b*sqrt(c + d*x))**(S(3)/2)/(S(3)*b**S(2)*d), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*sqrt(a + b*sqrt(c + d*x))), x), x, -S(2)*atanh(sqrt(a + b*sqrt(c + d*x))/sqrt(a + b*sqrt(c)))/sqrt(a + b*sqrt(c)) - S(2)*atanh(sqrt(a + b*sqrt(c + d*x))/sqrt(a - b*sqrt(c)))/sqrt(a - b*sqrt(c)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*sqrt(a + b*sqrt(c + d*x))), x), x, b*d*atanh(sqrt(a + b*sqrt(c + d*x))/sqrt(a + b*sqrt(c)))/(S(2)*sqrt(c)*(a + b*sqrt(c))**(S(3)/2)) - b*d*atanh(sqrt(a + b*sqrt(c + d*x))/sqrt(a - b*sqrt(c)))/(S(2)*sqrt(c)*(a - b*sqrt(c))**(S(3)/2)) - (a - b*sqrt(c + d*x))*sqrt(a + b*sqrt(c + d*x))/(x*(a**S(2) - b**S(2)*c)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*sqrt(a + b*sqrt(c + d*x))), x), x, -b*d*sqrt(a + b*sqrt(c + d*x))*(S(6)*a*b*c - (a**S(2) + S(5)*b**S(2)*c)*sqrt(c + d*x))/(S(8)*c*x*(a**S(2) - b**S(2)*c)**S(2)) - b*d**S(2)*(S(2)*a + S(5)*b*sqrt(c))*atanh(sqrt(a + b*sqrt(c + d*x))/sqrt(a + b*sqrt(c)))/(S(16)*c**(S(3)/2)*(a + b*sqrt(c))**(S(5)/2)) + b*d**S(2)*(S(2)*a - S(5)*b*sqrt(c))*atanh(sqrt(a + b*sqrt(c + d*x))/sqrt(a - b*sqrt(c)))/(S(16)*c**(S(3)/2)*(a - b*sqrt(c))**(S(5)/2)) - (a - b*sqrt(c + d*x))*sqrt(a + b*sqrt(c + d*x))/(x**S(2)*(S(2)*a**S(2) - S(2)*b**S(2)*c)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(a + b*sqrt(c + d*x))**p, x), x, -S(2)*a*(a + b*sqrt(c + d*x))**(p + S(1))*(a**S(2) - b**S(2)*c)**S(3)/(b**S(8)*d**S(4)*(p + S(1))) - S(6)*a*(a + b*sqrt(c + d*x))**(p + S(3))*(a**S(2) - b**S(2)*c)*(S(7)*a**S(2) - S(3)*b**S(2)*c)/(b**S(8)*d**S(4)*(p + S(3))) - S(10)*a*(a + b*sqrt(c + d*x))**(p + S(5))*(S(7)*a**S(2) - S(3)*b**S(2)*c)/(b**S(8)*d**S(4)*(p + S(5))) - S(14)*a*(a + b*sqrt(c + d*x))**(p + S(7))/(b**S(8)*d**S(4)*(p + S(7))) + S(2)*(a + b*sqrt(c + d*x))**(p + S(2))*(a**S(2) - b**S(2)*c)**S(2)*(S(7)*a**S(2) - b**S(2)*c)/(b**S(8)*d**S(4)*(p + S(2))) + (a + b*sqrt(c + d*x))**(p + S(4))*(S(70)*a**S(4) - S(60)*a**S(2)*b**S(2)*c + S(6)*b**S(4)*c**S(2))/(b**S(8)*d**S(4)*(p + S(4))) + (a + b*sqrt(c + d*x))**(p + S(6))*(S(42)*a**S(2) - S(6)*b**S(2)*c)/(b**S(8)*d**S(4)*(p + S(6))) + S(2)*(a + b*sqrt(c + d*x))**(p + S(8))/(b**S(8)*d**S(4)*(p + S(8))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(a + b*sqrt(c + d*x))**p, x), x, -S(2)*a*(a + b*sqrt(c + d*x))**(p + S(1))*(a**S(2) - b**S(2)*c)**S(2)/(b**S(6)*d**S(3)*(p + S(1))) - S(4)*a*(a + b*sqrt(c + d*x))**(p + S(3))*(S(5)*a**S(2) - S(3)*b**S(2)*c)/(b**S(6)*d**S(3)*(p + S(3))) - S(10)*a*(a + b*sqrt(c + d*x))**(p + S(5))/(b**S(6)*d**S(3)*(p + S(5))) + (a + b*sqrt(c + d*x))**(p + S(2))*(S(10)*a**S(4) - S(12)*a**S(2)*b**S(2)*c + S(2)*b**S(4)*c**S(2))/(b**S(6)*d**S(3)*(p + S(2))) + (a + b*sqrt(c + d*x))**(p + S(4))*(S(20)*a**S(2) - S(4)*b**S(2)*c)/(b**S(6)*d**S(3)*(p + S(4))) + S(2)*(a + b*sqrt(c + d*x))**(p + S(6))/(b**S(6)*d**S(3)*(p + S(6))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a + b*sqrt(c + d*x))**p, x), x, -S(2)*a*(a + b*sqrt(c + d*x))**(p + S(1))*(a**S(2) - b**S(2)*c)/(b**S(4)*d**S(2)*(p + S(1))) - S(6)*a*(a + b*sqrt(c + d*x))**(p + S(3))/(b**S(4)*d**S(2)*(p + S(3))) + (a + b*sqrt(c + d*x))**(p + S(2))*(S(6)*a**S(2) - S(2)*b**S(2)*c)/(b**S(4)*d**S(2)*(p + S(2))) + S(2)*(a + b*sqrt(c + d*x))**(p + S(4))/(b**S(4)*d**S(2)*(p + S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*sqrt(c + d*x))**p, x), x, -S(2)*a*(a + b*sqrt(c + d*x))**(p + S(1))/(b**S(2)*d*(p + S(1))) + S(2)*(a + b*sqrt(c + d*x))**(p + S(2))/(b**S(2)*d*(p + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*sqrt(c + d*x))**p/x, x), x, -(a + b*sqrt(c + d*x))**(p + S(1))*hyper((S(1), p + S(1)), (p + S(2),), (a + b*sqrt(c + d*x))/(a + b*sqrt(c)))/((a + b*sqrt(c))*(p + S(1))) - (a + b*sqrt(c + d*x))**(p + S(1))*hyper((S(1), p + S(1)), (p + S(2),), (a + b*sqrt(c + d*x))/(a - b*sqrt(c)))/((a - b*sqrt(c))*(p + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*(c*x)**n)**(S(5)/2)/x, x), x, -S(2)*a**(S(5)/2)*atanh(sqrt(a + b*(c*x)**n)/sqrt(a))/n + S(2)*a**S(2)*sqrt(a + b*(c*x)**n)/n + S(2)*a*(a + b*(c*x)**n)**(S(3)/2)/(S(3)*n) + S(2)*(a + b*(c*x)**n)**(S(5)/2)/(S(5)*n), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*(c*x)**n)**(S(3)/2)/x, x), x, -S(2)*a**(S(3)/2)*atanh(sqrt(a + b*(c*x)**n)/sqrt(a))/n + S(2)*a*sqrt(a + b*(c*x)**n)/n + S(2)*(a + b*(c*x)**n)**(S(3)/2)/(S(3)*n), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + b*(c*x)**n)/x, x), x, -S(2)*sqrt(a)*atanh(sqrt(a + b*(c*x)**n)/sqrt(a))/n + S(2)*sqrt(a + b*(c*x)**n)/n, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*sqrt(a + b*(c*x)**n)), x), x, -S(2)*atanh(sqrt(a + b*(c*x)**n)/sqrt(a))/(sqrt(a)*n), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(a + b*(c*x)**n)**(S(3)/2)), x), x, S(2)/(a*n*sqrt(a + b*(c*x)**n)) - S(2)*atanh(sqrt(a + b*(c*x)**n)/sqrt(a))/(a**(S(3)/2)*n), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(a + b*(c*x)**n)**(S(5)/2)), x), x, S(2)/(S(3)*a*n*(a + b*(c*x)**n)**(S(3)/2)) + S(2)/(a**S(2)*n*sqrt(a + b*(c*x)**n)) - S(2)*atanh(sqrt(a + b*(c*x)**n)/sqrt(a))/(a**(S(5)/2)*n), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-a + b*(c*x)**n)**(S(5)/2)/x, x), x, -S(2)*a**(S(5)/2)*atan(sqrt(-a + b*(c*x)**n)/sqrt(a))/n + S(2)*a**S(2)*sqrt(-a + b*(c*x)**n)/n - S(2)*a*(-a + b*(c*x)**n)**(S(3)/2)/(S(3)*n) + S(2)*(-a + b*(c*x)**n)**(S(5)/2)/(S(5)*n), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-a + b*(c*x)**n)**(S(3)/2)/x, x), x, S(2)*a**(S(3)/2)*atan(sqrt(-a + b*(c*x)**n)/sqrt(a))/n - S(2)*a*sqrt(-a + b*(c*x)**n)/n + S(2)*(-a + b*(c*x)**n)**(S(3)/2)/(S(3)*n), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(-a + b*(c*x)**n)/x, x), x, -S(2)*sqrt(a)*atan(sqrt(-a + b*(c*x)**n)/sqrt(a))/n + S(2)*sqrt(-a + b*(c*x)**n)/n, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*sqrt(-a + b*(c*x)**n)), x), x, S(2)*atan(sqrt(-a + b*(c*x)**n)/sqrt(a))/(sqrt(a)*n), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(-a + b*(c*x)**n)**(S(3)/2)), x), x, -S(2)/(a*n*sqrt(-a + b*(c*x)**n)) - S(2)*atan(sqrt(-a + b*(c*x)**n)/sqrt(a))/(a**(S(3)/2)*n), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(-a + b*(c*x)**n)**(S(5)/2)), x), x, -S(2)/(S(3)*a*n*(-a + b*(c*x)**n)**(S(3)/2)) + S(2)/(a**S(2)*n*sqrt(-a + b*(c*x)**n)) + S(2)*atan(sqrt(-a + b*(c*x)**n)/sqrt(a))/(a**(S(5)/2)*n), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*sqrt(a + b*x)), x), x, -S(2)*atanh(sqrt(a + b*x)/sqrt(a))/sqrt(a), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*sqrt(a + b*(c*x)**m)), x), x, -S(2)*atanh(sqrt(a + b*(c*x)**m)/sqrt(a))/(sqrt(a)*m), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*sqrt(a + b*(c*(d*x)**m)**n)), x), x, -S(2)*atanh(sqrt(a + b*(c*(d*x)**m)**n)/sqrt(a))/(sqrt(a)*m*n), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*sqrt(a + b*(c*(d*(e*x)**m)**n)**p)), x), x, -S(2)*atanh(sqrt(a + b*(c*(d*(e*x)**m)**n)**p)/sqrt(a))/(sqrt(a)*m*n*p), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*sqrt(a + b*(c*(d*(e*(f*x)**m)**n)**p)**q)), x), x, -S(2)*atanh(sqrt(a + b*(c*(d*(e*(f*x)**m)**n)**p)**q)/sqrt(a))/(sqrt(a)*m*n*p*q), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(S(-1) + x**(S(-2)))*(x**S(2) + S(-1))**S(3)/x, x), x, -x**S(6)*(S(-1) + x**(S(-2)))**(S(7)/2)/S(6) - S(7)*x**S(4)*(S(-1) + x**(S(-2)))**(S(5)/2)/S(24) - S(35)*x**S(2)*(S(-1) + x**(S(-2)))**(S(3)/2)/S(48) + S(35)*sqrt(S(-1) + x**(S(-2)))/S(16) - S(35)*atan(sqrt(S(-1) + x**(S(-2))))/S(16), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(S(-1) + x**(S(-2)))*(x**S(2) + S(-1))**S(2)/x, x), x, x**S(4)*(S(-1) + x**(S(-2)))**(S(5)/2)/S(4) + S(5)*x**S(2)*(S(-1) + x**(S(-2)))**(S(3)/2)/S(8) - S(15)*sqrt(S(-1) + x**(S(-2)))/S(8) + S(15)*atan(sqrt(S(-1) + x**(S(-2))))/S(8), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(S(-1) + x**(S(-2)))*(x**S(2) + S(-1))/x, x), x, -x**S(2)*(S(-1) + x**(S(-2)))**(S(3)/2)/S(2) + S(3)*sqrt(S(-1) + x**(S(-2)))/S(2) - S(3)*atan(sqrt(S(-1) + x**(S(-2))))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(S(-1) + x**(S(-2)))/(x*(x**S(2) + S(-1))), x), x, sqrt(S(-1) + x**(S(-2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(S(-1) + x**(S(-2)))/(x*(x**S(2) + S(-1))**S(2)), x), x, -sqrt(S(-1) + x**(S(-2))) + S(1)/sqrt(S(-1) + x**(S(-2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(S(-1) + x**(S(-2)))/(x*(x**S(2) + S(-1))**S(3)), x), x, sqrt(S(-1) + x**(S(-2))) - S(2)/sqrt(S(-1) + x**(S(-2))) - S(1)/(S(3)*(S(-1) + x**(S(-2)))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*sqrt(S(1) + x**(S(-2)))/(x**S(2) + S(1))**S(2), x), x, S(1)/sqrt(S(1) + x**(S(-2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*sqrt(S(1) + x**(S(-2)))*(x**S(2) + S(1))), x), x, S(1)/sqrt(S(1) + x**(S(-2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(a + b*x**S(2) + sqrt(a + b*x**S(2))), x), x, log(sqrt(a + b*x**S(2)) + S(1))/b, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(x**S(2) - (x**S(2))**(S(1)/3)), x), x, S(3)*log(-(x**S(2))**(S(2)/3) + S(1))/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(x**S(2) + S(1))**S(3)*sqrt(x**S(4) + S(2)*x**S(2) + S(2)), x), x, (x**S(2) + S(1))**S(2)*(x**S(4) + S(2)*x**S(2) + S(2))**(S(3)/2)/S(10) - (x**S(4) + S(2)*x**S(2) + S(2))**(S(3)/2)/S(15), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*sqrt((-x**S(2) + S(1))/(x**S(2) + S(1))), x), x, sqrt((-x**S(2) + S(1))/(x**S(2) + S(1)))*(x**S(2) + S(1))/S(2) - atan(sqrt((-x**S(2) + S(1))/(x**S(2) + S(1)))), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(x*sqrt((-x**S(2) + S(1))/(x**S(2) + S(1))), x), x, sqrt((-x**S(2) + S(1))/(x**S(2) + S(1)))/((-x**S(2) + S(1))/(x**S(2) + S(1)) + S(1)) - atan(sqrt((-x**S(2) + S(1))/(x**S(2) + S(1)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*sqrt((-S(7)*x**S(2) + S(5))/(S(5)*x**S(2) + S(7))), x), x, sqrt((-S(7)*x**S(2) + S(5))/(S(5)*x**S(2) + S(7)))*(S(5)*x**S(2) + S(7))/S(10) - S(37)*sqrt(S(35))*atan(sqrt(S(35))*sqrt((-S(7)*x**S(2) + S(5))/(S(5)*x**S(2) + S(7)))/S(7))/S(175), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(x*sqrt((-S(7)*x**S(2) + S(5))/(S(5)*x**S(2) + S(7))), x), x, S(37)*sqrt((-S(7)*x**S(2) + S(5))/(S(5)*x**S(2) + S(7)))/(S(5)*(-S(35)*x**S(2) + S(25))/(S(5)*x**S(2) + S(7)) + S(35)) - S(37)*sqrt(S(35))*atan(sqrt(S(35))*sqrt((-S(7)*x**S(2) + S(5))/(S(5)*x**S(2) + S(7)))/S(7))/S(175), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*sqrt((-x**S(3) + S(1))/(x**S(3) + S(1))), x), x, sqrt((-x**S(3) + S(1))/(x**S(3) + S(1)))*(x**S(3) + S(1))/S(3) - S(2)*atan(sqrt((-x**S(3) + S(1))/(x**S(3) + S(1))))/S(3), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(x**S(2)*sqrt((-x**S(3) + S(1))/(x**S(3) + S(1))), x), x, S(2)*sqrt((-x**S(3) + S(1))/(x**S(3) + S(1)))/(S(3)*(-x**S(3) + S(1))/(x**S(3) + S(1)) + S(3)) - S(2)*atan(sqrt((-x**S(3) + S(1))/(x**S(3) + S(1))))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)*sqrt(-x**S(3) + S(1))*(x**S(9) + S(1))**S(2), x), x, S(2)*(-x**S(3) + S(1))**(S(17)/2)/S(51) - S(14)*(-x**S(3) + S(1))**(S(15)/2)/S(45) + S(14)*(-x**S(3) + S(1))**(S(13)/2)/S(13) - S(74)*(-x**S(3) + S(1))**(S(11)/2)/S(33) + S(86)*(-x**S(3) + S(1))**(S(9)/2)/S(27) - S(22)*(-x**S(3) + S(1))**(S(7)/2)/S(7) + S(32)*(-x**S(3) + S(1))**(S(5)/2)/S(15) - S(8)*(-x**S(3) + S(1))**(S(3)/2)/S(9), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(8)*sqrt((-x**S(3) + S(1))/(x**S(3) + S(1))), x), x, -S(8)*((-x**S(3) + S(1))/(x**S(3) + S(1)))**(S(3)/2)/(S(9)*((-x**S(3) + S(1))/(x**S(3) + S(1)) + S(1))**S(3)) + sqrt((-x**S(3) + S(1))/(x**S(3) + S(1)))/((-x**S(3) + S(1))/(x**S(3) + S(1)) + S(1)) - S(2)*sqrt((-x**S(3) + S(1))/(x**S(3) + S(1)))/(S(3)*((-x**S(3) + S(1))/(x**S(3) + S(1)) + S(1))**S(2)) - atan(sqrt((-x**S(3) + S(1))/(x**S(3) + S(1))))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(9)*sqrt((-S(7)*x**S(5) + S(5))/(S(5)*x**S(5) + S(7))), x), x, -S(999)*sqrt((-S(7)*x**S(5) + S(5))/(S(5)*x**S(5) + S(7)))/(S(175)*(-S(35)*x**S(5) + S(25))/(S(5)*x**S(5) + S(7)) + S(1225)) + S(2738)*sqrt((-S(7)*x**S(5) + S(5))/(S(5)*x**S(5) + S(7)))/(S(125)*((-S(35)*x**S(5) + S(25))/(S(5)*x**S(5) + S(7)) + S(7))**S(2)) + S(2257)*sqrt(S(35))*atan(sqrt(S(35))*sqrt((-S(7)*x**S(5) + S(5))/(S(5)*x**S(5) + S(7)))/S(7))/S(30625), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(sqrt(a + b*x**S(2))*(x**S(2) + S(1))) + x/(a + b*x**S(2))**(S(3)/2), x), x, -atanh(sqrt(a + b*x**S(2))/sqrt(a - b))/sqrt(a - b) - S(1)/(b*sqrt(a + b*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a + b*x**S(2) + x**S(2) + S(1))/((a + b*x**S(2))**(S(3)/2)*(x**S(2) + S(1))), x), x, -atanh(sqrt(a + b*x**S(2))/sqrt(a - b))/sqrt(a - b) - S(1)/(b*sqrt(a + b*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(sqrt(a + b*x**S(2))*(x**S(2) + S(1))) + x/(a + b*x**S(2))**(S(3)/2) + x/(a + b*x**S(2))**(S(5)/2), x), x, -atanh(sqrt(a + b*x**S(2))/sqrt(a - b))/sqrt(a - b) - S(1)/(b*sqrt(a + b*x**S(2))) - S(1)/(S(3)*b*(a + b*x**S(2))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a**S(2) + S(2)*a*b*x**S(2) + a*x**S(2) + a + b**S(2)*x**S(4) + b*x**S(4) + b*x**S(2) + x**S(2) + S(1))/((a + b*x**S(2))**(S(5)/2)*(x**S(2) + S(1))), x), x, -atanh(sqrt(a + b*x**S(2))/sqrt(a - b))/sqrt(a - b) - S(1)/(b*sqrt(a + b*x**S(2))) - S(1)/(S(3)*b*(a + b*x**S(2))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(sqrt(x) + x), x), x, S(2)*sqrt(sqrt(x) + x) - S(2)*atanh(sqrt(x)/sqrt(sqrt(x) + x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(sqrt(x) + x), x), x, sqrt(x)*sqrt(sqrt(x) + x)/S(6) + S(2)*x*sqrt(sqrt(x) + x)/S(3) - sqrt(sqrt(x) + x)/S(4) + atanh(sqrt(x)/sqrt(sqrt(x) + x))/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(-x)*(x + sqrt(-x)), x), x, -x**S(2)/S(2) + S(2)*(-x)**(S(5)/2)/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**(S(1)/4) + S(5))/(x + S(-6)), x), x, S(4)*x**(S(1)/4) + S(5)*log(-x + S(6)) - S(2)*S(6)**(S(1)/4)*atan(S(6)**(S(3)/4)*x**(S(1)/4)/S(6)) - S(2)*S(6)**(S(1)/4)*atanh(S(6)**(S(3)/4)*x**(S(1)/4)/S(6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(-x + sqrt(-x + S(4)) + S(4)), x), x, -S(2)*log(sqrt(-x + S(4)) + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x - sqrt(x + S(2)) + S(1)), x), x, (sqrt(S(5))/S(5) + S(1))*log(-S(2)*sqrt(x + S(2)) + S(1) + sqrt(S(5))) + (-sqrt(S(5))/S(5) + S(1))*log(-S(2)*sqrt(x + S(2)) - sqrt(S(5)) + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x + sqrt(x + S(1)) + S(4)), x), x, log(x + sqrt(x + S(1)) + S(4)) - S(2)*sqrt(S(11))*atan(sqrt(S(11))*(S(2)*sqrt(x + S(1)) + S(1))/S(11))/S(11), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x - sqrt(x + S(1))), x), x, (sqrt(S(5))/S(5) + S(1))*log(-S(2)*sqrt(x + S(1)) + S(1) + sqrt(S(5))) + (-sqrt(S(5))/S(5) + S(1))*log(-S(2)*sqrt(x + S(1)) - sqrt(S(5)) + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x - sqrt(x + S(2))), x), x, S(4)*log(-sqrt(x + S(2)) + S(2))/S(3) + S(2)*log(sqrt(x + S(2)) + S(1))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x - sqrt(-x + S(1))), x), x, (sqrt(S(5))/S(5) + S(1))*log(S(2)*sqrt(-x + S(1)) + S(1) + sqrt(S(5))) + (-sqrt(S(5))/S(5) + S(1))*log(S(2)*sqrt(-x + S(1)) - sqrt(S(5)) + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(sqrt(x) + x + S(1)), x), x, (-sqrt(x)/S(2) + S(-1)/4)*sqrt(sqrt(x) + x + S(1)) + S(2)*(sqrt(x) + x + S(1))**(S(3)/2)/S(3) - S(3)*asinh(sqrt(S(3))*(S(2)*sqrt(x) + S(1))/S(3))/S(8), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x + sqrt(x + S(1)) + S(1)), x), x, -(S(2)*sqrt(x + S(1)) + S(1))*sqrt(x + sqrt(x + S(1)) + S(1))/S(4) + S(2)*(x + sqrt(x + S(1)) + S(1))**(S(3)/2)/S(3) + atanh(sqrt(x + S(1))/sqrt(x + sqrt(x + S(1)) + S(1)))/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x + sqrt(x + S(-1))), x), x, S(2)*(x + sqrt(x + S(-1)))**(S(3)/2)/S(3) + sqrt(x + sqrt(x + S(-1)))*(-sqrt(x + S(-1))/S(2) + S(-1)/4) - S(3)*asinh(sqrt(S(3))*(S(2)*sqrt(x + S(-1)) + S(1))/S(3))/S(8), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(S(2)*x + sqrt(S(2)*x + S(-1))), x), x, (S(2)*x + sqrt(S(2)*x + S(-1)))**(S(3)/2)/S(3) - sqrt(S(2)*x + sqrt(S(2)*x + S(-1)))*(S(2)*sqrt(S(2)*x + S(-1)) + S(1))/S(8) - S(3)*asinh(sqrt(S(3))*(S(2)*sqrt(S(2)*x + S(-1)) + S(1))/S(3))/S(16), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(S(3)*x + sqrt(S(8)*x + S(-7))), x), x, sqrt(S(2))*(S(24)*x + S(8)*sqrt(S(8)*x + S(-7)))**(S(3)/2)/S(144) - sqrt(S(2))*sqrt(S(24)*x + S(8)*sqrt(S(8)*x + S(-7)))*(S(3)*sqrt(S(8)*x + S(-7)) + S(4))/S(72) - S(47)*sqrt(S(6))*asinh(sqrt(S(47))*(S(3)*sqrt(S(8)*x + S(-7)) + S(4))/S(47))/S(216), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(x + sqrt(x + S(1))), x), x, S(2)*sqrt(x + sqrt(x + S(1))) - atanh((S(2)*sqrt(x + S(1)) + S(1))/(S(2)*sqrt(x + sqrt(x + S(1))))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x + S(1))/(x + sqrt(S(6)*x + S(-9)) + S(4)), x), x, x - S(2)*sqrt(S(3))*sqrt(S(2)*x + S(-3)) + S(3)*log(x + sqrt(S(3))*sqrt(S(2)*x + S(-3)) + S(4)) + S(4)*sqrt(S(6))*atan(sqrt(S(6))*(sqrt(S(6)*x + S(-9)) + S(3))/S(12)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-x + S(12))/(x + sqrt(S(6)*x + S(-9)) + S(4)), x), x, -x + S(2)*sqrt(S(3))*sqrt(S(2)*x + S(-3)) + S(10)*log(x + sqrt(S(3))*sqrt(S(2)*x + S(-3)) + S(4)) - S(21)*sqrt(S(6))*atan(sqrt(S(6))*(sqrt(S(6)*x + S(-9)) + S(3))/S(12))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(3) + S(-1))/(sqrt(x)*(x**S(2) + S(1))), x), x, S(2)*x**(S(3)/2)/S(3) - sqrt(S(2))*atan(sqrt(S(2))*sqrt(x) + S(-1)) - sqrt(S(2))*atan(sqrt(S(2))*sqrt(x) + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(S(2)*sqrt(x + S(-1))*sqrt(x - sqrt(x + S(-1)))), x), x, -asinh(sqrt(S(3))*(-S(2)*sqrt(x + S(-1)) + S(1))/S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**(S(7)/2) + S(1))/(-x**S(2) + S(1)), x), x, -S(2)*x**(S(5)/2)/S(5) - S(2)*sqrt(x) - log(-sqrt(x) + S(1)) + log(x + S(1))/S(2) + atan(sqrt(x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x + S(4))/((S(2)*x + S(-1))**(S(1)/3) + sqrt(S(2)*x + S(-1))), x), x, -x + S(3)*(S(2)*x + S(-1))**(S(7)/6)/S(7) + S(3)*(S(2)*x + S(-1))**(S(5)/6)/S(5) + S(18)*(S(2)*x + S(-1))**(S(1)/6) - S(3)*(S(2)*x + S(-1))**(S(4)/3)/S(8) - S(3)*(S(2)*x + S(-1))**(S(2)/3)/S(4) - S(9)*(S(2)*x + S(-1))**(S(1)/3) + (S(2)*x + S(-1))**(S(3)/2)/S(3) + S(6)*sqrt(S(2)*x + S(-1)) - S(18)*log((S(2)*x + S(-1))**(S(1)/6) + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(sqrt(sqrt(x) + S(1)) + S(2)), x), x, S(8)*(sqrt(sqrt(x) + S(1)) + S(2))**(S(7)/2)/S(7) - S(48)*(sqrt(sqrt(x) + S(1)) + S(2))**(S(5)/2)/S(5) + S(88)*(sqrt(sqrt(x) + S(1)) + S(2))**(S(3)/2)/S(3) - S(48)*sqrt(sqrt(sqrt(x) + S(1)) + S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(sqrt(sqrt(x) + S(4)) + S(2)), x), x, S(8)*(sqrt(sqrt(x) + S(4)) + S(2))**(S(9)/2)/S(9) - S(48)*(sqrt(sqrt(x) + S(4)) + S(2))**(S(7)/2)/S(7) + S(64)*(sqrt(sqrt(x) + S(4)) + S(2))**(S(5)/2)/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(-sqrt(sqrt(S(5)*x + S(-9)) + S(4)) + S(2)), x), x, S(8)*(-sqrt(sqrt(S(5)*x + S(-9)) + S(4)) + S(2))**(S(9)/2)/S(45) - S(48)*(-sqrt(sqrt(S(5)*x + S(-9)) + S(4)) + S(2))**(S(7)/2)/S(35) + S(64)*(-sqrt(sqrt(S(5)*x + S(-9)) + S(4)) + S(2))**(S(5)/2)/S(25), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(sqrt(sqrt(x) + S(1)) + S(2)), x), x, S(8)*(sqrt(sqrt(x) + S(1)) + S(2))**(S(7)/2)/S(7) - S(48)*(sqrt(sqrt(x) + S(1)) + S(2))**(S(5)/2)/S(5) + S(88)*(sqrt(sqrt(x) + S(1)) + S(2))**(S(3)/2)/S(3) - S(48)*sqrt(sqrt(sqrt(x) + S(1)) + S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(sqrt(sqrt(sqrt(x) + S(1)) + S(1)) + S(1)), x), x, S(16)*(sqrt(sqrt(sqrt(x) + S(1)) + S(1)) + S(1))**(S(17)/2)/S(17) - S(112)*(sqrt(sqrt(sqrt(x) + S(1)) + S(1)) + S(1))**(S(15)/2)/S(15) + S(288)*(sqrt(sqrt(sqrt(x) + S(1)) + S(1)) + S(1))**(S(13)/2)/S(13) - S(320)*(sqrt(sqrt(sqrt(x) + S(1)) + S(1)) + S(1))**(S(11)/2)/S(11) + S(112)*(sqrt(sqrt(sqrt(x) + S(1)) + S(1)) + S(1))**(S(9)/2)/S(9) + S(48)*(sqrt(sqrt(sqrt(x) + S(1)) + S(1)) + S(1))**(S(7)/2)/S(7) - S(32)*(sqrt(sqrt(sqrt(x) + S(1)) + S(1)) + S(1))**(S(5)/2)/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(sqrt(sqrt(S(2)*sqrt(x) + S(-1)) + S(3)) + S(2)), x), x, S(4)*(sqrt(sqrt(S(2)*sqrt(x) + S(-1)) + S(3)) + S(2))**(S(17)/2)/S(17) - S(56)*(sqrt(sqrt(S(2)*sqrt(x) + S(-1)) + S(3)) + S(2))**(S(15)/2)/S(15) + S(300)*(sqrt(sqrt(S(2)*sqrt(x) + S(-1)) + S(3)) + S(2))**(S(13)/2)/S(13) - S(760)*(sqrt(sqrt(S(2)*sqrt(x) + S(-1)) + S(3)) + S(2))**(S(11)/2)/S(11) + S(304)*(sqrt(sqrt(S(2)*sqrt(x) + S(-1)) + S(3)) + S(2))**(S(9)/2)/S(3) - S(480)*(sqrt(sqrt(S(2)*sqrt(x) + S(-1)) + S(3)) + S(2))**(S(7)/2)/S(7) + S(136)*(sqrt(sqrt(S(2)*sqrt(x) + S(-1)) + S(3)) + S(2))**(S(5)/2)/S(5) - S(16)*(sqrt(sqrt(S(2)*sqrt(x) + S(-1)) + S(3)) + S(2))**(S(3)/2)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*sqrt(sqrt(sqrt(x + S(-1)) + S(1)) + S(1)), x), x, S(8)*(sqrt(sqrt(x + S(-1)) + S(1)) + S(1))**(S(17)/2)/S(17) - S(56)*(sqrt(sqrt(x + S(-1)) + S(1)) + S(1))**(S(15)/2)/S(15) + S(144)*(sqrt(sqrt(x + S(-1)) + S(1)) + S(1))**(S(13)/2)/S(13) - S(160)*(sqrt(sqrt(x + S(-1)) + S(1)) + S(1))**(S(11)/2)/S(11) + S(8)*(sqrt(sqrt(x + S(-1)) + S(1)) + S(1))**(S(9)/2) - S(24)*(sqrt(sqrt(x + S(-1)) + S(1)) + S(1))**(S(7)/2)/S(7) + S(16)*(sqrt(sqrt(x + S(-1)) + S(1)) + S(1))**(S(5)/2)/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(x + S(-1))*sqrt(x - sqrt(x + S(-1)))), x), x, -S(2)*asinh(sqrt(S(3))*(-S(2)*sqrt(x + S(-1)) + S(1))/S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(x + sqrt(S(2)*x + S(-1)) + S(1)), x), x, S(2)*sqrt(x + sqrt(S(2)*x + S(-1)) + S(1)) - sqrt(S(2))*asinh(sqrt(S(2))*(sqrt(S(2)*x + S(-1)) + S(1))/S(2)), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(S(1)/sqrt(x + sqrt(S(2)*x + S(-1)) + S(1)), x), x, sqrt(S(2))*sqrt(S(2)*x + S(2)*sqrt(S(2)*x + S(-1)) + S(2)) - sqrt(S(2))*asinh(sqrt(S(2))*(sqrt(S(2)*x + S(-1)) + S(1))/S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((p*x + q)/((f + sqrt(a*x + b))*sqrt(a*x + b)), x), x, p*x/a - S(2)*f*p*sqrt(a*x + b)/a**S(2) - (-S(2)*a*q + S(2)*b*p - S(2)*f**S(2)*p)*log(f + sqrt(a*x + b))/a**S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(-sqrt(x) - x + S(1)), x), x, (-sqrt(x)/S(2) + S(-1)/4)*sqrt(-sqrt(x) - x + S(1)) - S(2)*(-sqrt(x) - x + S(1))**(S(3)/2)/S(3) - S(5)*asin(sqrt(S(5))*(S(2)*sqrt(x) + S(1))/S(5))/S(8), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(6)*sqrt(x) + x + S(9))/(S(4)*sqrt(x) + x), x), x, S(4)*sqrt(x) + x + S(2)*log(sqrt(x) + S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-S(8)*x**(S(7)/2) + S(6))/(-S(9)*sqrt(x) + S(5)), x), x, S(80)*x**(S(7)/2)/S(567) + S(400)*x**(S(5)/2)/S(6561) + S(50000)*x**(S(3)/2)/S(1594323) - S(56145628)*sqrt(x)/S(43046721) + S(2)*x**S(4)/S(9) + S(200)*x**S(3)/S(2187) + S(2500)*x**S(2)/S(59049) + S(125000)*x/S(4782969) - S(280728140)*log(-S(9)*sqrt(x) + S(5))/S(387420489), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x + S(1))*(x**S(3) + S(1))/(x**S(2) + S(1)), x), x, S(2)*(x + S(1))**(S(5)/2)/S(5) - S(2)*(x + S(1))**(S(3)/2)/S(3) - S(2)*sqrt(x + S(1)) + (S(1) - I)**(S(3)/2)*atanh(sqrt(x + S(1))/sqrt(S(1) - I)) + (S(1) + I)**(S(3)/2)*atanh(sqrt(x + S(1))/sqrt(S(1) + I)), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(sqrt(x + S(1))*(x**S(3) + S(1))/(x**S(2) + S(1)), x), x, S(2)*(x + S(1))**(S(5)/2)/S(5) - S(2)*(x + S(1))**(S(3)/2)/S(3) - S(2)*sqrt(x + S(1)) - log(x - sqrt(S(2) + S(2)*sqrt(S(2)))*sqrt(x + S(1)) + S(1) + sqrt(S(2)))/(S(2)*sqrt(S(1) + sqrt(S(2)))) + log(x + sqrt(S(2) + S(2)*sqrt(S(2)))*sqrt(x + S(1)) + S(1) + sqrt(S(2)))/(S(2)*sqrt(S(1) + sqrt(S(2)))) - sqrt(S(1) + sqrt(S(2)))*atan((-S(2)*sqrt(x + S(1)) + sqrt(S(2) + S(2)*sqrt(S(2))))/sqrt(S(-2) + S(2)*sqrt(S(2)))) + sqrt(S(1) + sqrt(S(2)))*atan((S(2)*sqrt(x + S(1)) + sqrt(S(2) + S(2)*sqrt(S(2))))/sqrt(S(-2) + S(2)*sqrt(S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(-sqrt(x) + x + S(-1))/(sqrt(x)*(x + S(-1))), x), x, atan((-sqrt(x) + S(3))/(S(2)*sqrt(-sqrt(x) + x + S(-1)))) - S(2)*atanh((-S(2)*sqrt(x) + S(1))/(S(2)*sqrt(-sqrt(x) + x + S(-1)))) - atanh((S(3)*sqrt(x) + S(1))/(S(2)*sqrt(-sqrt(x) + x + S(-1)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*sqrt(x + S(1)) + S(1))/(x*sqrt(x + S(1))*sqrt(x + sqrt(x + S(1)))), x), x, -atan((sqrt(x + S(1)) + S(3))/(S(2)*sqrt(x + sqrt(x + S(1))))) + S(3)*atanh((-S(3)*sqrt(x + S(1)) + S(1))/(S(2)*sqrt(x + sqrt(x + S(1))))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(x)*sqrt(x + S(1))), x), x, S(2)*asinh(sqrt(x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x/(x + S(1)))/x, x), x, S(2)*asinh(sqrt(x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x)/sqrt(x + S(1)), x), x, sqrt(x)*sqrt(x + S(1)) - asinh(sqrt(x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x/(x + S(1))), x), x, sqrt(x)*sqrt(x + S(1)) - asinh(sqrt(x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x + S(-1))/(x**S(2)*sqrt(x + S(1))), x), x, atan(sqrt(x + S(-1))*sqrt(x + S(1))) - sqrt(x + S(-1))*sqrt(x + S(1))/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt((x + S(-1))/(x + S(1)))/x**S(2), x), x, atan(sqrt(x + S(-1))*sqrt(x + S(1))) - sqrt(x + S(-1))*sqrt(x + S(1))/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*sqrt(x + S(-1))/sqrt(x + S(1)), x), x, x**S(2)*(x + S(-1))**(S(3)/2)*sqrt(x + S(1))/S(4) + (-x/S(12) + S(7)/24)*(x + S(-1))**(S(3)/2)*sqrt(x + S(1)) - S(3)*sqrt(x + S(-1))*sqrt(x + S(1))/S(8) + S(3)*acosh(x)/S(8), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*sqrt((x + S(-1))/(x + S(1))), x), x, x**S(2)*(x + S(-1))**(S(3)/2)*sqrt(x + S(1))/S(4) + (-x/S(12) + S(7)/24)*(x + S(-1))**(S(3)/2)*sqrt(x + S(1)) - S(3)*sqrt(x + S(-1))*sqrt(x + S(1))/S(8) + S(3)*acosh(x)/S(8), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(-x/(x + S(1)))/x, x), x, S(2)*atan(sqrt(-x/(x + S(1)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt((-x + S(1))/(x + S(1)))/(x + S(-1)), x), x, S(2)*atan(sqrt((-x + S(1))/(x + S(1)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt((a + b*x)/(-b*x + c))/(a + b*x), x), x, S(2)*atan(sqrt((a + b*x)/(-b*x + c)))/b, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt((a + b*x)/(c + d*x))/(a + b*x), x), x, S(2)*atanh(sqrt(d)*sqrt((a + b*x)/(c + d*x))/sqrt(b))/(sqrt(b)*sqrt(d)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(-x/(x + S(1))), x), x, sqrt(-x/(x + S(1)))*(x + S(1)) - atan(sqrt(-x/(x + S(1)))), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(sqrt(-x/(x + S(1))), x), x, sqrt(-x/(x + S(1)))/(-x/(x + S(1)) + S(1)) - atan(sqrt(-x/(x + S(1)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt((-x + S(1))/(x + S(1))), x), x, sqrt((-x + S(1))/(x + S(1)))*(x + S(1)) - S(2)*atan(sqrt((-x + S(1))/(x + S(1)))), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(sqrt((-x + S(1))/(x + S(1))), x), x, S(2)*sqrt((-x + S(1))/(x + S(1)))/((-x + S(1))/(x + S(1)) + S(1)) - S(2)*atan(sqrt((-x + S(1))/(x + S(1)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt((a + x)/(a - x)), x), x, S(2)*a*atan(sqrt((a + x)/(a - x))) - sqrt((a + x)/(a - x))*(a - x), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(sqrt((a + x)/(a - x)), x), x, -S(2)*a*sqrt((a + x)/(a - x))/(S(1) + (a + x)/(a - x)) + S(2)*a*atan(sqrt((a + x)/(a - x))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt((-a + x)/(a + x)), x), x, -S(2)*a*atanh(sqrt(-(a - x)/(a + x))) + sqrt(-(a - x)/(a + x))*(a + x), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(sqrt((-a + x)/(a + x)), x), x, S(2)*a*sqrt(-(a - x)/(a + x))/((a - x)/(a + x) + S(1)) - S(2)*a*atanh(sqrt(-(a - x)/(a + x))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt((a + b*x)/(c + d*x)), x), x, sqrt((a + b*x)/(c + d*x))*(c + d*x)/d - (-a*d + b*c)*atanh(sqrt(d)*sqrt((a + b*x)/(c + d*x))/sqrt(b))/(sqrt(b)*d**(S(3)/2)), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(sqrt((a + b*x)/(c + d*x)), x), x, sqrt((a + b*x)/(c + d*x))*(-a*d + b*c)/(d*(b - d*(a + b*x)/(c + d*x))) - (-a*d + b*c)*atanh(sqrt(d)*sqrt((a + b*x)/(c + d*x))/sqrt(b))/(sqrt(b)*d**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt((x + S(-1))/(S(3)*x + S(5))), x), x, sqrt(x + S(-1))*sqrt(S(3)*x + S(5))/S(3) - S(8)*sqrt(S(3))*asinh(sqrt(S(6))*sqrt(x + S(-1))/S(4))/S(9), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt((S(5)*x + S(-1))/(S(7)*x + S(1)))/x**S(2), x), x, -S(12)*atan(sqrt(S(7)*x + S(1))/sqrt(S(5)*x + S(-1))) - sqrt(S(5)*x + S(-1))*sqrt(S(7)*x + S(1))/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(sqrt((-x + S(1))/(x + S(1)))*(x + S(1))), x), x, -(-x + S(1))/sqrt((-x + S(1))/(x + S(1))), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(x/(sqrt((-x + S(1))/(x + S(1)))*(x + S(1))), x), x, -S(2)*sqrt((-x + S(1))/(x + S(1)))/((-x + S(1))/(x + S(1)) + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(sqrt(S(-1) + S(2)/(x + S(1)))*(x + S(1))), x), x, -sqrt(S(-1) + S(2)/(x + S(1)))*(x + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(sqrt((x + S(2))/(x + S(3)))*(x + S(1))), x), x, sqrt(x + S(2))*sqrt(x + S(3)) - asinh(sqrt(x + S(2))) + S(2)*sqrt(S(2))*atanh(sqrt(S(2))*sqrt(x + S(2))/sqrt(x + S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(S(1) + S(1)/x)/(x + S(1))**S(2), x), x, S(2)/sqrt(S(1) + S(1)/x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(S(1) + S(1)/x)/sqrt(-x**S(2) + S(1)), x), x, sqrt(x)*sqrt(S(1) + S(1)/x)*asin(S(2)*x + S(-1))/sqrt(x + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**m*sqrt(a + b*sqrt(c/x)), x), x, S(4)*x**(m + S(1))*(a + b*sqrt(c/x))**(S(3)/2)*hyper((S(1), -S(2)*m + S(-1)/2), (S(5)/2,), (a + b*sqrt(c/x))/a)/(S(3)*a), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(x**m*sqrt(a + b*sqrt(c/x)), x), x, S(4)*b**S(2)*c*x**m*(-b*sqrt(c/x)/a)**(S(2)*m)*(a + b*sqrt(c/x))**(S(3)/2)*hyper((S(3)/2, S(2)*m + S(3)), (S(5)/2,), S(1) + b*sqrt(c/x)/a)/(S(3)*a**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*sqrt(a + b*sqrt(c/x)), x), x, x**S(2)*sqrt(a + b*sqrt(c/x))/S(2) + b*c**S(2)*sqrt(a + b*sqrt(c/x))/(S(12)*a*(c/x)**(S(3)/2)) - S(5)*b**S(2)*c*x*sqrt(a + b*sqrt(c/x))/(S(48)*a**S(2)) + S(5)*b**S(3)*c**S(2)*sqrt(a + b*sqrt(c/x))/(S(32)*a**S(3)*sqrt(c/x)) - S(5)*b**S(4)*c**S(2)*atanh(sqrt(a + b*sqrt(c/x))/sqrt(a))/(S(32)*a**(S(7)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + b*sqrt(c/x)), x), x, x*sqrt(a + b*sqrt(c/x)) + b*c*sqrt(a + b*sqrt(c/x))/(S(2)*a*sqrt(c/x)) - b**S(2)*c*atanh(sqrt(a + b*sqrt(c/x))/sqrt(a))/(S(2)*a**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + b*sqrt(c/x))/x, x), x, S(4)*sqrt(a)*atanh(sqrt(a + b*sqrt(c/x))/sqrt(a)) - S(4)*sqrt(a + b*sqrt(c/x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + b*sqrt(c/x))/x**S(2), x), x, S(4)*a*(a + b*sqrt(c/x))**(S(3)/2)/(S(3)*b**S(2)*c) - S(4)*(a + b*sqrt(c/x))**(S(5)/2)/(S(5)*b**S(2)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + b*sqrt(c/x))/x**S(3), x), x, S(4)*a**S(3)*(a + b*sqrt(c/x))**(S(3)/2)/(S(3)*b**S(4)*c**S(2)) - S(12)*a**S(2)*(a + b*sqrt(c/x))**(S(5)/2)/(S(5)*b**S(4)*c**S(2)) + S(12)*a*(a + b*sqrt(c/x))**(S(7)/2)/(S(7)*b**S(4)*c**S(2)) - S(4)*(a + b*sqrt(c/x))**(S(9)/2)/(S(9)*b**S(4)*c**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + b*sqrt(c/x))/x**S(4), x), x, S(4)*a**S(5)*(a + b*sqrt(c/x))**(S(3)/2)/(S(3)*b**S(6)*c**S(3)) - S(4)*a**S(4)*(a + b*sqrt(c/x))**(S(5)/2)/(b**S(6)*c**S(3)) + S(40)*a**S(3)*(a + b*sqrt(c/x))**(S(7)/2)/(S(7)*b**S(6)*c**S(3)) - S(40)*a**S(2)*(a + b*sqrt(c/x))**(S(9)/2)/(S(9)*b**S(6)*c**S(3)) + S(20)*a*(a + b*sqrt(c/x))**(S(11)/2)/(S(11)*b**S(6)*c**S(3)) - S(4)*(a + b*sqrt(c/x))**(S(13)/2)/(S(13)*b**S(6)*c**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**m/sqrt(a + b*sqrt(c/x)), x), x, S(4)*x**(m + S(1))*sqrt(a + b*sqrt(c/x))*hyper((S(1), -S(2)*m + S(-3)/2), (S(3)/2,), (a + b*sqrt(c/x))/a)/a, expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(x**m/sqrt(a + b*sqrt(c/x)), x), x, S(4)*b**S(2)*c*x**m*(-b*sqrt(c/x)/a)**(S(2)*m)*sqrt(a + b*sqrt(c/x))*hyper((S(1)/2, S(2)*m + S(3)), (S(3)/2,), S(1) + b*sqrt(c/x)/a)/a**S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/sqrt(a + b*sqrt(c/x)), x), x, x**S(2)*sqrt(a + b*sqrt(c/x))/(S(2)*a) - S(7)*b*c**S(2)*sqrt(a + b*sqrt(c/x))/(S(12)*a**S(2)*(c/x)**(S(3)/2)) + S(35)*b**S(2)*c*x*sqrt(a + b*sqrt(c/x))/(S(48)*a**S(3)) - S(35)*b**S(3)*c**S(2)*sqrt(a + b*sqrt(c/x))/(S(32)*a**S(4)*sqrt(c/x)) + S(35)*b**S(4)*c**S(2)*atanh(sqrt(a + b*sqrt(c/x))/sqrt(a))/(S(32)*a**(S(9)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(a + b*sqrt(c/x)), x), x, x*sqrt(a + b*sqrt(c/x))/a - S(3)*b*c*sqrt(a + b*sqrt(c/x))/(S(2)*a**S(2)*sqrt(c/x)) + S(3)*b**S(2)*c*atanh(sqrt(a + b*sqrt(c/x))/sqrt(a))/(S(2)*a**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*sqrt(a + b*sqrt(c/x))), x), x, S(4)*atanh(sqrt(a + b*sqrt(c/x))/sqrt(a))/sqrt(a), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*sqrt(a + b*sqrt(c/x))), x), x, S(4)*a*sqrt(a + b*sqrt(c/x))/(b**S(2)*c) - S(4)*(a + b*sqrt(c/x))**(S(3)/2)/(S(3)*b**S(2)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*sqrt(a + b*sqrt(c/x))), x), x, S(4)*a**S(3)*sqrt(a + b*sqrt(c/x))/(b**S(4)*c**S(2)) - S(4)*a**S(2)*(a + b*sqrt(c/x))**(S(3)/2)/(b**S(4)*c**S(2)) + S(12)*a*(a + b*sqrt(c/x))**(S(5)/2)/(S(5)*b**S(4)*c**S(2)) - S(4)*(a + b*sqrt(c/x))**(S(7)/2)/(S(7)*b**S(4)*c**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(4)*sqrt(a + b*sqrt(c/x))), x), x, S(4)*a**S(5)*sqrt(a + b*sqrt(c/x))/(b**S(6)*c**S(3)) - S(20)*a**S(4)*(a + b*sqrt(c/x))**(S(3)/2)/(S(3)*b**S(6)*c**S(3)) + S(8)*a**S(3)*(a + b*sqrt(c/x))**(S(5)/2)/(b**S(6)*c**S(3)) - S(40)*a**S(2)*(a + b*sqrt(c/x))**(S(7)/2)/(S(7)*b**S(6)*c**S(3)) + S(20)*a*(a + b*sqrt(c/x))**(S(9)/2)/(S(9)*b**S(6)*c**S(3)) - S(4)*(a + b*sqrt(c/x))**(S(11)/2)/(S(11)*b**S(6)*c**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(sqrt(S(1)/x) + S(1)), x), x, x*sqrt(sqrt(S(1)/x) + S(1)) - S(3)*sqrt(sqrt(S(1)/x) + S(1))/(S(2)*sqrt(S(1)/x)) + S(3)*atanh(sqrt(sqrt(S(1)/x) + S(1)))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**m*sqrt(a + b*sqrt(d/x) + c/x), x), x, x**(m + S(1))*sqrt(a + b*sqrt(d/x) + c/x)*AppellF1(-S(2)*m + S(-2), S(-1)/2, S(-1)/2, -S(2)*m + S(-1), -S(2)*c*sqrt(d/x)/(sqrt(d)*(b*sqrt(d) - sqrt(-S(4)*a*c + b**S(2)*d))), -S(2)*c*sqrt(d/x)/(sqrt(d)*(b*sqrt(d) + sqrt(-S(4)*a*c + b**S(2)*d))))/((m + S(1))*sqrt(S(2)*c*sqrt(d/x)/(sqrt(d)*(b*sqrt(d) - sqrt(-S(4)*a*c + b**S(2)*d))) + S(1))*sqrt(S(2)*c*sqrt(d/x)/(sqrt(d)*(b*sqrt(d) + sqrt(-S(4)*a*c + b**S(2)*d))) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*sqrt(a + b*sqrt(d/x) + c/x), x), x, x**S(3)*(a + b*sqrt(d/x) + c/x)**(S(3)/2)/(S(3)*a) - S(3)*b*d**S(3)*(a + b*sqrt(d/x) + c/x)**(S(3)/2)/(S(10)*a**S(2)*(d/x)**(S(5)/2)) - x**S(2)*(S(20)*a*c - S(21)*b**S(2)*d)*(a + b*sqrt(d/x) + c/x)**(S(3)/2)/(S(80)*a**S(3)) + S(7)*b*d**S(2)*(S(28)*a*c - S(15)*b**S(2)*d)*(a + b*sqrt(d/x) + c/x)**(S(3)/2)/(S(480)*a**S(4)*(d/x)**(S(3)/2)) + x*(S(2)*a + b*sqrt(d/x))*sqrt(a + b*sqrt(d/x) + c/x)*(S(16)*a**S(2)*c**S(2) - S(56)*a*b**S(2)*c*d + S(21)*b**S(4)*d**S(2))/(S(256)*a**S(5)) + (S(4)*a*c - b**S(2)*d)*(S(16)*a**S(2)*c**S(2) - S(56)*a*b**S(2)*c*d + S(21)*b**S(4)*d**S(2))*atanh((S(2)*a + b*sqrt(d/x))/(S(2)*sqrt(a)*sqrt(a + b*sqrt(d/x) + c/x)))/(S(512)*a**(S(11)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*sqrt(a + b*sqrt(d/x) + c/x), x), x, x**S(2)*(a + b*sqrt(d/x) + c/x)**(S(3)/2)/(S(2)*a) - S(5)*b*d**S(2)*(a + b*sqrt(d/x) + c/x)**(S(3)/2)/(S(12)*a**S(2)*(d/x)**(S(3)/2)) - x*(S(2)*a + b*sqrt(d/x))*(S(4)*a*c - S(5)*b**S(2)*d)*sqrt(a + b*sqrt(d/x) + c/x)/(S(32)*a**S(3)) - (S(4)*a*c - S(5)*b**S(2)*d)*(S(4)*a*c - b**S(2)*d)*atanh((S(2)*a + b*sqrt(d/x))/(S(2)*sqrt(a)*sqrt(a + b*sqrt(d/x) + c/x)))/(S(64)*a**(S(7)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + b*sqrt(d/x) + c/x), x), x, x*(S(2)*a + b*sqrt(d/x))*sqrt(a + b*sqrt(d/x) + c/x)/(S(2)*a) + (S(4)*a*c - b**S(2)*d)*atanh((S(2)*a + b*sqrt(d/x))/(S(2)*sqrt(a)*sqrt(a + b*sqrt(d/x) + c/x)))/(S(4)*a**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + b*sqrt(d/x) + c/x)/x, x), x, S(2)*sqrt(a)*atanh((S(2)*a + b*sqrt(d/x))/(S(2)*sqrt(a)*sqrt(a + b*sqrt(d/x) + c/x))) - b*sqrt(d)*atanh((b*d + S(2)*c*sqrt(d/x))/(S(2)*sqrt(c)*sqrt(d)*sqrt(a + b*sqrt(d/x) + c/x)))/sqrt(c) - S(2)*sqrt(a + b*sqrt(d/x) + c/x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + b*sqrt(d/x) + c/x)/x**S(2), x), x, b*(b*d + S(2)*c*sqrt(d/x))*sqrt(a + b*sqrt(d/x) + c/x)/(S(4)*c**S(2)) + b*sqrt(d)*(S(4)*a*c - b**S(2)*d)*atanh((b*d + S(2)*c*sqrt(d/x))/(S(2)*sqrt(c)*sqrt(d)*sqrt(a + b*sqrt(d/x) + c/x)))/(S(8)*c**(S(5)/2)) - S(2)*(a + b*sqrt(d/x) + c/x)**(S(3)/2)/(S(3)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + b*sqrt(d/x) + c/x)/x**S(3), x), x, -b*(S(12)*a*c - S(7)*b**S(2)*d)*(b*d + S(2)*c*sqrt(d/x))*sqrt(a + b*sqrt(d/x) + c/x)/(S(64)*c**S(4)) - b*sqrt(d)*(S(4)*a*c - b**S(2)*d)*(S(12)*a*c - S(7)*b**S(2)*d)*atanh((b*d + S(2)*c*sqrt(d/x))/(S(2)*sqrt(c)*sqrt(d)*sqrt(a + b*sqrt(d/x) + c/x)))/(S(128)*c**(S(9)/2)) - S(2)*(a + b*sqrt(d/x) + c/x)**(S(3)/2)/(S(5)*c*x) + (a + b*sqrt(d/x) + c/x)**(S(3)/2)*(S(32)*a*c - S(35)*b**S(2)*d + S(42)*b*c*sqrt(d/x))/(S(120)*c**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + b*sqrt(d/x) + c/x)/x**S(4), x), x, S(11)*b*(d/x)**(S(3)/2)*(a + b*sqrt(d/x) + c/x)**(S(3)/2)/(S(42)*c**S(2)*d) + b*(b*d + S(2)*c*sqrt(d/x))*sqrt(a + b*sqrt(d/x) + c/x)*(S(80)*a**S(2)*c**S(2) - S(120)*a*b**S(2)*c*d + S(33)*b**S(4)*d**S(2))/(S(512)*c**S(6)) + b*sqrt(d)*(S(4)*a*c - b**S(2)*d)*(S(80)*a**S(2)*c**S(2) - S(120)*a*b**S(2)*c*d + S(33)*b**S(4)*d**S(2))*atanh((b*d + S(2)*c*sqrt(d/x))/(S(2)*sqrt(c)*sqrt(d)*sqrt(a + b*sqrt(d/x) + c/x)))/(S(1024)*c**(S(13)/2)) - S(2)*(a + b*sqrt(d/x) + c/x)**(S(3)/2)/(S(7)*c*x**S(2)) + (S(32)*a*c - S(33)*b**S(2)*d)*(a + b*sqrt(d/x) + c/x)**(S(3)/2)/(S(140)*c**S(3)*x) - (a + b*sqrt(d/x) + c/x)**(S(3)/2)*(S(1024)*a**S(2)*c**S(2) - S(3276)*a*b**S(2)*c*d + S(1155)*b**S(4)*d**S(2) + S(18)*b*c*sqrt(d/x)*(S(148)*a*c - S(77)*b**S(2)*d))/(S(6720)*c**S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**m/sqrt(a + b*sqrt(d/x) + c/x), x), x, x**(m + S(1))*sqrt(S(2)*c*sqrt(d/x)/(sqrt(d)*(b*sqrt(d) - sqrt(-S(4)*a*c + b**S(2)*d))) + S(1))*sqrt(S(2)*c*sqrt(d/x)/(sqrt(d)*(b*sqrt(d) + sqrt(-S(4)*a*c + b**S(2)*d))) + S(1))*AppellF1(-S(2)*m + S(-2), S(1)/2, S(1)/2, -S(2)*m + S(-1), -S(2)*c*sqrt(d/x)/(sqrt(d)*(b*sqrt(d) - sqrt(-S(4)*a*c + b**S(2)*d))), -S(2)*c*sqrt(d/x)/(sqrt(d)*(b*sqrt(d) + sqrt(-S(4)*a*c + b**S(2)*d))))/((m + S(1))*sqrt(a + b*sqrt(d/x) + c/x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/sqrt(a + b*sqrt(d/x) + c/x), x), x, x**S(3)*sqrt(a + b*sqrt(d/x) + c/x)/(S(3)*a) - S(11)*b*d**S(3)*sqrt(a + b*sqrt(d/x) + c/x)/(S(30)*a**S(2)*(d/x)**(S(5)/2)) - x**S(2)*(S(100)*a*c - S(99)*b**S(2)*d)*sqrt(a + b*sqrt(d/x) + c/x)/(S(240)*a**S(3)) + b*d**S(2)*(S(156)*a*c - S(77)*b**S(2)*d)*sqrt(a + b*sqrt(d/x) + c/x)/(S(160)*a**S(4)*(d/x)**(S(3)/2)) + x*sqrt(a + b*sqrt(d/x) + c/x)*(S(400)*a**S(2)*c**S(2) - S(1176)*a*b**S(2)*c*d + S(385)*b**S(4)*d**S(2))/(S(640)*a**S(5)) - S(7)*b*d*sqrt(a + b*sqrt(d/x) + c/x)*(S(528)*a**S(2)*c**S(2) - S(680)*a*b**S(2)*c*d + S(165)*b**S(4)*d**S(2))/(S(1280)*a**S(6)*sqrt(d/x)) - (S(320)*a**S(3)*c**S(3) - S(1680)*a**S(2)*b**S(2)*c**S(2)*d + S(1260)*a*b**S(4)*c*d**S(2) - S(231)*b**S(6)*d**S(3))*atanh((S(2)*a + b*sqrt(d/x))/(S(2)*sqrt(a)*sqrt(a + b*sqrt(d/x) + c/x)))/(S(512)*a**(S(13)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/sqrt(a + b*sqrt(d/x) + c/x), x), x, x**S(2)*sqrt(a + b*sqrt(d/x) + c/x)/(S(2)*a) - S(7)*b*d**S(2)*sqrt(a + b*sqrt(d/x) + c/x)/(S(12)*a**S(2)*(d/x)**(S(3)/2)) - x*(S(36)*a*c - S(35)*b**S(2)*d)*sqrt(a + b*sqrt(d/x) + c/x)/(S(48)*a**S(3)) + S(5)*b*d*(S(44)*a*c - S(21)*b**S(2)*d)*sqrt(a + b*sqrt(d/x) + c/x)/(S(96)*a**S(4)*sqrt(d/x)) + (S(48)*a**S(2)*c**S(2) - S(120)*a*b**S(2)*c*d + S(35)*b**S(4)*d**S(2))*atanh((S(2)*a + b*sqrt(d/x))/(S(2)*sqrt(a)*sqrt(a + b*sqrt(d/x) + c/x)))/(S(64)*a**(S(9)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(a + b*sqrt(d/x) + c/x), x), x, x*sqrt(a + b*sqrt(d/x) + c/x)/a - S(3)*b*d*sqrt(a + b*sqrt(d/x) + c/x)/(S(2)*a**S(2)*sqrt(d/x)) - (S(4)*a*c - S(3)*b**S(2)*d)*atanh((S(2)*a + b*sqrt(d/x))/(S(2)*sqrt(a)*sqrt(a + b*sqrt(d/x) + c/x)))/(S(4)*a**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*sqrt(a + b*sqrt(d/x) + c/x)), x), x, S(2)*atanh((S(2)*a + b*sqrt(d/x))/(S(2)*sqrt(a)*sqrt(a + b*sqrt(d/x) + c/x)))/sqrt(a), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*sqrt(a + b*sqrt(d/x) + c/x)), x), x, b*sqrt(d)*atanh((b*d + S(2)*c*sqrt(d/x))/(S(2)*sqrt(c)*sqrt(d)*sqrt(a + b*sqrt(d/x) + c/x)))/c**(S(3)/2) - S(2)*sqrt(a + b*sqrt(d/x) + c/x)/c, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*sqrt(a + b*sqrt(d/x) + c/x)), x), x, -b*sqrt(d)*(S(12)*a*c - S(5)*b**S(2)*d)*atanh((b*d + S(2)*c*sqrt(d/x))/(S(2)*sqrt(c)*sqrt(d)*sqrt(a + b*sqrt(d/x) + c/x)))/(S(8)*c**(S(7)/2)) - S(2)*sqrt(a + b*sqrt(d/x) + c/x)/(S(3)*c*x) + sqrt(a + b*sqrt(d/x) + c/x)*(S(16)*a*c - S(15)*b**S(2)*d + S(10)*b*c*sqrt(d/x))/(S(12)*c**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(4)*sqrt(a + b*sqrt(d/x) + c/x)), x), x, S(9)*b*(d/x)**(S(3)/2)*sqrt(a + b*sqrt(d/x) + c/x)/(S(20)*c**S(2)*d) + b*sqrt(d)*(S(240)*a**S(2)*c**S(2) - S(280)*a*b**S(2)*c*d + S(63)*b**S(4)*d**S(2))*atanh((b*d + S(2)*c*sqrt(d/x))/(S(2)*sqrt(c)*sqrt(d)*sqrt(a + b*sqrt(d/x) + c/x)))/(S(128)*c**(S(11)/2)) - S(2)*sqrt(a + b*sqrt(d/x) + c/x)/(S(5)*c*x**S(2)) + (S(64)*a*c - S(63)*b**S(2)*d)*sqrt(a + b*sqrt(d/x) + c/x)/(S(120)*c**S(3)*x) - sqrt(a + b*sqrt(d/x) + c/x)*(S(1024)*a**S(2)*c**S(2) - S(2940)*a*b**S(2)*c*d + S(945)*b**S(4)*d**S(2) + S(14)*b*c*sqrt(d/x)*(S(92)*a*c - S(45)*b**S(2)*d))/(S(960)*c**S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(sqrt(S(1)/x) + S(1)/x), x), x, S(4)*(sqrt(S(1)/x) + S(1)/x)**(S(3)/2)/(S(3)*(S(1)/x)**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(sqrt(S(1)/x) + S(2) + S(1)/x), x), x, x*(sqrt(S(1)/x)/S(4) + S(1))*sqrt(sqrt(S(1)/x) + S(2) + S(1)/x) + S(7)*sqrt(S(2))*atanh(sqrt(S(2))*(sqrt(S(1)/x) + S(4))/(S(4)*sqrt(sqrt(S(1)/x) + S(2) + S(1)/x)))/S(16), expand=True, _diff=True, _numerical=True)
# difference in simplify assert rubi_test(rubi_integrate(S(1)/(x + sqrt(-x**S(2) - S(2)*x + S(3))), x), x, -log(-(-x - sqrt(S(3))*sqrt(-x**S(2) - S(2)*x + S(3)) + S(3))/x**S(2))/S(2) + (-sqrt(S(7))/S(14) + S(1)/2)*log(S(1) + sqrt(S(3)) + sqrt(S(7)) - sqrt(S(3))*(-sqrt(-x**S(2) - S(2)*x + S(3)) + sqrt(S(3)))/x) + (sqrt(S(7))/S(14) + S(1)/2)*log(-sqrt(S(7)) + S(1) + sqrt(S(3)) - sqrt(S(3))*(-sqrt(-x**S(2) - S(2)*x + S(3)) + sqrt(S(3)))/x) + atan((-sqrt(-x**S(2) - S(2)*x + S(3)) + sqrt(S(3)))/x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x + sqrt(-x**S(2) - S(2)*x + S(3)))**(S(-2)), x), x, (-S(2)*sqrt(S(3)) + S(8) + S(2)*(-S(3)*sqrt(-x**S(2) - S(2)*x + S(3)) + S(3)*sqrt(S(3)))/x)/(-S(7)*sqrt(S(3)) + S(14) - S(7)*(S(2) + S(2)*sqrt(S(3)))*(-sqrt(-x**S(2) - S(2)*x + S(3)) + sqrt(S(3)))/x + S(7)*sqrt(S(3))*(-sqrt(-x**S(2) - S(2)*x + S(3)) + sqrt(S(3)))**S(2)/x**S(2)) - S(8)*sqrt(S(7))*atanh(sqrt(S(7))*(S(1) + sqrt(S(3)) - sqrt(S(3))*(-sqrt(-x**S(2) - S(2)*x + S(3)) + sqrt(S(3)))/x)/S(7))/S(49), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x + sqrt(-x**S(2) - S(2)*x + S(3)))**(S(-3)), x), x, S(4)*sqrt(S(3))*(S(1) + sqrt(S(3)) - sqrt(S(3))*(-sqrt(-x**S(2) - S(2)*x + S(3)) + sqrt(S(3)))/x)/(-S(49)*sqrt(S(3)) + S(98) - S(49)*(S(2) + S(2)*sqrt(S(3)))*(-sqrt(-x**S(2) - S(2)*x + S(3)) + sqrt(S(3)))/x + S(49)*sqrt(S(3))*(-sqrt(-x**S(2) - S(2)*x + S(3)) + sqrt(S(3)))**S(2)/x**S(2)) - sqrt(S(3))*(-S(2)*sqrt(S(3)) + S(8) + S(2)*(-S(7)*sqrt(S(3)) + S(10))*(-sqrt(-x**S(2) - S(2)*x + S(3)) + sqrt(S(3)))/x)/(S(21)*(-sqrt(S(3)) + S(2) - (S(2) + S(2)*sqrt(S(3)))*(-sqrt(-x**S(2) - S(2)*x + S(3)) + sqrt(S(3)))/x + sqrt(S(3))*(-sqrt(-x**S(2) - S(2)*x + S(3)) + sqrt(S(3)))**S(2)/x**S(2))**S(2)) - S(12)*sqrt(S(7))*atanh(sqrt(S(7))*(S(1) + sqrt(S(3)) - sqrt(S(3))*(-sqrt(-x**S(2) - S(2)*x + S(3)) + sqrt(S(3)))/x)/S(7))/S(343) + (S(6) + S(4)*sqrt(S(3)))*(-sqrt(-x**S(2) - S(2)*x + S(3)) + sqrt(S(3)))**S(2)/(S(3)*x**S(2)*(-sqrt(S(3)) + S(2) - (S(2) + S(2)*sqrt(S(3)))*(-sqrt(-x**S(2) - S(2)*x + S(3)) + sqrt(S(3)))/x + sqrt(S(3))*(-sqrt(-x**S(2) - S(2)*x + S(3)) + sqrt(S(3)))**S(2)/x**S(2))**S(2)) - S(2)*(-sqrt(-x**S(2) - S(2)*x + S(3)) + sqrt(S(3)))**S(3)/(x**S(3)*(-sqrt(S(3)) + S(2) - (S(2) + S(2)*sqrt(S(3)))*(-sqrt(-x**S(2) - S(2)*x + S(3)) + sqrt(S(3)))/x + sqrt(S(3))*(-sqrt(-x**S(2) - S(2)*x + S(3)) + sqrt(S(3)))**S(2)/x**S(2))**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x + sqrt(x**S(2) - S(2)*x + S(-3))), x), x, -S(3)*log(x + sqrt(x**S(2) - S(2)*x + S(-3)))/S(2) + S(2)*log(-x - sqrt(x**S(2) - S(2)*x + S(-3)) + S(1)) - S(2)/(-x - sqrt(x**S(2) - S(2)*x + S(-3)) + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x + sqrt(x**S(2) - S(2)*x + S(-3)))**(S(-2)), x), x, -S(4)*log(x + sqrt(x**S(2) - S(2)*x + S(-3))) + S(4)*log(-x - sqrt(x**S(2) - S(2)*x + S(-3)) + S(1)) - S(2)/(-x - sqrt(x**S(2) - S(2)*x + S(-3)) + S(1)) + S(3)/(S(2)*x + S(2)*sqrt(x**S(2) - S(2)*x + S(-3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x + sqrt(x**S(2) - S(2)*x + S(-3)))**(S(-3)), x), x, -S(6)*log(x + sqrt(x**S(2) - S(2)*x + S(-3))) + S(6)*log(-x - sqrt(x**S(2) - S(2)*x + S(-3)) + S(1)) - S(2)/(-x - sqrt(x**S(2) - S(2)*x + S(-3)) + S(1)) + S(4)/(x + sqrt(x**S(2) - S(2)*x + S(-3))) + S(3)/(S(4)*(x + sqrt(x**S(2) - S(2)*x + S(-3)))**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x + sqrt(-x**S(2) - S(4)*x + S(-3))), x), x, log((x*sqrt(-x + S(-1)) + x*sqrt(x + S(3)) + S(3)*sqrt(-x + S(-1)))/(x + S(3))**(S(3)/2))/S(2) - log(S(1)/(x + S(3)))/S(2) - sqrt(S(2))*atan(sqrt(S(2))*(-S(3)*sqrt(-x + S(-1))/sqrt(x + S(3)) + S(1))/S(2)) - atan(sqrt(-x + S(-1))/sqrt(x + S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x + sqrt(-x**S(2) - S(4)*x + S(-3)))**(S(-2)), x), x, (-sqrt(-x + S(-1))/sqrt(x + S(3)) + S(1))/(-S(2)*sqrt(-x + S(-1))/sqrt(x + S(3)) + S(1) - (S(3)*x + S(3))/(x + S(3))) + sqrt(S(2))*atan(sqrt(S(2))*(-S(3)*sqrt(-x + S(-1))/sqrt(x + S(3)) + S(1))/S(2))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x + sqrt(-x**S(2) - S(4)*x + S(-3)))**(S(-3)), x), x, -(-S(9)*sqrt(-x + S(-1))/sqrt(x + S(3)) + S(5))/(-S(18)*sqrt(-x + S(-1))/sqrt(x + S(3)) + S(9) - S(9)*(S(3)*x + S(3))/(x + S(3))) - (-S(3)*sqrt(-x + S(-1))/sqrt(x + S(3)) + S(1))/(-S(12)*sqrt(-x + S(-1))/sqrt(x + S(3)) + S(6) - S(6)*(S(3)*x + S(3))/(x + S(3))) - (-S(2)*sqrt(-x + S(-1))/sqrt(x + S(3)) + S(4))/(S(9)*(-S(2)*sqrt(-x + S(-1))/sqrt(x + S(3)) + S(1) - (S(3)*x + S(3))/(x + S(3)))**S(2)) - S(3)*sqrt(S(2))*atan(sqrt(S(2))*(-S(3)*sqrt(-x + S(-1))/sqrt(x + S(3)) + S(1))/S(2))/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(x + S(1))**S(3)*(S(2)*x + S(1))*sqrt(-x**S(4) - S(2)*x**S(3) - x**S(2) + S(1)), x), x, -(-x**S(4) - S(2)*x**S(3) - x**S(2) + S(1))**(S(3)/2)*(S(3)*x**S(4) + S(6)*x**S(3) + S(3)*x**S(2) + S(2))/S(15), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(x**S(3)*(x + S(1))**S(3)*(S(2)*x + S(1))*sqrt(-x**S(4) - S(2)*x**S(3) - x**S(2) + S(1)), x), x, -(-S(4)*(x + S(1)/2)**S(2) + S(1))**S(2)*(-S(16)*(x + S(1)/2)**S(4) + S(8)*(x + S(1)/2)**S(2) + S(15))**(S(3)/2)/S(5120) - (-S(16)*(x + S(1)/2)**S(4) + S(8)*(x + S(1)/2)**S(2) + S(15))**(S(3)/2)/S(480), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x + S(1))*(x**S(2) + x)**S(3)*sqrt(-(x**S(2) + x)**S(2) + S(1)), x), x, -(-x**S(4) - S(2)*x**S(3) - x**S(2) + S(1))**(S(3)/2)*(S(3)*x**S(4) + S(6)*x**S(3) + S(3)*x**S(2) + S(2))/S(15), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate((S(2)*x + S(1))*(x**S(2) + x)**S(3)*sqrt(-(x**S(2) + x)**S(2) + S(1)), x), x, -(-S(4)*(x + S(1)/2)**S(2) + S(1))**S(2)*(-S(16)*(x + S(1)/2)**S(4) + S(8)*(x + S(1)/2)**S(2) + S(15))**(S(3)/2)/S(5120) - (-S(16)*(x + S(1)/2)**S(4) + S(8)*(x + S(1)/2)**S(2) + S(15))**(S(3)/2)/S(480), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(3) + S(3)*x**S(2) + S(3)*x)/(x**S(4) + S(4)*x**S(3) + S(6)*x**S(2) + S(4)*x + S(1)), x), x, log(x + S(1)) + S(1)/(S(3)*(x + S(1))**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(3) - S(3)*x**S(2) + S(3)*x + S(-1))/(x**S(4) + S(4)*x**S(3) + S(6)*x**S(2) + S(4)*x + S(1)), x), x, log(x + S(1)) + S(6)/(x + S(1)) - S(6)/(x + S(1))**S(2) + S(8)/(S(3)*(x + S(1))**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-x**S(4) + S(4)*x**S(3) - S(8)*x**S(2) + S(8)*x)**(S(3)/2), x), x, (x + S(-1))*(-S(6)*(x + S(-1))**S(2)/S(35) + S(26)/35)*sqrt(-(x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3)) + (x + S(-1))*(-(x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3))**(S(3)/2)/S(7) - S(16)*sqrt(S(3))*elliptic_e(asin(x + S(-1)), S(-1)/3)/S(5) + S(176)*sqrt(S(3))*elliptic_f(asin(x + S(-1)), S(-1)/3)/S(35), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(-x**S(4) + S(4)*x**S(3) - S(8)*x**S(2) + S(8)*x), x), x, (x + S(-1))*sqrt(-(x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3))/S(3) - S(2)*sqrt(S(3))*elliptic_e(asin(x + S(-1)), S(-1)/3)/S(3) + S(4)*sqrt(S(3))*elliptic_f(asin(x + S(-1)), S(-1)/3)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-x**S(4) + S(4)*x**S(3) - S(8)*x**S(2) + S(8)*x), x), x, sqrt(S(3))*elliptic_f(asin(x + S(-1)), S(-1)/3)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-x**S(4) + S(4)*x**S(3) - S(8)*x**S(2) + S(8)*x)**(S(-3)/2), x), x, (x + S(-1))*((x + S(-1))**S(2) + S(5))/(S(24)*sqrt(-(x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3))) - sqrt(S(3))*elliptic_e(asin(x + S(-1)), S(-1)/3)/S(24) + sqrt(S(3))*elliptic_f(asin(x + S(-1)), S(-1)/3)/S(12), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-x**S(4) + S(4)*x**S(3) - S(8)*x**S(2) + S(8)*x)**(S(-5)/2), x), x, (x + S(-1))*((x + S(-1))**S(2) + S(5))/(S(72)*(-(x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3))**(S(3)/2)) + (x + S(-1))*(S(7)*(x + S(-1))**S(2) + S(26))/(S(432)*sqrt(-(x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3))) - S(7)*sqrt(S(3))*elliptic_e(asin(x + S(-1)), S(-1)/3)/S(432) + S(11)*sqrt(S(3))*elliptic_f(asin(x + S(-1)), S(-1)/3)/S(432), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x*(-x + S(2))*(x**S(2) - S(2)*x + S(4)))**(S(3)/2), x), x, (x + S(-1))*(-S(6)*(x + S(-1))**S(2)/S(35) + S(26)/35)*sqrt(-(x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3)) + (x + S(-1))*(-(x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3))**(S(3)/2)/S(7) - S(16)*sqrt(S(3))*elliptic_e(asin(x + S(-1)), S(-1)/3)/S(5) + S(176)*sqrt(S(3))*elliptic_f(asin(x + S(-1)), S(-1)/3)/S(35), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x*(-x + S(2))*(x**S(2) - S(2)*x + S(4))), x), x, (x + S(-1))*sqrt(-(x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3))/S(3) - S(2)*sqrt(S(3))*elliptic_e(asin(x + S(-1)), S(-1)/3)/S(3) + S(4)*sqrt(S(3))*elliptic_f(asin(x + S(-1)), S(-1)/3)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(x*(-x + S(2))*(x**S(2) - S(2)*x + S(4))), x), x, sqrt(S(3))*elliptic_f(asin(x + S(-1)), S(-1)/3)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x*(-x + S(2))*(x**S(2) - S(2)*x + S(4)))**(S(-3)/2), x), x, (x + S(-1))*((x + S(-1))**S(2) + S(5))/(S(24)*sqrt(-(x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3))) - sqrt(S(3))*elliptic_e(asin(x + S(-1)), S(-1)/3)/S(24) + sqrt(S(3))*elliptic_f(asin(x + S(-1)), S(-1)/3)/S(12), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x*(-x + S(2))*(x**S(2) - S(2)*x + S(4)))**(S(-5)/2), x), x, (x + S(-1))*((x + S(-1))**S(2) + S(5))/(S(72)*(-(x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3))**(S(3)/2)) + (x + S(-1))*(S(7)*(x + S(-1))**S(2) + S(26))/(S(432)*sqrt(-(x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3))) - S(7)*sqrt(S(3))*elliptic_e(asin(x + S(-1)), S(-1)/3)/S(432) + S(11)*sqrt(S(3))*elliptic_f(asin(x + S(-1)), S(-1)/3)/S(432), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(4)*a*c + S(4)*c**S(2)*x**S(2) + S(4)*c*d*x**S(3) + d**S(2)*x**S(4))**S(4), x), x, -S(8)*c**S(5)*(S(4)*a*d**S(2) + c**S(3))**S(3)*(c/d + x)**S(3)/(S(3)*d**S(6)) - S(8)*c**S(4)*(S(4)*a*d**S(2) + c**S(3))*(S(12)*a*d**S(2) + S(7)*c**S(3))*(c/d + x)**S(7)/(S(7)*d**S(2)) + c**S(4)*x*(S(4)*a*d**S(2) + c**S(3))**S(4)/d**S(8) - S(8)*c**S(3)*d**S(2)*(S(12)*a*d**S(2) + S(7)*c**S(3))*(c/d + x)**S(11)/S(11) + S(4)*c**S(3)*(S(4)*a*d**S(2) + c**S(3))**S(2)*(S(4)*a*d**S(2) + S(7)*c**S(3))*(c/d + x)**S(5)/(S(5)*d**S(4)) - S(8)*c**S(2)*d**S(6)*(c/d + x)**S(15)/S(15) + S(2)*c**S(2)*(c/d + x)**S(9)*(S(48)*a**S(2)*d**S(4) + S(120)*a*c**S(3)*d**S(2) + S(35)*c**S(6))/S(9) + S(4)*c*d**S(4)*(S(4)*a*d**S(2) + S(7)*c**S(3))*(c/d + x)**S(13)/S(13) + d**S(8)*(c/d + x)**S(17)/S(17), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(4)*a*c + S(4)*c**S(2)*x**S(2) + S(4)*c*d*x**S(3) + d**S(2)*x**S(4))**S(3), x), x, S(64)*a**S(3)*c**S(3)*x + S(64)*a**S(2)*c**S(4)*x**S(3) + S(48)*a**S(2)*c**S(3)*d*x**S(4) + S(64)*a*c**S(4)*d*x**S(6) + S(48)*a*c**S(2)*x**S(5)*(a*d**S(2) + S(4)*c**S(3))/S(5) + S(16)*c**S(3)*d**S(3)*x**S(10) + S(32)*c**S(3)*x**S(7)*(S(9)*a*d**S(2) + S(2)*c**S(3))/S(7) + S(60)*c**S(2)*d**S(4)*x**S(11)/S(11) + S(12)*c**S(2)*d*x**S(8)*(a*d**S(2) + S(2)*c**S(3)) + c*d**S(5)*x**S(12) + S(4)*c*d**S(2)*x**S(9)*(a*d**S(2) + S(20)*c**S(3))/S(3) + d**S(6)*x**S(13)/S(13), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(4)*a*c + S(4)*c**S(2)*x**S(2) + S(4)*c*d*x**S(3) + d**S(2)*x**S(4))**S(2), x), x, S(16)*a**S(2)*c**S(2)*x + S(32)*a*c**S(3)*x**S(3)/S(3) + S(8)*a*c**S(2)*d*x**S(4) + S(16)*c**S(3)*d*x**S(6)/S(3) + S(24)*c**S(2)*d**S(2)*x**S(7)/S(7) + c*d**S(3)*x**S(8) + S(8)*c*x**S(5)*(a*d**S(2) + S(2)*c**S(3))/S(5) + d**S(4)*x**S(9)/S(9), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(4)*a*c + S(4)*c**S(2)*x**S(2) + S(4)*c*d*x**S(3) + d**S(2)*x**S(4), x), x, S(4)*a*c*x + S(4)*c**S(2)*x**S(3)/S(3) + c*d*x**S(4) + d**S(2)*x**S(5)/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(S(4)*a*c + S(4)*c**S(2)*x**S(2) + S(4)*c*d*x**S(3) + d**S(2)*x**S(4)), x), x, -atanh(d*(c/d + x)/(c**(S(1)/4)*sqrt(c**(S(3)/2) + S(2)*d*sqrt(-a))))/(S(4)*c**(S(3)/4)*sqrt(-a)*sqrt(c**(S(3)/2) + S(2)*d*sqrt(-a))) + atanh(d*(c/d + x)/(c**(S(1)/4)*sqrt(c**(S(3)/2) - S(2)*d*sqrt(-a))))/(S(4)*c**(S(3)/4)*sqrt(-a)*sqrt(c**(S(3)/2) - S(2)*d*sqrt(-a))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(4)*a*c + S(4)*c**S(2)*x**S(2) + S(4)*c*d*x**S(3) + d**S(2)*x**S(4))**(S(-2)), x), x, (S(6)*a*d**S(2) + c**(S(3)/2)*d*sqrt(-a) + c**S(3))*atanh(d*(c/d + x)/(c**(S(1)/4)*sqrt(c**(S(3)/2) + S(2)*d*sqrt(-a))))/(S(32)*c**(S(7)/4)*(-a)**(S(3)/2)*sqrt(c**(S(3)/2) + S(2)*d*sqrt(-a))*(S(4)*a*d**S(2) + c**S(3))) - (S(6)*a*d**S(2) - c**(S(3)/2)*d*sqrt(-a) + c**S(3))*atanh(d*(c/d + x)/(c**(S(1)/4)*sqrt(c**(S(3)/2) - S(2)*d*sqrt(-a))))/(S(32)*c**(S(7)/4)*(-a)**(S(3)/2)*sqrt(c**(S(3)/2) - S(2)*d*sqrt(-a))*(S(4)*a*d**S(2) + c**S(3))) - (c/d + x)*(-S(4)*a*d**S(2) + c**S(3) - c*d**S(2)*(c/d + x)**S(2))/(S(16)*a*c*(S(4)*a*d**S(2) + c**S(3))*(-S(2)*c**S(2)*(c/d + x)**S(2) + c*(S(4)*a + c**S(3)/d**S(2)) + d**S(2)*(c/d + x)**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(4)*a*c + S(4)*c**S(2)*x**S(2) + S(4)*c*d*x**S(3) + d**S(2)*x**S(4))**(S(3)/2), x), x, S(16)*c**(S(13)/4)*sqrt((-S(2)*c**S(2)*(c/d + x)**S(2) + c*(S(4)*a + c**S(3)/d**S(2)) + d**S(2)*(c/d + x)**S(4))/((S(4)*a + c**S(3)/d**S(2))*(sqrt(c) + d**S(2)*(c/d + x)**S(2)/sqrt(S(4)*a*d**S(2) + c**S(3)))**S(2)))*(sqrt(c) + d**S(2)*(c/d + x)**S(2)/sqrt(S(4)*a*d**S(2) + c**S(3)))*(S(4)*a*d**S(2) + c**S(3))**(S(3)/4)*(S(8)*a*d**S(2) + c**S(3))*elliptic_e(S(2)*atan(d*(c/d + x)/(c**(S(1)/4)*(S(4)*a*d**S(2) + c**S(3))**(S(1)/4))), c**(S(3)/2)/(S(2)*sqrt(S(4)*a*d**S(2) + c**S(3))) + S(1)/2)/(S(35)*d**S(5)*sqrt(-S(2)*c**S(2)*(c/d + x)**S(2) + c*(S(4)*a + c**S(3)/d**S(2)) + d**S(2)*(c/d + x)**S(4))) + S(8)*c**(S(7)/4)*sqrt((-S(2)*c**S(2)*(c/d + x)**S(2) + c*(S(4)*a + c**S(3)/d**S(2)) + d**S(2)*(c/d + x)**S(4))/((S(4)*a + c**S(3)/d**S(2))*(sqrt(c) + d**S(2)*(c/d + x)**S(2)/sqrt(S(4)*a*d**S(2) + c**S(3)))**S(2)))*(sqrt(c) + d**S(2)*(c/d + x)**S(2)/sqrt(S(4)*a*d**S(2) + c**S(3)))*(S(4)*a*d**S(2) + c**S(3))**(S(3)/4)*(-c**(S(3)/2)*(S(8)*a*d**S(2) + c**S(3)) + sqrt(S(4)*a*d**S(2) + c**S(3))*(S(5)*a*d**S(2) + c**S(3)))*elliptic_f(S(2)*atan(d*(c/d + x)/(c**(S(1)/4)*(S(4)*a*d**S(2) + c**S(3))**(S(1)/4))), c**(S(3)/2)/(S(2)*sqrt(S(4)*a*d**S(2) + c**S(3))) + S(1)/2)/(S(35)*d**S(5)*sqrt(-S(2)*c**S(2)*(c/d + x)**S(2) + c*(S(4)*a + c**S(3)/d**S(2)) + d**S(2)*(c/d + x)**S(4))) - S(16)*c**S(3)*(S(8)*a*d**S(2) + c**S(3))*(c/d + x)*sqrt(-S(2)*c**S(2)*(c/d + x)**S(2) + c*(S(4)*a + c**S(3)/d**S(2)) + d**S(2)*(c/d + x)**S(4))/(S(35)*d**S(2)*(sqrt(c) + d**S(2)*(c/d + x)**S(2)/sqrt(S(4)*a*d**S(2) + c**S(3)))*sqrt(S(4)*a*d**S(2) + c**S(3))) + S(2)*c*(c/d + x)*(S(20)*a*d**S(2) + S(7)*c**S(3) - S(3)*c*d**S(2)*(c/d + x)**S(2))*sqrt(-S(2)*c**S(2)*(c/d + x)**S(2) + c*(S(4)*a + c**S(3)/d**S(2)) + d**S(2)*(c/d + x)**S(4))/(S(35)*d**S(2)) + (c/(S(7)*d) + x/S(7))*(-S(2)*c**S(2)*(c/d + x)**S(2) + c*(S(4)*a + c**S(3)/d**S(2)) + d**S(2)*(c/d + x)**S(4))**(S(3)/2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(S(4)*a*c + S(4)*c**S(2)*x**S(2) + S(4)*c*d*x**S(3) + d**S(2)*x**S(4)), x), x, S(2)*c**(S(9)/4)*sqrt((-S(2)*c**S(2)*(c/d + x)**S(2) + c*(S(4)*a + c**S(3)/d**S(2)) + d**S(2)*(c/d + x)**S(4))/((S(4)*a + c**S(3)/d**S(2))*(sqrt(c) + d**S(2)*(c/d + x)**S(2)/sqrt(S(4)*a*d**S(2) + c**S(3)))**S(2)))*(sqrt(c) + d**S(2)*(c/d + x)**S(2)/sqrt(S(4)*a*d**S(2) + c**S(3)))*(S(4)*a*d**S(2) + c**S(3))**(S(3)/4)*elliptic_e(S(2)*atan(d*(c/d + x)/(c**(S(1)/4)*(S(4)*a*d**S(2) + c**S(3))**(S(1)/4))), c**(S(3)/2)/(S(2)*sqrt(S(4)*a*d**S(2) + c**S(3))) + S(1)/2)/(S(3)*d**S(3)*sqrt(-S(2)*c**S(2)*(c/d + x)**S(2) + c*(S(4)*a + c**S(3)/d**S(2)) + d**S(2)*(c/d + x)**S(4))) + c**(S(3)/4)*sqrt((-S(2)*c**S(2)*(c/d + x)**S(2) + c*(S(4)*a + c**S(3)/d**S(2)) + d**S(2)*(c/d + x)**S(4))/((S(4)*a + c**S(3)/d**S(2))*(sqrt(c) + d**S(2)*(c/d + x)**S(2)/sqrt(S(4)*a*d**S(2) + c**S(3)))**S(2)))*(sqrt(c) + d**S(2)*(c/d + x)**S(2)/sqrt(S(4)*a*d**S(2) + c**S(3)))*(S(4)*a*d**S(2) + c**S(3))**(S(1)/4)*(S(4)*a*d**S(2) - c**(S(3)/2)*sqrt(S(4)*a*d**S(2) + c**S(3)) + c**S(3))*elliptic_f(S(2)*atan(d*(c/d + x)/(c**(S(1)/4)*(S(4)*a*d**S(2) + c**S(3))**(S(1)/4))), c**(S(3)/2)/(S(2)*sqrt(S(4)*a*d**S(2) + c**S(3))) + S(1)/2)/(S(3)*d**S(3)*sqrt(-S(2)*c**S(2)*(c/d + x)**S(2) + c*(S(4)*a + c**S(3)/d**S(2)) + d**S(2)*(c/d + x)**S(4))) - S(2)*c**S(2)*(c/d + x)*sqrt(-S(2)*c**S(2)*(c/d + x)**S(2) + c*(S(4)*a + c**S(3)/d**S(2)) + d**S(2)*(c/d + x)**S(4))/(S(3)*(sqrt(c) + d**S(2)*(c/d + x)**S(2)/sqrt(S(4)*a*d**S(2) + c**S(3)))*sqrt(S(4)*a*d**S(2) + c**S(3))) + (c/(S(3)*d) + x/S(3))*sqrt(-S(2)*c**S(2)*(c/d + x)**S(2) + c*(S(4)*a + c**S(3)/d**S(2)) + d**S(2)*(c/d + x)**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(4)*a*c + S(4)*c**S(2)*x**S(2) + S(4)*c*d*x**S(3) + d**S(2)*x**S(4)), x), x, sqrt((-S(2)*c**S(2)*(c/d + x)**S(2) + c*(S(4)*a + c**S(3)/d**S(2)) + d**S(2)*(c/d + x)**S(4))/((S(4)*a + c**S(3)/d**S(2))*(sqrt(c) + d**S(2)*(c/d + x)**S(2)/sqrt(S(4)*a*d**S(2) + c**S(3)))**S(2)))*(sqrt(c) + d**S(2)*(c/d + x)**S(2)/sqrt(S(4)*a*d**S(2) + c**S(3)))*(S(4)*a*d**S(2) + c**S(3))**(S(1)/4)*elliptic_f(S(2)*atan(d*(c/d + x)/(c**(S(1)/4)*(S(4)*a*d**S(2) + c**S(3))**(S(1)/4))), c**(S(3)/2)/(S(2)*sqrt(S(4)*a*d**S(2) + c**S(3))) + S(1)/2)/(S(2)*c**(S(1)/4)*d*sqrt(-S(2)*c**S(2)*(c/d + x)**S(2) + c*(S(4)*a + c**S(3)/d**S(2)) + d**S(2)*(c/d + x)**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(4)*a*c + S(4)*c**S(2)*x**S(2) + S(4)*c*d*x**S(3) + d**S(2)*x**S(4))**(S(-3)/2), x), x, c**(S(1)/4)*sqrt((-S(2)*c**S(2)*(c/d + x)**S(2) + c*(S(4)*a + c**S(3)/d**S(2)) + d**S(2)*(c/d + x)**S(4))/((S(4)*a + c**S(3)/d**S(2))*(sqrt(c) + d**S(2)*(c/d + x)**S(2)/sqrt(S(4)*a*d**S(2) + c**S(3)))**S(2)))*(sqrt(c) + d**S(2)*(c/d + x)**S(2)/sqrt(S(4)*a*d**S(2) + c**S(3)))*elliptic_e(S(2)*atan(d*(c/d + x)/(c**(S(1)/4)*(S(4)*a*d**S(2) + c**S(3))**(S(1)/4))), c**(S(3)/2)/(S(2)*sqrt(S(4)*a*d**S(2) + c**S(3))) + S(1)/2)/(S(8)*a*d*(S(4)*a*d**S(2) + c**S(3))**(S(1)/4)*sqrt(-S(2)*c**S(2)*(c/d + x)**S(2) + c*(S(4)*a + c**S(3)/d**S(2)) + d**S(2)*(c/d + x)**S(4))) - d**S(2)*(c/d + x)*sqrt(-S(2)*c**S(2)*(c/d + x)**S(2) + c*(S(4)*a + c**S(3)/d**S(2)) + d**S(2)*(c/d + x)**S(4))/(S(8)*a*(sqrt(c) + d**S(2)*(c/d + x)**S(2)/sqrt(S(4)*a*d**S(2) + c**S(3)))*(S(4)*a*d**S(2) + c**S(3))**(S(3)/2)) - (c/d + x)*(-S(4)*a*d**S(2) + c**S(3) - c*d**S(2)*(c/d + x)**S(2))/(S(8)*a*c*(S(4)*a*d**S(2) + c**S(3))*sqrt(-S(2)*c**S(2)*(c/d + x)**S(2) + c*(S(4)*a + c**S(3)/d**S(2)) + d**S(2)*(c/d + x)**S(4))) + sqrt((-S(2)*c**S(2)*(c/d + x)**S(2) + c*(S(4)*a + c**S(3)/d**S(2)) + d**S(2)*(c/d + x)**S(4))/((S(4)*a + c**S(3)/d**S(2))*(sqrt(c) + d**S(2)*(c/d + x)**S(2)/sqrt(S(4)*a*d**S(2) + c**S(3)))**S(2)))*(sqrt(c) + d**S(2)*(c/d + x)**S(2)/sqrt(S(4)*a*d**S(2) + c**S(3)))*(S(4)*a*d**S(2) - c**(S(3)/2)*sqrt(S(4)*a*d**S(2) + c**S(3)) + c**S(3))*elliptic_f(S(2)*atan(d*(c/d + x)/(c**(S(1)/4)*(S(4)*a*d**S(2) + c**S(3))**(S(1)/4))), c**(S(3)/2)/(S(2)*sqrt(S(4)*a*d**S(2) + c**S(3))) + S(1)/2)/(S(16)*a*c**(S(5)/4)*d*(S(4)*a*d**S(2) + c**S(3))**(S(3)/4)*sqrt(-S(2)*c**S(2)*(c/d + x)**S(2) + c*(S(4)*a + c**S(3)/d**S(2)) + d**S(2)*(c/d + x)**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(8)*a*e**S(2) - d**S(3)*x + S(8)*d*e**S(2)*x**S(3) + S(8)*e**S(3)*x**S(4))**S(4), x), x, -S(2048)*d**S(2)*e**S(10)*(d/(S(4)*e) + x)**S(15)/S(5) - S(72)*d**S(2)*e**S(6)*(S(256)*a*e**S(3) + S(17)*d**S(4))*(d/(S(4)*e) + x)**S(11)/S(11) - S(9)*d**S(2)*e**S(2)*(d/(S(4)*e) + x)**S(7)*(S(65536)*a**S(2)*e**S(6) + S(5632)*a*d**S(4)*e**S(3) + S(85)*d**S(8))/S(224) - d**S(2)*(S(256)*a*e**S(3) + S(5)*d**S(4))**S(3)*(d/(S(4)*e) + x)**S(3)/(S(8192)*e**S(2)) + S(4096)*e**S(12)*(d/(S(4)*e) + x)**S(17)/S(17) + S(64)*e**S(8)*(S(256)*a*e**S(3) + S(59)*d**S(4))*(d/(S(4)*e) + x)**S(13)/S(13) + e**S(4)*(d/(S(4)*e) + x)**S(9)*(S(65536)*a**S(2)*e**S(6) + S(20992)*a*d**S(4)*e**S(3) + S(601)*d**S(8))/S(24) + (S(256)*a*e**S(3) + S(5)*d**S(4))**S(2)*(S(256)*a*e**S(3) + S(59)*d**S(4))*(d/(S(4)*e) + x)**S(5)/S(5120) + x*(S(256)*a*e**S(3) + S(5)*d**S(4))**S(4)/(S(1048576)*e**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(8)*a*e**S(2) - d**S(3)*x + S(8)*d*e**S(2)*x**S(3) + S(8)*e**S(3)*x**S(4))**S(3), x), x, S(512)*a**S(3)*e**S(6)*x - S(96)*a**S(2)*d**S(3)*e**S(4)*x**S(2) + S(8)*a*d**S(6)*e**S(2)*x**S(3) - S(384)*a*e**S(4)*x**S(5)*(-S(4)*a*e**S(3) + d**S(4))/S(5) + S(32)*d**S(3)*e**S(6)*x**S(10) + S(4)*d**S(3)*e**S(2)*x**S(6)*(-S(16)*a*e**S(3) + d**S(4)) + S(1536)*d**S(2)*e**S(7)*x**S(11)/S(11) + S(24)*d**S(2)*e**S(3)*x**S(7)*(S(64)*a*e**S(3) + d**S(4))/S(7) + S(128)*d*e**S(8)*x**S(12) - S(24)*d*e**S(4)*x**S(8)*(-S(16)*a*e**S(3) + d**S(4)) - d*x**S(4)*(-S(1536)*a**S(2)*e**S(6) + d**S(8))/S(4) + S(512)*e**S(9)*x**S(13)/S(13) - S(128)*e**S(5)*x**S(9)*(-S(4)*a*e**S(3) + d**S(4))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(8)*a*e**S(2) - d**S(3)*x + S(8)*d*e**S(2)*x**S(3) + S(8)*e**S(3)*x**S(4))**S(2), x), x, S(64)*a**S(2)*e**S(4)*x - S(8)*a*d**S(3)*e**S(2)*x**S(2) + S(32)*a*d*e**S(4)*x**S(4) + d**S(6)*x**S(3)/S(3) - S(8)*d**S(3)*e**S(3)*x**S(6)/S(3) + S(64)*d**S(2)*e**S(4)*x**S(7)/S(7) + S(16)*d*e**S(5)*x**S(8) + S(64)*e**S(6)*x**S(9)/S(9) - S(16)*e**S(2)*x**S(5)*(-S(8)*a*e**S(3) + d**S(4))/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(8)*a*e**S(2) - d**S(3)*x + S(8)*d*e**S(2)*x**S(3) + S(8)*e**S(3)*x**S(4), x), x, S(8)*a*e**S(2)*x - d**S(3)*x**S(2)/S(2) + S(2)*d*e**S(2)*x**S(4) + S(8)*e**S(3)*x**S(5)/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(S(8)*a*e**S(2) - d**S(3)*x + S(8)*d*e**S(2)*x**S(3) + S(8)*e**S(3)*x**S(4)), x), x, -S(2)*atanh(S(4)*e*(d/(S(4)*e) + x)/sqrt(S(3)*d**S(2) + S(2)*sqrt(-S(64)*a*e**S(3) + d**S(4))))/(sqrt(S(3)*d**S(2) + S(2)*sqrt(-S(64)*a*e**S(3) + d**S(4)))*sqrt(-S(64)*a*e**S(3) + d**S(4))) + S(2)*atanh(S(4)*e*(d/(S(4)*e) + x)/sqrt(S(3)*d**S(2) - S(2)*sqrt(-S(64)*a*e**S(3) + d**S(4))))/(sqrt(S(3)*d**S(2) - S(2)*sqrt(-S(64)*a*e**S(3) + d**S(4)))*sqrt(-S(64)*a*e**S(3) + d**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(8)*a*e**S(2) - d**S(3)*x + S(8)*d*e**S(2)*x**S(3) + S(8)*e**S(3)*x**S(4))**(S(-2)), x), x, S(64)*e*(d/(S(4)*e) + x)*(-S(256)*a*e**S(3) + S(13)*d**S(4) - S(48)*d**S(2)*e**S(2)*(d/(S(4)*e) + x)**S(2))/((-S(16384)*a**S(2)*e**S(6) - S(64)*a*d**S(4)*e**S(3) + S(5)*d**S(8))*(S(256)*a*e**S(2) + S(5)*d**S(4)/e - S(96)*d**S(2)*e*(d/(S(4)*e) + x)**S(2) + S(256)*e**S(3)*(d/(S(4)*e) + x)**S(4))) + S(24)*e*(S(128)*a*e**S(3) + d**S(4) + d**S(2)*sqrt(-S(64)*a*e**S(3) + d**S(4)))*atanh(S(4)*e*(d/(S(4)*e) + x)/sqrt(S(3)*d**S(2) + S(2)*sqrt(-S(64)*a*e**S(3) + d**S(4))))/(sqrt(S(3)*d**S(2) + S(2)*sqrt(-S(64)*a*e**S(3) + d**S(4)))*(-S(64)*a*e**S(3) + d**S(4))**(S(3)/2)*(S(256)*a*e**S(3) + S(5)*d**S(4))) - S(24)*e*(S(128)*a*e**S(3) + d**S(4) - d**S(2)*sqrt(-S(64)*a*e**S(3) + d**S(4)))*atanh(S(4)*e*(d/(S(4)*e) + x)/sqrt(S(3)*d**S(2) - S(2)*sqrt(-S(64)*a*e**S(3) + d**S(4))))/(sqrt(S(3)*d**S(2) - S(2)*sqrt(-S(64)*a*e**S(3) + d**S(4)))*(-S(64)*a*e**S(3) + d**S(4))**(S(3)/2)*(S(256)*a*e**S(3) + S(5)*d**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(S(8)*a*e**S(2) - d**S(3)*x + S(8)*d*e**S(2)*x**S(3) + S(8)*e**S(3)*x**S(4)), x), x, -sqrt(S(2))*d**S(2)*(d/(S(4)*e) + x)*sqrt(S(256)*a*e**S(2) + S(5)*d**S(4)/e - S(96)*d**S(2)*e*(d/(S(4)*e) + x)**S(2) + S(256)*e**S(3)*(d/(S(4)*e) + x)**S(4))/(S(4)*sqrt(S(256)*a*e**S(3) + S(5)*d**S(4))*(S(16)*e**S(2)*(d/(S(4)*e) + x)**S(2)/sqrt(S(256)*a*e**S(3) + S(5)*d**S(4)) + S(1))) + sqrt(S(2))*d**S(2)*sqrt((S(256)*a*e**S(3) + S(5)*d**S(4) - S(96)*d**S(2)*e**S(2)*(d/(S(4)*e) + x)**S(2) + S(256)*e**S(4)*(d/(S(4)*e) + x)**S(4))/((S(256)*a*e**S(3) + S(5)*d**S(4))*(S(16)*e**S(2)*(d/(S(4)*e) + x)**S(2)/sqrt(S(256)*a*e**S(3) + S(5)*d**S(4)) + S(1))**S(2)))*(S(256)*a*e**S(3) + S(5)*d**S(4))**(S(3)/4)*(S(16)*e**S(2)*(d/(S(4)*e) + x)**S(2)/sqrt(S(256)*a*e**S(3) + S(5)*d**S(4)) + S(1))*elliptic_e(S(2)*atan(S(4)*e*(d/(S(4)*e) + x)/(S(256)*a*e**S(3) + S(5)*d**S(4))**(S(1)/4)), S(3)*d**S(2)/(S(2)*sqrt(S(256)*a*e**S(3) + S(5)*d**S(4))) + S(1)/2)/(S(16)*e**S(2)*sqrt(S(256)*a*e**S(2) + S(5)*d**S(4)/e - S(96)*d**S(2)*e*(d/(S(4)*e) + x)**S(2) + S(256)*e**S(3)*(d/(S(4)*e) + x)**S(4))) + sqrt(S(2))*(d/(S(4)*e) + x)*sqrt(S(256)*a*e**S(2) + S(5)*d**S(4)/e - S(96)*d**S(2)*e*(d/(S(4)*e) + x)**S(2) + S(256)*e**S(3)*(d/(S(4)*e) + x)**S(4))/S(24) + sqrt(S(2))*sqrt((S(256)*a*e**S(3) + S(5)*d**S(4) - S(96)*d**S(2)*e**S(2)*(d/(S(4)*e) + x)**S(2) + S(256)*e**S(4)*(d/(S(4)*e) + x)**S(4))/((S(256)*a*e**S(3) + S(5)*d**S(4))*(S(16)*e**S(2)*(d/(S(4)*e) + x)**S(2)/sqrt(S(256)*a*e**S(3) + S(5)*d**S(4)) + S(1))**S(2)))*(S(256)*a*e**S(3) + S(5)*d**S(4))**(S(1)/4)*(S(16)*e**S(2)*(d/(S(4)*e) + x)**S(2)/sqrt(S(256)*a*e**S(3) + S(5)*d**S(4)) + S(1))*(S(256)*a*e**S(3) + S(5)*d**S(4) - S(3)*d**S(2)*sqrt(S(256)*a*e**S(3) + S(5)*d**S(4)))*elliptic_f(S(2)*atan(S(4)*e*(d/(S(4)*e) + x)/(S(256)*a*e**S(3) + S(5)*d**S(4))**(S(1)/4)), S(3)*d**S(2)/(S(2)*sqrt(S(256)*a*e**S(3) + S(5)*d**S(4))) + S(1)/2)/(S(96)*e**S(2)*sqrt(S(256)*a*e**S(2) + S(5)*d**S(4)/e - S(96)*d**S(2)*e*(d/(S(4)*e) + x)**S(2) + S(256)*e**S(3)*(d/(S(4)*e) + x)**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(8)*a*e**S(2) - d**S(3)*x + S(8)*d*e**S(2)*x**S(3) + S(8)*e**S(3)*x**S(4)), x), x, sqrt(S(2))*sqrt((S(256)*a*e**S(3) + S(5)*d**S(4) - S(96)*d**S(2)*e**S(2)*(d/(S(4)*e) + x)**S(2) + S(256)*e**S(4)*(d/(S(4)*e) + x)**S(4))/((S(256)*a*e**S(3) + S(5)*d**S(4))*(S(16)*e**S(2)*(d/(S(4)*e) + x)**S(2)/sqrt(S(256)*a*e**S(3) + S(5)*d**S(4)) + S(1))**S(2)))*(S(256)*a*e**S(3) + S(5)*d**S(4))**(S(1)/4)*(S(16)*e**S(2)*(d/(S(4)*e) + x)**S(2)/sqrt(S(256)*a*e**S(3) + S(5)*d**S(4)) + S(1))*elliptic_f(S(2)*atan(S(4)*e*(d/(S(4)*e) + x)/(S(256)*a*e**S(3) + S(5)*d**S(4))**(S(1)/4)), S(3)*d**S(2)/(S(2)*sqrt(S(256)*a*e**S(3) + S(5)*d**S(4))) + S(1)/2)/(S(2)*e*sqrt(S(256)*a*e**S(2) + S(5)*d**S(4)/e - S(96)*d**S(2)*e*(d/(S(4)*e) + x)**S(2) + S(256)*e**S(3)*(d/(S(4)*e) + x)**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a - x**S(4) + S(4)*x**S(3) - S(8)*x**S(2) + S(8)*x)**S(4), x), x, x*(a + S(3))**S(4) + (-S(4)*a/S(5) + S(12)/5)*(a + S(3))**S(2)*(x + S(-1))**S(5) + (-S(4)*a/S(13) + S(12)/13)*(x + S(-1))**S(13) - S(8)*(a + S(3))**S(3)*(x + S(-1))**S(3)/S(3) + (S(8)*a/S(7) + S(24)/7)*(S(3)*a + S(5))*(x + S(-1))**S(7) - (S(24)*a/S(11) + S(40)/11)*(x + S(-1))**S(11) + (x + S(-1))**S(17)/S(17) + S(8)*(x + S(-1))**S(15)/S(15) - (x + S(-1))**S(9)*(-S(2)*a**S(2)/S(3) + S(4)*a/S(3) + S(74)/9), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a - x**S(4) + S(4)*x**S(3) - S(8)*x**S(2) + S(8)*x)**S(3), x), x, a**S(3)*x + S(12)*a**S(2)*x**S(2) + a*x**S(3)*(-S(8)*a + S(64)) - x**S(13)/S(13) + x**S(12) - S(72)*x**S(11)/S(11) + S(28)*x**S(10) - x**S(9)*(-a/S(3) + S(256)/3) + x**S(8)*(-S(3)*a + S(192)) - x**S(7)*(-S(96)*a/S(7) + S(320)) + x**S(6)*(-S(40)*a + S(384)) - x**S(5)*(S(3)*a**S(2)/S(5) - S(384)*a/S(5) + S(1536)/5) + x**S(4)*(S(3)*a**S(2) - S(96)*a + S(128)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a - x**S(4) + S(4)*x**S(3) - S(8)*x**S(2) + S(8)*x)**S(2), x), x, a**S(2)*x + S(8)*a*x**S(2) + x**S(9)/S(9) - x**S(8) + S(32)*x**S(7)/S(7) - S(40)*x**S(6)/S(3) + x**S(5)*(-S(2)*a/S(5) + S(128)/5) - x**S(4)*(-S(2)*a + S(32)) + x**S(3)*(-S(16)*a/S(3) + S(64)/3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(a - x**S(4) + S(4)*x**S(3) - S(8)*x**S(2) + S(8)*x, x), x, a*x - x**S(5)/S(5) + x**S(4) - S(8)*x**S(3)/S(3) + S(4)*x**S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(a - x**S(4) + S(4)*x**S(3) - S(8)*x**S(2) + S(8)*x), x), x, atan((x + S(-1))/sqrt(sqrt(a + S(4)) + S(1)))/(S(2)*sqrt(a + S(4))*sqrt(sqrt(a + S(4)) + S(1))) - atan((x + S(-1))/sqrt(-sqrt(a + S(4)) + S(1)))/(S(2)*sqrt(a + S(4))*sqrt(-sqrt(a + S(4)) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a - x**S(4) + S(4)*x**S(3) - S(8)*x**S(2) + S(8)*x)**(S(-2)), x), x, (x + S(-1))*(a + (x + S(-1))**S(2) + S(5))/((S(4)*a**S(2) + S(28)*a + S(48))*(a - (x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3))) + (S(3)*a - sqrt(a + S(4)) + S(10))*atan((x + S(-1))/sqrt(sqrt(a + S(4)) + S(1)))/((a + S(4))**(S(3)/2)*(S(8)*a + S(24))*sqrt(sqrt(a + S(4)) + S(1))) - (S(3)*a + sqrt(a + S(4)) + S(10))*atan((x + S(-1))/sqrt(-sqrt(a + S(4)) + S(1)))/((a + S(4))**(S(3)/2)*(S(8)*a + S(24))*sqrt(-sqrt(a + S(4)) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a - x**S(4) + S(4)*x**S(3) - S(8)*x**S(2) + S(8)*x)**S(4), x), x, a**S(4)*x**S(2)/S(2) + S(32)*a**S(3)*x**S(3)/S(3) + a**S(2)*x**S(4)*(-S(8)*a + S(96)) + S(16)*a*x**S(5)*(a**S(2) - S(48)*a + S(128))/S(5) + x**S(18)/S(18) - S(16)*x**S(17)/S(17) + S(8)*x**S(16) - S(224)*x**S(15)/S(5) + x**S(14)*(-S(2)*a/S(7) + S(1280)/7) - x**S(13)*(-S(48)*a/S(13) + S(7424)/13) + x**S(12)*(-S(24)*a + S(4192)/3) - x**S(11)*(-S(1120)*a/S(11) + S(29696)/11) + x**S(10)*(S(3)*a**S(2)/S(5) - S(1536)*a/S(5) + S(4096)) - x**S(9)*(S(16)*a**S(2)/S(3) - S(2048)*a/S(3) + S(14336)/3) + x**S(8)*(-S(24)*a + S(1024))*(-a + S(4)) - x**S(7)*(S(480)*a**S(2)/S(7) - S(9216)*a/S(7) + S(16384)/7) + x**S(6)*(-S(2)*a**S(3)/S(3) + S(128)*a**S(2) - S(1024)*a + S(2048)/3), expand=True, _diff=True, _numerical=True)
# long time in rubi_int assert rubi_test(rubi_integrate(x*(a - x**S(4) + S(4)*x**S(3) - S(8)*x**S(2) + S(8)*x)**S(3), x), x, a**S(3)*x**S(2)/S(2) + S(8)*a**S(2)*x**S(3) + a*x**S(4)*(-S(6)*a + S(48)) - x**S(14)/S(14) + S(12)*x**S(13)/S(13) - S(6)*x**S(12) + S(280)*x**S(11)/S(11) - x**S(10)*(-S(3)*a/S(10) + S(384)/5) + x**S(9)*(-S(8)*a/S(3) + S(512)/3) - x**S(8)*(-S(12)*a + S(280)) + x**S(7)*(-S(240)*a/S(7) + S(2304)/7) - x**S(6)*(a**S(2)/S(2) - S(64)*a + S(256)) + x**S(5)*(S(12)*a**S(2)/S(5) - S(384)*a/S(5) + S(512)/5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a - x**S(4) + S(4)*x**S(3) - S(8)*x**S(2) + S(8)*x)**S(2), x), x, a**S(2)*x**S(2)/S(2) + S(16)*a*x**S(3)/S(3) + x**S(10)/S(10) - S(8)*x**S(9)/S(9) + S(4)*x**S(8) - S(80)*x**S(7)/S(7) + x**S(6)*(-a/S(3) + S(64)/3) - x**S(5)*(-S(8)*a/S(5) + S(128)/5) + x**S(4)*(-S(4)*a + S(16)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a - x**S(4) + S(4)*x**S(3) - S(8)*x**S(2) + S(8)*x), x), x, a*x**S(2)/S(2) - x**S(6)/S(6) + S(4)*x**S(5)/S(5) - S(2)*x**S(4) + S(8)*x**S(3)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(a - x**S(4) + S(4)*x**S(3) - S(8)*x**S(2) + S(8)*x), x), x, atanh(((x + S(-1))**S(2) + S(1))/sqrt(a + S(4)))/(S(2)*sqrt(a + S(4))) + atan((x + S(-1))/sqrt(sqrt(a + S(4)) + S(1)))/(S(2)*sqrt(a + S(4))*sqrt(sqrt(a + S(4)) + S(1))) - atan((x + S(-1))/sqrt(-sqrt(a + S(4)) + S(1)))/(S(2)*sqrt(a + S(4))*sqrt(-sqrt(a + S(4)) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(a - x**S(4) + S(4)*x**S(3) - S(8)*x**S(2) + S(8)*x)**S(2), x), x, (x + S(-1))*(a + (a + S(5))*(x + S(-1)) + (x + S(-1))**S(3) + (x + S(-1))**S(2) + S(5))/((S(4)*a**S(2) + S(28)*a + S(48))*(a - (x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3))) + atanh(((x + S(-1))**S(2) + S(1))/sqrt(a + S(4)))/(S(4)*(a + S(4))**(S(3)/2)) + (S(3)*a - sqrt(a + S(4)) + S(10))*atan((x + S(-1))/sqrt(sqrt(a + S(4)) + S(1)))/((a + S(4))**(S(3)/2)*(S(8)*a + S(24))*sqrt(sqrt(a + S(4)) + S(1))) - (S(3)*a + sqrt(a + S(4)) + S(10))*atan((x + S(-1))/sqrt(-sqrt(a + S(4)) + S(1)))/((a + S(4))**(S(3)/2)*(S(8)*a + S(24))*sqrt(-sqrt(a + S(4)) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(a - x**S(4) + S(4)*x**S(3) - S(8)*x**S(2) + S(8)*x)**S(4), x), x, a**S(4)*x**S(3)/S(3) + S(8)*a**S(3)*x**S(4) + a**S(2)*x**S(5)*(-S(32)*a/S(5) + S(384)/5) + S(8)*a*x**S(6)*(a**S(2) - S(48)*a + S(128))/S(3) + x**S(19)/S(19) - S(8)*x**S(18)/S(9) + S(128)*x**S(17)/S(17) - S(42)*x**S(16) + x**S(15)*(-S(4)*a/S(15) + S(512)/3) - x**S(14)*(-S(24)*a/S(7) + S(3712)/7) + x**S(13)*(-S(288)*a/S(13) + S(16768)/13) - x**S(12)*(-S(280)*a/S(3) + S(7424)/3) + x**S(11)*(S(6)*a**S(2)/S(11) - S(3072)*a/S(11) + S(40960)/11) - x**S(10)*(S(24)*a**S(2)/S(5) - S(3072)*a/S(5) + S(21504)/5) + x**S(9)*(-S(64)*a/S(3) + S(8192)/9)*(-a + S(4)) - x**S(8)*(S(60)*a**S(2) - S(1152)*a + S(2048)) + x**S(7)*(-S(4)*a**S(3)/S(7) + S(768)*a**S(2)/S(7) - S(6144)*a/S(7) + S(4096)/7), expand=True, _diff=True, _numerical=True)
# long time in rubi_int assert rubi_test(rubi_integrate(x**S(2)*(a - x**S(4) + S(4)*x**S(3) - S(8)*x**S(2) + S(8)*x)**S(3), x), x, a**S(3)*x**S(3)/S(3) + S(6)*a**S(2)*x**S(4) + a*x**S(5)*(-S(24)*a/S(5) + S(192)/5) - x**S(15)/S(15) + S(6)*x**S(14)/S(7) - S(72)*x**S(13)/S(13) + S(70)*x**S(12)/S(3) - x**S(11)*(-S(3)*a/S(11) + S(768)/11) + x**S(10)*(-S(12)*a/S(5) + S(768)/5) - x**S(9)*(-S(32)*a/S(3) + S(2240)/9) + x**S(8)*(-S(30)*a + S(288)) - x**S(7)*(S(3)*a**S(2)/S(7) - S(384)*a/S(7) + S(1536)/7) + x**S(6)*(S(2)*a**S(2) - S(64)*a + S(256)/3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(a - x**S(4) + S(4)*x**S(3) - S(8)*x**S(2) + S(8)*x)**S(2), x), x, a**S(2)*x**S(3)/S(3) + S(4)*a*x**S(4) + x**S(11)/S(11) - S(4)*x**S(10)/S(5) + S(32)*x**S(9)/S(9) - S(10)*x**S(8) + x**S(7)*(-S(2)*a/S(7) + S(128)/7) - x**S(6)*(-S(4)*a/S(3) + S(64)/3) + x**S(5)*(-S(16)*a/S(5) + S(64)/5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(a - x**S(4) + S(4)*x**S(3) - S(8)*x**S(2) + S(8)*x), x), x, a*x**S(3)/S(3) - x**S(7)/S(7) + S(2)*x**S(6)/S(3) - S(8)*x**S(5)/S(5) + S(2)*x**S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(a - x**S(4) + S(4)*x**S(3) - S(8)*x**S(2) + S(8)*x), x), x, -atan((x + S(-1))/sqrt(sqrt(a + S(4)) + S(1)))/(S(2)*sqrt(sqrt(a + S(4)) + S(1))) - atan((x + S(-1))/sqrt(-sqrt(a + S(4)) + S(1)))/(S(2)*sqrt(-sqrt(a + S(4)) + S(1))) + atanh(((x + S(-1))**S(2) + S(1))/sqrt(a + S(4)))/sqrt(a + S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(a - x**S(4) + S(4)*x**S(3) - S(8)*x**S(2) + S(8)*x)**S(2), x), x, (x + S(-1))*(S(2)*a + (a + S(4))*(x + S(-1))**S(2) + (S(2)*a + S(10))*(x + S(-1)) + S(2)*(x + S(-1))**S(3) + S(8))/((S(4)*a**S(2) + S(28)*a + S(48))*(a - (x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3))) + (-sqrt(a + S(4)) + S(1))*atan((x + S(-1))/sqrt(sqrt(a + S(4)) + S(1)))/(sqrt(a + S(4))*(S(8)*a + S(24))*sqrt(sqrt(a + S(4)) + S(1))) - (sqrt(a + S(4)) + S(1))*atan((x + S(-1))/sqrt(-sqrt(a + S(4)) + S(1)))/(sqrt(a + S(4))*(S(8)*a + S(24))*sqrt(-sqrt(a + S(4)) + S(1))) + atanh(((x + S(-1))**S(2) + S(1))/sqrt(a + S(4)))/(S(2)*(a + S(4))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a - x**S(4) + S(4)*x**S(3) - S(8)*x**S(2) + S(8)*x)**(S(3)/2), x), x, -(S(32)*a + S(112))*(x + S(-1))*((x + S(-1))**S(2)/(-sqrt(a + S(4)) + S(1)) + S(1))*(-sqrt(a + S(4)) + S(1))/(S(35)*sqrt(a - (x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3))) + (x + S(-1))*(S(2)*a/S(7) - S(6)*(x + S(-1))**S(2)/S(35) + S(26)/35)*sqrt(a - (x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3)) + (x + S(-1))*(a - (x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3))**(S(3)/2)/S(7) + (S(4)*a + S(12))*(S(5)*a + S(16))*((x + S(-1))**S(2)/(-sqrt(a + S(4)) + S(1)) + S(1))*sqrt(sqrt(a + S(4)) + S(1))*elliptic_f(atan((x + S(-1))/sqrt(sqrt(a + S(4)) + S(1))), -S(2)*sqrt(a + S(4))/(-sqrt(a + S(4)) + S(1)))/(S(35)*sqrt(((x + S(-1))**S(2)/(-sqrt(a + S(4)) + S(1)) + S(1))/((x + S(-1))**S(2)/(sqrt(a + S(4)) + S(1)) + S(1)))*sqrt(a - (x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3))) + (S(32)*a + S(112))*((x + S(-1))**S(2)/(-sqrt(a + S(4)) + S(1)) + S(1))*(-sqrt(a + S(4)) + S(1))*sqrt(sqrt(a + S(4)) + S(1))*elliptic_e(atan((x + S(-1))/sqrt(sqrt(a + S(4)) + S(1))), -S(2)*sqrt(a + S(4))/(-sqrt(a + S(4)) + S(1)))/(S(35)*sqrt(((x + S(-1))**S(2)/(-sqrt(a + S(4)) + S(1)) + S(1))/((x + S(-1))**S(2)/(sqrt(a + S(4)) + S(1)) + S(1)))*sqrt(a - (x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a - x**S(4) + S(4)*x**S(3) - S(8)*x**S(2) + S(8)*x), x), x, -(x + S(-1))*((x + S(-1))**S(2)/(-sqrt(a + S(4)) + S(1)) + S(1))*(-S(2)*sqrt(a + S(4)) + S(2))/(S(3)*sqrt(a - (x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3))) + (x + S(-1))*sqrt(a - (x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3))/S(3) + (S(2)*a + S(6))*((x + S(-1))**S(2)/(-sqrt(a + S(4)) + S(1)) + S(1))*sqrt(sqrt(a + S(4)) + S(1))*elliptic_f(atan((x + S(-1))/sqrt(sqrt(a + S(4)) + S(1))), -S(2)*sqrt(a + S(4))/(-sqrt(a + S(4)) + S(1)))/(S(3)*sqrt(((x + S(-1))**S(2)/(-sqrt(a + S(4)) + S(1)) + S(1))/((x + S(-1))**S(2)/(sqrt(a + S(4)) + S(1)) + S(1)))*sqrt(a - (x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3))) + ((x + S(-1))**S(2)/(-sqrt(a + S(4)) + S(1)) + S(1))*(-S(2)*sqrt(a + S(4)) + S(2))*sqrt(sqrt(a + S(4)) + S(1))*elliptic_e(atan((x + S(-1))/sqrt(sqrt(a + S(4)) + S(1))), -S(2)*sqrt(a + S(4))/(-sqrt(a + S(4)) + S(1)))/(S(3)*sqrt(((x + S(-1))**S(2)/(-sqrt(a + S(4)) + S(1)) + S(1))/((x + S(-1))**S(2)/(sqrt(a + S(4)) + S(1)) + S(1)))*sqrt(a - (x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(a - x**S(4) + S(4)*x**S(3) - S(8)*x**S(2) + S(8)*x), x), x, ((x + S(-1))**S(2)/(-sqrt(a + S(4)) + S(1)) + S(1))*sqrt(sqrt(a + S(4)) + S(1))*elliptic_f(atan((x + S(-1))/sqrt(sqrt(a + S(4)) + S(1))), -S(2)*sqrt(a + S(4))/(-sqrt(a + S(4)) + S(1)))/(sqrt(((x + S(-1))**S(2)/(-sqrt(a + S(4)) + S(1)) + S(1))/((x + S(-1))**S(2)/(sqrt(a + S(4)) + S(1)) + S(1)))*sqrt(a - (x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a - x**S(4) + S(4)*x**S(3) - S(8)*x**S(2) + S(8)*x)**(S(3)/2), x), x, (S(3)*a/S(16) + S(3)/4)*((x + S(-1))**S(2) + S(1))*sqrt(a - (x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3)) + S(3)*(a + S(4))**S(2)*atan(((x + S(-1))**S(2) + S(1))/sqrt(a - (x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3)))/S(16) - (S(32)*a + S(112))*(x + S(-1))*((x + S(-1))**S(2)/(-sqrt(a + S(4)) + S(1)) + S(1))*(-sqrt(a + S(4)) + S(1))/(S(35)*sqrt(a - (x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3))) + (x + S(-1))*(S(2)*a/S(7) - S(6)*(x + S(-1))**S(2)/S(35) + S(26)/35)*sqrt(a - (x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3)) + (x + S(-1))*(a - (x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3))**(S(3)/2)/S(7) + ((x + S(-1))**S(2)/S(8) + S(1)/8)*(a - (x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3))**(S(3)/2) + (S(4)*a + S(12))*(S(5)*a + S(16))*((x + S(-1))**S(2)/(-sqrt(a + S(4)) + S(1)) + S(1))*sqrt(sqrt(a + S(4)) + S(1))*elliptic_f(atan((x + S(-1))/sqrt(sqrt(a + S(4)) + S(1))), -S(2)*sqrt(a + S(4))/(-sqrt(a + S(4)) + S(1)))/(S(35)*sqrt(((x + S(-1))**S(2)/(-sqrt(a + S(4)) + S(1)) + S(1))/((x + S(-1))**S(2)/(sqrt(a + S(4)) + S(1)) + S(1)))*sqrt(a - (x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3))) + (S(32)*a + S(112))*((x + S(-1))**S(2)/(-sqrt(a + S(4)) + S(1)) + S(1))*(-sqrt(a + S(4)) + S(1))*sqrt(sqrt(a + S(4)) + S(1))*elliptic_e(atan((x + S(-1))/sqrt(sqrt(a + S(4)) + S(1))), -S(2)*sqrt(a + S(4))/(-sqrt(a + S(4)) + S(1)))/(S(35)*sqrt(((x + S(-1))**S(2)/(-sqrt(a + S(4)) + S(1)) + S(1))/((x + S(-1))**S(2)/(sqrt(a + S(4)) + S(1)) + S(1)))*sqrt(a - (x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*sqrt(a - x**S(4) + S(4)*x**S(3) - S(8)*x**S(2) + S(8)*x), x), x, (a/S(4) + S(1))*atan(((x + S(-1))**S(2) + S(1))/sqrt(a - (x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3))) - (x + S(-1))*((x + S(-1))**S(2)/(-sqrt(a + S(4)) + S(1)) + S(1))*(-S(2)*sqrt(a + S(4)) + S(2))/(S(3)*sqrt(a - (x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3))) + (x + S(-1))*sqrt(a - (x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3))/S(3) + ((x + S(-1))**S(2)/S(4) + S(1)/4)*sqrt(a - (x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3)) + (S(2)*a + S(6))*((x + S(-1))**S(2)/(-sqrt(a + S(4)) + S(1)) + S(1))*sqrt(sqrt(a + S(4)) + S(1))*elliptic_f(atan((x + S(-1))/sqrt(sqrt(a + S(4)) + S(1))), -S(2)*sqrt(a + S(4))/(-sqrt(a + S(4)) + S(1)))/(S(3)*sqrt(((x + S(-1))**S(2)/(-sqrt(a + S(4)) + S(1)) + S(1))/((x + S(-1))**S(2)/(sqrt(a + S(4)) + S(1)) + S(1)))*sqrt(a - (x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3))) + ((x + S(-1))**S(2)/(-sqrt(a + S(4)) + S(1)) + S(1))*(-S(2)*sqrt(a + S(4)) + S(2))*sqrt(sqrt(a + S(4)) + S(1))*elliptic_e(atan((x + S(-1))/sqrt(sqrt(a + S(4)) + S(1))), -S(2)*sqrt(a + S(4))/(-sqrt(a + S(4)) + S(1)))/(S(3)*sqrt(((x + S(-1))**S(2)/(-sqrt(a + S(4)) + S(1)) + S(1))/((x + S(-1))**S(2)/(sqrt(a + S(4)) + S(1)) + S(1)))*sqrt(a - (x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/sqrt(a - x**S(4) + S(4)*x**S(3) - S(8)*x**S(2) + S(8)*x), x), x, atan(((x + S(-1))**S(2) + S(1))/sqrt(a - (x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3)))/S(2) + ((x + S(-1))**S(2)/(-sqrt(a + S(4)) + S(1)) + S(1))*sqrt(sqrt(a + S(4)) + S(1))*elliptic_f(atan((x + S(-1))/sqrt(sqrt(a + S(4)) + S(1))), -S(2)*sqrt(a + S(4))/(-sqrt(a + S(4)) + S(1)))/(sqrt(((x + S(-1))**S(2)/(-sqrt(a + S(4)) + S(1)) + S(1))/((x + S(-1))**S(2)/(sqrt(a + S(4)) + S(1)) + S(1)))*sqrt(a - (x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(a - x**S(4) + S(4)*x**S(3) - S(8)*x**S(2) + S(8)*x)**(S(3)/2), x), x, (S(3)*a/S(8) + S(3)/2)*((x + S(-1))**S(2) + S(1))*sqrt(a - (x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3)) + S(3)*(a + S(4))**S(2)*atan(((x + S(-1))**S(2) + S(1))/sqrt(a - (x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3)))/S(8) + (x + S(-1))*((x + S(-1))**S(2)/(-sqrt(a + S(4)) + S(1)) + S(1))*(-sqrt(a + S(4)) + S(1))*(S(84)*a**S(2) + S(444)*a + S(560))/(S(315)*sqrt(a - (x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3))) + (x + S(-1))*((x + S(-1))**S(2)/S(9) + S(5)/21)*(a - (x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3))**(S(3)/2) + (x + S(-1))*(S(12)*a/S(35) + S(2)*(S(21)*a + S(60))*(x + S(-1))**S(2)/S(315) + S(64)/63)*sqrt(a - (x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3)) + ((x + S(-1))**S(2)/S(4) + S(1)/4)*(a - (x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3))**(S(3)/2) + (S(4)*a + S(12))*(S(33)*a + S(100))*((x + S(-1))**S(2)/(-sqrt(a + S(4)) + S(1)) + S(1))*sqrt(sqrt(a + S(4)) + S(1))*elliptic_f(atan((x + S(-1))/sqrt(sqrt(a + S(4)) + S(1))), -S(2)*sqrt(a + S(4))/(-sqrt(a + S(4)) + S(1)))/(S(315)*sqrt(((x + S(-1))**S(2)/(-sqrt(a + S(4)) + S(1)) + S(1))/((x + S(-1))**S(2)/(sqrt(a + S(4)) + S(1)) + S(1)))*sqrt(a - (x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3))) - ((x + S(-1))**S(2)/(-sqrt(a + S(4)) + S(1)) + S(1))*(-sqrt(a + S(4)) + S(1))*sqrt(sqrt(a + S(4)) + S(1))*(S(84)*a**S(2) + S(444)*a + S(560))*elliptic_e(atan((x + S(-1))/sqrt(sqrt(a + S(4)) + S(1))), -S(2)*sqrt(a + S(4))/(-sqrt(a + S(4)) + S(1)))/(S(315)*sqrt(((x + S(-1))**S(2)/(-sqrt(a + S(4)) + S(1)) + S(1))/((x + S(-1))**S(2)/(sqrt(a + S(4)) + S(1)) + S(1)))*sqrt(a - (x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*sqrt(a - x**S(4) + S(4)*x**S(3) - S(8)*x**S(2) + S(8)*x), x), x, (a/S(2) + S(2))*atan(((x + S(-1))**S(2) + S(1))/sqrt(a - (x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3))) + (S(6)*a + S(16))*(x + S(-1))*((x + S(-1))**S(2)/(-sqrt(a + S(4)) + S(1)) + S(1))*(-sqrt(a + S(4)) + S(1))/(S(15)*sqrt(a - (x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3))) + (x + S(-1))*((x + S(-1))**S(2)/S(5) + S(7)/15)*sqrt(a - (x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3)) + ((x + S(-1))**S(2)/S(2) + S(1)/2)*sqrt(a - (x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3)) - (S(6)*a + S(16))*((x + S(-1))**S(2)/(-sqrt(a + S(4)) + S(1)) + S(1))*(-sqrt(a + S(4)) + S(1))*sqrt(sqrt(a + S(4)) + S(1))*elliptic_e(atan((x + S(-1))/sqrt(sqrt(a + S(4)) + S(1))), -S(2)*sqrt(a + S(4))/(-sqrt(a + S(4)) + S(1)))/(S(15)*sqrt(((x + S(-1))**S(2)/(-sqrt(a + S(4)) + S(1)) + S(1))/((x + S(-1))**S(2)/(sqrt(a + S(4)) + S(1)) + S(1)))*sqrt(a - (x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3))) + (S(8)*a + S(24))*((x + S(-1))**S(2)/(-sqrt(a + S(4)) + S(1)) + S(1))*sqrt(sqrt(a + S(4)) + S(1))*elliptic_f(atan((x + S(-1))/sqrt(sqrt(a + S(4)) + S(1))), -S(2)*sqrt(a + S(4))/(-sqrt(a + S(4)) + S(1)))/(S(15)*sqrt(((x + S(-1))**S(2)/(-sqrt(a + S(4)) + S(1)) + S(1))/((x + S(-1))**S(2)/(sqrt(a + S(4)) + S(1)) + S(1)))*sqrt(a - (x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/sqrt(a - x**S(4) + S(4)*x**S(3) - S(8)*x**S(2) + S(8)*x), x), x, (x + S(-1))*((x + S(-1))**S(2)/(-sqrt(a + S(4)) + S(1)) + S(1))*(-sqrt(a + S(4)) + S(1))/sqrt(a - (x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3)) + atan(((x + S(-1))**S(2) + S(1))/sqrt(a - (x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3))) - ((x + S(-1))**S(2)/(-sqrt(a + S(4)) + S(1)) + S(1))*(-sqrt(a + S(4)) + S(1))*sqrt(sqrt(a + S(4)) + S(1))*elliptic_e(atan((x + S(-1))/sqrt(sqrt(a + S(4)) + S(1))), -S(2)*sqrt(a + S(4))/(-sqrt(a + S(4)) + S(1)))/(sqrt(((x + S(-1))**S(2)/(-sqrt(a + S(4)) + S(1)) + S(1))/((x + S(-1))**S(2)/(sqrt(a + S(4)) + S(1)) + S(1)))*sqrt(a - (x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3))) + ((x + S(-1))**S(2)/(-sqrt(a + S(4)) + S(1)) + S(1))*sqrt(sqrt(a + S(4)) + S(1))*elliptic_f(atan((x + S(-1))/sqrt(sqrt(a + S(4)) + S(1))), -S(2)*sqrt(a + S(4))/(-sqrt(a + S(4)) + S(1)))/(sqrt(((x + S(-1))**S(2)/(-sqrt(a + S(4)) + S(1)) + S(1))/((x + S(-1))**S(2)/(sqrt(a + S(4)) + S(1)) + S(1)))*sqrt(a - (x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(a - x**S(4) + S(4)*x**S(3) - S(8)*x**S(2) + S(8)*x)**(S(3)/2), x), x, (x + S(-1))*(S(2)*a + (a + S(4))*(x + S(-1))**S(2) + (S(2)*a + S(10))*(x + S(-1)) + S(2)*(x + S(-1))**S(3) + S(8))/((S(2)*a**S(2) + S(14)*a + S(24))*sqrt(a - (x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3))) + sqrt(a - (x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3))/(a**S(2) + S(7)*a + S(12)) - (x + S(-1))*((x + S(-1))**S(2)/(-sqrt(a + S(4)) + S(1)) + S(1))*(-sqrt(a + S(4)) + S(1))/((S(2)*a + S(6))*sqrt(a - (x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3))) + ((x + S(-1))**S(2)/(-sqrt(a + S(4)) + S(1)) + S(1))*(-sqrt(a + S(4)) + S(1))*sqrt(sqrt(a + S(4)) + S(1))*elliptic_e(atan((x + S(-1))/sqrt(sqrt(a + S(4)) + S(1))), -S(2)*sqrt(a + S(4))/(-sqrt(a + S(4)) + S(1)))/(sqrt(((x + S(-1))**S(2)/(-sqrt(a + S(4)) + S(1)) + S(1))/((x + S(-1))**S(2)/(sqrt(a + S(4)) + S(1)) + S(1)))*(S(2)*a + S(6))*sqrt(a - (x + S(-1))**S(4) - S(2)*(x + S(-1))**S(2) + S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(8)*x**S(4) - x**S(3) + S(8)*x + S(8))**S(4), x), x, S(4096)*x**S(17)/S(17) - S(128)*x**S(16) + S(128)*x**S(15)/S(5) + S(1168)*x**S(14) + S(10241)*x**S(13)/S(13) - S(448)*x**S(12) + S(25312)*x**S(11)/S(11) + S(21488)*x**S(10)/S(5) + S(1408)*x**S(9) + S(1376)*x**S(8) + S(6784)*x**S(7) + S(7168)*x**S(6) + S(14336)*x**S(5)/S(5) + S(3584)*x**S(4) + S(8192)*x**S(3) + S(8192)*x**S(2) + S(4096)*x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(8)*x**S(4) - x**S(3) + S(8)*x + S(8))**S(3), x), x, S(512)*x**S(13)/S(13) - S(16)*x**S(12) + S(24)*x**S(11)/S(11) + S(307)*x**S(10)/S(2) + S(128)*x**S(9) - S(45)*x**S(8) + S(1560)*x**S(7)/S(7) + S(480)*x**S(6) + S(1152)*x**S(5)/S(5) + S(80)*x**S(4) + S(512)*x**S(3) + S(768)*x**S(2) + S(512)*x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(8)*x**S(4) - x**S(3) + S(8)*x + S(8))**S(2), x), x, S(64)*x**S(9)/S(9) - S(2)*x**S(8) + x**S(7)/S(7) + S(64)*x**S(6)/S(3) + S(112)*x**S(5)/S(5) - S(4)*x**S(4) + S(64)*x**S(3)/S(3) + S(64)*x**S(2) + S(64)*x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(8)*x**S(4) - x**S(3) + S(8)*x + S(8), x), x, S(8)*x**S(5)/S(5) - x**S(4)/S(4) + S(4)*x**S(2) + S(8)*x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(S(8)*x**S(4) - x**S(3) + S(8)*x + S(8)), x), x, -sqrt(S(-109)/1218 + S(67)*sqrt(S(29))/S(1218))*log((S(1) + S(4)/x)**S(2) - (S(1) + S(4)/x)*sqrt(S(6) + S(6)*sqrt(S(29))) + S(3)*sqrt(S(29)))/S(24) + sqrt(S(-109)/1218 + S(67)*sqrt(S(29))/S(1218))*log((S(1) + S(4)/x)**S(2) + (S(1) + S(4)/x)*sqrt(S(6) + S(6)*sqrt(S(29))) + S(3)*sqrt(S(29)))/S(24) - sqrt(S(7))*atan(sqrt(S(7))*(-(S(1) + S(4)/x)**S(2) + S(3))/S(42))/S(84) + sqrt(S(109)/1218 + S(67)*sqrt(S(29))/S(1218))*atan((S(-2) + sqrt(S(6) + S(6)*sqrt(S(29))) - S(8)/x)/sqrt(S(-6) + S(6)*sqrt(S(29))))/S(12) - sqrt(S(109)/1218 + S(67)*sqrt(S(29))/S(1218))*atan((S(2) + sqrt(S(6) + S(6)*sqrt(S(29))) + S(8)/x)/sqrt(S(-6) + S(6)*sqrt(S(29))))/S(12), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(8)*x**S(4) - x**S(3) + S(8)*x + S(8))**(S(-2)), x), x, (S(1) + S(4)/x)*(S(207)*(S(1) + S(4)/x)**S(3) + S(995)*(S(1) + S(4)/x)**S(2) + S(16974) - S(35244)/x)/(S(87696)*(S(1) + S(4)/x)**S(4) - S(526176)*(S(1) + S(4)/x)**S(2) + S(22888656)) - sqrt(S(-180983329)/1218 + S(1583563)*sqrt(S(29))/S(42))*log((S(1) + S(4)/x)**S(2) - (S(1) + S(4)/x)*sqrt(S(6) + S(6)*sqrt(S(29))) + S(3)*sqrt(S(29)))/S(175392) + sqrt(S(-180983329)/1218 + S(1583563)*sqrt(S(29))/S(42))*log((S(1) + S(4)/x)**S(2) + (S(1) + S(4)/x)*sqrt(S(6) + S(6)*sqrt(S(29))) + S(3)*sqrt(S(29)))/S(175392) - S(17)*sqrt(S(7))*atan(sqrt(S(7))*(-(S(1) + S(4)/x)**S(2) + S(3))/S(42))/S(7056) + sqrt(S(180983329)/1218 + S(1583563)*sqrt(S(29))/S(42))*atan((S(-2) + sqrt(S(6) + S(6)*sqrt(S(29))) - S(8)/x)/sqrt(S(-6) + S(6)*sqrt(S(29))))/S(87696) - sqrt(S(180983329)/1218 + S(1583563)*sqrt(S(29))/S(42))*atan((S(2) + sqrt(S(6) + S(6)*sqrt(S(29))) + S(8)/x)/sqrt(S(-6) + S(6)*sqrt(S(29))))/S(87696), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(4)*x**S(4) + S(4)*x**S(2) + S(4)*x + S(1))**S(4), x), x, S(256)*x**S(17)/S(17) + S(1024)*x**S(15)/S(15) + S(512)*x**S(14)/S(7) + S(1792)*x**S(13)/S(13) + S(256)*x**S(12) + S(3328)*x**S(11)/S(11) + S(384)*x**S(10) + S(4192)*x**S(9)/S(9) + S(448)*x**S(8) + S(2752)*x**S(7)/S(7) + S(992)*x**S(6)/S(3) + S(1136)*x**S(5)/S(5) + S(112)*x**S(4) + S(112)*x**S(3)/S(3) + S(8)*x**S(2) + x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(4)*x**S(4) + S(4)*x**S(2) + S(4)*x + S(1))**S(3), x), x, S(64)*x**S(13)/S(13) + S(192)*x**S(11)/S(11) + S(96)*x**S(10)/S(5) + S(80)*x**S(9)/S(3) + S(48)*x**S(8) + S(352)*x**S(7)/S(7) + S(48)*x**S(6) + S(252)*x**S(5)/S(5) + S(40)*x**S(4) + S(20)*x**S(3) + S(6)*x**S(2) + x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(4)*x**S(4) + S(4)*x**S(2) + S(4)*x + S(1))**S(2), x), x, S(16)*x**S(9)/S(9) + S(32)*x**S(7)/S(7) + S(16)*x**S(6)/S(3) + S(24)*x**S(5)/S(5) + S(8)*x**S(4) + S(8)*x**S(3) + S(4)*x**S(2) + x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(4)*x**S(4) + S(4)*x**S(2) + S(4)*x + S(1), x), x, S(4)*x**S(5)/S(5) + S(4)*x**S(3)/S(3) + S(2)*x**S(2) + x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(S(4)*x**S(4) + S(4)*x**S(2) + S(4)*x + S(1)), x), x, -sqrt(S(-2)/5 + sqrt(S(5))/S(5))*log((S(1) + S(1)/x)**S(2) - (S(1) + S(1)/x)*sqrt(S(2) + S(2)*sqrt(S(5))) + sqrt(S(5)))/S(4) + sqrt(S(-2)/5 + sqrt(S(5))/S(5))*log((S(1) + S(1)/x)**S(2) + (S(1) + S(1)/x)*sqrt(S(2) + S(2)*sqrt(S(5))) + sqrt(S(5)))/S(4) + sqrt(S(2)/5 + sqrt(S(5))/S(5))*atan((S(-2) + sqrt(S(2) + S(2)*sqrt(S(5))) - S(2)/x)/sqrt(S(-2) + S(2)*sqrt(S(5))))/S(2) - sqrt(S(2)/5 + sqrt(S(5))/S(5))*atan((S(2) + sqrt(S(2) + S(2)*sqrt(S(5))) + S(2)/x)/sqrt(S(-2) + S(2)*sqrt(S(5))))/S(2) + atan((S(1) + S(1)/x)**S(2)/S(2) + S(-1)/2)/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(4)*x**S(4) + S(4)*x**S(2) + S(4)*x + S(1))**(S(-2)), x), x, (S(1) + S(1)/x)*(S(17)*(S(1) + S(1)/x)**S(3) - S(17)*(S(1) + S(1)/x)**S(2) + S(30) - S(29)/x)/(S(10)*(S(1) + S(1)/x)**S(4) - S(20)*(S(1) + S(1)/x)**S(2) + S(50)) + sqrt(S(-5959)/10 + S(533)*sqrt(S(5))/S(2))*log((S(1) + S(1)/x)**S(2) - (S(1) + S(1)/x)*sqrt(S(2) + S(2)*sqrt(S(5))) + sqrt(S(5)))/S(40) - sqrt(S(-5959)/10 + S(533)*sqrt(S(5))/S(2))*log((S(1) + S(1)/x)**S(2) + (S(1) + S(1)/x)*sqrt(S(2) + S(2)*sqrt(S(5))) + sqrt(S(5)))/S(40) + sqrt(S(5959)/10 + S(533)*sqrt(S(5))/S(2))*atan((S(-2) + sqrt(S(2) + S(2)*sqrt(S(5))) - S(2)/x)/sqrt(S(-2) + S(2)*sqrt(S(5))))/S(20) - sqrt(S(5959)/10 + S(533)*sqrt(S(5))/S(2))*atan((S(2) + sqrt(S(2) + S(2)*sqrt(S(5))) + S(2)/x)/sqrt(S(-2) + S(2)*sqrt(S(5))))/S(20) + S(7)*atan((S(1) + S(1)/x)**S(2)/S(2) + S(-1)/2)/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(8)*x**S(4) - S(15)*x**S(3) + S(8)*x**S(2) + S(24)*x + S(8))**S(4), x), x, S(4096)*x**S(17)/S(17) - S(1920)*x**S(16) + S(102784)*x**S(15)/S(15) - S(75504)*x**S(14)/S(7) - S(12095)*x**S(13)/S(13) + S(31128)*x**S(12) - S(331040)*x**S(11)/S(11) - S(169584)*x**S(10)/S(5) + S(641152)*x**S(9)/S(9) + S(36384)*x**S(8) - S(566912)*x**S(7)/S(7) - S(30720)*x**S(6) + S(538624)*x**S(5)/S(5) + S(139776)*x**S(4) + S(237568)*x**S(3)/S(3) + S(24576)*x**S(2) + S(4096)*x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(8)*x**S(4) - S(15)*x**S(3) + S(8)*x**S(2) + S(24)*x + S(8))**S(3), x), x, S(512)*x**S(13)/S(13) - S(240)*x**S(12) + S(6936)*x**S(11)/S(11) - S(4527)*x**S(10)/S(10) - S(2936)*x**S(9)/S(3) + S(2097)*x**S(8) + S(5528)*x**S(7)/S(7) - S(2976)*x**S(6) - S(384)*x**S(5)/S(5) + S(5040)*x**S(4) + S(5120)*x**S(3) + S(2304)*x**S(2) + S(512)*x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(8)*x**S(4) - S(15)*x**S(3) + S(8)*x**S(2) + S(24)*x + S(8))**S(2), x), x, S(64)*x**S(9)/S(9) - S(30)*x**S(8) + S(353)*x**S(7)/S(7) + S(24)*x**S(6) - S(528)*x**S(5)/S(5) + S(36)*x**S(4) + S(704)*x**S(3)/S(3) + S(192)*x**S(2) + S(64)*x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(8)*x**S(4) - S(15)*x**S(3) + S(8)*x**S(2) + S(24)*x + S(8), x), x, S(8)*x**S(5)/S(5) - S(15)*x**S(4)/S(4) + S(8)*x**S(3)/S(3) + S(12)*x**S(2) + S(8)*x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(S(8)*x**S(4) - S(15)*x**S(3) + S(8)*x**S(2) + S(24)*x + S(8)), x), x, -sqrt(S(-5167)/40326 + S(5)*sqrt(S(517))/S(858))*log((S(3) + S(4)/x)**S(2) - (S(3) + S(4)/x)*sqrt(S(38) + S(2)*sqrt(S(517))) + sqrt(S(517)))/S(8) + sqrt(S(-5167)/40326 + S(5)*sqrt(S(517))/S(858))*log((S(3) + S(4)/x)**S(2) + (S(3) + S(4)/x)*sqrt(S(38) + S(2)*sqrt(S(517))) + sqrt(S(517)))/S(8) - sqrt(S(39))*atan(sqrt(S(39))*(-(S(3) + S(4)/x)**S(2) + S(19))/S(78))/S(52) + sqrt(S(5167)/40326 + S(5)*sqrt(S(517))/S(858))*atan((S(-6) + sqrt(S(38) + S(2)*sqrt(S(517))) - S(8)/x)/sqrt(S(-38) + S(2)*sqrt(S(517))))/S(4) - sqrt(S(5167)/40326 + S(5)*sqrt(S(517))/S(858))*atan((S(6) + sqrt(S(38) + S(2)*sqrt(S(517))) + S(8)/x)/sqrt(S(-38) + S(2)*sqrt(S(517))))/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(8)*x**S(4) - S(15)*x**S(3) + S(8)*x**S(2) + S(24)*x + S(8))**(S(-2)), x), x, (S(3) + S(4)/x)*(S(30231)*(S(3) + S(4)/x)**S(3) - S(129631)*(S(3) + S(4)/x)**S(2) + S(1375210) - S(2603628)/x)/(S(322608)*(S(3) + S(4)/x)**S(4) - S(12259104)*(S(3) + S(4)/x)**S(2) + S(166788336)) - sqrt(S(-59644114671451)/40326 + S(5073830635)*sqrt(S(517))/S(78))*log((S(3) + S(4)/x)**S(2) - (S(3) + S(4)/x)*sqrt(S(38) + S(2)*sqrt(S(517))) + sqrt(S(517)))/S(645216) + sqrt(S(-59644114671451)/40326 + S(5073830635)*sqrt(S(517))/S(78))*log((S(3) + S(4)/x)**S(2) + (S(3) + S(4)/x)*sqrt(S(38) + S(2)*sqrt(S(517))) + sqrt(S(517)))/S(645216) - S(73)*sqrt(S(39))*atan(sqrt(S(39))*(-(S(3) + S(4)/x)**S(2) + S(19))/S(78))/S(2704) + sqrt(S(19)/40326 + sqrt(S(517))/S(40326))*(S(1678181) + S(74897)*sqrt(S(517)))*atan((S(-6) + sqrt(S(38) + S(2)*sqrt(S(517))) - S(8)/x)/sqrt(S(-38) + S(2)*sqrt(S(517))))/S(645216) - sqrt(S(19)/40326 + sqrt(S(517))/S(40326))*(S(1678181) + S(74897)*sqrt(S(517)))*atan((S(6) + sqrt(S(38) + S(2)*sqrt(S(517))) + S(8)/x)/sqrt(S(-38) + S(2)*sqrt(S(517))))/S(645216), expand=True, _diff=True, _numerical=True)
'''Takes a long time in rubi test, final results contain subs with Integral
assert rubi_test(rubi_integrate(S(1)/sqrt(S(8)*x**S(4) - x**S(3) + S(8)*x + S(8)), x), x, -S(29)**(S(3)/4)*sqrt(S(6))*x**S(2)*sqrt(((S(1) + S(4)/x)**S(4) - S(6)*(S(1) + S(4)/x)**S(2) + S(261))/(sqrt(S(29))*(S(1) + S(4)/x)**S(2) + S(87))**S(2))*(sqrt(S(29))*(S(1) + S(4)/x)**S(2) + S(87))*elliptic_f(S(2)*atan(S(29)**(S(3)/4)*sqrt(S(3))*(S(1) + S(4)/x)/S(87)), sqrt(S(29))/S(58) + S(1)/2)/(S(174)*sqrt(x**S(4)*((S(1) + S(4)/x)**S(4) - S(6)*(S(1) + S(4)/x)**S(2) + S(261)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(8)*x**S(4) - x**S(3) + S(8)*x + S(8))**(S(-3)/2), x), x, S(29)**(S(1)/4)*sqrt(S(6))*x**S(2)*sqrt(((S(1) + S(4)/x)**S(4) - S(6)*(S(1) + S(4)/x)**S(2) + S(261))/(sqrt(S(29))*(S(1) + S(4)/x)**S(2) + S(87))**S(2))*(-S(5)*sqrt(S(29)) + S(14))*(sqrt(S(29))*(S(1) + S(4)/x)**S(2) + S(87))*elliptic_f(S(2)*atan(S(29)**(S(3)/4)*sqrt(S(3))*(S(1) + S(4)/x)/S(87)), sqrt(S(29))/S(58) + S(1)/2)/(S(12528)*sqrt(x**S(4)*((S(1) + S(4)/x)**S(4) - S(6)*(S(1) + S(4)/x)**S(2) + S(261)))) - S(29)**(S(1)/4)*sqrt(S(6))*x**S(2)*sqrt(((S(1) + S(4)/x)**S(4) - S(6)*(S(1) + S(4)/x)**S(2) + S(261))/(sqrt(S(29))*(S(1) + S(4)/x)**S(2) + S(87))**S(2))*(S(7)*sqrt(S(29))*(S(1) + S(4)/x)**S(2) + S(609))*elliptic_e(S(2)*atan(S(29)**(S(3)/4)*sqrt(S(3))*(S(1) + S(4)/x)/S(87)), sqrt(S(29))/S(58) + S(1)/2)/(S(3132)*sqrt(x**S(4)*((S(1) + S(4)/x)**S(4) - S(6)*(S(1) + S(4)/x)**S(2) + S(261)))) + sqrt(S(2))*x**S(2)*(S(1) + S(4)/x)*(S(22)*(S(1) + S(4)/x)**S(3) - S(49)*(S(1) + S(4)/x)**S(2) + S(1467) - S(180)/x)/(S(21924)*sqrt(x**S(4)*((S(1) + S(4)/x)**S(4) - S(6)*(S(1) + S(4)/x)**S(2) + S(261)))) + sqrt(S(58))*x**S(2)*(S(1) + S(4)/x)*(S(7)*(S(1) + S(4)/x)**S(4) - S(42)*(S(1) + S(4)/x)**S(2) + S(1827))/(S(3132)*sqrt(x**S(4)*((S(1) + S(4)/x)**S(4) - S(6)*(S(1) + S(4)/x)**S(2) + S(261)))*(sqrt(S(29))*(S(1) + S(4)/x)**S(2) + S(87))) - sqrt(S(2))*x**S(2)*(S(11)*(S(1) + S(4)/x)**S(4) - S(66)*(S(1) + S(4)/x)**S(2) + S(2871))/(S(10962)*sqrt(x**S(4)*((S(1) + S(4)/x)**S(4) - S(6)*(S(1) + S(4)/x)**S(2) + S(261)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(4)*x**S(4) + S(4)*x**S(2) + S(4)*x + S(1)), x), x, -S(5)**(S(3)/4)*x**S(2)*sqrt(((S(1) + S(1)/x)**S(4) - S(2)*(S(1) + S(1)/x)**S(2) + S(5))/((S(1) + S(1)/x)**S(2) + sqrt(S(5)))**S(2))*((S(1) + S(1)/x)**S(2) + sqrt(S(5)))*elliptic_f(S(2)*atan(S(5)**(S(3)/4)*(S(1) + S(1)/x)/S(5)), sqrt(S(5))/S(10) + S(1)/2)/(S(10)*sqrt(x**S(4)*((S(1) + S(1)/x)**S(4) - S(2)*(S(1) + S(1)/x)**S(2) + S(5)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(4)*x**S(4) + S(4)*x**S(2) + S(4)*x + S(1))**(S(-3)/2), x), x, S(5)**(S(1)/4)*x**S(2)*sqrt(((S(1) + S(1)/x)**S(4) - S(2)*(S(1) + S(1)/x)**S(2) + S(5))/((S(1) + S(1)/x)**S(2) + sqrt(S(5)))**S(2))*(-S(3)*sqrt(S(5)) + S(9))*((S(1) + S(1)/x)**S(2) + sqrt(S(5)))*elliptic_f(S(2)*atan(S(5)**(S(3)/4)*(S(1) + S(1)/x)/S(5)), sqrt(S(5))/S(10) + S(1)/2)/(S(20)*sqrt(x**S(4)*((S(1) + S(1)/x)**S(4) - S(2)*(S(1) + S(1)/x)**S(2) + S(5)))) - S(5)**(S(1)/4)*x**S(2)*sqrt(((S(1) + S(1)/x)**S(4) - S(2)*(S(1) + S(1)/x)**S(2) + S(5))/((S(1) + S(1)/x)**S(2) + sqrt(S(5)))**S(2))*(S(9)*(S(1) + S(1)/x)**S(2) + S(9)*sqrt(S(5)))*elliptic_e(S(2)*atan(S(5)**(S(3)/4)*(S(1) + S(1)/x)/S(5)), sqrt(S(5))/S(10) + S(1)/2)/(S(10)*sqrt(x**S(4)*((S(1) + S(1)/x)**S(4) - S(2)*(S(1) + S(1)/x)**S(2) + S(5)))) + x**S(2)*(S(1) + S(1)/x)*(S(6)*(S(1) + S(1)/x)**S(3) - S(9)*(S(1) + S(1)/x)**S(2) + S(11) - S(2)/x)/(S(10)*sqrt(x**S(4)*((S(1) + S(1)/x)**S(4) - S(2)*(S(1) + S(1)/x)**S(2) + S(5)))) + x**S(2)*(S(1) + S(1)/x)*(S(9)*(S(1) + S(1)/x)**S(4) - S(18)*(S(1) + S(1)/x)**S(2) + S(45))/(sqrt(x**S(4)*((S(1) + S(1)/x)**S(4) - S(2)*(S(1) + S(1)/x)**S(2) + S(5)))*(S(10)*(S(1) + S(1)/x)**S(2) + S(10)*sqrt(S(5)))) - x**S(2)*(S(3)*(S(1) + S(1)/x)**S(4) - S(6)*(S(1) + S(1)/x)**S(2) + S(15))/(S(5)*sqrt(x**S(4)*((S(1) + S(1)/x)**S(4) - S(2)*(S(1) + S(1)/x)**S(2) + S(5)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(8)*x**S(4) - S(15)*x**S(3) + S(8)*x**S(2) + S(24)*x + S(8)), x), x, -sqrt(S(2))*S(517)**(S(3)/4)*x**S(2)*sqrt(((S(3) + S(4)/x)**S(4) - S(38)*(S(3) + S(4)/x)**S(2) + S(517))/((S(3) + S(4)/x)**S(2) + sqrt(S(517)))**S(2))*((S(3) + S(4)/x)**S(2) + sqrt(S(517)))*elliptic_f(S(2)*atan(S(517)**(S(3)/4)*(S(3) + S(4)/x)/S(517)), S(19)*sqrt(S(517))/S(1034) + S(1)/2)/(S(1034)*sqrt(x**S(4)*((S(3) + S(4)/x)**S(4) - S(38)*(S(3) + S(4)/x)**S(2) + S(517)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(8)*x**S(4) - S(15)*x**S(3) + S(8)*x**S(2) + S(24)*x + S(8))**(S(-3)/2), x), x, sqrt(S(2))*S(517)**(S(1)/4)*x**S(2)*sqrt(((S(3) + S(4)/x)**S(4) - S(38)*(S(3) + S(4)/x)**S(2) + S(517))/((S(3) + S(4)/x)**S(2) + sqrt(S(517)))**S(2))*(-S(203)*sqrt(S(517)) + S(4910))*((S(3) + S(4)/x)**S(2) + sqrt(S(517)))*elliptic_f(S(2)*atan(S(517)**(S(3)/4)*(S(3) + S(4)/x)/S(517)), S(19)*sqrt(S(517))/S(1034) + S(1)/2)/(S(322608)*sqrt(x**S(4)*((S(3) + S(4)/x)**S(4) - S(38)*(S(3) + S(4)/x)**S(2) + S(517)))) - sqrt(S(2))*S(517)**(S(1)/4)*x**S(2)*sqrt(((S(3) + S(4)/x)**S(4) - S(38)*(S(3) + S(4)/x)**S(2) + S(517))/((S(3) + S(4)/x)**S(2) + sqrt(S(517)))**S(2))*(S(2455)*(S(3) + S(4)/x)**S(2) + S(2455)*sqrt(S(517)))*elliptic_e(S(2)*atan(S(517)**(S(3)/4)*(S(3) + S(4)/x)/S(517)), S(19)*sqrt(S(517))/S(1034) + S(1)/2)/(S(80652)*sqrt(x**S(4)*((S(3) + S(4)/x)**S(4) - S(38)*(S(3) + S(4)/x)**S(2) + S(517)))) + sqrt(S(2))*x**S(2)*(S(3) + S(4)/x)*(S(516)*(S(3) + S(4)/x)**S(3) - S(2455)*(S(3) + S(4)/x)**S(2) + S(24643) - S(35004)/x)/(S(80652)*sqrt(x**S(4)*((S(3) + S(4)/x)**S(4) - S(38)*(S(3) + S(4)/x)**S(2) + S(517)))) + sqrt(S(2))*x**S(2)*(S(3) + S(4)/x)*(S(2455)*(S(3) + S(4)/x)**S(4) - S(93290)*(S(3) + S(4)/x)**S(2) + S(1269235))/(S(80652)*sqrt(x**S(4)*((S(3) + S(4)/x)**S(4) - S(38)*(S(3) + S(4)/x)**S(2) + S(517)))*((S(3) + S(4)/x)**S(2) + sqrt(S(517)))) - S(43)*sqrt(S(2))*x**S(2)*((S(3) + S(4)/x)**S(4) - S(38)*(S(3) + S(4)/x)**S(2) + S(517))/(S(6721)*sqrt(x**S(4)*((S(3) + S(4)/x)**S(4) - S(38)*(S(3) + S(4)/x)**S(2) + S(517)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(8)*x**S(4) - S(15)*x**S(3) + S(8)*x**S(2) + S(24)*x + S(8))**(S(-5)/2), x), x, sqrt(S(2))*S(517)**(S(1)/4)*x**S(2)*sqrt(((S(3) + S(4)/x)**S(4) - S(38)*(S(3) + S(4)/x)**S(2) + S(517))/((S(3) + S(4)/x)**S(2) + sqrt(S(517)))**S(2))*(-S(175318963)*sqrt(S(517)) + S(4346103976))*((S(3) + S(4)/x)**S(2) + sqrt(S(517)))*elliptic_f(S(2)*atan(S(517)**(S(3)/4)*(S(3) + S(4)/x)/S(517)), S(19)*sqrt(S(517))/S(1034) + S(1)/2)/(S(156113882496)*sqrt(x**S(4)*((S(3) + S(4)/x)**S(4) - S(38)*(S(3) + S(4)/x)**S(2) + S(517)))) - sqrt(S(2))*S(517)**(S(1)/4)*x**S(2)*sqrt(((S(3) + S(4)/x)**S(4) - S(38)*(S(3) + S(4)/x)**S(2) + S(517))/((S(3) + S(4)/x)**S(2) + sqrt(S(517)))**S(2))*(S(543262997)*(S(3) + S(4)/x)**S(2) + S(543262997)*sqrt(S(517)))*elliptic_e(S(2)*atan(S(517)**(S(3)/4)*(S(3) + S(4)/x)/S(517)), S(19)*sqrt(S(517))/S(1034) + S(1)/2)/(S(9757117656)*sqrt(x**S(4)*((S(3) + S(4)/x)**S(4) - S(38)*(S(3) + S(4)/x)**S(2) + S(517)))) + sqrt(S(2))*x**S(2)*(S(3) + S(4)/x)*(S(223148517)*(S(3) + S(4)/x)**S(3) - S(1086525994)*(S(3) + S(4)/x)**S(2) + S(8668521901) - S(13685866440)/x)/(S(19514235312)*sqrt(x**S(4)*((S(3) + S(4)/x)**S(4) - S(38)*(S(3) + S(4)/x)**S(2) + S(517)))) + sqrt(S(2))*x**S(2)*(S(3) + S(4)/x)*(S(193467)*(S(3) + S(4)/x)**S(3) - S(718994)*(S(3) + S(4)/x)**S(2) + S(8297705) - S(20727588)/x)/(S(241956)*sqrt(x**S(4)*((S(3) + S(4)/x)**S(4) - S(38)*(S(3) + S(4)/x)**S(2) + S(517)))*((S(3) + S(4)/x)**S(4) - S(38)*(S(3) + S(4)/x)**S(2) + S(517))) + sqrt(S(2))*x**S(2)*(S(3) + S(4)/x)*(S(543262997)*(S(3) + S(4)/x)**S(4) - S(20643993886)*(S(3) + S(4)/x)**S(2) + S(280866969449))/(S(9757117656)*sqrt(x**S(4)*((S(3) + S(4)/x)**S(4) - S(38)*(S(3) + S(4)/x)**S(2) + S(517)))*((S(3) + S(4)/x)**S(2) + sqrt(S(517)))) - sqrt(S(2))*x**S(2)*(S(74382839)*(S(3) + S(4)/x)**S(4) - S(2826547882)*(S(3) + S(4)/x)**S(2) + S(38455927763))/(S(6504745104)*sqrt(x**S(4)*((S(3) + S(4)/x)**S(4) - S(38)*(S(3) + S(4)/x)**S(2) + S(517)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(3)*x**S(4) + S(15)*x**S(3) - S(44)*x**S(2) - S(6)*x + S(9)), x), x, S(613)**(S(3)/4)*x**S(2)*sqrt(((S(-1) + S(6)/x)**S(4) - S(182)*(S(1) - S(6)/x)**S(2) + S(613))/((S(-1) + S(6)/x)**S(2) + sqrt(S(613)))**S(2))*((S(-1) + S(6)/x)**S(2) + sqrt(S(613)))*elliptic_f(S(2)*atan(S(613)**(S(3)/4)*(S(1) - S(6)/x)/S(613)), S(1)/2 + S(91)*sqrt(S(613))/S(1226))/(S(613)*sqrt(x**S(4)*((S(-1) + S(6)/x)**S(4) - S(182)*(S(1) - S(6)/x)**S(2) + S(613)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(3)*x**S(4) + S(15)*x**S(3) - S(44)*x**S(2) - S(6)*x + S(9))**(S(-3)/2), x), x, S(613)**(S(1)/4)*x**S(2)*sqrt(((S(-1) + S(6)/x)**S(4) - S(182)*(S(1) - S(6)/x)**S(2) + S(613))/((S(-1) + S(6)/x)**S(2) + sqrt(S(613)))**S(2))*(-S(145)*sqrt(S(613)) + S(7444))*((S(-1) + S(6)/x)**S(2) + sqrt(S(613)))*elliptic_f(S(2)*atan(S(613)**(S(3)/4)*(S(1) - S(6)/x)/S(613)), S(1)/2 + S(91)*sqrt(S(613))/S(1226))/(S(10576089)*sqrt(x**S(4)*((S(-1) + S(6)/x)**S(4) - S(182)*(S(1) - S(6)/x)**S(2) + S(613)))) - S(613)**(S(1)/4)*x**S(2)*sqrt(((S(-1) + S(6)/x)**S(4) - S(182)*(S(1) - S(6)/x)**S(2) + S(613))/((S(-1) + S(6)/x)**S(2) + sqrt(S(613)))**S(2))*(S(14888)*(S(-1) + S(6)/x)**S(2) + S(14888)*sqrt(S(613)))*elliptic_e(S(2)*atan(S(613)**(S(3)/4)*(S(1) - S(6)/x)/S(613)), S(1)/2 + S(91)*sqrt(S(613))/S(1226))/(S(10576089)*sqrt(x**S(4)*((S(-1) + S(6)/x)**S(4) - S(182)*(S(1) - S(6)/x)**S(2) + S(613)))) + x**S(2)*(S(1) - S(6)/x)*(S(704)*(S(1) - S(6)/x)**S(3) - S(14888)*(S(1) - S(6)/x)**S(2) + S(109872) + S(430392)/x)/(S(10576089)*sqrt(x**S(4)*((S(-1) + S(6)/x)**S(4) - S(182)*(S(1) - S(6)/x)**S(2) + S(613)))) + x**S(2)*(S(1) - S(6)/x)*(S(14888)*(S(-1) + S(6)/x)**S(4) - S(2709616)*(S(1) - S(6)/x)**S(2) + S(9126344))/(sqrt(x**S(4)*((S(-1) + S(6)/x)**S(4) - S(182)*(S(1) - S(6)/x)**S(2) + S(613)))*(S(10576089)*(S(-1) + S(6)/x)**S(2) + S(10576089)*sqrt(S(613)))) - x**S(2)*(S(704)*(S(-1) + S(6)/x)**S(4) - S(128128)*(S(1) - S(6)/x)**S(2) + S(431552))/(S(10576089)*sqrt(x**S(4)*((S(-1) + S(6)/x)**S(4) - S(182)*(S(1) - S(6)/x)**S(2) + S(613)))), expand=True, _diff=True, _numerical=True)
'''
def test_5():
assert rubi_test(rubi_integrate(x**m*sqrt(-a/x + b)/sqrt(a - b*x), x), x, S(2)*x**(m + S(1))*sqrt(-a/x + b)/(sqrt(a - b*x)*(S(2)*m + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*sqrt(-a/x + b)/sqrt(a - b*x), x), x, S(2)*x**S(3)*sqrt(-a/x + b)/(S(5)*sqrt(a - b*x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*sqrt(-a/x + b)/sqrt(a - b*x), x), x, S(2)*x**S(2)*sqrt(-a/x + b)/(S(3)*sqrt(a - b*x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(-a/x + b)/sqrt(a - b*x), x), x, S(2)*x*sqrt(-a/x + b)/sqrt(a - b*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(-a/x + b)/(x*sqrt(a - b*x)), x), x, -S(2)*sqrt(-a/x + b)/sqrt(a - b*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(-a/x + b)/(x**S(2)*sqrt(a - b*x)), x), x, -S(2)*sqrt(-a/x + b)/(S(3)*x*sqrt(a - b*x)), expand=True, _diff=True, _numerical=True)
# appellf1 assert rubi_test(rubi_integrate((a + b/x)**m*(c + d*x)**n, x), x, x*(S(1) + d*x/c)**(-n)*(a + b/x)**m*(c + d*x)**n*(a*x/b + S(1))**(-m)*AppellF1(-m + S(1), -m, -n, -m + S(2), -a*x/b, -d*x/c)/(-m + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b/x)**m*(c + d*x)**S(2), x), x, d**S(2)*x**S(3)*(a + b/x)**(m + S(1))/(S(3)*a) + d*x**S(2)*(a + b/x)**(m + S(1))*(S(6)*a*c - b*d*(-m + S(2)))/(S(6)*a**S(2)) - b*(a + b/x)**(m + S(1))*(S(6)*a**S(2)*c**S(2) - S(6)*a*b*c*d*(-m + S(1)) + b**S(2)*d**S(2)*(m**S(2) - S(3)*m + S(2)))*hyper((S(2), m + S(1)), (m + S(2),), S(1) + b/(a*x))/(S(6)*a**S(4)*(m + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b/x)**m*(c + d*x), x), x, d*x**S(2)*(a + b/x)**(m + S(1))/(S(2)*a) - b*(a + b/x)**(m + S(1))*(S(2)*a*c - b*d*(-m + S(1)))*hyper((S(2), m + S(1)), (m + S(2),), S(1) + b/(a*x))/(S(2)*a**S(3)*(m + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b/x)**m, x), x, -b*(a + b/x)**(m + S(1))*hyper((S(2), m + S(1)), (m + S(2),), S(1) + b/(a*x))/(a**S(2)*(m + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b/x)**m/(c + d*x), x), x, -c*(a + b/x)**(m + S(1))*hyper((S(1), m + S(1)), (m + S(2),), c*(a + b/x)/(a*c - b*d))/(d*(m + S(1))*(a*c - b*d)) + (a + b/x)**(m + S(1))*hyper((S(1), m + S(1)), (m + S(2),), S(1) + b/(a*x))/(a*d*(m + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b/x)**m/(c + d*x)**S(2), x), x, -b*(a + b/x)**(m + S(1))*hyper((S(2), m + S(1)), (m + S(2),), c*(a + b/x)/(a*c - b*d))/((m + S(1))*(a*c - b*d)**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b/x)**m/(c + d*x)**S(3), x), x, -b*(a + b/x)**(m + S(1))*(S(2)*a*c - b*d*(m + S(1)))*hyper((S(2), m + S(1)), (m + S(2),), c*(a + b/x)/(a*c - b*d))/(S(2)*c*(m + S(1))*(a*c - b*d)**S(3)) - d*(a + b/x)**(m + S(1))/(S(2)*c*(a*c - b*d)*(c/x + d)**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b/x)**m/(c + d*x)**S(4), x), x, -b*(a + b/x)**(m + S(1))*(S(6)*a**S(2)*c**S(2) - S(6)*a*b*c*d*(m + S(1)) + b**S(2)*d**S(2)*(m**S(2) + S(3)*m + S(2)))*hyper((S(2), m + S(1)), (m + S(2),), c*(a + b/x)/(a*c - b*d))/(S(6)*c**S(2)*(m + S(1))*(a*c - b*d)**S(4)) + d**S(2)*(a + b/x)**(m + S(1))/(S(3)*c**S(2)*(a*c - b*d)*(c/x + d)**S(3)) - d*(a + b/x)**(m + S(1))*(S(6)*a*c - b*d*(m + S(4)))/(S(6)*c**S(2)*(a*c - b*d)**S(2)*(c/x + d)**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**m*sqrt(-a/x**S(2) + b)/sqrt(a - b*x**S(2)), x), x, x**(m + S(1))*sqrt(-a/x**S(2) + b)/(m*sqrt(a - b*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*sqrt(-a/x**S(2) + b)/sqrt(a - b*x**S(2)), x), x, x**S(3)*sqrt(-a/x**S(2) + b)/(S(2)*sqrt(a - b*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*sqrt(-a/x**S(2) + b)/sqrt(a - b*x**S(2)), x), x, x**S(2)*sqrt(-a/x**S(2) + b)/sqrt(a - b*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(-a/x**S(2) + b)/sqrt(a - b*x**S(2)), x), x, x*sqrt(-a/x**S(2) + b)*log(x)/sqrt(a - b*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(-a/x**S(2) + b)/(x*sqrt(a - b*x**S(2))), x), x, -sqrt(-a/x**S(2) + b)/sqrt(a - b*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(-a/x**S(2) + b)/(x**S(2)*sqrt(a - b*x**S(2))), x), x, -sqrt(-a/x**S(2) + b)/(S(2)*x*sqrt(a - b*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c + d*x)**(S(3)/2)/sqrt(a + b/x**S(2)), x), x, -2*sqrt(b)*c*sqrt(a*(c + d*x)/(a*c - sqrt(b)*d*sqrt(-a)))*(a*c**2 + b*d**2)*sqrt(a*x**2/b + 1)*EllipticF(asin(sqrt(2)*sqrt(1 - x*sqrt(-a)/sqrt(b))/2), -2*sqrt(b)*d*sqrt(-a)/(a*c - sqrt(b)*d*sqrt(-a)))/(5*d*x*(-a)**(3/2)*sqrt(a + b/x**2)*sqrt(c + d*x)) + 2*sqrt(b)*sqrt(c + d*x)*(a*c**2 - 3*b*d**2)*sqrt(a*x**2/b + 1)*EllipticE(asin(sqrt(2)*sqrt(1 - x*sqrt(-a)/sqrt(b))/2), -2*sqrt(b)*d*sqrt(-a)/(a*c - sqrt(b)*d*sqrt(-a)))/(5*d*x*(-a)**(3/2)*sqrt(a*(c + d*x)/(a*c - sqrt(b)*d*sqrt(-a)))*sqrt(a + b/x**2)) + 2*c*sqrt(c + d*x)*(a*x**2 + b)/(5*a*x*sqrt(a + b/x**2)) + 2*(c + d*x)**(3/2)*(a*x**2 + b)/(5*a*x*sqrt(a + b/x**2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2))**(S(5)/2)/sqrt(a**S(2) - b**S(2)*x**S(4)), x), x, S(19)*a**S(2)*sqrt(a - b*x**S(2))*sqrt(a + b*x**S(2))*atan(sqrt(b)*x/sqrt(a - b*x**S(2)))/(S(8)*sqrt(b)*sqrt(a**S(2) - b**S(2)*x**S(4))) - S(9)*a*x*(a - b*x**S(2))*sqrt(a + b*x**S(2))/(S(8)*sqrt(a**S(2) - b**S(2)*x**S(4))) - x*(a - b*x**S(2))*(a + b*x**S(2))**(S(3)/2)/(S(4)*sqrt(a**S(2) - b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2))**(S(3)/2)/sqrt(a**S(2) - b**S(2)*x**S(4)), x), x, S(3)*a*sqrt(a - b*x**S(2))*sqrt(a + b*x**S(2))*atan(sqrt(b)*x/sqrt(a - b*x**S(2)))/(S(2)*sqrt(b)*sqrt(a**S(2) - b**S(2)*x**S(4))) - x*(a - b*x**S(2))*sqrt(a + b*x**S(2))/(S(2)*sqrt(a**S(2) - b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + b*x**S(2))/sqrt(a**S(2) - b**S(2)*x**S(4)), x), x, sqrt(a - b*x**S(2))*sqrt(a + b*x**S(2))*atan(sqrt(b)*x/sqrt(a - b*x**S(2)))/(sqrt(b)*sqrt(a**S(2) - b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(a + b*x**S(2))*sqrt(a**S(2) - b**S(2)*x**S(4))), x), x, sqrt(S(2))*sqrt(a - b*x**S(2))*sqrt(a + b*x**S(2))*atan(sqrt(S(2))*sqrt(b)*x/sqrt(a - b*x**S(2)))/(S(2)*a*sqrt(b)*sqrt(a**S(2) - b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((a + b*x**S(2))**(S(3)/2)*sqrt(a**S(2) - b**S(2)*x**S(4))), x), x, x*(a - b*x**S(2))/(S(4)*a**S(2)*sqrt(a + b*x**S(2))*sqrt(a**S(2) - b**S(2)*x**S(4))) + S(3)*sqrt(S(2))*sqrt(a - b*x**S(2))*sqrt(a + b*x**S(2))*atan(sqrt(S(2))*sqrt(b)*x/sqrt(a - b*x**S(2)))/(S(8)*a**S(2)*sqrt(b)*sqrt(a**S(2) - b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((a + b*x**S(2))**(S(5)/2)*sqrt(a**S(2) - b**S(2)*x**S(4))), x), x, x*(a - b*x**S(2))/(S(8)*a**S(2)*(a + b*x**S(2))**(S(3)/2)*sqrt(a**S(2) - b**S(2)*x**S(4))) + S(9)*x*(a - b*x**S(2))/(S(32)*a**S(3)*sqrt(a + b*x**S(2))*sqrt(a**S(2) - b**S(2)*x**S(4))) + S(19)*sqrt(S(2))*sqrt(a - b*x**S(2))*sqrt(a + b*x**S(2))*atan(sqrt(S(2))*sqrt(b)*x/sqrt(a - b*x**S(2)))/(S(64)*a**S(3)*sqrt(b)*sqrt(a**S(2) - b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a - b*x**S(2))**(S(5)/2)/sqrt(a**S(2) - b**S(2)*x**S(4)), x), x, S(19)*a**S(2)*sqrt(a - b*x**S(2))*sqrt(a + b*x**S(2))*atanh(sqrt(b)*x/sqrt(a + b*x**S(2)))/(S(8)*sqrt(b)*sqrt(a**S(2) - b**S(2)*x**S(4))) - S(9)*a*x*sqrt(a - b*x**S(2))*(a + b*x**S(2))/(S(8)*sqrt(a**S(2) - b**S(2)*x**S(4))) - x*(a - b*x**S(2))**(S(3)/2)*(a + b*x**S(2))/(S(4)*sqrt(a**S(2) - b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a - b*x**S(2))**(S(3)/2)/sqrt(a**S(2) - b**S(2)*x**S(4)), x), x, S(3)*a*sqrt(a - b*x**S(2))*sqrt(a + b*x**S(2))*atanh(sqrt(b)*x/sqrt(a + b*x**S(2)))/(S(2)*sqrt(b)*sqrt(a**S(2) - b**S(2)*x**S(4))) - x*sqrt(a - b*x**S(2))*(a + b*x**S(2))/(S(2)*sqrt(a**S(2) - b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a - b*x**S(2))/sqrt(a**S(2) - b**S(2)*x**S(4)), x), x, sqrt(a - b*x**S(2))*sqrt(a + b*x**S(2))*atanh(sqrt(b)*x/sqrt(a + b*x**S(2)))/(sqrt(b)*sqrt(a**S(2) - b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(a - b*x**S(2))*sqrt(a**S(2) - b**S(2)*x**S(4))), x), x, sqrt(S(2))*sqrt(a - b*x**S(2))*sqrt(a + b*x**S(2))*atanh(sqrt(S(2))*sqrt(b)*x/sqrt(a + b*x**S(2)))/(S(2)*a*sqrt(b)*sqrt(a**S(2) - b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((a - b*x**S(2))**(S(3)/2)*sqrt(a**S(2) - b**S(2)*x**S(4))), x), x, x*(a + b*x**S(2))/(S(4)*a**S(2)*sqrt(a - b*x**S(2))*sqrt(a**S(2) - b**S(2)*x**S(4))) + S(3)*sqrt(S(2))*sqrt(a - b*x**S(2))*sqrt(a + b*x**S(2))*atanh(sqrt(S(2))*sqrt(b)*x/sqrt(a + b*x**S(2)))/(S(8)*a**S(2)*sqrt(b)*sqrt(a**S(2) - b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((a - b*x**S(2))**(S(5)/2)*sqrt(a**S(2) - b**S(2)*x**S(4))), x), x, x*(a + b*x**S(2))/(S(8)*a**S(2)*(a - b*x**S(2))**(S(3)/2)*sqrt(a**S(2) - b**S(2)*x**S(4))) + S(9)*x*(a + b*x**S(2))/(S(32)*a**S(3)*sqrt(a - b*x**S(2))*sqrt(a**S(2) - b**S(2)*x**S(4))) + S(19)*sqrt(S(2))*sqrt(a - b*x**S(2))*sqrt(a + b*x**S(2))*atanh(sqrt(S(2))*sqrt(b)*x/sqrt(a + b*x**S(2)))/(S(64)*a**S(3)*sqrt(b)*sqrt(a**S(2) - b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x**S(2)/(x**S(2) + S(-1)))/(x**S(2) + S(1)), x), x, sqrt(S(2))*sqrt(-x**S(2)/(-x**S(2) + S(1)))*sqrt(x**S(2) + S(-1))*atan(sqrt(S(2))*sqrt(x**S(2) + S(-1))/S(2))/(S(2)*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x**S(2)/(a + x**S(2)*(a + S(1)) + S(-1)))/(x**S(2) + S(1)), x), x, sqrt(S(2))*sqrt(-x**S(2)/(-a - x**S(2)*(a + S(1)) + S(1)))*sqrt(a + x**S(2)*(a + S(1)) + S(-1))*atan(sqrt(S(2))*sqrt(a + x**S(2)*(a + S(1)) + S(-1))/S(2))/(S(2)*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(((x + S(1))*(x**S(2) + S(-1)))**(S(-2)/3), x), x, (S(3)*x**S(2)/S(2) + S(-3)/2)/((-x + S(-1))*(-x**S(2) + S(1)))**(S(2)/3), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(((x + S(1))*(x**S(2) + S(-1)))**(S(-2)/3), x), x, (x + S(1))*(S(3)*x/S(2) + S(-3)/2)/(x**S(3) + x**S(2) - x + S(-1))**(S(2)/3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) + S(-1))/(sqrt(x*(x**S(2) + S(1)))*(x**S(2) + S(1))), x), x, -S(2)*x/sqrt(x*(x**S(2) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) + S(-1))/((x**S(2) + S(1))*sqrt(x**S(3) + x)), x), x, -S(2)*x/sqrt(x**S(3) + x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt((x**S(2) + S(-1))**S(2)/(x*(x**S(2) + S(1))))/(x**S(2) + S(1)), x), x, S(2)*x*sqrt((-x**S(2) + S(1))**S(2)/(x*(x**S(2) + S(1))))/(-x**S(2) + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt((x**S(2) + S(-1))**S(2)/(x**S(3) + x))/(x**S(2) + S(1)), x), x, S(2)*x*sqrt((-x**S(2) + S(1))**S(2)/(x**S(3) + x))/(-x**S(2) + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(a + b/x**S(2))*sqrt(c + d*x**S(2))), x), x, sqrt(a*x**S(2) + b)*atanh(sqrt(d)*sqrt(a*x**S(2) + b)/(sqrt(a)*sqrt(c + d*x**S(2))))/(sqrt(a)*sqrt(d)*x*sqrt(a + b/x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x**S(4) - S(2)*x**S(2))/((x**S(2) + S(-1))*(x**S(2) + S(2))), x), x, S(2)*sqrt(x**S(4) - S(2)*x**S(2))*atan(sqrt(x**S(2) + S(-2))/S(2))/(S(3)*x*sqrt(x**S(2) + S(-2))) - sqrt(x**S(4) - S(2)*x**S(2))*atan(sqrt(x**S(2) + S(-2)))/(S(3)*x*sqrt(x**S(2) + S(-2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(S(1) - S(1)/(x**S(2) + S(-1))**S(2))/(-x**S(2) + S(2)), x), x, sqrt(S(1) - S(1)/(-x**S(2) + S(1))**S(2))*(-x**S(2) + S(1))*atan(sqrt(x**S(2) + S(-2)))/(x*sqrt(x**S(2) + S(-2))), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(sqrt(S(1) - S(1)/(x**S(2) + S(-1))**S(2))/(-x**S(2) + S(2)), x), x, sqrt(S(1) - S(1)/(-x**S(2) + S(1))**S(2))*(-x**S(2) + S(1))*sqrt(x**S(4) - S(2)*x**S(2))*atan(sqrt(x**S(2) + S(-2)))/(x*sqrt(x**S(2) + S(-2))*sqrt((x**S(2) + S(-1))**S(2) + S(-1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt((x**S(4) - S(2)*x**S(2))/(x**S(2) + S(-1))**S(2))/(x**S(2) + S(2)), x), x, sqrt((x**S(4) - S(2)*x**S(2))/(-x**S(2) + S(1))**S(2))*(-x**S(2)/S(3) + S(1)/3)*atan(sqrt(x**S(2) + S(-2)))/(x*sqrt(x**S(2) + S(-2))) + sqrt((x**S(4) - S(2)*x**S(2))/(-x**S(2) + S(1))**S(2))*(S(2)*x**S(2)/S(3) + S(-2)/3)*atan(sqrt(x**S(2) + S(-2))/S(2))/(x*sqrt(x**S(2) + S(-2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x/(x**S(2) + S(1)) + S(1))**(S(5)/2), x), x, -(-x/S(3) + S(1)/3)*(x + S(1))**S(3)*sqrt(S(2)*x/(x**S(2) + S(1)) + S(1))/(x**S(2) + S(1)) + (x + S(1))*(S(8)*x/S(3) + S(-4)/3)*sqrt(S(2)*x/(x**S(2) + S(1)) + S(1)) - (S(3)*x + S(4))*(x**S(2) + S(1))*sqrt(S(2)*x/(x**S(2) + S(1)) + S(1))/(x + S(1)) + S(5)*sqrt(x**S(2) + S(1))*sqrt(S(2)*x/(x**S(2) + S(1)) + S(1))*asinh(x)/(x + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x/(x**S(2) + S(1)) + S(1))**(S(3)/2), x), x, -x*(x**S(2) + S(1))*sqrt(S(2)*x/(x**S(2) + S(1)) + S(1))/(x + S(1)) + (x + S(-1))*(x + S(1))*sqrt(S(2)*x/(x**S(2) + S(1)) + S(1)) + S(3)*sqrt(x**S(2) + S(1))*sqrt(S(2)*x/(x**S(2) + S(1)) + S(1))*asinh(x)/(x + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(S(2)*x/(x**S(2) + S(1)) + S(1)), x), x, sqrt(x**S(2) + S(1))*sqrt(S(2)*x/(x**S(2) + S(1)) + S(1))*asinh(x)/(x + S(1)) + (x**S(2) + S(1))*sqrt(S(2)*x/(x**S(2) + S(1)) + S(1))/(x + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(2)*x/(x**S(2) + S(1)) + S(1)), x), x, (x + S(1))/sqrt(S(2)*x/(x**S(2) + S(1)) + S(1)) - (x + S(1))*asinh(x)/(sqrt(x**S(2) + S(1))*sqrt(S(2)*x/(x**S(2) + S(1)) + S(1))) - sqrt(S(2))*(x + S(1))*atanh(sqrt(S(2))*(-x + S(1))/(S(2)*sqrt(x**S(2) + S(1))))/(sqrt(x**S(2) + S(1))*sqrt(S(2)*x/(x**S(2) + S(1)) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x/(x**S(2) + S(1)) + S(1))**(S(-3)/2), x), x, (S(3)*x/S(2) + S(3))/sqrt(S(2)*x/(x**S(2) + S(1)) + S(1)) - (S(3)*x + S(3))*asinh(x)/(sqrt(x**S(2) + S(1))*sqrt(S(2)*x/(x**S(2) + S(1)) + S(1))) - sqrt(S(2))*(S(9)*x/S(2) + S(9)/2)*atanh(sqrt(S(2))*(-x + S(1))/(S(2)*sqrt(x**S(2) + S(1))))/(S(2)*sqrt(x**S(2) + S(1))*sqrt(S(2)*x/(x**S(2) + S(1)) + S(1))) + (-x**S(2)/S(2) + S(-1)/2)/((x + S(1))*sqrt(S(2)*x/(x**S(2) + S(1)) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(S(2)*x/(x**S(2) + S(1)) + S(1))/(x**S(2) + S(1)), x), x, (x + S(-1))*sqrt(S(2)*x/(x**S(2) + S(1)) + S(1))/(x + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(c/(a + b*x**S(2)))**(S(3)/2), x), x, -c*x*sqrt(c/(a + b*x**S(2)))/b + c*sqrt(c/(a + b*x**S(2)))*sqrt(a + b*x**S(2))*atanh(sqrt(b)*x/sqrt(a + b*x**S(2)))/b**(S(3)/2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(c/(a + b*x**S(2)))**(S(3)/2), x), x, -c*sqrt(c/(a + b*x**S(2)))/b, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c/(a + b*x**S(2)))**(S(3)/2), x), x, c*x*sqrt(c/(a + b*x**S(2)))/a, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c/(a + b*x**S(2)))**(S(3)/2)/x, x), x, c*sqrt(c/(a + b*x**S(2)))/a - c*sqrt(c/(a + b*x**S(2)))*sqrt(a + b*x**S(2))*atanh(sqrt(a + b*x**S(2))/sqrt(a))/a**(S(3)/2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c/(a + b*x**S(2)))**(S(3)/2)/x**S(2), x), x, -c*sqrt(c/(a + b*x**S(2)))/(a*x) - S(2)*b*c*x*sqrt(c/(a + b*x**S(2)))/a**S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c/(a + b*x**S(2)))**(S(3)/2)/x**S(3), x), x, c*sqrt(c/(a + b*x**S(2)))/(a*x**S(2)) - S(3)*c*sqrt(c/(a + b*x**S(2)))*(a + b*x**S(2))/(S(2)*a**S(2)*x**S(2)) + S(3)*b*c*sqrt(c/(a + b*x**S(2)))*sqrt(a + b*x**S(2))*atanh(sqrt(a + b*x**S(2))/sqrt(a))/(S(2)*a**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(c*(a + b*x**S(2))**S(3))**(S(3)/2), x), x, -S(21)*a**S(6)*c*sqrt(c*(a + b*x**S(2))**S(3))*atanh(sqrt(b)*x/sqrt(a + b*x**S(2)))/(S(1024)*b**(S(3)/2)*(a + b*x**S(2))**(S(3)/2)) + S(21)*a**S(5)*c*x*sqrt(c*(a + b*x**S(2))**S(3))/(S(1024)*b*(a + b*x**S(2))) + S(21)*a**S(4)*c*x**S(3)*sqrt(c*(a + b*x**S(2))**S(3))/(S(512)*(a + b*x**S(2))) + S(7)*a**S(3)*c*x**S(3)*sqrt(c*(a + b*x**S(2))**S(3))/S(128) + S(21)*a**S(2)*c*x**S(3)*sqrt(c*(a + b*x**S(2))**S(3))*(a + b*x**S(2))/S(320) + S(3)*a*c*x**S(3)*sqrt(c*(a + b*x**S(2))**S(3))*(a + b*x**S(2))**S(2)/S(40) + c*x**S(3)*sqrt(c*(a + b*x**S(2))**S(3))*(a + b*x**S(2))**S(3)/S(12), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(c*(a + b*x**S(2))**S(3))**(S(3)/2), x), x, c*sqrt(c*(a + b*x**S(2))**S(3))*(a + b*x**S(2))**S(4)/(S(11)*b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*(a + b*x**S(2))**S(3))**(S(3)/2), x), x, S(63)*a**S(5)*c*sqrt(c*(a + b*x**S(2))**S(3))*atanh(sqrt(b)*x/sqrt(a + b*x**S(2)))/(S(256)*sqrt(b)*(a + b*x**S(2))**(S(3)/2)) + S(63)*a**S(4)*c*x*sqrt(c*(a + b*x**S(2))**S(3))/(S(256)*(a + b*x**S(2))) + S(21)*a**S(3)*c*x*sqrt(c*(a + b*x**S(2))**S(3))/S(128) + S(21)*a**S(2)*c*x*sqrt(c*(a + b*x**S(2))**S(3))*(a + b*x**S(2))/S(160) + S(9)*a*c*x*sqrt(c*(a + b*x**S(2))**S(3))*(a + b*x**S(2))**S(2)/S(80) + c*x*sqrt(c*(a + b*x**S(2))**S(3))*(a + b*x**S(2))**S(3)/S(10), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*(a + b*x**S(2))**S(3))**(S(3)/2)/x, x), x, -a**(S(9)/2)*c*sqrt(c*(a + b*x**S(2))**S(3))*atanh(sqrt(a + b*x**S(2))/sqrt(a))/(a + b*x**S(2))**(S(3)/2) + a**S(4)*c*sqrt(c*(a + b*x**S(2))**S(3))/(a + b*x**S(2)) + a**S(3)*c*sqrt(c*(a + b*x**S(2))**S(3))/S(3) + a**S(2)*c*sqrt(c*(a + b*x**S(2))**S(3))*(a + b*x**S(2))/S(5) + a*c*sqrt(c*(a + b*x**S(2))**S(3))*(a + b*x**S(2))**S(2)/S(7) + c*sqrt(c*(a + b*x**S(2))**S(3))*(a + b*x**S(2))**S(3)/S(9), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*(a + b*x**S(2))**S(3))**(S(3)/2)/x**S(2), x), x, S(315)*a**S(4)*sqrt(b)*c*sqrt(c*(a + b*x**S(2))**S(3))*atanh(sqrt(b)*x/sqrt(a + b*x**S(2)))/(S(128)*(a + b*x**S(2))**(S(3)/2)) + S(315)*a**S(3)*b*c*x*sqrt(c*(a + b*x**S(2))**S(3))/(S(128)*(a + b*x**S(2))) + S(105)*a**S(2)*b*c*x*sqrt(c*(a + b*x**S(2))**S(3))/S(64) + S(21)*a*b*c*x*sqrt(c*(a + b*x**S(2))**S(3))*(a + b*x**S(2))/S(16) + S(9)*b*c*x*sqrt(c*(a + b*x**S(2))**S(3))*(a + b*x**S(2))**S(2)/S(8) - c*sqrt(c*(a + b*x**S(2))**S(3))*(a + b*x**S(2))**S(3)/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c*(a + b*x**S(2))**S(3))**(S(3)/2)/x**S(3), x), x, -S(9)*a**(S(7)/2)*b*c*sqrt(c*(a + b*x**S(2))**S(3))*atanh(sqrt(a + b*x**S(2))/sqrt(a))/(S(2)*(a + b*x**S(2))**(S(3)/2)) + S(9)*a**S(3)*b*c*sqrt(c*(a + b*x**S(2))**S(3))/(S(2)*(a + b*x**S(2))) + S(3)*a**S(2)*b*c*sqrt(c*(a + b*x**S(2))**S(3))/S(2) + S(9)*a*b*c*sqrt(c*(a + b*x**S(2))**S(3))*(a + b*x**S(2))/S(10) + S(9)*b*c*sqrt(c*(a + b*x**S(2))**S(3))*(a + b*x**S(2))**S(2)/S(14) - c*sqrt(c*(a + b*x**S(2))**S(3))*(a + b*x**S(2))**S(3)/(S(2)*x**S(2)), expand=True, _diff=True, _numerical=True)
| 330.077743
| 3,421
| 0.471252
|
7951e8642b30faa0308ce92775099bd2849ec534
| 12,604
|
py
|
Python
|
aws_logging_handlers/S3/__init__.py
|
pagliaccl/aws_logging_handlers
|
930966a61bfa2ba4b856fc6d45e88bff6d56e6db
|
[
"MIT"
] | null | null | null |
aws_logging_handlers/S3/__init__.py
|
pagliaccl/aws_logging_handlers
|
930966a61bfa2ba4b856fc6d45e88bff6d56e6db
|
[
"MIT"
] | null | null | null |
aws_logging_handlers/S3/__init__.py
|
pagliaccl/aws_logging_handlers
|
930966a61bfa2ba4b856fc6d45e88bff6d56e6db
|
[
"MIT"
] | null | null | null |
"""
S3 Binding Module with logging handler and stream object
"""
__author__ = 'Omri Eival'
import atexit
import signal
import threading
import queue
import gzip
import codecs
from logging import StreamHandler
from io import BufferedIOBase, BytesIO
from boto3 import Session
from datetime import datetime
from aws_logging_handlers.validation import is_non_empty_string, is_positive_int, empty_str_err, bad_integer_err, ValidationRule
from aws_logging_handlers.tasks import Task, task_worker, STOP_SIGNAL
DEFAULT_CHUNK_SIZE = 5 * 1024 ** 2 # 5 MB
DEFAULT_ROTATION_TIME_SECS = 12 * 60 * 60 # 12 hours
MAX_FILE_SIZE_BYTES = 100 * 1024 ** 2 # 100 MB
MIN_WORKERS_NUM = 1
class StreamObject:
"""
Class representation of the AWS s3 object along with all the needed metadata to stream to s3
"""
def __init__(self, s3_resource, bucket_name, filename, buffer_queue):
self.object = s3_resource.Object(bucket_name, filename)
self.uploader = self.object.initiate_multipart_upload()
self.bucket = bucket_name
try:
total_bytes = s3_resource.meta.client.head_object(Bucket=self.bucket.name, Key=filename)
except Exception:
total_bytes = 0
self.buffer = BytesIO()
self.chunk_count = 0
self.byte_count = total_bytes
self.parts = []
self.tasks = buffer_queue
def add_task(self, task):
"""
Add a task to the tasks queue
:param task: Task object
:return:
"""
self.tasks.put(task)
def join_tasks(self):
"""
Join all the tasks
:return:
"""
self.tasks.join()
class S3Stream(BufferedIOBase):
"""
stream interface used by the handler
"""
_stream_buffer_queue = queue.Queue()
_rotation_queue = queue.Queue()
def __init__(self, bucket: str, key: str, *, chunk_size: int = DEFAULT_CHUNK_SIZE,
max_file_log_time: int = DEFAULT_ROTATION_TIME_SECS, max_file_size_bytes: int = MAX_FILE_SIZE_BYTES,
encoder: str = 'utf-8', workers: int = 1, compress: bool = False, **boto_session_kwargs):
"""
:param bucket: name of the s3 bucket
:type bucket: str
:param key: s3 key path
:type key: str
:param chunk_size: size of multipart upload chunk size (default 5MB)
:type chunk_size: int
:param max_file_log_time: threshold period for a log period until file rotation (default 12 Hours)
:type max_file_log_time: int
:param max_file_size_bytes: threshold for file rotation by bytes (default 100MB)
:type max_file_size_bytes: int
:param encoder: the encoder to be used for log records (default 'utf-8')
:type encoder: str
:param workers: the number of background workers that rotate log records (default 1)
:type workers: int
:param compress: flag indication for archiving the content of a file
:type compress: bool
:param boto_session_kwargs: additional keyword arguments for the AWS Kinesis Resource
:type boto_session_kwargs: boto3 resource keyword arguments
"""
self._session = Session()
self.s3 = self._session.resource('s3', **boto_session_kwargs)
self.start_time = int(datetime.utcnow().strftime('%s'))
self.key = key
self.chunk_size = chunk_size
self.max_file_log_time = max_file_log_time
self.max_file_size_bytes = max_file_size_bytes
self.current_file_name = "{}_{}".format(key, int(datetime.utcnow().strftime('%s')))
if compress:
self.current_file_name = "{}.gz".format(self.current_file_name)
self.encoder = encoder
self.bucket = bucket
self._current_object = self._get_stream_object(self.current_file_name)
self.workers = [threading.Thread(target=task_worker, args=(self._rotation_queue,), daemon=True).start() for _ in
range(int(max(workers, MIN_WORKERS_NUM) / 2) + 1)]
self._stream_bg_workers = [threading.Thread(target=task_worker, args=(self._stream_buffer_queue,), daemon=True).start() for _
in range(max(int(max(workers, MIN_WORKERS_NUM) / 2), 1))]
self._is_open = True
self.compress = compress
BufferedIOBase.__init__(self)
@property
def bucket(self):
return self._bucket
@bucket.setter
def bucket(self, val):
if not val:
raise ValueError("Bucket name is invalid")
try:
self.s3.meta.client.head_bucket(Bucket=val)
except Exception:
raise ValueError('Bucket %s does not exist, or insufficient permissions' % val)
self._bucket = self.s3.Bucket(val)
@property
def key(self):
return self._key
@key.setter
def key(self, val):
if not val:
raise ValueError("Given key is invalid")
self._key = val.strip('/')
@property
def encoder(self):
return self._encoder
@encoder.setter
def encoder(self, val):
_ = codecs.getencoder(val)
self._encoder = val
def get_filename(self):
"""
returns a log file name
:return: name of the log file in s3
"""
filename = "{}_{}".format(self.key, self.start_time)
if not self.compress:
return filename
return "{}.gz".format(filename)
def _add_task(self, task):
self._rotation_queue.put(task)
def _join_tasks(self):
self._rotation_queue.join()
def _get_stream_object(self, filename):
try:
return StreamObject(self.s3, self.bucket.name, filename, self._stream_buffer_queue)
except Exception:
raise RuntimeError('Failed to open new S3 stream object')
def _rotate_chunk(self, run_async=True):
assert self._current_object, "Stream object not found"
part_num = self._current_object.chunk_count + 1
part = self._current_object.uploader.Part(part_num)
buffer = self._current_object.buffer
self._current_object.buffer = BytesIO()
buffer.seek(0)
if run_async:
self._current_object.add_task(Task(self._upload_part, self._current_object, part, part_num, buffer))
else:
self._upload_part(self._current_object, part, part_num, buffer)
self._current_object.chunk_count += 1
@staticmethod
def _upload_part(s3_object, part, part_num, buffer):
upload = part.upload(Body=buffer)
s3_object.parts.append({'ETag': upload['ETag'], 'PartNumber': part_num})
def _rotate_file(self):
if self._current_object.buffer.tell() > 0:
self._rotate_chunk()
temp_object = self._current_object
self._add_task(Task(self._close_stream, stream_object=temp_object))
self.start_time = int(datetime.utcnow().strftime('%s'))
new_filename = self.get_filename()
self._current_object = self._get_stream_object(new_filename)
@staticmethod
def _close_stream(stream_object, callback=None, *args, **kwargs):
stream_object.join_tasks()
if stream_object.chunk_count > 0:
stream_object.uploader.complete(MultipartUpload={'Parts': stream_object.parts})
else:
stream_object.uploader.abort()
if callback and callable(callback):
callback(*args, **kwargs)
def close(self, *args, **kwargs):
"""
close the stream for writing, upload remaining log records in stream
:param args:
:param kwargs:
:return:
"""
if self._current_object.buffer.tell() > 0:
self._rotate_chunk(run_async=False)
self._current_object.join_tasks()
self._join_tasks()
self._close_stream(self._current_object)
# Stop the worker threads
for _ in range(len(self.workers)):
self._rotation_queue.put(STOP_SIGNAL)
for _ in range(len(self._stream_bg_workers)):
self._stream_buffer_queue.put(STOP_SIGNAL)
self._is_open = False
@property
def closed(self):
return not self._is_open
@property
def writable(self, *args, **kwargs):
return True
def tell(self, *args, **kwargs):
"""
indication of current size of the stream before rotation
:param args:
:param kwargs:
:return: size of the current stream
"""
return self._current_object.byte_count
def write(self, *args, **kwargs):
"""
writes a log record to the stream
:param args:
:param kwargs:
:return: size of record that was written
"""
s = self.compress and gzip.compress(args[0].encode(self.encoder)) or args[0].encode(self.encoder)
self._current_object.buffer.write(s)
self._current_object.byte_count = self._current_object.byte_count + len(s)
return len(s)
def flush(self, *args, **kwargs):
"""
flushes the current stream if it exceeds the threshold size
:return:
"""
if self._current_object.buffer.tell() > self.chunk_size:
self._rotate_chunk()
if (self.max_file_size_bytes and self._current_object.byte_count > self.max_file_size_bytes) or (
self.max_file_log_time and int(
datetime.utcnow().strftime('%s')) - self.start_time > self.max_file_log_time):
self._rotate_file()
class S3Handler(StreamHandler):
"""
A Logging handler class that streams log records to S3 by chunks
"""
def __init__(self, key: str, bucket: str, *, chunk_size: int = DEFAULT_CHUNK_SIZE,
time_rotation: int = DEFAULT_ROTATION_TIME_SECS, max_file_size_bytes: int = MAX_FILE_SIZE_BYTES,
encoder: str = 'utf-8',
max_threads: int = 1, compress: bool = False, **boto_session_kwargs):
"""
:param key: The path of the S3 object
:type key: str
:param bucket: The id of the S3 bucket
:type bucket: str
:param chunk_size: size of a chunk in the multipart upload in bytes (default 5MB)
:type chunk_size: int
:param time_rotation: Interval in seconds to rotate the file by (default 12 hours)
:type time_rotation: int
:param max_file_size_bytes: maximum file size in bytes before rotation (default 100MB)
:type max_file_size_bytes: int
:param encoder: default utf-8
:type encoder: str
:param max_threads: the number of threads that a stream handler would run for file and chunk rotation tasks,
only useful if emitting lot's of records
:type max_threads: int
:param compress: indicating weather to save a compressed gz suffixed file
:type compress: bool
"""
args_validation = (
ValidationRule(time_rotation, is_positive_int, bad_integer_err('time_rotation')),
ValidationRule(max_file_size_bytes, is_positive_int, bad_integer_err('max_file_size_bytes')),
ValidationRule(encoder, is_non_empty_string, empty_str_err('encoder')),
ValidationRule(max_threads, is_positive_int, bad_integer_err('thread_count')),
)
for rule in args_validation:
assert rule.func(rule.arg), rule.message
self.bucket = bucket
self.stream = S3Stream(self.bucket, key, chunk_size=chunk_size, max_file_log_time=time_rotation,
max_file_size_bytes=max_file_size_bytes, encoder=encoder, workers=max_threads,
compress=compress, **boto_session_kwargs)
# Make sure we gracefully clear the buffers and upload the missing parts before exiting
signal.signal(signal.SIGTERM, self._teardown)
signal.signal(signal.SIGINT, self._teardown)
signal.signal(signal.SIGQUIT, self._teardown)
atexit.register(self.close)
StreamHandler.__init__(self, self.stream)
def _teardown(self, _: int, __):
return self.close()
def close(self, *args, **kwargs):
"""
Closes the stream
"""
self.acquire()
try:
if self.stream:
try:
self.flush()
finally:
stream = self.stream
self.stream = None
if hasattr(stream, "close"):
stream.close(*args, **kwargs)
finally:
self.release()
| 35.011111
| 133
| 0.634481
|
7951e8ab2206bb904e00683a4ed5a2aae4d8efd2
| 25,611
|
py
|
Python
|
usaspending_api/awards/v2/data_layer/orm.py
|
g4brielvs/usaspending-api
|
bae7da2c204937ec1cdf75c052405b13145728d5
|
[
"CC0-1.0"
] | 1
|
2022-01-28T16:08:04.000Z
|
2022-01-28T16:08:04.000Z
|
usaspending_api/awards/v2/data_layer/orm.py
|
g4brielvs/usaspending-api
|
bae7da2c204937ec1cdf75c052405b13145728d5
|
[
"CC0-1.0"
] | null | null | null |
usaspending_api/awards/v2/data_layer/orm.py
|
g4brielvs/usaspending-api
|
bae7da2c204937ec1cdf75c052405b13145728d5
|
[
"CC0-1.0"
] | null | null | null |
import copy
import logging
from collections import OrderedDict
from decimal import Decimal
from django.db.models import Sum, F, Subquery
from typing import Optional
from usaspending_api.awards.models import (
Award,
FinancialAccountsByAwards,
ParentAward,
TransactionFABS,
TransactionFPDS,
TransactionNormalized,
)
from usaspending_api.awards.v2.data_layer.orm_mappers import (
FABS_ASSISTANCE_FIELDS,
FABS_AWARD_FIELDS,
FPDS_AWARD_FIELDS,
FPDS_CONTRACT_FIELDS,
)
from usaspending_api.awards.v2.data_layer.orm_utils import delete_keys_from_dict, split_mapper_into_qs
from usaspending_api.common.helpers.business_categories_helper import get_business_category_display_names
from usaspending_api.common.helpers.data_constants import state_code_from_name, state_name_from_code
from usaspending_api.common.helpers.date_helper import get_date_from_datetime
from usaspending_api.common.helpers.sql_helpers import execute_sql_to_ordered_dictionary
from usaspending_api.common.recipient_lookups import obtain_recipient_uri
from usaspending_api.references.models import Agency, Cfda, PSC, NAICS, SubtierAgency, DisasterEmergencyFundCode
from usaspending_api.submissions.models import SubmissionAttributes
from usaspending_api.awards.v2.data_layer.sql import defc_sql
logger = logging.getLogger("console")
def construct_assistance_response(requested_award_dict: dict) -> OrderedDict:
"""Build an Assistance Award summary object to send as an API response"""
response = OrderedDict()
award = fetch_award_details(requested_award_dict, FABS_AWARD_FIELDS)
if not award:
return None
response.update(award)
account_data = fetch_account_details_award(award["id"])
response.update(account_data)
transaction = fetch_fabs_details_by_pk(award["_trx"], FABS_ASSISTANCE_FIELDS)
response["record_type"] = transaction["record_type"]
response["cfda_info"] = fetch_all_cfda_details(award)
response["transaction_obligated_amount"] = fetch_transaction_obligated_amount_by_internal_award_id(award["id"])
response["funding_agency"] = fetch_agency_details(response["_funding_agency"])
if response["funding_agency"]:
response["funding_agency"]["office_agency_name"] = transaction["_funding_office_name"]
response["awarding_agency"] = fetch_agency_details(response["_awarding_agency"])
if response["awarding_agency"]:
response["awarding_agency"]["office_agency_name"] = transaction["_awarding_office_name"]
response["period_of_performance"] = OrderedDict(
[
("start_date", award["_start_date"]),
("end_date", award["_end_date"]),
("last_modified_date", get_date_from_datetime(transaction["_modified_at"])),
]
)
response["recipient"] = create_recipient_object(transaction)
response["executive_details"] = create_officers_object(award)
response["place_of_performance"] = create_place_of_performance_object(transaction)
return delete_keys_from_dict(response)
def construct_contract_response(requested_award_dict: dict) -> OrderedDict:
"""Build a Procurement Award summary object to send as an API response"""
response = OrderedDict()
award = fetch_award_details(requested_award_dict, FPDS_AWARD_FIELDS)
if not award:
return None
response.update(award)
account_data = fetch_account_details_award(award["id"])
response.update(account_data)
transaction = fetch_fpds_details_by_pk(award["_trx"], FPDS_CONTRACT_FIELDS)
response["parent_award"] = fetch_contract_parent_award_details(
award["_parent_award_piid"], award["_fpds_parent_agency_id"]
)
response["latest_transaction_contract_data"] = transaction
response["funding_agency"] = fetch_agency_details(response["_funding_agency"])
if response["funding_agency"]:
response["funding_agency"]["office_agency_name"] = transaction["_funding_office_name"]
response["awarding_agency"] = fetch_agency_details(response["_awarding_agency"])
if response["awarding_agency"]:
response["awarding_agency"]["office_agency_name"] = transaction["_awarding_office_name"]
response["period_of_performance"] = OrderedDict(
[
("start_date", award["_start_date"]),
("end_date", award["_end_date"]),
("last_modified_date", transaction["_last_modified"]),
("potential_end_date", transaction["_period_of_perf_potential_e"]),
]
)
response["recipient"] = create_recipient_object(transaction)
response["executive_details"] = create_officers_object(award)
response["place_of_performance"] = create_place_of_performance_object(transaction)
if transaction["product_or_service_code"]:
response["psc_hierarchy"] = fetch_psc_hierarchy(transaction["product_or_service_code"])
if transaction["naics"]:
response["naics_hierarchy"] = fetch_naics_hierarchy(transaction["naics"])
return delete_keys_from_dict(response)
def construct_idv_response(requested_award_dict: dict) -> OrderedDict:
"""Build a Procurement IDV summary object to send as an API response"""
idv_specific_award_fields = OrderedDict(
[
("period_of_performance_star", "_start_date"),
("last_modified", "_last_modified_date"),
("ordering_period_end_date", "_end_date"),
]
)
mapper = copy.deepcopy(FPDS_CONTRACT_FIELDS)
mapper.update(idv_specific_award_fields)
response = OrderedDict()
award = fetch_award_details(requested_award_dict, FPDS_AWARD_FIELDS)
if not award:
return None
response.update(award)
account_data = fetch_account_details_award(award["id"])
response.update(account_data)
transaction = fetch_fpds_details_by_pk(award["_trx"], mapper)
response["parent_award"] = fetch_idv_parent_award_details(award["generated_unique_award_id"])
response["latest_transaction_contract_data"] = transaction
response["funding_agency"] = fetch_agency_details(response["_funding_agency"])
if response["funding_agency"]:
response["funding_agency"]["office_agency_name"] = transaction["_funding_office_name"]
response["awarding_agency"] = fetch_agency_details(response["_awarding_agency"])
if response["awarding_agency"]:
response["awarding_agency"]["office_agency_name"] = transaction["_awarding_office_name"]
response["period_of_performance"] = OrderedDict(
[
("start_date", award["_start_date"]),
("end_date", transaction["_end_date"]),
("last_modified_date", transaction["_last_modified_date"]),
("potential_end_date", transaction["_period_of_perf_potential_e"]),
]
)
response["recipient"] = create_recipient_object(transaction)
response["executive_details"] = create_officers_object(award)
response["place_of_performance"] = create_place_of_performance_object(transaction)
if transaction["product_or_service_code"]:
response["psc_hierarchy"] = fetch_psc_hierarchy(transaction["product_or_service_code"])
if transaction["naics"]:
response["naics_hierarchy"] = fetch_naics_hierarchy(transaction["naics"])
return delete_keys_from_dict(response)
def create_recipient_object(db_row_dict: dict) -> OrderedDict:
return OrderedDict(
[
(
"recipient_hash",
obtain_recipient_uri(
db_row_dict["_recipient_name"],
db_row_dict["_recipient_unique_id"],
db_row_dict["_parent_recipient_unique_id"],
),
),
("recipient_name", db_row_dict["_recipient_name"]),
("recipient_unique_id", db_row_dict["_recipient_unique_id"]),
(
"parent_recipient_hash",
obtain_recipient_uri(
db_row_dict["_parent_recipient_name"],
db_row_dict["_parent_recipient_unique_id"],
None, # parent_recipient_unique_id
True, # is_parent_recipient
),
),
("parent_recipient_name", db_row_dict["_parent_recipient_name"]),
("parent_recipient_unique_id", db_row_dict["_parent_recipient_unique_id"]),
(
"business_categories",
get_business_category_display_names(
fetch_business_categories_by_transaction_id(db_row_dict["_transaction_id"])
),
),
(
"location",
OrderedDict(
[
("location_country_code", db_row_dict["_rl_location_country_code"]),
("country_name", db_row_dict["_rl_country_name"]),
("state_code", db_row_dict["_rl_state_code"]),
("state_name", db_row_dict["_rl_state_name"]),
("city_name", db_row_dict["_rl_city_name"] or db_row_dict.get("_rl_foreign_city")),
("county_code", db_row_dict["_rl_county_code"]),
("county_name", db_row_dict["_rl_county_name"]),
("address_line1", db_row_dict["_rl_address_line1"]),
("address_line2", db_row_dict["_rl_address_line2"]),
("address_line3", db_row_dict["_rl_address_line3"]),
("congressional_code", db_row_dict["_rl_congressional_code"]),
("zip4", db_row_dict.get("_rl_zip_last_4") or db_row_dict.get("_rl_zip4")),
("zip5", db_row_dict["_rl_zip5"]),
("foreign_postal_code", db_row_dict.get("_rl_foreign_postal_code")),
("foreign_province", db_row_dict.get("_rl_foreign_province")),
]
),
),
]
)
def create_place_of_performance_object(db_row_dict: dict) -> OrderedDict:
return OrderedDict(
[
("location_country_code", db_row_dict["_pop_location_country_code"]),
("country_name", db_row_dict["_pop_country_name"]),
("county_code", db_row_dict["_pop_county_code"]),
("county_name", db_row_dict["_pop_county_name"]),
("city_name", db_row_dict["_pop_city_name"]),
(
"state_code",
db_row_dict["_pop_state_code"]
if db_row_dict["_pop_state_code"]
else state_code_from_name(db_row_dict["_pop_state_name"]),
),
(
"state_name",
db_row_dict["_pop_state_name"]
if db_row_dict["_pop_state_name"]
else state_name_from_code(db_row_dict["_pop_state_code"]),
),
("congressional_code", db_row_dict["_pop_congressional_code"]),
("zip4", db_row_dict["_pop_zip4"]),
("zip5", db_row_dict["_pop_zip5"]),
("address_line1", None),
("address_line2", None),
("address_line3", None),
("foreign_province", db_row_dict.get("_pop_foreign_province")),
("foreign_postal_code", None),
]
)
def create_officers_object(award: dict) -> dict:
"""Construct the Executive Compensation Object"""
return {
"officers": [
{
"name": award.get("_officer_{}_name".format(officer_num)),
"amount": award.get("_officer_{}_amount".format(officer_num)),
}
for officer_num in range(1, 6)
]
}
def fetch_award_details(filter_q: dict, mapper_fields: OrderedDict) -> dict:
vals, ann = split_mapper_into_qs(mapper_fields)
return Award.objects.filter(**filter_q).values(*vals).annotate(**ann).first()
def fetch_contract_parent_award_details(parent_piid: str, parent_fpds_agency: str) -> Optional[OrderedDict]:
parent_guai = "CONT_IDV_{}_{}".format(parent_piid or "NONE", parent_fpds_agency or "NONE")
parent_award_ids = (
ParentAward.objects.filter(generated_unique_award_id=parent_guai)
.annotate(parent_award_award_id=F("award_id"), parent_award_guai=F("generated_unique_award_id"))
.values("parent_award_award_id", "parent_award_guai")
.first()
)
return _fetch_parent_award_details(parent_award_ids)
def fetch_idv_parent_award_details(guai: str) -> Optional[OrderedDict]:
parent_award_ids = (
ParentAward.objects.filter(generated_unique_award_id=guai, parent_award__isnull=False)
.annotate(
parent_award_award_id=F("parent_award__award_id"),
parent_award_guai=F("parent_award__generated_unique_award_id"),
)
.values("parent_award_award_id", "parent_award_guai")
.first()
)
return _fetch_parent_award_details(parent_award_ids)
def _fetch_parent_award_details(parent_award_ids: dict) -> Optional[OrderedDict]:
if not parent_award_ids:
return None
# These are not exact query paths but instead expected aliases to allow reuse
parent_award_award_id = parent_award_ids["parent_award_award_id"]
parent_award_guai = parent_award_ids["parent_award_guai"]
parent_award = (
Award.objects.filter(id=parent_award_award_id)
.values(
"latest_transaction__contract_data__agency_id",
"latest_transaction__contract_data__idv_type_description",
"latest_transaction__contract_data__multiple_or_single_aw_desc",
"latest_transaction__contract_data__piid",
"latest_transaction__contract_data__type_of_idc_description",
)
.first()
)
if not parent_award:
logging.debug("Unable to find award for award id %s" % parent_award_award_id)
return None
parent_sub_agency = (
SubtierAgency.objects.filter(subtier_code=parent_award["latest_transaction__contract_data__agency_id"])
.values("name", "subtier_agency_id")
.first()
)
parent_agency = (
(
Agency.objects.filter(
toptier_flag=True,
toptier_agency_id=Subquery(
Agency.objects.filter(
subtier_agency_id__isnull=False, subtier_agency_id=parent_sub_agency["subtier_agency_id"]
).values("toptier_agency_id")
),
)
.values("id", "toptier_agency__name")
.first()
)
if parent_sub_agency
else None
)
parent_object = OrderedDict(
[
("agency_id", parent_agency["id"] if parent_agency else None),
("agency_name", parent_agency["toptier_agency__name"] if parent_agency else None),
("sub_agency_id", parent_award["latest_transaction__contract_data__agency_id"]),
("sub_agency_name", parent_sub_agency["name"] if parent_sub_agency else None),
("award_id", parent_award_award_id),
("generated_unique_award_id", parent_award_guai),
("idv_type_description", parent_award["latest_transaction__contract_data__idv_type_description"]),
(
"multiple_or_single_aw_desc",
parent_award["latest_transaction__contract_data__multiple_or_single_aw_desc"],
),
("piid", parent_award["latest_transaction__contract_data__piid"]),
("type_of_idc_description", parent_award["latest_transaction__contract_data__type_of_idc_description"]),
]
)
return parent_object
def fetch_fabs_details_by_pk(primary_key: int, mapper: OrderedDict) -> dict:
vals, ann = split_mapper_into_qs(mapper)
return TransactionFABS.objects.filter(pk=primary_key).values(*vals).annotate(**ann).first()
def fetch_fpds_details_by_pk(primary_key: int, mapper: OrderedDict) -> dict:
vals, ann = split_mapper_into_qs(mapper)
return TransactionFPDS.objects.filter(pk=primary_key).values(*vals).annotate(**ann).first()
def fetch_latest_ec_details(award_id: int, mapper: OrderedDict, transaction_type: str) -> dict:
vals, ann = split_mapper_into_qs(mapper)
model = TransactionFPDS if transaction_type == "fpds" else TransactionFABS
retval = (
model.objects.filter(transaction__award_id=award_id, officer_1_name__isnull=False)
.values(*vals)
.annotate(**ann)
.order_by("-action_date")
)
return retval.first()
def agency_has_file_c_submission(agency_id):
return SubmissionAttributes.objects.filter(
toptier_code=Subquery(Agency.objects.filter(id=agency_id).values("toptier_agency__toptier_code")[:1])
).exists()
def fetch_agency_details(agency_id: int) -> Optional[dict]:
values = [
"toptier_agency__toptier_code",
"toptier_agency__name",
"toptier_agency__abbreviation",
"subtier_agency__subtier_code",
"subtier_agency__name",
"subtier_agency__abbreviation",
]
agency = Agency.objects.filter(pk=agency_id).values(*values).first()
agency_details = None
if agency:
agency_details = {
"id": agency_id,
"has_agency_page": agency_has_file_c_submission(agency_id),
"toptier_agency": {
"name": agency["toptier_agency__name"],
"code": agency["toptier_agency__toptier_code"],
"abbreviation": agency["toptier_agency__abbreviation"],
},
"subtier_agency": {
"name": agency["subtier_agency__name"],
"code": agency["subtier_agency__subtier_code"],
"abbreviation": agency["subtier_agency__abbreviation"],
},
}
return agency_details
def fetch_business_categories_by_transaction_id(transaction_id: int) -> list:
tn = TransactionNormalized.objects.filter(pk=transaction_id).values("business_categories").first()
if tn:
return tn["business_categories"]
return []
def normalize_cfda_number_format(fabs_transaction: dict) -> str:
"""Normalize a CFDA number to 6 digits by padding 0 in case the value was truncated"""
cfda_number = fabs_transaction.get("cfda_number")
if cfda_number and len(cfda_number) < 6:
cfda_number += "0" * (6 - len(cfda_number))
return cfda_number
def fetch_all_cfda_details(award: dict) -> list:
fabs_values = ["cfda_number", "federal_action_obligation", "non_federal_funding_amount", "total_funding_amount"]
queryset = TransactionFABS.objects.filter(transaction__award_id=award["id"]).values(*fabs_values)
cfda_dicts = {}
for transaction in queryset:
clean_cfda_number_str = normalize_cfda_number_format(transaction)
if cfda_dicts.get(clean_cfda_number_str):
cfda_dicts.update(
{
clean_cfda_number_str: {
"federal_action_obligation": cfda_dicts[clean_cfda_number_str]["federal_action_obligation"]
+ Decimal(transaction["federal_action_obligation"] or 0),
"non_federal_funding_amount": cfda_dicts[clean_cfda_number_str]["non_federal_funding_amount"]
+ Decimal(transaction["non_federal_funding_amount"] or 0),
"total_funding_amount": cfda_dicts[clean_cfda_number_str]["total_funding_amount"]
+ Decimal(transaction["total_funding_amount"] or 0),
}
}
)
else:
cfda_dicts.update(
{
clean_cfda_number_str: {
"federal_action_obligation": Decimal(transaction["federal_action_obligation"] or 0),
"non_federal_funding_amount": Decimal(transaction["non_federal_funding_amount"] or 0),
"total_funding_amount": Decimal(transaction["total_funding_amount"] or 0),
}
}
)
final_cfda_objects = []
for cfda_number in cfda_dicts.keys():
details = fetch_cfda_details_using_cfda_number(cfda_number)
if details.get("url") == "None;":
details.update({"url": None})
final_cfda_objects.append(
OrderedDict(
[
("applicant_eligibility", details.get("applicant_eligibility")),
("beneficiary_eligibility", details.get("beneficiary_eligibility")),
("cfda_federal_agency", details.get("federal_agency")),
("cfda_number", cfda_number),
("cfda_objectives", details.get("objectives")),
("cfda_obligations", details.get("obligations")),
("cfda_popular_name", details.get("popular_name")),
("cfda_title", details.get("program_title")),
("cfda_website", details.get("website_address")),
("federal_action_obligation_amount", cfda_dicts[cfda_number]["federal_action_obligation"]),
("non_federal_funding_amount", cfda_dicts[cfda_number]["non_federal_funding_amount"]),
("sam_website", details.get("url")),
("total_funding_amount", cfda_dicts[cfda_number]["total_funding_amount"]),
]
)
)
final_cfda_objects.sort(key=lambda cfda: cfda["total_funding_amount"], reverse=True)
return final_cfda_objects
def fetch_cfda_details_using_cfda_number(cfda: str) -> dict:
values = [
"applicant_eligibility",
"beneficiary_eligibility",
"program_title",
"objectives",
"federal_agency",
"website_address",
"url",
"obligations",
"popular_name",
]
cfda_details = Cfda.objects.filter(program_number=cfda).values(*values).first()
return cfda_details or {}
def fetch_transaction_obligated_amount_by_internal_award_id(internal_award_id: int) -> Optional[Decimal]:
_sum = FinancialAccountsByAwards.objects.filter(award_id=internal_award_id).aggregate(
Sum("transaction_obligated_amount")
)
if _sum:
return _sum["transaction_obligated_amount__sum"]
return None
def fetch_psc_hierarchy(psc_code: str) -> dict:
codes = [psc_code, psc_code[:2], psc_code[:1], psc_code[:3] if psc_code[0] == "A" else None]
toptier_code = {}
midtier_code = {}
subtier_code = {} # only used for R&D codes which start with "A"
base_code = {}
if psc_code[0].isalpha(): # we only want to look for the toptier code for services, which start with letters
try:
psc_top = PSC.objects.get(code=codes[2])
toptier_code = {"code": psc_top.code, "description": psc_top.description}
except PSC.DoesNotExist:
pass
try:
psc_mid = PSC.objects.get(code=codes[1])
midtier_code = {"code": psc_mid.code, "description": psc_mid.description}
except PSC.DoesNotExist:
pass
try:
psc = PSC.objects.get(code=codes[0])
base_code = {"code": psc.code, "description": psc.description}
except PSC.DoesNotExist:
pass
if codes[3] is not None: # don't bother looking for 3 digit codes unless they start with "A"
try:
psc_rd = PSC.objects.get(code=codes[3])
subtier_code = {"code": psc_rd.code, "description": psc_rd.description}
except PSC.DoesNotExist:
pass
results = {
"toptier_code": toptier_code,
"midtier_code": midtier_code,
"subtier_code": subtier_code,
"base_code": base_code,
}
return results
def fetch_naics_hierarchy(naics: str) -> dict:
codes = [naics, naics[:4], naics[:2]]
toptier_code = {}
midtier_code = {}
base_code = {}
try:
toptier = NAICS.objects.get(code=codes[2])
toptier_code = {"code": toptier.code, "description": toptier.description}
except NAICS.DoesNotExist:
pass
try:
midtier = NAICS.objects.get(code=codes[1])
midtier_code = {"code": midtier.code, "description": midtier.description}
except NAICS.DoesNotExist:
pass
try:
base = NAICS.objects.get(code=codes[0])
base_code = {"code": base.code, "description": base.description}
except NAICS.DoesNotExist:
pass
results = {"toptier_code": toptier_code, "midtier_code": midtier_code, "base_code": base_code}
return results
def fetch_account_details_award(award_id: int) -> dict:
award_id_sql = "faba.award_id = {award_id}".format(award_id=award_id)
results = execute_sql_to_ordered_dictionary(defc_sql.format(award_id_sql=award_id_sql))
outlay_by_code = []
obligation_by_code = []
total_outlay = 0
total_obligations = 0
covid_defcs = DisasterEmergencyFundCode.objects.filter(group_name="covid_19").values_list("code", flat=True)
for row in results:
if row["disaster_emergency_fund_code"] in covid_defcs:
total_outlay += row["total_outlay"]
total_obligations += row["obligated_amount"]
outlay_by_code.append({"code": row["disaster_emergency_fund_code"], "amount": row["total_outlay"]})
obligation_by_code.append({"code": row["disaster_emergency_fund_code"], "amount": row["obligated_amount"]})
results = {
"total_account_outlay": total_outlay,
"total_account_obligation": total_obligations,
"account_outlays_by_defc": outlay_by_code,
"account_obligations_by_defc": obligation_by_code,
}
return results
| 41.848039
| 117
| 0.660576
|
7951e94a08edcc5f251a0b90f2834d9a7c5c6ad6
| 80
|
py
|
Python
|
bin/hello_world.py
|
Cray-HPE/metal-net-scripts
|
86755c78b5a8d6fb28a96ae78b6b0b9a1dccc546
|
[
"MIT"
] | null | null | null |
bin/hello_world.py
|
Cray-HPE/metal-net-scripts
|
86755c78b5a8d6fb28a96ae78b6b0b9a1dccc546
|
[
"MIT"
] | null | null | null |
bin/hello_world.py
|
Cray-HPE/metal-net-scripts
|
86755c78b5a8d6fb28a96ae78b6b0b9a1dccc546
|
[
"MIT"
] | null | null | null |
#!/usr/bin/python3
foo = 'world'
print(f'Hello, {foo.capitalize()}!'.rstrip())
| 16
| 45
| 0.6375
|
7951e9638f0ba5c0aa4410cf8d136cdb544c5918
| 7,029
|
py
|
Python
|
eth2/beacon/types/blocks.py
|
teotoplak/trinity
|
6c67b5debfb94f74d0162c70f92ae3d13918b174
|
[
"MIT"
] | null | null | null |
eth2/beacon/types/blocks.py
|
teotoplak/trinity
|
6c67b5debfb94f74d0162c70f92ae3d13918b174
|
[
"MIT"
] | 2
|
2019-04-30T06:22:12.000Z
|
2019-06-14T04:27:18.000Z
|
eth2/beacon/types/blocks.py
|
teotoplak/trinity
|
6c67b5debfb94f74d0162c70f92ae3d13918b174
|
[
"MIT"
] | null | null | null |
from abc import ABC, abstractmethod
from typing import TYPE_CHECKING, Sequence
from eth._utils.datatypes import Configurable
from eth.constants import ZERO_HASH32
from eth_typing import BLSSignature, Hash32
from eth_utils import humanize_hash
import ssz
from ssz.sedes import List, bytes32, bytes96, uint64
from eth2.beacon.constants import (
EMPTY_SIGNATURE,
GENESIS_PARENT_ROOT,
ZERO_SIGNING_ROOT,
)
from eth2.beacon.typing import FromBlockParams, SigningRoot, Slot
from .attestations import Attestation
from .attester_slashings import AttesterSlashing
from .block_headers import BeaconBlockHeader
from .defaults import default_slot, default_tuple
from .deposits import Deposit
from .eth1_data import Eth1Data, default_eth1_data
from .proposer_slashings import ProposerSlashing
from .voluntary_exits import VoluntaryExit
if TYPE_CHECKING:
from eth2.beacon.db.chain import BaseBeaconChainDB # noqa: F401
class BeaconBlockBody(ssz.Serializable):
fields = [
("randao_reveal", bytes96),
("eth1_data", Eth1Data),
("graffiti", bytes32),
("proposer_slashings", List(ProposerSlashing, 1)),
("attester_slashings", List(AttesterSlashing, 1)),
("attestations", List(Attestation, 1)),
("deposits", List(Deposit, 1)),
("voluntary_exits", List(VoluntaryExit, 1)),
]
def __init__(
self,
*,
randao_reveal: bytes96 = EMPTY_SIGNATURE,
eth1_data: Eth1Data = default_eth1_data,
graffiti: Hash32 = ZERO_HASH32,
proposer_slashings: Sequence[ProposerSlashing] = default_tuple,
attester_slashings: Sequence[AttesterSlashing] = default_tuple,
attestations: Sequence[Attestation] = default_tuple,
deposits: Sequence[Deposit] = default_tuple,
voluntary_exits: Sequence[VoluntaryExit] = default_tuple,
) -> None:
super().__init__(
randao_reveal=randao_reveal,
eth1_data=eth1_data,
graffiti=graffiti,
proposer_slashings=proposer_slashings,
attester_slashings=attester_slashings,
attestations=attestations,
deposits=deposits,
voluntary_exits=voluntary_exits,
)
@property
def is_empty(self) -> bool:
return self == BeaconBlockBody()
def __str__(self) -> str:
return (
f"randao_reveal={humanize_hash(self.randao_reveal)},"
f" graffiti={humanize_hash(self.graffiti)},"
f" proposer_slashings={self.proposer_slashings},"
f" attester_slashings={self.attester_slashings},"
f" attestations={self.attestations},"
f" deposits={self.deposits},"
f" voluntary_exits={self.voluntary_exits},"
)
def __repr__(self) -> str:
return f"<{self.__class__.__name__}: {str(self)}>"
default_beacon_block_body = BeaconBlockBody()
class BaseBeaconBlock(ssz.SignedSerializable, Configurable, ABC):
fields = [
("slot", uint64),
("parent_root", bytes32),
("state_root", bytes32),
("body", BeaconBlockBody),
("signature", bytes96),
]
def __init__(
self,
*,
slot: Slot = default_slot,
parent_root: SigningRoot = ZERO_SIGNING_ROOT,
state_root: Hash32 = ZERO_HASH32,
body: BeaconBlockBody = default_beacon_block_body,
signature: BLSSignature = EMPTY_SIGNATURE,
) -> None:
super().__init__(
slot=slot,
parent_root=parent_root,
state_root=state_root,
body=body,
signature=signature,
)
def __str__(self) -> str:
return (
f"[signing_root]={humanize_hash(self.signing_root)},"
f" [hash_tree_root]={humanize_hash(self.hash_tree_root)},"
f" slot={self.slot},"
f" parent_root={humanize_hash(self.parent_root)},"
f" state_root={humanize_hash(self.state_root)},"
f" body=({self.body}),"
f" signature={humanize_hash(self.signature)}"
)
@property
def is_genesis(self) -> bool:
return self.parent_root == GENESIS_PARENT_ROOT
@property
def header(self) -> BeaconBlockHeader:
return BeaconBlockHeader(
slot=self.slot,
parent_root=self.parent_root,
state_root=self.state_root,
body_root=self.body.hash_tree_root,
signature=self.signature,
)
@classmethod
@abstractmethod
def from_root(
cls, root: SigningRoot, chaindb: "BaseBeaconChainDB"
) -> "BaseBeaconBlock":
"""
Return the block denoted by the given block root.
"""
...
def __repr__(self) -> str:
return f"<{self.__class__.__name__}: {str(self)}>"
class BeaconBlock(BaseBeaconBlock):
block_body_class = BeaconBlockBody
@classmethod
def from_root(
cls, root: SigningRoot, chaindb: "BaseBeaconChainDB"
) -> "BeaconBlock":
"""
Return the block denoted by the given block ``root``.
"""
block = chaindb.get_block_by_root(root, cls)
body = cls.block_body_class(
randao_reveal=block.body.randao_reveal,
eth1_data=block.body.eth1_data,
graffiti=block.body.graffiti,
proposer_slashings=block.body.proposer_slashings,
attester_slashings=block.body.attester_slashings,
attestations=block.body.attestations,
deposits=block.body.deposits,
voluntary_exits=block.body.voluntary_exits,
)
return cls(
slot=block.slot,
parent_root=block.parent_root,
state_root=block.state_root,
body=body,
signature=block.signature,
)
@classmethod
def from_parent(
cls, parent_block: "BaseBeaconBlock", block_params: FromBlockParams
) -> "BaseBeaconBlock":
"""
Initialize a new block with the ``parent_block`` as the block's
previous block root.
"""
if block_params.slot is None:
slot = parent_block.slot + 1
else:
slot = block_params.slot
return cls(
slot=slot,
parent_root=parent_block.signing_root,
state_root=parent_block.state_root,
body=cls.block_body_class(),
)
@classmethod
def convert_block(cls, block: "BaseBeaconBlock") -> "BeaconBlock":
return cls(
slot=block.slot,
parent_root=block.parent_root,
state_root=block.state_root,
body=block.body,
signature=block.signature,
)
@classmethod
def from_header(cls, header: BeaconBlockHeader) -> "BeaconBlock":
return cls(
slot=header.slot,
parent_root=header.parent_root,
state_root=header.state_root,
signature=header.signature,
body=BeaconBlockBody(),
)
| 31.520179
| 75
| 0.62797
|
7951ea66e81e254b1f8b2f8cd28ed5d4576c3005
| 1,009
|
py
|
Python
|
ca_nb_moncton/__init__.py
|
dcycle/scrapers-ca
|
4c7a6cd01d603221b5b3b7a400d2e5ca0c6e916f
|
[
"MIT"
] | 19
|
2015-05-26T03:18:50.000Z
|
2022-01-31T03:27:41.000Z
|
ca_nb_moncton/__init__.py
|
dcycle/scrapers-ca
|
4c7a6cd01d603221b5b3b7a400d2e5ca0c6e916f
|
[
"MIT"
] | 119
|
2015-01-09T06:09:35.000Z
|
2022-01-20T23:05:05.000Z
|
ca_nb_moncton/__init__.py
|
dcycle/scrapers-ca
|
4c7a6cd01d603221b5b3b7a400d2e5ca0c6e916f
|
[
"MIT"
] | 17
|
2015-11-23T05:00:10.000Z
|
2021-09-15T16:03:33.000Z
|
from utils import CanadianJurisdiction
from pupa.scrape import Organization
class Moncton(CanadianJurisdiction):
classification = 'legislature'
division_id = 'ocd-division/country:ca/csd:1307022'
division_name = 'Moncton'
name = 'Moncton City Council'
url = 'http://www.moncton.ca'
def get_organizations(self):
organization = Organization(self.name, classification=self.classification)
organization.add_post(role='Mayor', label=self.division_name, division_id=self.division_id)
for seat_number in range(1, 3):
organization.add_post(role='Councillor at Large', label='{} (seat {})'.format(self.division_name, seat_number), division_id=self.division_id)
for ward_number in range(1, 5):
for seat_number in range(1, 3):
organization.add_post(role='Councillor', label='Ward {} (seat {})'.format(ward_number, seat_number), division_id='{}/ward:{}'.format(self.division_id, ward_number))
yield organization
| 43.869565
| 180
| 0.702676
|
7951eb3ce7992dd3eaa0c1bffeb23481076b2430
| 2,589
|
py
|
Python
|
process_threading/mutil_process.py
|
wanghuafeng/auth_login_tools
|
b8b8c87d8d9b92c29c1eca6625cf1040d83ecdd0
|
[
"MIT"
] | 3
|
2017-08-11T20:59:00.000Z
|
2017-10-04T01:23:24.000Z
|
process_threading/mutil_process.py
|
wanghuafeng/auth_login_tools
|
b8b8c87d8d9b92c29c1eca6625cf1040d83ecdd0
|
[
"MIT"
] | null | null | null |
process_threading/mutil_process.py
|
wanghuafeng/auth_login_tools
|
b8b8c87d8d9b92c29c1eca6625cf1040d83ecdd0
|
[
"MIT"
] | 1
|
2018-07-26T02:49:41.000Z
|
2018-07-26T02:49:41.000Z
|
# coding:utf-8
"""
多线程阻塞与非阻塞实现
网络请求时,用于断开请求端连接,后续逻辑继续执行
"""
import threading
import time
def thread_tst():
def gen_thread():
#方法一:将要执行的方法作为参数传给Thread的构造方法
def action(arg):
time.sleep(5)
print 'the arg is:%s\r' %arg
for i in xrange(4):
t =threading.Thread(target=action,args=(i,))
t.start()
print 'main thread end!'
def overload_parent():
class MyThread(threading.Thread):
def __init__(self,arg):
super(MyThread, self).__init__()#注意:一定要显式的调用父类的初始化函数。
self.arg=arg
def run(self):#定义每个线程要运行的函数
time.sleep(1)
print 'the arg is:%s\r' % self.arg
for i in xrange(4):
t =MyThread(i)
t.start()
print 'main thread end!'
def deamon_tst():
def deamon_false():
'''主线程执行过程中,前台线程也在进行,主线程执行完毕后,等待前台线程也执行完成后,程序停止'''
def action(arg):
time.sleep(2)
# print 'sub thread start!the thread name is:%s\r' % threading.currentThread().getName()
print 'the arg is:%s\r' % arg
time.sleep(1)
for i in xrange(50):
t = threading.Thread(target=action, args=(i,))
t.start()
print 'main_thread end!'
def deamon_true():
'''主线程执行完毕后,后台线程不管是成功与否,主线程均停止'''
def action(arg):
time.sleep(1)
print 'sub thread start!the thread name is:%s\r' % threading.currentThread().getName()
print 'the arg is:%s\r' % arg
time.sleep(1)
thread_list = []
for i in xrange(50):
t = threading.Thread(target=action, args=(i,))
t.daemon=True
t.start()
# thread_list.append(t)
# for thread in thread_list:
# print thread.getName()
# thread.join() # 调用json()阻塞至子进程结束
st = time.time()
deamon_false()
# deamon_true()
print time.time() - st
deamon_tst()
exit()
"""
1、如果某个子线程的daemon属性为False,主线程结束时会检测该子线程是否结束,
如果该子线程还在运行,则主线程会等待它完成后再退出;
2、如果某个子线程的daemon属性为True,主线程运行结束时不对这个子线程进行检查而直接退出,
同时所有daemon值为True的子线程将随主线程一起结束,而不论是否运行完成。
属性daemon的值默认为False,如果需要修改,必须在调用start()方法启动线程之前进行设置。
另外要注意的是,上面的描述并不适用于IDLE环境中的交互模式或脚本运行模式,因为在该环境中的主线程只有在退出Python IDLE时才终止。
"""
import time
import threading
def fun():
print "start fun"
# time.sleep(2)
print "end fun"
return 'aaaaaa'
print "main thread"
t1 = threading.Thread(target=fun,args=())
t1.setDaemon(True)
t1.start()
t1.join()
# time.sleep(1)
# print "main thread end"
| 26.96875
| 101
| 0.585168
|
7951ec9714c4128a0e7f677555deda4bd96a7b25
| 13,006
|
py
|
Python
|
wwyfcs/trainer/train_language_model.py
|
shc558/wwyfcs
|
05ca6c94f59f7317e4e597d3df18f549dcadf7c1
|
[
"MIT"
] | 1
|
2021-03-24T18:00:03.000Z
|
2021-03-24T18:00:03.000Z
|
wwyfcs/trainer/train_language_model.py
|
shc558/wwyfcs
|
05ca6c94f59f7317e4e597d3df18f549dcadf7c1
|
[
"MIT"
] | null | null | null |
wwyfcs/trainer/train_language_model.py
|
shc558/wwyfcs
|
05ca6c94f59f7317e4e597d3df18f549dcadf7c1
|
[
"MIT"
] | null | null | null |
# -*- coding: utf-8 -*-
"""
Fine-tuning DialoGPT using language modeling based on
Huggingface transformers run_language_modeling.py &
tutorial from Nathan Cooper
"""
import pandas as pd
import logging
import math
import os
import pickle
from dataclasses import dataclass, field
from typing import Optional, Dict, List, Tuple, Union
import torch
from torch.nn.utils.rnn import pad_sequence
from torch.utils.data import Dataset
from transformers import (
MODEL_WITH_LM_HEAD_MAPPING,
WEIGHTS_NAME,
AdamW,
AutoConfig,
AutoModelForCausalLM,
AutoTokenizer,
HfArgumentParser,
PreTrainedModel,
PreTrainedTokenizer,
get_linear_schedule_with_warmup,
set_seed,
TrainingArguments,
Trainer,
BatchEncoding
)
try:
from torch.utils.tensorboard import SummaryWriter
except ImportError:
from tensorboardX import SummaryWriter
logger = logging.getLogger(__name__)
MODEL_CONFIG_CLASSES = list(MODEL_WITH_LM_HEAD_MAPPING.keys())
MODEL_TYPES = tuple(conf.model_type for conf in MODEL_CONFIG_CLASSES)
@dataclass
class DataCollatorForLanguageModeling:
"""
Data collator used for language modeling.
- collates batches of tensors, honoring their tokenizer's pad_token
- preprocesses batches for masked language modeling
"""
tokenizer: PreTrainedTokenizer
mlm: bool = True
mlm_probability: float = 0.15
def __call__(
self, examples: List[Union[List[int], torch.Tensor, Dict[str, torch.Tensor]]]
) -> Dict[str, torch.Tensor]:
if isinstance(examples[0], (dict, BatchEncoding)):
examples = [e["input_ids"] for e in examples]
batch = self._tensorize_batch(examples)
if self.mlm:
inputs, labels = self.mask_tokens(batch)
return {"input_ids": inputs, "labels": labels}
else:
labels = batch.clone().detach()
if self.tokenizer.pad_token_id is not None:
labels[labels == self.tokenizer.pad_token_id] = -100
return {"input_ids": batch, "labels": labels}
def _tensorize_batch(
self, examples: List[Union[List[int], torch.Tensor, Dict[str, torch.Tensor]]]
) -> torch.Tensor:
# In order to accept both lists of lists and lists of Tensors
if isinstance(examples[0], (list, tuple)):
examples = [torch.tensor(e, dtype=torch.long) for e in examples]
length_of_first = examples[0].size(0)
are_tensors_same_length = all(x.size(0) == length_of_first for x in examples)
if are_tensors_same_length:
return torch.stack(examples, dim=0)
else:
if self.tokenizer._pad_token is None:
return pad_sequence(examples, batch_first=True)
# raise ValueError(
# "You are attempting to pad samples but the tokenizer you are using"
# f" ({self.tokenizer.__class__.__name__}) does not have one."
# )
return pad_sequence(examples, batch_first=True, padding_value=self.tokenizer.pad_token_id)
return inputs, labels
@dataclass
class ModelArguments:
"""
Arguments pertaining to which model/config/tokenizer we are going to fine-tune, or train from scratch.
"""
model_name_or_path: str = field(
default='microsoft/DialoGPT-small',
metadata={
"help": "The model checkpoint for weights initialization. Leave None if you want to train a model from scratch."
},
)
model_type: str = field(
default='gpt2',
metadata={"help": "If training from scratch, pass a model type from the list: " + ", ".join(MODEL_TYPES)},
)
config_name: str = field(
default='microsoft/DialoGPT-small',
metadata={"help": "Pretrained config name or path if not the same as model_name"}
)
tokenizer_name: str = field(
default='microsoft/DialoGPT-small',
metadata={"help": "Pretrained tokenizer name or path if not the same as model_name"}
)
cache_dir: str = field(
default='data/cached',
metadata={"help": "Where do you want to store the pretrained models downloaded from s3"}
)
@dataclass
class DataArguments:
"""
Arguments pertaining to what data we are going to input our model for training and eval.
"""
train_data_file: str = field(
# default=None,
metadata={"help": "The input training data file (a csv file)."}
)
eval_data_file: str = field(
# default=None,
metadata={"help": "An optional input evaluation data file to evaluate the perplexity on (a csv file)."}
)
overwrite_cache: bool = field(
default=True,
metadata={"help": "Overwrite the cached training and evaluation sets"}
)
block_size: int = field(
default=512,
metadata={
"help": "Optional input sequence length after tokenization."
"The training dataset will be truncated in block of this size for training."
"Default to the model max input length for single sentence inputs (take into account special tokens)."
}
)
mlm: bool = field(
default=False, metadata={"help": "Train with masked-language modeling loss instead of language modeling."}
)
def construct_conv(row, tokenizer, eos = True):
# flatten a list of lists
flatten = lambda l: [item for sublist in l for item in sublist]
conv = list(reversed([tokenizer.encode(x) + [tokenizer.eos_token_id] for x in row]))
conv = flatten(conv)
return conv
class ConversationDataset(Dataset):
def __init__(self, tokenizer, model_args, data_args, df):
# leave room for special tokens
block_size = data_args.block_size - (tokenizer.model_max_length - tokenizer.max_len_single_sentence)
directory = model_args.cache_dir
cached_features_file = os.path.join(
directory, model_args.model_type + "_cached_lm_" + str(block_size)
)
if os.path.exists(cached_features_file) and not data_args.overwrite_cache:
logger.info("Loading features from cached file %s", cached_features_file)
with open(cached_features_file, "rb") as handle:
self.examples = pickle.load(handle)
else:
logger.info("Creating features from dataset file")
self.examples = []
for _, row in df.iterrows():
conv = construct_conv(row, tokenizer)
self.examples.append(conv)
logger.info("Saving features into cached file %s", cached_features_file)
with open(cached_features_file, "wb") as handle:
pickle.dump(self.examples, handle, protocol=pickle.HIGHEST_PROTOCOL)
def __len__(self):
return len(self.examples)
def __getitem__(self, item):
return torch.tensor(self.examples[item], dtype=torch.long)
def get_dataset(
model_args,
data_args,
tokenizer,
evaluate = False
):
file_path = data_args.eval_data_file if evaluate else data_args.train_data_file
df = pd.read_csv(file_path)
return ConversationDataset(
tokenizer = tokenizer,
model_args = model_args,
data_args = data_args,
df = df
)
def main():
# See all possible arguments in src/transformers/training_args.py
# or by passing the --help flag to this script.
# We now keep distinct sets of args, for a cleaner separation of concerns.
parser = HfArgumentParser((ModelArguments,DataArguments, TrainingArguments))
model_args, data_args, training_args = parser.parse_args_into_dataclasses()
print('===========')
print(data_args)
print('===========')
if data_args.eval_data_file is None and training_args.do_eval:
raise ValueError(
"Cannot do evaluation without an evaluation data file. Either supply a file to --eval_data_file "
"or remove the --do_eval argument."
)
if (
os.path.exists(training_args.output_dir)
and os.listdir(training_args.output_dir)
and training_args.do_train
and not training_args.overwrite_output_dir
):
raise ValueError(
f"Output directory ({training_args.output_dir}) already exists and is not empty. Use --overwrite_output_dir to overcome."
)
# Setup logging
logging.basicConfig(
format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
datefmt="%m/%d/%Y %H:%M:%S",
level=logging.INFO if training_args.local_rank in [-1, 0] else logging.WARN,
)
logger.warning(
"Process rank: %s, device: %s, n_gpu: %s, distributed training: %s, 16-bits training: %s, training_steps: %s",
training_args.local_rank,
training_args.device,
training_args.n_gpu,
bool(training_args.local_rank != -1),
training_args.fp16,
training_args.max_steps
)
logger.info("Training/evaluation parameters %s", training_args)
# Set seed
set_seed(training_args.seed)
# Load pretrained model and tokenizer
#
# Distributed training:
# The .from_pretrained methods guarantee that only one local process can concurrently
# download model & vocab.
if model_args.config_name:
config = AutoConfig.from_pretrained(model_args.config_name, cache_dir=model_args.cache_dir)
elif model_args.model_name_or_path:
config = AutoConfig.from_pretrained(model_args.model_name_or_path, cache_dir=model_args.cache_dir)
else:
config = CONFIG_MAPPING[model_args.model_type]()
logger.warning("You are instantiating a new config instance from scratch.")
if model_args.tokenizer_name:
tokenizer = AutoTokenizer.from_pretrained(model_args.tokenizer_name, cache_dir=model_args.cache_dir)
elif model_args.model_name_or_path:
tokenizer = AutoTokenizer.from_pretrained(model_args.model_name_or_path, cache_dir=model_args.cache_dir)
else:
raise ValueError(
"You are instantiating a new tokenizer from scratch. This is not supported, but you can do it from another script, save it,"
"and load it from here, using --tokenizer_name"
)
if model_args.model_name_or_path:
model = AutoModelForCausalLM.from_pretrained(
model_args.model_name_or_path,
from_tf=bool(".ckpt" in model_args.model_name_or_path),
config=config,
cache_dir=model_args.cache_dir,
)
else:
logger.info("Training new model from scratch")
model = AutoModelForCausalLM.from_config(config)
model.resize_token_embeddings(len(tokenizer))
if data_args.block_size <= 0:
data_args.block_size = tokenizer.max_len
# Our input block size will be the max possible for the model
else:
data_args.block_size = min(data_args.block_size, tokenizer.max_len)
# Get datasets
train_dataset = (
get_dataset(model_args = model_args, data_args = data_args, tokenizer = tokenizer)
)
eval_dataset = (
get_dataset(model_args = model_args, data_args = data_args, tokenizer = tokenizer, evaluate = True)
if training_args.do_eval
else None
)
data_collator = DataCollatorForLanguageModeling(
tokenizer=tokenizer, mlm=data_args.mlm
)
# Initialize our Trainer
trainer = Trainer(
model=model,
args=training_args,
data_collator=data_collator,
train_dataset=train_dataset,
eval_dataset=eval_dataset,
prediction_loss_only=True,
)
# Training
if training_args.do_train:
model_path = (
model_args.model_name_or_path
if model_args.model_name_or_path is not None and os.path.isdir(model_args.model_name_or_path)
else None
)
trainer.train(model_path=model_path)
trainer.save_model()
# For convenience, we also re-save the tokenizer to the same directory,
# so that you can share your model easily on huggingface.co/models =)
if trainer.is_world_process_zero():
tokenizer.save_pretrained(training_args.output_dir)
# Evaluation
results = {}
if training_args.do_eval:
logger.info("*** Evaluate ***")
eval_output = trainer.evaluate()
perplexity = math.exp(eval_output["eval_loss"])
result = {"perplexity": perplexity}
output_eval_file = os.path.join(training_args.output_dir, "eval_results_lm.txt")
if trainer.is_world_process_zero():
with open(output_eval_file, "w") as writer:
logger.info("***** Eval results *****")
for key in sorted(result.keys()):
logger.info(" %s = %s", key, str(result[key]))
writer.write("%s = %s\n" % (key, str(result[key])))
results.update(result)
return results
if __name__ == "__main__":
main()
| 36.027701
| 136
| 0.658312
|
7951ecdaee268109ad913547f4a389308b5b2c9f
| 3,662
|
py
|
Python
|
configs/tuturial/sort-fpga.py
|
zslwyuan/gem5-HDL_v1.0
|
7f21d9b368b33c0f1426bc1e79c61574a49f169f
|
[
"BSD-3-Clause"
] | 1
|
2019-06-07T19:42:28.000Z
|
2019-06-07T19:42:28.000Z
|
configs/tuturial/sort-fpga.py
|
zslwyuan/gem5-HDL_v1.0
|
7f21d9b368b33c0f1426bc1e79c61574a49f169f
|
[
"BSD-3-Clause"
] | null | null | null |
configs/tuturial/sort-fpga.py
|
zslwyuan/gem5-HDL_v1.0
|
7f21d9b368b33c0f1426bc1e79c61574a49f169f
|
[
"BSD-3-Clause"
] | null | null | null |
import optparse
import sys
import os
import m5
from m5.defines import buildEnv
from m5.objects import *
from m5.util import addToPath, fatal
addToPath('../')
from ruby import Ruby
from common import Options
from common import Simulation
from common import CacheConfig
from common import CpuConfig
from common import MemConfig
from common.Caches import *
from common.cpu2000 import *
parser = optparse.OptionParser()
Options.addCommonOptions(parser)
Options.addSEOptions(parser)
if '--ruby' in sys.argv:
Ruby.define_options(parser)
else:
fatal("This test is only for FPGA in Ruby. Please set --ruby.\n")
(options, args) = parser.parse_args()
if args:
print "Error: script doesn't take any positional arguments"
sys.exit(1)
numThreads = 1
process1 = LiveProcess()
process1.pid = 1100;
process1.cmd = ['tests/test-progs/sort/sort-fpga']
(CPUClass, test_mem_mode, FutureClass) = Simulation.setCPUClass(options)
CPUClass.numThreads = numThreads
np = options.num_cpus
system = System(cpu = [DerivO3CPU() for i in xrange(np)],
#system = System(cpu = [TimingSimpleCPU() for i in xrange(np)],
mem_mode = 'timing',
mem_ranges = [AddrRange('512MB')],
cache_line_size = 64)
system.fpga = [FpgaCPU() for i in xrange(options.num_fpgas)]
system.voltage_domain = VoltageDomain(voltage = options.sys_voltage)
system.clk_domain = SrcClockDomain(clock = options.sys_clock,
voltage_domain = system.voltage_domain)
system.cpu_voltage_domain = VoltageDomain()
system.cpu_clk_domain = SrcClockDomain(clock = options.cpu_clock,
voltage_domain = system.cpu_voltage_domain)
for cpu in system.cpu:
cpu.clk_domain = system.cpu_clk_domain
system.fpga[0].clk_domain = SrcClockDomain(clock = options.fpga_clock)
system.fpga[0].clk_domain.voltage_domain = VoltageDomain()
system.fpga[0].fpga_bus_addr = 1073741824*2
system.fpga[0].ModuleName = 'sort/obj_dir/Vour'
system.cpu[0].workload = process1
system.cpu[0].createThreads()
system.piobus = IOXBar()
if options.ruby:
if options.cpu_type == "atomic" or options.cpu_type == "AtomicSimpleCPU":
print >> sys.stderr, "Ruby does not work with atomic cpu!!"
sys.exit(1)
Ruby.create_system(options, False, system, system.piobus)
system.ruby.clk_domain = SrcClockDomain(clock = options.ruby_clock,
voltage_domain = system.voltage_domain)
for i in xrange(np):
print len(system.ruby._cpu_ports)
ruby_port = system.ruby._cpu_ports[i]
system.cpu[i].createInterruptController()
system.cpu[i].icache_port = ruby_port.slave
system.cpu[i].dcache_port = ruby_port.slave
if buildEnv['TARGET_ISA'] == "x86":
system.cpu[i].interrupts[0].pio = ruby_port.master
system.cpu[i].interrupts[0].int_master = ruby_port.slave
system.cpu[i].interrupts[0].int_slave = ruby_port.master
system.cpu[i].itb.walker.port = ruby_port.slave
system.cpu[i].dtb.walker.port = ruby_port.slave
for i in xrange(options.num_fpgas):
ruby_port = system.ruby._cpu_ports[i+np]
system.fpga[i].icache_port = ruby_port.slave
system.fpga[i].dcache_port = ruby_port.slave
system.fpga[i].itb.walker.port = ruby_port.slave
system.fpga[i].dtb.walker.port = ruby_port.slave
system.fpga[i].control_port = system.piobus.master
root = Root(full_system = False, system = system)
m5.instantiate()
print "Beginning simulation!"
exit_event = m5.simulate()
print 'Exiting @ tick %i because %s' % (m5.curTick(), exit_event.getCause())
| 33.290909
| 79
| 0.698798
|
7951edfee46ec52bc6806dd791612c5532973657
| 9,706
|
py
|
Python
|
app/parse_html.py
|
jjdelvalle/gradcafe_analysis
|
a5d72bd7e60d014d5ed1111ea2a32cb503f89c55
|
[
"MIT"
] | 3
|
2021-01-21T16:23:00.000Z
|
2021-01-27T16:31:04.000Z
|
app/parse_html.py
|
mehmetsuci/gradcafe_analysis
|
a5d72bd7e60d014d5ed1111ea2a32cb503f89c55
|
[
"MIT"
] | null | null | null |
app/parse_html.py
|
mehmetsuci/gradcafe_analysis
|
a5d72bd7e60d014d5ed1111ea2a32cb503f89c55
|
[
"MIT"
] | 3
|
2021-01-15T05:16:24.000Z
|
2022-02-24T19:55:33.000Z
|
from bs4 import BeautifulSoup
import datetime, time
from IPython.core.debugger import Pdb
import sys, re
import os.path
from collections import Counter
import seaborn as sns
import matplotlib.pyplot as plt
import pandas
PROGS = [
('Computer Engineering', 'Electrical and Computer Engineering'),
('Computer Enginnerin', 'Electrical and Computer Engineering'),
('Electrical', 'Electrical and Computer Engineering'),
('ECE', 'Electrical and Computer Engineering'),
('Computer Sc', 'Computer Science'),
('Computer Sc', 'Computer Science'),
('Computer Sicen', 'Computer Science'),
('Computer Sien', 'Computer Science'),
('Computer S Cience', 'Computer Science'),
('Computer,', 'Computer Science'),
('Computers,', 'Computer Science'),
('ComputerScience', 'Computer Science'),
('Human Computer Interaction', 'Human Computer Interaction'),
('Human-Computer Interaction', 'Human Computer Interaction'),
('Human-computer Interaction', 'Human Computer Interaction'),
('software engineering', 'Software Engineering'),
('Embedded', 'Electrical and Computer Engineering'),
('Computer Eng', 'Electrical and Computer Engineering'),
('Computer Vision', 'Computer Science')]
# ('computer graphics', 'Game Development'),
# ('computer gam', 'Game Development'),
# ('Computer Systems', 'Computer Systems Engineering'),
# ('Computer And Systems', 'Computer Systems Engineering'),
# ('Computer & Systems', 'Computer Systems Engineering'),
# ('Information Technology', 'IT'),
# ('Communication', 'Computers and Communication'),
# ('Computer Network', 'Computer Networking'),
# ('Computer And Computational Sciences', 'Computer And Computational Sciences'),
# ('Computer Music', 'Computer Music'),
# ('Computer Control And Automation', 'Computer Control And Automation'),
# ('Computer Aided Mechanical Engineering', 'CAME'),
# ('Computer Art', 'Computer Art'),
# ('Computer Animation', 'Computer Art'),
# ('composition and computer technologies', 'Computer Art'),
# ('computer forensics', 'Computer Art')]
DEGREE = [
(' MFA', 'MFA'),
(' M Eng', 'MEng'),
(' MEng', 'MEng'),
(' M.Eng', 'MEng'),
(' Masters', 'MS'),
(' PhD', 'PhD'),
(' MBA', 'MBA'),
(' Other', 'Other'),
(' EdD', 'Other'),
]
STATUS = {
'A': 'American',
'U': 'International with US Degree',
'I': 'International',
'O': 'Other',
}
COLLEGES = [
('Stanford', 'Stanford'),
('MIT', 'MIT'),
('CMU', 'CMU'),
('Cornell', 'Cornell')
]
errlog = {'major': [], 'gpa': [], 'general': [], 'subject': []}
def process(index, col):
global err
inst, major, degree, season, status, date_add, date_add_ts, comment = None, None, None, None, None, None, None, None
if len(col) != 6:
return []
try:
inst = col[0].text.strip()
except:
print("Couldn't retrieve institution")
try:
major = None
progtext = col[1].text.strip()
if not ',' in progtext:
print('no comma')
errlog['major'].append((index, col))
else:
parts = progtext.split(',')
major = parts[0].strip()
progtext = ' '.join(parts[1:])
for p, nam in PROGS:
if p.lower() in major.lower():
major = nam
break
degree = None
for (d, deg) in DEGREE:
if d in progtext:
degree = deg
break
if not degree:
degree = 'Other'
season = None
mat = re.search('\([SF][012][0-9]\)', progtext)
if mat:
season = mat.group()[1:-1]
else:
mat = re.search('\(\?\)', progtext)
if mat:
season = None
except NameError as e:
print(e)
except:
print("Unexpected error:", sys.exc_info()[0])
try:
extra = col[2].find(class_='extinfo')
gpafin, grev, grem, grew, new_gre, sub = None, None, None, None, None, None
if extra:
gre_text = extra.text.strip()
gpa = re.search('Undergrad GPA: ((?:[0-9]\.[0-9]{1,2})|(?:n/a))', gre_text)
general = re.search('GRE General \(V/Q/W\): ((?:1[0-9]{2}/1[0-9]{2}/(?:(?:[0-6]\.[0-9]{2})|(?:99\.99)|(?:56\.00)))|(?:n/a))', gre_text)
new_gref = True
subject = re.search('GRE Subject: ((?:[2-9][0-9]0)|(?:n/a))', gre_text)
if gpa:
gpa = gpa.groups(1)[0]
if not gpa == 'n/a':
try:
gpafin = float(gpa)
except:
print("Couldn't convert gpa to float")
else:
errlog['gpa'].append((index, gre_text))
if not general:
general = re.search('GRE General \(V/Q/W\): ((?:[2-8][0-9]0/[2-8][0-9]0/(?:(?:[0-6]\.[0-9]{2})|(?:99\.99)|(?:56\.00)))|(?:n/a))', gre_text)
new_gref = False
if general:
general = general.groups(1)[0]
if not general == 'n/a':
try:
greparts = general.split('/')
if greparts[2] == '99.99' or greparts[2] == '0.00' or greparts[2] == '56.00':
grew = None
else:
grew = float(greparts[2])
grev = int(greparts[0])
grem = int(greparts[1])
new_gre = new_gref
if new_gref and (grev > 170 or grev < 130 or grem > 170 or grem < 130 or (grew and (grew < 0 or grew > 6))):
errlog['general'].append((index, gre_text))
grew, grem, grev, new_gre = None, None, None, None
elif not new_gref and (grev > 800 or grev < 200 or grem > 800 or grem < 200 or (grew and (grew < 0 or grew > 6))):
errlog['general'].append((index, gre_text))
grew, grem, grev, new_gre = None, None, None, None
except Exception as e:
print(e)
else:
errlog['general'].append((index, gre_text))
if subject:
subject = subject.groups(1)[0]
if not subject == 'n/a':
sub = int(subject)
else:
errlog['subject'].append((index, gre_text))
extra.extract()
decision = col[2].text.strip()
try:
decisionfin, method, decdate, decdate_ts = None, None, None, None
(decisionfin, method, decdate) = re.search('((?:Accepted)|(?:Rejected)|(?:Wait listed)|(?:Other)|(?:Interview))? ?via ?((?:E-[mM]ail)|(?:Website)|(?:Phone)|(?:Other)|(?:Postal Service)|(?:POST)|(?:Unknown))? ?on ?([0-9]{1,2} [A-Z][a-z]{2} [0-9]{4})?' , decision).groups()
if method and method == 'E-Mail':
method = 'E-mail'
if method and method=='Unknown':
method = 'Other'
if method and method=='POST':
method = 'Postal Service'
if decdate:
try:
decdate_date = datetime.datetime.strptime(decdate, '%d %b %Y')
decdate_ts = decdate_date.strftime('%s')
decdate = decdate_date.strftime('%d-%m-%Y')
except Exception as e:
decdate_date, decdate_ts, decdate = None, None, None
except Exception as e:
print("Couldn't assign method of reporting")
except Exception as e:
print("Extra information error")
try:
statustxt = col[3].text.strip()
if statustxt in STATUS:
status = STATUS[statustxt]
else:
status = None
except:
print("Couldn't retrieve status")
try:
date_addtxt = col[4].text.strip()
date_add_date = datetime.datetime.strptime(date_addtxt, '%d %b %Y')
date_add_ts = date_add_date.strftime('%s')
date_add = date_add_date.strftime('%d-%m-%Y')
except:
print("Couldn't retrieve date_add")
try:
comment = col[5].text.strip()
except:
print("Couldn't retrieve the comment")
res = [inst, major, degree, season, decisionfin, method, decdate, decdate_ts, gpafin, grev, grem, grew, new_gre, sub, status, date_add, date_add_ts, comment]
return res
if __name__ == '__main__':
args = sys.argv
if len(args) < 4:
exit()
if not args[-1].isdigit():
exit()
path = args[1]
title = args[2]
n_pages = int(args[3])
data = []
for page in range(1, n_pages):
if not os.path.isfile('{0}/{1}.html'.format(path, page)):
print("Page {0} not found.".format(page))
continue
with open('{0}/{1}.html'.format(path, page), 'r') as f:
soup = BeautifulSoup(f.read(), features="html.parser")
tables = soup.findAll('table', class_='submission-table')
for tab in tables:
rows = tab.findAll('tr')
for row in rows[1:]:
cols = row.findAll('td')
pro = process(page, cols)
if len(pro) > 0:
data.append(pro)
if page % 10 == 0:
print("Processed 10 more pages (page {0})".format(page))
df = pandas.DataFrame(data)
df.columns = ['institution', 'major', 'degree', 'season', 'decisionfin', 'method', 'decdate', 'decdate_ts', 'gpafin', 'grev', 'grem', 'grew', 'new_gre', 'sub', 'status', 'date_add', 'date_add_ts', 'comment']
df.to_csv("data/{0}.csv".format(title))
| 38.515873
| 284
| 0.523697
|
7951ee0d331b1cdf4c8189896fdbd335f290e621
| 1,614
|
py
|
Python
|
mayan/apps/history/api.py
|
Dave360-crypto/mayan-edms
|
9cd37537461347f79ff0429e4b8b16fd2446798d
|
[
"Apache-2.0"
] | 3
|
2020-02-03T11:58:51.000Z
|
2020-10-20T03:52:21.000Z
|
mayan/apps/history/api.py
|
Dave360-crypto/mayan-edms
|
9cd37537461347f79ff0429e4b8b16fd2446798d
|
[
"Apache-2.0"
] | null | null | null |
mayan/apps/history/api.py
|
Dave360-crypto/mayan-edms
|
9cd37537461347f79ff0429e4b8b16fd2446798d
|
[
"Apache-2.0"
] | 2
|
2020-10-24T11:10:06.000Z
|
2021-03-03T20:05:38.000Z
|
from __future__ import absolute_import
import json
import pickle
from django.db import models
from django.core import serializers
from .models import HistoryType, History
from .runtime_data import history_types_dict
def register_history_type(history_type_dict):
namespace = history_type_dict['namespace']
name = history_type_dict['name']
# Runtime
history_types_dict.setdefault(namespace, {})
history_types_dict[namespace][name] = {
'label': history_type_dict['label'],
'summary': history_type_dict.get('summary', u''),
'details': history_type_dict.get('details', u''),
'expressions': history_type_dict.get('expressions', {}),
}
def create_history(history_type_dict, source_object=None, data=None):
history_type, created = HistoryType.objects.get_or_create(namespace=history_type_dict['namespace'], name=history_type_dict['name'])
new_history = History(history_type=history_type)
if source_object:
new_history.content_object = source_object
if data:
new_dict = {}
for key, value in data.items():
new_dict[key] = {}
if isinstance(value, models.Model):
new_dict[key]['value'] = serializers.serialize('json', [value])
elif isinstance(value, models.query.QuerySet):
new_dict[key]['value'] = serializers.serialize('json', value)
else:
new_dict[key]['value'] = json.dumps(value)
new_dict[key]['type'] = pickle.dumps(type(value))
new_history.dictionary = json.dumps(new_dict)
new_history.save()
| 34.340426
| 135
| 0.675341
|
7951ee4307308904bbcaf3a94ef888dcd671e1fa
| 2,871
|
py
|
Python
|
gracebot/detector.py
|
Roald87/GraceDB
|
5c7e6cc93a33b00c1c30ce040ef26326c003630d
|
[
"Apache-2.0"
] | 7
|
2019-05-16T20:08:11.000Z
|
2021-10-07T03:15:00.000Z
|
gracebot/detector.py
|
Roald87/GraceDB
|
5c7e6cc93a33b00c1c30ce040ef26326c003630d
|
[
"Apache-2.0"
] | 24
|
2019-07-07T06:14:12.000Z
|
2021-09-21T18:50:50.000Z
|
gracebot/detector.py
|
Roald87/GraceDB
|
5c7e6cc93a33b00c1c30ce040ef26326c003630d
|
[
"Apache-2.0"
] | null | null | null |
import logging
import requests
from datetime import timedelta, datetime
from html.parser import HTMLParser
class MyHTMLParser(HTMLParser):
def __init__(self):
HTMLParser.__init__(self)
self.data = []
def handle_data(self, data):
if data[:2] != "\n":
self.data.append(data)
retrieve_date = datetime(1987, 4, 3)
text = ""
class Detector:
default_source = "https://ldas-jobs.ligo.caltech.edu/~gwistat/gwistat/gwistat.html"
def __init__(self, name, source=default_source):
self.name = name
self.source = source
self.status = ""
self.status_icon = ""
self.status_duration = timedelta(0)
self.__post_init__()
@property
def age(self):
global retrieve_date
return datetime.now() - retrieve_date
def __post_init__(self):
global retrieve_date
global text
if self.age < timedelta(minutes=1):
pass
elif self._remote_source():
text = requests.get(self.source).text
retrieve_date = datetime.now()
else:
with open(self.source, "r") as file:
text = file.read()
parser = MyHTMLParser()
parser.feed(text)
detector_index = [i for i, t in enumerate(parser.data) if self.name in t][0]
status_raw = parser.data[detector_index + 1]
self.status = status_raw.replace("_", " ").lower().capitalize()
self.status_icon = self._get_status_icon()
duration = parser.data[detector_index + 2]
self.status_duration = self._convert_to_time(duration)
def _get_status_icon(self) -> str:
check_mark = ":white_check_mark:"
cross = ":x:"
construction = ":construction:"
status_mapper = {
"observing": check_mark,
"up": check_mark,
"science": check_mark,
"not locked": cross,
"down": cross,
"info too old": cross,
"maintenance": construction,
"locking": construction,
"troubleshooting": construction,
"calibration": construction,
}
status_icon = status_mapper.get(self.status.lower(), ":question:")
if status_icon == ":question:":
logging.warning(f"Unknown status {self.status}")
return status_icon
def _remote_source(self) -> bool:
return self.source.split(":")[0] == "https"
def _convert_to_time(self, time_string: str) -> timedelta:
try:
hours, minutes = time_string.split(":")
h = int(hours[1:]) if hours[0] == ">" else int(hours)
m = int(minutes)
except ValueError:
logging.error(f"Could not convert the string '{time_string}' to a time.")
h, m = 0, 0
return timedelta(hours=h, minutes=m)
| 28.71
| 87
| 0.58342
|
7951ee4d316535dc030a79d497ac8b0f23df0a6a
| 5,753
|
py
|
Python
|
mother_agents.py
|
dimelab-public/MTConnect-Testbed-Simulator-Public
|
4b42052953d042418ddecbd5ed8608ccbdbaa189
|
[
"MIT"
] | null | null | null |
mother_agents.py
|
dimelab-public/MTConnect-Testbed-Simulator-Public
|
4b42052953d042418ddecbd5ed8608ccbdbaa189
|
[
"MIT"
] | null | null | null |
mother_agents.py
|
dimelab-public/MTConnect-Testbed-Simulator-Public
|
4b42052953d042418ddecbd5ed8608ccbdbaa189
|
[
"MIT"
] | 1
|
2019-12-09T14:52:18.000Z
|
2019-12-09T14:52:18.000Z
|
# -*- coding: utf-8 -*-
"""
Created on Thu Jan 17 09:19:19 2019
@author: smehdi@ncsu.edu
"""
import pandas as pd
master = pd.read_csv('dbs\master.csv')
ports =list(master['agentPorts'])
machines =list(master['machines'])
for port in ports:
PO=str(port)
i=(ports.index(port))
path='temp_folder/Org '+str(i+1)+'/'
agent = open(path+'agent.py','w+')
manager = open(path+'manager.py','w')
weed="{'Content-Type': 'application/xml'}"
agent.write(f'''from flask import Flask,Response
import xml.etree.ElementTree as ET
import datetime
from flask import render_template,request
import pandas as pd
def header_update(file):
utcnow = datetime.datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S')
tree = ET.parse(file)
root = tree.getroot()
for elems in root.iter('Header'):
elems.set('creationTime',str(utcnow))
j= elems.get('instanceId')
elems.set('instanceId',str(int(j)+1))
tree.write(file)
tree = ET.parse(file)
root2 = tree.getroot()
return root2
def stream(file):
tree = ET.parse(file)
root2 = tree.getroot()
return root2
def sample(F=0,C=100):
if F==0:
buffer=pd.read_csv("buffer.txt",sep='|',names = ["Seq","time", "Mach", "na", "OEE","na2","power","order","qty","partid"])
if F!=0:
buffer=pd.read_csv("buffer.txt",sep='|',names = ["Seq","time", "Mach", "na", "OEE","na2","power","order","qty","partid"])
buffer = buffer = buffer[(buffer.Seq>=int(F))&(buffer.Seq<=int(F)+int(C))]
buffer=buffer.sort_values(by=['Mach'])
root = ET.Element("MTConnectStreams")
doc = ET.SubElement(root, "Streams")
machs=(buffer.Mach.unique())
for i in machs:
xmlpd=(buffer[buffer.Mach==i])
OEE=list(xmlpd['OEE'])
seq=list(xmlpd['Seq'])
time=list(xmlpd['time'])
for O in range(len(OEE)):
DS=ET.SubElement(doc, "DeviceStream",timestamp=time[O],sequence=str(seq[O]), name=i).text=str(OEE[O])
tree = ET.ElementTree(root)
tree.write("sample.xml")
tree = ET.parse("sample.xml")
root3 = tree.getroot()
return root3
app = Flask(__name__)
class MyResponse(Response):
default_mimetype = 'application/xml'
@app.route('/<path:path>')
def get_sample(path):
if path=="probe":
return (ET.tostring(header_update('devices.xml'), encoding='UTF-8').decode('UTF-8'),{weed})
if path=="current":
return (ET.tostring(stream('streams.xml'), encoding='UTF-8').decode('UTF-8'),{weed})
if path=="sample":
if request.args.get('from')!=None:
F=int(request.args.get('from'))
if request.args.get('count')==None:
C=100
if request.args.get('count')!=None:
C=int(request.args.get('count'))
return (ET.tostring(sample(F,C), encoding='UTF-8').decode('UTF-8'),{weed})
return (ET.tostring(sample(), encoding='UTF-8').decode('UTF-8'),{weed})
if __name__ == "__main__":
app.run(host='0.0.0.0',port={PO} , threaded=True)''')
agent.close()
adpPorts=[a+port for a in (list(range(1,machines[i]+1)))]
manager.write(f'''
import xml.etree.ElementTree as ET
import asyncio
import datetime
import time
ports={adpPorts}
file='streams.xml'
try:
f=open("buffer.txt","r")
b=f.readlines()
if len(b)>0:
e=b[-1].split('|')
seq=int(e[0])
except:
seq=1
@asyncio.coroutine
async def handle_hello(reader, writer):
global seq
utcnow= datetime.datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S')
f=open('buffer.txt','a+')
data = await reader.read(1024)
SHDR = data.decode('utf-8')
f.write(str(seq)+"|"+str(utcnow)+"|"+SHDR+"\\n")
seq=seq+1
data=(SHDR).split('|')
m=str(data[0])
o=str(data[5])
p=str(data[7])
q=str(data[6])
for node in tree.findall("./Streams/DeviceStream[@name='%s']"%m):
node.set('Order',o)
node.set('PartID',p)
node.set('QTY',q)
utcnow= datetime.datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S')
for a in node.findall('./Events/Power'):
a.set('timestamp',utcnow)
a.text=str(data[4])
tree.write(file)
for b in node.findall('./Samples/OEE'):
b.set('timestamp',utcnow)
b.text=str(data[2])
writer.write("Pong".encode("utf-8"))
writer.close()
f.seek(0)
a=f.readlines()
if(len(a)>1000):
with open('buffer.txt', 'r') as fin:
data = fin.read().splitlines(True)
with open('buffer.txt', 'w') as fout:
fout.writelines(data[500:])
if __name__ == "__main__":
loop = asyncio.get_event_loop()
servers = []
for i in ports:
#print("Starting server ",i)
tree = ET.parse(file)
server = loop.run_until_complete(
asyncio.start_server(handle_hello, '127.0.0.1', i, loop=loop))
tree.write(file)
servers.append(server)
try:
#print("Running... Press ^C to shutdown")
#run loops of servers
loop.run_forever()
except KeyboardInterrupt:
pass
for i, server in enumerate(servers):
#print("Closing server ",i)
#if key pressed close all servers.
server.close()
loop.run_until_complete(server.wait_closed())
loop.close()
''')
manager.close()
start=open(path+'/startAgent.bat','w')
stop=open(path+'/stopAgent.bat','w')
start.write(f'start /min "[O{i}agent]" python agent.py\nstart /min "[O{i}manager]" python manager.py')
start.close()
stop.write(f'taskkill /f /FI "WINDOWTITLE eq [O{i}agent]\ntaskkill /f /FI "WINDOWTITLE eq [O{i}manager]')
stop.close()
| 29.654639
| 129
| 0.582479
|
7951ee7aedc728446bb9f8af97f77ef886f5dd56
| 814
|
py
|
Python
|
setup.py
|
Nishk23/Flappy-bird
|
31991f93f9c7b6de465253ef837c4aca022f80ff
|
[
"MIT"
] | null | null | null |
setup.py
|
Nishk23/Flappy-bird
|
31991f93f9c7b6de465253ef837c4aca022f80ff
|
[
"MIT"
] | null | null | null |
setup.py
|
Nishk23/Flappy-bird
|
31991f93f9c7b6de465253ef837c4aca022f80ff
|
[
"MIT"
] | null | null | null |
import os
import sys
from distutils.core import setup
import py2exe
origIsSystemDLL = py2exe.build_exe.isSystemDLL
def isSystemDLL(pathname):
dlls = ("libfreetype-6.dll", "libogg-0.dll", "sdl_ttf.dll")
if os.path.basename(pathname).lower() in dlls:
return 0
return origIsSystemDLL(pathname)
py2exe.build_exe.isSystemDLL = isSystemDLL
sys.argv.append('py2exe')
setup(
name = 'Flappy Bird',
version = '1.0',
author = 'Sourabh Verma',
options = {
'py2exe': {
'bundle_files': 1, # doesn't work on win64
'compressed': True,
}
},
windows = [{
'script': "flappy.py",
'icon_resources': [
(1, 'flappy.ico')
]
}],
zipfile=None, requires=['pygame']
)
| 22
| 64
| 0.563882
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.