pyswordfish 3.0.4.0__cp312-cp312-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyswordfish-3.0.4.0.dist-info/METADATA +53 -0
- pyswordfish-3.0.4.0.dist-info/RECORD +644 -0
- pyswordfish-3.0.4.0.dist-info/WHEEL +5 -0
- pyswordfish-3.0.4.0.dist-info/top_level.txt +1 -0
- swordfish/__init__.py +102 -0
- swordfish/_config.py +901 -0
- swordfish/_connection.py +1418 -0
- swordfish/_core.py +17 -0
- swordfish/_engine.py +1456 -0
- swordfish/_enums.py +142 -0
- swordfish/_function_bindings.py +23594 -0
- swordfish/_function_tools.py +124 -0
- swordfish/_helper.py +57 -0
- swordfish/_runtime.py +158 -0
- swordfish/_sqlbuilder.py +549 -0
- swordfish/_streaming.py +333 -0
- swordfish/_swordfishcpp.cp312-win_amd64.pyd +0 -0
- swordfish/_swordfishcpp.pyi +4784 -0
- swordfish/_translator.py +580 -0
- swordfish/asset/dolphindb.dos +71 -0
- swordfish/asset/tzdb/Africa/Abidjan +0 -0
- swordfish/asset/tzdb/Africa/Accra +0 -0
- swordfish/asset/tzdb/Africa/Addis_Ababa +0 -0
- swordfish/asset/tzdb/Africa/Algiers +0 -0
- swordfish/asset/tzdb/Africa/Asmara +0 -0
- swordfish/asset/tzdb/Africa/Asmera +0 -0
- swordfish/asset/tzdb/Africa/Bamako +0 -0
- swordfish/asset/tzdb/Africa/Bangui +0 -0
- swordfish/asset/tzdb/Africa/Banjul +0 -0
- swordfish/asset/tzdb/Africa/Bissau +0 -0
- swordfish/asset/tzdb/Africa/Blantyre +0 -0
- swordfish/asset/tzdb/Africa/Brazzaville +0 -0
- swordfish/asset/tzdb/Africa/Bujumbura +0 -0
- swordfish/asset/tzdb/Africa/Cairo +0 -0
- swordfish/asset/tzdb/Africa/Casablanca +0 -0
- swordfish/asset/tzdb/Africa/Ceuta +0 -0
- swordfish/asset/tzdb/Africa/Conakry +0 -0
- swordfish/asset/tzdb/Africa/Dakar +0 -0
- swordfish/asset/tzdb/Africa/Dar_es_Salaam +0 -0
- swordfish/asset/tzdb/Africa/Djibouti +0 -0
- swordfish/asset/tzdb/Africa/Douala +0 -0
- swordfish/asset/tzdb/Africa/El_Aaiun +0 -0
- swordfish/asset/tzdb/Africa/Freetown +0 -0
- swordfish/asset/tzdb/Africa/Gaborone +0 -0
- swordfish/asset/tzdb/Africa/Harare +0 -0
- swordfish/asset/tzdb/Africa/Johannesburg +0 -0
- swordfish/asset/tzdb/Africa/Juba +0 -0
- swordfish/asset/tzdb/Africa/Kampala +0 -0
- swordfish/asset/tzdb/Africa/Khartoum +0 -0
- swordfish/asset/tzdb/Africa/Kigali +0 -0
- swordfish/asset/tzdb/Africa/Kinshasa +0 -0
- swordfish/asset/tzdb/Africa/Lagos +0 -0
- swordfish/asset/tzdb/Africa/Libreville +0 -0
- swordfish/asset/tzdb/Africa/Lome +0 -0
- swordfish/asset/tzdb/Africa/Luanda +0 -0
- swordfish/asset/tzdb/Africa/Lubumbashi +0 -0
- swordfish/asset/tzdb/Africa/Lusaka +0 -0
- swordfish/asset/tzdb/Africa/Malabo +0 -0
- swordfish/asset/tzdb/Africa/Maputo +0 -0
- swordfish/asset/tzdb/Africa/Maseru +0 -0
- swordfish/asset/tzdb/Africa/Mbabane +0 -0
- swordfish/asset/tzdb/Africa/Mogadishu +0 -0
- swordfish/asset/tzdb/Africa/Monrovia +0 -0
- swordfish/asset/tzdb/Africa/Nairobi +0 -0
- swordfish/asset/tzdb/Africa/Ndjamena +0 -0
- swordfish/asset/tzdb/Africa/Niamey +0 -0
- swordfish/asset/tzdb/Africa/Nouakchott +0 -0
- swordfish/asset/tzdb/Africa/Ouagadougou +0 -0
- swordfish/asset/tzdb/Africa/Porto-Novo +0 -0
- swordfish/asset/tzdb/Africa/Sao_Tome +0 -0
- swordfish/asset/tzdb/Africa/Timbuktu +0 -0
- swordfish/asset/tzdb/Africa/Tripoli +0 -0
- swordfish/asset/tzdb/Africa/Tunis +0 -0
- swordfish/asset/tzdb/Africa/Windhoek +0 -0
- swordfish/asset/tzdb/America/Adak +0 -0
- swordfish/asset/tzdb/America/Anchorage +0 -0
- swordfish/asset/tzdb/America/Anguilla +0 -0
- swordfish/asset/tzdb/America/Antigua +0 -0
- swordfish/asset/tzdb/America/Araguaina +0 -0
- swordfish/asset/tzdb/America/Argentina/Buenos_Aires +0 -0
- swordfish/asset/tzdb/America/Argentina/Catamarca +0 -0
- swordfish/asset/tzdb/America/Argentina/ComodRivadavia +0 -0
- swordfish/asset/tzdb/America/Argentina/Cordoba +0 -0
- swordfish/asset/tzdb/America/Argentina/Jujuy +0 -0
- swordfish/asset/tzdb/America/Argentina/La_Rioja +0 -0
- swordfish/asset/tzdb/America/Argentina/Mendoza +0 -0
- swordfish/asset/tzdb/America/Argentina/Rio_Gallegos +0 -0
- swordfish/asset/tzdb/America/Argentina/Salta +0 -0
- swordfish/asset/tzdb/America/Argentina/San_Juan +0 -0
- swordfish/asset/tzdb/America/Argentina/San_Luis +0 -0
- swordfish/asset/tzdb/America/Argentina/Tucuman +0 -0
- swordfish/asset/tzdb/America/Argentina/Ushuaia +0 -0
- swordfish/asset/tzdb/America/Aruba +0 -0
- swordfish/asset/tzdb/America/Asuncion +0 -0
- swordfish/asset/tzdb/America/Atikokan +0 -0
- swordfish/asset/tzdb/America/Atka +0 -0
- swordfish/asset/tzdb/America/Bahia +0 -0
- swordfish/asset/tzdb/America/Bahia_Banderas +0 -0
- swordfish/asset/tzdb/America/Barbados +0 -0
- swordfish/asset/tzdb/America/Belem +0 -0
- swordfish/asset/tzdb/America/Belize +0 -0
- swordfish/asset/tzdb/America/Blanc-Sablon +0 -0
- swordfish/asset/tzdb/America/Boa_Vista +0 -0
- swordfish/asset/tzdb/America/Bogota +0 -0
- swordfish/asset/tzdb/America/Boise +0 -0
- swordfish/asset/tzdb/America/Buenos_Aires +0 -0
- swordfish/asset/tzdb/America/Cambridge_Bay +0 -0
- swordfish/asset/tzdb/America/Campo_Grande +0 -0
- swordfish/asset/tzdb/America/Cancun +0 -0
- swordfish/asset/tzdb/America/Caracas +0 -0
- swordfish/asset/tzdb/America/Catamarca +0 -0
- swordfish/asset/tzdb/America/Cayenne +0 -0
- swordfish/asset/tzdb/America/Cayman +0 -0
- swordfish/asset/tzdb/America/Chicago +0 -0
- swordfish/asset/tzdb/America/Chihuahua +0 -0
- swordfish/asset/tzdb/America/Coral_Harbour +0 -0
- swordfish/asset/tzdb/America/Cordoba +0 -0
- swordfish/asset/tzdb/America/Costa_Rica +0 -0
- swordfish/asset/tzdb/America/Creston +0 -0
- swordfish/asset/tzdb/America/Cuiaba +0 -0
- swordfish/asset/tzdb/America/Curacao +0 -0
- swordfish/asset/tzdb/America/Danmarkshavn +0 -0
- swordfish/asset/tzdb/America/Dawson +0 -0
- swordfish/asset/tzdb/America/Dawson_Creek +0 -0
- swordfish/asset/tzdb/America/Denver +0 -0
- swordfish/asset/tzdb/America/Detroit +0 -0
- swordfish/asset/tzdb/America/Dominica +0 -0
- swordfish/asset/tzdb/America/Edmonton +0 -0
- swordfish/asset/tzdb/America/Eirunepe +0 -0
- swordfish/asset/tzdb/America/El_Salvador +0 -0
- swordfish/asset/tzdb/America/Ensenada +0 -0
- swordfish/asset/tzdb/America/Fort_Nelson +0 -0
- swordfish/asset/tzdb/America/Fort_Wayne +0 -0
- swordfish/asset/tzdb/America/Fortaleza +0 -0
- swordfish/asset/tzdb/America/Glace_Bay +0 -0
- swordfish/asset/tzdb/America/Godthab +0 -0
- swordfish/asset/tzdb/America/Goose_Bay +0 -0
- swordfish/asset/tzdb/America/Grand_Turk +0 -0
- swordfish/asset/tzdb/America/Grenada +0 -0
- swordfish/asset/tzdb/America/Guadeloupe +0 -0
- swordfish/asset/tzdb/America/Guatemala +0 -0
- swordfish/asset/tzdb/America/Guayaquil +0 -0
- swordfish/asset/tzdb/America/Guyana +0 -0
- swordfish/asset/tzdb/America/Halifax +0 -0
- swordfish/asset/tzdb/America/Havana +0 -0
- swordfish/asset/tzdb/America/Hermosillo +0 -0
- swordfish/asset/tzdb/America/Indiana/Indianapolis +0 -0
- swordfish/asset/tzdb/America/Indiana/Knox +0 -0
- swordfish/asset/tzdb/America/Indiana/Marengo +0 -0
- swordfish/asset/tzdb/America/Indiana/Petersburg +0 -0
- swordfish/asset/tzdb/America/Indiana/Tell_City +0 -0
- swordfish/asset/tzdb/America/Indiana/Vevay +0 -0
- swordfish/asset/tzdb/America/Indiana/Vincennes +0 -0
- swordfish/asset/tzdb/America/Indiana/Winamac +0 -0
- swordfish/asset/tzdb/America/Indianapolis +0 -0
- swordfish/asset/tzdb/America/Inuvik +0 -0
- swordfish/asset/tzdb/America/Iqaluit +0 -0
- swordfish/asset/tzdb/America/Jamaica +0 -0
- swordfish/asset/tzdb/America/Jujuy +0 -0
- swordfish/asset/tzdb/America/Juneau +0 -0
- swordfish/asset/tzdb/America/Kentucky/Louisville +0 -0
- swordfish/asset/tzdb/America/Kentucky/Monticello +0 -0
- swordfish/asset/tzdb/America/Knox_IN +0 -0
- swordfish/asset/tzdb/America/Kralendijk +0 -0
- swordfish/asset/tzdb/America/La_Paz +0 -0
- swordfish/asset/tzdb/America/Lima +0 -0
- swordfish/asset/tzdb/America/Los_Angeles +0 -0
- swordfish/asset/tzdb/America/Louisville +0 -0
- swordfish/asset/tzdb/America/Lower_Princes +0 -0
- swordfish/asset/tzdb/America/Maceio +0 -0
- swordfish/asset/tzdb/America/Managua +0 -0
- swordfish/asset/tzdb/America/Manaus +0 -0
- swordfish/asset/tzdb/America/Marigot +0 -0
- swordfish/asset/tzdb/America/Martinique +0 -0
- swordfish/asset/tzdb/America/Matamoros +0 -0
- swordfish/asset/tzdb/America/Mazatlan +0 -0
- swordfish/asset/tzdb/America/Mendoza +0 -0
- swordfish/asset/tzdb/America/Menominee +0 -0
- swordfish/asset/tzdb/America/Merida +0 -0
- swordfish/asset/tzdb/America/Metlakatla +0 -0
- swordfish/asset/tzdb/America/Mexico_City +0 -0
- swordfish/asset/tzdb/America/Miquelon +0 -0
- swordfish/asset/tzdb/America/Moncton +0 -0
- swordfish/asset/tzdb/America/Monterrey +0 -0
- swordfish/asset/tzdb/America/Montevideo +0 -0
- swordfish/asset/tzdb/America/Montreal +0 -0
- swordfish/asset/tzdb/America/Montserrat +0 -0
- swordfish/asset/tzdb/America/Nassau +0 -0
- swordfish/asset/tzdb/America/New_York +0 -0
- swordfish/asset/tzdb/America/Nipigon +0 -0
- swordfish/asset/tzdb/America/Nome +0 -0
- swordfish/asset/tzdb/America/Noronha +0 -0
- swordfish/asset/tzdb/America/North_Dakota/Beulah +0 -0
- swordfish/asset/tzdb/America/North_Dakota/Center +0 -0
- swordfish/asset/tzdb/America/North_Dakota/New_Salem +0 -0
- swordfish/asset/tzdb/America/Ojinaga +0 -0
- swordfish/asset/tzdb/America/Panama +0 -0
- swordfish/asset/tzdb/America/Pangnirtung +0 -0
- swordfish/asset/tzdb/America/Paramaribo +0 -0
- swordfish/asset/tzdb/America/Phoenix +0 -0
- swordfish/asset/tzdb/America/Port-au-Prince +0 -0
- swordfish/asset/tzdb/America/Port_of_Spain +0 -0
- swordfish/asset/tzdb/America/Porto_Acre +0 -0
- swordfish/asset/tzdb/America/Porto_Velho +0 -0
- swordfish/asset/tzdb/America/Puerto_Rico +0 -0
- swordfish/asset/tzdb/America/Punta_Arenas +0 -0
- swordfish/asset/tzdb/America/Rainy_River +0 -0
- swordfish/asset/tzdb/America/Rankin_Inlet +0 -0
- swordfish/asset/tzdb/America/Recife +0 -0
- swordfish/asset/tzdb/America/Regina +0 -0
- swordfish/asset/tzdb/America/Resolute +0 -0
- swordfish/asset/tzdb/America/Rio_Branco +0 -0
- swordfish/asset/tzdb/America/Rosario +0 -0
- swordfish/asset/tzdb/America/Santa_Isabel +0 -0
- swordfish/asset/tzdb/America/Santarem +0 -0
- swordfish/asset/tzdb/America/Santiago +0 -0
- swordfish/asset/tzdb/America/Santo_Domingo +0 -0
- swordfish/asset/tzdb/America/Sao_Paulo +0 -0
- swordfish/asset/tzdb/America/Scoresbysund +0 -0
- swordfish/asset/tzdb/America/Shiprock +0 -0
- swordfish/asset/tzdb/America/Sitka +0 -0
- swordfish/asset/tzdb/America/St_Barthelemy +0 -0
- swordfish/asset/tzdb/America/St_Johns +0 -0
- swordfish/asset/tzdb/America/St_Kitts +0 -0
- swordfish/asset/tzdb/America/St_Lucia +0 -0
- swordfish/asset/tzdb/America/St_Thomas +0 -0
- swordfish/asset/tzdb/America/St_Vincent +0 -0
- swordfish/asset/tzdb/America/Swift_Current +0 -0
- swordfish/asset/tzdb/America/Tegucigalpa +0 -0
- swordfish/asset/tzdb/America/Thule +0 -0
- swordfish/asset/tzdb/America/Thunder_Bay +0 -0
- swordfish/asset/tzdb/America/Tijuana +0 -0
- swordfish/asset/tzdb/America/Toronto +0 -0
- swordfish/asset/tzdb/America/Tortola +0 -0
- swordfish/asset/tzdb/America/Vancouver +0 -0
- swordfish/asset/tzdb/America/Virgin +0 -0
- swordfish/asset/tzdb/America/Whitehorse +0 -0
- swordfish/asset/tzdb/America/Winnipeg +0 -0
- swordfish/asset/tzdb/America/Yakutat +0 -0
- swordfish/asset/tzdb/America/Yellowknife +0 -0
- swordfish/asset/tzdb/Antarctica/Casey +0 -0
- swordfish/asset/tzdb/Antarctica/Davis +0 -0
- swordfish/asset/tzdb/Antarctica/DumontDUrville +0 -0
- swordfish/asset/tzdb/Antarctica/Macquarie +0 -0
- swordfish/asset/tzdb/Antarctica/Mawson +0 -0
- swordfish/asset/tzdb/Antarctica/McMurdo +0 -0
- swordfish/asset/tzdb/Antarctica/Palmer +0 -0
- swordfish/asset/tzdb/Antarctica/Rothera +0 -0
- swordfish/asset/tzdb/Antarctica/South_Pole +0 -0
- swordfish/asset/tzdb/Antarctica/Syowa +0 -0
- swordfish/asset/tzdb/Antarctica/Troll +0 -0
- swordfish/asset/tzdb/Antarctica/Vostok +0 -0
- swordfish/asset/tzdb/Arctic/Longyearbyen +0 -0
- swordfish/asset/tzdb/Asia/Aden +0 -0
- swordfish/asset/tzdb/Asia/Almaty +0 -0
- swordfish/asset/tzdb/Asia/Amman +0 -0
- swordfish/asset/tzdb/Asia/Anadyr +0 -0
- swordfish/asset/tzdb/Asia/Aqtau +0 -0
- swordfish/asset/tzdb/Asia/Aqtobe +0 -0
- swordfish/asset/tzdb/Asia/Ashgabat +0 -0
- swordfish/asset/tzdb/Asia/Ashkhabad +0 -0
- swordfish/asset/tzdb/Asia/Atyrau +0 -0
- swordfish/asset/tzdb/Asia/Baghdad +0 -0
- swordfish/asset/tzdb/Asia/Bahrain +0 -0
- swordfish/asset/tzdb/Asia/Baku +0 -0
- swordfish/asset/tzdb/Asia/Bangkok +0 -0
- swordfish/asset/tzdb/Asia/Barnaul +0 -0
- swordfish/asset/tzdb/Asia/Beirut +0 -0
- swordfish/asset/tzdb/Asia/Bishkek +0 -0
- swordfish/asset/tzdb/Asia/Brunei +0 -0
- swordfish/asset/tzdb/Asia/Calcutta +0 -0
- swordfish/asset/tzdb/Asia/Chita +0 -0
- swordfish/asset/tzdb/Asia/Choibalsan +0 -0
- swordfish/asset/tzdb/Asia/Chongqing +0 -0
- swordfish/asset/tzdb/Asia/Chungking +0 -0
- swordfish/asset/tzdb/Asia/Colombo +0 -0
- swordfish/asset/tzdb/Asia/Dacca +0 -0
- swordfish/asset/tzdb/Asia/Damascus +0 -0
- swordfish/asset/tzdb/Asia/Dhaka +0 -0
- swordfish/asset/tzdb/Asia/Dili +0 -0
- swordfish/asset/tzdb/Asia/Dubai +0 -0
- swordfish/asset/tzdb/Asia/Dushanbe +0 -0
- swordfish/asset/tzdb/Asia/Famagusta +0 -0
- swordfish/asset/tzdb/Asia/Gaza +0 -0
- swordfish/asset/tzdb/Asia/Harbin +0 -0
- swordfish/asset/tzdb/Asia/Hebron +0 -0
- swordfish/asset/tzdb/Asia/Ho_Chi_Minh +0 -0
- swordfish/asset/tzdb/Asia/Hong_Kong +0 -0
- swordfish/asset/tzdb/Asia/Hovd +0 -0
- swordfish/asset/tzdb/Asia/Irkutsk +0 -0
- swordfish/asset/tzdb/Asia/Istanbul +0 -0
- swordfish/asset/tzdb/Asia/Jakarta +0 -0
- swordfish/asset/tzdb/Asia/Jayapura +0 -0
- swordfish/asset/tzdb/Asia/Jerusalem +0 -0
- swordfish/asset/tzdb/Asia/Kabul +0 -0
- swordfish/asset/tzdb/Asia/Kamchatka +0 -0
- swordfish/asset/tzdb/Asia/Karachi +0 -0
- swordfish/asset/tzdb/Asia/Kashgar +0 -0
- swordfish/asset/tzdb/Asia/Kathmandu +0 -0
- swordfish/asset/tzdb/Asia/Katmandu +0 -0
- swordfish/asset/tzdb/Asia/Khandyga +0 -0
- swordfish/asset/tzdb/Asia/Kolkata +0 -0
- swordfish/asset/tzdb/Asia/Krasnoyarsk +0 -0
- swordfish/asset/tzdb/Asia/Kuala_Lumpur +0 -0
- swordfish/asset/tzdb/Asia/Kuching +0 -0
- swordfish/asset/tzdb/Asia/Kuwait +0 -0
- swordfish/asset/tzdb/Asia/Macao +0 -0
- swordfish/asset/tzdb/Asia/Macau +0 -0
- swordfish/asset/tzdb/Asia/Magadan +0 -0
- swordfish/asset/tzdb/Asia/Makassar +0 -0
- swordfish/asset/tzdb/Asia/Manila +0 -0
- swordfish/asset/tzdb/Asia/Muscat +0 -0
- swordfish/asset/tzdb/Asia/Nicosia +0 -0
- swordfish/asset/tzdb/Asia/Novokuznetsk +0 -0
- swordfish/asset/tzdb/Asia/Novosibirsk +0 -0
- swordfish/asset/tzdb/Asia/Omsk +0 -0
- swordfish/asset/tzdb/Asia/Oral +0 -0
- swordfish/asset/tzdb/Asia/Phnom_Penh +0 -0
- swordfish/asset/tzdb/Asia/Pontianak +0 -0
- swordfish/asset/tzdb/Asia/Pyongyang +0 -0
- swordfish/asset/tzdb/Asia/Qatar +0 -0
- swordfish/asset/tzdb/Asia/Qyzylorda +0 -0
- swordfish/asset/tzdb/Asia/Rangoon +0 -0
- swordfish/asset/tzdb/Asia/Riyadh +0 -0
- swordfish/asset/tzdb/Asia/Saigon +0 -0
- swordfish/asset/tzdb/Asia/Sakhalin +0 -0
- swordfish/asset/tzdb/Asia/Samarkand +0 -0
- swordfish/asset/tzdb/Asia/Seoul +0 -0
- swordfish/asset/tzdb/Asia/Shanghai +0 -0
- swordfish/asset/tzdb/Asia/Singapore +0 -0
- swordfish/asset/tzdb/Asia/Srednekolymsk +0 -0
- swordfish/asset/tzdb/Asia/Taipei +0 -0
- swordfish/asset/tzdb/Asia/Tashkent +0 -0
- swordfish/asset/tzdb/Asia/Tbilisi +0 -0
- swordfish/asset/tzdb/Asia/Tehran +0 -0
- swordfish/asset/tzdb/Asia/Tel_Aviv +0 -0
- swordfish/asset/tzdb/Asia/Thimbu +0 -0
- swordfish/asset/tzdb/Asia/Thimphu +0 -0
- swordfish/asset/tzdb/Asia/Tokyo +0 -0
- swordfish/asset/tzdb/Asia/Tomsk +0 -0
- swordfish/asset/tzdb/Asia/Ujung_Pandang +0 -0
- swordfish/asset/tzdb/Asia/Ulaanbaatar +0 -0
- swordfish/asset/tzdb/Asia/Ulan_Bator +0 -0
- swordfish/asset/tzdb/Asia/Urumqi +0 -0
- swordfish/asset/tzdb/Asia/Ust-Nera +0 -0
- swordfish/asset/tzdb/Asia/Vientiane +0 -0
- swordfish/asset/tzdb/Asia/Vladivostok +0 -0
- swordfish/asset/tzdb/Asia/Yakutsk +0 -0
- swordfish/asset/tzdb/Asia/Yangon +0 -0
- swordfish/asset/tzdb/Asia/Yekaterinburg +0 -0
- swordfish/asset/tzdb/Asia/Yerevan +0 -0
- swordfish/asset/tzdb/Atlantic/Azores +0 -0
- swordfish/asset/tzdb/Atlantic/Bermuda +0 -0
- swordfish/asset/tzdb/Atlantic/Canary +0 -0
- swordfish/asset/tzdb/Atlantic/Cape_Verde +0 -0
- swordfish/asset/tzdb/Atlantic/Faeroe +0 -0
- swordfish/asset/tzdb/Atlantic/Faroe +0 -0
- swordfish/asset/tzdb/Atlantic/Jan_Mayen +0 -0
- swordfish/asset/tzdb/Atlantic/Madeira +0 -0
- swordfish/asset/tzdb/Atlantic/Reykjavik +0 -0
- swordfish/asset/tzdb/Atlantic/South_Georgia +0 -0
- swordfish/asset/tzdb/Atlantic/St_Helena +0 -0
- swordfish/asset/tzdb/Atlantic/Stanley +0 -0
- swordfish/asset/tzdb/Australia/ACT +0 -0
- swordfish/asset/tzdb/Australia/Adelaide +0 -0
- swordfish/asset/tzdb/Australia/Brisbane +0 -0
- swordfish/asset/tzdb/Australia/Broken_Hill +0 -0
- swordfish/asset/tzdb/Australia/Canberra +0 -0
- swordfish/asset/tzdb/Australia/Currie +0 -0
- swordfish/asset/tzdb/Australia/Darwin +0 -0
- swordfish/asset/tzdb/Australia/Eucla +0 -0
- swordfish/asset/tzdb/Australia/Hobart +0 -0
- swordfish/asset/tzdb/Australia/LHI +0 -0
- swordfish/asset/tzdb/Australia/Lindeman +0 -0
- swordfish/asset/tzdb/Australia/Lord_Howe +0 -0
- swordfish/asset/tzdb/Australia/Melbourne +0 -0
- swordfish/asset/tzdb/Australia/NSW +0 -0
- swordfish/asset/tzdb/Australia/North +0 -0
- swordfish/asset/tzdb/Australia/Perth +0 -0
- swordfish/asset/tzdb/Australia/Queensland +0 -0
- swordfish/asset/tzdb/Australia/South +0 -0
- swordfish/asset/tzdb/Australia/Sydney +0 -0
- swordfish/asset/tzdb/Australia/Tasmania +0 -0
- swordfish/asset/tzdb/Australia/Victoria +0 -0
- swordfish/asset/tzdb/Australia/West +0 -0
- swordfish/asset/tzdb/Australia/Yancowinna +0 -0
- swordfish/asset/tzdb/Brazil/Acre +0 -0
- swordfish/asset/tzdb/Brazil/DeNoronha +0 -0
- swordfish/asset/tzdb/Brazil/East +0 -0
- swordfish/asset/tzdb/Brazil/West +0 -0
- swordfish/asset/tzdb/CET +0 -0
- swordfish/asset/tzdb/CST6CDT +0 -0
- swordfish/asset/tzdb/Canada/Atlantic +0 -0
- swordfish/asset/tzdb/Canada/Central +0 -0
- swordfish/asset/tzdb/Canada/Eastern +0 -0
- swordfish/asset/tzdb/Canada/Mountain +0 -0
- swordfish/asset/tzdb/Canada/Newfoundland +0 -0
- swordfish/asset/tzdb/Canada/Pacific +0 -0
- swordfish/asset/tzdb/Canada/Saskatchewan +0 -0
- swordfish/asset/tzdb/Canada/Yukon +0 -0
- swordfish/asset/tzdb/Chile/Continental +0 -0
- swordfish/asset/tzdb/Chile/EasterIsland +0 -0
- swordfish/asset/tzdb/Cuba +0 -0
- swordfish/asset/tzdb/EET +0 -0
- swordfish/asset/tzdb/EST +0 -0
- swordfish/asset/tzdb/EST5EDT +0 -0
- swordfish/asset/tzdb/Egypt +0 -0
- swordfish/asset/tzdb/Eire +0 -0
- swordfish/asset/tzdb/Etc/GMT +0 -0
- swordfish/asset/tzdb/Etc/GMT+0 +0 -0
- swordfish/asset/tzdb/Etc/GMT+1 +0 -0
- swordfish/asset/tzdb/Etc/GMT+10 +0 -0
- swordfish/asset/tzdb/Etc/GMT+11 +0 -0
- swordfish/asset/tzdb/Etc/GMT+12 +0 -0
- swordfish/asset/tzdb/Etc/GMT+2 +0 -0
- swordfish/asset/tzdb/Etc/GMT+3 +0 -0
- swordfish/asset/tzdb/Etc/GMT+4 +0 -0
- swordfish/asset/tzdb/Etc/GMT+5 +0 -0
- swordfish/asset/tzdb/Etc/GMT+6 +0 -0
- swordfish/asset/tzdb/Etc/GMT+7 +0 -0
- swordfish/asset/tzdb/Etc/GMT+8 +0 -0
- swordfish/asset/tzdb/Etc/GMT+9 +0 -0
- swordfish/asset/tzdb/Etc/GMT-0 +0 -0
- swordfish/asset/tzdb/Etc/GMT-1 +0 -0
- swordfish/asset/tzdb/Etc/GMT-10 +0 -0
- swordfish/asset/tzdb/Etc/GMT-11 +0 -0
- swordfish/asset/tzdb/Etc/GMT-12 +0 -0
- swordfish/asset/tzdb/Etc/GMT-13 +0 -0
- swordfish/asset/tzdb/Etc/GMT-14 +0 -0
- swordfish/asset/tzdb/Etc/GMT-2 +0 -0
- swordfish/asset/tzdb/Etc/GMT-3 +0 -0
- swordfish/asset/tzdb/Etc/GMT-4 +0 -0
- swordfish/asset/tzdb/Etc/GMT-5 +0 -0
- swordfish/asset/tzdb/Etc/GMT-6 +0 -0
- swordfish/asset/tzdb/Etc/GMT-7 +0 -0
- swordfish/asset/tzdb/Etc/GMT-8 +0 -0
- swordfish/asset/tzdb/Etc/GMT-9 +0 -0
- swordfish/asset/tzdb/Etc/GMT0 +0 -0
- swordfish/asset/tzdb/Etc/Greenwich +0 -0
- swordfish/asset/tzdb/Etc/UCT +0 -0
- swordfish/asset/tzdb/Etc/UTC +0 -0
- swordfish/asset/tzdb/Etc/Universal +0 -0
- swordfish/asset/tzdb/Etc/Zulu +0 -0
- swordfish/asset/tzdb/Europe/Amsterdam +0 -0
- swordfish/asset/tzdb/Europe/Andorra +0 -0
- swordfish/asset/tzdb/Europe/Astrakhan +0 -0
- swordfish/asset/tzdb/Europe/Athens +0 -0
- swordfish/asset/tzdb/Europe/Belfast +0 -0
- swordfish/asset/tzdb/Europe/Belgrade +0 -0
- swordfish/asset/tzdb/Europe/Berlin +0 -0
- swordfish/asset/tzdb/Europe/Bratislava +0 -0
- swordfish/asset/tzdb/Europe/Brussels +0 -0
- swordfish/asset/tzdb/Europe/Bucharest +0 -0
- swordfish/asset/tzdb/Europe/Budapest +0 -0
- swordfish/asset/tzdb/Europe/Busingen +0 -0
- swordfish/asset/tzdb/Europe/Chisinau +0 -0
- swordfish/asset/tzdb/Europe/Copenhagen +0 -0
- swordfish/asset/tzdb/Europe/Dublin +0 -0
- swordfish/asset/tzdb/Europe/Gibraltar +0 -0
- swordfish/asset/tzdb/Europe/Guernsey +0 -0
- swordfish/asset/tzdb/Europe/Helsinki +0 -0
- swordfish/asset/tzdb/Europe/Isle_of_Man +0 -0
- swordfish/asset/tzdb/Europe/Istanbul +0 -0
- swordfish/asset/tzdb/Europe/Jersey +0 -0
- swordfish/asset/tzdb/Europe/Kaliningrad +0 -0
- swordfish/asset/tzdb/Europe/Kiev +0 -0
- swordfish/asset/tzdb/Europe/Kirov +0 -0
- swordfish/asset/tzdb/Europe/Lisbon +0 -0
- swordfish/asset/tzdb/Europe/Ljubljana +0 -0
- swordfish/asset/tzdb/Europe/London +0 -0
- swordfish/asset/tzdb/Europe/Luxembourg +0 -0
- swordfish/asset/tzdb/Europe/Madrid +0 -0
- swordfish/asset/tzdb/Europe/Malta +0 -0
- swordfish/asset/tzdb/Europe/Mariehamn +0 -0
- swordfish/asset/tzdb/Europe/Minsk +0 -0
- swordfish/asset/tzdb/Europe/Monaco +0 -0
- swordfish/asset/tzdb/Europe/Moscow +0 -0
- swordfish/asset/tzdb/Europe/Nicosia +0 -0
- swordfish/asset/tzdb/Europe/Oslo +0 -0
- swordfish/asset/tzdb/Europe/Paris +0 -0
- swordfish/asset/tzdb/Europe/Podgorica +0 -0
- swordfish/asset/tzdb/Europe/Prague +0 -0
- swordfish/asset/tzdb/Europe/Riga +0 -0
- swordfish/asset/tzdb/Europe/Rome +0 -0
- swordfish/asset/tzdb/Europe/Samara +0 -0
- swordfish/asset/tzdb/Europe/San_Marino +0 -0
- swordfish/asset/tzdb/Europe/Sarajevo +0 -0
- swordfish/asset/tzdb/Europe/Saratov +0 -0
- swordfish/asset/tzdb/Europe/Simferopol +0 -0
- swordfish/asset/tzdb/Europe/Skopje +0 -0
- swordfish/asset/tzdb/Europe/Sofia +0 -0
- swordfish/asset/tzdb/Europe/Stockholm +0 -0
- swordfish/asset/tzdb/Europe/Tallinn +0 -0
- swordfish/asset/tzdb/Europe/Tirane +0 -0
- swordfish/asset/tzdb/Europe/Tiraspol +0 -0
- swordfish/asset/tzdb/Europe/Ulyanovsk +0 -0
- swordfish/asset/tzdb/Europe/Uzhgorod +0 -0
- swordfish/asset/tzdb/Europe/Vaduz +0 -0
- swordfish/asset/tzdb/Europe/Vatican +0 -0
- swordfish/asset/tzdb/Europe/Vienna +0 -0
- swordfish/asset/tzdb/Europe/Vilnius +0 -0
- swordfish/asset/tzdb/Europe/Volgograd +0 -0
- swordfish/asset/tzdb/Europe/Warsaw +0 -0
- swordfish/asset/tzdb/Europe/Zagreb +0 -0
- swordfish/asset/tzdb/Europe/Zaporozhye +0 -0
- swordfish/asset/tzdb/Europe/Zurich +0 -0
- swordfish/asset/tzdb/Factory +0 -0
- swordfish/asset/tzdb/GB +0 -0
- swordfish/asset/tzdb/GB-Eire +0 -0
- swordfish/asset/tzdb/GMT +0 -0
- swordfish/asset/tzdb/GMT+0 +0 -0
- swordfish/asset/tzdb/GMT-0 +0 -0
- swordfish/asset/tzdb/GMT0 +0 -0
- swordfish/asset/tzdb/Greenwich +0 -0
- swordfish/asset/tzdb/HST +0 -0
- swordfish/asset/tzdb/Hongkong +0 -0
- swordfish/asset/tzdb/Iceland +0 -0
- swordfish/asset/tzdb/Indian/Antananarivo +0 -0
- swordfish/asset/tzdb/Indian/Chagos +0 -0
- swordfish/asset/tzdb/Indian/Christmas +0 -0
- swordfish/asset/tzdb/Indian/Cocos +0 -0
- swordfish/asset/tzdb/Indian/Comoro +0 -0
- swordfish/asset/tzdb/Indian/Kerguelen +0 -0
- swordfish/asset/tzdb/Indian/Mahe +0 -0
- swordfish/asset/tzdb/Indian/Maldives +0 -0
- swordfish/asset/tzdb/Indian/Mauritius +0 -0
- swordfish/asset/tzdb/Indian/Mayotte +0 -0
- swordfish/asset/tzdb/Indian/Reunion +0 -0
- swordfish/asset/tzdb/Iran +0 -0
- swordfish/asset/tzdb/Israel +0 -0
- swordfish/asset/tzdb/Jamaica +0 -0
- swordfish/asset/tzdb/Japan +0 -0
- swordfish/asset/tzdb/Kwajalein +0 -0
- swordfish/asset/tzdb/Libya +0 -0
- swordfish/asset/tzdb/MET +0 -0
- swordfish/asset/tzdb/MST +0 -0
- swordfish/asset/tzdb/MST7MDT +0 -0
- swordfish/asset/tzdb/Mexico/BajaNorte +0 -0
- swordfish/asset/tzdb/Mexico/BajaSur +0 -0
- swordfish/asset/tzdb/Mexico/General +0 -0
- swordfish/asset/tzdb/NZ +0 -0
- swordfish/asset/tzdb/NZ-CHAT +0 -0
- swordfish/asset/tzdb/Navajo +0 -0
- swordfish/asset/tzdb/PRC +0 -0
- swordfish/asset/tzdb/PST8PDT +0 -0
- swordfish/asset/tzdb/Pacific/Apia +0 -0
- swordfish/asset/tzdb/Pacific/Auckland +0 -0
- swordfish/asset/tzdb/Pacific/Bougainville +0 -0
- swordfish/asset/tzdb/Pacific/Chatham +0 -0
- swordfish/asset/tzdb/Pacific/Chuuk +0 -0
- swordfish/asset/tzdb/Pacific/Easter +0 -0
- swordfish/asset/tzdb/Pacific/Efate +0 -0
- swordfish/asset/tzdb/Pacific/Enderbury +0 -0
- swordfish/asset/tzdb/Pacific/Fakaofo +0 -0
- swordfish/asset/tzdb/Pacific/Fiji +0 -0
- swordfish/asset/tzdb/Pacific/Funafuti +0 -0
- swordfish/asset/tzdb/Pacific/Galapagos +0 -0
- swordfish/asset/tzdb/Pacific/Gambier +0 -0
- swordfish/asset/tzdb/Pacific/Guadalcanal +0 -0
- swordfish/asset/tzdb/Pacific/Guam +0 -0
- swordfish/asset/tzdb/Pacific/Honolulu +0 -0
- swordfish/asset/tzdb/Pacific/Johnston +0 -0
- swordfish/asset/tzdb/Pacific/Kiritimati +0 -0
- swordfish/asset/tzdb/Pacific/Kosrae +0 -0
- swordfish/asset/tzdb/Pacific/Kwajalein +0 -0
- swordfish/asset/tzdb/Pacific/Majuro +0 -0
- swordfish/asset/tzdb/Pacific/Marquesas +0 -0
- swordfish/asset/tzdb/Pacific/Midway +0 -0
- swordfish/asset/tzdb/Pacific/Nauru +0 -0
- swordfish/asset/tzdb/Pacific/Niue +0 -0
- swordfish/asset/tzdb/Pacific/Norfolk +0 -0
- swordfish/asset/tzdb/Pacific/Noumea +0 -0
- swordfish/asset/tzdb/Pacific/Pago_Pago +0 -0
- swordfish/asset/tzdb/Pacific/Palau +0 -0
- swordfish/asset/tzdb/Pacific/Pitcairn +0 -0
- swordfish/asset/tzdb/Pacific/Pohnpei +0 -0
- swordfish/asset/tzdb/Pacific/Ponape +0 -0
- swordfish/asset/tzdb/Pacific/Port_Moresby +0 -0
- swordfish/asset/tzdb/Pacific/Rarotonga +0 -0
- swordfish/asset/tzdb/Pacific/Saipan +0 -0
- swordfish/asset/tzdb/Pacific/Samoa +0 -0
- swordfish/asset/tzdb/Pacific/Tahiti +0 -0
- swordfish/asset/tzdb/Pacific/Tarawa +0 -0
- swordfish/asset/tzdb/Pacific/Tongatapu +0 -0
- swordfish/asset/tzdb/Pacific/Truk +0 -0
- swordfish/asset/tzdb/Pacific/Wake +0 -0
- swordfish/asset/tzdb/Pacific/Wallis +0 -0
- swordfish/asset/tzdb/Pacific/Yap +0 -0
- swordfish/asset/tzdb/Poland +0 -0
- swordfish/asset/tzdb/Portugal +0 -0
- swordfish/asset/tzdb/ROC +0 -0
- swordfish/asset/tzdb/ROK +0 -0
- swordfish/asset/tzdb/Singapore +0 -0
- swordfish/asset/tzdb/Turkey +0 -0
- swordfish/asset/tzdb/UCT +0 -0
- swordfish/asset/tzdb/US/Alaska +0 -0
- swordfish/asset/tzdb/US/Aleutian +0 -0
- swordfish/asset/tzdb/US/Arizona +0 -0
- swordfish/asset/tzdb/US/Central +0 -0
- swordfish/asset/tzdb/US/East-Indiana +0 -0
- swordfish/asset/tzdb/US/Eastern +0 -0
- swordfish/asset/tzdb/US/Hawaii +0 -0
- swordfish/asset/tzdb/US/Indiana-Starke +0 -0
- swordfish/asset/tzdb/US/Michigan +0 -0
- swordfish/asset/tzdb/US/Mountain +0 -0
- swordfish/asset/tzdb/US/Pacific +0 -0
- swordfish/asset/tzdb/US/Samoa +0 -0
- swordfish/asset/tzdb/UTC +0 -0
- swordfish/asset/tzdb/Universal +0 -0
- swordfish/asset/tzdb/W-SU +0 -0
- swordfish/asset/tzdb/WET +0 -0
- swordfish/asset/tzdb/Zulu +0 -0
- swordfish/asset/tzdb/iso3166.tab +274 -0
- swordfish/asset/tzdb/leapseconds +61 -0
- swordfish/asset/tzdb/posixrules +0 -0
- swordfish/asset/tzdb/tzdata.zi +4150 -0
- swordfish/asset/tzdb/tzmap_gen.py +27 -0
- swordfish/asset/tzdb/tzmapping +501 -0
- swordfish/asset/tzdb/windowsZones.xml +781 -0
- swordfish/asset/tzdb/zone.tab +448 -0
- swordfish/asset/tzdb/zone1970.tab +382 -0
- swordfish/connection.py +33 -0
- swordfish/data.py +806 -0
- swordfish/engine.py +28 -0
- swordfish/enums.py +32 -0
- swordfish/function.py +3 -0
- swordfish/infos.py +53 -0
- swordfish/io.py +11 -0
- swordfish/libSwordfish.dll +0 -0
- swordfish/libclucene-contribs-lib.dll +0 -0
- swordfish/libclucene-core.dll +0 -0
- swordfish/libclucene-shared.dll +0 -0
- swordfish/libgcc_s_seh-1.dll +0 -0
- swordfish/libstdc++-6.dll +0 -0
- swordfish/libwinpthread-1.dll +0 -0
- swordfish/module.py +57 -0
- swordfish/plugins/__init__.py +17 -0
- swordfish/plugins/backtest/__init__.py +38 -0
- swordfish/plugins/backtest/backtest.py +4228 -0
- swordfish/plugins/backtest/translator.py +820 -0
- swordfish/plugins/matching_engine_simulator.py +247 -0
- swordfish/streaming.py +19 -0
- swordfish/tools.py +71 -0
- swordfish/types.py +30 -0
swordfish/_translator.py
ADDED
|
@@ -0,0 +1,580 @@
|
|
|
1
|
+
import ast
|
|
2
|
+
import inspect
|
|
3
|
+
import uuid
|
|
4
|
+
import warnings
|
|
5
|
+
from enum import Enum
|
|
6
|
+
from types import FrameType, FunctionType
|
|
7
|
+
from typing import Any, Dict, List, Optional, Union
|
|
8
|
+
|
|
9
|
+
from ._swordfishcpp import (Constant, FunctionDef, Void, # type: ignore
|
|
10
|
+
check_builtin_function, check_is_nothing,
|
|
11
|
+
create_partial)
|
|
12
|
+
|
|
13
|
+
Nothing = Void.VOID_VALUE
|
|
14
|
+
DFLT = Void.DFLT_VALUE
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def _generate_name():
|
|
18
|
+
return f"TMP_TRS_{uuid.uuid4().hex[:8]}"
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class VariableMode(Enum):
|
|
22
|
+
PYTHON = 0
|
|
23
|
+
SWORDFISH = 1
|
|
24
|
+
FAKE = 2
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class Variable:
|
|
28
|
+
def __init__(self, data, mode: VariableMode) -> None:
|
|
29
|
+
self.data = data
|
|
30
|
+
self.mode = mode
|
|
31
|
+
|
|
32
|
+
def dot(self, o: str):
|
|
33
|
+
if self.mode == VariableMode.PYTHON:
|
|
34
|
+
return Variable(getattr(self.data, o), VariableMode.PYTHON)
|
|
35
|
+
elif self.mode == VariableMode.SWORDFISH:
|
|
36
|
+
return Variable(str(self.data) + f".{o}", VariableMode.SWORDFISH)
|
|
37
|
+
else:
|
|
38
|
+
raise ValueError("Invalid statement.")
|
|
39
|
+
|
|
40
|
+
def process(self, visitor):
|
|
41
|
+
if self.mode == VariableMode.PYTHON:
|
|
42
|
+
if isinstance(self.data, FunctionDef) and check_builtin_function(self.data):
|
|
43
|
+
return str(self.data)
|
|
44
|
+
return visitor.update_argvar(self)
|
|
45
|
+
return str(self.data)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class VariableFrame:
|
|
49
|
+
data: Dict[str, Variable]
|
|
50
|
+
|
|
51
|
+
def __init__(self, vars_dict: Dict[str, Any] = None):
|
|
52
|
+
self.data = dict()
|
|
53
|
+
if vars_dict:
|
|
54
|
+
for n, v in vars_dict.items():
|
|
55
|
+
self.data[n] = Variable(v, VariableMode.PYTHON)
|
|
56
|
+
|
|
57
|
+
def update(self, name: str, value: Variable):
|
|
58
|
+
self.data[name] = value
|
|
59
|
+
|
|
60
|
+
def find(self, name: str) -> Union[Variable, None]:
|
|
61
|
+
if name in self.data:
|
|
62
|
+
return self.data[name]
|
|
63
|
+
else:
|
|
64
|
+
return None
|
|
65
|
+
|
|
66
|
+
@classmethod
|
|
67
|
+
def createArgsFrame(cls, args: set):
|
|
68
|
+
frame = VariableFrame()
|
|
69
|
+
for arg in args:
|
|
70
|
+
frame.update(arg, Variable(arg, VariableMode.SWORDFISH))
|
|
71
|
+
return frame
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
class FrameStack:
|
|
75
|
+
stack: List[VariableFrame]
|
|
76
|
+
|
|
77
|
+
def __init__(self):
|
|
78
|
+
self.stack = []
|
|
79
|
+
|
|
80
|
+
def push(self, frame: Optional[VariableFrame] = None):
|
|
81
|
+
if frame:
|
|
82
|
+
self.stack.append(frame)
|
|
83
|
+
else:
|
|
84
|
+
self.stack.append(VariableFrame())
|
|
85
|
+
|
|
86
|
+
def pop(self):
|
|
87
|
+
self.stack.pop()
|
|
88
|
+
|
|
89
|
+
def add(self, name: str, value: Variable):
|
|
90
|
+
self.stack[-1].update(name, value)
|
|
91
|
+
|
|
92
|
+
def find(self, name: str) -> Union[Variable, None]:
|
|
93
|
+
for frame in reversed(self.stack):
|
|
94
|
+
res = frame.find(name)
|
|
95
|
+
if res:
|
|
96
|
+
return res
|
|
97
|
+
return None
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def process(data, visitor) -> str:
|
|
101
|
+
if isinstance(data, Variable):
|
|
102
|
+
return data.process(visitor)
|
|
103
|
+
return str(data)
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
class StandardVisitor(ast.NodeVisitor):
|
|
107
|
+
def __init__(self):
|
|
108
|
+
self.stack = FrameStack()
|
|
109
|
+
self.var_dict: Dict[str, Constant] = dict()
|
|
110
|
+
self.rev_dict: Dict[int, str] = dict()
|
|
111
|
+
|
|
112
|
+
def update_argvar(self, var: Variable):
|
|
113
|
+
if id(var.data) in self.rev_dict:
|
|
114
|
+
return self.rev_dict[id(var.data)]
|
|
115
|
+
name = _generate_name()
|
|
116
|
+
self.var_dict[name] = var.data
|
|
117
|
+
self.rev_dict[id(var.data)] = name
|
|
118
|
+
return name
|
|
119
|
+
|
|
120
|
+
def add_arguments(self, node: ast.arguments):
|
|
121
|
+
if node.posonlyargs:
|
|
122
|
+
raise ValueError("Unsupported position only arguments.")
|
|
123
|
+
if node.kwonlyargs or node.kw_defaults:
|
|
124
|
+
raise ValueError("Unsupported keyword only arguments.")
|
|
125
|
+
args = set([arg.arg for arg in node.args])
|
|
126
|
+
self.stack.push(VariableFrame.createArgsFrame(args))
|
|
127
|
+
|
|
128
|
+
def visit_arguments(self, node: ast.arguments):
|
|
129
|
+
if node.posonlyargs:
|
|
130
|
+
raise ValueError("Unsupported position only arguments.")
|
|
131
|
+
if node.kwonlyargs or node.kw_defaults:
|
|
132
|
+
raise ValueError("Unsupported keyword only arguments.")
|
|
133
|
+
all_args_len = len(node.args)
|
|
134
|
+
all_defaults_len = len(node.defaults)
|
|
135
|
+
index = 0
|
|
136
|
+
arg_statements = []
|
|
137
|
+
defaults = node.defaults
|
|
138
|
+
non_defaults = all_args_len - all_defaults_len
|
|
139
|
+
for arg in node.args:
|
|
140
|
+
if index < non_defaults:
|
|
141
|
+
arg_statements.append(arg.arg)
|
|
142
|
+
else:
|
|
143
|
+
arg_statements.append(f"{arg.arg} = {process(self.visit(defaults[index - non_defaults]), self)}")
|
|
144
|
+
index += 1
|
|
145
|
+
if not arg_statements:
|
|
146
|
+
return []
|
|
147
|
+
return arg_statements
|
|
148
|
+
|
|
149
|
+
def generic_visit(self, node):
|
|
150
|
+
raise ValueError(f"Unsupported {type(node)} in translate mode.")
|
|
151
|
+
|
|
152
|
+
def visit_Lambda(self, node: ast.Lambda):
|
|
153
|
+
statement_visitor = StandardVisitor()
|
|
154
|
+
statement_visitor.stack = self.stack
|
|
155
|
+
self.add_arguments(node.args)
|
|
156
|
+
self.stack.push()
|
|
157
|
+
args = statement_visitor.visit_arguments(node.args)
|
|
158
|
+
code = statement_visitor.visit(node.body)
|
|
159
|
+
vars_args = list(statement_visitor.var_dict.keys())
|
|
160
|
+
args_str = ",".join(vars_args + args)
|
|
161
|
+
function_code = f"""(defg ({args_str}): {code})"""
|
|
162
|
+
self.stack.pop()
|
|
163
|
+
self.stack.pop()
|
|
164
|
+
return function_code
|
|
165
|
+
|
|
166
|
+
def visit_Name(self, node: ast.Name):
|
|
167
|
+
if isinstance(node.ctx, ast.Load):
|
|
168
|
+
res = self.stack.find(node.id)
|
|
169
|
+
if res:
|
|
170
|
+
return res
|
|
171
|
+
else:
|
|
172
|
+
raise ValueError("The variable: " + node.id + " is undefined.")
|
|
173
|
+
elif isinstance(node.ctx, ast.Store):
|
|
174
|
+
var = Variable(node.id, VariableMode.SWORDFISH)
|
|
175
|
+
self.stack.add(node.id, var)
|
|
176
|
+
return var
|
|
177
|
+
else: # node.ctx == ast.Del()
|
|
178
|
+
raise ValueError("Unsupported delete statement.")
|
|
179
|
+
# return Variable(self, f"del {node.id}", VariableMode.DELETE)
|
|
180
|
+
|
|
181
|
+
def visit_Constant(self, node: ast.Constant):
|
|
182
|
+
value = node.value
|
|
183
|
+
if value is None:
|
|
184
|
+
return "NULL"
|
|
185
|
+
if isinstance(value, str):
|
|
186
|
+
chs = []
|
|
187
|
+
for ch in value:
|
|
188
|
+
if ch in ['"', "'"]:
|
|
189
|
+
chs.append("\\" + ch)
|
|
190
|
+
elif ch == "\\":
|
|
191
|
+
chs.append("\\\\")
|
|
192
|
+
else:
|
|
193
|
+
chs.append(ch)
|
|
194
|
+
return f'"{"".join(chs)}"'
|
|
195
|
+
if isinstance(value, bool):
|
|
196
|
+
return str(value).lower()
|
|
197
|
+
if isinstance(value, int):
|
|
198
|
+
return str(value)
|
|
199
|
+
if isinstance(value, float):
|
|
200
|
+
return str(value)
|
|
201
|
+
# bytes, complex, Ellipsis
|
|
202
|
+
raise RuntimeError(f"Unsupported Constant node: {value}")
|
|
203
|
+
|
|
204
|
+
def visit_Tuple(self, node: ast.Tuple):
|
|
205
|
+
sub_objs = []
|
|
206
|
+
for sub_node in node.elts:
|
|
207
|
+
sub_objs.append(process(self.visit(sub_node), self))
|
|
208
|
+
return f"({', '.join(sub_objs)})"
|
|
209
|
+
|
|
210
|
+
def visit_List(self, node: ast.List):
|
|
211
|
+
sub_objs = []
|
|
212
|
+
for sub_node in node.elts:
|
|
213
|
+
sub_objs.append(process(self.visit(sub_node), self))
|
|
214
|
+
return f"[{', '.join(sub_objs)}]"
|
|
215
|
+
|
|
216
|
+
def visit_Set(self, node: ast.Set):
|
|
217
|
+
sub_objs = []
|
|
218
|
+
for sub_node in node.elts:
|
|
219
|
+
sub_objs.append(process(self.visit(sub_node), self))
|
|
220
|
+
return f"set([{', '.join(sub_objs)}])"
|
|
221
|
+
|
|
222
|
+
def visit_Dict(self, node: ast.Dict):
|
|
223
|
+
key_objs = []
|
|
224
|
+
for key in node.keys:
|
|
225
|
+
key_objs.append(process(self.visit(key), self))
|
|
226
|
+
val_objs = []
|
|
227
|
+
for val in node.values:
|
|
228
|
+
val_objs.append(process(self.visit(val), self))
|
|
229
|
+
return f"dict([{', '.join(key_objs)}], [{', '.join(val_objs)}], false)"
|
|
230
|
+
|
|
231
|
+
def visit_Attribute(self, node: ast.Attribute):
|
|
232
|
+
attr: Variable = self.visit(node.value).dot(node.attr)
|
|
233
|
+
if isinstance(node.ctx, ast.Store):
|
|
234
|
+
if attr.mode == VariableMode.PYTHON:
|
|
235
|
+
raise ValueError("Unsupported attribute assign.")
|
|
236
|
+
return attr
|
|
237
|
+
|
|
238
|
+
def visit_Subscript(self, node: ast.Subscript):
|
|
239
|
+
value: Variable = self.visit(node.value)
|
|
240
|
+
if isinstance(node.ctx, ast.Store):
|
|
241
|
+
if value.mode == VariableMode.PYTHON:
|
|
242
|
+
raise ValueError("Unsupported subscript assign.")
|
|
243
|
+
slice = self.visit(node.slice)
|
|
244
|
+
return f"{process(value, self)}[{process(slice, self)}]"
|
|
245
|
+
|
|
246
|
+
def visit_Index(self, node: ast.Index) -> Any:
|
|
247
|
+
return self.visit(node.value)
|
|
248
|
+
|
|
249
|
+
def visit_ExtSlice(self, node: ast.ExtSlice) -> Any:
|
|
250
|
+
return ",".join([process(self.visit(dim), self) for dim in node.dims])
|
|
251
|
+
|
|
252
|
+
def visit_Slice(self, node: ast.Slice) -> Any:
|
|
253
|
+
lower = process(self.visit(node.lower), self) if node.lower else ""
|
|
254
|
+
upper = process(self.visit(node.upper), self) if node.upper else ""
|
|
255
|
+
if node.step:
|
|
256
|
+
raise ValueError("Unsupported step in Slice.")
|
|
257
|
+
return f"{lower}:{upper}"
|
|
258
|
+
|
|
259
|
+
def visit_Call(self, node: ast.Call):
|
|
260
|
+
func: Variable = self.visit(node.func)
|
|
261
|
+
func_str = ""
|
|
262
|
+
if func.mode == VariableMode.PYTHON:
|
|
263
|
+
if isinstance(func.data, Constant):
|
|
264
|
+
func_str = process(func, self)
|
|
265
|
+
else:
|
|
266
|
+
raise ValueError("Only support Constant in Call node.")
|
|
267
|
+
elif func.mode == VariableMode.SWORDFISH:
|
|
268
|
+
func_str = process(func, self)
|
|
269
|
+
else:
|
|
270
|
+
raise ValueError("Invalid variable mode.")
|
|
271
|
+
args = [process(self.visit(_arg), self) for _arg in node.args]
|
|
272
|
+
kwargs = [f"{k.arg}={process(self.visit(k.value), self)}" for k in node.keywords]
|
|
273
|
+
all_args = ",".join(args + kwargs)
|
|
274
|
+
return f"{func_str}({all_args})"
|
|
275
|
+
|
|
276
|
+
def visit_Assign(self, node: ast.Assign):
|
|
277
|
+
value_str = process(self.visit(node.value), self)
|
|
278
|
+
target_str: str = ""
|
|
279
|
+
for target in node.targets:
|
|
280
|
+
tmp_str: str
|
|
281
|
+
if isinstance(target, ast.Tuple):
|
|
282
|
+
tmp_str = ", ".join([process(self.visit(sub_node), self) for sub_node in target.elts])
|
|
283
|
+
elif isinstance(target, ast.Name):
|
|
284
|
+
tmp_str = process(self.visit_Name(target), self)
|
|
285
|
+
elif isinstance(target, ast.Subscript):
|
|
286
|
+
tmp_str = process(self.visit_Subscript(target), self)
|
|
287
|
+
else:
|
|
288
|
+
raise RuntimeError(f"Unsupported Assign node: {node}")
|
|
289
|
+
target_str += f"{tmp_str} = {value_str};\n"
|
|
290
|
+
return target_str
|
|
291
|
+
|
|
292
|
+
def visit_AugAssign(self, node: ast.AugAssign):
|
|
293
|
+
value_str = process(self.visit(node.value), self)
|
|
294
|
+
target_str = process(self.visit(node.target), self)
|
|
295
|
+
op_str = process(self.visit(node.op), self)
|
|
296
|
+
|
|
297
|
+
if isinstance(node.op, (ast.Mod, ast.Pow, ast.LShift, ast.RShift, ast.MatMult)):
|
|
298
|
+
return f"{target_str} = {target_str} {op_str} {value_str};\n"
|
|
299
|
+
|
|
300
|
+
return f"{target_str} {op_str}= {value_str};\n"
|
|
301
|
+
|
|
302
|
+
def visit_If(self, node: ast.If):
|
|
303
|
+
test = process(self.visit(node.test), self)
|
|
304
|
+
self.stack.push()
|
|
305
|
+
body = [process(self.visit(b), self) for b in node.body]
|
|
306
|
+
self.stack.pop()
|
|
307
|
+
orelse = [process(self.visit(o), self) for o in node.orelse]
|
|
308
|
+
return f"""
|
|
309
|
+
if ({test}) {{
|
|
310
|
+
{"".join(body)}
|
|
311
|
+
}}
|
|
312
|
+
else {{
|
|
313
|
+
{"".join(orelse)}
|
|
314
|
+
}}
|
|
315
|
+
"""
|
|
316
|
+
|
|
317
|
+
def visit_For(self, node: ast.For):
|
|
318
|
+
target: Variable = self.visit(node.target)
|
|
319
|
+
iter: Variable = self.visit(node.iter)
|
|
320
|
+
self.stack.push()
|
|
321
|
+
self.stack.add(process(target, self), target)
|
|
322
|
+
self.stack.push()
|
|
323
|
+
body = [process(self.visit(b), self) for b in node.body]
|
|
324
|
+
self.stack.pop()
|
|
325
|
+
if node.orelse:
|
|
326
|
+
raise ValueError("Unsupported for-else statement in For node.")
|
|
327
|
+
res = f"""
|
|
328
|
+
for ({process(target, self)} in {process(iter, self)}) {{
|
|
329
|
+
{"".join(body)}
|
|
330
|
+
}}
|
|
331
|
+
"""
|
|
332
|
+
self.stack.pop()
|
|
333
|
+
return res
|
|
334
|
+
|
|
335
|
+
def visit_While(self, node: ast.While):
|
|
336
|
+
test = self.visit(node.test)
|
|
337
|
+
self.stack.push()
|
|
338
|
+
body = [process(self.visit(b), self) for b in node.body]
|
|
339
|
+
if node.orelse:
|
|
340
|
+
raise ValueError("Unsupported for-else statement in While node.")
|
|
341
|
+
|
|
342
|
+
check_var = _generate_name()
|
|
343
|
+
res = f"""
|
|
344
|
+
{check_var} = true;
|
|
345
|
+
do {{
|
|
346
|
+
if ({check_var}) {{
|
|
347
|
+
{check_var} = false;
|
|
348
|
+
continue;
|
|
349
|
+
}}
|
|
350
|
+
{"".join(body)}
|
|
351
|
+
}}
|
|
352
|
+
while ({process(test, self)});
|
|
353
|
+
"""
|
|
354
|
+
self.stack.pop()
|
|
355
|
+
return res
|
|
356
|
+
|
|
357
|
+
def visit_Break(self, node: ast.Break):
|
|
358
|
+
return "break;\n"
|
|
359
|
+
|
|
360
|
+
def visit_Continue(self, node: ast.Continue):
|
|
361
|
+
return "continue;\n"
|
|
362
|
+
|
|
363
|
+
def visit_Return(self, node: ast.Return):
|
|
364
|
+
return f"return {process(self.visit(node.value), self)};"
|
|
365
|
+
|
|
366
|
+
def visit_Expr(self, node: ast.Expr):
|
|
367
|
+
if isinstance(node.value, ast.Name):
|
|
368
|
+
raise RuntimeError("Unsupported Expr node that only contain Name node.")
|
|
369
|
+
return process(self.visit(node.value), self) + ";\n"
|
|
370
|
+
|
|
371
|
+
def visit_IfExp(self, node: ast.IfExp):
|
|
372
|
+
return f"({process(self.visit(node.test), self)})?({process(self.visit(node.body), self)}):({process(self.visit(node.orelse), self)})"
|
|
373
|
+
|
|
374
|
+
def visit_Compare(self, node: ast.Compare):
|
|
375
|
+
left = process(self.visit(node.left), self)
|
|
376
|
+
ops = [self.visit(op) for op in node.ops]
|
|
377
|
+
comps = [process(self.visit(c), self) for c in node.comparators]
|
|
378
|
+
compare_str = left
|
|
379
|
+
for op, comp in zip(ops, comps):
|
|
380
|
+
compare_str += f" {op} {comp}"
|
|
381
|
+
return compare_str
|
|
382
|
+
|
|
383
|
+
def visit_BoolOp(self, node: ast.BoolOp):
|
|
384
|
+
op = self.visit(node.op)
|
|
385
|
+
values = [process(self.visit(value), self) for value in node.values]
|
|
386
|
+
return "(" + f" {op} ".join(values) + ")"
|
|
387
|
+
|
|
388
|
+
def visit_UnaryOp(self, node: ast.UnaryOp):
|
|
389
|
+
op = self.visit(node.op)
|
|
390
|
+
operand = self.visit(node.operand)
|
|
391
|
+
return f"({op} {process(operand, self)})"
|
|
392
|
+
|
|
393
|
+
def visit_BinOp(self, node: ast.BinOp):
|
|
394
|
+
L = process(self.visit(node.left), self)
|
|
395
|
+
R = process(self.visit(node.right), self)
|
|
396
|
+
op = self.visit(node.op)
|
|
397
|
+
return f"({L} {op} {R})"
|
|
398
|
+
|
|
399
|
+
# --------------------------------------
|
|
400
|
+
# --- cmpop
|
|
401
|
+
def visit_Eq(self, node: ast.Eq):
|
|
402
|
+
return "=="
|
|
403
|
+
|
|
404
|
+
def visit_Gt(self, node: ast.Gt):
|
|
405
|
+
return ">"
|
|
406
|
+
|
|
407
|
+
def visit_GtE(self, node: ast.GtE):
|
|
408
|
+
return ">="
|
|
409
|
+
|
|
410
|
+
def visit_In(self, node: ast.In):
|
|
411
|
+
return "in"
|
|
412
|
+
|
|
413
|
+
def visit_Is(self, node: ast.Is):
|
|
414
|
+
raise ValueError("Unsupported Is comparison.")
|
|
415
|
+
|
|
416
|
+
def visit_IsNot(self, node: ast.IsNot):
|
|
417
|
+
raise ValueError("Unsupported IsNot comparison.")
|
|
418
|
+
|
|
419
|
+
def visit_Lt(self, node: ast.Lt):
|
|
420
|
+
return "<"
|
|
421
|
+
|
|
422
|
+
def visit_LtE(self, node: ast.LtE):
|
|
423
|
+
return "<="
|
|
424
|
+
|
|
425
|
+
def visit_NotEq(self, node: ast.NotEq):
|
|
426
|
+
return "!="
|
|
427
|
+
|
|
428
|
+
def visit_NotIn(self, node: ast.NotIn):
|
|
429
|
+
raise ValueError("[] Unsupported NotIn comparison.")
|
|
430
|
+
|
|
431
|
+
# --------------------------------------
|
|
432
|
+
# --- boolOp
|
|
433
|
+
def visit_And(self, node: ast.And):
|
|
434
|
+
return "and"
|
|
435
|
+
|
|
436
|
+
def visit_Or(self, node: ast.Or):
|
|
437
|
+
return "or"
|
|
438
|
+
|
|
439
|
+
# --------------------------------------
|
|
440
|
+
# --- UnaryOp
|
|
441
|
+
def visit_Invert(self, node: ast.Invert):
|
|
442
|
+
return "bitNot"
|
|
443
|
+
|
|
444
|
+
def visit_Not(self, node: ast.Not):
|
|
445
|
+
return "!"
|
|
446
|
+
|
|
447
|
+
def visit_UAdd(self, node: ast.UAdd):
|
|
448
|
+
warnings.warn("UAdd operator has no corresponding syntax and will be ignored.")
|
|
449
|
+
return ""
|
|
450
|
+
|
|
451
|
+
def visit_USub(self, node: ast.USub):
|
|
452
|
+
return "-"
|
|
453
|
+
|
|
454
|
+
# --------------------------------------
|
|
455
|
+
# --- BinOp
|
|
456
|
+
def visit_Add(self, node: ast.Add):
|
|
457
|
+
return "+"
|
|
458
|
+
|
|
459
|
+
def visit_BitAnd(self, node: ast.BitAnd):
|
|
460
|
+
return "&"
|
|
461
|
+
|
|
462
|
+
def visit_BitOr(self, node: ast.BitOr):
|
|
463
|
+
return "|"
|
|
464
|
+
|
|
465
|
+
def visit_BitXor(self, node: ast.BitXor):
|
|
466
|
+
return "^"
|
|
467
|
+
|
|
468
|
+
def visit_Div(self, node: ast.Div):
|
|
469
|
+
# TODO: need check
|
|
470
|
+
return "\\"
|
|
471
|
+
|
|
472
|
+
def visit_FloorDiv(self, node: ast.FloorDiv):
|
|
473
|
+
return "/"
|
|
474
|
+
|
|
475
|
+
def visit_LShift(self, node: ast.LShift):
|
|
476
|
+
return "<<"
|
|
477
|
+
|
|
478
|
+
def visit_Mod(self, node: ast.Mod):
|
|
479
|
+
return "%"
|
|
480
|
+
|
|
481
|
+
def visit_Mult(self, node: ast.Mult):
|
|
482
|
+
return "*"
|
|
483
|
+
|
|
484
|
+
def visit_MatMult(self, node: ast.MatMult):
|
|
485
|
+
return "**"
|
|
486
|
+
|
|
487
|
+
def visit_Pow(self, node: ast.Pow):
|
|
488
|
+
return "pow"
|
|
489
|
+
|
|
490
|
+
def visit_RShift(self, node: ast.RShift):
|
|
491
|
+
return ">>"
|
|
492
|
+
|
|
493
|
+
def visit_Sub(self, node: ast.Sub):
|
|
494
|
+
return "-"
|
|
495
|
+
|
|
496
|
+
def visit_Pass(self, node: ast.Pass):
|
|
497
|
+
return "\n;\n;"
|
|
498
|
+
|
|
499
|
+
|
|
500
|
+
class StatementVisitor(StandardVisitor):
|
|
501
|
+
def __init__(self, func: FunctionType, frame: FrameType, is_state: bool = False):
|
|
502
|
+
super().__init__()
|
|
503
|
+
self.stack.push(VariableFrame(frame.f_globals))
|
|
504
|
+
self.stack.push(VariableFrame(frame.f_locals))
|
|
505
|
+
signature = inspect.signature(func)
|
|
506
|
+
params = set(signature.parameters.keys())
|
|
507
|
+
self.stack.push(VariableFrame.createArgsFrame(params))
|
|
508
|
+
self.is_state = is_state
|
|
509
|
+
|
|
510
|
+
def visit_Call(self, node: ast.Call):
|
|
511
|
+
func: Variable = self.visit(node.func)
|
|
512
|
+
func_str = ""
|
|
513
|
+
if func.mode == VariableMode.PYTHON:
|
|
514
|
+
if isinstance(func.data, Constant):
|
|
515
|
+
func_str = process(func, self)
|
|
516
|
+
else:
|
|
517
|
+
raise ValueError("Only support Constant in Call node.")
|
|
518
|
+
elif func.mode == VariableMode.SWORDFISH:
|
|
519
|
+
func_str = process(func, self)
|
|
520
|
+
else:
|
|
521
|
+
raise ValueError("Invalid variable mode.")
|
|
522
|
+
args = [process(self.visit(_arg), self) for _arg in node.args]
|
|
523
|
+
kwargs = [f"{k.arg}={process(self.visit(k.value), self)}" for k in node.keywords]
|
|
524
|
+
all_args = ",".join(args + kwargs)
|
|
525
|
+
if func.mode == VariableMode.PYTHON and self.is_state:
|
|
526
|
+
if check_builtin_function(func.data):
|
|
527
|
+
return f"{func_str}({all_args})"
|
|
528
|
+
if all_args:
|
|
529
|
+
return f"call({func_str}, {all_args})"
|
|
530
|
+
else:
|
|
531
|
+
return f"call({func_str})"
|
|
532
|
+
return f"{func_str}({all_args})"
|
|
533
|
+
|
|
534
|
+
def visit_IfExp(self, node: ast.IfExp):
|
|
535
|
+
if not self.is_state:
|
|
536
|
+
return f"({process(self.visit(node.test), self)})?({process(self.visit(node.body), self)}):({process(self.visit(node.orelse), self)})"
|
|
537
|
+
else:
|
|
538
|
+
return f"iif(({process(self.visit(node.test), self)}), {process(self.visit(node.body), self)}, {process(self.visit(node.orelse), self)})"
|
|
539
|
+
|
|
540
|
+
|
|
541
|
+
def _translate_wrapper(func: FunctionType, frame: FrameType, is_aggregation: bool = False, is_state: bool = False):
|
|
542
|
+
source_lines, line_nums = inspect.getsourcelines(func)
|
|
543
|
+
|
|
544
|
+
if source_lines:
|
|
545
|
+
s = source_lines[0]
|
|
546
|
+
if s.startswith(" "):
|
|
547
|
+
num_spaces = len(s) - len(s.lstrip(' '))
|
|
548
|
+
source_lines = [line[num_spaces:] for line in source_lines]
|
|
549
|
+
func_code = "".join(source_lines)
|
|
550
|
+
|
|
551
|
+
func_node = ast.parse(func_code).body[0]
|
|
552
|
+
|
|
553
|
+
statements = []
|
|
554
|
+
statement_visitor = StatementVisitor(func, frame, is_state=is_state)
|
|
555
|
+
args = statement_visitor.visit_arguments(func_node.args)
|
|
556
|
+
for statement in func_node.body:
|
|
557
|
+
code = statement_visitor.visit(statement)
|
|
558
|
+
statements.append(code)
|
|
559
|
+
|
|
560
|
+
vars_args = list(statement_visitor.var_dict.keys())
|
|
561
|
+
args_str = ",".join(vars_args + args)
|
|
562
|
+
|
|
563
|
+
function_body = "".join(statements)
|
|
564
|
+
function_head = "defg" if is_aggregation else "def"
|
|
565
|
+
function_code = f"""
|
|
566
|
+
{function_head} ({args_str}) {{
|
|
567
|
+
{function_body}
|
|
568
|
+
}}
|
|
569
|
+
"""
|
|
570
|
+
functiondef = FunctionDef(function_code, state=is_state)
|
|
571
|
+
args = list(statement_visitor.var_dict.values())
|
|
572
|
+
if args:
|
|
573
|
+
args = [DFLT if isinstance(arg, Constant) and check_is_nothing(arg) else arg for arg in args]
|
|
574
|
+
return create_partial(functiondef, *args)
|
|
575
|
+
return functiondef
|
|
576
|
+
|
|
577
|
+
|
|
578
|
+
__all__ = [
|
|
579
|
+
"_translate_wrapper",
|
|
580
|
+
]
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
def avgRunning(mysum, mycount): mysum\mycount
|
|
2
|
+
|
|
3
|
+
defg tval(x, w){
|
|
4
|
+
wavgX = wavg(x, w)
|
|
5
|
+
wavgX2 = wavg(x*x, w)
|
|
6
|
+
return wavgX/sqrt(wavgX2 - wavgX.square())
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
def wsum2(X,Y): wsum(X*X, Y)
|
|
10
|
+
|
|
11
|
+
defg tvalReduce(wsumX, wsumX2, w){
|
|
12
|
+
wavgX = wsumX.sum()\w.sum()
|
|
13
|
+
wavgX2 = wsumX2.sum\w.sum()
|
|
14
|
+
return wavgX/sqrt(wavgX2 - wavgX.square())
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
def tvalRunning(wsumX, wsumX2, w){
|
|
18
|
+
wavgX = wsumX\w
|
|
19
|
+
wavgX2 = wsumX2\w
|
|
20
|
+
return wavgX/sqrt(wavgX2 - wavgX.square())
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
mapr tval(x, w){wsum(x, w), wsum2(x, w), contextSum(w, x)->tvalReduce; cumsum, cumsum, cumsum->tvalRunning}
|
|
24
|
+
|
|
25
|
+
defg geometricMean(x){
|
|
26
|
+
return x.log().avg().exp()
|
|
27
|
+
}
|
|
28
|
+
def logAvg(x) : log(x).avg()
|
|
29
|
+
defg geometricMeanReduce(logAvgs, counts) : wavg(logAvgs, counts).exp()
|
|
30
|
+
def geometricMeanRunning(logAvgs, counts) : cumwavg(logAvgs, counts).exp()
|
|
31
|
+
|
|
32
|
+
mapr geometricMean(x){logAvg(x), count(x) -> geometricMeanReduce; copy, copy->geometricMeanRunning}
|
|
33
|
+
|
|
34
|
+
mapr distinct(x){distinct(x)->distinct}
|
|
35
|
+
mapr nunique(x){distinct(x)->nunique}
|
|
36
|
+
mapr nunique(x, ignoreNull){distinct(x), copy(ignoreNull)->nunique}
|
|
37
|
+
mapr sum(x){sum(x)->sum; cumsum}
|
|
38
|
+
mapr sum2(x){sum2(x)->sum; cumsum}
|
|
39
|
+
mapr sum3(x){sum3(x)->sum; cumsum}
|
|
40
|
+
mapr sum4(x){sum4(x)->sum; cumsum}
|
|
41
|
+
mapr prod(x){prod(x)->prod; cumprod}
|
|
42
|
+
mapr max(x){max(x)->max; cummax}
|
|
43
|
+
mapr min(x){min(x)->min; cummin}
|
|
44
|
+
mapr first(x){first(x)->first; first}
|
|
45
|
+
mapr last(x){last(x)->last; copy}
|
|
46
|
+
mapr firstNot(x){firstNot(x)->firstNot}
|
|
47
|
+
mapr firstNot(x, exclude){firstNot(x, exclude)->firstNot}
|
|
48
|
+
mapr lastNot(x){lastNot(x)->lastNot}
|
|
49
|
+
mapr lastNot(x, exclude){lastNot(x, exclude)->lastNot}
|
|
50
|
+
mapr count(x){count(x)->sum; cumsum}
|
|
51
|
+
mapr size(x){size(x)->sum; cumsum}
|
|
52
|
+
mapr avg(x){sum(x),count(x)->avgReduce; cumsum,cumsum->avgRunning}
|
|
53
|
+
mapr mean(x){sum(x),count(x)->avgReduce; cumsum,cumsum->avgRunning}
|
|
54
|
+
mapr std(x){sum(x),sum2(x),count(x)->stdReduce; cumsum,cumsum,cumsum->stdRunning}
|
|
55
|
+
mapr stdp(x){sum(x),sum2(x),count(x)->stdpReduce; cumsum,cumsum,cumsum->stdpRunning}
|
|
56
|
+
mapr var(x){sum(x),sum2(x),count(x)->varReduce; cumsum,cumsum,cumsum->varRunning}
|
|
57
|
+
mapr varp(x){sum(x),sum2(x),count(x)->varpReduce; cumsum,cumsum,cumsum->varpRunning}
|
|
58
|
+
mapr skew(x){sum(x),sum2(x),sum3(x),count(x)->skewReduce; cumsum,cumsum,cumsum,cumsum->skewRunning}
|
|
59
|
+
mapr skew(x, biased){sum(x),sum2(x),sum3(x),count(x),copy(biased)->skewReduce2; cumsum,cumsum,cumsum,cumsum,copy->skewRunning2}
|
|
60
|
+
mapr kurtosis(x){sum(x),sum2(x),sum3(x),sum4(x),count(x)->kurtosisReduce; cumsum,cumsum,cumsum,cumsum,cumsum->kurtosisRunning}
|
|
61
|
+
mapr kurtosis(x, biased){sum(x),sum2(x),sum3(x),sum4(x),count(x),copy(biased)->kurtosisReduce2; cumsum,cumsum,cumsum,cumsum,cumsum,copy->kurtosisRunning2}
|
|
62
|
+
mapr wsum(x,y){wsum(x,y)->sum; cumsum}
|
|
63
|
+
mapr contextCount(x,y){contextCount(x,y)->sum; cumsum}
|
|
64
|
+
mapr contextSum(x,y){contextSum(x,y)->sum; cumsum}
|
|
65
|
+
mapr contextSum2(x,y){contextSum2(x,y)->sum; cumsum}
|
|
66
|
+
mapr wavg(x,y){wavg(x,y),contextSum(y,x)->wavg; copy,copy->cumwavg}
|
|
67
|
+
mapr covar(x,y){wsum(x,y),contextSum(x,y),contextSum(y,x),contextCount(y,x)->covarReduce; cumsum,cumsum,cumsum,cumsum->covarRunning}
|
|
68
|
+
mapr cov(x,y){wsum(x,y),contextSum(x,y),contextSum(y,x),contextCount(y,x)->covarReduce; cumsum,cumsum,cumsum,cumsum->covarRunning}
|
|
69
|
+
mapr corr(x,y){wsum(x,y),contextSum2(x,y),contextSum(x,y),contextSum2(y,x),contextSum(y,x),contextCount(y,x)->corrReduce; cumsum,cumsum,cumsum,cumsum,cumsum,cumsum->corrRunning}
|
|
70
|
+
mapr atImax(x,y){max(x),atImax(x,y)->atImax}
|
|
71
|
+
mapr atImin(x,y){min(x),atImin(x,y)->atImin}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|