`_"""
-
- def __init__(self,
- backbone,
- neck,
- bbox_head,
- train_cfg=None,
- test_cfg=None,
- pretrained=None):
- super(RetinaNet, self).__init__(backbone, neck, bbox_head, train_cfg,
- test_cfg, pretrained)
diff --git a/spaces/Andy1621/uniformer_image_segmentation/configs/ocrnet/ocrnet_hr18s_512x1024_80k_cityscapes.py b/spaces/Andy1621/uniformer_image_segmentation/configs/ocrnet/ocrnet_hr18s_512x1024_80k_cityscapes.py
deleted file mode 100644
index be6bf16a2fd234f3526bf8fb8c30179f1ef9df78..0000000000000000000000000000000000000000
--- a/spaces/Andy1621/uniformer_image_segmentation/configs/ocrnet/ocrnet_hr18s_512x1024_80k_cityscapes.py
+++ /dev/null
@@ -1,9 +0,0 @@
-_base_ = './ocrnet_hr18_512x1024_80k_cityscapes.py'
-model = dict(
- pretrained='open-mmlab://msra/hrnetv2_w18_small',
- backbone=dict(
- extra=dict(
- stage1=dict(num_blocks=(2, )),
- stage2=dict(num_blocks=(2, 2)),
- stage3=dict(num_modules=3, num_blocks=(2, 2, 2)),
- stage4=dict(num_modules=2, num_blocks=(2, 2, 2, 2)))))
diff --git a/spaces/Andy1621/uniformer_image_segmentation/configs/pspnet/pspnet_r50-d8_512x512_20k_voc12aug.py b/spaces/Andy1621/uniformer_image_segmentation/configs/pspnet/pspnet_r50-d8_512x512_20k_voc12aug.py
deleted file mode 100644
index cd88154d5e0be1a519e973331e0a14ae8a7de13e..0000000000000000000000000000000000000000
--- a/spaces/Andy1621/uniformer_image_segmentation/configs/pspnet/pspnet_r50-d8_512x512_20k_voc12aug.py
+++ /dev/null
@@ -1,7 +0,0 @@
-_base_ = [
- '../_base_/models/pspnet_r50-d8.py',
- '../_base_/datasets/pascal_voc12_aug.py', '../_base_/default_runtime.py',
- '../_base_/schedules/schedule_20k.py'
-]
-model = dict(
- decode_head=dict(num_classes=21), auxiliary_head=dict(num_classes=21))
diff --git a/spaces/AnishKumbhar/ChatBot/text-generation-webui-main/css/NotoSans/stylesheet.css b/spaces/AnishKumbhar/ChatBot/text-generation-webui-main/css/NotoSans/stylesheet.css
deleted file mode 100644
index 467973b8eebd42a5ba50f4df0a07440b843a19cc..0000000000000000000000000000000000000000
--- a/spaces/AnishKumbhar/ChatBot/text-generation-webui-main/css/NotoSans/stylesheet.css
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
-Copied from https://github.com/SillyTavern/SillyTavern/tree/6c8bd06308c69d51e2eb174541792a870a83d2d6/public/webfonts/NotoSans
-*/
-
-@font-face {
- font-family: 'Noto Sans';
- src: url('file/css/NotoSans/NotoSans-Black.woff2') format('woff2'),
- url('file/css/NotoSans/NotoSans-Black.woff') format('woff');
- font-weight: 900;
- font-style: normal;
- font-display: swap;
-}
-
-@font-face {
- font-family: 'Noto Sans';
- src: url('file/css/NotoSans/NotoSans-ExtraBoldItalic.woff2') format('woff2'),
- url('file/css/NotoSans/NotoSans-ExtraBoldItalic.woff') format('woff');
- font-weight: bold;
- font-style: italic;
- font-display: swap;
-}
-
-@font-face {
- font-family: 'Noto Sans';
- src: url('file/css/NotoSans/NotoSans-BlackItalic.woff2') format('woff2'),
- url('file/css/NotoSans/NotoSans-BlackItalic.woff') format('woff');
- font-weight: 900;
- font-style: italic;
- font-display: swap;
-}
-
-@font-face {
- font-family: 'Noto Sans';
- src: url('file/css/NotoSans/NotoSans-ExtraBold.woff2') format('woff2'),
- url('file/css/NotoSans/NotoSans-ExtraBold.woff') format('woff');
- font-weight: bold;
- font-style: normal;
- font-display: swap;
-}
-
-@font-face {
- font-family: 'Noto Sans';
- src: url('file/css/NotoSans/NotoSans-ThinItalic.woff2') format('woff2'),
- url('file/css/NotoSans/NotoSans-ThinItalic.woff') format('woff');
- font-weight: 100;
- font-style: italic;
- font-display: swap;
-}
-
-@font-face {
- font-family: 'Noto Sans';
- src: url('file/css/NotoSans/NotoSans-BoldItalic.woff2') format('woff2'),
- url('file/css/NotoSans/NotoSans-BoldItalic.woff') format('woff');
- font-weight: bold;
- font-style: italic;
- font-display: swap;
-}
-
-@font-face {
- font-family: 'Noto Sans';
- src: url('file/css/NotoSans/NotoSans-Bold.woff2') format('woff2'),
- url('file/css/NotoSans/NotoSans-Bold.woff') format('woff');
- font-weight: bold;
- font-style: normal;
- font-display: swap;
-}
-
-@font-face {
- font-family: 'Noto Sans';
- src: url('file/css/NotoSans/NotoSans-LightItalic.woff2') format('woff2'),
- url('file/css/NotoSans/NotoSans-LightItalic.woff') format('woff');
- font-weight: 300;
- font-style: italic;
- font-display: swap;
-}
-
-@font-face {
- font-family: 'Noto Sans';
- src: url('file/css/NotoSans/NotoSans-Italic.woff2') format('woff2'),
- url('file/css/NotoSans/NotoSans-Italic.woff') format('woff');
- font-weight: normal;
- font-style: italic;
- font-display: swap;
-}
-
-@font-face {
- font-family: 'Noto Sans';
- src: url('file/css/NotoSans/NotoSans-ExtraLightItalic.woff2') format('woff2'),
- url('file/css/NotoSans/NotoSans-ExtraLightItalic.woff') format('woff');
- font-weight: 200;
- font-style: italic;
- font-display: swap;
-}
-
-@font-face {
- font-family: 'Noto Sans';
- src: url('file/css/NotoSans/NotoSans-Light.woff2') format('woff2'),
- url('file/css/NotoSans/NotoSans-Light.woff') format('woff');
- font-weight: 300;
- font-style: normal;
- font-display: swap;
-}
-
-@font-face {
- font-family: 'Noto Sans';
- src: url('file/css/NotoSans/NotoSans-ExtraLight.woff2') format('woff2'),
- url('file/css/NotoSans/NotoSans-ExtraLight.woff') format('woff');
- font-weight: 200;
- font-style: normal;
- font-display: swap;
-}
-
-@font-face {
- font-family: 'Noto Sans';
- src: url('file/css/NotoSans/NotoSans-Medium.woff2') format('woff2'),
- url('file/css/NotoSans/NotoSans-Medium.woff') format('woff');
- font-weight: 500;
- font-style: normal;
- font-display: swap;
-}
-
-@font-face {
- font-family: 'Noto Sans';
- src: url('file/css/NotoSans/NotoSans-Regular.woff2') format('woff2'),
- url('file/css/NotoSans/NotoSans-Regular.woff') format('woff');
- font-weight: normal;
- font-style: normal;
- font-display: swap;
-}
-
-@font-face {
- font-family: 'Noto Sans';
- src: url('file/css/NotoSans/NotoSans-MediumItalic.woff2') format('woff2'),
- url('file/css/NotoSans/NotoSans-MediumItalic.woff') format('woff');
- font-weight: 500;
- font-style: italic;
- font-display: swap;
-}
-
-@font-face {
- font-family: 'Noto Sans';
- src: url('file/css/NotoSans/NotoSans-SemiBoldItalic.woff2') format('woff2'),
- url('file/css/NotoSans/NotoSans-SemiBoldItalic.woff') format('woff');
- font-weight: 600;
- font-style: italic;
- font-display: swap;
-}
-
-@font-face {
- font-family: 'Noto Sans';
- src: url('file/css/NotoSans/NotoSans-SemiBold.woff2') format('woff2'),
- url('file/css/NotoSans/NotoSans-SemiBold.woff') format('woff');
- font-weight: 600;
- font-style: normal;
- font-display: swap;
-}
-
-@font-face {
- font-family: 'Noto Sans';
- src: url('file/css/NotoSans/NotoSans-Thin.woff2') format('woff2'),
- url('file/css/NotoSans/NotoSans-Thin.woff') format('woff');
- font-weight: 100;
- font-style: normal;
- font-display: swap;
-}
-
diff --git a/spaces/AnishKumbhar/ChatBot/text-generation-webui-main/js/main.js b/spaces/AnishKumbhar/ChatBot/text-generation-webui-main/js/main.js
deleted file mode 100644
index 01ad4af9e46d4a3adfa3e301d321f6cfcb5628a5..0000000000000000000000000000000000000000
--- a/spaces/AnishKumbhar/ChatBot/text-generation-webui-main/js/main.js
+++ /dev/null
@@ -1,330 +0,0 @@
-let main_parent = document.getElementById("chat-tab").parentNode;
-let extensions = document.getElementById("extensions");
-
-main_parent.childNodes[0].classList.add("header_bar");
-main_parent.style = "padding: 0; margin: 0";
-main_parent.parentNode.style = "gap: 0";
-main_parent.parentNode.parentNode.style = "padding: 0";
-
-document.querySelector(".header_bar").addEventListener("click", function(event) {
- if (event.target.tagName === "BUTTON") {
- const buttonText = event.target.textContent.trim();
-
- let chat_visible = (buttonText == "Chat");
- let default_visible = (buttonText == "Default");
- let notebook_visible = (buttonText == "Notebook");
-
- // Check if one of the generation tabs is visible
- if (chat_visible || notebook_visible || default_visible) {
- extensions.style.display = "flex";
- if (chat_visible) {
- extensions.style.maxWidth = "880px";
- extensions.style.padding = "0px";
- } else {
- extensions.style.maxWidth = "none";
- extensions.style.padding = "15px";
- }
- } else {
- extensions.style.display = "none";
- }
- }
-});
-
-//------------------------------------------------
-// Keyboard shortcuts
-//------------------------------------------------
-document.addEventListener("keydown", function(event) {
-
- // Stop generation on Esc pressed
- if (event.key === "Escape") {
- // Find the element with id 'stop' and click it
- var stopButton = document.getElementById("stop");
- if (stopButton) {
- stopButton.click();
- }
- }
-
- // Show chat controls on Ctrl + S
- else if (event.ctrlKey && event.key == "s") {
- event.preventDefault();
-
- var showControlsElement = document.getElementById("show-controls");
- if (showControlsElement && showControlsElement.childNodes.length >= 4) {
- showControlsElement.childNodes[3].click();
-
- var arr = document.getElementById("chat-input").childNodes[2].childNodes;
- arr[arr.length - 1].focus();
- }
- }
-
- // Regenerate on Ctrl + Enter
- else if (event.ctrlKey && event.key === "Enter") {
- event.preventDefault();
- document.getElementById("Regenerate").click();
- }
-
- // Continue on Alt + Enter
- else if (event.altKey && event.key === "Enter") {
- event.preventDefault();
- document.getElementById("Continue").click();
- }
-
- // Remove last on Ctrl + Shift + Backspace
- else if (event.ctrlKey && event.shiftKey && event.key === "Backspace") {
- event.preventDefault();
- document.getElementById("Remove-last").click();
- }
-
- // Copy last on Ctrl + Shift + K
- else if (event.ctrlKey && event.shiftKey && event.key === "K") {
- event.preventDefault();
- document.getElementById("Copy-last").click();
- }
-
- // Replace last on Ctrl + Shift + L
- else if (event.ctrlKey && event.shiftKey && event.key === "L") {
- event.preventDefault();
- document.getElementById("Replace-last").click();
- }
-
- // Impersonate on Ctrl + Shift + M
- else if (event.ctrlKey && event.shiftKey && event.key === "M") {
- event.preventDefault();
- document.getElementById("Impersonate").click();
- }
-
-});
-
-//------------------------------------------------
-// Position the chat typing dots
-//------------------------------------------------
-typing = document.getElementById("typing-container");
-typingParent = typing.parentNode;
-typingSibling = typing.previousElementSibling;
-typingSibling.insertBefore(typing, typingSibling.childNodes[2]);
-
-//------------------------------------------------
-// Chat scrolling
-//------------------------------------------------
-const targetElement = document.getElementById("chat").parentNode.parentNode.parentNode;
-targetElement.classList.add("pretty_scrollbar");
-targetElement.classList.add("chat-parent");
-let isScrolled = false;
-
-targetElement.addEventListener("scroll", function() {
- let diff = targetElement.scrollHeight - targetElement.clientHeight;
- if(Math.abs(targetElement.scrollTop - diff) <= 10 || diff == 0) {
- isScrolled = false;
- } else {
- isScrolled = true;
- }
-});
-
-// Create a MutationObserver instance
-const observer = new MutationObserver(function(mutations) {
- mutations.forEach(function(mutation) {
- if(!isScrolled) {
- targetElement.scrollTop = targetElement.scrollHeight;
- }
-
- const firstChild = targetElement.children[0];
- if (firstChild.classList.contains("generating")) {
- typing.parentNode.classList.add("visible-dots");
- document.getElementById("stop").style.display = "flex";
- document.getElementById("Generate").style.display = "none";
- } else {
- typing.parentNode.classList.remove("visible-dots");
- document.getElementById("stop").style.display = "none";
- document.getElementById("Generate").style.display = "flex";
- }
-
- });
-});
-
-// Configure the observer to watch for changes in the subtree and attributes
-const config = {
- childList: true,
- subtree: true,
- characterData: true,
- attributeOldValue: true,
- characterDataOldValue: true
-};
-
-// Start observing the target element
-observer.observe(targetElement, config);
-
-//------------------------------------------------
-// Notebook box scrolling
-//------------------------------------------------
-const notebookElement = document.querySelector("#textbox-notebook textarea");
-let notebookScrolled = false;
-
-notebookElement.addEventListener("scroll", function() {
- let diff = notebookElement.scrollHeight - notebookElement.clientHeight;
- if(Math.abs(notebookElement.scrollTop - diff) <= 10 || diff == 0) {
- notebookScrolled = false;
- } else {
- notebookScrolled = true;
- }
-});
-
-const notebookObserver = new MutationObserver(function(mutations) {
- mutations.forEach(function(mutation) {
- if(!notebookScrolled) {
- notebookElement.scrollTop = notebookElement.scrollHeight;
- }
- });
-});
-
-notebookObserver.observe(notebookElement.parentNode.parentNode.parentNode, config);
-
-//------------------------------------------------
-// Default box scrolling
-//------------------------------------------------
-const defaultElement = document.querySelector("#textbox-default textarea");
-let defaultScrolled = false;
-
-defaultElement.addEventListener("scroll", function() {
- let diff = defaultElement.scrollHeight - defaultElement.clientHeight;
- if(Math.abs(defaultElement.scrollTop - diff) <= 10 || diff == 0) {
- defaultScrolled = false;
- } else {
- defaultScrolled = true;
- }
-});
-
-const defaultObserver = new MutationObserver(function(mutations) {
- mutations.forEach(function(mutation) {
- if(!defaultScrolled) {
- defaultElement.scrollTop = defaultElement.scrollHeight;
- }
- });
-});
-
-defaultObserver.observe(defaultElement.parentNode.parentNode.parentNode, config);
-
-//------------------------------------------------
-// Add some scrollbars
-//------------------------------------------------
-const textareaElements = document.querySelectorAll(".add_scrollbar textarea");
-for(i = 0; i < textareaElements.length; i++) {
- textareaElements[i].classList.remove("scroll-hide");
- textareaElements[i].classList.add("pretty_scrollbar");
- textareaElements[i].style.resize = "none";
-}
-
-//------------------------------------------------
-// Remove some backgrounds
-//------------------------------------------------
-const noBackgroundelements = document.querySelectorAll(".no-background");
-for(i = 0; i < noBackgroundelements.length; i++) {
- noBackgroundelements[i].parentNode.style.border = "none";
- noBackgroundelements[i].parentNode.parentNode.parentNode.style.alignItems = "center";
-}
-
-//------------------------------------------------
-// Create the hover menu in the chat tab
-// The show/hide events were adapted from:
-// https://github.com/SillyTavern/SillyTavern/blob/6c8bd06308c69d51e2eb174541792a870a83d2d6/public/script.js
-//------------------------------------------------
-var buttonsInChat = document.querySelectorAll("#chat-tab:not(.old-ui) #chat-buttons button");
-var button = document.getElementById("hover-element-button");
-var menu = document.getElementById("hover-menu");
-
-function showMenu() {
- menu.style.display = "flex"; // Show the menu
-}
-
-function hideMenu() {
- menu.style.display = "none"; // Hide the menu
- document.querySelector("#chat-input textarea").focus();
-}
-
-if (buttonsInChat.length > 0) {
- for (let i = buttonsInChat.length - 1; i >= 0; i--) {
- const thisButton = buttonsInChat[i];
- menu.appendChild(thisButton);
-
- thisButton.addEventListener("click", () => {
- hideMenu();
- });
-
- const buttonText = thisButton.textContent;
- const matches = buttonText.match(/(\(.*?\))/);
-
- if (matches && matches.length > 1) {
- // Apply the transparent-substring class to the matched substring
- const substring = matches[1];
- const newText = buttonText.replace(substring, ` ${substring.slice(1, -1)} `);
- thisButton.innerHTML = newText;
- }
- }
-} else {
- buttonsInChat = document.querySelectorAll("#chat-tab.old-ui #chat-buttons button");
- for (let i = 0; i < buttonsInChat.length; i++) {
- buttonsInChat[i].textContent = buttonsInChat[i].textContent.replace(/ \(.*?\)/, "");
- }
- document.getElementById("gr-hover-container").style.display = "none";
-}
-
-function isMouseOverButtonOrMenu() {
- return menu.matches(":hover") || button.matches(":hover");
-}
-
-button.addEventListener("mouseenter", function () {
- showMenu();
-});
-
-button.addEventListener("click", function () {
- showMenu();
-});
-
-// Add event listener for mouseleave on the button
-button.addEventListener("mouseleave", function () {
- // Delay to prevent menu hiding when the mouse leaves the button into the menu
- setTimeout(function () {
- if (!isMouseOverButtonOrMenu()) {
- hideMenu();
- }
- }, 100);
-});
-
-// Add event listener for mouseleave on the menu
-menu.addEventListener("mouseleave", function () {
- // Delay to prevent menu hide when the mouse leaves the menu into the button
- setTimeout(function () {
- if (!isMouseOverButtonOrMenu()) {
- hideMenu();
- }
- }, 100);
-});
-
-// Add event listener for click anywhere in the document
-document.addEventListener("click", function (event) {
- // Check if the click is outside the button/menu and the menu is visible
- if (!isMouseOverButtonOrMenu() && menu.style.display === "flex") {
- hideMenu();
- }
-});
-
-//------------------------------------------------
-// Relocate the "Show controls" checkbox
-//------------------------------------------------
-var elementToMove = document.getElementById("show-controls");
-var parent = elementToMove.parentNode;
-for (var i = 0; i < 2; i++) {
- parent = parent.parentNode;
-}
-
-parent.insertBefore(elementToMove, parent.firstChild);
-
-//------------------------------------------------
-// Make the chat input grow upwards instead of downwards
-//------------------------------------------------
-document.getElementById("show-controls").parentNode.style.position = "absolute";
-document.getElementById("show-controls").parentNode.style.bottom = "0px";
-
-//------------------------------------------------
-// Focus on the chat input
-//------------------------------------------------
-document.querySelector("#chat-input textarea").focus();
diff --git a/spaces/Anonymous-123/ImageNet-Editing/editing_diffusion/guided_diffusion/README.md b/spaces/Anonymous-123/ImageNet-Editing/editing_diffusion/guided_diffusion/README.md
deleted file mode 100644
index 9350ea065615675bac1629178d3f591b3a445d45..0000000000000000000000000000000000000000
--- a/spaces/Anonymous-123/ImageNet-Editing/editing_diffusion/guided_diffusion/README.md
+++ /dev/null
@@ -1,176 +0,0 @@
-# guided-diffusion
-
-This is the codebase for [Diffusion Models Beat GANS on Image Synthesis](http://arxiv.org/abs/2105.05233).
-
-This repository is based on [openai/improved-diffusion](https://github.com/openai/improved-diffusion), with modifications for classifier conditioning and architecture improvements.
-
-# Download pre-trained models
-
-We have released checkpoints for the main models in the paper. Before using these models, please review the corresponding [model card](model-card.md) to understand the intended use and limitations of these models.
-
-Here are the download links for each model checkpoint:
-
- * 64x64 classifier: [64x64_classifier.pt](https://openaipublic.blob.core.windows.net/diffusion/jul-2021/64x64_classifier.pt)
- * 64x64 diffusion: [64x64_diffusion.pt](https://openaipublic.blob.core.windows.net/diffusion/jul-2021/64x64_diffusion.pt)
- * 128x128 classifier: [128x128_classifier.pt](https://openaipublic.blob.core.windows.net/diffusion/jul-2021/128x128_classifier.pt)
- * 128x128 diffusion: [128x128_diffusion.pt](https://openaipublic.blob.core.windows.net/diffusion/jul-2021/128x128_diffusion.pt)
- * 256x256 classifier: [256x256_classifier.pt](https://openaipublic.blob.core.windows.net/diffusion/jul-2021/256x256_classifier.pt)
- * 256x256 diffusion: [256x256_diffusion.pt](https://openaipublic.blob.core.windows.net/diffusion/jul-2021/256x256_diffusion.pt)
- * 256x256 diffusion (not class conditional): [256x256_diffusion_uncond.pt](https://openaipublic.blob.core.windows.net/diffusion/jul-2021/256x256_diffusion_uncond.pt)
- * 512x512 classifier: [512x512_classifier.pt](https://openaipublic.blob.core.windows.net/diffusion/jul-2021/512x512_classifier.pt)
- * 512x512 diffusion: [512x512_diffusion.pt](https://openaipublic.blob.core.windows.net/diffusion/jul-2021/512x512_diffusion.pt)
- * 64x64 -> 256x256 upsampler: [64_256_upsampler.pt](https://openaipublic.blob.core.windows.net/diffusion/jul-2021/64_256_upsampler.pt)
- * 128x128 -> 512x512 upsampler: [128_512_upsampler.pt](https://openaipublic.blob.core.windows.net/diffusion/jul-2021/128_512_upsampler.pt)
- * LSUN bedroom: [lsun_bedroom.pt](https://openaipublic.blob.core.windows.net/diffusion/jul-2021/lsun_bedroom.pt)
- * LSUN cat: [lsun_cat.pt](https://openaipublic.blob.core.windows.net/diffusion/jul-2021/lsun_cat.pt)
- * LSUN horse: [lsun_horse.pt](https://openaipublic.blob.core.windows.net/diffusion/jul-2021/lsun_horse.pt)
- * LSUN horse (no dropout): [lsun_horse_nodropout.pt](https://openaipublic.blob.core.windows.net/diffusion/jul-2021/lsun_horse_nodropout.pt)
-
-# Sampling from pre-trained models
-
-To sample from these models, you can use the `classifier_sample.py`, `image_sample.py`, and `super_res_sample.py` scripts.
-Here, we provide flags for sampling from all of these models.
-We assume that you have downloaded the relevant model checkpoints into a folder called `models/`.
-
-For these examples, we will generate 100 samples with batch size 4. Feel free to change these values.
-
-```
-SAMPLE_FLAGS="--batch_size 4 --num_samples 100 --timestep_respacing 250"
-```
-
-## Classifier guidance
-
-Note for these sampling runs that you can set `--classifier_scale 0` to sample from the base diffusion model.
-You may also use the `image_sample.py` script instead of `classifier_sample.py` in that case.
-
- * 64x64 model:
-
-```
-MODEL_FLAGS="--attention_resolutions 32,16,8 --class_cond True --diffusion_steps 1000 --dropout 0.1 --image_size 64 --learn_sigma True --noise_schedule cosine --num_channels 192 --num_head_channels 64 --num_res_blocks 3 --resblock_updown True --use_new_attention_order True --use_fp16 True --use_scale_shift_norm True"
-python classifier_sample.py $MODEL_FLAGS --classifier_scale 1.0 --classifier_path models/64x64_classifier.pt --model_path models/64x64_diffusion.pt $SAMPLE_FLAGS
-```
-
- * 128x128 model:
-
-```
-MODEL_FLAGS="--attention_resolutions 32,16,8 --class_cond True --diffusion_steps 1000 --image_size 128 --learn_sigma True --noise_schedule linear --num_channels 256 --num_heads 4 --num_res_blocks 2 --resblock_updown True --use_fp16 True --use_scale_shift_norm True"
-python classifier_sample.py $MODEL_FLAGS --classifier_scale 0.5 --classifier_path models/128x128_classifier.pt --model_path models/128x128_diffusion.pt $SAMPLE_FLAGS
-```
-
- * 256x256 model:
-
-```
-MODEL_FLAGS="--attention_resolutions 32,16,8 --class_cond True --diffusion_steps 1000 --image_size 256 --learn_sigma True --noise_schedule linear --num_channels 256 --num_head_channels 64 --num_res_blocks 2 --resblock_updown True --use_fp16 True --use_scale_shift_norm True"
-python classifier_sample.py $MODEL_FLAGS --classifier_scale 1.0 --classifier_path models/256x256_classifier.pt --model_path models/256x256_diffusion.pt $SAMPLE_FLAGS
-```
-
- * 256x256 model (unconditional):
-
-```
-MODEL_FLAGS="--attention_resolutions 32,16,8 --class_cond False --diffusion_steps 1000 --image_size 256 --learn_sigma True --noise_schedule linear --num_channels 256 --num_head_channels 64 --num_res_blocks 2 --resblock_updown True --use_fp16 True --use_scale_shift_norm True"
-python classifier_sample.py $MODEL_FLAGS --classifier_scale 10.0 --classifier_path models/256x256_classifier.pt --model_path models/256x256_diffusion.pt $SAMPLE_FLAGS
-```
-
- * 512x512 model:
-
-```
-MODEL_FLAGS="--attention_resolutions 32,16,8 --class_cond True --diffusion_steps 1000 --image_size 512 --learn_sigma True --noise_schedule linear --num_channels 256 --num_head_channels 64 --num_res_blocks 2 --resblock_updown True --use_fp16 False --use_scale_shift_norm True"
-python classifier_sample.py $MODEL_FLAGS --classifier_scale 4.0 --classifier_path models/512x512_classifier.pt --model_path models/512x512_diffusion.pt $SAMPLE_FLAGS
-```
-
-## Upsampling
-
-For these runs, we assume you have some base samples in a file `64_samples.npz` or `128_samples.npz` for the two respective models.
-
- * 64 -> 256:
-
-```
-MODEL_FLAGS="--attention_resolutions 32,16,8 --class_cond True --diffusion_steps 1000 --large_size 256 --small_size 64 --learn_sigma True --noise_schedule linear --num_channels 192 --num_heads 4 --num_res_blocks 2 --resblock_updown True --use_fp16 True --use_scale_shift_norm True"
-python super_res_sample.py $MODEL_FLAGS --model_path models/64_256_upsampler.pt --base_samples 64_samples.npz $SAMPLE_FLAGS
-```
-
- * 128 -> 512:
-
-```
-MODEL_FLAGS="--attention_resolutions 32,16 --class_cond True --diffusion_steps 1000 --large_size 512 --small_size 128 --learn_sigma True --noise_schedule linear --num_channels 192 --num_head_channels 64 --num_res_blocks 2 --resblock_updown True --use_fp16 True --use_scale_shift_norm True"
-python super_res_sample.py $MODEL_FLAGS --model_path models/128_512_upsampler.pt $SAMPLE_FLAGS --base_samples 128_samples.npz
-```
-
-## LSUN models
-
-These models are class-unconditional and correspond to a single LSUN class. Here, we show how to sample from `lsun_bedroom.pt`, but the other two LSUN checkpoints should work as well:
-
-```
-MODEL_FLAGS="--attention_resolutions 32,16,8 --class_cond False --diffusion_steps 1000 --dropout 0.1 --image_size 256 --learn_sigma True --noise_schedule linear --num_channels 256 --num_head_channels 64 --num_res_blocks 2 --resblock_updown True --use_fp16 True --use_scale_shift_norm True"
-python image_sample.py $MODEL_FLAGS --model_path models/lsun_bedroom.pt $SAMPLE_FLAGS
-```
-
-You can sample from `lsun_horse_nodropout.pt` by changing the dropout flag:
-
-```
-MODEL_FLAGS="--attention_resolutions 32,16,8 --class_cond False --diffusion_steps 1000 --dropout 0.0 --image_size 256 --learn_sigma True --noise_schedule linear --num_channels 256 --num_head_channels 64 --num_res_blocks 2 --resblock_updown True --use_fp16 True --use_scale_shift_norm True"
-python image_sample.py $MODEL_FLAGS --model_path models/lsun_horse_nodropout.pt $SAMPLE_FLAGS
-```
-
-Note that for these models, the best samples result from using 1000 timesteps:
-
-```
-SAMPLE_FLAGS="--batch_size 4 --num_samples 100 --timestep_respacing 1000"
-```
-
-# Results
-
-This table summarizes our ImageNet results for pure guided diffusion models:
-
-| Dataset | FID | Precision | Recall |
-|------------------|------|-----------|--------|
-| ImageNet 64x64 | 2.07 | 0.74 | 0.63 |
-| ImageNet 128x128 | 2.97 | 0.78 | 0.59 |
-| ImageNet 256x256 | 4.59 | 0.82 | 0.52 |
-| ImageNet 512x512 | 7.72 | 0.87 | 0.42 |
-
-This table shows the best results for high resolutions when using upsampling and guidance together:
-
-| Dataset | FID | Precision | Recall |
-|------------------|------|-----------|--------|
-| ImageNet 256x256 | 3.94 | 0.83 | 0.53 |
-| ImageNet 512x512 | 3.85 | 0.84 | 0.53 |
-
-Finally, here are the unguided results on individual LSUN classes:
-
-| Dataset | FID | Precision | Recall |
-|--------------|------|-----------|--------|
-| LSUN Bedroom | 1.90 | 0.66 | 0.51 |
-| LSUN Cat | 5.57 | 0.63 | 0.52 |
-| LSUN Horse | 2.57 | 0.71 | 0.55 |
-
-# Training models
-
-Training diffusion models is described in the [parent repository](https://github.com/openai/improved-diffusion). Training a classifier is similar. We assume you have put training hyperparameters into a `TRAIN_FLAGS` variable, and classifier hyperparameters into a `CLASSIFIER_FLAGS` variable. Then you can run:
-
-```
-mpiexec -n N python scripts/classifier_train.py --data_dir path/to/imagenet $TRAIN_FLAGS $CLASSIFIER_FLAGS
-```
-
-Make sure to divide the batch size in `TRAIN_FLAGS` by the number of MPI processes you are using.
-
-Here are flags for training the 128x128 classifier. You can modify these for training classifiers at other resolutions:
-
-```sh
-TRAIN_FLAGS="--iterations 300000 --anneal_lr True --batch_size 256 --lr 3e-4 --save_interval 10000 --weight_decay 0.05"
-CLASSIFIER_FLAGS="--image_size 128 --classifier_attention_resolutions 32,16,8 --classifier_depth 2 --classifier_width 128 --classifier_pool attention --classifier_resblock_updown True --classifier_use_scale_shift_norm True"
-```
-
-For sampling from a 128x128 classifier-guided model, 25 step DDIM:
-
-```sh
-MODEL_FLAGS="--attention_resolutions 32,16,8 --class_cond True --image_size 128 --learn_sigma True --num_channels 256 --num_heads 4 --num_res_blocks 2 --resblock_updown True --use_fp16 True --use_scale_shift_norm True"
-CLASSIFIER_FLAGS="--image_size 128 --classifier_attention_resolutions 32,16,8 --classifier_depth 2 --classifier_width 128 --classifier_pool attention --classifier_resblock_updown True --classifier_use_scale_shift_norm True --classifier_scale 1.0 --classifier_use_fp16 True"
-SAMPLE_FLAGS="--batch_size 4 --num_samples 50000 --timestep_respacing ddim25 --use_ddim True"
-mpiexec -n N python scripts/classifier_sample.py \
- --model_path /path/to/model.pt \
- --classifier_path path/to/classifier.pt \
- $MODEL_FLAGS $CLASSIFIER_FLAGS $SAMPLE_FLAGS
-```
-
-To sample for 250 timesteps without DDIM, replace `--timestep_respacing ddim25` to `--timestep_respacing 250`, and replace `--use_ddim True` with `--use_ddim False`.
diff --git a/spaces/Anonymous-sub/Rerender/ControlNet/annotator/uniformer/mmcv/ops/saconv.py b/spaces/Anonymous-sub/Rerender/ControlNet/annotator/uniformer/mmcv/ops/saconv.py
deleted file mode 100644
index b4ee3978e097fca422805db4e31ae481006d7971..0000000000000000000000000000000000000000
--- a/spaces/Anonymous-sub/Rerender/ControlNet/annotator/uniformer/mmcv/ops/saconv.py
+++ /dev/null
@@ -1,145 +0,0 @@
-# Copyright (c) OpenMMLab. All rights reserved.
-import torch
-import torch.nn as nn
-import torch.nn.functional as F
-
-from annotator.uniformer.mmcv.cnn import CONV_LAYERS, ConvAWS2d, constant_init
-from annotator.uniformer.mmcv.ops.deform_conv import deform_conv2d
-from annotator.uniformer.mmcv.utils import TORCH_VERSION, digit_version
-
-
-@CONV_LAYERS.register_module(name='SAC')
-class SAConv2d(ConvAWS2d):
- """SAC (Switchable Atrous Convolution)
-
- This is an implementation of SAC in DetectoRS
- (https://arxiv.org/pdf/2006.02334.pdf).
-
- Args:
- in_channels (int): Number of channels in the input image
- out_channels (int): Number of channels produced by the convolution
- kernel_size (int or tuple): Size of the convolving kernel
- stride (int or tuple, optional): Stride of the convolution. Default: 1
- padding (int or tuple, optional): Zero-padding added to both sides of
- the input. Default: 0
- padding_mode (string, optional): ``'zeros'``, ``'reflect'``,
- ``'replicate'`` or ``'circular'``. Default: ``'zeros'``
- dilation (int or tuple, optional): Spacing between kernel elements.
- Default: 1
- groups (int, optional): Number of blocked connections from input
- channels to output channels. Default: 1
- bias (bool, optional): If ``True``, adds a learnable bias to the
- output. Default: ``True``
- use_deform: If ``True``, replace convolution with deformable
- convolution. Default: ``False``.
- """
-
- def __init__(self,
- in_channels,
- out_channels,
- kernel_size,
- stride=1,
- padding=0,
- dilation=1,
- groups=1,
- bias=True,
- use_deform=False):
- super().__init__(
- in_channels,
- out_channels,
- kernel_size,
- stride=stride,
- padding=padding,
- dilation=dilation,
- groups=groups,
- bias=bias)
- self.use_deform = use_deform
- self.switch = nn.Conv2d(
- self.in_channels, 1, kernel_size=1, stride=stride, bias=True)
- self.weight_diff = nn.Parameter(torch.Tensor(self.weight.size()))
- self.pre_context = nn.Conv2d(
- self.in_channels, self.in_channels, kernel_size=1, bias=True)
- self.post_context = nn.Conv2d(
- self.out_channels, self.out_channels, kernel_size=1, bias=True)
- if self.use_deform:
- self.offset_s = nn.Conv2d(
- self.in_channels,
- 18,
- kernel_size=3,
- padding=1,
- stride=stride,
- bias=True)
- self.offset_l = nn.Conv2d(
- self.in_channels,
- 18,
- kernel_size=3,
- padding=1,
- stride=stride,
- bias=True)
- self.init_weights()
-
- def init_weights(self):
- constant_init(self.switch, 0, bias=1)
- self.weight_diff.data.zero_()
- constant_init(self.pre_context, 0)
- constant_init(self.post_context, 0)
- if self.use_deform:
- constant_init(self.offset_s, 0)
- constant_init(self.offset_l, 0)
-
- def forward(self, x):
- # pre-context
- avg_x = F.adaptive_avg_pool2d(x, output_size=1)
- avg_x = self.pre_context(avg_x)
- avg_x = avg_x.expand_as(x)
- x = x + avg_x
- # switch
- avg_x = F.pad(x, pad=(2, 2, 2, 2), mode='reflect')
- avg_x = F.avg_pool2d(avg_x, kernel_size=5, stride=1, padding=0)
- switch = self.switch(avg_x)
- # sac
- weight = self._get_weight(self.weight)
- zero_bias = torch.zeros(
- self.out_channels, device=weight.device, dtype=weight.dtype)
-
- if self.use_deform:
- offset = self.offset_s(avg_x)
- out_s = deform_conv2d(x, offset, weight, self.stride, self.padding,
- self.dilation, self.groups, 1)
- else:
- if (TORCH_VERSION == 'parrots'
- or digit_version(TORCH_VERSION) < digit_version('1.5.0')):
- out_s = super().conv2d_forward(x, weight)
- elif digit_version(TORCH_VERSION) >= digit_version('1.8.0'):
- # bias is a required argument of _conv_forward in torch 1.8.0
- out_s = super()._conv_forward(x, weight, zero_bias)
- else:
- out_s = super()._conv_forward(x, weight)
- ori_p = self.padding
- ori_d = self.dilation
- self.padding = tuple(3 * p for p in self.padding)
- self.dilation = tuple(3 * d for d in self.dilation)
- weight = weight + self.weight_diff
- if self.use_deform:
- offset = self.offset_l(avg_x)
- out_l = deform_conv2d(x, offset, weight, self.stride, self.padding,
- self.dilation, self.groups, 1)
- else:
- if (TORCH_VERSION == 'parrots'
- or digit_version(TORCH_VERSION) < digit_version('1.5.0')):
- out_l = super().conv2d_forward(x, weight)
- elif digit_version(TORCH_VERSION) >= digit_version('1.8.0'):
- # bias is a required argument of _conv_forward in torch 1.8.0
- out_l = super()._conv_forward(x, weight, zero_bias)
- else:
- out_l = super()._conv_forward(x, weight)
-
- out = switch * out_s + (1 - switch) * out_l
- self.padding = ori_p
- self.dilation = ori_d
- # post-context
- avg_x = F.adaptive_avg_pool2d(out, output_size=1)
- avg_x = self.post_context(avg_x)
- avg_x = avg_x.expand_as(out)
- out = out + avg_x
- return out
diff --git a/spaces/ArchitSharma/Digital-Photo-Color-Restoration/src/deoldify/__init__.py b/spaces/ArchitSharma/Digital-Photo-Color-Restoration/src/deoldify/__init__.py
deleted file mode 100644
index db38aa1a7e4c2f9c87b859c55f4f16a78aaa3b18..0000000000000000000000000000000000000000
--- a/spaces/ArchitSharma/Digital-Photo-Color-Restoration/src/deoldify/__init__.py
+++ /dev/null
@@ -1,3 +0,0 @@
-from src.deoldify._device import _Device
-
-device = _Device()
\ No newline at end of file
diff --git a/spaces/Ash58947/Bot/Dockerfile b/spaces/Ash58947/Bot/Dockerfile
deleted file mode 100644
index 6c01c09373883afcb4ea34ae2d316cd596e1737b..0000000000000000000000000000000000000000
--- a/spaces/Ash58947/Bot/Dockerfile
+++ /dev/null
@@ -1,21 +0,0 @@
-FROM node:18-bullseye-slim
-
-RUN apt-get update && \
-
-apt-get install -y git
-
-RUN git clone https://gitgud.io/khanon/oai-reverse-proxy.git /app
-
-WORKDIR /app
-
-RUN npm install
-
-COPY Dockerfile greeting.md* .env* ./
-
-RUN npm run build
-
-EXPOSE 7860
-
-ENV NODE_ENV=production
-
-CMD [ "npm", "start" ]
\ No newline at end of file
diff --git a/spaces/Ataturk-Chatbot/HuggingFaceChat/venv/lib/python3.11/site-packages/pkg_resources/_vendor/importlib_resources/_legacy.py b/spaces/Ataturk-Chatbot/HuggingFaceChat/venv/lib/python3.11/site-packages/pkg_resources/_vendor/importlib_resources/_legacy.py
deleted file mode 100644
index 1d5d3f1fbb1f6c69d0da2a50e1d4492ad3378f17..0000000000000000000000000000000000000000
--- a/spaces/Ataturk-Chatbot/HuggingFaceChat/venv/lib/python3.11/site-packages/pkg_resources/_vendor/importlib_resources/_legacy.py
+++ /dev/null
@@ -1,121 +0,0 @@
-import functools
-import os
-import pathlib
-import types
-import warnings
-
-from typing import Union, Iterable, ContextManager, BinaryIO, TextIO, Any
-
-from . import _common
-
-Package = Union[types.ModuleType, str]
-Resource = str
-
-
-def deprecated(func):
- @functools.wraps(func)
- def wrapper(*args, **kwargs):
- warnings.warn(
- f"{func.__name__} is deprecated. Use files() instead. "
- "Refer to https://importlib-resources.readthedocs.io"
- "/en/latest/using.html#migrating-from-legacy for migration advice.",
- DeprecationWarning,
- stacklevel=2,
- )
- return func(*args, **kwargs)
-
- return wrapper
-
-
-def normalize_path(path):
- # type: (Any) -> str
- """Normalize a path by ensuring it is a string.
-
- If the resulting string contains path separators, an exception is raised.
- """
- str_path = str(path)
- parent, file_name = os.path.split(str_path)
- if parent:
- raise ValueError(f'{path!r} must be only a file name')
- return file_name
-
-
-@deprecated
-def open_binary(package: Package, resource: Resource) -> BinaryIO:
- """Return a file-like object opened for binary reading of the resource."""
- return (_common.files(package) / normalize_path(resource)).open('rb')
-
-
-@deprecated
-def read_binary(package: Package, resource: Resource) -> bytes:
- """Return the binary contents of the resource."""
- return (_common.files(package) / normalize_path(resource)).read_bytes()
-
-
-@deprecated
-def open_text(
- package: Package,
- resource: Resource,
- encoding: str = 'utf-8',
- errors: str = 'strict',
-) -> TextIO:
- """Return a file-like object opened for text reading of the resource."""
- return (_common.files(package) / normalize_path(resource)).open(
- 'r', encoding=encoding, errors=errors
- )
-
-
-@deprecated
-def read_text(
- package: Package,
- resource: Resource,
- encoding: str = 'utf-8',
- errors: str = 'strict',
-) -> str:
- """Return the decoded string of the resource.
-
- The decoding-related arguments have the same semantics as those of
- bytes.decode().
- """
- with open_text(package, resource, encoding, errors) as fp:
- return fp.read()
-
-
-@deprecated
-def contents(package: Package) -> Iterable[str]:
- """Return an iterable of entries in `package`.
-
- Note that not all entries are resources. Specifically, directories are
- not considered resources. Use `is_resource()` on each entry returned here
- to check if it is a resource or not.
- """
- return [path.name for path in _common.files(package).iterdir()]
-
-
-@deprecated
-def is_resource(package: Package, name: str) -> bool:
- """True if `name` is a resource inside `package`.
-
- Directories are *not* resources.
- """
- resource = normalize_path(name)
- return any(
- traversable.name == resource and traversable.is_file()
- for traversable in _common.files(package).iterdir()
- )
-
-
-@deprecated
-def path(
- package: Package,
- resource: Resource,
-) -> ContextManager[pathlib.Path]:
- """A context manager providing a file path object to the resource.
-
- If the resource does not already exist on its own on the file system,
- a temporary file will be created. If the file was created, the file
- will be deleted upon exiting the context manager (no exception is
- raised if the file was deleted prior to the context manager
- exiting).
- """
- return _common.as_file(_common.files(package) / normalize_path(resource))
diff --git a/spaces/Awiny/Image2Paragraph/models/grit_src/third_party/CenterNet2/tests/structures/test_instances.py b/spaces/Awiny/Image2Paragraph/models/grit_src/third_party/CenterNet2/tests/structures/test_instances.py
deleted file mode 100644
index a352f74313ae9b2b7a42398f0ef4606fcb4a610c..0000000000000000000000000000000000000000
--- a/spaces/Awiny/Image2Paragraph/models/grit_src/third_party/CenterNet2/tests/structures/test_instances.py
+++ /dev/null
@@ -1,219 +0,0 @@
-# Copyright (c) Facebook, Inc. and its affiliates.
-import unittest
-import torch
-from torch import Tensor
-
-from detectron2.export.torchscript import patch_instances
-from detectron2.structures import Boxes, Instances
-from detectron2.utils.testing import convert_scripted_instances
-
-
-class TestInstances(unittest.TestCase):
- def test_int_indexing(self):
- attr1 = torch.tensor([[0.0, 0.0, 1.0], [0.0, 0.0, 0.5], [0.0, 0.0, 1.0], [0.0, 0.5, 0.5]])
- attr2 = torch.tensor([0.1, 0.2, 0.3, 0.4])
- instances = Instances((100, 100))
- instances.attr1 = attr1
- instances.attr2 = attr2
- for i in range(-len(instances), len(instances)):
- inst = instances[i]
- self.assertEqual((inst.attr1 == attr1[i]).all(), True)
- self.assertEqual((inst.attr2 == attr2[i]).all(), True)
-
- self.assertRaises(IndexError, lambda: instances[len(instances)])
- self.assertRaises(IndexError, lambda: instances[-len(instances) - 1])
-
- def test_script_new_fields(self):
- def get_mask(x: Instances) -> torch.Tensor:
- return x.mask
-
- class f(torch.nn.Module):
- def forward(self, x: Instances):
- proposal_boxes = x.proposal_boxes # noqa F841
- objectness_logits = x.objectness_logits # noqa F841
- return x
-
- class g(torch.nn.Module):
- def forward(self, x: Instances):
- return get_mask(x)
-
- class g2(torch.nn.Module):
- def __init__(self):
- super().__init__()
- self.g = g()
-
- def forward(self, x: Instances):
- proposal_boxes = x.proposal_boxes # noqa F841
- return x, self.g(x)
-
- fields = {"proposal_boxes": Boxes, "objectness_logits": Tensor}
- with patch_instances(fields):
- torch.jit.script(f())
-
- # can't script anymore after exiting the context
- with self.assertRaises(Exception):
- # will create a ConcreteType for g
- torch.jit.script(g2())
-
- new_fields = {"mask": Tensor}
- with patch_instances(new_fields):
- # will compile g with a different Instances; this should pass
- torch.jit.script(g())
- with self.assertRaises(Exception):
- torch.jit.script(g2())
-
- new_fields = {"mask": Tensor, "proposal_boxes": Boxes}
- with patch_instances(new_fields) as NewInstances:
- # get_mask will be compiled with a different Instances; this should pass
- scripted_g2 = torch.jit.script(g2())
- x = NewInstances((3, 4))
- x.mask = torch.rand(3)
- x.proposal_boxes = Boxes(torch.rand(3, 4))
- scripted_g2(x) # it should accept the new Instances object and run successfully
-
- def test_script_access_fields(self):
- class f(torch.nn.Module):
- def forward(self, x: Instances):
- proposal_boxes = x.proposal_boxes
- objectness_logits = x.objectness_logits
- return proposal_boxes.tensor + objectness_logits
-
- fields = {"proposal_boxes": Boxes, "objectness_logits": Tensor}
- with patch_instances(fields):
- torch.jit.script(f())
-
- def test_script_len(self):
- class f(torch.nn.Module):
- def forward(self, x: Instances):
- return len(x)
-
- class g(torch.nn.Module):
- def forward(self, x: Instances):
- return len(x)
-
- image_shape = (15, 15)
-
- fields = {"proposal_boxes": Boxes}
- with patch_instances(fields) as new_instance:
- script_module = torch.jit.script(f())
- x = new_instance(image_shape)
- with self.assertRaises(Exception):
- script_module(x)
- box_tensors = torch.tensor([[5, 5, 10, 10], [1, 1, 2, 3]])
- x.proposal_boxes = Boxes(box_tensors)
- length = script_module(x)
- self.assertEqual(length, 2)
-
- fields = {"objectness_logits": Tensor}
- with patch_instances(fields) as new_instance:
- script_module = torch.jit.script(g())
- x = new_instance(image_shape)
- objectness_logits = torch.tensor([1.0]).reshape(1, 1)
- x.objectness_logits = objectness_logits
- length = script_module(x)
- self.assertEqual(length, 1)
-
- def test_script_has(self):
- class f(torch.nn.Module):
- def forward(self, x: Instances):
- return x.has("proposal_boxes")
-
- image_shape = (15, 15)
- fields = {"proposal_boxes": Boxes}
- with patch_instances(fields) as new_instance:
- script_module = torch.jit.script(f())
- x = new_instance(image_shape)
- self.assertFalse(script_module(x))
-
- box_tensors = torch.tensor([[5, 5, 10, 10], [1, 1, 2, 3]])
- x.proposal_boxes = Boxes(box_tensors)
- self.assertTrue(script_module(x))
-
- def test_script_to(self):
- class f(torch.nn.Module):
- def forward(self, x: Instances):
- return x.to(torch.device("cpu"))
-
- image_shape = (15, 15)
- fields = {"proposal_boxes": Boxes, "a": Tensor}
- with patch_instances(fields) as new_instance:
- script_module = torch.jit.script(f())
- x = new_instance(image_shape)
- script_module(x)
-
- box_tensors = torch.tensor([[5, 5, 10, 10], [1, 1, 2, 3]])
- x.proposal_boxes = Boxes(box_tensors)
- x.a = box_tensors
- script_module(x)
-
- def test_script_getitem(self):
- class f(torch.nn.Module):
- def forward(self, x: Instances, idx):
- return x[idx]
-
- image_shape = (15, 15)
- fields = {"proposal_boxes": Boxes, "a": Tensor}
- inst = Instances(image_shape)
- inst.proposal_boxes = Boxes(torch.rand(4, 4))
- inst.a = torch.rand(4, 10)
- idx = torch.tensor([True, False, True, False])
- with patch_instances(fields) as new_instance:
- script_module = torch.jit.script(f())
-
- out = f()(inst, idx)
- out_scripted = script_module(new_instance.from_instances(inst), idx)
- self.assertTrue(
- torch.equal(out.proposal_boxes.tensor, out_scripted.proposal_boxes.tensor)
- )
- self.assertTrue(torch.equal(out.a, out_scripted.a))
-
- def test_from_to_instances(self):
- orig = Instances((30, 30))
- orig.proposal_boxes = Boxes(torch.rand(3, 4))
-
- fields = {"proposal_boxes": Boxes, "a": Tensor}
- with patch_instances(fields) as NewInstances:
- # convert to NewInstances and back
- new1 = NewInstances.from_instances(orig)
- new2 = convert_scripted_instances(new1)
- self.assertTrue(torch.equal(orig.proposal_boxes.tensor, new1.proposal_boxes.tensor))
- self.assertTrue(torch.equal(orig.proposal_boxes.tensor, new2.proposal_boxes.tensor))
-
- def test_script_init_args(self):
- def f(x: Tensor):
- image_shape = (15, 15)
- # __init__ can take arguments
- inst = Instances(image_shape, a=x, proposal_boxes=Boxes(x))
- inst2 = Instances(image_shape, a=x)
- return inst.a, inst2.a
-
- fields = {"proposal_boxes": Boxes, "a": Tensor}
- with patch_instances(fields):
- script_f = torch.jit.script(f)
- x = torch.randn(3, 4)
- outputs = script_f(x)
- self.assertTrue(torch.equal(outputs[0], x))
- self.assertTrue(torch.equal(outputs[1], x))
-
- def test_script_cat(self):
- def f(x: Tensor):
- image_shape = (15, 15)
- # __init__ can take arguments
- inst = Instances(image_shape, a=x)
- inst2 = Instances(image_shape, a=x)
-
- inst3 = Instances(image_shape, proposal_boxes=Boxes(x))
- return inst.cat([inst, inst2]), inst3.cat([inst3, inst3])
-
- fields = {"proposal_boxes": Boxes, "a": Tensor}
- with patch_instances(fields):
- script_f = torch.jit.script(f)
- x = torch.randn(3, 4)
- output, output2 = script_f(x)
- self.assertTrue(torch.equal(output.a, torch.cat([x, x])))
- self.assertFalse(output.has("proposal_boxes"))
- self.assertTrue(torch.equal(output2.proposal_boxes.tensor, torch.cat([x, x])))
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/spaces/Benson/text-generation/Examples/Carx Calle Pc Descargar Mediafre.md b/spaces/Benson/text-generation/Examples/Carx Calle Pc Descargar Mediafre.md
deleted file mode 100644
index b54b96df33c24b1327d037493ccfe56dd1f0aac8..0000000000000000000000000000000000000000
--- a/spaces/Benson/text-generation/Examples/Carx Calle Pc Descargar Mediafre.md
+++ /dev/null
@@ -1,33 +0,0 @@
-
-CarX Street PC Descargar Mediafıre: Cómo jugar el último juego de carreras en su computadora
-Si eres un fan de los juegos de carreras, es posible que hayas oído hablar de CarX Street, un emocionante juego que te permite explorar el mundo de las carreras nocturnas. Puede recoger coches legendarios, personalizarlos y desafiar a otros jugadores en carreras de red reales. ¿Pero sabías que también puedes jugar CarX Street en tu PC usando Mediafıre? En este artículo, le mostraremos cómo descargar e instalar CarX Street en su computadora usando Mediafıre, y cómo optimizar su experiencia de juego de PC con este increíble juego. ¡Vamos a empezar!
-carx calle pc descargar mediafıre Download ⚹ https://bltlly.com/2v6ITu
-Introducción
-¿Qué es CarX Street?
-CarX Street es un juego de carreras desarrollado por CarX Technologies, LLC. Está disponible para dispositivos Android e iOS, así como para ordenadores Windows y Mac. En CarX Street, puede conducir más de 50 coches oficiales de los mejores fabricantes de automóviles del mundo, como BMW, Toyota, Nissan, Subaru y más. También puede personalizar sus coches con diferentes partes, colores, pegatinas y calcomanías. Puedes correr en varios lugares, desde las concurridas calles de la ciudad hasta las carreteras de montaña en espiral y las carreteras costeras. Puedes desviar, acelerar y esquivar el tráfico mientras compites con otros jugadores en carreras de red reales. También puedes participar en competiciones basadas en historias con múltiples formas de ganar.
-¿Por qué jugar CarX Street en PC?
-Si bien CarX Street es un gran juego para jugar en tu dispositivo móvil, jugar en tu PC tiene algunas ventajas. Por un lado, se puede disfrutar de los impresionantes gráficos y la física realista del juego en una pantalla más grande. También puede utilizar un controlador o un teclado y ratón para controlar su coche más fácilmente. También puede acceder a miles de aplicaciones y herramientas de productividad en su PC sin cambiar de dispositivo. Jugar CarX Street en PC también le permite ahorrar batería y espacio de almacenamiento en su dispositivo móvil.
-Cómo descargar e instalar CarX Street en PC usando Mediafıre
-
-Para jugar CarX Street en su PC, tendrá que descargar los archivos del juego desde Mediafıre, un servicio de almacenamiento en la nube que le permite compartir archivos en línea. Puede encontrar el enlace Mediafıre para CarX Street [aquí]( 1 ). Haga clic en el enlace y espere a que comience la descarga. El tamaño del archivo es de aproximadamente 1 GB, por lo que podría tomar algún tiempo dependiendo de su velocidad de Internet.
-Paso 2: Extraer el archivo zip y ejecutar el archivo de configuración
-Una vez completada la descarga, tendrá que extraer el archivo zip utilizando un programa como WinRAR o 7-Zip. Puede descargar WinRAR [aquí] o 7-Zip [aquí]. Después de extraer el archivo zip, verá una carpeta llamada "CarX_Street". Ábralo y busque el archivo de configuración llamado "CarX_Street_Setup.exe". Haga doble clic en él y espere a que aparezca el asistente de instalación.
-
-Paso 3: Siga las instrucciones de instalación y inicie el juego
-El asistente de instalación le guiará a través del proceso de instalación de CarX Street en su PC. Deberá aceptar los términos y condiciones, elegir una carpeta de destino y crear un acceso directo al escritorio. La instalación tomará unos minutos, así que ten paciencia. Después de la instalación, puede iniciar el juego haciendo clic en el acceso directo del escritorio o el icono del menú de inicio. Verás el logo de CarX Street y luego el menú principal del juego.
-Cómo optimizar tu experiencia de juego en PC con CarX Street
-Ajustar la configuración de gráficos y la resolución
-
-Usa un controlador o un teclado y ratón
-Otra forma de optimizar su experiencia de juego de PC con CarX Street es usar un controlador o un teclado y ratón para controlar su automóvil. Puedes usar cualquier mando compatible que se conecte a tu PC a través de USB o Bluetooth, como un mando de Xbox One, PlayStation 4 o Nintendo Switch. También puede utilizar un teclado y un ratón si lo prefiere. Puede personalizar los controles haciendo clic en el icono de engranaje en la esquina superior derecha del menú principal y luego seleccionando la pestaña de controles. Puede asignar diferentes teclas o botones a diferentes acciones, como dirección, aceleración, frenado, deriva, cambio de cámara y más.
-Activar el modo multijugador en línea y unirse a otros corredores
-La parte más divertida de jugar CarX Street en tu PC es habilitar el modo multijugador en línea y unirse a otros corredores de todo el mundo. Puede acceder al modo multijugador en línea haciendo clic en el icono del globo en la esquina superior izquierda del menú principal. Puede elegir entre diferentes modos, como carrera rápida, carrera clasificada, carrera personalizada o carrera privada. También puede crear o unirse a un club y chatear con otros miembros. Puedes competir con otros jugadores en carreras de red reales y ganar recompensas, puntos de reputación y clasificaciones de clasificación.
-Conclusión
-Resumen de los puntos principales
-En este artículo, le hemos mostrado cómo jugar CarX Street en su PC usando Mediafıre. Hemos explicado lo que es CarX Street, por qué debe jugar en el PC, cómo descargar e instalar con Mediafıre, y cómo optimizar su experiencia de juego de PC con él. Esperamos que haya encontrado este artículo útil e informativo.
-Llamada a la acción y pensamientos finales
-
-Gracias por leer este artículo. Si tiene alguna pregunta o comentario, déjelos en la sección de comentarios a continuación. Nos encantaría saber de ti. ¡Feliz carrera!
- P: ¿CarX Street es libre para jugar? R: Sí, CarX Street es libre para jugar en todas las plataformas. Sin embargo, contiene compras en la aplicación que le permiten comprar moneda premium, automóviles, piezas y otros artículos. P: ¿Es seguro descargar CarX Street desde Mediafıre? R: Sí, CarX Street es seguro para descargar desde Mediafıre siempre y cuando utilice el enlace oficial proporcionado en este artículo. Lo hemos probado nosotros mismos y no encontramos virus o malware. P: ¿Cuáles son los requisitos mínimos del sistema para jugar CarX Street en PC? R: Los requisitos mínimos del sistema para jugar CarX Street en PC son: - OS: Windows 7/8/10 - Procesador: Intel Core i3-4130 / AMD FX-4300 - Memoria: 4 GB RAM - Gráficos: NVIDIA GeForce GTX 660 / AMD Radeon HD 7870 - DirectX: Versión 11 - Almacenamiento: 5 GB de espacio disponible Q: ¿Cómo puedo contactar a los desarrolladores de CarX Street? R: Puede ponerse en contacto con los desarrolladores de CarX Street visitando su sitio web oficial [aquí], su página de Facebook [aquí], su página de Instagram [aquí], o su servidor Discord [aquí]. P: ¿Cómo puedo obtener más información sobre CarX Street? R: Puedes aprender más sobre CarX Street leyendo su blog oficial [ aquí], viendo su canal oficial de YouTube [aquí], o siguiendo su cuenta oficial de Twitter [aquí]. 64aa2da5cf
-
-
\ No newline at end of file
diff --git a/spaces/Benson/text-generation/Examples/Descargar Cuentos De Los Hroes Gemelos Valientes (parcheado En Ingls) Iso Psp.md b/spaces/Benson/text-generation/Examples/Descargar Cuentos De Los Hroes Gemelos Valientes (parcheado En Ingls) Iso Psp.md
deleted file mode 100644
index eebfc1e7154564de16ba6b5b494529493a24d38e..0000000000000000000000000000000000000000
--- a/spaces/Benson/text-generation/Examples/Descargar Cuentos De Los Hroes Gemelos Valientes (parcheado En Ingls) Iso Psp.md
+++ /dev/null
@@ -1,58 +0,0 @@
-
-Cómo descargar cuentos de los héroes: Twin Brave (parcheado en inglés) ISO PSP
-Si eres un fan de la serie Tales , quizás te interese jugar a Tales of the Heroes: Twin Brave , un juego spin-off que cuenta con muchos personajes del pasado Tales en un estilo de acción beat 'em up. Sin embargo, hay un problema: este juego solo fue lanzado en Japón para PlayStation Portable (PSP) en 2012, y no hay ninguna localización oficial en inglés. Afortunadamente, hay una manera de jugar este juego en inglés utilizando un parche en inglés no oficial hecho por fans. En este artículo, le mostraremos cómo descargar Tales of the Heroes: Twin Brave (parcheado en inglés) ISO PSP y disfrutar jugando en su dispositivo PSP.
-Introducción
-Antes de entrar en detalles, primero vamos a explicar lo que es Tales of the Heroes: Twin Brave y por qué necesitas un parche en inglés para jugarlo.
-descargar cuentos de los héroes gemelos valientes (parcheado en inglés) iso psp DOWNLOAD ★★★★★ https://bltlly.com/2v6Ldu
-¿Qué es Cuentos de los Héroes: Twin Brave?
-Tales of the Heroes: Twin Brave es un juego de acción en el Tales Por eso necesitas un parche en inglés, que es una modificación de los archivos del juego que traduce el texto japonés al inglés. Un parche de Inglés es creado por los fans que tienen las habilidades y la pasión para hacer el juego accesible a más personas. Sin embargo, un parche en inglés no es un producto oficial, y puede tener algunos errores o inconsistencias. Por lo tanto, debes usarlo bajo tu propio riesgo y respetar a los creadores originales del juego y el parche.
-¿Cuáles son los requisitos para jugar en PSP?
-Para jugar Tales of the Heroes: Twin Brave (parcheado en inglés) ISO PSP en su dispositivo PSP, necesitará las siguientes cosas:
-
-
-Una tarjeta de memoria que tiene suficiente espacio para almacenar la ISO del juego y el parche en inglés. El juego ISO es de aproximadamente 1,5 GB, y el parche en inglés es de unos 300 MB. También necesitará un poco de espacio adicional para el juego parcheado ISO, que será de aproximadamente 1,8 GB.
-Un cable USB que puede conectar su PSP a su PC. Necesitará esto para transferir los archivos de su PC a su PSP.
-
-Una vez que tengas estas cosas listas, puedes proceder al siguiente paso.
-Paso 1: Descargar el juego ISO y el parche en inglés
-El primer paso es descargar el juego ISO y el parche en inglés de fuentes confiables. Puede encontrarlos en varios sitios web, como CDRomance , Nicoblog , o Romhacking.net . Sin embargo, debe tener cuidado ya que algunos sitios web pueden contener malware o virus que pueden dañar su PC o PSP. También deberías revisar los comentarios y reseñas de otros usuarios antes de descargar nada.
-Después de descargar el juego ISO y el parche en inglés, debe verificar los archivos y extraerlos. Puede utilizar una herramienta como 7-Zip o WinRAR para extraer los archivos de sus formatos comprimidos. También debe usar una herramienta como HashTab para verificar las sumas de verificación de los archivos y asegurarse de que no están dañados o manipulados. Las sumas de verificación suelen ser proporcionados por los cargadores de los archivos, y deben coincidir con los que obtiene de su herramienta.
Paso 2: Aplicar el parche en inglés al juego ISO
-El siguiente paso es aplicar el parche en inglés a la ISO del juego. Necesitará algunas herramientas para hacer esto, como Xdelta o PPF-O-Matic . Estas herramientas pueden aplicar un archivo de parche a un archivo de origen y crear un nuevo archivo con los cambios. Puedes encontrar estas herramientas en línea, pero de nuevo, ten cuidado con el malware o los virus.
-
-Después de parchear el juego ISO, usted debe tener un nuevo archivo que tiene la traducción al inglés aplicado. Puede comprobar el tamaño y el nombre del archivo y compararlo con los dados por los creadores del parche en inglés. También puedes probar la ISO del juego parcheado en tu PC usando un emulador de PSP, como PPSSPP , para ver si funciona correctamente y no tiene errores o fallos.
-Paso 3: Transferir el juego parcheado ISO a su PSP
-El paso final es transferir el juego parcheado ISO a su dispositivo PSP. Tendrá que conectar su PSP a su PC mediante un cable USB. Entonces, tendrá que crear una carpeta para juegos de PSP en su tarjeta de memoria. La carpeta debe llamarse ISO y debe estar ubicada en el directorio raíz de su tarjeta de memoria. Si ya tiene esta carpeta, puede omitir este paso.
-
-A continuación, tendrá que copiar el juego parcheado ISO a su carpeta PSP. Puede utilizar una herramienta como Explorador de Windows o ) A list of possible signature
- versions, including s3, v4, v2, and s3v4
- - protocols: (list) A list of supported protocols
- (e.g., http, https)
- - ...: Other keys may be included as well based on the metadata
- """
- raise NotImplementedError
-
- def get_available_partitions(self):
- """Lists the partitions available to the endpoint resolver.
-
- :return: Returns a list of partition names (e.g., ["aws", "aws-cn"]).
- """
- raise NotImplementedError
-
- def get_available_endpoints(
- self, service_name, partition_name='aws', allow_non_regional=False
- ):
- """Lists the endpoint names of a particular partition.
-
- :type service_name: string
- :param service_name: Name of a service to list endpoint for (e.g., s3)
-
- :type partition_name: string
- :param partition_name: Name of the partition to limit endpoints to.
- (e.g., aws for the public AWS endpoints, aws-cn for AWS China
- endpoints, aws-us-gov for AWS GovCloud (US) Endpoints, etc.
-
- :type allow_non_regional: bool
- :param allow_non_regional: Set to True to include endpoints that are
- not regional endpoints (e.g., s3-external-1,
- fips-us-gov-west-1, etc).
- :return: Returns a list of endpoint names (e.g., ["us-east-1"]).
- """
- raise NotImplementedError
-
-
-class EndpointResolver(BaseEndpointResolver):
- """Resolves endpoints based on partition endpoint metadata"""
-
- _UNSUPPORTED_DUALSTACK_PARTITIONS = ['aws-iso', 'aws-iso-b']
-
- def __init__(self, endpoint_data, uses_builtin_data=False):
- """
- :type endpoint_data: dict
- :param endpoint_data: A dict of partition data.
-
- :type uses_builtin_data: boolean
- :param uses_builtin_data: Whether the endpoint data originates in the
- package's data directory.
- """
- if 'partitions' not in endpoint_data:
- raise ValueError('Missing "partitions" in endpoint data')
- self._endpoint_data = endpoint_data
- self.uses_builtin_data = uses_builtin_data
-
- def get_service_endpoints_data(self, service_name, partition_name='aws'):
- for partition in self._endpoint_data['partitions']:
- if partition['partition'] != partition_name:
- continue
- services = partition['services']
- if service_name not in services:
- continue
- return services[service_name]['endpoints']
-
- def get_available_partitions(self):
- result = []
- for partition in self._endpoint_data['partitions']:
- result.append(partition['partition'])
- return result
-
- def get_available_endpoints(
- self,
- service_name,
- partition_name='aws',
- allow_non_regional=False,
- endpoint_variant_tags=None,
- ):
- result = []
- for partition in self._endpoint_data['partitions']:
- if partition['partition'] != partition_name:
- continue
- services = partition['services']
- if service_name not in services:
- continue
- service_endpoints = services[service_name]['endpoints']
- for endpoint_name in service_endpoints:
- is_regional_endpoint = endpoint_name in partition['regions']
- # Only regional endpoints can be modeled with variants
- if endpoint_variant_tags and is_regional_endpoint:
- variant_data = self._retrieve_variant_data(
- service_endpoints[endpoint_name], endpoint_variant_tags
- )
- if variant_data:
- result.append(endpoint_name)
- elif allow_non_regional or is_regional_endpoint:
- result.append(endpoint_name)
- return result
-
- def get_partition_dns_suffix(
- self, partition_name, endpoint_variant_tags=None
- ):
- for partition in self._endpoint_data['partitions']:
- if partition['partition'] == partition_name:
- if endpoint_variant_tags:
- variant = self._retrieve_variant_data(
- partition.get('defaults'), endpoint_variant_tags
- )
- if variant and 'dnsSuffix' in variant:
- return variant['dnsSuffix']
- else:
- return partition['dnsSuffix']
- return None
-
- def construct_endpoint(
- self,
- service_name,
- region_name=None,
- partition_name=None,
- use_dualstack_endpoint=False,
- use_fips_endpoint=False,
- ):
- if (
- service_name == 's3'
- and use_dualstack_endpoint
- and region_name is None
- ):
- region_name = 'us-east-1'
-
- if partition_name is not None:
- valid_partition = None
- for partition in self._endpoint_data['partitions']:
- if partition['partition'] == partition_name:
- valid_partition = partition
-
- if valid_partition is not None:
- result = self._endpoint_for_partition(
- valid_partition,
- service_name,
- region_name,
- use_dualstack_endpoint,
- use_fips_endpoint,
- True,
- )
- return result
- return None
-
- # Iterate over each partition until a match is found.
- for partition in self._endpoint_data['partitions']:
- if use_dualstack_endpoint and (
- partition['partition']
- in self._UNSUPPORTED_DUALSTACK_PARTITIONS
- ):
- continue
- result = self._endpoint_for_partition(
- partition,
- service_name,
- region_name,
- use_dualstack_endpoint,
- use_fips_endpoint,
- )
- if result:
- return result
-
- def get_partition_for_region(self, region_name):
- for partition in self._endpoint_data['partitions']:
- if self._region_match(partition, region_name):
- return partition['partition']
- raise UnknownRegionError(
- region_name=region_name,
- error_msg='No partition found for provided region_name.',
- )
-
- def _endpoint_for_partition(
- self,
- partition,
- service_name,
- region_name,
- use_dualstack_endpoint,
- use_fips_endpoint,
- force_partition=False,
- ):
- partition_name = partition["partition"]
- if (
- use_dualstack_endpoint
- and partition_name in self._UNSUPPORTED_DUALSTACK_PARTITIONS
- ):
- error_msg = (
- "Dualstack endpoints are currently not supported"
- " for %s partition" % partition_name
- )
- raise EndpointVariantError(tags=['dualstack'], error_msg=error_msg)
-
- # Get the service from the partition, or an empty template.
- service_data = partition['services'].get(
- service_name, DEFAULT_SERVICE_DATA
- )
- # Use the partition endpoint if no region is supplied.
- if region_name is None:
- if 'partitionEndpoint' in service_data:
- region_name = service_data['partitionEndpoint']
- else:
- raise NoRegionError()
-
- resolve_kwargs = {
- 'partition': partition,
- 'service_name': service_name,
- 'service_data': service_data,
- 'endpoint_name': region_name,
- 'use_dualstack_endpoint': use_dualstack_endpoint,
- 'use_fips_endpoint': use_fips_endpoint,
- }
-
- # Attempt to resolve the exact region for this partition.
- if region_name in service_data['endpoints']:
- return self._resolve(**resolve_kwargs)
-
- # Check to see if the endpoint provided is valid for the partition.
- if self._region_match(partition, region_name) or force_partition:
- # Use the partition endpoint if set and not regionalized.
- partition_endpoint = service_data.get('partitionEndpoint')
- is_regionalized = service_data.get('isRegionalized', True)
- if partition_endpoint and not is_regionalized:
- LOG.debug(
- 'Using partition endpoint for %s, %s: %s',
- service_name,
- region_name,
- partition_endpoint,
- )
- resolve_kwargs['endpoint_name'] = partition_endpoint
- return self._resolve(**resolve_kwargs)
- LOG.debug(
- 'Creating a regex based endpoint for %s, %s',
- service_name,
- region_name,
- )
- return self._resolve(**resolve_kwargs)
-
- def _region_match(self, partition, region_name):
- if region_name in partition['regions']:
- return True
- if 'regionRegex' in partition:
- return re.compile(partition['regionRegex']).match(region_name)
- return False
-
- def _retrieve_variant_data(self, endpoint_data, tags):
- variants = endpoint_data.get('variants', [])
- for variant in variants:
- if set(variant['tags']) == set(tags):
- result = variant.copy()
- return result
-
- def _create_tag_list(self, use_dualstack_endpoint, use_fips_endpoint):
- tags = []
- if use_dualstack_endpoint:
- tags.append('dualstack')
- if use_fips_endpoint:
- tags.append('fips')
- return tags
-
- def _resolve_variant(
- self, tags, endpoint_data, service_defaults, partition_defaults
- ):
- result = {}
- for variants in [endpoint_data, service_defaults, partition_defaults]:
- variant = self._retrieve_variant_data(variants, tags)
- if variant:
- self._merge_keys(variant, result)
- return result
-
- def _resolve(
- self,
- partition,
- service_name,
- service_data,
- endpoint_name,
- use_dualstack_endpoint,
- use_fips_endpoint,
- ):
- endpoint_data = service_data.get('endpoints', {}).get(
- endpoint_name, {}
- )
-
- if endpoint_data.get('deprecated'):
- LOG.warning(
- 'Client is configured with the deprecated endpoint: %s'
- % (endpoint_name)
- )
-
- service_defaults = service_data.get('defaults', {})
- partition_defaults = partition.get('defaults', {})
- tags = self._create_tag_list(use_dualstack_endpoint, use_fips_endpoint)
-
- if tags:
- result = self._resolve_variant(
- tags, endpoint_data, service_defaults, partition_defaults
- )
- if result == {}:
- error_msg = (
- f"Endpoint does not exist for {service_name} "
- f"in region {endpoint_name}"
- )
- raise EndpointVariantError(tags=tags, error_msg=error_msg)
- self._merge_keys(endpoint_data, result)
- else:
- result = endpoint_data
-
- # If dnsSuffix has not already been consumed from a variant definition
- if 'dnsSuffix' not in result:
- result['dnsSuffix'] = partition['dnsSuffix']
-
- result['partition'] = partition['partition']
- result['endpointName'] = endpoint_name
-
- # Merge in the service defaults then the partition defaults.
- self._merge_keys(service_defaults, result)
- self._merge_keys(partition_defaults, result)
-
- result['hostname'] = self._expand_template(
- partition,
- result['hostname'],
- service_name,
- endpoint_name,
- result['dnsSuffix'],
- )
- if 'sslCommonName' in result:
- result['sslCommonName'] = self._expand_template(
- partition,
- result['sslCommonName'],
- service_name,
- endpoint_name,
- result['dnsSuffix'],
- )
-
- return result
-
- def _merge_keys(self, from_data, result):
- for key in from_data:
- if key not in result:
- result[key] = from_data[key]
-
- def _expand_template(
- self, partition, template, service_name, endpoint_name, dnsSuffix
- ):
- return template.format(
- service=service_name, region=endpoint_name, dnsSuffix=dnsSuffix
- )
-
-
-class EndpointResolverBuiltins(str, Enum):
- # The AWS Region configured for the SDK client (str)
- AWS_REGION = "AWS::Region"
- # Whether the UseFIPSEndpoint configuration option has been enabled for
- # the SDK client (bool)
- AWS_USE_FIPS = "AWS::UseFIPS"
- # Whether the UseDualStackEndpoint configuration option has been enabled
- # for the SDK client (bool)
- AWS_USE_DUALSTACK = "AWS::UseDualStack"
- # Whether the global endpoint should be used with STS, rather the the
- # regional endpoint for us-east-1 (bool)
- AWS_STS_USE_GLOBAL_ENDPOINT = "AWS::STS::UseGlobalEndpoint"
- # Whether the global endpoint should be used with S3, rather then the
- # regional endpoint for us-east-1 (bool)
- AWS_S3_USE_GLOBAL_ENDPOINT = "AWS::S3::UseGlobalEndpoint"
- # Whether S3 Transfer Acceleration has been requested (bool)
- AWS_S3_ACCELERATE = "AWS::S3::Accelerate"
- # Whether S3 Force Path Style has been enabled (bool)
- AWS_S3_FORCE_PATH_STYLE = "AWS::S3::ForcePathStyle"
- # Whether to use the ARN region or raise an error when ARN and client
- # region differ (for s3 service only, bool)
- AWS_S3_USE_ARN_REGION = "AWS::S3::UseArnRegion"
- # Whether to use the ARN region or raise an error when ARN and client
- # region differ (for s3-control service only, bool)
- AWS_S3CONTROL_USE_ARN_REGION = 'AWS::S3Control::UseArnRegion'
- # Whether multi-region access points (MRAP) should be disabled (bool)
- AWS_S3_DISABLE_MRAP = "AWS::S3::DisableMultiRegionAccessPoints"
- # Whether a custom endpoint has been configured (str)
- SDK_ENDPOINT = "SDK::Endpoint"
-
-
-class EndpointRulesetResolver:
- """Resolves endpoints using a service's endpoint ruleset"""
-
- def __init__(
- self,
- endpoint_ruleset_data,
- partition_data,
- service_model,
- builtins,
- client_context,
- event_emitter,
- use_ssl=True,
- requested_auth_scheme=None,
- ):
- self._provider = EndpointProvider(
- ruleset_data=endpoint_ruleset_data,
- partition_data=partition_data,
- )
- self._param_definitions = self._provider.ruleset.parameters
- self._service_model = service_model
- self._builtins = builtins
- self._client_context = client_context
- self._event_emitter = event_emitter
- self._use_ssl = use_ssl
- self._requested_auth_scheme = requested_auth_scheme
- self._instance_cache = {}
-
- def construct_endpoint(
- self,
- operation_model,
- call_args,
- request_context,
- ):
- """Invokes the provider with params defined in the service's ruleset"""
- if call_args is None:
- call_args = {}
-
- if request_context is None:
- request_context = {}
-
- provider_params = self._get_provider_params(
- operation_model, call_args, request_context
- )
- LOG.debug(
- 'Calling endpoint provider with parameters: %s' % provider_params
- )
- try:
- provider_result = self._provider.resolve_endpoint(
- **provider_params
- )
- except EndpointProviderError as ex:
- botocore_exception = self.ruleset_error_to_botocore_exception(
- ex, provider_params
- )
- if botocore_exception is None:
- raise
- else:
- raise botocore_exception from ex
- LOG.debug('Endpoint provider result: %s' % provider_result.url)
-
- # The endpoint provider does not support non-secure transport.
- if not self._use_ssl and provider_result.url.startswith('https://'):
- provider_result = provider_result._replace(
- url=f'http://{provider_result.url[8:]}'
- )
-
- # Multi-valued headers are not supported in botocore. Replace the list
- # of values returned for each header with just its first entry,
- # dropping any additionally entries.
- provider_result = provider_result._replace(
- headers={
- key: val[0] for key, val in provider_result.headers.items()
- }
- )
-
- return provider_result
-
- def _get_provider_params(
- self, operation_model, call_args, request_context
- ):
- """Resolve a value for each parameter defined in the service's ruleset
-
- The resolution order for parameter values is:
- 1. Operation-specific static context values from the service definition
- 2. Operation-specific dynamic context values from API parameters
- 3. Client-specific context parameters
- 4. Built-in values such as region, FIPS usage, ...
- """
- provider_params = {}
- # Builtin values can be customized for each operation by hooks
- # subscribing to the ``before-endpoint-resolution.*`` event.
- customized_builtins = self._get_customized_builtins(
- operation_model, call_args, request_context
- )
- for param_name, param_def in self._param_definitions.items():
- param_val = self._resolve_param_from_context(
- param_name=param_name,
- operation_model=operation_model,
- call_args=call_args,
- )
- if param_val is None and param_def.builtin is not None:
- param_val = self._resolve_param_as_builtin(
- builtin_name=param_def.builtin,
- builtins=customized_builtins,
- )
- if param_val is not None:
- provider_params[param_name] = param_val
-
- return provider_params
-
- def _resolve_param_from_context(
- self, param_name, operation_model, call_args
- ):
- static = self._resolve_param_as_static_context_param(
- param_name, operation_model
- )
- if static is not None:
- return static
- dynamic = self._resolve_param_as_dynamic_context_param(
- param_name, operation_model, call_args
- )
- if dynamic is not None:
- return dynamic
- return self._resolve_param_as_client_context_param(param_name)
-
- def _resolve_param_as_static_context_param(
- self, param_name, operation_model
- ):
- static_ctx_params = self._get_static_context_params(operation_model)
- return static_ctx_params.get(param_name)
-
- def _resolve_param_as_dynamic_context_param(
- self, param_name, operation_model, call_args
- ):
- dynamic_ctx_params = self._get_dynamic_context_params(operation_model)
- if param_name in dynamic_ctx_params:
- member_name = dynamic_ctx_params[param_name]
- return call_args.get(member_name)
-
- def _resolve_param_as_client_context_param(self, param_name):
- client_ctx_params = self._get_client_context_params()
- if param_name in client_ctx_params:
- client_ctx_varname = client_ctx_params[param_name]
- return self._client_context.get(client_ctx_varname)
-
- def _resolve_param_as_builtin(self, builtin_name, builtins):
- if builtin_name not in EndpointResolverBuiltins.__members__.values():
- raise UnknownEndpointResolutionBuiltInName(name=builtin_name)
- return builtins.get(builtin_name)
-
- @instance_cache
- def _get_static_context_params(self, operation_model):
- """Mapping of param names to static param value for an operation"""
- return {
- param.name: param.value
- for param in operation_model.static_context_parameters
- }
-
- @instance_cache
- def _get_dynamic_context_params(self, operation_model):
- """Mapping of param names to member names for an operation"""
- return {
- param.name: param.member_name
- for param in operation_model.context_parameters
- }
-
- @instance_cache
- def _get_client_context_params(self):
- """Mapping of param names to client configuration variable"""
- return {
- param.name: xform_name(param.name)
- for param in self._service_model.client_context_parameters
- }
-
- def _get_customized_builtins(
- self, operation_model, call_args, request_context
- ):
- service_id = self._service_model.service_id.hyphenize()
- customized_builtins = copy.copy(self._builtins)
- # Handlers are expected to modify the builtins dict in place.
- self._event_emitter.emit(
- 'before-endpoint-resolution.%s' % service_id,
- builtins=customized_builtins,
- model=operation_model,
- params=call_args,
- context=request_context,
- )
- return customized_builtins
-
- def auth_schemes_to_signing_ctx(self, auth_schemes):
- """Convert an Endpoint's authSchemes property to a signing_context dict
-
- :type auth_schemes: list
- :param auth_schemes: A list of dictionaries taken from the
- ``authSchemes`` property of an Endpoint object returned by
- ``EndpointProvider``.
-
- :rtype: str, dict
- :return: Tuple of auth type string (to be used in
- ``request_context['auth_type']``) and signing context dict (for use
- in ``request_context['signing']``).
- """
- if not isinstance(auth_schemes, list) or len(auth_schemes) == 0:
- raise TypeError("auth_schemes must be a non-empty list.")
-
- LOG.debug(
- 'Selecting from endpoint provider\'s list of auth schemes: %s. '
- 'User selected auth scheme is: "%s"',
- ', '.join([f'"{s.get("name")}"' for s in auth_schemes]),
- self._requested_auth_scheme,
- )
-
- if self._requested_auth_scheme == UNSIGNED:
- return 'none', {}
-
- auth_schemes = [
- {**scheme, 'name': self._strip_sig_prefix(scheme['name'])}
- for scheme in auth_schemes
- ]
- if self._requested_auth_scheme is not None:
- try:
- # Use the first scheme that matches the requested scheme,
- # after accounting for naming differences between botocore and
- # endpoint rulesets. Keep the requested name.
- name, scheme = next(
- (self._requested_auth_scheme, s)
- for s in auth_schemes
- if self._does_botocore_authname_match_ruleset_authname(
- self._requested_auth_scheme, s['name']
- )
- )
- except StopIteration:
- # For legacy signers, no match will be found. Do not raise an
- # exception, instead default to the logic in botocore
- # customizations.
- return None, {}
- else:
- try:
- name, scheme = next(
- (s['name'], s)
- for s in auth_schemes
- if s['name'] in AUTH_TYPE_MAPS
- )
- except StopIteration:
- # If no auth scheme was specifically requested and an
- # authSchemes list is present in the Endpoint object but none
- # of the entries are supported, raise an exception.
- fixable_with_crt = False
- auth_type_options = [s['name'] for s in auth_schemes]
- if not HAS_CRT:
- fixable_with_crt = any(
- scheme in CRT_SUPPORTED_AUTH_TYPES
- for scheme in auth_type_options
- )
-
- if fixable_with_crt:
- raise MissingDependencyException(
- msg='This operation requires an additional dependency.'
- ' Use pip install botocore[crt] before proceeding.'
- )
- else:
- raise UnknownSignatureVersionError(
- signature_version=', '.join(auth_type_options)
- )
-
- signing_context = {}
- if 'signingRegion' in scheme:
- signing_context['region'] = scheme['signingRegion']
- elif 'signingRegionSet' in scheme:
- if len(scheme['signingRegionSet']) > 0:
- signing_context['region'] = scheme['signingRegionSet'][0]
- if 'signingName' in scheme:
- signing_context.update(signing_name=scheme['signingName'])
- if 'disableDoubleEncoding' in scheme:
- signing_context['disableDoubleEncoding'] = ensure_boolean(
- scheme['disableDoubleEncoding']
- )
-
- LOG.debug(
- 'Selected auth type "%s" as "%s" with signing context params: %s',
- scheme['name'], # original name without "sig"
- name, # chosen name can differ when `signature_version` is set
- signing_context,
- )
- return name, signing_context
-
- def _strip_sig_prefix(self, auth_name):
- """Normalize auth type names by removing any "sig" prefix"""
- return auth_name[3:] if auth_name.startswith('sig') else auth_name
-
- def _does_botocore_authname_match_ruleset_authname(self, botoname, rsname):
- """
- Whether a valid string provided as signature_version parameter for
- client construction refers to the same auth methods as a string
- returned by the endpoint ruleset provider. This accounts for:
-
- * The ruleset prefixes auth names with "sig"
- * The s3 and s3control rulesets don't distinguish between v4[a] and
- s3v4[a] signers
- * The v2, v3, and HMAC v1 based signers (s3, s3-*) are botocore legacy
- features and do not exist in the rulesets
- * Only characters up to the first dash are considered
-
- Example matches:
- * v4, sigv4
- * v4, v4
- * s3v4, sigv4
- * s3v7, sigv7 (hypothetical example)
- * s3v4a, sigv4a
- * s3v4-query, sigv4
-
- Example mismatches:
- * v4a, sigv4
- * s3, sigv4
- * s3-presign-post, sigv4
- """
- rsname = self._strip_sig_prefix(rsname)
- botoname = botoname.split('-')[0]
- if botoname != 's3' and botoname.startswith('s3'):
- botoname = botoname[2:]
- return rsname == botoname
-
- def ruleset_error_to_botocore_exception(self, ruleset_exception, params):
- """Attempts to translate ruleset errors to pre-existing botocore
- exception types by string matching exception strings.
- """
- msg = ruleset_exception.kwargs.get('msg')
- if msg is None:
- return
-
- if msg.startswith('Invalid region in ARN: '):
- # Example message:
- # "Invalid region in ARN: `us-we$t-2` (invalid DNS name)"
- try:
- label = msg.split('`')[1]
- except IndexError:
- label = msg
- return InvalidHostLabelError(label=label)
-
- service_name = self._service_model.service_name
- if service_name == 's3':
- if (
- msg == 'S3 Object Lambda does not support S3 Accelerate'
- or msg == 'Accelerate cannot be used with FIPS'
- ):
- return UnsupportedS3ConfigurationError(msg=msg)
- if (
- msg.startswith('S3 Outposts does not support')
- or msg.startswith('S3 MRAP does not support')
- or msg.startswith('S3 Object Lambda does not support')
- or msg.startswith('Access Points do not support')
- or msg.startswith('Invalid configuration:')
- or msg.startswith('Client was configured for partition')
- ):
- return UnsupportedS3AccesspointConfigurationError(msg=msg)
- if msg.lower().startswith('invalid arn:'):
- return ParamValidationError(report=msg)
- if service_name == 's3control':
- if msg.startswith('Invalid ARN:'):
- arn = params.get('Bucket')
- return UnsupportedS3ControlArnError(arn=arn, msg=msg)
- if msg.startswith('Invalid configuration:') or msg.startswith(
- 'Client was configured for partition'
- ):
- return UnsupportedS3ControlConfigurationError(msg=msg)
- if msg == "AccountId is required but not set":
- return ParamValidationError(report=msg)
- if service_name == 'events':
- if msg.startswith(
- 'Invalid Configuration: FIPS is not supported with '
- 'EventBridge multi-region endpoints.'
- ):
- return InvalidEndpointConfigurationError(msg=msg)
- if msg == 'EndpointId must be a valid host label.':
- return InvalidEndpointConfigurationError(msg=msg)
- return None
diff --git a/spaces/BigBoyBranding/README/README.md b/spaces/BigBoyBranding/README/README.md
deleted file mode 100644
index acb7726e157c447579e0aac623d25363a7c9f93d..0000000000000000000000000000000000000000
--- a/spaces/BigBoyBranding/README/README.md
+++ /dev/null
@@ -1,10 +0,0 @@
----
-title: README
-emoji: 🏃
-colorFrom: red
-colorTo: indigo
-sdk: static
-pinned: false
----
-
-Big Bird's Ballsack
\ No newline at end of file
diff --git a/spaces/CVPR/Dual-Key_Backdoor_Attacks/datagen/detectron2/tools/README.md b/spaces/CVPR/Dual-Key_Backdoor_Attacks/datagen/detectron2/tools/README.md
deleted file mode 100644
index 3733863970218bf8bdf9b32420163f4c858e209e..0000000000000000000000000000000000000000
--- a/spaces/CVPR/Dual-Key_Backdoor_Attacks/datagen/detectron2/tools/README.md
+++ /dev/null
@@ -1,45 +0,0 @@
-
-This directory contains a few scripts that use detectron2.
-
-
-* `train_net.py`
-
-An example training script that's made to train builtin models of detectron2.
-
-For usage, see [GETTING_STARTED.md](../GETTING_STARTED.md).
-
-* `plain_train_net.py`
-
-Similar to `train_net.py`, but implements a training loop instead of using `Trainer`.
-This script includes fewer features but it may be more friendly to hackers.
-
-* `benchmark.py`
-
-Benchmark the training speed, inference speed or data loading speed of a given config.
-
-Usage:
-```
-python benchmark.py --config-file config.yaml --task train/eval/data [optional DDP flags]
-```
-
-* `visualize_json_results.py`
-
-Visualize the json instance detection/segmentation results dumped by `COCOEvalutor` or `LVISEvaluator`
-
-Usage:
-```
-python visualize_json_results.py --input x.json --output dir/ --dataset coco_2017_val
-```
-If not using a builtin dataset, you'll need your own script or modify this script.
-
-* `visualize_data.py`
-
-Visualize ground truth raw annotations or training data (after preprocessing/augmentations).
-
-Usage:
-```
-python visualize_data.py --config-file config.yaml --source annotation/dataloader --output-dir dir/ [--show]
-```
-
-NOTE: the script does not stop by itself when using `--source dataloader` because a training
-dataloader is usually infinite.
diff --git a/spaces/CVPR/Text2Human/Text2Human/models/archs/shape_attr_embedding_arch.py b/spaces/CVPR/Text2Human/Text2Human/models/archs/shape_attr_embedding_arch.py
deleted file mode 100644
index 217c179be3591173596bac7eb1df277e6b1a3c23..0000000000000000000000000000000000000000
--- a/spaces/CVPR/Text2Human/Text2Human/models/archs/shape_attr_embedding_arch.py
+++ /dev/null
@@ -1,35 +0,0 @@
-import torch
-import torch.nn.functional as F
-from torch import nn
-
-
-class ShapeAttrEmbedding(nn.Module):
-
- def __init__(self, dim, out_dim, cls_num_list):
- super(ShapeAttrEmbedding, self).__init__()
-
- for idx, cls_num in enumerate(cls_num_list):
- setattr(
- self, f'attr_{idx}',
- nn.Sequential(
- nn.Linear(cls_num, dim), nn.LeakyReLU(),
- nn.Linear(dim, dim)))
- self.cls_num_list = cls_num_list
- self.attr_num = len(cls_num_list)
- self.fusion = nn.Sequential(
- nn.Linear(dim * self.attr_num, out_dim), nn.LeakyReLU(),
- nn.Linear(out_dim, out_dim))
-
- def forward(self, attr):
- attr_embedding_list = []
- for idx in range(self.attr_num):
- attr_embed_fc = getattr(self, f'attr_{idx}')
- attr_embedding_list.append(
- attr_embed_fc(
- F.one_hot(
- attr[:, idx],
- num_classes=self.cls_num_list[idx]).to(torch.float32)))
- attr_embedding = torch.cat(attr_embedding_list, dim=1)
- attr_embedding = self.fusion(attr_embedding)
-
- return attr_embedding
diff --git a/spaces/CVPR/WALT/mmdet/models/roi_heads/mask_heads/feature_relay_head.py b/spaces/CVPR/WALT/mmdet/models/roi_heads/mask_heads/feature_relay_head.py
deleted file mode 100644
index a1cfb2ce8631d51e5c465f9bbc4164a37acc4782..0000000000000000000000000000000000000000
--- a/spaces/CVPR/WALT/mmdet/models/roi_heads/mask_heads/feature_relay_head.py
+++ /dev/null
@@ -1,55 +0,0 @@
-import torch.nn as nn
-from mmcv.cnn import kaiming_init
-from mmcv.runner import auto_fp16
-
-from mmdet.models.builder import HEADS
-
-
-@HEADS.register_module()
-class FeatureRelayHead(nn.Module):
- """Feature Relay Head used in `SCNet `_.
-
- Args:
- in_channels (int, optional): number of input channels. Default: 256.
- conv_out_channels (int, optional): number of output channels before
- classification layer. Default: 256.
- roi_feat_size (int, optional): roi feat size at box head. Default: 7.
- scale_factor (int, optional): scale factor to match roi feat size
- at mask head. Default: 2.
- """
-
- def __init__(self,
- in_channels=1024,
- out_conv_channels=256,
- roi_feat_size=7,
- scale_factor=2):
- super(FeatureRelayHead, self).__init__()
- assert isinstance(roi_feat_size, int)
-
- self.in_channels = in_channels
- self.out_conv_channels = out_conv_channels
- self.roi_feat_size = roi_feat_size
- self.out_channels = (roi_feat_size**2) * out_conv_channels
- self.scale_factor = scale_factor
- self.fp16_enabled = False
-
- self.fc = nn.Linear(self.in_channels, self.out_channels)
- self.upsample = nn.Upsample(
- scale_factor=scale_factor, mode='bilinear', align_corners=True)
-
- def init_weights(self):
- """Init weights for the head."""
- kaiming_init(self.fc)
-
- @auto_fp16()
- def forward(self, x):
- """Forward function."""
- N, in_C = x.shape
- if N > 0:
- out_C = self.out_conv_channels
- out_HW = self.roi_feat_size
- x = self.fc(x)
- x = x.reshape(N, out_C, out_HW, out_HW)
- x = self.upsample(x)
- return x
- return None
diff --git a/spaces/CVPR/lama-example/bin/paper_runfiles/find_best_checkpoint.py b/spaces/CVPR/lama-example/bin/paper_runfiles/find_best_checkpoint.py
deleted file mode 100644
index 42f5e0f9bb1a2ea25dd9a97a58cf318e6de19532..0000000000000000000000000000000000000000
--- a/spaces/CVPR/lama-example/bin/paper_runfiles/find_best_checkpoint.py
+++ /dev/null
@@ -1,54 +0,0 @@
-#!/usr/bin/env python3
-
-
-import os
-from argparse import ArgumentParser
-
-
-def ssim_fid100_f1(metrics, fid_scale=100):
- ssim = metrics.loc['total', 'ssim']['mean']
- fid = metrics.loc['total', 'fid']['mean']
- fid_rel = max(0, fid_scale - fid) / fid_scale
- f1 = 2 * ssim * fid_rel / (ssim + fid_rel + 1e-3)
- return f1
-
-
-def find_best_checkpoint(model_list, models_dir):
- with open(model_list) as f:
- models = [m.strip() for m in f.readlines()]
- with open(f'{model_list}_best', 'w') as f:
- for model in models:
- print(model)
- best_f1 = 0
- best_epoch = 0
- best_step = 0
- with open(os.path.join(models_dir, model, 'train.log')) as fm:
- lines = fm.readlines()
- for line_index in range(len(lines)):
- line = lines[line_index]
- if 'Validation metrics after epoch' in line:
- sharp_index = line.index('#')
- cur_ep = line[sharp_index + 1:]
- comma_index = cur_ep.index(',')
- cur_ep = int(cur_ep[:comma_index])
- total_index = line.index('total ')
- step = int(line[total_index:].split()[1].strip())
- total_line = lines[line_index + 5]
- if not total_line.startswith('total'):
- continue
- words = total_line.strip().split()
- f1 = float(words[-1])
- print(f'\tEpoch: {cur_ep}, f1={f1}')
- if f1 > best_f1:
- best_f1 = f1
- best_epoch = cur_ep
- best_step = step
- f.write(f'{model}\t{best_epoch}\t{best_step}\t{best_f1}\n')
-
-
-if __name__ == '__main__':
- parser = ArgumentParser()
- parser.add_argument('model_list')
- parser.add_argument('models_dir')
- args = parser.parse_args()
- find_best_checkpoint(args.model_list, args.models_dir)
diff --git a/spaces/CVPR/lama-example/fetch_data/sampler.py b/spaces/CVPR/lama-example/fetch_data/sampler.py
deleted file mode 100644
index b25fa1fefc20f7f4eea7dbb69e54a8075570a1d1..0000000000000000000000000000000000000000
--- a/spaces/CVPR/lama-example/fetch_data/sampler.py
+++ /dev/null
@@ -1,39 +0,0 @@
-import os
-import random
-
-test_files_path = os.path.abspath('.') + '/places_standard_dataset/original/test/'
-test_files = [test_files_path + image for image in os.listdir(test_files_path)]
-print(f'found {len(test_files)} images in {test_files_path}')
-
-random.shuffle(test_files)
-test_files_random = test_files[0:2000]
-#print(test_files_random[0:10])
-
-list_of_random_test_files = os.path.abspath('.') \
-+ '/places_standard_dataset/original/test_random_files.txt'
-
-print(f'copying 100 random images to {list_of_random_test_files}')
-with open(list_of_random_test_files, 'w') as fw:
- for filename in test_files_random:
- fw.write(filename+'\n')
-print('...done')
-
-# ----------------------------------------------------------------------------------
-
-
-val_files_path = os.path.abspath('.') + '/places_standard_dataset/original/val/'
-val_files = [val_files_path + image for image in os.listdir(val_files_path)]
-print(f'found {len(val_files)} images in {val_files_path}')
-
-random.shuffle(val_files)
-val_files_random = val_files[0:100]
-
-list_of_random_val_files = os.path.abspath('.') \
-+ '/places_standard_dataset/original/val_random_files.txt'
-
-print(f'copying 100 random images to {list_of_random_val_files}')
-with open(list_of_random_val_files, 'w') as fw:
- for filename in val_files_random:
- fw.write(filename+'\n')
-print('...done')
-
diff --git a/spaces/ChrisPreston/diff-svc_minato_aqua/utils/svc_utils.py b/spaces/ChrisPreston/diff-svc_minato_aqua/utils/svc_utils.py
deleted file mode 100644
index 6fea0c1ee280fa7c8927c3d692a482fd50f6660a..0000000000000000000000000000000000000000
--- a/spaces/ChrisPreston/diff-svc_minato_aqua/utils/svc_utils.py
+++ /dev/null
@@ -1,141 +0,0 @@
-import glob
-import importlib
-import os
-
-import matplotlib
-import numpy as np
-import torch
-import torch.distributions
-import torch.optim
-import torch.optim
-import torch.utils.data
-
-from preprocessing.process_pipeline import File2Batch
-from utils.hparams import hparams
-from utils.indexed_datasets import IndexedDataset
-from utils.pitch_utils import norm_interp_f0
-
-matplotlib.use('Agg')
-
-
-class SvcDataset(torch.utils.data.Dataset):
- def __init__(self, prefix, shuffle=False):
- super().__init__()
- self.hparams = hparams
- self.shuffle = shuffle
- self.sort_by_len = hparams['sort_by_len']
- self.sizes = None
- self.data_dir = hparams['binary_data_dir']
- self.prefix = prefix
- self.sizes = np.load(f'{self.data_dir}/{self.prefix}_lengths.npy')
- self.indexed_ds = None
- # self.name2spk_id={}
-
- # pitch stats
- f0_stats_fn = f'{self.data_dir}/train_f0s_mean_std.npy'
- if os.path.exists(f0_stats_fn):
- hparams['f0_mean'], hparams['f0_std'] = self.f0_mean, self.f0_std = np.load(f0_stats_fn)
- hparams['f0_mean'] = float(hparams['f0_mean'])
- hparams['f0_std'] = float(hparams['f0_std'])
- else:
- hparams['f0_mean'], hparams['f0_std'] = self.f0_mean, self.f0_std = None, None
-
- if prefix == 'test':
- if hparams['test_input_dir'] != '':
- self.indexed_ds, self.sizes = self.load_test_inputs(hparams['test_input_dir'])
- else:
- if hparams['num_test_samples'] > 0:
- self.avail_idxs = list(range(hparams['num_test_samples'])) + hparams['test_ids']
- self.sizes = [self.sizes[i] for i in self.avail_idxs]
-
- @property
- def _sizes(self):
- return self.sizes
-
- def _get_item(self, index):
- if hasattr(self, 'avail_idxs') and self.avail_idxs is not None:
- index = self.avail_idxs[index]
- if self.indexed_ds is None:
- self.indexed_ds = IndexedDataset(f'{self.data_dir}/{self.prefix}')
- return self.indexed_ds[index]
-
- def __getitem__(self, index):
- item = self._get_item(index)
- max_frames = hparams['max_frames']
- spec = torch.Tensor(item['mel'])[:max_frames]
- # energy = (spec.exp() ** 2).sum(-1).sqrt()
- mel2ph = torch.LongTensor(item['mel2ph'])[:max_frames] if 'mel2ph' in item else None
- f0, uv = norm_interp_f0(item["f0"][:max_frames], hparams)
- hubert = torch.Tensor(item['hubert'][:hparams['max_input_tokens']])
- pitch = torch.LongTensor(item.get("pitch"))[:max_frames]
- sample = {
- "id": index,
- "item_name": item['item_name'],
- "hubert": hubert,
- "mel": spec,
- "pitch": pitch,
- "f0": f0,
- "uv": uv,
- "mel2ph": mel2ph,
- "mel_nonpadding": spec.abs().sum(-1) > 0,
- }
- if hparams['use_energy_embed']:
- sample['energy'] = item['energy']
- if hparams['use_spk_embed']:
- sample["spk_embed"] = torch.Tensor(item['spk_embed'])
- if hparams['use_spk_id']:
- sample["spk_id"] = item['spk_id']
- return sample
-
- @staticmethod
- def collater(samples):
- return File2Batch.processed_input2batch(samples)
-
- @staticmethod
- def load_test_inputs(test_input_dir):
- inp_wav_paths = glob.glob(f'{test_input_dir}/*.wav') + glob.glob(f'{test_input_dir}/*.mp3')
- sizes = []
- items = []
-
- binarizer_cls = hparams.get("binarizer_cls", 'basics.base_binarizer.BaseBinarizer')
- pkg = ".".join(binarizer_cls.split(".")[:-1])
- cls_name = binarizer_cls.split(".")[-1]
- binarizer_cls = getattr(importlib.import_module(pkg), cls_name)
- from preprocessing.hubertinfer import HubertEncoder
- for wav_fn in inp_wav_paths:
- item_name = os.path.basename(wav_fn)
- wav_fn = wav_fn
- encoder = HubertEncoder(hparams['hubert_path'])
- item = binarizer_cls.process_item(item_name, {'wav_fn': wav_fn}, encoder)
- print(item)
- items.append(item)
- sizes.append(item['len'])
- return items, sizes
-
- def __len__(self):
- return len(self._sizes)
-
- def num_tokens(self, index):
- return self.size(index)
-
- def size(self, index):
- """Return an example's size as a float or tuple. This value is used when
- filtering a dataset with ``--max-positions``."""
- size = min(self._sizes[index], hparams['max_frames'])
- return size
-
- def ordered_indices(self):
- """Return an ordered list of indices. Batches will be constructed based
- on this order."""
- if self.shuffle:
- indices = np.random.permutation(len(self))
- if self.sort_by_len:
- indices = indices[np.argsort(np.array(self._sizes)[indices], kind='mergesort')]
- # 先random, 然后稳定排序, 保证排序后同长度的数据顺序是依照random permutation的 (被其随机打乱).
- else:
- indices = np.arange(len(self))
- return indices
-
- @property
- def num_workers(self):
- return int(os.getenv('NUM_WORKERS', hparams['ds_workers']))
diff --git a/spaces/Cicooo/vits-uma-genshin-honkai/models.py b/spaces/Cicooo/vits-uma-genshin-honkai/models.py
deleted file mode 100644
index 52e15d1b9775038fd6e82b2efe6f95f51c66802d..0000000000000000000000000000000000000000
--- a/spaces/Cicooo/vits-uma-genshin-honkai/models.py
+++ /dev/null
@@ -1,534 +0,0 @@
-import math
-import torch
-from torch import nn
-from torch.nn import functional as F
-
-import commons
-import modules
-import attentions
-import monotonic_align
-
-from torch.nn import Conv1d, ConvTranspose1d, Conv2d
-from torch.nn.utils import weight_norm, remove_weight_norm, spectral_norm
-from commons import init_weights, get_padding
-
-
-class StochasticDurationPredictor(nn.Module):
- def __init__(self, in_channels, filter_channels, kernel_size, p_dropout, n_flows=4, gin_channels=0):
- super().__init__()
- filter_channels = in_channels # it needs to be removed from future version.
- self.in_channels = in_channels
- self.filter_channels = filter_channels
- self.kernel_size = kernel_size
- self.p_dropout = p_dropout
- self.n_flows = n_flows
- self.gin_channels = gin_channels
-
- self.log_flow = modules.Log()
- self.flows = nn.ModuleList()
- self.flows.append(modules.ElementwiseAffine(2))
- for i in range(n_flows):
- self.flows.append(modules.ConvFlow(2, filter_channels, kernel_size, n_layers=3))
- self.flows.append(modules.Flip())
-
- self.post_pre = nn.Conv1d(1, filter_channels, 1)
- self.post_proj = nn.Conv1d(filter_channels, filter_channels, 1)
- self.post_convs = modules.DDSConv(filter_channels, kernel_size, n_layers=3, p_dropout=p_dropout)
- self.post_flows = nn.ModuleList()
- self.post_flows.append(modules.ElementwiseAffine(2))
- for i in range(4):
- self.post_flows.append(modules.ConvFlow(2, filter_channels, kernel_size, n_layers=3))
- self.post_flows.append(modules.Flip())
-
- self.pre = nn.Conv1d(in_channels, filter_channels, 1)
- self.proj = nn.Conv1d(filter_channels, filter_channels, 1)
- self.convs = modules.DDSConv(filter_channels, kernel_size, n_layers=3, p_dropout=p_dropout)
- if gin_channels != 0:
- self.cond = nn.Conv1d(gin_channels, filter_channels, 1)
-
- def forward(self, x, x_mask, w=None, g=None, reverse=False, noise_scale=1.0):
- x = torch.detach(x)
- x = self.pre(x)
- if g is not None:
- g = torch.detach(g)
- x = x + self.cond(g)
- x = self.convs(x, x_mask)
- x = self.proj(x) * x_mask
-
- if not reverse:
- flows = self.flows
- assert w is not None
-
- logdet_tot_q = 0
- h_w = self.post_pre(w)
- h_w = self.post_convs(h_w, x_mask)
- h_w = self.post_proj(h_w) * x_mask
- e_q = torch.randn(w.size(0), 2, w.size(2)).to(device=x.device, dtype=x.dtype) * x_mask
- z_q = e_q
- for flow in self.post_flows:
- z_q, logdet_q = flow(z_q, x_mask, g=(x + h_w))
- logdet_tot_q += logdet_q
- z_u, z1 = torch.split(z_q, [1, 1], 1)
- u = torch.sigmoid(z_u) * x_mask
- z0 = (w - u) * x_mask
- logdet_tot_q += torch.sum((F.logsigmoid(z_u) + F.logsigmoid(-z_u)) * x_mask, [1,2])
- logq = torch.sum(-0.5 * (math.log(2*math.pi) + (e_q**2)) * x_mask, [1,2]) - logdet_tot_q
-
- logdet_tot = 0
- z0, logdet = self.log_flow(z0, x_mask)
- logdet_tot += logdet
- z = torch.cat([z0, z1], 1)
- for flow in flows:
- z, logdet = flow(z, x_mask, g=x, reverse=reverse)
- logdet_tot = logdet_tot + logdet
- nll = torch.sum(0.5 * (math.log(2*math.pi) + (z**2)) * x_mask, [1,2]) - logdet_tot
- return nll + logq # [b]
- else:
- flows = list(reversed(self.flows))
- flows = flows[:-2] + [flows[-1]] # remove a useless vflow
- z = torch.randn(x.size(0), 2, x.size(2)).to(device=x.device, dtype=x.dtype) * noise_scale
- for flow in flows:
- z = flow(z, x_mask, g=x, reverse=reverse)
- z0, z1 = torch.split(z, [1, 1], 1)
- logw = z0
- return logw
-
-
-class DurationPredictor(nn.Module):
- def __init__(self, in_channels, filter_channels, kernel_size, p_dropout, gin_channels=0):
- super().__init__()
-
- self.in_channels = in_channels
- self.filter_channels = filter_channels
- self.kernel_size = kernel_size
- self.p_dropout = p_dropout
- self.gin_channels = gin_channels
-
- self.drop = nn.Dropout(p_dropout)
- self.conv_1 = nn.Conv1d(in_channels, filter_channels, kernel_size, padding=kernel_size//2)
- self.norm_1 = modules.LayerNorm(filter_channels)
- self.conv_2 = nn.Conv1d(filter_channels, filter_channels, kernel_size, padding=kernel_size//2)
- self.norm_2 = modules.LayerNorm(filter_channels)
- self.proj = nn.Conv1d(filter_channels, 1, 1)
-
- if gin_channels != 0:
- self.cond = nn.Conv1d(gin_channels, in_channels, 1)
-
- def forward(self, x, x_mask, g=None):
- x = torch.detach(x)
- if g is not None:
- g = torch.detach(g)
- x = x + self.cond(g)
- x = self.conv_1(x * x_mask)
- x = torch.relu(x)
- x = self.norm_1(x)
- x = self.drop(x)
- x = self.conv_2(x * x_mask)
- x = torch.relu(x)
- x = self.norm_2(x)
- x = self.drop(x)
- x = self.proj(x * x_mask)
- return x * x_mask
-
-
-class TextEncoder(nn.Module):
- def __init__(self,
- n_vocab,
- out_channels,
- hidden_channels,
- filter_channels,
- n_heads,
- n_layers,
- kernel_size,
- p_dropout):
- super().__init__()
- self.n_vocab = n_vocab
- self.out_channels = out_channels
- self.hidden_channels = hidden_channels
- self.filter_channels = filter_channels
- self.n_heads = n_heads
- self.n_layers = n_layers
- self.kernel_size = kernel_size
- self.p_dropout = p_dropout
-
- self.emb = nn.Embedding(n_vocab, hidden_channels)
- nn.init.normal_(self.emb.weight, 0.0, hidden_channels**-0.5)
-
- self.encoder = attentions.Encoder(
- hidden_channels,
- filter_channels,
- n_heads,
- n_layers,
- kernel_size,
- p_dropout)
- self.proj= nn.Conv1d(hidden_channels, out_channels * 2, 1)
-
- def forward(self, x, x_lengths):
- x = self.emb(x) * math.sqrt(self.hidden_channels) # [b, t, h]
- x = torch.transpose(x, 1, -1) # [b, h, t]
- x_mask = torch.unsqueeze(commons.sequence_mask(x_lengths, x.size(2)), 1).to(x.dtype)
-
- x = self.encoder(x * x_mask, x_mask)
- stats = self.proj(x) * x_mask
-
- m, logs = torch.split(stats, self.out_channels, dim=1)
- return x, m, logs, x_mask
-
-
-class ResidualCouplingBlock(nn.Module):
- def __init__(self,
- channels,
- hidden_channels,
- kernel_size,
- dilation_rate,
- n_layers,
- n_flows=4,
- gin_channels=0):
- super().__init__()
- self.channels = channels
- self.hidden_channels = hidden_channels
- self.kernel_size = kernel_size
- self.dilation_rate = dilation_rate
- self.n_layers = n_layers
- self.n_flows = n_flows
- self.gin_channels = gin_channels
-
- self.flows = nn.ModuleList()
- for i in range(n_flows):
- self.flows.append(modules.ResidualCouplingLayer(channels, hidden_channels, kernel_size, dilation_rate, n_layers, gin_channels=gin_channels, mean_only=True))
- self.flows.append(modules.Flip())
-
- def forward(self, x, x_mask, g=None, reverse=False):
- if not reverse:
- for flow in self.flows:
- x, _ = flow(x, x_mask, g=g, reverse=reverse)
- else:
- for flow in reversed(self.flows):
- x = flow(x, x_mask, g=g, reverse=reverse)
- return x
-
-
-class PosteriorEncoder(nn.Module):
- def __init__(self,
- in_channels,
- out_channels,
- hidden_channels,
- kernel_size,
- dilation_rate,
- n_layers,
- gin_channels=0):
- super().__init__()
- self.in_channels = in_channels
- self.out_channels = out_channels
- self.hidden_channels = hidden_channels
- self.kernel_size = kernel_size
- self.dilation_rate = dilation_rate
- self.n_layers = n_layers
- self.gin_channels = gin_channels
-
- self.pre = nn.Conv1d(in_channels, hidden_channels, 1)
- self.enc = modules.WN(hidden_channels, kernel_size, dilation_rate, n_layers, gin_channels=gin_channels)
- self.proj = nn.Conv1d(hidden_channels, out_channels * 2, 1)
-
- def forward(self, x, x_lengths, g=None):
- x_mask = torch.unsqueeze(commons.sequence_mask(x_lengths, x.size(2)), 1).to(x.dtype)
- x = self.pre(x) * x_mask
- x = self.enc(x, x_mask, g=g)
- stats = self.proj(x) * x_mask
- m, logs = torch.split(stats, self.out_channels, dim=1)
- z = (m + torch.randn_like(m) * torch.exp(logs)) * x_mask
- return z, m, logs, x_mask
-
-
-class Generator(torch.nn.Module):
- def __init__(self, initial_channel, resblock, resblock_kernel_sizes, resblock_dilation_sizes, upsample_rates, upsample_initial_channel, upsample_kernel_sizes, gin_channels=0):
- super(Generator, self).__init__()
- self.num_kernels = len(resblock_kernel_sizes)
- self.num_upsamples = len(upsample_rates)
- self.conv_pre = Conv1d(initial_channel, upsample_initial_channel, 7, 1, padding=3)
- resblock = modules.ResBlock1 if resblock == '1' else modules.ResBlock2
-
- self.ups = nn.ModuleList()
- for i, (u, k) in enumerate(zip(upsample_rates, upsample_kernel_sizes)):
- self.ups.append(weight_norm(
- ConvTranspose1d(upsample_initial_channel//(2**i), upsample_initial_channel//(2**(i+1)),
- k, u, padding=(k-u)//2)))
-
- self.resblocks = nn.ModuleList()
- for i in range(len(self.ups)):
- ch = upsample_initial_channel//(2**(i+1))
- for j, (k, d) in enumerate(zip(resblock_kernel_sizes, resblock_dilation_sizes)):
- self.resblocks.append(resblock(ch, k, d))
-
- self.conv_post = Conv1d(ch, 1, 7, 1, padding=3, bias=False)
- self.ups.apply(init_weights)
-
- if gin_channels != 0:
- self.cond = nn.Conv1d(gin_channels, upsample_initial_channel, 1)
-
- def forward(self, x, g=None):
- x = self.conv_pre(x)
- if g is not None:
- x = x + self.cond(g)
-
- for i in range(self.num_upsamples):
- x = F.leaky_relu(x, modules.LRELU_SLOPE)
- x = self.ups[i](x)
- xs = None
- for j in range(self.num_kernels):
- if xs is None:
- xs = self.resblocks[i*self.num_kernels+j](x)
- else:
- xs += self.resblocks[i*self.num_kernels+j](x)
- x = xs / self.num_kernels
- x = F.leaky_relu(x)
- x = self.conv_post(x)
- x = torch.tanh(x)
-
- return x
-
- def remove_weight_norm(self):
- print('Removing weight norm...')
- for l in self.ups:
- remove_weight_norm(l)
- for l in self.resblocks:
- l.remove_weight_norm()
-
-
-class DiscriminatorP(torch.nn.Module):
- def __init__(self, period, kernel_size=5, stride=3, use_spectral_norm=False):
- super(DiscriminatorP, self).__init__()
- self.period = period
- self.use_spectral_norm = use_spectral_norm
- norm_f = weight_norm if use_spectral_norm == False else spectral_norm
- self.convs = nn.ModuleList([
- norm_f(Conv2d(1, 32, (kernel_size, 1), (stride, 1), padding=(get_padding(kernel_size, 1), 0))),
- norm_f(Conv2d(32, 128, (kernel_size, 1), (stride, 1), padding=(get_padding(kernel_size, 1), 0))),
- norm_f(Conv2d(128, 512, (kernel_size, 1), (stride, 1), padding=(get_padding(kernel_size, 1), 0))),
- norm_f(Conv2d(512, 1024, (kernel_size, 1), (stride, 1), padding=(get_padding(kernel_size, 1), 0))),
- norm_f(Conv2d(1024, 1024, (kernel_size, 1), 1, padding=(get_padding(kernel_size, 1), 0))),
- ])
- self.conv_post = norm_f(Conv2d(1024, 1, (3, 1), 1, padding=(1, 0)))
-
- def forward(self, x):
- fmap = []
-
- # 1d to 2d
- b, c, t = x.shape
- if t % self.period != 0: # pad first
- n_pad = self.period - (t % self.period)
- x = F.pad(x, (0, n_pad), "reflect")
- t = t + n_pad
- x = x.view(b, c, t // self.period, self.period)
-
- for l in self.convs:
- x = l(x)
- x = F.leaky_relu(x, modules.LRELU_SLOPE)
- fmap.append(x)
- x = self.conv_post(x)
- fmap.append(x)
- x = torch.flatten(x, 1, -1)
-
- return x, fmap
-
-
-class DiscriminatorS(torch.nn.Module):
- def __init__(self, use_spectral_norm=False):
- super(DiscriminatorS, self).__init__()
- norm_f = weight_norm if use_spectral_norm == False else spectral_norm
- self.convs = nn.ModuleList([
- norm_f(Conv1d(1, 16, 15, 1, padding=7)),
- norm_f(Conv1d(16, 64, 41, 4, groups=4, padding=20)),
- norm_f(Conv1d(64, 256, 41, 4, groups=16, padding=20)),
- norm_f(Conv1d(256, 1024, 41, 4, groups=64, padding=20)),
- norm_f(Conv1d(1024, 1024, 41, 4, groups=256, padding=20)),
- norm_f(Conv1d(1024, 1024, 5, 1, padding=2)),
- ])
- self.conv_post = norm_f(Conv1d(1024, 1, 3, 1, padding=1))
-
- def forward(self, x):
- fmap = []
-
- for l in self.convs:
- x = l(x)
- x = F.leaky_relu(x, modules.LRELU_SLOPE)
- fmap.append(x)
- x = self.conv_post(x)
- fmap.append(x)
- x = torch.flatten(x, 1, -1)
-
- return x, fmap
-
-
-class MultiPeriodDiscriminator(torch.nn.Module):
- def __init__(self, use_spectral_norm=False):
- super(MultiPeriodDiscriminator, self).__init__()
- periods = [2,3,5,7,11]
-
- discs = [DiscriminatorS(use_spectral_norm=use_spectral_norm)]
- discs = discs + [DiscriminatorP(i, use_spectral_norm=use_spectral_norm) for i in periods]
- self.discriminators = nn.ModuleList(discs)
-
- def forward(self, y, y_hat):
- y_d_rs = []
- y_d_gs = []
- fmap_rs = []
- fmap_gs = []
- for i, d in enumerate(self.discriminators):
- y_d_r, fmap_r = d(y)
- y_d_g, fmap_g = d(y_hat)
- y_d_rs.append(y_d_r)
- y_d_gs.append(y_d_g)
- fmap_rs.append(fmap_r)
- fmap_gs.append(fmap_g)
-
- return y_d_rs, y_d_gs, fmap_rs, fmap_gs
-
-
-
-class SynthesizerTrn(nn.Module):
- """
- Synthesizer for Training
- """
-
- def __init__(self,
- n_vocab,
- spec_channels,
- segment_size,
- inter_channels,
- hidden_channels,
- filter_channels,
- n_heads,
- n_layers,
- kernel_size,
- p_dropout,
- resblock,
- resblock_kernel_sizes,
- resblock_dilation_sizes,
- upsample_rates,
- upsample_initial_channel,
- upsample_kernel_sizes,
- n_speakers=0,
- gin_channels=0,
- use_sdp=True,
- **kwargs):
-
- super().__init__()
- self.n_vocab = n_vocab
- self.spec_channels = spec_channels
- self.inter_channels = inter_channels
- self.hidden_channels = hidden_channels
- self.filter_channels = filter_channels
- self.n_heads = n_heads
- self.n_layers = n_layers
- self.kernel_size = kernel_size
- self.p_dropout = p_dropout
- self.resblock = resblock
- self.resblock_kernel_sizes = resblock_kernel_sizes
- self.resblock_dilation_sizes = resblock_dilation_sizes
- self.upsample_rates = upsample_rates
- self.upsample_initial_channel = upsample_initial_channel
- self.upsample_kernel_sizes = upsample_kernel_sizes
- self.segment_size = segment_size
- self.n_speakers = n_speakers
- self.gin_channels = gin_channels
-
- self.use_sdp = use_sdp
-
- self.enc_p = TextEncoder(n_vocab,
- inter_channels,
- hidden_channels,
- filter_channels,
- n_heads,
- n_layers,
- kernel_size,
- p_dropout)
- self.dec = Generator(inter_channels, resblock, resblock_kernel_sizes, resblock_dilation_sizes, upsample_rates, upsample_initial_channel, upsample_kernel_sizes, gin_channels=gin_channels)
- self.enc_q = PosteriorEncoder(spec_channels, inter_channels, hidden_channels, 5, 1, 16, gin_channels=gin_channels)
- self.flow = ResidualCouplingBlock(inter_channels, hidden_channels, 5, 1, 4, gin_channels=gin_channels)
-
- if use_sdp:
- self.dp = StochasticDurationPredictor(hidden_channels, 192, 3, 0.5, 4, gin_channels=gin_channels)
- else:
- self.dp = DurationPredictor(hidden_channels, 256, 3, 0.5, gin_channels=gin_channels)
-
- if n_speakers > 1:
- self.emb_g = nn.Embedding(n_speakers, gin_channels)
-
- def forward(self, x, x_lengths, y, y_lengths, sid=None):
-
- x, m_p, logs_p, x_mask = self.enc_p(x, x_lengths)
- if self.n_speakers > 0:
- g = self.emb_g(sid).unsqueeze(-1) # [b, h, 1]
- else:
- g = None
-
- z, m_q, logs_q, y_mask = self.enc_q(y, y_lengths, g=g)
- z_p = self.flow(z, y_mask, g=g)
-
- with torch.no_grad():
- # negative cross-entropy
- s_p_sq_r = torch.exp(-2 * logs_p) # [b, d, t]
- neg_cent1 = torch.sum(-0.5 * math.log(2 * math.pi) - logs_p, [1], keepdim=True) # [b, 1, t_s]
- neg_cent2 = torch.matmul(-0.5 * (z_p ** 2).transpose(1, 2), s_p_sq_r) # [b, t_t, d] x [b, d, t_s] = [b, t_t, t_s]
- neg_cent3 = torch.matmul(z_p.transpose(1, 2), (m_p * s_p_sq_r)) # [b, t_t, d] x [b, d, t_s] = [b, t_t, t_s]
- neg_cent4 = torch.sum(-0.5 * (m_p ** 2) * s_p_sq_r, [1], keepdim=True) # [b, 1, t_s]
- neg_cent = neg_cent1 + neg_cent2 + neg_cent3 + neg_cent4
-
- attn_mask = torch.unsqueeze(x_mask, 2) * torch.unsqueeze(y_mask, -1)
- attn = monotonic_align.maximum_path(neg_cent, attn_mask.squeeze(1)).unsqueeze(1).detach()
-
- w = attn.sum(2)
- if self.use_sdp:
- l_length = self.dp(x, x_mask, w, g=g)
- l_length = l_length / torch.sum(x_mask)
- else:
- logw_ = torch.log(w + 1e-6) * x_mask
- logw = self.dp(x, x_mask, g=g)
- l_length = torch.sum((logw - logw_)**2, [1,2]) / torch.sum(x_mask) # for averaging
-
- # expand prior
- m_p = torch.matmul(attn.squeeze(1), m_p.transpose(1, 2)).transpose(1, 2)
- logs_p = torch.matmul(attn.squeeze(1), logs_p.transpose(1, 2)).transpose(1, 2)
-
- z_slice, ids_slice = commons.rand_slice_segments(z, y_lengths, self.segment_size)
- o = self.dec(z_slice, g=g)
- return o, l_length, attn, ids_slice, x_mask, y_mask, (z, z_p, m_p, logs_p, m_q, logs_q)
-
- def infer(self, x, x_lengths, sid=None, noise_scale=1, length_scale=1, noise_scale_w=1., max_len=None):
- device = next(self.parameters()).device # 获取模型所在的设备
- x, m_p, logs_p, x_mask = self.enc_p(x.to(device), x_lengths.to(device))
- if self.n_speakers > 0:
- g = self.emb_g(sid.to(device)).unsqueeze(-1) # [b, h, 1]
- else:
- g = None
-
- if self.use_sdp:
- logw = self.dp(x, x_mask, g=g, reverse=True, noise_scale=noise_scale_w)
- else:
- logw = self.dp(x, x_mask, g=g)
- w = torch.exp(logw) * x_mask * length_scale
- w_ceil = torch.ceil(w)
- y_lengths = torch.clamp_min(torch.sum(w_ceil, [1, 2]), 1).long()
- y_mask = torch.unsqueeze(commons.sequence_mask(y_lengths, None), 1).to(x_mask.dtype)
- attn_mask = torch.unsqueeze(x_mask, 2) * torch.unsqueeze(y_mask, -1)
- attn = commons.generate_path(w_ceil, attn_mask)
-
- m_p = torch.matmul(attn.squeeze(1), m_p.transpose(1, 2)).transpose(1, 2) # [b, t', t], [b, t, d] -> [b, d, t']
- logs_p = torch.matmul(attn.squeeze(1), logs_p.transpose(1, 2)).transpose(1, 2) # [b, t', t], [b, t, d] -> [b, d, t']
-
- z_p = m_p + torch.randn_like(m_p) * torch.exp(logs_p) * noise_scale
- z = self.flow(z_p, y_mask, g=g, reverse=True)
- o = self.dec((z * y_mask)[:,:,:max_len], g=g)
- return o, attn, y_mask, (z, z_p, m_p, logs_p)
-
- def voice_conversion(self, y, y_lengths, sid_src, sid_tgt):
- assert self.n_speakers > 0, "n_speakers have to be larger than 0."
- g_src = self.emb_g(sid_src).unsqueeze(-1)
- g_tgt = self.emb_g(sid_tgt).unsqueeze(-1)
- z, m_q, logs_q, y_mask = self.enc_q(y, y_lengths, g=g_src)
- z_p = self.flow(z, y_mask, g=g_src)
- z_hat = self.flow(z_p, y_mask, g=g_tgt, reverse=True)
- o_hat = self.dec(z_hat * y_mask, g=g_tgt)
- return o_hat, y_mask, (z, z_p, z_hat)
-
diff --git a/spaces/CofAI/chat/server/website.py b/spaces/CofAI/chat/server/website.py
deleted file mode 100644
index 01b35dee1621b5b5bea49de330466ebb62817f20..0000000000000000000000000000000000000000
--- a/spaces/CofAI/chat/server/website.py
+++ /dev/null
@@ -1,58 +0,0 @@
-from flask import render_template, redirect, url_for, request, session
-from flask_babel import refresh
-from time import time
-from os import urandom
-from server.babel import get_locale, get_languages
-
-
-class Website:
- def __init__(self, bp, url_prefix) -> None:
- self.bp = bp
- self.url_prefix = url_prefix
- self.routes = {
- '/': {
- 'function': lambda: redirect(url_for('._index')),
- 'methods': ['GET', 'POST']
- },
- '/chat/': {
- 'function': self._index,
- 'methods': ['GET', 'POST']
- },
- '/chat/': {
- 'function': self._chat,
- 'methods': ['GET', 'POST']
- },
- '/change-language': {
- 'function': self.change_language,
- 'methods': ['POST']
- },
- '/get-locale': {
- 'function': self.get_locale,
- 'methods': ['GET']
- },
- '/get-languages': {
- 'function': self.get_languages,
- 'methods': ['GET']
- }
- }
-
- def _chat(self, conversation_id):
- if '-' not in conversation_id:
- return redirect(url_for('._index'))
-
- return render_template('index.html', chat_id=conversation_id, url_prefix=self.url_prefix)
-
- def _index(self):
- return render_template('index.html', chat_id=f'{urandom(4).hex()}-{urandom(2).hex()}-{urandom(2).hex()}-{urandom(2).hex()}-{hex(int(time() * 1000))[2:]}', url_prefix=self.url_prefix)
-
- def change_language(self):
- data = request.get_json()
- session['language'] = data.get('language')
- refresh()
- return '', 204
-
- def get_locale(self):
- return get_locale()
-
- def get_languages(self):
- return get_languages()
diff --git a/spaces/CoreyMorris/MMLU-by-task-Leaderboard/save_for_regression.py b/spaces/CoreyMorris/MMLU-by-task-Leaderboard/save_for_regression.py
deleted file mode 100644
index 047ac6eb876dfd8b2a1d153dd850807a76397122..0000000000000000000000000000000000000000
--- a/spaces/CoreyMorris/MMLU-by-task-Leaderboard/save_for_regression.py
+++ /dev/null
@@ -1,55 +0,0 @@
-# when run
-# checks if there is uncommitted code
-# if there is uncommitted code, ti retuns an error
-# if there is no uncommitted code, it saves the dataframe as a parquet file with the commit hash in the name
-
-import pytest
-import pandas as pd
-from result_data_processor import ResultDataProcessor
-
-import os
-
-import subprocess
-
-def check_git_changes(repo_path):
- try:
- # Change to the repository directory
- original_path = os.getcwd()
- os.chdir(repo_path)
-
- # Run the git status command
- result = subprocess.run(['git', 'status', '--porcelain'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
-
- # Check the result
- if result.returncode != 0:
- print(f"Error checking git status: {result.stderr}")
- return False, False
-
- # Check for tracked and untracked changes
- tracked_changes = any(line[:2].strip() != '??' for line in result.stdout.splitlines())
- untracked_changes = any(line[:2] == '??' for line in result.stdout.splitlines())
-
- return tracked_changes, untracked_changes
-
- finally:
- # Change back to the original directory
- os.chdir(original_path)
-
-if __name__ == '__main__':
- tracked_changes, untracked_changes = check_git_changes('.')
- if tracked_changes:
- print("There are tracked changes")
- else:
- print("There are no tracked changes")
- df_current = ResultDataProcessor().data
- last_commit = os.popen('git rev-parse HEAD').read().strip()
- print(last_commit)
- # save the current output to a file
- df_current.to_parquet(f'dataframe_history/output_{last_commit}.parquet', index=True)
- print("Saved output to file")
- if untracked_changes:
- print("There are untracked changes")
- else:
- print("There are no untracked changes")
-
-
diff --git a/spaces/Cyril666/ContourNet-ABI/maskrcnn_benchmark/modeling/backbone/resnet.py b/spaces/Cyril666/ContourNet-ABI/maskrcnn_benchmark/modeling/backbone/resnet.py
deleted file mode 100644
index 39adf1520463abcf5778a674c7e4d5fb3dc0163d..0000000000000000000000000000000000000000
--- a/spaces/Cyril666/ContourNet-ABI/maskrcnn_benchmark/modeling/backbone/resnet.py
+++ /dev/null
@@ -1,498 +0,0 @@
-# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
-"""
-Variant of the resnet module that takes cfg as an argument.
-Example usage. Strings may be specified in the config file.
- model = ResNet(
- "StemWithFixedBatchNorm",
- "BottleneckWithFixedBatchNorm",
- "ResNet50StagesTo4",
- )
-OR:
- model = ResNet(
- "StemWithGN",
- "BottleneckWithGN",
- "ResNet50StagesTo4",
- )
-Custom implementations may be written in user code and hooked in via the
-`register_*` functions.
-"""
-from collections import namedtuple
-
-import torch
-import torch.nn.functional as F
-from torch import nn
-
-from maskrcnn_benchmark.layers import FrozenBatchNorm2d
-from maskrcnn_benchmark.layers import Conv2d
-from maskrcnn_benchmark.modeling.make_layers import group_norm
-from maskrcnn_benchmark.layers import DCN
-from maskrcnn_benchmark.utils.registry import Registry
-
-
-# ResNet stage specification
-StageSpec = namedtuple(
- "StageSpec",
- [
- "index", # Index of the stage, eg 1, 2, ..,. 5
- "block_count", # Number of residual blocks in the stage
- "return_features", # True => return the last feature map from this stage
- ],
-)
-
-# -----------------------------------------------------------------------------
-# Standard ResNet models
-# -----------------------------------------------------------------------------
-# ResNet-50 (including all stages)
-ResNet50StagesTo5 = tuple(
- StageSpec(index=i, block_count=c, return_features=r)
- for (i, c, r) in ((1, 3, False), (2, 4, False), (3, 6, False), (4, 3, True))
-)
-# ResNet-50 up to stage 4 (excludes stage 5)
-ResNet50StagesTo4 = tuple(
- StageSpec(index=i, block_count=c, return_features=r)
- for (i, c, r) in ((1, 3, False), (2, 4, False), (3, 6, True))
-)
-# ResNet-101 (including all stages)
-ResNet101StagesTo5 = tuple(
- StageSpec(index=i, block_count=c, return_features=r)
- for (i, c, r) in ((1, 3, False), (2, 4, False), (3, 23, False), (4, 3, True))
-)
-# ResNet-101 up to stage 4 (excludes stage 5)
-ResNet101StagesTo4 = tuple(
- StageSpec(index=i, block_count=c, return_features=r)
- for (i, c, r) in ((1, 3, False), (2, 4, False), (3, 23, True))
-)
-# ResNet-50-FPN (including all stages)
-ResNet50FPNStagesTo5 = tuple(
- StageSpec(index=i, block_count=c, return_features=r)
- for (i, c, r) in ((1, 3, True), (2, 4, True), (3, 6, True), (4, 3, True))
-)
-# ResNet-101-FPN (including all stages)
-ResNet101FPNStagesTo5 = tuple(
- StageSpec(index=i, block_count=c, return_features=r)
- for (i, c, r) in ((1, 3, True), (2, 4, True), (3, 23, True), (4, 3, True))
-)
-# ResNet-152-FPN (including all stages)
-ResNet152FPNStagesTo5 = tuple(
- StageSpec(index=i, block_count=c, return_features=r)
- for (i, c, r) in ((1, 3, True), (2, 8, True), (3, 36, True), (4, 3, True))
-)
-
-class ResNet(nn.Module):
- def __init__(self, cfg):
- super(ResNet, self).__init__()
-
- # If we want to use the cfg in forward(), then we should make a copy
- # of it and store it for later use:
- # self.cfg = cfg.clone()
-
- # Translate string names to implementations
- stem_module = _STEM_MODULES[cfg.MODEL.RESNETS.STEM_FUNC]
- stage_specs = _STAGE_SPECS[cfg.MODEL.BACKBONE.CONV_BODY]
- transformation_module = _TRANSFORMATION_MODULES[cfg.MODEL.RESNETS.TRANS_FUNC]
- deformable_module = _TRANSFORMATION_MODULES[cfg.MODEL.RESNETS.DEF_FUNC]
- start_module = cfg.MODEL.RESNETS.DEF_START_MODULE
- _DEF_IDX = {"C3": 1, "C4": 2, "C5": 3}
- if start_module in _DEF_IDX:
- start_idx = _DEF_IDX[start_module]
- else:
- start_idx = 65535
-
- # Construct the stem module
- self.stem = stem_module(cfg)
-
- # Constuct the specified ResNet stages
- num_groups = cfg.MODEL.RESNETS.NUM_GROUPS
- width_per_group = cfg.MODEL.RESNETS.WIDTH_PER_GROUP
- in_channels = cfg.MODEL.RESNETS.STEM_OUT_CHANNELS
- stage2_bottleneck_channels = num_groups * width_per_group
- stage2_out_channels = cfg.MODEL.RESNETS.RES2_OUT_CHANNELS
- self.stages = []
- self.return_features = {}
- for i, stage_spec in enumerate(stage_specs):
- name = "layer" + str(stage_spec.index)
- stage2_relative_factor = 2 ** (stage_spec.index - 1)
- bottleneck_channels = stage2_bottleneck_channels * stage2_relative_factor
- out_channels = stage2_out_channels * stage2_relative_factor
- if i >= start_idx:
- trans_mod = deformable_module
- else:
- trans_mod = transformation_module
- module = _make_stage(
- trans_mod,
- in_channels,
- bottleneck_channels,
- out_channels,
- stage_spec.block_count,
- num_groups,
- cfg.MODEL.RESNETS.STRIDE_IN_1X1,
- first_stride=int(stage_spec.index > 1) + 1,
- )
- in_channels = out_channels
- self.add_module(name, module)
- self.stages.append(name)
- self.return_features[name] = stage_spec.return_features
-
- # Optionally freeze (requires_grad=False) parts of the backbone
- self._freeze_backbone(cfg.MODEL.BACKBONE.FREEZE_CONV_BODY_AT)
-
- def _freeze_backbone(self, freeze_at):
- if freeze_at < 0:
- return
- for stage_index in range(freeze_at):
- if stage_index == 0:
- m = self.stem # stage 0 is the stem
- else:
- m = getattr(self, "layer" + str(stage_index))
- for p in m.parameters():
- p.requires_grad = False
-
- def forward(self, x):
- outputs = []
- x = self.stem(x)
- for stage_name in self.stages:
- x = getattr(self, stage_name)(x)
- if self.return_features[stage_name]:
- outputs.append(x)
- return outputs
-
-
-class ResNetHead(nn.Module):
- def __init__(
- self,
- block_module,
- stages,
- num_groups=1,
- width_per_group=64,
- stride_in_1x1=True,
- stride_init=None,
- res2_out_channels=256,
- dilation=1
- ):
- super(ResNetHead, self).__init__()
-
- stage2_relative_factor = 2 ** (stages[0].index - 1)
- # print('stage2_relative_factor---',stage2_relative_factor)
-
- stage2_bottleneck_channels = num_groups * width_per_group
- # print('stage2_bottleneck_channels---',stage2_bottleneck_channels)
-
- out_channels = res2_out_channels * stage2_relative_factor
- # print('out_channels---',out_channels)
-
- in_channels = out_channels // 2
- # print('in_channels---',in_channels)
- #
- bottleneck_channels = stage2_bottleneck_channels * stage2_relative_factor
- # print('bottleneck_channels---',bottleneck_channels)
-
- block_module = _TRANSFORMATION_MODULES[block_module]
- # print('block_module---',block_module)
-
-
- self.stages = []
- stride = stride_init
- for stage in stages:
- name = "layer" + str(stage.index)
- if not stride:
- stride = int(stage.index > 1) + 1
- # print('stride---', stride)
- print('stage.block_count---', stage.block_count)
- module = _make_stage(
- block_module,
- in_channels,
- bottleneck_channels,
- out_channels,
- stage.block_count,
- num_groups,
- stride_in_1x1,
- first_stride=stride,
- dilation=dilation
- )
- stride = None
- self.add_module(name, module)
- self.stages.append(name)
- self.out_channels = out_channels
-
- def forward(self, x):
- for stage in self.stages:
- x = getattr(self, stage)(x)
- print('x-----------',x.shape)
- return x
-
-
-def _make_stage(
- transformation_module,
- in_channels,
- bottleneck_channels,
- out_channels,
- block_count,
- num_groups,
- stride_in_1x1,
- first_stride,
- dilation=1
-):
- blocks = []
- stride = first_stride
- for _ in range(block_count):
- blocks.append(
- transformation_module(
- in_channels,
- bottleneck_channels,
- out_channels,
- num_groups,
- stride_in_1x1,
- stride,
- dilation=dilation
- )
- )
- stride = 1
- in_channels = out_channels
- return nn.Sequential(*blocks)
-
-
-class Bottleneck(nn.Module):
- def __init__(
- self,
- in_channels,
- bottleneck_channels,
- out_channels,
- num_groups,
- stride_in_1x1,
- stride,
- dilation,
- norm_func,
- conv_func=Conv2d
- ):
- super(Bottleneck, self).__init__()
-
- self.downsample = None
- if in_channels != out_channels:
- down_stride = stride if dilation == 1 else 1
- self.downsample = nn.Sequential(
- conv_func(
- in_channels, out_channels,
- kernel_size=1, stride=down_stride, bias=False
- ),
- norm_func(out_channels),
- )
- for modules in [self.downsample,]:
- for l in modules.modules():
- if isinstance(l, Conv2d):
- nn.init.kaiming_uniform_(l.weight, a=1)
-
- if dilation > 1:
- stride = 1 # reset to be 1
-
- # The original MSRA ResNet models have stride in the first 1x1 conv
- # The subsequent fb.torch.resnet and Caffe2 ResNe[X]t implementations have
- # stride in the 3x3 conv
- stride_1x1, stride_3x3 = (stride, 1) if stride_in_1x1 else (1, stride)
-
- self.conv1 = conv_func(
- in_channels,
- bottleneck_channels,
- kernel_size=1,
- stride=stride_1x1,
- bias=False,
- )
- self.bn1 = norm_func(bottleneck_channels)
- # TODO: specify init for the above
-
- self.conv2 = conv_func(
- bottleneck_channels,
- bottleneck_channels,
- kernel_size=3,
- stride=stride_3x3,
- padding=dilation,
- bias=False,
- groups=num_groups,
- dilation=dilation
- )
- self.bn2 = norm_func(bottleneck_channels)
-
- self.conv3 = Conv2d(
- bottleneck_channels, out_channels, kernel_size=1, bias=False
- )
- self.bn3 = norm_func(out_channels)
-
- for l in [self.conv1, self.conv2, self.conv3,]:
- nn.init.kaiming_uniform_(l.weight, a=1)
-
- def forward(self, x):
- identity = x
-
- out = self.conv1(x)
- out = self.bn1(out)
- out = F.relu_(out)
-
- out = self.conv2(out)
- out = self.bn2(out)
- out = F.relu_(out)
-
- out0 = self.conv3(out)
- out = self.bn3(out0)
-
- if self.downsample is not None:
- identity = self.downsample(x)
-
- out += identity
- out = F.relu_(out)
-
- return out
-
-
-class BaseStem(nn.Module):
- def __init__(self, cfg, norm_func):
- super(BaseStem, self).__init__()
-
- out_channels = cfg.MODEL.RESNETS.STEM_OUT_CHANNELS
-
- self.conv1 = Conv2d(
- 3, out_channels, kernel_size=7, stride=2, padding=3, bias=False
- )
- self.bn1 = norm_func(out_channels)
-
- for l in [self.conv1,]:
- nn.init.kaiming_uniform_(l.weight, a=1)
-
- def forward(self, x):
- x = self.conv1(x)
- x = self.bn1(x)
- x = F.relu_(x)
- x = F.max_pool2d(x, kernel_size=3, stride=2, padding=1)
- return x
-
-#############################################
-
-class BottleneckWithFixedBatchNorm(Bottleneck):
- def __init__(
- self,
- in_channels,
- bottleneck_channels,
- out_channels,
- num_groups=1,
- stride_in_1x1=True,
- stride=1,
- dilation=1
- ):
- super(BottleneckWithFixedBatchNorm, self).__init__(
- in_channels=in_channels,
- bottleneck_channels=bottleneck_channels,
- out_channels=out_channels,
- num_groups=num_groups,
- stride_in_1x1=stride_in_1x1,
- stride=stride,
- dilation=dilation,
- norm_func=FrozenBatchNorm2d
- )
-
-
-class DeformableConvWithFixedBatchNorm(Bottleneck):
- def __init__(
- self,
- in_channels,
- bottleneck_channels,
- out_channels,
- num_groups=1,
- stride_in_1x1=True,
- stride=1,
- dilation=1
- ):
- super(DeformableConvWithFixedBatchNorm, self).__init__(
- in_channels=in_channels,
- bottleneck_channels=bottleneck_channels,
- out_channels=out_channels,
- num_groups=num_groups,
- stride_in_1x1=stride_in_1x1,
- stride=stride,
- dilation=dilation,
- norm_func=FrozenBatchNorm2d,
- conv_func=DCN
- )
-
-
-class StemWithFixedBatchNorm(BaseStem):
- def __init__(self, cfg):
- super(StemWithFixedBatchNorm, self).__init__(
- cfg, norm_func=FrozenBatchNorm2d
- )
-
-
-class BottleneckWithGN(Bottleneck):
- def __init__(
- self,
- in_channels,
- bottleneck_channels,
- out_channels,
- num_groups=1,
- stride_in_1x1=True,
- stride=1,
- dilation=1
- ):
- super(BottleneckWithGN, self).__init__(
- in_channels=in_channels,
- bottleneck_channels=bottleneck_channels,
- out_channels=out_channels,
- num_groups=num_groups,
- stride_in_1x1=stride_in_1x1,
- stride=stride,
- dilation=dilation,
- norm_func=group_norm
- )
-
-
-class DeformableConvWithGN(Bottleneck):
- def __init__(
- self,
- in_channels,
- bottleneck_channels,
- out_channels,
- num_groups=1,
- stride_in_1x1=True,
- stride=1,
- dilation=1
- ):
- super(DeformableConvWithGN, self).__init__(
- in_channels=in_channels,
- bottleneck_channels=bottleneck_channels,
- out_channels=out_channels,
- num_groups=num_groups,
- stride_in_1x1=stride_in_1x1,
- stride=stride,
- dilation=dilation,
- norm_func=group_norm,
- conv_func=DCN
- )
-
-
-class StemWithGN(BaseStem):
- def __init__(self, cfg):
- super(StemWithGN, self).__init__(cfg, norm_func=group_norm)
-
-
-_TRANSFORMATION_MODULES = Registry({
- "BottleneckWithFixedBatchNorm": BottleneckWithFixedBatchNorm,
- "BottleneckWithGN": BottleneckWithGN,
- "DeformableConvWithFixedBatchNorm": DeformableConvWithFixedBatchNorm,
- "DeformableConvWithGN": DeformableConvWithGN,
-})
-
-_STEM_MODULES = Registry({
- "StemWithFixedBatchNorm": StemWithFixedBatchNorm,
- "StemWithGN": StemWithGN,
-})
-
-_STAGE_SPECS = Registry({
- "R-50-C4": ResNet50StagesTo4,
- "R-50-C5": ResNet50StagesTo5,
- "R-101-C4": ResNet101StagesTo4,
- "R-101-C5": ResNet101StagesTo5,
- "R-50-FPN": ResNet50FPNStagesTo5,
- "R-50-FPN-RETINANET": ResNet50FPNStagesTo5,
- "R-101-FPN": ResNet101FPNStagesTo5,
- "R-101-PAN": ResNet101FPNStagesTo5,
- "R-101-FPN-RETINANET": ResNet101FPNStagesTo5,
- "R-152-FPN": ResNet152FPNStagesTo5,
- "R-152-PAN": ResNet152FPNStagesTo5,
-})
diff --git a/spaces/DQChoi/gpt-demo/venv/lib/python3.11/site-packages/fontTools/feaLib/lexer.c b/spaces/DQChoi/gpt-demo/venv/lib/python3.11/site-packages/fontTools/feaLib/lexer.c
deleted file mode 100644
index 1fef32ff3a4213e59ffbf37dce573f65a87cf0da..0000000000000000000000000000000000000000
--- a/spaces/DQChoi/gpt-demo/venv/lib/python3.11/site-packages/fontTools/feaLib/lexer.c
+++ /dev/null
@@ -1,13368 +0,0 @@
-/* Generated by Cython 0.29.36 */
-
-/* BEGIN: Cython Metadata
-{
- "distutils": {
- "name": "fontTools.feaLib.lexer",
- "sources": [
- "Lib/fontTools/feaLib/lexer.py"
- ]
- },
- "module_name": "fontTools.feaLib.lexer"
-}
-END: Cython Metadata */
-
-#ifndef PY_SSIZE_T_CLEAN
-#define PY_SSIZE_T_CLEAN
-#endif /* PY_SSIZE_T_CLEAN */
-#include "Python.h"
-#ifndef Py_PYTHON_H
- #error Python headers needed to compile C extensions, please install development version of Python.
-#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
- #error Cython requires Python 2.6+ or Python 3.3+.
-#else
-#define CYTHON_ABI "0_29_36"
-#define CYTHON_HEX_VERSION 0x001D24F0
-#define CYTHON_FUTURE_DIVISION 1
-#include
-#ifndef offsetof
- #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
-#endif
-#if !defined(WIN32) && !defined(MS_WINDOWS)
- #ifndef __stdcall
- #define __stdcall
- #endif
- #ifndef __cdecl
- #define __cdecl
- #endif
- #ifndef __fastcall
- #define __fastcall
- #endif
-#endif
-#ifndef DL_IMPORT
- #define DL_IMPORT(t) t
-#endif
-#ifndef DL_EXPORT
- #define DL_EXPORT(t) t
-#endif
-#define __PYX_COMMA ,
-#ifndef HAVE_LONG_LONG
- #if PY_VERSION_HEX >= 0x02070000
- #define HAVE_LONG_LONG
- #endif
-#endif
-#ifndef PY_LONG_LONG
- #define PY_LONG_LONG LONG_LONG
-#endif
-#ifndef Py_HUGE_VAL
- #define Py_HUGE_VAL HUGE_VAL
-#endif
-#ifdef PYPY_VERSION
- #define CYTHON_COMPILING_IN_PYPY 1
- #define CYTHON_COMPILING_IN_PYSTON 0
- #define CYTHON_COMPILING_IN_CPYTHON 0
- #define CYTHON_COMPILING_IN_NOGIL 0
- #undef CYTHON_USE_TYPE_SLOTS
- #define CYTHON_USE_TYPE_SLOTS 0
- #undef CYTHON_USE_PYTYPE_LOOKUP
- #define CYTHON_USE_PYTYPE_LOOKUP 0
- #if PY_VERSION_HEX < 0x03050000
- #undef CYTHON_USE_ASYNC_SLOTS
- #define CYTHON_USE_ASYNC_SLOTS 0
- #elif !defined(CYTHON_USE_ASYNC_SLOTS)
- #define CYTHON_USE_ASYNC_SLOTS 1
- #endif
- #undef CYTHON_USE_PYLIST_INTERNALS
- #define CYTHON_USE_PYLIST_INTERNALS 0
- #undef CYTHON_USE_UNICODE_INTERNALS
- #define CYTHON_USE_UNICODE_INTERNALS 0
- #undef CYTHON_USE_UNICODE_WRITER
- #define CYTHON_USE_UNICODE_WRITER 0
- #undef CYTHON_USE_PYLONG_INTERNALS
- #define CYTHON_USE_PYLONG_INTERNALS 0
- #undef CYTHON_AVOID_BORROWED_REFS
- #define CYTHON_AVOID_BORROWED_REFS 1
- #undef CYTHON_ASSUME_SAFE_MACROS
- #define CYTHON_ASSUME_SAFE_MACROS 0
- #undef CYTHON_UNPACK_METHODS
- #define CYTHON_UNPACK_METHODS 0
- #undef CYTHON_FAST_THREAD_STATE
- #define CYTHON_FAST_THREAD_STATE 0
- #undef CYTHON_FAST_PYCALL
- #define CYTHON_FAST_PYCALL 0
- #if PY_VERSION_HEX < 0x03090000
- #undef CYTHON_PEP489_MULTI_PHASE_INIT
- #define CYTHON_PEP489_MULTI_PHASE_INIT 0
- #elif !defined(CYTHON_PEP489_MULTI_PHASE_INIT)
- #define CYTHON_PEP489_MULTI_PHASE_INIT 1
- #endif
- #undef CYTHON_USE_TP_FINALIZE
- #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1 && PYPY_VERSION_NUM >= 0x07030C00)
- #undef CYTHON_USE_DICT_VERSIONS
- #define CYTHON_USE_DICT_VERSIONS 0
- #undef CYTHON_USE_EXC_INFO_STACK
- #define CYTHON_USE_EXC_INFO_STACK 0
- #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
- #define CYTHON_UPDATE_DESCRIPTOR_DOC 0
- #endif
-#elif defined(PYSTON_VERSION)
- #define CYTHON_COMPILING_IN_PYPY 0
- #define CYTHON_COMPILING_IN_PYSTON 1
- #define CYTHON_COMPILING_IN_CPYTHON 0
- #define CYTHON_COMPILING_IN_NOGIL 0
- #ifndef CYTHON_USE_TYPE_SLOTS
- #define CYTHON_USE_TYPE_SLOTS 1
- #endif
- #undef CYTHON_USE_PYTYPE_LOOKUP
- #define CYTHON_USE_PYTYPE_LOOKUP 0
- #undef CYTHON_USE_ASYNC_SLOTS
- #define CYTHON_USE_ASYNC_SLOTS 0
- #undef CYTHON_USE_PYLIST_INTERNALS
- #define CYTHON_USE_PYLIST_INTERNALS 0
- #ifndef CYTHON_USE_UNICODE_INTERNALS
- #define CYTHON_USE_UNICODE_INTERNALS 1
- #endif
- #undef CYTHON_USE_UNICODE_WRITER
- #define CYTHON_USE_UNICODE_WRITER 0
- #undef CYTHON_USE_PYLONG_INTERNALS
- #define CYTHON_USE_PYLONG_INTERNALS 0
- #ifndef CYTHON_AVOID_BORROWED_REFS
- #define CYTHON_AVOID_BORROWED_REFS 0
- #endif
- #ifndef CYTHON_ASSUME_SAFE_MACROS
- #define CYTHON_ASSUME_SAFE_MACROS 1
- #endif
- #ifndef CYTHON_UNPACK_METHODS
- #define CYTHON_UNPACK_METHODS 1
- #endif
- #undef CYTHON_FAST_THREAD_STATE
- #define CYTHON_FAST_THREAD_STATE 0
- #undef CYTHON_FAST_PYCALL
- #define CYTHON_FAST_PYCALL 0
- #undef CYTHON_PEP489_MULTI_PHASE_INIT
- #define CYTHON_PEP489_MULTI_PHASE_INIT 0
- #undef CYTHON_USE_TP_FINALIZE
- #define CYTHON_USE_TP_FINALIZE 0
- #undef CYTHON_USE_DICT_VERSIONS
- #define CYTHON_USE_DICT_VERSIONS 0
- #undef CYTHON_USE_EXC_INFO_STACK
- #define CYTHON_USE_EXC_INFO_STACK 0
- #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
- #define CYTHON_UPDATE_DESCRIPTOR_DOC 0
- #endif
-#elif defined(PY_NOGIL)
- #define CYTHON_COMPILING_IN_PYPY 0
- #define CYTHON_COMPILING_IN_PYSTON 0
- #define CYTHON_COMPILING_IN_CPYTHON 0
- #define CYTHON_COMPILING_IN_NOGIL 1
- #ifndef CYTHON_USE_TYPE_SLOTS
- #define CYTHON_USE_TYPE_SLOTS 1
- #endif
- #undef CYTHON_USE_PYTYPE_LOOKUP
- #define CYTHON_USE_PYTYPE_LOOKUP 0
- #ifndef CYTHON_USE_ASYNC_SLOTS
- #define CYTHON_USE_ASYNC_SLOTS 1
- #endif
- #undef CYTHON_USE_PYLIST_INTERNALS
- #define CYTHON_USE_PYLIST_INTERNALS 0
- #ifndef CYTHON_USE_UNICODE_INTERNALS
- #define CYTHON_USE_UNICODE_INTERNALS 1
- #endif
- #undef CYTHON_USE_UNICODE_WRITER
- #define CYTHON_USE_UNICODE_WRITER 0
- #undef CYTHON_USE_PYLONG_INTERNALS
- #define CYTHON_USE_PYLONG_INTERNALS 0
- #ifndef CYTHON_AVOID_BORROWED_REFS
- #define CYTHON_AVOID_BORROWED_REFS 0
- #endif
- #ifndef CYTHON_ASSUME_SAFE_MACROS
- #define CYTHON_ASSUME_SAFE_MACROS 1
- #endif
- #ifndef CYTHON_UNPACK_METHODS
- #define CYTHON_UNPACK_METHODS 1
- #endif
- #undef CYTHON_FAST_THREAD_STATE
- #define CYTHON_FAST_THREAD_STATE 0
- #undef CYTHON_FAST_PYCALL
- #define CYTHON_FAST_PYCALL 0
- #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
- #define CYTHON_PEP489_MULTI_PHASE_INIT 1
- #endif
- #ifndef CYTHON_USE_TP_FINALIZE
- #define CYTHON_USE_TP_FINALIZE 1
- #endif
- #undef CYTHON_USE_DICT_VERSIONS
- #define CYTHON_USE_DICT_VERSIONS 0
- #undef CYTHON_USE_EXC_INFO_STACK
- #define CYTHON_USE_EXC_INFO_STACK 0
-#else
- #define CYTHON_COMPILING_IN_PYPY 0
- #define CYTHON_COMPILING_IN_PYSTON 0
- #define CYTHON_COMPILING_IN_CPYTHON 1
- #define CYTHON_COMPILING_IN_NOGIL 0
- #ifndef CYTHON_USE_TYPE_SLOTS
- #define CYTHON_USE_TYPE_SLOTS 1
- #endif
- #if PY_VERSION_HEX < 0x02070000
- #undef CYTHON_USE_PYTYPE_LOOKUP
- #define CYTHON_USE_PYTYPE_LOOKUP 0
- #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
- #define CYTHON_USE_PYTYPE_LOOKUP 1
- #endif
- #if PY_MAJOR_VERSION < 3
- #undef CYTHON_USE_ASYNC_SLOTS
- #define CYTHON_USE_ASYNC_SLOTS 0
- #elif !defined(CYTHON_USE_ASYNC_SLOTS)
- #define CYTHON_USE_ASYNC_SLOTS 1
- #endif
- #if PY_VERSION_HEX < 0x02070000
- #undef CYTHON_USE_PYLONG_INTERNALS
- #define CYTHON_USE_PYLONG_INTERNALS 0
- #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
- #define CYTHON_USE_PYLONG_INTERNALS (PY_VERSION_HEX < 0x030C00A5)
- #endif
- #ifndef CYTHON_USE_PYLIST_INTERNALS
- #define CYTHON_USE_PYLIST_INTERNALS 1
- #endif
- #ifndef CYTHON_USE_UNICODE_INTERNALS
- #define CYTHON_USE_UNICODE_INTERNALS 1
- #endif
- #if PY_VERSION_HEX < 0x030300F0 || PY_VERSION_HEX >= 0x030B00A2
- #undef CYTHON_USE_UNICODE_WRITER
- #define CYTHON_USE_UNICODE_WRITER 0
- #elif !defined(CYTHON_USE_UNICODE_WRITER)
- #define CYTHON_USE_UNICODE_WRITER 1
- #endif
- #ifndef CYTHON_AVOID_BORROWED_REFS
- #define CYTHON_AVOID_BORROWED_REFS 0
- #endif
- #ifndef CYTHON_ASSUME_SAFE_MACROS
- #define CYTHON_ASSUME_SAFE_MACROS 1
- #endif
- #ifndef CYTHON_UNPACK_METHODS
- #define CYTHON_UNPACK_METHODS 1
- #endif
- #if PY_VERSION_HEX >= 0x030B00A4
- #undef CYTHON_FAST_THREAD_STATE
- #define CYTHON_FAST_THREAD_STATE 0
- #elif !defined(CYTHON_FAST_THREAD_STATE)
- #define CYTHON_FAST_THREAD_STATE 1
- #endif
- #ifndef CYTHON_FAST_PYCALL
- #define CYTHON_FAST_PYCALL (PY_VERSION_HEX < 0x030A0000)
- #endif
- #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
- #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
- #endif
- #ifndef CYTHON_USE_TP_FINALIZE
- #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
- #endif
- #ifndef CYTHON_USE_DICT_VERSIONS
- #define CYTHON_USE_DICT_VERSIONS ((PY_VERSION_HEX >= 0x030600B1) && (PY_VERSION_HEX < 0x030C00A5))
- #endif
- #if PY_VERSION_HEX >= 0x030B00A4
- #undef CYTHON_USE_EXC_INFO_STACK
- #define CYTHON_USE_EXC_INFO_STACK 0
- #elif !defined(CYTHON_USE_EXC_INFO_STACK)
- #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3)
- #endif
- #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
- #define CYTHON_UPDATE_DESCRIPTOR_DOC 1
- #endif
-#endif
-#if !defined(CYTHON_FAST_PYCCALL)
-#define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
-#endif
-#if CYTHON_USE_PYLONG_INTERNALS
- #if PY_MAJOR_VERSION < 3
- #include "longintrepr.h"
- #endif
- #undef SHIFT
- #undef BASE
- #undef MASK
- #ifdef SIZEOF_VOID_P
- enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
- #endif
-#endif
-#ifndef __has_attribute
- #define __has_attribute(x) 0
-#endif
-#ifndef __has_cpp_attribute
- #define __has_cpp_attribute(x) 0
-#endif
-#ifndef CYTHON_RESTRICT
- #if defined(__GNUC__)
- #define CYTHON_RESTRICT __restrict__
- #elif defined(_MSC_VER) && _MSC_VER >= 1400
- #define CYTHON_RESTRICT __restrict
- #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- #define CYTHON_RESTRICT restrict
- #else
- #define CYTHON_RESTRICT
- #endif
-#endif
-#ifndef CYTHON_UNUSED
-# if defined(__GNUC__)
-# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
-# define CYTHON_UNUSED __attribute__ ((__unused__))
-# else
-# define CYTHON_UNUSED
-# endif
-# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
-# define CYTHON_UNUSED __attribute__ ((__unused__))
-# else
-# define CYTHON_UNUSED
-# endif
-#endif
-#ifndef CYTHON_MAYBE_UNUSED_VAR
-# if defined(__cplusplus)
- template void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
-# else
-# define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
-# endif
-#endif
-#ifndef CYTHON_NCP_UNUSED
-# if CYTHON_COMPILING_IN_CPYTHON
-# define CYTHON_NCP_UNUSED
-# else
-# define CYTHON_NCP_UNUSED CYTHON_UNUSED
-# endif
-#endif
-#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
-#ifdef _MSC_VER
- #ifndef _MSC_STDINT_H_
- #if _MSC_VER < 1300
- typedef unsigned char uint8_t;
- typedef unsigned int uint32_t;
- #else
- typedef unsigned __int8 uint8_t;
- typedef unsigned __int32 uint32_t;
- #endif
- #endif
-#else
- #include
-#endif
-#ifndef CYTHON_FALLTHROUGH
- #if defined(__cplusplus) && __cplusplus >= 201103L
- #if __has_cpp_attribute(fallthrough)
- #define CYTHON_FALLTHROUGH [[fallthrough]]
- #elif __has_cpp_attribute(clang::fallthrough)
- #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
- #elif __has_cpp_attribute(gnu::fallthrough)
- #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
- #endif
- #endif
- #ifndef CYTHON_FALLTHROUGH
- #if __has_attribute(fallthrough)
- #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
- #else
- #define CYTHON_FALLTHROUGH
- #endif
- #endif
- #if defined(__clang__ ) && defined(__apple_build_version__)
- #if __apple_build_version__ < 7000000
- #undef CYTHON_FALLTHROUGH
- #define CYTHON_FALLTHROUGH
- #endif
- #endif
-#endif
-
-#ifndef CYTHON_INLINE
- #if defined(__clang__)
- #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
- #elif defined(__GNUC__)
- #define CYTHON_INLINE __inline__
- #elif defined(_MSC_VER)
- #define CYTHON_INLINE __inline
- #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- #define CYTHON_INLINE inline
- #else
- #define CYTHON_INLINE
- #endif
-#endif
-
-#define __PYX_BUILD_PY_SSIZE_T "n"
-#define CYTHON_FORMAT_SSIZE_T "z"
-#if PY_MAJOR_VERSION < 3
- #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
- #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
- PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
- #define __Pyx_DefaultClassType PyClass_Type
-#else
- #define __Pyx_BUILTIN_MODULE_NAME "builtins"
- #define __Pyx_DefaultClassType PyType_Type
-#if PY_VERSION_HEX >= 0x030B00A1
- static CYTHON_INLINE PyCodeObject* __Pyx_PyCode_New(int a, int k, int l, int s, int f,
- PyObject *code, PyObject *c, PyObject* n, PyObject *v,
- PyObject *fv, PyObject *cell, PyObject* fn,
- PyObject *name, int fline, PyObject *lnos) {
- PyObject *kwds=NULL, *argcount=NULL, *posonlyargcount=NULL, *kwonlyargcount=NULL;
- PyObject *nlocals=NULL, *stacksize=NULL, *flags=NULL, *replace=NULL, *call_result=NULL, *empty=NULL;
- const char *fn_cstr=NULL;
- const char *name_cstr=NULL;
- PyCodeObject* co=NULL;
- PyObject *type, *value, *traceback;
- PyErr_Fetch(&type, &value, &traceback);
- if (!(kwds=PyDict_New())) goto end;
- if (!(argcount=PyLong_FromLong(a))) goto end;
- if (PyDict_SetItemString(kwds, "co_argcount", argcount) != 0) goto end;
- if (!(posonlyargcount=PyLong_FromLong(0))) goto end;
- if (PyDict_SetItemString(kwds, "co_posonlyargcount", posonlyargcount) != 0) goto end;
- if (!(kwonlyargcount=PyLong_FromLong(k))) goto end;
- if (PyDict_SetItemString(kwds, "co_kwonlyargcount", kwonlyargcount) != 0) goto end;
- if (!(nlocals=PyLong_FromLong(l))) goto end;
- if (PyDict_SetItemString(kwds, "co_nlocals", nlocals) != 0) goto end;
- if (!(stacksize=PyLong_FromLong(s))) goto end;
- if (PyDict_SetItemString(kwds, "co_stacksize", stacksize) != 0) goto end;
- if (!(flags=PyLong_FromLong(f))) goto end;
- if (PyDict_SetItemString(kwds, "co_flags", flags) != 0) goto end;
- if (PyDict_SetItemString(kwds, "co_code", code) != 0) goto end;
- if (PyDict_SetItemString(kwds, "co_consts", c) != 0) goto end;
- if (PyDict_SetItemString(kwds, "co_names", n) != 0) goto end;
- if (PyDict_SetItemString(kwds, "co_varnames", v) != 0) goto end;
- if (PyDict_SetItemString(kwds, "co_freevars", fv) != 0) goto end;
- if (PyDict_SetItemString(kwds, "co_cellvars", cell) != 0) goto end;
- if (PyDict_SetItemString(kwds, "co_linetable", lnos) != 0) goto end;
- if (!(fn_cstr=PyUnicode_AsUTF8AndSize(fn, NULL))) goto end;
- if (!(name_cstr=PyUnicode_AsUTF8AndSize(name, NULL))) goto end;
- if (!(co = PyCode_NewEmpty(fn_cstr, name_cstr, fline))) goto end;
- if (!(replace = PyObject_GetAttrString((PyObject*)co, "replace"))) goto cleanup_code_too;
- if (!(empty = PyTuple_New(0))) goto cleanup_code_too; // unfortunately __pyx_empty_tuple isn't available here
- if (!(call_result = PyObject_Call(replace, empty, kwds))) goto cleanup_code_too;
- Py_XDECREF((PyObject*)co);
- co = (PyCodeObject*)call_result;
- call_result = NULL;
- if (0) {
- cleanup_code_too:
- Py_XDECREF((PyObject*)co);
- co = NULL;
- }
- end:
- Py_XDECREF(kwds);
- Py_XDECREF(argcount);
- Py_XDECREF(posonlyargcount);
- Py_XDECREF(kwonlyargcount);
- Py_XDECREF(nlocals);
- Py_XDECREF(stacksize);
- Py_XDECREF(replace);
- Py_XDECREF(call_result);
- Py_XDECREF(empty);
- if (type) {
- PyErr_Restore(type, value, traceback);
- }
- return co;
- }
-#else
- #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
- PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
-#endif
- #define __Pyx_DefaultClassType PyType_Type
-#endif
-#if PY_VERSION_HEX >= 0x030900F0 && !CYTHON_COMPILING_IN_PYPY
- #define __Pyx_PyObject_GC_IsFinalized(o) PyObject_GC_IsFinalized(o)
-#else
- #define __Pyx_PyObject_GC_IsFinalized(o) _PyGC_FINALIZED(o)
-#endif
-#ifndef Py_TPFLAGS_CHECKTYPES
- #define Py_TPFLAGS_CHECKTYPES 0
-#endif
-#ifndef Py_TPFLAGS_HAVE_INDEX
- #define Py_TPFLAGS_HAVE_INDEX 0
-#endif
-#ifndef Py_TPFLAGS_HAVE_NEWBUFFER
- #define Py_TPFLAGS_HAVE_NEWBUFFER 0
-#endif
-#ifndef Py_TPFLAGS_HAVE_FINALIZE
- #define Py_TPFLAGS_HAVE_FINALIZE 0
-#endif
-#ifndef METH_STACKLESS
- #define METH_STACKLESS 0
-#endif
-#if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
- #ifndef METH_FASTCALL
- #define METH_FASTCALL 0x80
- #endif
- typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
- typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
- Py_ssize_t nargs, PyObject *kwnames);
-#else
- #define __Pyx_PyCFunctionFast _PyCFunctionFast
- #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
-#endif
-#if CYTHON_FAST_PYCCALL
-#define __Pyx_PyFastCFunction_Check(func)\
- ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)))))
-#else
-#define __Pyx_PyFastCFunction_Check(func) 0
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
- #define PyObject_Malloc(s) PyMem_Malloc(s)
- #define PyObject_Free(p) PyMem_Free(p)
- #define PyObject_Realloc(p) PyMem_Realloc(p)
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1
- #define PyMem_RawMalloc(n) PyMem_Malloc(n)
- #define PyMem_RawRealloc(p, n) PyMem_Realloc(p, n)
- #define PyMem_RawFree(p) PyMem_Free(p)
-#endif
-#if CYTHON_COMPILING_IN_PYSTON
- #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co)
- #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
-#else
- #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
- #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
-#endif
-#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
- #define __Pyx_PyThreadState_Current PyThreadState_GET()
-#elif PY_VERSION_HEX >= 0x03060000
- #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
-#elif PY_VERSION_HEX >= 0x03000000
- #define __Pyx_PyThreadState_Current PyThreadState_GET()
-#else
- #define __Pyx_PyThreadState_Current _PyThreadState_Current
-#endif
-#if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
-#include "pythread.h"
-#define Py_tss_NEEDS_INIT 0
-typedef int Py_tss_t;
-static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
- *key = PyThread_create_key();
- return 0;
-}
-static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
- Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
- *key = Py_tss_NEEDS_INIT;
- return key;
-}
-static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
- PyObject_Free(key);
-}
-static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
- return *key != Py_tss_NEEDS_INIT;
-}
-static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
- PyThread_delete_key(*key);
- *key = Py_tss_NEEDS_INIT;
-}
-static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
- return PyThread_set_key_value(*key, value);
-}
-static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
- return PyThread_get_key_value(*key);
-}
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
-#define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
-#else
-#define __Pyx_PyDict_NewPresized(n) PyDict_New()
-#endif
-#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
- #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
- #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
-#else
- #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
- #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
-#define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
-#else
-#define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name)
-#endif
-#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
- #define CYTHON_PEP393_ENABLED 1
- #if PY_VERSION_HEX >= 0x030C0000
- #define __Pyx_PyUnicode_READY(op) (0)
- #else
- #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
- 0 : _PyUnicode_Ready((PyObject *)(op)))
- #endif
- #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
- #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
- #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
- #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
- #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
- #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
- #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
- #if PY_VERSION_HEX >= 0x030C0000
- #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_LENGTH(u))
- #else
- #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03090000
- #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : ((PyCompactUnicodeObject *)(u))->wstr_length))
- #else
- #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
- #endif
- #endif
-#else
- #define CYTHON_PEP393_ENABLED 0
- #define PyUnicode_1BYTE_KIND 1
- #define PyUnicode_2BYTE_KIND 2
- #define PyUnicode_4BYTE_KIND 4
- #define __Pyx_PyUnicode_READY(op) (0)
- #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
- #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
- #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
- #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
- #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
- #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
- #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
- #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
-#endif
-#if CYTHON_COMPILING_IN_PYPY
- #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
- #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
-#else
- #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
- #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
- PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
- #define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
- #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
- #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
-#endif
-#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
-#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
-#if PY_MAJOR_VERSION >= 3
- #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
-#else
- #define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
-#endif
-#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
- #define PyObject_ASCII(o) PyObject_Repr(o)
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define PyBaseString_Type PyUnicode_Type
- #define PyStringObject PyUnicodeObject
- #define PyString_Type PyUnicode_Type
- #define PyString_Check PyUnicode_Check
- #define PyString_CheckExact PyUnicode_CheckExact
-#ifndef PyObject_Unicode
- #define PyObject_Unicode PyObject_Str
-#endif
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
- #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
-#else
- #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
- #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
-#endif
-#ifndef PySet_CheckExact
- #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
-#endif
-#if PY_VERSION_HEX >= 0x030900A4
- #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt)
- #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size)
-#else
- #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt)
- #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size)
-#endif
-#if CYTHON_ASSUME_SAFE_MACROS
- #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
-#else
- #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq)
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define PyIntObject PyLongObject
- #define PyInt_Type PyLong_Type
- #define PyInt_Check(op) PyLong_Check(op)
- #define PyInt_CheckExact(op) PyLong_CheckExact(op)
- #define PyInt_FromString PyLong_FromString
- #define PyInt_FromUnicode PyLong_FromUnicode
- #define PyInt_FromLong PyLong_FromLong
- #define PyInt_FromSize_t PyLong_FromSize_t
- #define PyInt_FromSsize_t PyLong_FromSsize_t
- #define PyInt_AsLong PyLong_AsLong
- #define PyInt_AS_LONG PyLong_AS_LONG
- #define PyInt_AsSsize_t PyLong_AsSsize_t
- #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
- #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
- #define PyNumber_Int PyNumber_Long
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define PyBoolObject PyLongObject
-#endif
-#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
- #ifndef PyUnicode_InternFromString
- #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
- #endif
-#endif
-#if PY_VERSION_HEX < 0x030200A4
- typedef long Py_hash_t;
- #define __Pyx_PyInt_FromHash_t PyInt_FromLong
- #define __Pyx_PyInt_AsHash_t __Pyx_PyIndex_AsHash_t
-#else
- #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
- #define __Pyx_PyInt_AsHash_t __Pyx_PyIndex_AsSsize_t
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define __Pyx_PyMethod_New(func, self, klass) ((self) ? ((void)(klass), PyMethod_New(func, self)) : __Pyx_NewRef(func))
-#else
- #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
-#endif
-#if CYTHON_USE_ASYNC_SLOTS
- #if PY_VERSION_HEX >= 0x030500B1
- #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
- #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
- #else
- #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
- #endif
-#else
- #define __Pyx_PyType_AsAsync(obj) NULL
-#endif
-#ifndef __Pyx_PyAsyncMethodsStruct
- typedef struct {
- unaryfunc am_await;
- unaryfunc am_aiter;
- unaryfunc am_anext;
- } __Pyx_PyAsyncMethodsStruct;
-#endif
-
-#if defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS)
- #if !defined(_USE_MATH_DEFINES)
- #define _USE_MATH_DEFINES
- #endif
-#endif
-#include
-#ifdef NAN
-#define __PYX_NAN() ((float) NAN)
-#else
-static CYTHON_INLINE float __PYX_NAN() {
- float value;
- memset(&value, 0xFF, sizeof(value));
- return value;
-}
-#endif
-#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
-#define __Pyx_truncl trunc
-#else
-#define __Pyx_truncl truncl
-#endif
-
-#define __PYX_MARK_ERR_POS(f_index, lineno) \
- { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; }
-#define __PYX_ERR(f_index, lineno, Ln_error) \
- { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }
-
-#ifndef __PYX_EXTERN_C
- #ifdef __cplusplus
- #define __PYX_EXTERN_C extern "C"
- #else
- #define __PYX_EXTERN_C extern
- #endif
-#endif
-
-#define __PYX_HAVE__fontTools__feaLib__lexer
-#define __PYX_HAVE_API__fontTools__feaLib__lexer
-/* Early includes */
-#ifdef _OPENMP
-#include
-#endif /* _OPENMP */
-
-#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
-#define CYTHON_WITHOUT_ASSERTIONS
-#endif
-
-typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
- const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
-
-#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
-#define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0
-#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8)
-#define __PYX_DEFAULT_STRING_ENCODING ""
-#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
-#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
-#define __Pyx_uchar_cast(c) ((unsigned char)c)
-#define __Pyx_long_cast(x) ((long)x)
-#define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
- (sizeof(type) < sizeof(Py_ssize_t)) ||\
- (sizeof(type) > sizeof(Py_ssize_t) &&\
- likely(v < (type)PY_SSIZE_T_MAX ||\
- v == (type)PY_SSIZE_T_MAX) &&\
- (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
- v == (type)PY_SSIZE_T_MIN))) ||\
- (sizeof(type) == sizeof(Py_ssize_t) &&\
- (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
- v == (type)PY_SSIZE_T_MAX))) )
-static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
- return (size_t) i < (size_t) limit;
-}
-#if defined (__cplusplus) && __cplusplus >= 201103L
- #include
- #define __Pyx_sst_abs(value) std::abs(value)
-#elif SIZEOF_INT >= SIZEOF_SIZE_T
- #define __Pyx_sst_abs(value) abs(value)
-#elif SIZEOF_LONG >= SIZEOF_SIZE_T
- #define __Pyx_sst_abs(value) labs(value)
-#elif defined (_MSC_VER)
- #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
-#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- #define __Pyx_sst_abs(value) llabs(value)
-#elif defined (__GNUC__)
- #define __Pyx_sst_abs(value) __builtin_llabs(value)
-#else
- #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
-#endif
-static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
-static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
-#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
-#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
-#define __Pyx_PyBytes_FromString PyBytes_FromString
-#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
-static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
-#if PY_MAJOR_VERSION < 3
- #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
- #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
-#else
- #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
- #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
-#endif
-#define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
-#define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
-#define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
-#define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
-#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
-static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
- const Py_UNICODE *u_end = u;
- while (*u_end++) ;
- return (size_t)(u_end - u - 1);
-}
-#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
-#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
-#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
-#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
-#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
-static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
-static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
-static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
-static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
-#define __Pyx_PySequence_Tuple(obj)\
- (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
-static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
-static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
-static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject*);
-#if CYTHON_ASSUME_SAFE_MACROS
-#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
-#else
-#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
-#endif
-#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
-#if PY_MAJOR_VERSION >= 3
-#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
-#else
-#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
-#endif
-#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
-#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
-static int __Pyx_sys_getdefaultencoding_not_ascii;
-static int __Pyx_init_sys_getdefaultencoding_params(void) {
- PyObject* sys;
- PyObject* default_encoding = NULL;
- PyObject* ascii_chars_u = NULL;
- PyObject* ascii_chars_b = NULL;
- const char* default_encoding_c;
- sys = PyImport_ImportModule("sys");
- if (!sys) goto bad;
- default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
- Py_DECREF(sys);
- if (!default_encoding) goto bad;
- default_encoding_c = PyBytes_AsString(default_encoding);
- if (!default_encoding_c) goto bad;
- if (strcmp(default_encoding_c, "ascii") == 0) {
- __Pyx_sys_getdefaultencoding_not_ascii = 0;
- } else {
- char ascii_chars[128];
- int c;
- for (c = 0; c < 128; c++) {
- ascii_chars[c] = c;
- }
- __Pyx_sys_getdefaultencoding_not_ascii = 1;
- ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
- if (!ascii_chars_u) goto bad;
- ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
- if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
- PyErr_Format(
- PyExc_ValueError,
- "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
- default_encoding_c);
- goto bad;
- }
- Py_DECREF(ascii_chars_u);
- Py_DECREF(ascii_chars_b);
- }
- Py_DECREF(default_encoding);
- return 0;
-bad:
- Py_XDECREF(default_encoding);
- Py_XDECREF(ascii_chars_u);
- Py_XDECREF(ascii_chars_b);
- return -1;
-}
-#endif
-#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
-#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
-#else
-#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
-#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
-static char* __PYX_DEFAULT_STRING_ENCODING;
-static int __Pyx_init_sys_getdefaultencoding_params(void) {
- PyObject* sys;
- PyObject* default_encoding = NULL;
- char* default_encoding_c;
- sys = PyImport_ImportModule("sys");
- if (!sys) goto bad;
- default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
- Py_DECREF(sys);
- if (!default_encoding) goto bad;
- default_encoding_c = PyBytes_AsString(default_encoding);
- if (!default_encoding_c) goto bad;
- __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1);
- if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
- strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
- Py_DECREF(default_encoding);
- return 0;
-bad:
- Py_XDECREF(default_encoding);
- return -1;
-}
-#endif
-#endif
-
-
-/* Test for GCC > 2.95 */
-#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
- #define likely(x) __builtin_expect(!!(x), 1)
- #define unlikely(x) __builtin_expect(!!(x), 0)
-#else /* !__GNUC__ or GCC < 2.95 */
- #define likely(x) (x)
- #define unlikely(x) (x)
-#endif /* __GNUC__ */
-static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
-
-static PyObject *__pyx_m = NULL;
-static PyObject *__pyx_d;
-static PyObject *__pyx_b;
-static PyObject *__pyx_cython_runtime = NULL;
-static PyObject *__pyx_empty_tuple;
-static PyObject *__pyx_empty_bytes;
-static PyObject *__pyx_empty_unicode;
-static int __pyx_lineno;
-static int __pyx_clineno = 0;
-static const char * __pyx_cfilenm= __FILE__;
-static const char *__pyx_filename;
-
-
-static const char *__pyx_f[] = {
- "Lib/fontTools/feaLib/lexer.py",
-};
-
-/*--- Type declarations ---*/
-
-/* --- Runtime support code (head) --- */
-/* Refnanny.proto */
-#ifndef CYTHON_REFNANNY
- #define CYTHON_REFNANNY 0
-#endif
-#if CYTHON_REFNANNY
- typedef struct {
- void (*INCREF)(void*, PyObject*, int);
- void (*DECREF)(void*, PyObject*, int);
- void (*GOTREF)(void*, PyObject*, int);
- void (*GIVEREF)(void*, PyObject*, int);
- void* (*SetupContext)(const char*, int, const char*);
- void (*FinishContext)(void**);
- } __Pyx_RefNannyAPIStruct;
- static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
- static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
- #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
-#ifdef WITH_THREAD
- #define __Pyx_RefNannySetupContext(name, acquire_gil)\
- if (acquire_gil) {\
- PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
- __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
- PyGILState_Release(__pyx_gilstate_save);\
- } else {\
- __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
- }
-#else
- #define __Pyx_RefNannySetupContext(name, acquire_gil)\
- __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
-#endif
- #define __Pyx_RefNannyFinishContext()\
- __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
- #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
- #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
- #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
- #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
-#else
- #define __Pyx_RefNannyDeclarations
- #define __Pyx_RefNannySetupContext(name, acquire_gil)
- #define __Pyx_RefNannyFinishContext()
- #define __Pyx_INCREF(r) Py_INCREF(r)
- #define __Pyx_DECREF(r) Py_DECREF(r)
- #define __Pyx_GOTREF(r)
- #define __Pyx_GIVEREF(r)
- #define __Pyx_XINCREF(r) Py_XINCREF(r)
- #define __Pyx_XDECREF(r) Py_XDECREF(r)
- #define __Pyx_XGOTREF(r)
- #define __Pyx_XGIVEREF(r)
-#endif
-#define __Pyx_XDECREF_SET(r, v) do {\
- PyObject *tmp = (PyObject *) r;\
- r = v; __Pyx_XDECREF(tmp);\
- } while (0)
-#define __Pyx_DECREF_SET(r, v) do {\
- PyObject *tmp = (PyObject *) r;\
- r = v; __Pyx_DECREF(tmp);\
- } while (0)
-#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
-#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
-
-/* PyObjectGetAttrStr.proto */
-#if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
-#else
-#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
-#endif
-
-/* GetBuiltinName.proto */
-static PyObject *__Pyx_GetBuiltinName(PyObject *name);
-
-/* RaiseArgTupleInvalid.proto */
-static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
- Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
-
-/* RaiseDoubleKeywords.proto */
-static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
-
-/* ParseKeywords.proto */
-static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
- PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
- const char* function_name);
-
-/* PyObjectSetAttrStr.proto */
-#if CYTHON_USE_TYPE_SLOTS
-#define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o, n, NULL)
-static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value);
-#else
-#define __Pyx_PyObject_DelAttrStr(o,n) PyObject_DelAttr(o,n)
-#define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v)
-#endif
-
-/* PyDictVersioning.proto */
-#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
-#define __PYX_DICT_VERSION_INIT ((PY_UINT64_T) -1)
-#define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag)
-#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
- (version_var) = __PYX_GET_DICT_VERSION(dict);\
- (cache_var) = (value);
-#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
- static PY_UINT64_T __pyx_dict_version = 0;\
- static PyObject *__pyx_dict_cached_value = NULL;\
- if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
- (VAR) = __pyx_dict_cached_value;\
- } else {\
- (VAR) = __pyx_dict_cached_value = (LOOKUP);\
- __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
- }\
-}
-static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
-static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
-static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
-#else
-#define __PYX_GET_DICT_VERSION(dict) (0)
-#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
-#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP);
-#endif
-
-/* GetModuleGlobalName.proto */
-#if CYTHON_USE_DICT_VERSIONS
-#define __Pyx_GetModuleGlobalName(var, name) do {\
- static PY_UINT64_T __pyx_dict_version = 0;\
- static PyObject *__pyx_dict_cached_value = NULL;\
- (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\
- (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\
- __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
-} while(0)
-#define __Pyx_GetModuleGlobalNameUncached(var, name) do {\
- PY_UINT64_T __pyx_dict_version;\
- PyObject *__pyx_dict_cached_value;\
- (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
-} while(0)
-static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value);
-#else
-#define __Pyx_GetModuleGlobalName(var, name) (var) = __Pyx__GetModuleGlobalName(name)
-#define __Pyx_GetModuleGlobalNameUncached(var, name) (var) = __Pyx__GetModuleGlobalName(name)
-static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name);
-#endif
-
-/* PyFunctionFastCall.proto */
-#if CYTHON_FAST_PYCALL
-#define __Pyx_PyFunction_FastCall(func, args, nargs)\
- __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
-#if 1 || PY_VERSION_HEX < 0x030600B1
-static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs);
-#else
-#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
-#endif
-#define __Pyx_BUILD_ASSERT_EXPR(cond)\
- (sizeof(char [1 - 2*!(cond)]) - 1)
-#ifndef Py_MEMBER_SIZE
-#define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
-#endif
-#if CYTHON_FAST_PYCALL
- static size_t __pyx_pyframe_localsplus_offset = 0;
- #include "frameobject.h"
-#if PY_VERSION_HEX >= 0x030b00a6
- #ifndef Py_BUILD_CORE
- #define Py_BUILD_CORE 1
- #endif
- #include "internal/pycore_frame.h"
-#endif
- #define __Pxy_PyFrame_Initialize_Offsets()\
- ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
- (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
- #define __Pyx_PyFrame_GetLocalsplus(frame)\
- (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
-#endif // CYTHON_FAST_PYCALL
-#endif
-
-/* PyObjectCall.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
-#else
-#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
-#endif
-
-/* PyObjectCallMethO.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
-#endif
-
-/* PyObjectCallNoArg.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
-#else
-#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
-#endif
-
-/* PyCFunctionFastCall.proto */
-#if CYTHON_FAST_PYCCALL
-static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
-#else
-#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL)
-#endif
-
-/* PyObjectCallOneArg.proto */
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
-
-/* RaiseTooManyValuesToUnpack.proto */
-static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
-
-/* RaiseNeedMoreValuesToUnpack.proto */
-static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
-
-/* IterFinish.proto */
-static CYTHON_INLINE int __Pyx_IterFinish(void);
-
-/* UnpackItemEndCheck.proto */
-static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected);
-
-/* PyIntBinop.proto */
-#if !CYTHON_COMPILING_IN_PYPY
-static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
-#else
-#define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace, zerodivision_check)\
- (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2))
-#endif
-
-/* PyObjectCall2Args.proto */
-static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2);
-
-/* PyThreadStateGet.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
-#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current;
-#define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type
-#else
-#define __Pyx_PyThreadState_declare
-#define __Pyx_PyThreadState_assign
-#define __Pyx_PyErr_Occurred() PyErr_Occurred()
-#endif
-
-/* PyErrFetchRestore.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
-#define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
-#define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
-#define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
-#define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
-static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#if CYTHON_COMPILING_IN_CPYTHON
-#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
-#else
-#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
-#endif
-#else
-#define __Pyx_PyErr_Clear() PyErr_Clear()
-#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
-#define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
-#define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
-#define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
-#define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
-#define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
-#define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
-#endif
-
-/* RaiseException.proto */
-static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
-
-/* GetItemInt.proto */
-#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
- (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
- __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
- (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
- __Pyx_GetItemInt_Generic(o, to_py_func(i))))
-#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
- (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
- __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
- (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
- int wraparound, int boundscheck);
-#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
- (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
- __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
- (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
- int wraparound, int boundscheck);
-static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
- int is_list, int wraparound, int boundscheck);
-
-/* ObjectGetItem.proto */
-#if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key);
-#else
-#define __Pyx_PyObject_GetItem(obj, key) PyObject_GetItem(obj, key)
-#endif
-
-/* IncludeStringH.proto */
-#include
-
-/* BytesEquals.proto */
-static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals);
-
-/* UnicodeEquals.proto */
-static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals);
-
-/* SliceObject.proto */
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(
- PyObject* obj, Py_ssize_t cstart, Py_ssize_t cstop,
- PyObject** py_start, PyObject** py_stop, PyObject** py_slice,
- int has_cstart, int has_cstop, int wraparound);
-
-/* PyIntBinop.proto */
-#if !CYTHON_COMPILING_IN_PYPY
-static PyObject* __Pyx_PyInt_SubtractObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
-#else
-#define __Pyx_PyInt_SubtractObjC(op1, op2, intval, inplace, zerodivision_check)\
- (inplace ? PyNumber_InPlaceSubtract(op1, op2) : PyNumber_Subtract(op1, op2))
-#endif
-
-/* PySequenceContains.proto */
-static CYTHON_INLINE int __Pyx_PySequence_ContainsTF(PyObject* item, PyObject* seq, int eq) {
- int result = PySequence_Contains(seq, item);
- return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
-}
-
-/* PyUnicodeContains.proto */
-static CYTHON_INLINE int __Pyx_PyUnicode_ContainsTF(PyObject* substring, PyObject* text, int eq) {
- int result = PyUnicode_Contains(text, substring);
- return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
-}
-
-/* IterNext.proto */
-#define __Pyx_PyIter_Next(obj) __Pyx_PyIter_Next2(obj, NULL)
-static CYTHON_INLINE PyObject *__Pyx_PyIter_Next2(PyObject *, PyObject *);
-
-/* GetTopmostException.proto */
-#if CYTHON_USE_EXC_INFO_STACK
-static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate);
-#endif
-
-/* SaveResetException.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
-#else
-#define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb)
-#define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb)
-#endif
-
-/* PyErrExceptionMatches.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
-static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
-#else
-#define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
-#endif
-
-/* GetException.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb)
-static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#else
-static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
-#endif
-
-/* PyObjectGetMethod.proto */
-static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method);
-
-/* PyObjectCallMethod0.proto */
-static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name);
-
-/* pop.proto */
-static CYTHON_INLINE PyObject* __Pyx__PyObject_Pop(PyObject* L);
-#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
-static CYTHON_INLINE PyObject* __Pyx_PyList_Pop(PyObject* L);
-#define __Pyx_PyObject_Pop(L) (likely(PyList_CheckExact(L)) ?\
- __Pyx_PyList_Pop(L) : __Pyx__PyObject_Pop(L))
-#else
-#define __Pyx_PyList_Pop(L) __Pyx__PyObject_Pop(L)
-#define __Pyx_PyObject_Pop(L) __Pyx__PyObject_Pop(L)
-#endif
-
-/* UnpackUnboundCMethod.proto */
-typedef struct {
- PyObject *type;
- PyObject **method_name;
- PyCFunction func;
- PyObject *method;
- int flag;
-} __Pyx_CachedCFunction;
-
-/* CallUnboundCMethod0.proto */
-static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self);
-#if CYTHON_COMPILING_IN_CPYTHON
-#define __Pyx_CallUnboundCMethod0(cfunc, self)\
- (likely((cfunc)->func) ?\
- (likely((cfunc)->flag == METH_NOARGS) ? (*((cfunc)->func))(self, NULL) :\
- (PY_VERSION_HEX >= 0x030600B1 && likely((cfunc)->flag == METH_FASTCALL) ?\
- (PY_VERSION_HEX >= 0x030700A0 ?\
- (*(__Pyx_PyCFunctionFast)(void*)(PyCFunction)(cfunc)->func)(self, &__pyx_empty_tuple, 0) :\
- (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)(cfunc)->func)(self, &__pyx_empty_tuple, 0, NULL)) :\
- (PY_VERSION_HEX >= 0x030700A0 && (cfunc)->flag == (METH_FASTCALL | METH_KEYWORDS) ?\
- (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)(cfunc)->func)(self, &__pyx_empty_tuple, 0, NULL) :\
- (likely((cfunc)->flag == (METH_VARARGS | METH_KEYWORDS)) ? ((*(PyCFunctionWithKeywords)(void*)(PyCFunction)(cfunc)->func)(self, __pyx_empty_tuple, NULL)) :\
- ((cfunc)->flag == METH_VARARGS ? (*((cfunc)->func))(self, __pyx_empty_tuple) :\
- __Pyx__CallUnboundCMethod0(cfunc, self)))))) :\
- __Pyx__CallUnboundCMethod0(cfunc, self))
-#else
-#define __Pyx_CallUnboundCMethod0(cfunc, self) __Pyx__CallUnboundCMethod0(cfunc, self)
-#endif
-
-/* ListAppend.proto */
-#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
-static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
- PyListObject* L = (PyListObject*) list;
- Py_ssize_t len = Py_SIZE(list);
- if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
- Py_INCREF(x);
- PyList_SET_ITEM(list, len, x);
- __Pyx_SET_SIZE(list, len + 1);
- return 0;
- }
- return PyList_Append(list, x);
-}
-#else
-#define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
-#endif
-
-/* PyObjectCallMethod1.proto */
-static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg);
-
-/* append.proto */
-static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x);
-
-/* FastTypeChecks.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
-static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
-#else
-#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
-#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
-#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
-#endif
-#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
-
-/* SwapException.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_ExceptionSwap(type, value, tb) __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#else
-static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
-#endif
-
-/* GetAttr.proto */
-static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);
-
-/* HasAttr.proto */
-static CYTHON_INLINE int __Pyx_HasAttr(PyObject *, PyObject *);
-
-/* GetAttr3.proto */
-static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *);
-
-/* Import.proto */
-static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
-
-/* ImportFrom.proto */
-static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
-
-/* CalculateMetaclass.proto */
-static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases);
-
-/* SetNameInClass.proto */
-#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
-#define __Pyx_SetNameInClass(ns, name, value)\
- (likely(PyDict_CheckExact(ns)) ? _PyDict_SetItem_KnownHash(ns, name, value, ((PyASCIIObject *) name)->hash) : PyObject_SetItem(ns, name, value))
-#elif CYTHON_COMPILING_IN_CPYTHON
-#define __Pyx_SetNameInClass(ns, name, value)\
- (likely(PyDict_CheckExact(ns)) ? PyDict_SetItem(ns, name, value) : PyObject_SetItem(ns, name, value))
-#else
-#define __Pyx_SetNameInClass(ns, name, value) PyObject_SetItem(ns, name, value)
-#endif
-
-/* FetchCommonType.proto */
-static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);
-
-/* CythonFunctionShared.proto */
-#define __Pyx_CyFunction_USED 1
-#define __Pyx_CYFUNCTION_STATICMETHOD 0x01
-#define __Pyx_CYFUNCTION_CLASSMETHOD 0x02
-#define __Pyx_CYFUNCTION_CCLASS 0x04
-#define __Pyx_CyFunction_GetClosure(f)\
- (((__pyx_CyFunctionObject *) (f))->func_closure)
-#define __Pyx_CyFunction_GetClassObj(f)\
- (((__pyx_CyFunctionObject *) (f))->func_classobj)
-#define __Pyx_CyFunction_Defaults(type, f)\
- ((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
-#define __Pyx_CyFunction_SetDefaultsGetter(f, g)\
- ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
-typedef struct {
- PyCFunctionObject func;
-#if PY_VERSION_HEX < 0x030500A0
- PyObject *func_weakreflist;
-#endif
- PyObject *func_dict;
- PyObject *func_name;
- PyObject *func_qualname;
- PyObject *func_doc;
- PyObject *func_globals;
- PyObject *func_code;
- PyObject *func_closure;
- PyObject *func_classobj;
- void *defaults;
- int defaults_pyobjects;
- size_t defaults_size; // used by FusedFunction for copying defaults
- int flags;
- PyObject *defaults_tuple;
- PyObject *defaults_kwdict;
- PyObject *(*defaults_getter)(PyObject *);
- PyObject *func_annotations;
-} __pyx_CyFunctionObject;
-static PyTypeObject *__pyx_CyFunctionType = 0;
-#define __Pyx_CyFunction_Check(obj) (__Pyx_TypeCheck(obj, __pyx_CyFunctionType))
-static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject* op, PyMethodDef *ml,
- int flags, PyObject* qualname,
- PyObject *self,
- PyObject *module, PyObject *globals,
- PyObject* code);
-static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m,
- size_t size,
- int pyobjects);
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
- PyObject *tuple);
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m,
- PyObject *dict);
-static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m,
- PyObject *dict);
-static int __pyx_CyFunction_init(void);
-
-/* CythonFunction.proto */
-static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml,
- int flags, PyObject* qualname,
- PyObject *closure,
- PyObject *module, PyObject *globals,
- PyObject* code);
-
-/* Py3ClassCreate.proto */
-static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, PyObject *qualname,
- PyObject *mkw, PyObject *modname, PyObject *doc);
-static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, PyObject *dict,
- PyObject *mkw, int calculate_metaclass, int allow_py2_metaclass);
-
-/* CLineInTraceback.proto */
-#ifdef CYTHON_CLINE_IN_TRACEBACK
-#define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
-#else
-static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
-#endif
-
-/* CodeObjectCache.proto */
-typedef struct {
- PyCodeObject* code_object;
- int code_line;
-} __Pyx_CodeObjectCacheEntry;
-struct __Pyx_CodeObjectCache {
- int count;
- int max_count;
- __Pyx_CodeObjectCacheEntry* entries;
-};
-static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
-static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
-static PyCodeObject *__pyx_find_code_object(int code_line);
-static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
-
-/* AddTraceback.proto */
-static void __Pyx_AddTraceback(const char *funcname, int c_line,
- int py_line, const char *filename);
-
-/* GCCDiagnostics.proto */
-#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
-#define __Pyx_HAS_GCC_DIAGNOSTIC
-#endif
-
-/* CIntToPy.proto */
-static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
-
-/* CIntFromPy.proto */
-static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
-
-/* CIntFromPy.proto */
-static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
-
-/* CheckBinaryVersion.proto */
-static int __Pyx_check_binary_version(void);
-
-/* InitStrings.proto */
-static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
-
-
-/* Module declarations from 'cython' */
-
-/* Module declarations from 'fontTools.feaLib.lexer' */
-#define __Pyx_MODULE_NAME "fontTools.feaLib.lexer"
-extern int __pyx_module_is_main_fontTools__feaLib__lexer;
-int __pyx_module_is_main_fontTools__feaLib__lexer = 0;
-
-/* Implementation of 'fontTools.feaLib.lexer' */
-static PyObject *__pyx_builtin_ImportError;
-static PyObject *__pyx_builtin_object;
-static PyObject *__pyx_builtin_staticmethod;
-static PyObject *__pyx_builtin_StopIteration;
-static PyObject *__pyx_builtin_open;
-static const char __pyx_k_[] = "\n";
-static const char __pyx_k_0[] = "0";
-static const char __pyx_k_p[] = "p";
-static const char __pyx_k_r[] = "r";
-static const char __pyx_k_s[] = "}\\s*";
-static const char __pyx_k__2[] = "\r";
-static const char __pyx_k__3[] = "#";
-static const char __pyx_k__4[] = "(";
-static const char __pyx_k__5[] = ")";
-static const char __pyx_k__6[] = "\\";
-static const char __pyx_k__7[] = "@";
-static const char __pyx_k__8[] = ".";
-static const char __pyx_k__9[] = "-";
-static const char __pyx_k_os[] = "os";
-static const char __pyx_k_re[] = "re";
-static const char __pyx_k_xX[] = "xX";
-static const char __pyx_k_CID[] = "CID";
-static const char __pyx_k__10[] = "\"";
-static const char __pyx_k__11[] = "[\r\n]";
-static const char __pyx_k__12[] = "";
-static const char __pyx_k__14[] = " \t";
-static const char __pyx_k__15[] = "\r\n";
-static const char __pyx_k__16[] = ",;:-+'{}[]<>()=";
-static const char __pyx_k__17[] = "_+*:.^~!\\";
-static const char __pyx_k__18[] = "_.+*:^~!/-";
-static const char __pyx_k_doc[] = "__doc__";
-static const char __pyx_k_err[] = "err";
-static const char __pyx_k_pop[] = "pop";
-static const char __pyx_k_pos[] = "pos_";
-static const char __pyx_k_s_2[] = "\\s*;";
-static const char __pyx_k_sub[] = "sub";
-static const char __pyx_k_tag[] = "tag";
-static const char __pyx_k_NAME[] = "NAME";
-static const char __pyx_k_data[] = "data";
-static const char __pyx_k_init[] = "__init__";
-static const char __pyx_k_iter[] = "__iter__";
-static const char __pyx_k_join[] = "join";
-static const char __pyx_k_line[] = "line_";
-static const char __pyx_k_main[] = "__main__";
-static const char __pyx_k_mode[] = "mode_";
-static const char __pyx_k_name[] = "name";
-static const char __pyx_k_next[] = "__next__";
-static const char __pyx_k_open[] = "open";
-static const char __pyx_k_path[] = "path";
-static const char __pyx_k_read[] = "read";
-static const char __pyx_k_self[] = "self";
-static const char __pyx_k_test[] = "__test__";
-static const char __pyx_k_text[] = "text";
-static const char __pyx_k_FLOAT[] = "FLOAT";
-static const char __pyx_k_Lexer[] = "Lexer";
-static const char __pyx_k_OCTAL[] = "OCTAL";
-static const char __pyx_k_close[] = "close";
-static const char __pyx_k_isabs[] = "isabs";
-static const char __pyx_k_lexer[] = "lexer";
-static const char __pyx_k_limit[] = "limit";
-static const char __pyx_k_match[] = "match";
-static const char __pyx_k_split[] = "split";
-static const char __pyx_k_start[] = "start";
-static const char __pyx_k_strip[] = "strip";
-static const char __pyx_k_token[] = "token";
-static const char __pyx_k_utf_8[] = "utf-8";
-static const char __pyx_k_valid[] = "valid";
-static const char __pyx_k_NORMAL[] = "NORMAL";
-static const char __pyx_k_NUMBER[] = "NUMBER";
-static const char __pyx_k_STRING[] = "STRING";
-static const char __pyx_k_SYMBOL[] = "SYMBOL";
-static const char __pyx_k_append[] = "append";
-static const char __pyx_k_column[] = "column";
-static const char __pyx_k_getcwd[] = "getcwd";
-static const char __pyx_k_import[] = "__import__";
-static const char __pyx_k_lexers[] = "lexers_";
-static const char __pyx_k_module[] = "__module__";
-static const char __pyx_k_name_2[] = "__name__";
-static const char __pyx_k_next_2[] = "next_";
-static const char __pyx_k_next_3[] = "next";
-static const char __pyx_k_object[] = "object";
-static const char __pyx_k_regexp[] = "regexp";
-static const char __pyx_k_string[] = "string";
-static const char __pyx_k_text_2[] = "text_";
-static const char __pyx_k_COMMENT[] = "COMMENT";
-static const char __pyx_k_NEWLINE[] = "NEWLINE";
-static const char __pyx_k_NUMBERS[] = "NUMBERS";
-static const char __pyx_k_closing[] = "closing";
-static const char __pyx_k_compile[] = "compile";
-static const char __pyx_k_curpath[] = "curpath";
-static const char __pyx_k_dirname[] = "dirname";
-static const char __pyx_k_fileobj[] = "fileobj";
-static const char __pyx_k_include[] = "include";
-static const char __pyx_k_prepare[] = "__prepare__";
-static const char __pyx_k_stop_at[] = "stop_at";
-static const char __pyx_k_FILENAME[] = "FILENAME";
-static const char __pyx_k_cur_char[] = "cur_char";
-static const char __pyx_k_encoding[] = "encoding";
-static const char __pyx_k_features[] = "";
-static const char __pyx_k_filename[] = "filename";
-static const char __pyx_k_location[] = "location_";
-static const char __pyx_k_maxsplit[] = "maxsplit";
-static const char __pyx_k_qualname[] = "__qualname__";
-static const char __pyx_k_metaclass[] = "__metaclass__";
-static const char __pyx_k_next_char[] = "next_char";
-static const char __pyx_k_scan_over[] = "scan_over_";
-static const char __pyx_k_0123456789[] = "0123456789";
-static const char __pyx_k_A_Za_z_0_9[] = "^[A-Za-z_0-9.\\-]+$";
-static const char __pyx_k_CHAR_DIGIT[] = "CHAR_DIGIT_";
-static const char __pyx_k_GLYPHCLASS[] = "GLYPHCLASS";
-static const char __pyx_k_Lexer_next[] = "Lexer.next";
-static const char __pyx_k_filename_2[] = "filename_";
-static const char __pyx_k_fname_type[] = "fname_type";
-static const char __pyx_k_glyphclass[] = "glyphclass";
-static const char __pyx_k_includeDir[] = "includeDir";
-static const char __pyx_k_line_start[] = "line_start_";
-static const char __pyx_k_location_2[] = "location";
-static const char __pyx_k_make_lexer[] = "make_lexer_";
-static const char __pyx_k_scan_until[] = "scan_until_";
-static const char __pyx_k_token_type[] = "token_type";
-static const char __pyx_k_CHAR_LETTER[] = "CHAR_LETTER_";
-static const char __pyx_k_CHAR_SYMBOL[] = "CHAR_SYMBOL_";
-static const char __pyx_k_HEXADECIMAL[] = "HEXADECIMAL";
-static const char __pyx_k_ImportError[] = "ImportError";
-static const char __pyx_k_MODE_NORMAL[] = "MODE_NORMAL_";
-static const char __pyx_k_featurefile[] = "featurefile";
-static const char __pyx_k_fname_token[] = "fname_token";
-static const char __pyx_k_text_length[] = "text_length_";
-static const char __pyx_k_CHAR_NEWLINE[] = "CHAR_NEWLINE_";
-static const char __pyx_k_Lexer___init[] = "Lexer.__init__";
-static const char __pyx_k_Lexer___iter[] = "Lexer.__iter__";
-static const char __pyx_k_Lexer___next[] = "Lexer.__next__";
-static const char __pyx_k_Lexer_next_2[] = "Lexer.next_";
-static const char __pyx_k_file_or_path[] = "file_or_path";
-static const char __pyx_k_staticmethod[] = "staticmethod";
-static const char __pyx_k_CHAR_HEXDIGIT[] = "CHAR_HEXDIGIT_";
-static const char __pyx_k_MODE_FILENAME[] = "MODE_FILENAME_";
-static const char __pyx_k_RE_GLYPHCLASS[] = "RE_GLYPHCLASS";
-static const char __pyx_k_StopIteration[] = "StopIteration";
-static const char __pyx_k_IncludingLexer[] = "IncludingLexer";
-static const char __pyx_k_Lexer_location[] = "Lexer.location_";
-static const char __pyx_k_fname_location[] = "fname_location";
-static const char __pyx_k_ANONYMOUS_BLOCK[] = "ANONYMOUS_BLOCK";
-static const char __pyx_k_CHAR_NAME_START[] = "CHAR_NAME_START_";
-static const char __pyx_k_CHAR_WHITESPACE[] = "CHAR_WHITESPACE_";
-static const char __pyx_k_FeatureLibError[] = "FeatureLibError";
-static const char __pyx_k_Lexer_scan_over[] = "Lexer.scan_over_";
-static const char __pyx_k_featurefilepath[] = "featurefilepath";
-static const char __pyx_k_Lexer_scan_until[] = "Lexer.scan_until_";
-static const char __pyx_k_FileNotFoundError[] = "FileNotFoundError";
-static const char __pyx_k_NonIncludingLexer[] = "NonIncludingLexer";
-static const char __pyx_k_Expected_file_name[] = "Expected file name";
-static const char __pyx_k_FeatureLibLocation[] = "FeatureLibLocation";
-static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
-static const char __pyx_k_IncludedFeaNotFound[] = "IncludedFeaNotFound";
-static const char __pyx_k_IncludingLexer_next[] = "IncludingLexer.next";
-static const char __pyx_k_scan_anonymous_block[] = "scan_anonymous_block";
-static const char __pyx_k_IncludingLexer___init[] = "IncludingLexer.__init__";
-static const char __pyx_k_IncludingLexer___iter[] = "IncludingLexer.__iter__";
-static const char __pyx_k_IncludingLexer___next[] = "IncludingLexer.__next__";
-static const char __pyx_k_0123456789ABCDEFabcdef[] = "0123456789ABCDEFabcdef";
-static const char __pyx_k_CHAR_NAME_CONTINUATION[] = "CHAR_NAME_CONTINUATION_";
-static const char __pyx_k_Unexpected_character_r[] = "Unexpected character: %r";
-static const char __pyx_k_fontTools_feaLib_error[] = "fontTools.feaLib.error";
-static const char __pyx_k_fontTools_feaLib_lexer[] = "fontTools.feaLib.lexer";
-static const char __pyx_k_Expected_after_file_name[] = "Expected ')' after file name";
-static const char __pyx_k_NonIncludingLexer___next[] = "NonIncludingLexer.__next__";
-static const char __pyx_k_Expected_before_file_name[] = "Expected '(' before file name";
-static const char __pyx_k_Expected_glyph_class_name[] = "Expected glyph class name";
-static const char __pyx_k_IncludingLexer_make_lexer[] = "IncludingLexer.make_lexer_";
-static const char __pyx_k_fontTools_feaLib_location[] = "fontTools.feaLib.location";
-static const char __pyx_k_Lexer_scan_anonymous_block[] = "Lexer.scan_anonymous_block";
-static const char __pyx_k_Too_many_recursive_includes[] = "Too many recursive includes";
-static const char __pyx_k_Expected_to_terminate_string[] = "Expected '\"' to terminate string";
-static const char __pyx_k_Lib_fontTools_feaLib_lexer_py[] = "Lib/fontTools/feaLib/lexer.py";
-static const char __pyx_k_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
-static const char __pyx_k_A_Lexer_that_follows_include_sta[] = "A Lexer that follows include statements.\n\n The OpenType feature file specification states that due to\n historical reasons, relative imports should be resolved in this\n order:\n\n 1. If the source font is UFO format, then relative to the UFO's\n font directory\n 2. relative to the top-level include file\n 3. relative to the parent include file\n\n We only support 1 (via includeDir) and 2.\n ";
-static const char __pyx_k_Expected_s_to_terminate_anonymou[] = "Expected '} %s;' to terminate anonymous block";
-static const char __pyx_k_Glyph_class_names_must_consist_o[] = "Glyph class names must consist of letters, digits, underscore, period or hyphen";
-static const char __pyx_k_Glyph_class_names_must_not_be_lo[] = "Glyph class names must not be longer than 63 characters";
-static const char __pyx_k_IncludingLexer_scan_anonymous_bl[] = "IncludingLexer.scan_anonymous_block";
-static const char __pyx_k_Lexer_that_does_not_follow_inclu[] = "Lexer that does not follow `include` statements, emits them as-is.";
-static PyObject *__pyx_kp_u_;
-static PyObject *__pyx_kp_u_0;
-static PyObject *__pyx_kp_u_0123456789;
-static PyObject *__pyx_kp_u_0123456789ABCDEFabcdef;
-static PyObject *__pyx_n_u_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef;
-static PyObject *__pyx_n_s_ANONYMOUS_BLOCK;
-static PyObject *__pyx_n_u_ANONYMOUS_BLOCK;
-static PyObject *__pyx_kp_s_A_Lexer_that_follows_include_sta;
-static PyObject *__pyx_kp_u_A_Za_z_0_9;
-static PyObject *__pyx_n_s_CHAR_DIGIT;
-static PyObject *__pyx_n_s_CHAR_HEXDIGIT;
-static PyObject *__pyx_n_s_CHAR_LETTER;
-static PyObject *__pyx_n_s_CHAR_NAME_CONTINUATION;
-static PyObject *__pyx_n_s_CHAR_NAME_START;
-static PyObject *__pyx_n_s_CHAR_NEWLINE;
-static PyObject *__pyx_n_s_CHAR_SYMBOL;
-static PyObject *__pyx_n_s_CHAR_WHITESPACE;
-static PyObject *__pyx_n_s_CID;
-static PyObject *__pyx_n_u_CID;
-static PyObject *__pyx_n_s_COMMENT;
-static PyObject *__pyx_n_u_COMMENT;
-static PyObject *__pyx_kp_u_Expected_after_file_name;
-static PyObject *__pyx_kp_u_Expected_before_file_name;
-static PyObject *__pyx_kp_u_Expected_file_name;
-static PyObject *__pyx_kp_u_Expected_glyph_class_name;
-static PyObject *__pyx_kp_u_Expected_s_to_terminate_anonymou;
-static PyObject *__pyx_kp_u_Expected_to_terminate_string;
-static PyObject *__pyx_n_s_FILENAME;
-static PyObject *__pyx_n_u_FILENAME;
-static PyObject *__pyx_n_s_FLOAT;
-static PyObject *__pyx_n_u_FLOAT;
-static PyObject *__pyx_n_s_FeatureLibError;
-static PyObject *__pyx_n_s_FeatureLibLocation;
-static PyObject *__pyx_n_s_FileNotFoundError;
-static PyObject *__pyx_n_s_GLYPHCLASS;
-static PyObject *__pyx_n_u_GLYPHCLASS;
-static PyObject *__pyx_kp_u_Glyph_class_names_must_consist_o;
-static PyObject *__pyx_kp_u_Glyph_class_names_must_not_be_lo;
-static PyObject *__pyx_n_s_HEXADECIMAL;
-static PyObject *__pyx_n_u_HEXADECIMAL;
-static PyObject *__pyx_n_s_ImportError;
-static PyObject *__pyx_n_s_IncludedFeaNotFound;
-static PyObject *__pyx_n_s_IncludingLexer;
-static PyObject *__pyx_n_s_IncludingLexer___init;
-static PyObject *__pyx_n_s_IncludingLexer___iter;
-static PyObject *__pyx_n_s_IncludingLexer___next;
-static PyObject *__pyx_n_s_IncludingLexer_make_lexer;
-static PyObject *__pyx_n_s_IncludingLexer_next;
-static PyObject *__pyx_n_s_IncludingLexer_scan_anonymous_bl;
-static PyObject *__pyx_n_s_Lexer;
-static PyObject *__pyx_n_s_Lexer___init;
-static PyObject *__pyx_n_s_Lexer___iter;
-static PyObject *__pyx_n_s_Lexer___next;
-static PyObject *__pyx_n_s_Lexer_location;
-static PyObject *__pyx_n_s_Lexer_next;
-static PyObject *__pyx_n_s_Lexer_next_2;
-static PyObject *__pyx_n_s_Lexer_scan_anonymous_block;
-static PyObject *__pyx_n_s_Lexer_scan_over;
-static PyObject *__pyx_n_s_Lexer_scan_until;
-static PyObject *__pyx_kp_s_Lexer_that_does_not_follow_inclu;
-static PyObject *__pyx_kp_s_Lib_fontTools_feaLib_lexer_py;
-static PyObject *__pyx_n_s_MODE_FILENAME;
-static PyObject *__pyx_n_s_MODE_NORMAL;
-static PyObject *__pyx_n_s_NAME;
-static PyObject *__pyx_n_u_NAME;
-static PyObject *__pyx_n_s_NEWLINE;
-static PyObject *__pyx_n_u_NEWLINE;
-static PyObject *__pyx_n_u_NORMAL;
-static PyObject *__pyx_n_s_NUMBER;
-static PyObject *__pyx_n_u_NUMBER;
-static PyObject *__pyx_n_s_NUMBERS;
-static PyObject *__pyx_n_s_NonIncludingLexer;
-static PyObject *__pyx_n_s_NonIncludingLexer___next;
-static PyObject *__pyx_n_s_OCTAL;
-static PyObject *__pyx_n_u_OCTAL;
-static PyObject *__pyx_n_s_RE_GLYPHCLASS;
-static PyObject *__pyx_n_s_STRING;
-static PyObject *__pyx_n_u_STRING;
-static PyObject *__pyx_n_s_SYMBOL;
-static PyObject *__pyx_n_u_SYMBOL;
-static PyObject *__pyx_n_s_StopIteration;
-static PyObject *__pyx_kp_u_Too_many_recursive_includes;
-static PyObject *__pyx_kp_u_Unexpected_character_r;
-static PyObject *__pyx_kp_u__10;
-static PyObject *__pyx_kp_u__11;
-static PyObject *__pyx_kp_u__12;
-static PyObject *__pyx_kp_u__14;
-static PyObject *__pyx_kp_u__15;
-static PyObject *__pyx_kp_u__16;
-static PyObject *__pyx_kp_u__17;
-static PyObject *__pyx_kp_u__18;
-static PyObject *__pyx_kp_u__2;
-static PyObject *__pyx_kp_u__3;
-static PyObject *__pyx_kp_u__4;
-static PyObject *__pyx_kp_u__5;
-static PyObject *__pyx_kp_u__6;
-static PyObject *__pyx_kp_u__7;
-static PyObject *__pyx_kp_u__8;
-static PyObject *__pyx_kp_u__9;
-static PyObject *__pyx_n_s_append;
-static PyObject *__pyx_n_s_cline_in_traceback;
-static PyObject *__pyx_n_s_close;
-static PyObject *__pyx_n_s_closing;
-static PyObject *__pyx_n_s_column;
-static PyObject *__pyx_n_s_compile;
-static PyObject *__pyx_n_s_cur_char;
-static PyObject *__pyx_n_s_curpath;
-static PyObject *__pyx_n_s_data;
-static PyObject *__pyx_n_s_dirname;
-static PyObject *__pyx_n_s_doc;
-static PyObject *__pyx_n_s_encoding;
-static PyObject *__pyx_n_s_err;
-static PyObject *__pyx_n_s_featurefile;
-static PyObject *__pyx_n_s_featurefilepath;
-static PyObject *__pyx_kp_u_features;
-static PyObject *__pyx_n_s_file_or_path;
-static PyObject *__pyx_n_s_filename;
-static PyObject *__pyx_n_s_filename_2;
-static PyObject *__pyx_n_s_fileobj;
-static PyObject *__pyx_n_s_fname_location;
-static PyObject *__pyx_n_s_fname_token;
-static PyObject *__pyx_n_s_fname_type;
-static PyObject *__pyx_n_s_fontTools_feaLib_error;
-static PyObject *__pyx_n_s_fontTools_feaLib_lexer;
-static PyObject *__pyx_n_s_fontTools_feaLib_location;
-static PyObject *__pyx_n_s_getcwd;
-static PyObject *__pyx_n_s_glyphclass;
-static PyObject *__pyx_n_s_import;
-static PyObject *__pyx_n_u_include;
-static PyObject *__pyx_n_s_includeDir;
-static PyObject *__pyx_n_s_init;
-static PyObject *__pyx_n_s_isabs;
-static PyObject *__pyx_n_s_iter;
-static PyObject *__pyx_n_s_join;
-static PyObject *__pyx_n_s_lexer;
-static PyObject *__pyx_n_s_lexers;
-static PyObject *__pyx_n_s_limit;
-static PyObject *__pyx_n_s_line;
-static PyObject *__pyx_n_s_line_start;
-static PyObject *__pyx_n_s_location;
-static PyObject *__pyx_n_s_location_2;
-static PyObject *__pyx_n_s_main;
-static PyObject *__pyx_n_s_make_lexer;
-static PyObject *__pyx_n_s_match;
-static PyObject *__pyx_n_s_maxsplit;
-static PyObject *__pyx_n_s_metaclass;
-static PyObject *__pyx_n_s_mode;
-static PyObject *__pyx_n_s_module;
-static PyObject *__pyx_n_u_name;
-static PyObject *__pyx_n_s_name_2;
-static PyObject *__pyx_n_s_next;
-static PyObject *__pyx_n_s_next_2;
-static PyObject *__pyx_n_s_next_3;
-static PyObject *__pyx_n_s_next_char;
-static PyObject *__pyx_n_s_object;
-static PyObject *__pyx_n_s_open;
-static PyObject *__pyx_n_s_os;
-static PyObject *__pyx_n_s_p;
-static PyObject *__pyx_n_s_path;
-static PyObject *__pyx_n_s_pop;
-static PyObject *__pyx_n_s_pos;
-static PyObject *__pyx_n_s_prepare;
-static PyObject *__pyx_n_s_qualname;
-static PyObject *__pyx_n_u_r;
-static PyObject *__pyx_n_s_re;
-static PyObject *__pyx_n_s_read;
-static PyObject *__pyx_n_u_read;
-static PyObject *__pyx_n_s_regexp;
-static PyObject *__pyx_kp_u_s;
-static PyObject *__pyx_kp_u_s_2;
-static PyObject *__pyx_n_s_scan_anonymous_block;
-static PyObject *__pyx_n_s_scan_over;
-static PyObject *__pyx_n_s_scan_until;
-static PyObject *__pyx_n_s_self;
-static PyObject *__pyx_n_s_split;
-static PyObject *__pyx_n_s_start;
-static PyObject *__pyx_n_s_staticmethod;
-static PyObject *__pyx_n_s_stop_at;
-static PyObject *__pyx_n_s_string;
-static PyObject *__pyx_n_s_strip;
-static PyObject *__pyx_n_s_sub;
-static PyObject *__pyx_n_s_tag;
-static PyObject *__pyx_n_s_test;
-static PyObject *__pyx_n_s_text;
-static PyObject *__pyx_n_s_text_2;
-static PyObject *__pyx_n_s_text_length;
-static PyObject *__pyx_n_s_token;
-static PyObject *__pyx_n_s_token_type;
-static PyObject *__pyx_kp_u_utf_8;
-static PyObject *__pyx_n_s_valid;
-static PyObject *__pyx_n_u_xX;
-static PyObject *__pyx_pf_9fontTools_6feaLib_5lexer_5Lexer___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_text, PyObject *__pyx_v_filename); /* proto */
-static PyObject *__pyx_pf_9fontTools_6feaLib_5lexer_5Lexer_2__iter__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_9fontTools_6feaLib_5lexer_5Lexer_4next(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_9fontTools_6feaLib_5lexer_5Lexer_6__next__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_9fontTools_6feaLib_5lexer_5Lexer_8location_(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_9fontTools_6feaLib_5lexer_5Lexer_10next_(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_9fontTools_6feaLib_5lexer_5Lexer_12scan_over_(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_valid); /* proto */
-static PyObject *__pyx_pf_9fontTools_6feaLib_5lexer_5Lexer_14scan_until_(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_stop_at); /* proto */
-static PyObject *__pyx_pf_9fontTools_6feaLib_5lexer_5Lexer_16scan_anonymous_block(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_tag); /* proto */
-static PyObject *__pyx_pf_9fontTools_6feaLib_5lexer_14IncludingLexer___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_featurefile, PyObject *__pyx_v_includeDir); /* proto */
-static PyObject *__pyx_pf_9fontTools_6feaLib_5lexer_14IncludingLexer_2__iter__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_9fontTools_6feaLib_5lexer_14IncludingLexer_4next(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_9fontTools_6feaLib_5lexer_14IncludingLexer_6__next__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_9fontTools_6feaLib_5lexer_14IncludingLexer_8make_lexer_(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_file_or_path); /* proto */
-static PyObject *__pyx_pf_9fontTools_6feaLib_5lexer_14IncludingLexer_10scan_anonymous_block(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_tag); /* proto */
-static PyObject *__pyx_pf_9fontTools_6feaLib_5lexer_17NonIncludingLexer___next__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
-static __Pyx_CachedCFunction __pyx_umethod_PyList_Type_pop = {0, &__pyx_n_s_pop, 0, 0, 0};
-static PyObject *__pyx_int_0;
-static PyObject *__pyx_int_1;
-static PyObject *__pyx_int_2;
-static PyObject *__pyx_int_8;
-static PyObject *__pyx_int_10;
-static PyObject *__pyx_int_16;
-static PyObject *__pyx_tuple__13;
-static PyObject *__pyx_tuple__19;
-static PyObject *__pyx_tuple__21;
-static PyObject *__pyx_tuple__23;
-static PyObject *__pyx_tuple__25;
-static PyObject *__pyx_tuple__27;
-static PyObject *__pyx_tuple__29;
-static PyObject *__pyx_tuple__31;
-static PyObject *__pyx_tuple__33;
-static PyObject *__pyx_tuple__35;
-static PyObject *__pyx_tuple__37;
-static PyObject *__pyx_tuple__38;
-static PyObject *__pyx_tuple__40;
-static PyObject *__pyx_tuple__42;
-static PyObject *__pyx_tuple__44;
-static PyObject *__pyx_tuple__46;
-static PyObject *__pyx_tuple__48;
-static PyObject *__pyx_tuple__50;
-static PyObject *__pyx_codeobj__20;
-static PyObject *__pyx_codeobj__22;
-static PyObject *__pyx_codeobj__24;
-static PyObject *__pyx_codeobj__26;
-static PyObject *__pyx_codeobj__28;
-static PyObject *__pyx_codeobj__30;
-static PyObject *__pyx_codeobj__32;
-static PyObject *__pyx_codeobj__34;
-static PyObject *__pyx_codeobj__36;
-static PyObject *__pyx_codeobj__39;
-static PyObject *__pyx_codeobj__41;
-static PyObject *__pyx_codeobj__43;
-static PyObject *__pyx_codeobj__45;
-static PyObject *__pyx_codeobj__47;
-static PyObject *__pyx_codeobj__49;
-static PyObject *__pyx_codeobj__51;
-/* Late includes */
-
-/* "fontTools/feaLib/lexer.py":43
- * MODE_FILENAME_ = "FILENAME"
- *
- * def __init__(self, text, filename): # <<<<<<<<<<<<<<
- * self.filename_ = filename
- * self.line_ = 1
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_9fontTools_6feaLib_5lexer_5Lexer_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_9fontTools_6feaLib_5lexer_5Lexer___init__[] = "Lexer.__init__(self, text, filename)";
-static PyMethodDef __pyx_mdef_9fontTools_6feaLib_5lexer_5Lexer_1__init__ = {"__init__", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_9fontTools_6feaLib_5lexer_5Lexer_1__init__, METH_VARARGS|METH_KEYWORDS, __pyx_doc_9fontTools_6feaLib_5lexer_5Lexer___init__};
-static PyObject *__pyx_pw_9fontTools_6feaLib_5lexer_5Lexer_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_self = 0;
- PyObject *__pyx_v_text = 0;
- PyObject *__pyx_v_filename = 0;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_text,&__pyx_n_s_filename,0};
- PyObject* values[3] = {0,0,0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_text)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 1); __PYX_ERR(0, 43, __pyx_L3_error)
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_filename)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 2); __PYX_ERR(0, 43, __pyx_L3_error)
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 43, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- }
- __pyx_v_self = values[0];
- __pyx_v_text = values[1];
- __pyx_v_filename = values[2];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 43, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("fontTools.feaLib.lexer.Lexer.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_9fontTools_6feaLib_5lexer_5Lexer___init__(__pyx_self, __pyx_v_self, __pyx_v_text, __pyx_v_filename);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_9fontTools_6feaLib_5lexer_5Lexer___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_text, PyObject *__pyx_v_filename) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- Py_ssize_t __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("__init__", 0);
-
- /* "fontTools/feaLib/lexer.py":44
- *
- * def __init__(self, text, filename):
- * self.filename_ = filename # <<<<<<<<<<<<<<
- * self.line_ = 1
- * self.pos_ = 0
- */
- if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_filename_2, __pyx_v_filename) < 0) __PYX_ERR(0, 44, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":45
- * def __init__(self, text, filename):
- * self.filename_ = filename
- * self.line_ = 1 # <<<<<<<<<<<<<<
- * self.pos_ = 0
- * self.line_start_ = 0
- */
- if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_line, __pyx_int_1) < 0) __PYX_ERR(0, 45, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":46
- * self.filename_ = filename
- * self.line_ = 1
- * self.pos_ = 0 # <<<<<<<<<<<<<<
- * self.line_start_ = 0
- * self.text_ = text
- */
- if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_pos, __pyx_int_0) < 0) __PYX_ERR(0, 46, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":47
- * self.line_ = 1
- * self.pos_ = 0
- * self.line_start_ = 0 # <<<<<<<<<<<<<<
- * self.text_ = text
- * self.text_length_ = len(text)
- */
- if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_line_start, __pyx_int_0) < 0) __PYX_ERR(0, 47, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":48
- * self.pos_ = 0
- * self.line_start_ = 0
- * self.text_ = text # <<<<<<<<<<<<<<
- * self.text_length_ = len(text)
- * self.mode_ = Lexer.MODE_NORMAL_
- */
- if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_text_2, __pyx_v_text) < 0) __PYX_ERR(0, 48, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":49
- * self.line_start_ = 0
- * self.text_ = text
- * self.text_length_ = len(text) # <<<<<<<<<<<<<<
- * self.mode_ = Lexer.MODE_NORMAL_
- *
- */
- __pyx_t_1 = PyObject_Length(__pyx_v_text); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 49, __pyx_L1_error)
- __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 49, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_text_length, __pyx_t_2) < 0) __PYX_ERR(0, 49, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "fontTools/feaLib/lexer.py":50
- * self.text_ = text
- * self.text_length_ = len(text)
- * self.mode_ = Lexer.MODE_NORMAL_ # <<<<<<<<<<<<<<
- *
- * def __iter__(self):
- */
- __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Lexer); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 50, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_MODE_NORMAL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 50, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_mode, __pyx_t_3) < 0) __PYX_ERR(0, 50, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "fontTools/feaLib/lexer.py":43
- * MODE_FILENAME_ = "FILENAME"
- *
- * def __init__(self, text, filename): # <<<<<<<<<<<<<<
- * self.filename_ = filename
- * self.line_ = 1
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("fontTools.feaLib.lexer.Lexer.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "fontTools/feaLib/lexer.py":52
- * self.mode_ = Lexer.MODE_NORMAL_
- *
- * def __iter__(self): # <<<<<<<<<<<<<<
- * return self
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_9fontTools_6feaLib_5lexer_5Lexer_3__iter__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
-static char __pyx_doc_9fontTools_6feaLib_5lexer_5Lexer_2__iter__[] = "Lexer.__iter__(self)";
-static PyMethodDef __pyx_mdef_9fontTools_6feaLib_5lexer_5Lexer_3__iter__ = {"__iter__", (PyCFunction)__pyx_pw_9fontTools_6feaLib_5lexer_5Lexer_3__iter__, METH_O, __pyx_doc_9fontTools_6feaLib_5lexer_5Lexer_2__iter__};
-static PyObject *__pyx_pw_9fontTools_6feaLib_5lexer_5Lexer_3__iter__(PyObject *__pyx_self, PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
- __pyx_r = __pyx_pf_9fontTools_6feaLib_5lexer_5Lexer_2__iter__(__pyx_self, ((PyObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_9fontTools_6feaLib_5lexer_5Lexer_2__iter__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__iter__", 0);
-
- /* "fontTools/feaLib/lexer.py":53
- *
- * def __iter__(self):
- * return self # <<<<<<<<<<<<<<
- *
- * def next(self): # Python 2
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_self);
- __pyx_r = __pyx_v_self;
- goto __pyx_L0;
-
- /* "fontTools/feaLib/lexer.py":52
- * self.mode_ = Lexer.MODE_NORMAL_
- *
- * def __iter__(self): # <<<<<<<<<<<<<<
- * return self
- *
- */
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "fontTools/feaLib/lexer.py":55
- * return self
- *
- * def next(self): # Python 2 # <<<<<<<<<<<<<<
- * return self.__next__()
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_9fontTools_6feaLib_5lexer_5Lexer_5next(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
-static char __pyx_doc_9fontTools_6feaLib_5lexer_5Lexer_4next[] = "Lexer.next(self)";
-static PyMethodDef __pyx_mdef_9fontTools_6feaLib_5lexer_5Lexer_5next = {"next", (PyCFunction)__pyx_pw_9fontTools_6feaLib_5lexer_5Lexer_5next, METH_O, __pyx_doc_9fontTools_6feaLib_5lexer_5Lexer_4next};
-static PyObject *__pyx_pw_9fontTools_6feaLib_5lexer_5Lexer_5next(PyObject *__pyx_self, PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("next (wrapper)", 0);
- __pyx_r = __pyx_pf_9fontTools_6feaLib_5lexer_5Lexer_4next(__pyx_self, ((PyObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_9fontTools_6feaLib_5lexer_5Lexer_4next(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("next", 0);
-
- /* "fontTools/feaLib/lexer.py":56
- *
- * def next(self): # Python 2
- * return self.__next__() # <<<<<<<<<<<<<<
- *
- * def __next__(self): # Python 3
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_next); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 56, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 56, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "fontTools/feaLib/lexer.py":55
- * return self
- *
- * def next(self): # Python 2 # <<<<<<<<<<<<<<
- * return self.__next__()
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("fontTools.feaLib.lexer.Lexer.next", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "fontTools/feaLib/lexer.py":58
- * return self.__next__()
- *
- * def __next__(self): # Python 3 # <<<<<<<<<<<<<<
- * while True:
- * token_type, token, location = self.next_()
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_9fontTools_6feaLib_5lexer_5Lexer_7__next__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
-static char __pyx_doc_9fontTools_6feaLib_5lexer_5Lexer_6__next__[] = "Lexer.__next__(self)";
-static PyMethodDef __pyx_mdef_9fontTools_6feaLib_5lexer_5Lexer_7__next__ = {"__next__", (PyCFunction)__pyx_pw_9fontTools_6feaLib_5lexer_5Lexer_7__next__, METH_O, __pyx_doc_9fontTools_6feaLib_5lexer_5Lexer_6__next__};
-static PyObject *__pyx_pw_9fontTools_6feaLib_5lexer_5Lexer_7__next__(PyObject *__pyx_self, PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__next__ (wrapper)", 0);
- __pyx_r = __pyx_pf_9fontTools_6feaLib_5lexer_5Lexer_6__next__(__pyx_self, ((PyObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_9fontTools_6feaLib_5lexer_5Lexer_6__next__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
- PyObject *__pyx_v_token_type = NULL;
- PyObject *__pyx_v_token = NULL;
- PyObject *__pyx_v_location = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- PyObject *(*__pyx_t_6)(PyObject *);
- int __pyx_t_7;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("__next__", 0);
-
- /* "fontTools/feaLib/lexer.py":59
- *
- * def __next__(self): # Python 3
- * while True: # <<<<<<<<<<<<<<
- * token_type, token, location = self.next_()
- * if token_type != Lexer.NEWLINE:
- */
- while (1) {
-
- /* "fontTools/feaLib/lexer.py":60
- * def __next__(self): # Python 3
- * while True:
- * token_type, token, location = self.next_() # <<<<<<<<<<<<<<
- * if token_type != Lexer.NEWLINE:
- * return (token_type, token, location)
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_next_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 60, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 60, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
- PyObject* sequence = __pyx_t_1;
- Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
- if (unlikely(size != 3)) {
- if (size > 3) __Pyx_RaiseTooManyValuesError(3);
- else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
- __PYX_ERR(0, 60, __pyx_L1_error)
- }
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- if (likely(PyTuple_CheckExact(sequence))) {
- __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0);
- __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1);
- __pyx_t_4 = PyTuple_GET_ITEM(sequence, 2);
- } else {
- __pyx_t_2 = PyList_GET_ITEM(sequence, 0);
- __pyx_t_3 = PyList_GET_ITEM(sequence, 1);
- __pyx_t_4 = PyList_GET_ITEM(sequence, 2);
- }
- __Pyx_INCREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- #else
- __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 60, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 60, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 60, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- #endif
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- } else {
- Py_ssize_t index = -1;
- __pyx_t_5 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 60, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_6 = Py_TYPE(__pyx_t_5)->tp_iternext;
- index = 0; __pyx_t_2 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_2)) goto __pyx_L5_unpacking_failed;
- __Pyx_GOTREF(__pyx_t_2);
- index = 1; __pyx_t_3 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L5_unpacking_failed;
- __Pyx_GOTREF(__pyx_t_3);
- index = 2; __pyx_t_4 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L5_unpacking_failed;
- __Pyx_GOTREF(__pyx_t_4);
- if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 3) < 0) __PYX_ERR(0, 60, __pyx_L1_error)
- __pyx_t_6 = NULL;
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- goto __pyx_L6_unpacking_done;
- __pyx_L5_unpacking_failed:;
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __pyx_t_6 = NULL;
- if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
- __PYX_ERR(0, 60, __pyx_L1_error)
- __pyx_L6_unpacking_done:;
- }
- __Pyx_XDECREF_SET(__pyx_v_token_type, __pyx_t_2);
- __pyx_t_2 = 0;
- __Pyx_XDECREF_SET(__pyx_v_token, __pyx_t_3);
- __pyx_t_3 = 0;
- __Pyx_XDECREF_SET(__pyx_v_location, __pyx_t_4);
- __pyx_t_4 = 0;
-
- /* "fontTools/feaLib/lexer.py":61
- * while True:
- * token_type, token, location = self.next_()
- * if token_type != Lexer.NEWLINE: # <<<<<<<<<<<<<<
- * return (token_type, token, location)
- *
- */
- __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Lexer); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 61, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_NEWLINE); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 61, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = PyObject_RichCompare(__pyx_v_token_type, __pyx_t_4, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 61, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 61, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- if (__pyx_t_7) {
-
- /* "fontTools/feaLib/lexer.py":62
- * token_type, token, location = self.next_()
- * if token_type != Lexer.NEWLINE:
- * return (token_type, token, location) # <<<<<<<<<<<<<<
- *
- * def location_(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 62, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_v_token_type);
- __Pyx_GIVEREF(__pyx_v_token_type);
- PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_token_type);
- __Pyx_INCREF(__pyx_v_token);
- __Pyx_GIVEREF(__pyx_v_token);
- PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_token);
- __Pyx_INCREF(__pyx_v_location);
- __Pyx_GIVEREF(__pyx_v_location);
- PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_location);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "fontTools/feaLib/lexer.py":61
- * while True:
- * token_type, token, location = self.next_()
- * if token_type != Lexer.NEWLINE: # <<<<<<<<<<<<<<
- * return (token_type, token, location)
- *
- */
- }
- }
-
- /* "fontTools/feaLib/lexer.py":58
- * return self.__next__()
- *
- * def __next__(self): # Python 3 # <<<<<<<<<<<<<<
- * while True:
- * token_type, token, location = self.next_()
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("fontTools.feaLib.lexer.Lexer.__next__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_token_type);
- __Pyx_XDECREF(__pyx_v_token);
- __Pyx_XDECREF(__pyx_v_location);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "fontTools/feaLib/lexer.py":64
- * return (token_type, token, location)
- *
- * def location_(self): # <<<<<<<<<<<<<<
- * column = self.pos_ - self.line_start_ + 1
- * return FeatureLibLocation(self.filename_ or "", self.line_, column)
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_9fontTools_6feaLib_5lexer_5Lexer_9location_(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
-static char __pyx_doc_9fontTools_6feaLib_5lexer_5Lexer_8location_[] = "Lexer.location_(self)";
-static PyMethodDef __pyx_mdef_9fontTools_6feaLib_5lexer_5Lexer_9location_ = {"location_", (PyCFunction)__pyx_pw_9fontTools_6feaLib_5lexer_5Lexer_9location_, METH_O, __pyx_doc_9fontTools_6feaLib_5lexer_5Lexer_8location_};
-static PyObject *__pyx_pw_9fontTools_6feaLib_5lexer_5Lexer_9location_(PyObject *__pyx_self, PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("location_ (wrapper)", 0);
- __pyx_r = __pyx_pf_9fontTools_6feaLib_5lexer_5Lexer_8location_(__pyx_self, ((PyObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_9fontTools_6feaLib_5lexer_5Lexer_8location_(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
- PyObject *__pyx_v_column = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_t_5;
- PyObject *__pyx_t_6 = NULL;
- int __pyx_t_7;
- PyObject *__pyx_t_8 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("location_", 0);
-
- /* "fontTools/feaLib/lexer.py":65
- *
- * def location_(self):
- * column = self.pos_ - self.line_start_ + 1 # <<<<<<<<<<<<<<
- * return FeatureLibLocation(self.filename_ or "", self.line_, column)
- *
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_pos); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 65, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_line_start); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 65, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = PyNumber_Subtract(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 65, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyInt_AddObjC(__pyx_t_3, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 65, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_v_column = __pyx_t_2;
- __pyx_t_2 = 0;
-
- /* "fontTools/feaLib/lexer.py":66
- * def location_(self):
- * column = self.pos_ - self.line_start_ + 1
- * return FeatureLibLocation(self.filename_ or "", self.line_, column) # <<<<<<<<<<<<<<
- *
- * def next_(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_FeatureLibLocation); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 66, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_filename_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 66, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 66, __pyx_L1_error)
- if (!__pyx_t_5) {
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else {
- __Pyx_INCREF(__pyx_t_4);
- __pyx_t_1 = __pyx_t_4;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- goto __pyx_L3_bool_binop_done;
- }
- __Pyx_INCREF(__pyx_kp_u_features);
- __pyx_t_1 = __pyx_kp_u_features;
- __pyx_L3_bool_binop_done:;
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_line); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 66, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_6 = NULL;
- __pyx_t_7 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_6)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_6);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- __pyx_t_7 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_t_1, __pyx_t_4, __pyx_v_column};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 66, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_t_1, __pyx_t_4, __pyx_v_column};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 3+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 66, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- } else
- #endif
- {
- __pyx_t_8 = PyTuple_New(3+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 66, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- if (__pyx_t_6) {
- __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL;
- }
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_4);
- PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_4);
- __Pyx_INCREF(__pyx_v_column);
- __Pyx_GIVEREF(__pyx_v_column);
- PyTuple_SET_ITEM(__pyx_t_8, 2+__pyx_t_7, __pyx_v_column);
- __pyx_t_1 = 0;
- __pyx_t_4 = 0;
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 66, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
- /* "fontTools/feaLib/lexer.py":64
- * return (token_type, token, location)
- *
- * def location_(self): # <<<<<<<<<<<<<<
- * column = self.pos_ - self.line_start_ + 1
- * return FeatureLibLocation(self.filename_ or "", self.line_, column)
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_8);
- __Pyx_AddTraceback("fontTools.feaLib.lexer.Lexer.location_", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_column);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "fontTools/feaLib/lexer.py":68
- * return FeatureLibLocation(self.filename_ or "", self.line_, column)
- *
- * def next_(self): # <<<<<<<<<<<<<<
- * self.scan_over_(Lexer.CHAR_WHITESPACE_)
- * location = self.location_()
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_9fontTools_6feaLib_5lexer_5Lexer_11next_(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
-static char __pyx_doc_9fontTools_6feaLib_5lexer_5Lexer_10next_[] = "Lexer.next_(self)";
-static PyMethodDef __pyx_mdef_9fontTools_6feaLib_5lexer_5Lexer_11next_ = {"next_", (PyCFunction)__pyx_pw_9fontTools_6feaLib_5lexer_5Lexer_11next_, METH_O, __pyx_doc_9fontTools_6feaLib_5lexer_5Lexer_10next_};
-static PyObject *__pyx_pw_9fontTools_6feaLib_5lexer_5Lexer_11next_(PyObject *__pyx_self, PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("next_ (wrapper)", 0);
- __pyx_r = __pyx_pf_9fontTools_6feaLib_5lexer_5Lexer_10next_(__pyx_self, ((PyObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_9fontTools_6feaLib_5lexer_5Lexer_10next_(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
- PyObject *__pyx_v_location = NULL;
- PyObject *__pyx_v_start = NULL;
- PyObject *__pyx_v_text = NULL;
- Py_ssize_t __pyx_v_limit;
- PyObject *__pyx_v_cur_char = NULL;
- PyObject *__pyx_v_next_char = NULL;
- PyObject *__pyx_v_glyphclass = NULL;
- PyObject *__pyx_v_token = NULL;
- PyObject *__pyx_v_string = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- Py_ssize_t __pyx_t_5;
- int __pyx_t_6;
- int __pyx_t_7;
- int __pyx_t_8;
- int __pyx_t_9;
- PyObject *__pyx_t_10 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("next_", 0);
-
- /* "fontTools/feaLib/lexer.py":69
- *
- * def next_(self):
- * self.scan_over_(Lexer.CHAR_WHITESPACE_) # <<<<<<<<<<<<<<
- * location = self.location_()
- * start = self.pos_
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_scan_over); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 69, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_Lexer); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 69, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_CHAR_WHITESPACE); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 69, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 69, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "fontTools/feaLib/lexer.py":70
- * def next_(self):
- * self.scan_over_(Lexer.CHAR_WHITESPACE_)
- * location = self.location_() # <<<<<<<<<<<<<<
- * start = self.pos_
- * text = self.text_
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_location); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 70, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 70, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_v_location = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "fontTools/feaLib/lexer.py":71
- * self.scan_over_(Lexer.CHAR_WHITESPACE_)
- * location = self.location_()
- * start = self.pos_ # <<<<<<<<<<<<<<
- * text = self.text_
- * limit = len(text)
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_pos); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 71, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_start = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "fontTools/feaLib/lexer.py":72
- * location = self.location_()
- * start = self.pos_
- * text = self.text_ # <<<<<<<<<<<<<<
- * limit = len(text)
- * if start >= limit:
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_text_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 72, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_text = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "fontTools/feaLib/lexer.py":73
- * start = self.pos_
- * text = self.text_
- * limit = len(text) # <<<<<<<<<<<<<<
- * if start >= limit:
- * raise StopIteration()
- */
- __pyx_t_5 = PyObject_Length(__pyx_v_text); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 73, __pyx_L1_error)
- __pyx_v_limit = __pyx_t_5;
-
- /* "fontTools/feaLib/lexer.py":74
- * text = self.text_
- * limit = len(text)
- * if start >= limit: # <<<<<<<<<<<<<<
- * raise StopIteration()
- * cur_char = text[start]
- */
- __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_limit); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 74, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = PyObject_RichCompare(__pyx_v_start, __pyx_t_1, Py_GE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 74, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 74, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- if (unlikely(__pyx_t_6)) {
-
- /* "fontTools/feaLib/lexer.py":75
- * limit = len(text)
- * if start >= limit:
- * raise StopIteration() # <<<<<<<<<<<<<<
- * cur_char = text[start]
- * next_char = text[start + 1] if start + 1 < limit else None
- */
- __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_builtin_StopIteration); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 75, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_Raise(__pyx_t_2, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __PYX_ERR(0, 75, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":74
- * text = self.text_
- * limit = len(text)
- * if start >= limit: # <<<<<<<<<<<<<<
- * raise StopIteration()
- * cur_char = text[start]
- */
- }
-
- /* "fontTools/feaLib/lexer.py":76
- * if start >= limit:
- * raise StopIteration()
- * cur_char = text[start] # <<<<<<<<<<<<<<
- * next_char = text[start + 1] if start + 1 < limit else None
- *
- */
- __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_v_text, __pyx_v_start); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 76, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_v_cur_char = __pyx_t_2;
- __pyx_t_2 = 0;
-
- /* "fontTools/feaLib/lexer.py":77
- * raise StopIteration()
- * cur_char = text[start]
- * next_char = text[start + 1] if start + 1 < limit else None # <<<<<<<<<<<<<<
- *
- * if cur_char == "\n":
- */
- __pyx_t_1 = __Pyx_PyInt_AddObjC(__pyx_v_start, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 77, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_limit); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 77, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_t_4, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 77, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 77, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- if (__pyx_t_6) {
- __pyx_t_3 = __Pyx_PyInt_AddObjC(__pyx_v_start, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 77, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_v_text, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 77, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_2 = __pyx_t_4;
- __pyx_t_4 = 0;
- } else {
- __Pyx_INCREF(Py_None);
- __pyx_t_2 = Py_None;
- }
- __pyx_v_next_char = __pyx_t_2;
- __pyx_t_2 = 0;
-
- /* "fontTools/feaLib/lexer.py":79
- * next_char = text[start + 1] if start + 1 < limit else None
- *
- * if cur_char == "\n": # <<<<<<<<<<<<<<
- * self.pos_ += 1
- * self.line_ += 1
- */
- __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_v_cur_char, __pyx_kp_u_, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 79, __pyx_L1_error)
- if (__pyx_t_6) {
-
- /* "fontTools/feaLib/lexer.py":80
- *
- * if cur_char == "\n":
- * self.pos_ += 1 # <<<<<<<<<<<<<<
- * self.line_ += 1
- * self.line_start_ = self.pos_
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_pos); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 80, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_4 = __Pyx_PyInt_AddObjC(__pyx_t_2, __pyx_int_1, 1, 1, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 80, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_pos, __pyx_t_4) < 0) __PYX_ERR(0, 80, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-
- /* "fontTools/feaLib/lexer.py":81
- * if cur_char == "\n":
- * self.pos_ += 1
- * self.line_ += 1 # <<<<<<<<<<<<<<
- * self.line_start_ = self.pos_
- * return (Lexer.NEWLINE, None, location)
- */
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_line); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 81, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_2 = __Pyx_PyInt_AddObjC(__pyx_t_4, __pyx_int_1, 1, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 81, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_line, __pyx_t_2) < 0) __PYX_ERR(0, 81, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "fontTools/feaLib/lexer.py":82
- * self.pos_ += 1
- * self.line_ += 1
- * self.line_start_ = self.pos_ # <<<<<<<<<<<<<<
- * return (Lexer.NEWLINE, None, location)
- * if cur_char == "\r":
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_pos); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 82, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_line_start, __pyx_t_2) < 0) __PYX_ERR(0, 82, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "fontTools/feaLib/lexer.py":83
- * self.line_ += 1
- * self.line_start_ = self.pos_
- * return (Lexer.NEWLINE, None, location) # <<<<<<<<<<<<<<
- * if cur_char == "\r":
- * self.pos_ += 2 if next_char == "\n" else 1
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Lexer); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 83, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_NEWLINE); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 83, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 83, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_4);
- PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4);
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- PyTuple_SET_ITEM(__pyx_t_2, 1, Py_None);
- __Pyx_INCREF(__pyx_v_location);
- __Pyx_GIVEREF(__pyx_v_location);
- PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_location);
- __pyx_t_4 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
- /* "fontTools/feaLib/lexer.py":79
- * next_char = text[start + 1] if start + 1 < limit else None
- *
- * if cur_char == "\n": # <<<<<<<<<<<<<<
- * self.pos_ += 1
- * self.line_ += 1
- */
- }
-
- /* "fontTools/feaLib/lexer.py":84
- * self.line_start_ = self.pos_
- * return (Lexer.NEWLINE, None, location)
- * if cur_char == "\r": # <<<<<<<<<<<<<<
- * self.pos_ += 2 if next_char == "\n" else 1
- * self.line_ += 1
- */
- __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_v_cur_char, __pyx_kp_u__2, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 84, __pyx_L1_error)
- if (__pyx_t_6) {
-
- /* "fontTools/feaLib/lexer.py":85
- * return (Lexer.NEWLINE, None, location)
- * if cur_char == "\r":
- * self.pos_ += 2 if next_char == "\n" else 1 # <<<<<<<<<<<<<<
- * self.line_ += 1
- * self.line_start_ = self.pos_
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_pos); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 85, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_v_next_char, __pyx_kp_u_, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 85, __pyx_L1_error)
- if (__pyx_t_6) {
- __Pyx_INCREF(__pyx_int_2);
- __pyx_t_4 = __pyx_int_2;
- } else {
- __Pyx_INCREF(__pyx_int_1);
- __pyx_t_4 = __pyx_int_1;
- }
- __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 85, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_pos, __pyx_t_3) < 0) __PYX_ERR(0, 85, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "fontTools/feaLib/lexer.py":86
- * if cur_char == "\r":
- * self.pos_ += 2 if next_char == "\n" else 1
- * self.line_ += 1 # <<<<<<<<<<<<<<
- * self.line_start_ = self.pos_
- * return (Lexer.NEWLINE, None, location)
- */
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_line); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 86, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = __Pyx_PyInt_AddObjC(__pyx_t_3, __pyx_int_1, 1, 1, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 86, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_line, __pyx_t_4) < 0) __PYX_ERR(0, 86, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-
- /* "fontTools/feaLib/lexer.py":87
- * self.pos_ += 2 if next_char == "\n" else 1
- * self.line_ += 1
- * self.line_start_ = self.pos_ # <<<<<<<<<<<<<<
- * return (Lexer.NEWLINE, None, location)
- * if cur_char == "#":
- */
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_pos); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 87, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_line_start, __pyx_t_4) < 0) __PYX_ERR(0, 87, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-
- /* "fontTools/feaLib/lexer.py":88
- * self.line_ += 1
- * self.line_start_ = self.pos_
- * return (Lexer.NEWLINE, None, location) # <<<<<<<<<<<<<<
- * if cur_char == "#":
- * self.scan_until_(Lexer.CHAR_NEWLINE_)
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_Lexer); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 88, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_NEWLINE); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 88, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 88, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- PyTuple_SET_ITEM(__pyx_t_4, 1, Py_None);
- __Pyx_INCREF(__pyx_v_location);
- __Pyx_GIVEREF(__pyx_v_location);
- PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_location);
- __pyx_t_3 = 0;
- __pyx_r = __pyx_t_4;
- __pyx_t_4 = 0;
- goto __pyx_L0;
-
- /* "fontTools/feaLib/lexer.py":84
- * self.line_start_ = self.pos_
- * return (Lexer.NEWLINE, None, location)
- * if cur_char == "\r": # <<<<<<<<<<<<<<
- * self.pos_ += 2 if next_char == "\n" else 1
- * self.line_ += 1
- */
- }
-
- /* "fontTools/feaLib/lexer.py":89
- * self.line_start_ = self.pos_
- * return (Lexer.NEWLINE, None, location)
- * if cur_char == "#": # <<<<<<<<<<<<<<
- * self.scan_until_(Lexer.CHAR_NEWLINE_)
- * return (Lexer.COMMENT, text[start : self.pos_], location)
- */
- __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_v_cur_char, __pyx_kp_u__3, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 89, __pyx_L1_error)
- if (__pyx_t_6) {
-
- /* "fontTools/feaLib/lexer.py":90
- * return (Lexer.NEWLINE, None, location)
- * if cur_char == "#":
- * self.scan_until_(Lexer.CHAR_NEWLINE_) # <<<<<<<<<<<<<<
- * return (Lexer.COMMENT, text[start : self.pos_], location)
- *
- */
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_scan_until); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 90, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Lexer); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 90, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_CHAR_NEWLINE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 90, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_2)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_2);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- __pyx_t_4 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 90, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-
- /* "fontTools/feaLib/lexer.py":91
- * if cur_char == "#":
- * self.scan_until_(Lexer.CHAR_NEWLINE_)
- * return (Lexer.COMMENT, text[start : self.pos_], location) # <<<<<<<<<<<<<<
- *
- * if self.mode_ is Lexer.MODE_FILENAME_:
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_Lexer); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 91, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_COMMENT); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 91, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_pos); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 91, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_v_text, 0, 0, &__pyx_v_start, &__pyx_t_4, NULL, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 91, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 91, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
- __Pyx_INCREF(__pyx_v_location);
- __Pyx_GIVEREF(__pyx_v_location);
- PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_location);
- __pyx_t_3 = 0;
- __pyx_t_1 = 0;
- __pyx_r = __pyx_t_4;
- __pyx_t_4 = 0;
- goto __pyx_L0;
-
- /* "fontTools/feaLib/lexer.py":89
- * self.line_start_ = self.pos_
- * return (Lexer.NEWLINE, None, location)
- * if cur_char == "#": # <<<<<<<<<<<<<<
- * self.scan_until_(Lexer.CHAR_NEWLINE_)
- * return (Lexer.COMMENT, text[start : self.pos_], location)
- */
- }
-
- /* "fontTools/feaLib/lexer.py":93
- * return (Lexer.COMMENT, text[start : self.pos_], location)
- *
- * if self.mode_ is Lexer.MODE_FILENAME_: # <<<<<<<<<<<<<<
- * if cur_char != "(":
- * raise FeatureLibError("Expected '(' before file name", location)
- */
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_mode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 93, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Lexer); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 93, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_MODE_FILENAME); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 93, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_6 = (__pyx_t_4 == __pyx_t_3);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_7 = (__pyx_t_6 != 0);
- if (__pyx_t_7) {
-
- /* "fontTools/feaLib/lexer.py":94
- *
- * if self.mode_ is Lexer.MODE_FILENAME_:
- * if cur_char != "(": # <<<<<<<<<<<<<<
- * raise FeatureLibError("Expected '(' before file name", location)
- * self.scan_until_(")")
- */
- __pyx_t_7 = (__Pyx_PyUnicode_Equals(__pyx_v_cur_char, __pyx_kp_u__4, Py_NE)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 94, __pyx_L1_error)
- if (unlikely(__pyx_t_7)) {
-
- /* "fontTools/feaLib/lexer.py":95
- * if self.mode_ is Lexer.MODE_FILENAME_:
- * if cur_char != "(":
- * raise FeatureLibError("Expected '(' before file name", location) # <<<<<<<<<<<<<<
- * self.scan_until_(")")
- * cur_char = text[self.pos_] if self.pos_ < limit else None
- */
- __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_FeatureLibError); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 95, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_1 = NULL;
- __pyx_t_8 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_1)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- __pyx_t_8 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_4)) {
- PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_kp_u_Expected_before_file_name, __pyx_v_location};
- __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 95, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
- PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_kp_u_Expected_before_file_name, __pyx_v_location};
- __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 95, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- } else
- #endif
- {
- __pyx_t_2 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 95, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (__pyx_t_1) {
- __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __pyx_t_1 = NULL;
- }
- __Pyx_INCREF(__pyx_kp_u_Expected_before_file_name);
- __Pyx_GIVEREF(__pyx_kp_u_Expected_before_file_name);
- PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_8, __pyx_kp_u_Expected_before_file_name);
- __Pyx_INCREF(__pyx_v_location);
- __Pyx_GIVEREF(__pyx_v_location);
- PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_8, __pyx_v_location);
- __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 95, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- }
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_Raise(__pyx_t_3, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __PYX_ERR(0, 95, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":94
- *
- * if self.mode_ is Lexer.MODE_FILENAME_:
- * if cur_char != "(": # <<<<<<<<<<<<<<
- * raise FeatureLibError("Expected '(' before file name", location)
- * self.scan_until_(")")
- */
- }
-
- /* "fontTools/feaLib/lexer.py":96
- * if cur_char != "(":
- * raise FeatureLibError("Expected '(' before file name", location)
- * self.scan_until_(")") # <<<<<<<<<<<<<<
- * cur_char = text[self.pos_] if self.pos_ < limit else None
- * if cur_char != ")":
- */
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_scan_until); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 96, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_2 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_2)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_2);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- }
- }
- __pyx_t_3 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_2, __pyx_kp_u__5) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_kp_u__5);
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 96, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "fontTools/feaLib/lexer.py":97
- * raise FeatureLibError("Expected '(' before file name", location)
- * self.scan_until_(")")
- * cur_char = text[self.pos_] if self.pos_ < limit else None # <<<<<<<<<<<<<<
- * if cur_char != ")":
- * raise FeatureLibError("Expected ')' after file name", location)
- */
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_pos); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 97, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_limit); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 97, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_1 = PyObject_RichCompare(__pyx_t_4, __pyx_t_2, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 97, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 97, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- if (__pyx_t_7) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_pos); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 97, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_v_text, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 97, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_3 = __pyx_t_2;
- __pyx_t_2 = 0;
- } else {
- __Pyx_INCREF(Py_None);
- __pyx_t_3 = Py_None;
- }
- __Pyx_DECREF_SET(__pyx_v_cur_char, __pyx_t_3);
- __pyx_t_3 = 0;
-
- /* "fontTools/feaLib/lexer.py":98
- * self.scan_until_(")")
- * cur_char = text[self.pos_] if self.pos_ < limit else None
- * if cur_char != ")": # <<<<<<<<<<<<<<
- * raise FeatureLibError("Expected ')' after file name", location)
- * self.pos_ += 1
- */
- __pyx_t_7 = (__Pyx_PyUnicode_Equals(__pyx_v_cur_char, __pyx_kp_u__5, Py_NE)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 98, __pyx_L1_error)
- if (unlikely(__pyx_t_7)) {
-
- /* "fontTools/feaLib/lexer.py":99
- * cur_char = text[self.pos_] if self.pos_ < limit else None
- * if cur_char != ")":
- * raise FeatureLibError("Expected ')' after file name", location) # <<<<<<<<<<<<<<
- * self.pos_ += 1
- * self.mode_ = Lexer.MODE_NORMAL_
- */
- __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_FeatureLibError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 99, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_1 = NULL;
- __pyx_t_8 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_1)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- __pyx_t_8 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_kp_u_Expected_after_file_name, __pyx_v_location};
- __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 99, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
- PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_kp_u_Expected_after_file_name, __pyx_v_location};
- __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 99, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- } else
- #endif
- {
- __pyx_t_4 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 99, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- if (__pyx_t_1) {
- __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); __pyx_t_1 = NULL;
- }
- __Pyx_INCREF(__pyx_kp_u_Expected_after_file_name);
- __Pyx_GIVEREF(__pyx_kp_u_Expected_after_file_name);
- PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_8, __pyx_kp_u_Expected_after_file_name);
- __Pyx_INCREF(__pyx_v_location);
- __Pyx_GIVEREF(__pyx_v_location);
- PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_8, __pyx_v_location);
- __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 99, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_Raise(__pyx_t_3, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __PYX_ERR(0, 99, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":98
- * self.scan_until_(")")
- * cur_char = text[self.pos_] if self.pos_ < limit else None
- * if cur_char != ")": # <<<<<<<<<<<<<<
- * raise FeatureLibError("Expected ')' after file name", location)
- * self.pos_ += 1
- */
- }
-
- /* "fontTools/feaLib/lexer.py":100
- * if cur_char != ")":
- * raise FeatureLibError("Expected ')' after file name", location)
- * self.pos_ += 1 # <<<<<<<<<<<<<<
- * self.mode_ = Lexer.MODE_NORMAL_
- * return (Lexer.FILENAME, text[start + 1 : self.pos_ - 1], location)
- */
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_pos); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 100, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_2 = __Pyx_PyInt_AddObjC(__pyx_t_3, __pyx_int_1, 1, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 100, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_pos, __pyx_t_2) < 0) __PYX_ERR(0, 100, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "fontTools/feaLib/lexer.py":101
- * raise FeatureLibError("Expected ')' after file name", location)
- * self.pos_ += 1
- * self.mode_ = Lexer.MODE_NORMAL_ # <<<<<<<<<<<<<<
- * return (Lexer.FILENAME, text[start + 1 : self.pos_ - 1], location)
- *
- */
- __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Lexer); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 101, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_MODE_NORMAL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 101, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_mode, __pyx_t_3) < 0) __PYX_ERR(0, 101, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "fontTools/feaLib/lexer.py":102
- * self.pos_ += 1
- * self.mode_ = Lexer.MODE_NORMAL_
- * return (Lexer.FILENAME, text[start + 1 : self.pos_ - 1], location) # <<<<<<<<<<<<<<
- *
- * if cur_char == "\\" and next_char in Lexer.CHAR_DIGIT_:
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_Lexer); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 102, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_FILENAME); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 102, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_3 = __Pyx_PyInt_AddObjC(__pyx_v_start, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 102, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_pos); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 102, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_1 = __Pyx_PyInt_SubtractObjC(__pyx_t_4, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 102, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = __Pyx_PyObject_GetSlice(__pyx_v_text, 0, 0, &__pyx_t_3, &__pyx_t_1, NULL, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 102, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 102, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_4);
- PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_4);
- __Pyx_INCREF(__pyx_v_location);
- __Pyx_GIVEREF(__pyx_v_location);
- PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_location);
- __pyx_t_2 = 0;
- __pyx_t_4 = 0;
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "fontTools/feaLib/lexer.py":93
- * return (Lexer.COMMENT, text[start : self.pos_], location)
- *
- * if self.mode_ is Lexer.MODE_FILENAME_: # <<<<<<<<<<<<<<
- * if cur_char != "(":
- * raise FeatureLibError("Expected '(' before file name", location)
- */
- }
-
- /* "fontTools/feaLib/lexer.py":104
- * return (Lexer.FILENAME, text[start + 1 : self.pos_ - 1], location)
- *
- * if cur_char == "\\" and next_char in Lexer.CHAR_DIGIT_: # <<<<<<<<<<<<<<
- * self.pos_ += 1
- * self.scan_over_(Lexer.CHAR_DIGIT_)
- */
- __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_v_cur_char, __pyx_kp_u__6, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 104, __pyx_L1_error)
- if (__pyx_t_6) {
- } else {
- __pyx_t_7 = __pyx_t_6;
- goto __pyx_L11_bool_binop_done;
- }
- __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Lexer); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 104, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_CHAR_DIGIT); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 104, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_6 = (__Pyx_PySequence_ContainsTF(__pyx_v_next_char, __pyx_t_4, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 104, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_9 = (__pyx_t_6 != 0);
- __pyx_t_7 = __pyx_t_9;
- __pyx_L11_bool_binop_done:;
- if (__pyx_t_7) {
-
- /* "fontTools/feaLib/lexer.py":105
- *
- * if cur_char == "\\" and next_char in Lexer.CHAR_DIGIT_:
- * self.pos_ += 1 # <<<<<<<<<<<<<<
- * self.scan_over_(Lexer.CHAR_DIGIT_)
- * return (Lexer.CID, int(text[start + 1 : self.pos_], 10), location)
- */
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_pos); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 105, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_1 = __Pyx_PyInt_AddObjC(__pyx_t_4, __pyx_int_1, 1, 1, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 105, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_pos, __pyx_t_1) < 0) __PYX_ERR(0, 105, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "fontTools/feaLib/lexer.py":106
- * if cur_char == "\\" and next_char in Lexer.CHAR_DIGIT_:
- * self.pos_ += 1
- * self.scan_over_(Lexer.CHAR_DIGIT_) # <<<<<<<<<<<<<<
- * return (Lexer.CID, int(text[start + 1 : self.pos_], 10), location)
- * if cur_char == "@":
- */
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_scan_over); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 106, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Lexer); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 106, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_CHAR_DIGIT); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 106, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_2)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_2);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- }
- }
- __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3);
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 106, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "fontTools/feaLib/lexer.py":107
- * self.pos_ += 1
- * self.scan_over_(Lexer.CHAR_DIGIT_)
- * return (Lexer.CID, int(text[start + 1 : self.pos_], 10), location) # <<<<<<<<<<<<<<
- * if cur_char == "@":
- * self.pos_ += 1
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Lexer); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 107, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_CID); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 107, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_PyInt_AddObjC(__pyx_v_start, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 107, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_pos); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 107, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_2 = __Pyx_PyObject_GetSlice(__pyx_v_text, 0, 0, &__pyx_t_1, &__pyx_t_3, NULL, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 107, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 107, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
- __Pyx_INCREF(__pyx_int_10);
- __Pyx_GIVEREF(__pyx_int_10);
- PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_10);
- __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)(&PyInt_Type)), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 107, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 107, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_4);
- PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
- __Pyx_INCREF(__pyx_v_location);
- __Pyx_GIVEREF(__pyx_v_location);
- PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_location);
- __pyx_t_4 = 0;
- __pyx_t_2 = 0;
- __pyx_r = __pyx_t_3;
- __pyx_t_3 = 0;
- goto __pyx_L0;
-
- /* "fontTools/feaLib/lexer.py":104
- * return (Lexer.FILENAME, text[start + 1 : self.pos_ - 1], location)
- *
- * if cur_char == "\\" and next_char in Lexer.CHAR_DIGIT_: # <<<<<<<<<<<<<<
- * self.pos_ += 1
- * self.scan_over_(Lexer.CHAR_DIGIT_)
- */
- }
-
- /* "fontTools/feaLib/lexer.py":108
- * self.scan_over_(Lexer.CHAR_DIGIT_)
- * return (Lexer.CID, int(text[start + 1 : self.pos_], 10), location)
- * if cur_char == "@": # <<<<<<<<<<<<<<
- * self.pos_ += 1
- * self.scan_over_(Lexer.CHAR_NAME_CONTINUATION_)
- */
- __pyx_t_7 = (__Pyx_PyUnicode_Equals(__pyx_v_cur_char, __pyx_kp_u__7, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 108, __pyx_L1_error)
- if (__pyx_t_7) {
-
- /* "fontTools/feaLib/lexer.py":109
- * return (Lexer.CID, int(text[start + 1 : self.pos_], 10), location)
- * if cur_char == "@":
- * self.pos_ += 1 # <<<<<<<<<<<<<<
- * self.scan_over_(Lexer.CHAR_NAME_CONTINUATION_)
- * glyphclass = text[start + 1 : self.pos_]
- */
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_pos); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 109, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_2 = __Pyx_PyInt_AddObjC(__pyx_t_3, __pyx_int_1, 1, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 109, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_pos, __pyx_t_2) < 0) __PYX_ERR(0, 109, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "fontTools/feaLib/lexer.py":110
- * if cur_char == "@":
- * self.pos_ += 1
- * self.scan_over_(Lexer.CHAR_NAME_CONTINUATION_) # <<<<<<<<<<<<<<
- * glyphclass = text[start + 1 : self.pos_]
- * if len(glyphclass) < 1:
- */
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_scan_over); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 110, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_Lexer); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 110, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_CHAR_NAME_CONTINUATION); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 110, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_1);
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 110, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "fontTools/feaLib/lexer.py":111
- * self.pos_ += 1
- * self.scan_over_(Lexer.CHAR_NAME_CONTINUATION_)
- * glyphclass = text[start + 1 : self.pos_] # <<<<<<<<<<<<<<
- * if len(glyphclass) < 1:
- * raise FeatureLibError("Expected glyph class name", location)
- */
- __pyx_t_2 = __Pyx_PyInt_AddObjC(__pyx_v_start, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 111, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_pos); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 111, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_v_text, 0, 0, &__pyx_t_2, &__pyx_t_3, NULL, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 111, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_v_glyphclass = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "fontTools/feaLib/lexer.py":112
- * self.scan_over_(Lexer.CHAR_NAME_CONTINUATION_)
- * glyphclass = text[start + 1 : self.pos_]
- * if len(glyphclass) < 1: # <<<<<<<<<<<<<<
- * raise FeatureLibError("Expected glyph class name", location)
- * if len(glyphclass) > 63:
- */
- __pyx_t_5 = PyObject_Length(__pyx_v_glyphclass); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 112, __pyx_L1_error)
- __pyx_t_7 = ((__pyx_t_5 < 1) != 0);
- if (unlikely(__pyx_t_7)) {
-
- /* "fontTools/feaLib/lexer.py":113
- * glyphclass = text[start + 1 : self.pos_]
- * if len(glyphclass) < 1:
- * raise FeatureLibError("Expected glyph class name", location) # <<<<<<<<<<<<<<
- * if len(glyphclass) > 63:
- * raise FeatureLibError(
- */
- __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_FeatureLibError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 113, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_2 = NULL;
- __pyx_t_8 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_2)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_2);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- __pyx_t_8 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_kp_u_Expected_glyph_class_name, __pyx_v_location};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 113, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_kp_u_Expected_glyph_class_name, __pyx_v_location};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 113, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_4 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 113, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- if (__pyx_t_2) {
- __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL;
- }
- __Pyx_INCREF(__pyx_kp_u_Expected_glyph_class_name);
- __Pyx_GIVEREF(__pyx_kp_u_Expected_glyph_class_name);
- PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_8, __pyx_kp_u_Expected_glyph_class_name);
- __Pyx_INCREF(__pyx_v_location);
- __Pyx_GIVEREF(__pyx_v_location);
- PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_8, __pyx_v_location);
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 113, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_Raise(__pyx_t_1, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __PYX_ERR(0, 113, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":112
- * self.scan_over_(Lexer.CHAR_NAME_CONTINUATION_)
- * glyphclass = text[start + 1 : self.pos_]
- * if len(glyphclass) < 1: # <<<<<<<<<<<<<<
- * raise FeatureLibError("Expected glyph class name", location)
- * if len(glyphclass) > 63:
- */
- }
-
- /* "fontTools/feaLib/lexer.py":114
- * if len(glyphclass) < 1:
- * raise FeatureLibError("Expected glyph class name", location)
- * if len(glyphclass) > 63: # <<<<<<<<<<<<<<
- * raise FeatureLibError(
- * "Glyph class names must not be longer than 63 characters", location
- */
- __pyx_t_5 = PyObject_Length(__pyx_v_glyphclass); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 114, __pyx_L1_error)
- __pyx_t_7 = ((__pyx_t_5 > 63) != 0);
- if (unlikely(__pyx_t_7)) {
-
- /* "fontTools/feaLib/lexer.py":115
- * raise FeatureLibError("Expected glyph class name", location)
- * if len(glyphclass) > 63:
- * raise FeatureLibError( # <<<<<<<<<<<<<<
- * "Glyph class names must not be longer than 63 characters", location
- * )
- */
- __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_FeatureLibError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 115, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
-
- /* "fontTools/feaLib/lexer.py":116
- * if len(glyphclass) > 63:
- * raise FeatureLibError(
- * "Glyph class names must not be longer than 63 characters", location # <<<<<<<<<<<<<<
- * )
- * if not Lexer.RE_GLYPHCLASS.match(glyphclass):
- */
- __pyx_t_4 = NULL;
- __pyx_t_8 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- __pyx_t_8 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_kp_u_Glyph_class_names_must_not_be_lo, __pyx_v_location};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 115, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_kp_u_Glyph_class_names_must_not_be_lo, __pyx_v_location};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 115, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_2 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 115, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (__pyx_t_4) {
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4); __pyx_t_4 = NULL;
- }
- __Pyx_INCREF(__pyx_kp_u_Glyph_class_names_must_not_be_lo);
- __Pyx_GIVEREF(__pyx_kp_u_Glyph_class_names_must_not_be_lo);
- PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_8, __pyx_kp_u_Glyph_class_names_must_not_be_lo);
- __Pyx_INCREF(__pyx_v_location);
- __Pyx_GIVEREF(__pyx_v_location);
- PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_8, __pyx_v_location);
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 115, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_Raise(__pyx_t_1, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __PYX_ERR(0, 115, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":114
- * if len(glyphclass) < 1:
- * raise FeatureLibError("Expected glyph class name", location)
- * if len(glyphclass) > 63: # <<<<<<<<<<<<<<
- * raise FeatureLibError(
- * "Glyph class names must not be longer than 63 characters", location
- */
- }
-
- /* "fontTools/feaLib/lexer.py":118
- * "Glyph class names must not be longer than 63 characters", location
- * )
- * if not Lexer.RE_GLYPHCLASS.match(glyphclass): # <<<<<<<<<<<<<<
- * raise FeatureLibError(
- * "Glyph class names must consist of letters, digits, "
- */
- __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_Lexer); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 118, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_RE_GLYPHCLASS); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 118, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_match); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 118, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_2)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_2);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_glyphclass) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_glyphclass);
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 118, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 118, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_9 = ((!__pyx_t_7) != 0);
- if (unlikely(__pyx_t_9)) {
-
- /* "fontTools/feaLib/lexer.py":119
- * )
- * if not Lexer.RE_GLYPHCLASS.match(glyphclass):
- * raise FeatureLibError( # <<<<<<<<<<<<<<
- * "Glyph class names must consist of letters, digits, "
- * "underscore, period or hyphen",
- */
- __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_FeatureLibError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 119, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
-
- /* "fontTools/feaLib/lexer.py":122
- * "Glyph class names must consist of letters, digits, "
- * "underscore, period or hyphen",
- * location, # <<<<<<<<<<<<<<
- * )
- * return (Lexer.GLYPHCLASS, glyphclass, location)
- */
- __pyx_t_2 = NULL;
- __pyx_t_8 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_2)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_2);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- __pyx_t_8 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_kp_u_Glyph_class_names_must_consist_o, __pyx_v_location};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 119, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_kp_u_Glyph_class_names_must_consist_o, __pyx_v_location};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 119, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- } else
- #endif
- {
- __pyx_t_4 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 119, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- if (__pyx_t_2) {
- __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL;
- }
- __Pyx_INCREF(__pyx_kp_u_Glyph_class_names_must_consist_o);
- __Pyx_GIVEREF(__pyx_kp_u_Glyph_class_names_must_consist_o);
- PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_8, __pyx_kp_u_Glyph_class_names_must_consist_o);
- __Pyx_INCREF(__pyx_v_location);
- __Pyx_GIVEREF(__pyx_v_location);
- PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_8, __pyx_v_location);
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 119, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_Raise(__pyx_t_1, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __PYX_ERR(0, 119, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":118
- * "Glyph class names must not be longer than 63 characters", location
- * )
- * if not Lexer.RE_GLYPHCLASS.match(glyphclass): # <<<<<<<<<<<<<<
- * raise FeatureLibError(
- * "Glyph class names must consist of letters, digits, "
- */
- }
-
- /* "fontTools/feaLib/lexer.py":124
- * location,
- * )
- * return (Lexer.GLYPHCLASS, glyphclass, location) # <<<<<<<<<<<<<<
- * if cur_char in Lexer.CHAR_NAME_START_:
- * self.pos_ += 1
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Lexer); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 124, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_GLYPHCLASS); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 124, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 124, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
- __Pyx_INCREF(__pyx_v_glyphclass);
- __Pyx_GIVEREF(__pyx_v_glyphclass);
- PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_glyphclass);
- __Pyx_INCREF(__pyx_v_location);
- __Pyx_GIVEREF(__pyx_v_location);
- PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_location);
- __pyx_t_3 = 0;
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "fontTools/feaLib/lexer.py":108
- * self.scan_over_(Lexer.CHAR_DIGIT_)
- * return (Lexer.CID, int(text[start + 1 : self.pos_], 10), location)
- * if cur_char == "@": # <<<<<<<<<<<<<<
- * self.pos_ += 1
- * self.scan_over_(Lexer.CHAR_NAME_CONTINUATION_)
- */
- }
-
- /* "fontTools/feaLib/lexer.py":125
- * )
- * return (Lexer.GLYPHCLASS, glyphclass, location)
- * if cur_char in Lexer.CHAR_NAME_START_: # <<<<<<<<<<<<<<
- * self.pos_ += 1
- * self.scan_over_(Lexer.CHAR_NAME_CONTINUATION_)
- */
- __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Lexer); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 125, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_CHAR_NAME_START); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 125, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_9 = (__Pyx_PySequence_ContainsTF(__pyx_v_cur_char, __pyx_t_3, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 125, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_7 = (__pyx_t_9 != 0);
- if (__pyx_t_7) {
-
- /* "fontTools/feaLib/lexer.py":126
- * return (Lexer.GLYPHCLASS, glyphclass, location)
- * if cur_char in Lexer.CHAR_NAME_START_:
- * self.pos_ += 1 # <<<<<<<<<<<<<<
- * self.scan_over_(Lexer.CHAR_NAME_CONTINUATION_)
- * token = text[start : self.pos_]
- */
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_pos); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 126, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_1 = __Pyx_PyInt_AddObjC(__pyx_t_3, __pyx_int_1, 1, 1, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 126, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_pos, __pyx_t_1) < 0) __PYX_ERR(0, 126, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "fontTools/feaLib/lexer.py":127
- * if cur_char in Lexer.CHAR_NAME_START_:
- * self.pos_ += 1
- * self.scan_over_(Lexer.CHAR_NAME_CONTINUATION_) # <<<<<<<<<<<<<<
- * token = text[start : self.pos_]
- * if token == "include":
- */
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_scan_over); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 127, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_Lexer); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 127, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_CHAR_NAME_CONTINUATION); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 127, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2);
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 127, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "fontTools/feaLib/lexer.py":128
- * self.pos_ += 1
- * self.scan_over_(Lexer.CHAR_NAME_CONTINUATION_)
- * token = text[start : self.pos_] # <<<<<<<<<<<<<<
- * if token == "include":
- * self.mode_ = Lexer.MODE_FILENAME_
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_pos); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 128, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_3 = __Pyx_PyObject_GetSlice(__pyx_v_text, 0, 0, &__pyx_v_start, &__pyx_t_1, NULL, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 128, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_v_token = __pyx_t_3;
- __pyx_t_3 = 0;
-
- /* "fontTools/feaLib/lexer.py":129
- * self.scan_over_(Lexer.CHAR_NAME_CONTINUATION_)
- * token = text[start : self.pos_]
- * if token == "include": # <<<<<<<<<<<<<<
- * self.mode_ = Lexer.MODE_FILENAME_
- * return (Lexer.NAME, token, location)
- */
- __pyx_t_7 = (__Pyx_PyUnicode_Equals(__pyx_v_token, __pyx_n_u_include, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 129, __pyx_L1_error)
- if (__pyx_t_7) {
-
- /* "fontTools/feaLib/lexer.py":130
- * token = text[start : self.pos_]
- * if token == "include":
- * self.mode_ = Lexer.MODE_FILENAME_ # <<<<<<<<<<<<<<
- * return (Lexer.NAME, token, location)
- * if cur_char == "0" and next_char in "xX":
- */
- __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_Lexer); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 130, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_MODE_FILENAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 130, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_mode, __pyx_t_1) < 0) __PYX_ERR(0, 130, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "fontTools/feaLib/lexer.py":129
- * self.scan_over_(Lexer.CHAR_NAME_CONTINUATION_)
- * token = text[start : self.pos_]
- * if token == "include": # <<<<<<<<<<<<<<
- * self.mode_ = Lexer.MODE_FILENAME_
- * return (Lexer.NAME, token, location)
- */
- }
-
- /* "fontTools/feaLib/lexer.py":131
- * if token == "include":
- * self.mode_ = Lexer.MODE_FILENAME_
- * return (Lexer.NAME, token, location) # <<<<<<<<<<<<<<
- * if cur_char == "0" and next_char in "xX":
- * self.pos_ += 2
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Lexer); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 131, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_NAME); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 131, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 131, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
- __Pyx_INCREF(__pyx_v_token);
- __Pyx_GIVEREF(__pyx_v_token);
- PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_token);
- __Pyx_INCREF(__pyx_v_location);
- __Pyx_GIVEREF(__pyx_v_location);
- PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_location);
- __pyx_t_3 = 0;
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "fontTools/feaLib/lexer.py":125
- * )
- * return (Lexer.GLYPHCLASS, glyphclass, location)
- * if cur_char in Lexer.CHAR_NAME_START_: # <<<<<<<<<<<<<<
- * self.pos_ += 1
- * self.scan_over_(Lexer.CHAR_NAME_CONTINUATION_)
- */
- }
-
- /* "fontTools/feaLib/lexer.py":132
- * self.mode_ = Lexer.MODE_FILENAME_
- * return (Lexer.NAME, token, location)
- * if cur_char == "0" and next_char in "xX": # <<<<<<<<<<<<<<
- * self.pos_ += 2
- * self.scan_over_(Lexer.CHAR_HEXDIGIT_)
- */
- __pyx_t_9 = (__Pyx_PyUnicode_Equals(__pyx_v_cur_char, __pyx_kp_u_0, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 132, __pyx_L1_error)
- if (__pyx_t_9) {
- } else {
- __pyx_t_7 = __pyx_t_9;
- goto __pyx_L20_bool_binop_done;
- }
- __pyx_t_9 = (__Pyx_PyUnicode_ContainsTF(__pyx_v_next_char, __pyx_n_u_xX, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 132, __pyx_L1_error)
- __pyx_t_6 = (__pyx_t_9 != 0);
- __pyx_t_7 = __pyx_t_6;
- __pyx_L20_bool_binop_done:;
- if (__pyx_t_7) {
-
- /* "fontTools/feaLib/lexer.py":133
- * return (Lexer.NAME, token, location)
- * if cur_char == "0" and next_char in "xX":
- * self.pos_ += 2 # <<<<<<<<<<<<<<
- * self.scan_over_(Lexer.CHAR_HEXDIGIT_)
- * return (Lexer.HEXADECIMAL, int(text[start : self.pos_], 16), location)
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_pos); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 133, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_3 = __Pyx_PyInt_AddObjC(__pyx_t_1, __pyx_int_2, 2, 1, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 133, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_pos, __pyx_t_3) < 0) __PYX_ERR(0, 133, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "fontTools/feaLib/lexer.py":134
- * if cur_char == "0" and next_char in "xX":
- * self.pos_ += 2
- * self.scan_over_(Lexer.CHAR_HEXDIGIT_) # <<<<<<<<<<<<<<
- * return (Lexer.HEXADECIMAL, int(text[start : self.pos_], 16), location)
- * if cur_char == "0" and next_char in Lexer.CHAR_DIGIT_:
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_scan_over); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 134, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Lexer); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 134, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_CHAR_HEXDIGIT); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 134, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
- __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1);
- if (likely(__pyx_t_2)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
- __Pyx_INCREF(__pyx_t_2);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_1, function);
- }
- }
- __pyx_t_3 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_2, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4);
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 134, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "fontTools/feaLib/lexer.py":135
- * self.pos_ += 2
- * self.scan_over_(Lexer.CHAR_HEXDIGIT_)
- * return (Lexer.HEXADECIMAL, int(text[start : self.pos_], 16), location) # <<<<<<<<<<<<<<
- * if cur_char == "0" and next_char in Lexer.CHAR_DIGIT_:
- * self.scan_over_(Lexer.CHAR_DIGIT_)
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_Lexer); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 135, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_HEXADECIMAL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 135, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_pos); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 135, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = __Pyx_PyObject_GetSlice(__pyx_v_text, 0, 0, &__pyx_v_start, &__pyx_t_3, NULL, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 135, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 135, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_4);
- PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
- __Pyx_INCREF(__pyx_int_16);
- __Pyx_GIVEREF(__pyx_int_16);
- PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_16);
- __pyx_t_4 = 0;
- __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)(&PyInt_Type)), __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 135, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 135, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_4);
- PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4);
- __Pyx_INCREF(__pyx_v_location);
- __Pyx_GIVEREF(__pyx_v_location);
- PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_location);
- __pyx_t_1 = 0;
- __pyx_t_4 = 0;
- __pyx_r = __pyx_t_3;
- __pyx_t_3 = 0;
- goto __pyx_L0;
-
- /* "fontTools/feaLib/lexer.py":132
- * self.mode_ = Lexer.MODE_FILENAME_
- * return (Lexer.NAME, token, location)
- * if cur_char == "0" and next_char in "xX": # <<<<<<<<<<<<<<
- * self.pos_ += 2
- * self.scan_over_(Lexer.CHAR_HEXDIGIT_)
- */
- }
-
- /* "fontTools/feaLib/lexer.py":136
- * self.scan_over_(Lexer.CHAR_HEXDIGIT_)
- * return (Lexer.HEXADECIMAL, int(text[start : self.pos_], 16), location)
- * if cur_char == "0" and next_char in Lexer.CHAR_DIGIT_: # <<<<<<<<<<<<<<
- * self.scan_over_(Lexer.CHAR_DIGIT_)
- * return (Lexer.OCTAL, int(text[start : self.pos_], 8), location)
- */
- __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_v_cur_char, __pyx_kp_u_0, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 136, __pyx_L1_error)
- if (__pyx_t_6) {
- } else {
- __pyx_t_7 = __pyx_t_6;
- goto __pyx_L23_bool_binop_done;
- }
- __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_Lexer); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 136, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_CHAR_DIGIT); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 136, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_6 = (__Pyx_PySequence_ContainsTF(__pyx_v_next_char, __pyx_t_4, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 136, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_9 = (__pyx_t_6 != 0);
- __pyx_t_7 = __pyx_t_9;
- __pyx_L23_bool_binop_done:;
- if (__pyx_t_7) {
-
- /* "fontTools/feaLib/lexer.py":137
- * return (Lexer.HEXADECIMAL, int(text[start : self.pos_], 16), location)
- * if cur_char == "0" and next_char in Lexer.CHAR_DIGIT_:
- * self.scan_over_(Lexer.CHAR_DIGIT_) # <<<<<<<<<<<<<<
- * return (Lexer.OCTAL, int(text[start : self.pos_], 8), location)
- * if cur_char in Lexer.CHAR_DIGIT_:
- */
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_scan_over); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 137, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Lexer); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 137, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_CHAR_DIGIT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 137, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_1)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- __pyx_t_4 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_1, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2);
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 137, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-
- /* "fontTools/feaLib/lexer.py":138
- * if cur_char == "0" and next_char in Lexer.CHAR_DIGIT_:
- * self.scan_over_(Lexer.CHAR_DIGIT_)
- * return (Lexer.OCTAL, int(text[start : self.pos_], 8), location) # <<<<<<<<<<<<<<
- * if cur_char in Lexer.CHAR_DIGIT_:
- * self.scan_over_(Lexer.CHAR_DIGIT_)
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_Lexer); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 138, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_OCTAL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 138, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_pos); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 138, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_2 = __Pyx_PyObject_GetSlice(__pyx_v_text, 0, 0, &__pyx_v_start, &__pyx_t_4, NULL, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 138, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 138, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
- __Pyx_INCREF(__pyx_int_8);
- __Pyx_GIVEREF(__pyx_int_8);
- PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_int_8);
- __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)(&PyInt_Type)), __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 138, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 138, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
- __Pyx_INCREF(__pyx_v_location);
- __Pyx_GIVEREF(__pyx_v_location);
- PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_location);
- __pyx_t_3 = 0;
- __pyx_t_2 = 0;
- __pyx_r = __pyx_t_4;
- __pyx_t_4 = 0;
- goto __pyx_L0;
-
- /* "fontTools/feaLib/lexer.py":136
- * self.scan_over_(Lexer.CHAR_HEXDIGIT_)
- * return (Lexer.HEXADECIMAL, int(text[start : self.pos_], 16), location)
- * if cur_char == "0" and next_char in Lexer.CHAR_DIGIT_: # <<<<<<<<<<<<<<
- * self.scan_over_(Lexer.CHAR_DIGIT_)
- * return (Lexer.OCTAL, int(text[start : self.pos_], 8), location)
- */
- }
-
- /* "fontTools/feaLib/lexer.py":139
- * self.scan_over_(Lexer.CHAR_DIGIT_)
- * return (Lexer.OCTAL, int(text[start : self.pos_], 8), location)
- * if cur_char in Lexer.CHAR_DIGIT_: # <<<<<<<<<<<<<<
- * self.scan_over_(Lexer.CHAR_DIGIT_)
- * if self.pos_ >= limit or text[self.pos_] != ".":
- */
- __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_Lexer); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 139, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_CHAR_DIGIT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 139, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_7 = (__Pyx_PySequence_ContainsTF(__pyx_v_cur_char, __pyx_t_2, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 139, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_9 = (__pyx_t_7 != 0);
- if (__pyx_t_9) {
-
- /* "fontTools/feaLib/lexer.py":140
- * return (Lexer.OCTAL, int(text[start : self.pos_], 8), location)
- * if cur_char in Lexer.CHAR_DIGIT_:
- * self.scan_over_(Lexer.CHAR_DIGIT_) # <<<<<<<<<<<<<<
- * if self.pos_ >= limit or text[self.pos_] != ".":
- * return (Lexer.NUMBER, int(text[start : self.pos_], 10), location)
- */
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_scan_over); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 140, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_Lexer); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 140, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_CHAR_DIGIT); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 140, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- }
- }
- __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_3, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_1);
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 140, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "fontTools/feaLib/lexer.py":141
- * if cur_char in Lexer.CHAR_DIGIT_:
- * self.scan_over_(Lexer.CHAR_DIGIT_)
- * if self.pos_ >= limit or text[self.pos_] != ".": # <<<<<<<<<<<<<<
- * return (Lexer.NUMBER, int(text[start : self.pos_], 10), location)
- * self.scan_over_(".")
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_pos); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 141, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_limit); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 141, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_t_4, Py_GE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 141, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 141, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- if (!__pyx_t_7) {
- } else {
- __pyx_t_9 = __pyx_t_7;
- goto __pyx_L27_bool_binop_done;
- }
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_pos); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 141, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_v_text, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 141, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_7 = (__Pyx_PyUnicode_Equals(__pyx_t_4, __pyx_kp_u__8, Py_NE)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 141, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_9 = __pyx_t_7;
- __pyx_L27_bool_binop_done:;
- if (__pyx_t_9) {
-
- /* "fontTools/feaLib/lexer.py":142
- * self.scan_over_(Lexer.CHAR_DIGIT_)
- * if self.pos_ >= limit or text[self.pos_] != ".":
- * return (Lexer.NUMBER, int(text[start : self.pos_], 10), location) # <<<<<<<<<<<<<<
- * self.scan_over_(".")
- * self.scan_over_(Lexer.CHAR_DIGIT_)
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_Lexer); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 142, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_NUMBER); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 142, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_pos); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 142, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_2 = __Pyx_PyObject_GetSlice(__pyx_v_text, 0, 0, &__pyx_v_start, &__pyx_t_4, NULL, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 142, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 142, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
- __Pyx_INCREF(__pyx_int_10);
- __Pyx_GIVEREF(__pyx_int_10);
- PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_int_10);
- __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)(&PyInt_Type)), __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 142, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 142, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
- __Pyx_INCREF(__pyx_v_location);
- __Pyx_GIVEREF(__pyx_v_location);
- PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_location);
- __pyx_t_1 = 0;
- __pyx_t_2 = 0;
- __pyx_r = __pyx_t_4;
- __pyx_t_4 = 0;
- goto __pyx_L0;
-
- /* "fontTools/feaLib/lexer.py":141
- * if cur_char in Lexer.CHAR_DIGIT_:
- * self.scan_over_(Lexer.CHAR_DIGIT_)
- * if self.pos_ >= limit or text[self.pos_] != ".": # <<<<<<<<<<<<<<
- * return (Lexer.NUMBER, int(text[start : self.pos_], 10), location)
- * self.scan_over_(".")
- */
- }
-
- /* "fontTools/feaLib/lexer.py":143
- * if self.pos_ >= limit or text[self.pos_] != ".":
- * return (Lexer.NUMBER, int(text[start : self.pos_], 10), location)
- * self.scan_over_(".") # <<<<<<<<<<<<<<
- * self.scan_over_(Lexer.CHAR_DIGIT_)
- * return (Lexer.FLOAT, float(text[start : self.pos_]), location)
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_scan_over); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 143, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_1 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_1)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- __pyx_t_4 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_1, __pyx_kp_u__8) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_kp_u__8);
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 143, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-
- /* "fontTools/feaLib/lexer.py":144
- * return (Lexer.NUMBER, int(text[start : self.pos_], 10), location)
- * self.scan_over_(".")
- * self.scan_over_(Lexer.CHAR_DIGIT_) # <<<<<<<<<<<<<<
- * return (Lexer.FLOAT, float(text[start : self.pos_]), location)
- * if cur_char == "-" and next_char in Lexer.CHAR_DIGIT_:
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_scan_over); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 144, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Lexer); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 144, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_CHAR_DIGIT); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 144, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_1)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- __pyx_t_4 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_1, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 144, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-
- /* "fontTools/feaLib/lexer.py":145
- * self.scan_over_(".")
- * self.scan_over_(Lexer.CHAR_DIGIT_)
- * return (Lexer.FLOAT, float(text[start : self.pos_]), location) # <<<<<<<<<<<<<<
- * if cur_char == "-" and next_char in Lexer.CHAR_DIGIT_:
- * self.pos_ += 1
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_Lexer); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 145, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_FLOAT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 145, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_pos); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 145, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_3 = __Pyx_PyObject_GetSlice(__pyx_v_text, 0, 0, &__pyx_v_start, &__pyx_t_4, NULL, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 145, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = __Pyx_PyNumber_Float(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 145, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 145, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_4);
- PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4);
- __Pyx_INCREF(__pyx_v_location);
- __Pyx_GIVEREF(__pyx_v_location);
- PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_location);
- __pyx_t_2 = 0;
- __pyx_t_4 = 0;
- __pyx_r = __pyx_t_3;
- __pyx_t_3 = 0;
- goto __pyx_L0;
-
- /* "fontTools/feaLib/lexer.py":139
- * self.scan_over_(Lexer.CHAR_DIGIT_)
- * return (Lexer.OCTAL, int(text[start : self.pos_], 8), location)
- * if cur_char in Lexer.CHAR_DIGIT_: # <<<<<<<<<<<<<<
- * self.scan_over_(Lexer.CHAR_DIGIT_)
- * if self.pos_ >= limit or text[self.pos_] != ".":
- */
- }
-
- /* "fontTools/feaLib/lexer.py":146
- * self.scan_over_(Lexer.CHAR_DIGIT_)
- * return (Lexer.FLOAT, float(text[start : self.pos_]), location)
- * if cur_char == "-" and next_char in Lexer.CHAR_DIGIT_: # <<<<<<<<<<<<<<
- * self.pos_ += 1
- * self.scan_over_(Lexer.CHAR_DIGIT_)
- */
- __pyx_t_7 = (__Pyx_PyUnicode_Equals(__pyx_v_cur_char, __pyx_kp_u__9, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 146, __pyx_L1_error)
- if (__pyx_t_7) {
- } else {
- __pyx_t_9 = __pyx_t_7;
- goto __pyx_L30_bool_binop_done;
- }
- __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_Lexer); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 146, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_CHAR_DIGIT); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 146, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_7 = (__Pyx_PySequence_ContainsTF(__pyx_v_next_char, __pyx_t_4, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 146, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_6 = (__pyx_t_7 != 0);
- __pyx_t_9 = __pyx_t_6;
- __pyx_L30_bool_binop_done:;
- if (__pyx_t_9) {
-
- /* "fontTools/feaLib/lexer.py":147
- * return (Lexer.FLOAT, float(text[start : self.pos_]), location)
- * if cur_char == "-" and next_char in Lexer.CHAR_DIGIT_:
- * self.pos_ += 1 # <<<<<<<<<<<<<<
- * self.scan_over_(Lexer.CHAR_DIGIT_)
- * if self.pos_ >= limit or text[self.pos_] != ".":
- */
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_pos); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 147, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_3 = __Pyx_PyInt_AddObjC(__pyx_t_4, __pyx_int_1, 1, 1, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 147, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_pos, __pyx_t_3) < 0) __PYX_ERR(0, 147, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "fontTools/feaLib/lexer.py":148
- * if cur_char == "-" and next_char in Lexer.CHAR_DIGIT_:
- * self.pos_ += 1
- * self.scan_over_(Lexer.CHAR_DIGIT_) # <<<<<<<<<<<<<<
- * if self.pos_ >= limit or text[self.pos_] != ".":
- * return (Lexer.NUMBER, int(text[start : self.pos_], 10), location)
- */
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_scan_over); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 148, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Lexer); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 148, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_CHAR_DIGIT); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 148, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_2)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_2);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- }
- }
- __pyx_t_3 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_2, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 148, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "fontTools/feaLib/lexer.py":149
- * self.pos_ += 1
- * self.scan_over_(Lexer.CHAR_DIGIT_)
- * if self.pos_ >= limit or text[self.pos_] != ".": # <<<<<<<<<<<<<<
- * return (Lexer.NUMBER, int(text[start : self.pos_], 10), location)
- * self.scan_over_(".")
- */
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_pos); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 149, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_limit); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 149, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_1 = PyObject_RichCompare(__pyx_t_3, __pyx_t_4, Py_GE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 149, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 149, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- if (!__pyx_t_6) {
- } else {
- __pyx_t_9 = __pyx_t_6;
- goto __pyx_L33_bool_binop_done;
- }
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_pos); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 149, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_v_text, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 149, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_t_4, __pyx_kp_u__8, Py_NE)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 149, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_9 = __pyx_t_6;
- __pyx_L33_bool_binop_done:;
- if (__pyx_t_9) {
-
- /* "fontTools/feaLib/lexer.py":150
- * self.scan_over_(Lexer.CHAR_DIGIT_)
- * if self.pos_ >= limit or text[self.pos_] != ".":
- * return (Lexer.NUMBER, int(text[start : self.pos_], 10), location) # <<<<<<<<<<<<<<
- * self.scan_over_(".")
- * self.scan_over_(Lexer.CHAR_DIGIT_)
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_Lexer); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 150, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_NUMBER); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 150, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_pos); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 150, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_3 = __Pyx_PyObject_GetSlice(__pyx_v_text, 0, 0, &__pyx_v_start, &__pyx_t_4, NULL, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 150, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 150, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
- __Pyx_INCREF(__pyx_int_10);
- __Pyx_GIVEREF(__pyx_int_10);
- PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_int_10);
- __pyx_t_3 = 0;
- __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)(&PyInt_Type)), __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 150, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 150, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
- __Pyx_INCREF(__pyx_v_location);
- __Pyx_GIVEREF(__pyx_v_location);
- PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_location);
- __pyx_t_1 = 0;
- __pyx_t_3 = 0;
- __pyx_r = __pyx_t_4;
- __pyx_t_4 = 0;
- goto __pyx_L0;
-
- /* "fontTools/feaLib/lexer.py":149
- * self.pos_ += 1
- * self.scan_over_(Lexer.CHAR_DIGIT_)
- * if self.pos_ >= limit or text[self.pos_] != ".": # <<<<<<<<<<<<<<
- * return (Lexer.NUMBER, int(text[start : self.pos_], 10), location)
- * self.scan_over_(".")
- */
- }
-
- /* "fontTools/feaLib/lexer.py":151
- * if self.pos_ >= limit or text[self.pos_] != ".":
- * return (Lexer.NUMBER, int(text[start : self.pos_], 10), location)
- * self.scan_over_(".") # <<<<<<<<<<<<<<
- * self.scan_over_(Lexer.CHAR_DIGIT_)
- * return (Lexer.FLOAT, float(text[start : self.pos_]), location)
- */
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_scan_over); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 151, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_1 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_1)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- __pyx_t_4 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_1, __pyx_kp_u__8) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_kp_u__8);
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 151, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-
- /* "fontTools/feaLib/lexer.py":152
- * return (Lexer.NUMBER, int(text[start : self.pos_], 10), location)
- * self.scan_over_(".")
- * self.scan_over_(Lexer.CHAR_DIGIT_) # <<<<<<<<<<<<<<
- * return (Lexer.FLOAT, float(text[start : self.pos_]), location)
- * if cur_char in Lexer.CHAR_SYMBOL_:
- */
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_scan_over); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 152, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Lexer); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 152, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_CHAR_DIGIT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 152, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_1)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- __pyx_t_4 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_1, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2);
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 152, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-
- /* "fontTools/feaLib/lexer.py":153
- * self.scan_over_(".")
- * self.scan_over_(Lexer.CHAR_DIGIT_)
- * return (Lexer.FLOAT, float(text[start : self.pos_]), location) # <<<<<<<<<<<<<<
- * if cur_char in Lexer.CHAR_SYMBOL_:
- * self.pos_ += 1
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_Lexer); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 153, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_FLOAT); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 153, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_pos); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 153, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_2 = __Pyx_PyObject_GetSlice(__pyx_v_text, 0, 0, &__pyx_v_start, &__pyx_t_4, NULL, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 153, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = __Pyx_PyNumber_Float(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 153, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 153, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_4);
- PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4);
- __Pyx_INCREF(__pyx_v_location);
- __Pyx_GIVEREF(__pyx_v_location);
- PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_location);
- __pyx_t_3 = 0;
- __pyx_t_4 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
- /* "fontTools/feaLib/lexer.py":146
- * self.scan_over_(Lexer.CHAR_DIGIT_)
- * return (Lexer.FLOAT, float(text[start : self.pos_]), location)
- * if cur_char == "-" and next_char in Lexer.CHAR_DIGIT_: # <<<<<<<<<<<<<<
- * self.pos_ += 1
- * self.scan_over_(Lexer.CHAR_DIGIT_)
- */
- }
-
- /* "fontTools/feaLib/lexer.py":154
- * self.scan_over_(Lexer.CHAR_DIGIT_)
- * return (Lexer.FLOAT, float(text[start : self.pos_]), location)
- * if cur_char in Lexer.CHAR_SYMBOL_: # <<<<<<<<<<<<<<
- * self.pos_ += 1
- * return (Lexer.SYMBOL, cur_char, location)
- */
- __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Lexer); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 154, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_CHAR_SYMBOL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 154, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_9 = (__Pyx_PySequence_ContainsTF(__pyx_v_cur_char, __pyx_t_4, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 154, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_6 = (__pyx_t_9 != 0);
- if (__pyx_t_6) {
-
- /* "fontTools/feaLib/lexer.py":155
- * return (Lexer.FLOAT, float(text[start : self.pos_]), location)
- * if cur_char in Lexer.CHAR_SYMBOL_:
- * self.pos_ += 1 # <<<<<<<<<<<<<<
- * return (Lexer.SYMBOL, cur_char, location)
- * if cur_char == '"':
- */
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_pos); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 155, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_2 = __Pyx_PyInt_AddObjC(__pyx_t_4, __pyx_int_1, 1, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 155, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_pos, __pyx_t_2) < 0) __PYX_ERR(0, 155, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "fontTools/feaLib/lexer.py":156
- * if cur_char in Lexer.CHAR_SYMBOL_:
- * self.pos_ += 1
- * return (Lexer.SYMBOL, cur_char, location) # <<<<<<<<<<<<<<
- * if cur_char == '"':
- * self.pos_ += 1
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Lexer); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 156, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_SYMBOL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 156, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 156, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_4);
- PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4);
- __Pyx_INCREF(__pyx_v_cur_char);
- __Pyx_GIVEREF(__pyx_v_cur_char);
- PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_cur_char);
- __Pyx_INCREF(__pyx_v_location);
- __Pyx_GIVEREF(__pyx_v_location);
- PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_location);
- __pyx_t_4 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
- /* "fontTools/feaLib/lexer.py":154
- * self.scan_over_(Lexer.CHAR_DIGIT_)
- * return (Lexer.FLOAT, float(text[start : self.pos_]), location)
- * if cur_char in Lexer.CHAR_SYMBOL_: # <<<<<<<<<<<<<<
- * self.pos_ += 1
- * return (Lexer.SYMBOL, cur_char, location)
- */
- }
-
- /* "fontTools/feaLib/lexer.py":157
- * self.pos_ += 1
- * return (Lexer.SYMBOL, cur_char, location)
- * if cur_char == '"': # <<<<<<<<<<<<<<
- * self.pos_ += 1
- * self.scan_until_('"')
- */
- __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_v_cur_char, __pyx_kp_u__10, Py_EQ)); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 157, __pyx_L1_error)
- if (__pyx_t_6) {
-
- /* "fontTools/feaLib/lexer.py":158
- * return (Lexer.SYMBOL, cur_char, location)
- * if cur_char == '"':
- * self.pos_ += 1 # <<<<<<<<<<<<<<
- * self.scan_until_('"')
- * if self.pos_ < self.text_length_ and self.text_[self.pos_] == '"':
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_pos); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 158, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_4 = __Pyx_PyInt_AddObjC(__pyx_t_2, __pyx_int_1, 1, 1, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 158, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_pos, __pyx_t_4) < 0) __PYX_ERR(0, 158, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-
- /* "fontTools/feaLib/lexer.py":159
- * if cur_char == '"':
- * self.pos_ += 1
- * self.scan_until_('"') # <<<<<<<<<<<<<<
- * if self.pos_ < self.text_length_ and self.text_[self.pos_] == '"':
- * self.pos_ += 1
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_scan_until); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 159, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- __pyx_t_4 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_kp_u__10) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_kp_u__10);
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 159, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-
- /* "fontTools/feaLib/lexer.py":160
- * self.pos_ += 1
- * self.scan_until_('"')
- * if self.pos_ < self.text_length_ and self.text_[self.pos_] == '"': # <<<<<<<<<<<<<<
- * self.pos_ += 1
- * # strip newlines embedded within a string
- */
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_pos); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 160, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_text_length); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 160, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = PyObject_RichCompare(__pyx_t_4, __pyx_t_2, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 160, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 160, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- if (__pyx_t_9) {
- } else {
- __pyx_t_6 = __pyx_t_9;
- goto __pyx_L38_bool_binop_done;
- }
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_text_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 160, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_pos); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 160, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 160, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_9 = (__Pyx_PyUnicode_Equals(__pyx_t_4, __pyx_kp_u__10, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 160, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_6 = __pyx_t_9;
- __pyx_L38_bool_binop_done:;
- if (likely(__pyx_t_6)) {
-
- /* "fontTools/feaLib/lexer.py":161
- * self.scan_until_('"')
- * if self.pos_ < self.text_length_ and self.text_[self.pos_] == '"':
- * self.pos_ += 1 # <<<<<<<<<<<<<<
- * # strip newlines embedded within a string
- * string = re.sub("[\r\n]", "", text[start + 1 : self.pos_ - 1])
- */
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_pos); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 161, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_2 = __Pyx_PyInt_AddObjC(__pyx_t_4, __pyx_int_1, 1, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 161, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_pos, __pyx_t_2) < 0) __PYX_ERR(0, 161, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "fontTools/feaLib/lexer.py":163
- * self.pos_ += 1
- * # strip newlines embedded within a string
- * string = re.sub("[\r\n]", "", text[start + 1 : self.pos_ - 1]) # <<<<<<<<<<<<<<
- * return (Lexer.STRING, string, location)
- * else:
- */
- __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_re); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 163, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_sub); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 163, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = __Pyx_PyInt_AddObjC(__pyx_v_start, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 163, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_pos); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 163, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_10 = __Pyx_PyInt_SubtractObjC(__pyx_t_1, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 163, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_10);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_v_text, 0, 0, &__pyx_t_4, &__pyx_t_10, NULL, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 163, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
- __pyx_t_10 = NULL;
- __pyx_t_8 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_10)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_10);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- __pyx_t_8 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[4] = {__pyx_t_10, __pyx_kp_u__11, __pyx_kp_u__12, __pyx_t_1};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 163, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[4] = {__pyx_t_10, __pyx_kp_u__11, __pyx_kp_u__12, __pyx_t_1};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_8, 3+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 163, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- } else
- #endif
- {
- __pyx_t_4 = PyTuple_New(3+__pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 163, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- if (__pyx_t_10) {
- __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_10); __pyx_t_10 = NULL;
- }
- __Pyx_INCREF(__pyx_kp_u__11);
- __Pyx_GIVEREF(__pyx_kp_u__11);
- PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_8, __pyx_kp_u__11);
- __Pyx_INCREF(__pyx_kp_u__12);
- __Pyx_GIVEREF(__pyx_kp_u__12);
- PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_8, __pyx_kp_u__12);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_4, 2+__pyx_t_8, __pyx_t_1);
- __pyx_t_1 = 0;
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 163, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_v_string = __pyx_t_2;
- __pyx_t_2 = 0;
-
- /* "fontTools/feaLib/lexer.py":164
- * # strip newlines embedded within a string
- * string = re.sub("[\r\n]", "", text[start + 1 : self.pos_ - 1])
- * return (Lexer.STRING, string, location) # <<<<<<<<<<<<<<
- * else:
- * raise FeatureLibError("Expected '\"' to terminate string", location)
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Lexer); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 164, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_STRING); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 164, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 164, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
- __Pyx_INCREF(__pyx_v_string);
- __Pyx_GIVEREF(__pyx_v_string);
- PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_string);
- __Pyx_INCREF(__pyx_v_location);
- __Pyx_GIVEREF(__pyx_v_location);
- PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_location);
- __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
- /* "fontTools/feaLib/lexer.py":160
- * self.pos_ += 1
- * self.scan_until_('"')
- * if self.pos_ < self.text_length_ and self.text_[self.pos_] == '"': # <<<<<<<<<<<<<<
- * self.pos_ += 1
- * # strip newlines embedded within a string
- */
- }
-
- /* "fontTools/feaLib/lexer.py":166
- * return (Lexer.STRING, string, location)
- * else:
- * raise FeatureLibError("Expected '\"' to terminate string", location) # <<<<<<<<<<<<<<
- * raise FeatureLibError("Unexpected character: %r" % cur_char, location)
- *
- */
- /*else*/ {
- __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_FeatureLibError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 166, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = NULL;
- __pyx_t_8 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- __pyx_t_8 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_kp_u_Expected_to_terminate_string, __pyx_v_location};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 166, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_kp_u_Expected_to_terminate_string, __pyx_v_location};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 166, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- } else
- #endif
- {
- __pyx_t_1 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 166, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (__pyx_t_4) {
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4); __pyx_t_4 = NULL;
- }
- __Pyx_INCREF(__pyx_kp_u_Expected_to_terminate_string);
- __Pyx_GIVEREF(__pyx_kp_u_Expected_to_terminate_string);
- PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_8, __pyx_kp_u_Expected_to_terminate_string);
- __Pyx_INCREF(__pyx_v_location);
- __Pyx_GIVEREF(__pyx_v_location);
- PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_8, __pyx_v_location);
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 166, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_Raise(__pyx_t_2, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __PYX_ERR(0, 166, __pyx_L1_error)
- }
-
- /* "fontTools/feaLib/lexer.py":157
- * self.pos_ += 1
- * return (Lexer.SYMBOL, cur_char, location)
- * if cur_char == '"': # <<<<<<<<<<<<<<
- * self.pos_ += 1
- * self.scan_until_('"')
- */
- }
-
- /* "fontTools/feaLib/lexer.py":167
- * else:
- * raise FeatureLibError("Expected '\"' to terminate string", location)
- * raise FeatureLibError("Unexpected character: %r" % cur_char, location) # <<<<<<<<<<<<<<
- *
- * def scan_over_(self, valid):
- */
- __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_FeatureLibError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 167, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_1 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_Unexpected_character_r, __pyx_v_cur_char); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 167, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_4 = NULL;
- __pyx_t_8 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- __pyx_t_8 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_1, __pyx_v_location};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 167, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
- PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_1, __pyx_v_location};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 167, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- } else
- #endif
- {
- __pyx_t_10 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 167, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_10);
- if (__pyx_t_4) {
- __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_4); __pyx_t_4 = NULL;
- }
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_8, __pyx_t_1);
- __Pyx_INCREF(__pyx_v_location);
- __Pyx_GIVEREF(__pyx_v_location);
- PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_8, __pyx_v_location);
- __pyx_t_1 = 0;
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 167, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_Raise(__pyx_t_2, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __PYX_ERR(0, 167, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":68
- * return FeatureLibLocation(self.filename_ or "", self.line_, column)
- *
- * def next_(self): # <<<<<<<<<<<<<<
- * self.scan_over_(Lexer.CHAR_WHITESPACE_)
- * location = self.location_()
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_10);
- __Pyx_AddTraceback("fontTools.feaLib.lexer.Lexer.next_", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_location);
- __Pyx_XDECREF(__pyx_v_start);
- __Pyx_XDECREF(__pyx_v_text);
- __Pyx_XDECREF(__pyx_v_cur_char);
- __Pyx_XDECREF(__pyx_v_next_char);
- __Pyx_XDECREF(__pyx_v_glyphclass);
- __Pyx_XDECREF(__pyx_v_token);
- __Pyx_XDECREF(__pyx_v_string);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "fontTools/feaLib/lexer.py":169
- * raise FeatureLibError("Unexpected character: %r" % cur_char, location)
- *
- * def scan_over_(self, valid): # <<<<<<<<<<<<<<
- * p = self.pos_
- * while p < self.text_length_ and self.text_[p] in valid:
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_9fontTools_6feaLib_5lexer_5Lexer_13scan_over_(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_9fontTools_6feaLib_5lexer_5Lexer_12scan_over_[] = "Lexer.scan_over_(self, valid)";
-static PyMethodDef __pyx_mdef_9fontTools_6feaLib_5lexer_5Lexer_13scan_over_ = {"scan_over_", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_9fontTools_6feaLib_5lexer_5Lexer_13scan_over_, METH_VARARGS|METH_KEYWORDS, __pyx_doc_9fontTools_6feaLib_5lexer_5Lexer_12scan_over_};
-static PyObject *__pyx_pw_9fontTools_6feaLib_5lexer_5Lexer_13scan_over_(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_self = 0;
- PyObject *__pyx_v_valid = 0;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("scan_over_ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_valid,0};
- PyObject* values[2] = {0,0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_valid)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("scan_over_", 1, 2, 2, 1); __PYX_ERR(0, 169, __pyx_L3_error)
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "scan_over_") < 0)) __PYX_ERR(0, 169, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- }
- __pyx_v_self = values[0];
- __pyx_v_valid = values[1];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("scan_over_", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 169, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("fontTools.feaLib.lexer.Lexer.scan_over_", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_9fontTools_6feaLib_5lexer_5Lexer_12scan_over_(__pyx_self, __pyx_v_self, __pyx_v_valid);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_9fontTools_6feaLib_5lexer_5Lexer_12scan_over_(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_valid) {
- PyObject *__pyx_v_p = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- int __pyx_t_4;
- int __pyx_t_5;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("scan_over_", 0);
-
- /* "fontTools/feaLib/lexer.py":170
- *
- * def scan_over_(self, valid):
- * p = self.pos_ # <<<<<<<<<<<<<<
- * while p < self.text_length_ and self.text_[p] in valid:
- * p += 1
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_pos); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 170, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_p = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "fontTools/feaLib/lexer.py":171
- * def scan_over_(self, valid):
- * p = self.pos_
- * while p < self.text_length_ and self.text_[p] in valid: # <<<<<<<<<<<<<<
- * p += 1
- * self.pos_ = p
- */
- while (1) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_text_length); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 171, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_3 = PyObject_RichCompare(__pyx_v_p, __pyx_t_1, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 171, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 171, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- if (__pyx_t_4) {
- } else {
- __pyx_t_2 = __pyx_t_4;
- goto __pyx_L5_bool_binop_done;
- }
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_text_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 171, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_t_3, __pyx_v_p); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 171, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_4 = (__Pyx_PySequence_ContainsTF(__pyx_t_1, __pyx_v_valid, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 171, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_5 = (__pyx_t_4 != 0);
- __pyx_t_2 = __pyx_t_5;
- __pyx_L5_bool_binop_done:;
- if (!__pyx_t_2) break;
-
- /* "fontTools/feaLib/lexer.py":172
- * p = self.pos_
- * while p < self.text_length_ and self.text_[p] in valid:
- * p += 1 # <<<<<<<<<<<<<<
- * self.pos_ = p
- *
- */
- __pyx_t_1 = __Pyx_PyInt_AddObjC(__pyx_v_p, __pyx_int_1, 1, 1, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 172, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF_SET(__pyx_v_p, __pyx_t_1);
- __pyx_t_1 = 0;
- }
-
- /* "fontTools/feaLib/lexer.py":173
- * while p < self.text_length_ and self.text_[p] in valid:
- * p += 1
- * self.pos_ = p # <<<<<<<<<<<<<<
- *
- * def scan_until_(self, stop_at):
- */
- if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_pos, __pyx_v_p) < 0) __PYX_ERR(0, 173, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":169
- * raise FeatureLibError("Unexpected character: %r" % cur_char, location)
- *
- * def scan_over_(self, valid): # <<<<<<<<<<<<<<
- * p = self.pos_
- * while p < self.text_length_ and self.text_[p] in valid:
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("fontTools.feaLib.lexer.Lexer.scan_over_", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_p);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "fontTools/feaLib/lexer.py":175
- * self.pos_ = p
- *
- * def scan_until_(self, stop_at): # <<<<<<<<<<<<<<
- * p = self.pos_
- * while p < self.text_length_ and self.text_[p] not in stop_at:
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_9fontTools_6feaLib_5lexer_5Lexer_15scan_until_(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_9fontTools_6feaLib_5lexer_5Lexer_14scan_until_[] = "Lexer.scan_until_(self, stop_at)";
-static PyMethodDef __pyx_mdef_9fontTools_6feaLib_5lexer_5Lexer_15scan_until_ = {"scan_until_", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_9fontTools_6feaLib_5lexer_5Lexer_15scan_until_, METH_VARARGS|METH_KEYWORDS, __pyx_doc_9fontTools_6feaLib_5lexer_5Lexer_14scan_until_};
-static PyObject *__pyx_pw_9fontTools_6feaLib_5lexer_5Lexer_15scan_until_(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_self = 0;
- PyObject *__pyx_v_stop_at = 0;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("scan_until_ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_stop_at,0};
- PyObject* values[2] = {0,0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_stop_at)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("scan_until_", 1, 2, 2, 1); __PYX_ERR(0, 175, __pyx_L3_error)
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "scan_until_") < 0)) __PYX_ERR(0, 175, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- }
- __pyx_v_self = values[0];
- __pyx_v_stop_at = values[1];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("scan_until_", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 175, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("fontTools.feaLib.lexer.Lexer.scan_until_", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_9fontTools_6feaLib_5lexer_5Lexer_14scan_until_(__pyx_self, __pyx_v_self, __pyx_v_stop_at);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_9fontTools_6feaLib_5lexer_5Lexer_14scan_until_(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_stop_at) {
- PyObject *__pyx_v_p = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- int __pyx_t_4;
- int __pyx_t_5;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("scan_until_", 0);
-
- /* "fontTools/feaLib/lexer.py":176
- *
- * def scan_until_(self, stop_at):
- * p = self.pos_ # <<<<<<<<<<<<<<
- * while p < self.text_length_ and self.text_[p] not in stop_at:
- * p += 1
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_pos); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 176, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_p = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "fontTools/feaLib/lexer.py":177
- * def scan_until_(self, stop_at):
- * p = self.pos_
- * while p < self.text_length_ and self.text_[p] not in stop_at: # <<<<<<<<<<<<<<
- * p += 1
- * self.pos_ = p
- */
- while (1) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_text_length); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 177, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_3 = PyObject_RichCompare(__pyx_v_p, __pyx_t_1, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 177, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 177, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- if (__pyx_t_4) {
- } else {
- __pyx_t_2 = __pyx_t_4;
- goto __pyx_L5_bool_binop_done;
- }
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_text_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 177, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_t_3, __pyx_v_p); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 177, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_4 = (__Pyx_PySequence_ContainsTF(__pyx_t_1, __pyx_v_stop_at, Py_NE)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 177, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_5 = (__pyx_t_4 != 0);
- __pyx_t_2 = __pyx_t_5;
- __pyx_L5_bool_binop_done:;
- if (!__pyx_t_2) break;
-
- /* "fontTools/feaLib/lexer.py":178
- * p = self.pos_
- * while p < self.text_length_ and self.text_[p] not in stop_at:
- * p += 1 # <<<<<<<<<<<<<<
- * self.pos_ = p
- *
- */
- __pyx_t_1 = __Pyx_PyInt_AddObjC(__pyx_v_p, __pyx_int_1, 1, 1, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 178, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF_SET(__pyx_v_p, __pyx_t_1);
- __pyx_t_1 = 0;
- }
-
- /* "fontTools/feaLib/lexer.py":179
- * while p < self.text_length_ and self.text_[p] not in stop_at:
- * p += 1
- * self.pos_ = p # <<<<<<<<<<<<<<
- *
- * def scan_anonymous_block(self, tag):
- */
- if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_pos, __pyx_v_p) < 0) __PYX_ERR(0, 179, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":175
- * self.pos_ = p
- *
- * def scan_until_(self, stop_at): # <<<<<<<<<<<<<<
- * p = self.pos_
- * while p < self.text_length_ and self.text_[p] not in stop_at:
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("fontTools.feaLib.lexer.Lexer.scan_until_", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_p);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "fontTools/feaLib/lexer.py":181
- * self.pos_ = p
- *
- * def scan_anonymous_block(self, tag): # <<<<<<<<<<<<<<
- * location = self.location_()
- * tag = tag.strip()
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_9fontTools_6feaLib_5lexer_5Lexer_17scan_anonymous_block(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_9fontTools_6feaLib_5lexer_5Lexer_16scan_anonymous_block[] = "Lexer.scan_anonymous_block(self, tag)";
-static PyMethodDef __pyx_mdef_9fontTools_6feaLib_5lexer_5Lexer_17scan_anonymous_block = {"scan_anonymous_block", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_9fontTools_6feaLib_5lexer_5Lexer_17scan_anonymous_block, METH_VARARGS|METH_KEYWORDS, __pyx_doc_9fontTools_6feaLib_5lexer_5Lexer_16scan_anonymous_block};
-static PyObject *__pyx_pw_9fontTools_6feaLib_5lexer_5Lexer_17scan_anonymous_block(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_self = 0;
- PyObject *__pyx_v_tag = 0;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("scan_anonymous_block (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_tag,0};
- PyObject* values[2] = {0,0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_tag)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("scan_anonymous_block", 1, 2, 2, 1); __PYX_ERR(0, 181, __pyx_L3_error)
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "scan_anonymous_block") < 0)) __PYX_ERR(0, 181, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- }
- __pyx_v_self = values[0];
- __pyx_v_tag = values[1];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("scan_anonymous_block", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 181, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("fontTools.feaLib.lexer.Lexer.scan_anonymous_block", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_9fontTools_6feaLib_5lexer_5Lexer_16scan_anonymous_block(__pyx_self, __pyx_v_self, __pyx_v_tag);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_9fontTools_6feaLib_5lexer_5Lexer_16scan_anonymous_block(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_tag) {
- PyObject *__pyx_v_location = NULL;
- PyObject *__pyx_v_regexp = NULL;
- PyObject *__pyx_v_split = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- Py_ssize_t __pyx_t_5;
- int __pyx_t_6;
- int __pyx_t_7;
- PyObject *__pyx_t_8 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("scan_anonymous_block", 0);
- __Pyx_INCREF(__pyx_v_tag);
-
- /* "fontTools/feaLib/lexer.py":182
- *
- * def scan_anonymous_block(self, tag):
- * location = self.location_() # <<<<<<<<<<<<<<
- * tag = tag.strip()
- * self.scan_until_(Lexer.CHAR_NEWLINE_)
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_location); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 182, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 182, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_v_location = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "fontTools/feaLib/lexer.py":183
- * def scan_anonymous_block(self, tag):
- * location = self.location_()
- * tag = tag.strip() # <<<<<<<<<<<<<<
- * self.scan_until_(Lexer.CHAR_NEWLINE_)
- * self.scan_over_(Lexer.CHAR_NEWLINE_)
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_tag, __pyx_n_s_strip); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 183, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 183, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF_SET(__pyx_v_tag, __pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "fontTools/feaLib/lexer.py":184
- * location = self.location_()
- * tag = tag.strip()
- * self.scan_until_(Lexer.CHAR_NEWLINE_) # <<<<<<<<<<<<<<
- * self.scan_over_(Lexer.CHAR_NEWLINE_)
- * regexp = r"}\s*" + tag + r"\s*;"
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_scan_until); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 184, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_Lexer); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 184, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_CHAR_NEWLINE); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 184, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 184, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "fontTools/feaLib/lexer.py":185
- * tag = tag.strip()
- * self.scan_until_(Lexer.CHAR_NEWLINE_)
- * self.scan_over_(Lexer.CHAR_NEWLINE_) # <<<<<<<<<<<<<<
- * regexp = r"}\s*" + tag + r"\s*;"
- * split = re.split(regexp, self.text_[self.pos_ :], maxsplit=1)
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_scan_over); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 185, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_Lexer); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 185, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_CHAR_NEWLINE); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 185, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 185, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "fontTools/feaLib/lexer.py":186
- * self.scan_until_(Lexer.CHAR_NEWLINE_)
- * self.scan_over_(Lexer.CHAR_NEWLINE_)
- * regexp = r"}\s*" + tag + r"\s*;" # <<<<<<<<<<<<<<
- * split = re.split(regexp, self.text_[self.pos_ :], maxsplit=1)
- * if len(split) != 2:
- */
- __pyx_t_1 = PyNumber_Add(__pyx_kp_u_s, __pyx_v_tag); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 186, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = PyNumber_Add(__pyx_t_1, __pyx_kp_u_s_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 186, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_v_regexp = __pyx_t_2;
- __pyx_t_2 = 0;
-
- /* "fontTools/feaLib/lexer.py":187
- * self.scan_over_(Lexer.CHAR_NEWLINE_)
- * regexp = r"}\s*" + tag + r"\s*;"
- * split = re.split(regexp, self.text_[self.pos_ :], maxsplit=1) # <<<<<<<<<<<<<<
- * if len(split) != 2:
- * raise FeatureLibError(
- */
- __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_re); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 187, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_split); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 187, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_text_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 187, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_pos); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 187, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = __Pyx_PyObject_GetSlice(__pyx_t_2, 0, 0, &__pyx_t_3, NULL, NULL, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 187, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 187, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_INCREF(__pyx_v_regexp);
- __Pyx_GIVEREF(__pyx_v_regexp);
- PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_regexp);
- __Pyx_GIVEREF(__pyx_t_4);
- PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4);
- __pyx_t_4 = 0;
- __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 187, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_maxsplit, __pyx_int_1) < 0) __PYX_ERR(0, 187, __pyx_L1_error)
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 187, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_v_split = __pyx_t_2;
- __pyx_t_2 = 0;
-
- /* "fontTools/feaLib/lexer.py":188
- * regexp = r"}\s*" + tag + r"\s*;"
- * split = re.split(regexp, self.text_[self.pos_ :], maxsplit=1)
- * if len(split) != 2: # <<<<<<<<<<<<<<
- * raise FeatureLibError(
- * "Expected '} %s;' to terminate anonymous block" % tag, location
- */
- __pyx_t_5 = PyObject_Length(__pyx_v_split); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 188, __pyx_L1_error)
- __pyx_t_6 = ((__pyx_t_5 != 2) != 0);
- if (unlikely(__pyx_t_6)) {
-
- /* "fontTools/feaLib/lexer.py":189
- * split = re.split(regexp, self.text_[self.pos_ :], maxsplit=1)
- * if len(split) != 2:
- * raise FeatureLibError( # <<<<<<<<<<<<<<
- * "Expected '} %s;' to terminate anonymous block" % tag, location
- * )
- */
- __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_FeatureLibError); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 189, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
-
- /* "fontTools/feaLib/lexer.py":190
- * if len(split) != 2:
- * raise FeatureLibError(
- * "Expected '} %s;' to terminate anonymous block" % tag, location # <<<<<<<<<<<<<<
- * )
- * self.pos_ += len(split[0])
- */
- __pyx_t_3 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_Expected_s_to_terminate_anonymou, __pyx_v_tag); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 190, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_1 = NULL;
- __pyx_t_7 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_1)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- __pyx_t_7 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_4)) {
- PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_t_3, __pyx_v_location};
- __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 189, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
- PyObject *__pyx_temp[3] = {__pyx_t_1, __pyx_t_3, __pyx_v_location};
- __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 189, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else
- #endif
- {
- __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 189, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- if (__pyx_t_1) {
- __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1); __pyx_t_1 = NULL;
- }
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_3);
- __Pyx_INCREF(__pyx_v_location);
- __Pyx_GIVEREF(__pyx_v_location);
- PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_location);
- __pyx_t_3 = 0;
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 189, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- }
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_Raise(__pyx_t_2, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __PYX_ERR(0, 189, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":188
- * regexp = r"}\s*" + tag + r"\s*;"
- * split = re.split(regexp, self.text_[self.pos_ :], maxsplit=1)
- * if len(split) != 2: # <<<<<<<<<<<<<<
- * raise FeatureLibError(
- * "Expected '} %s;' to terminate anonymous block" % tag, location
- */
- }
-
- /* "fontTools/feaLib/lexer.py":192
- * "Expected '} %s;' to terminate anonymous block" % tag, location
- * )
- * self.pos_ += len(split[0]) # <<<<<<<<<<<<<<
- * return (Lexer.ANONYMOUS_BLOCK, split[0], location)
- *
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_pos); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 192, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_split, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 192, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = PyObject_Length(__pyx_t_4); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 192, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 192, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_8 = PyNumber_InPlaceAdd(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 192, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_pos, __pyx_t_8) < 0) __PYX_ERR(0, 192, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
-
- /* "fontTools/feaLib/lexer.py":193
- * )
- * self.pos_ += len(split[0])
- * return (Lexer.ANONYMOUS_BLOCK, split[0], location) # <<<<<<<<<<<<<<
- *
- *
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_Lexer); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 193, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_ANONYMOUS_BLOCK); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 193, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_split, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 193, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 193, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_4);
- PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_8);
- PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_8);
- __Pyx_INCREF(__pyx_v_location);
- __Pyx_GIVEREF(__pyx_v_location);
- PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_location);
- __pyx_t_4 = 0;
- __pyx_t_8 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
- /* "fontTools/feaLib/lexer.py":181
- * self.pos_ = p
- *
- * def scan_anonymous_block(self, tag): # <<<<<<<<<<<<<<
- * location = self.location_()
- * tag = tag.strip()
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_8);
- __Pyx_AddTraceback("fontTools.feaLib.lexer.Lexer.scan_anonymous_block", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_location);
- __Pyx_XDECREF(__pyx_v_regexp);
- __Pyx_XDECREF(__pyx_v_split);
- __Pyx_XDECREF(__pyx_v_tag);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "fontTools/feaLib/lexer.py":211
- * """
- *
- * def __init__(self, featurefile, *, includeDir=None): # <<<<<<<<<<<<<<
- * """Initializes an IncludingLexer.
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_9fontTools_6feaLib_5lexer_14IncludingLexer_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_9fontTools_6feaLib_5lexer_14IncludingLexer___init__[] = "IncludingLexer.__init__(self, featurefile, *, includeDir=None)\nInitializes an IncludingLexer.\n\n Behavior:\n If includeDir is passed, it will be used to determine the top-level\n include directory to use for all encountered include statements. If it is\n not passed, ``os.path.dirname(featurefile)`` will be considered the\n include directory.\n ";
-static PyMethodDef __pyx_mdef_9fontTools_6feaLib_5lexer_14IncludingLexer_1__init__ = {"__init__", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_9fontTools_6feaLib_5lexer_14IncludingLexer_1__init__, METH_VARARGS|METH_KEYWORDS, __pyx_doc_9fontTools_6feaLib_5lexer_14IncludingLexer___init__};
-static PyObject *__pyx_pw_9fontTools_6feaLib_5lexer_14IncludingLexer_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_self = 0;
- PyObject *__pyx_v_featurefile = 0;
- PyObject *__pyx_v_includeDir = 0;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_featurefile,&__pyx_n_s_includeDir,0};
- PyObject* values[3] = {0,0,0};
- values[2] = ((PyObject *)((PyObject *)Py_None));
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_featurefile)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); __PYX_ERR(0, 211, __pyx_L3_error)
- }
- }
- if (kw_args == 1) {
- const Py_ssize_t index = 2;
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, *__pyx_pyargnames[index]);
- if (value) { values[index] = value; kw_args--; }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 211, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- }
- __pyx_v_self = values[0];
- __pyx_v_featurefile = values[1];
- __pyx_v_includeDir = values[2];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 211, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("fontTools.feaLib.lexer.IncludingLexer.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_9fontTools_6feaLib_5lexer_14IncludingLexer___init__(__pyx_self, __pyx_v_self, __pyx_v_featurefile, __pyx_v_includeDir);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_9fontTools_6feaLib_5lexer_14IncludingLexer___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_featurefile, PyObject *__pyx_v_includeDir) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("__init__", 0);
-
- /* "fontTools/feaLib/lexer.py":221
- * """
- *
- * self.lexers_ = [self.make_lexer_(featurefile)] # <<<<<<<<<<<<<<
- * self.featurefilepath = self.lexers_[0].filename_
- * self.includeDir = includeDir
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_make_lexer); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 221, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_featurefile) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_featurefile);
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 221, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 221, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_1);
- PyList_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
- __pyx_t_1 = 0;
- if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_lexers, __pyx_t_2) < 0) __PYX_ERR(0, 221, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "fontTools/feaLib/lexer.py":222
- *
- * self.lexers_ = [self.make_lexer_(featurefile)]
- * self.featurefilepath = self.lexers_[0].filename_ # <<<<<<<<<<<<<<
- * self.includeDir = includeDir
- *
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_lexers); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 222, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_2, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 222, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_filename_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 222, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_featurefilepath, __pyx_t_2) < 0) __PYX_ERR(0, 222, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "fontTools/feaLib/lexer.py":223
- * self.lexers_ = [self.make_lexer_(featurefile)]
- * self.featurefilepath = self.lexers_[0].filename_
- * self.includeDir = includeDir # <<<<<<<<<<<<<<
- *
- * def __iter__(self):
- */
- if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_includeDir, __pyx_v_includeDir) < 0) __PYX_ERR(0, 223, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":211
- * """
- *
- * def __init__(self, featurefile, *, includeDir=None): # <<<<<<<<<<<<<<
- * """Initializes an IncludingLexer.
- *
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("fontTools.feaLib.lexer.IncludingLexer.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "fontTools/feaLib/lexer.py":225
- * self.includeDir = includeDir
- *
- * def __iter__(self): # <<<<<<<<<<<<<<
- * return self
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_9fontTools_6feaLib_5lexer_14IncludingLexer_3__iter__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
-static char __pyx_doc_9fontTools_6feaLib_5lexer_14IncludingLexer_2__iter__[] = "IncludingLexer.__iter__(self)";
-static PyMethodDef __pyx_mdef_9fontTools_6feaLib_5lexer_14IncludingLexer_3__iter__ = {"__iter__", (PyCFunction)__pyx_pw_9fontTools_6feaLib_5lexer_14IncludingLexer_3__iter__, METH_O, __pyx_doc_9fontTools_6feaLib_5lexer_14IncludingLexer_2__iter__};
-static PyObject *__pyx_pw_9fontTools_6feaLib_5lexer_14IncludingLexer_3__iter__(PyObject *__pyx_self, PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
- __pyx_r = __pyx_pf_9fontTools_6feaLib_5lexer_14IncludingLexer_2__iter__(__pyx_self, ((PyObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_9fontTools_6feaLib_5lexer_14IncludingLexer_2__iter__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__iter__", 0);
-
- /* "fontTools/feaLib/lexer.py":226
- *
- * def __iter__(self):
- * return self # <<<<<<<<<<<<<<
- *
- * def next(self): # Python 2
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_self);
- __pyx_r = __pyx_v_self;
- goto __pyx_L0;
-
- /* "fontTools/feaLib/lexer.py":225
- * self.includeDir = includeDir
- *
- * def __iter__(self): # <<<<<<<<<<<<<<
- * return self
- *
- */
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "fontTools/feaLib/lexer.py":228
- * return self
- *
- * def next(self): # Python 2 # <<<<<<<<<<<<<<
- * return self.__next__()
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_9fontTools_6feaLib_5lexer_14IncludingLexer_5next(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
-static char __pyx_doc_9fontTools_6feaLib_5lexer_14IncludingLexer_4next[] = "IncludingLexer.next(self)";
-static PyMethodDef __pyx_mdef_9fontTools_6feaLib_5lexer_14IncludingLexer_5next = {"next", (PyCFunction)__pyx_pw_9fontTools_6feaLib_5lexer_14IncludingLexer_5next, METH_O, __pyx_doc_9fontTools_6feaLib_5lexer_14IncludingLexer_4next};
-static PyObject *__pyx_pw_9fontTools_6feaLib_5lexer_14IncludingLexer_5next(PyObject *__pyx_self, PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("next (wrapper)", 0);
- __pyx_r = __pyx_pf_9fontTools_6feaLib_5lexer_14IncludingLexer_4next(__pyx_self, ((PyObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_9fontTools_6feaLib_5lexer_14IncludingLexer_4next(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("next", 0);
-
- /* "fontTools/feaLib/lexer.py":229
- *
- * def next(self): # Python 2
- * return self.__next__() # <<<<<<<<<<<<<<
- *
- * def __next__(self): # Python 3
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_next); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 229, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 229, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "fontTools/feaLib/lexer.py":228
- * return self
- *
- * def next(self): # Python 2 # <<<<<<<<<<<<<<
- * return self.__next__()
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("fontTools.feaLib.lexer.IncludingLexer.next", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "fontTools/feaLib/lexer.py":231
- * return self.__next__()
- *
- * def __next__(self): # Python 3 # <<<<<<<<<<<<<<
- * while self.lexers_:
- * lexer = self.lexers_[-1]
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_9fontTools_6feaLib_5lexer_14IncludingLexer_7__next__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
-static char __pyx_doc_9fontTools_6feaLib_5lexer_14IncludingLexer_6__next__[] = "IncludingLexer.__next__(self)";
-static PyMethodDef __pyx_mdef_9fontTools_6feaLib_5lexer_14IncludingLexer_7__next__ = {"__next__", (PyCFunction)__pyx_pw_9fontTools_6feaLib_5lexer_14IncludingLexer_7__next__, METH_O, __pyx_doc_9fontTools_6feaLib_5lexer_14IncludingLexer_6__next__};
-static PyObject *__pyx_pw_9fontTools_6feaLib_5lexer_14IncludingLexer_7__next__(PyObject *__pyx_self, PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__next__ (wrapper)", 0);
- __pyx_r = __pyx_pf_9fontTools_6feaLib_5lexer_14IncludingLexer_6__next__(__pyx_self, ((PyObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_9fontTools_6feaLib_5lexer_14IncludingLexer_6__next__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
- PyObject *__pyx_v_lexer = NULL;
- PyObject *__pyx_v_token_type = NULL;
- PyObject *__pyx_v_token = NULL;
- PyObject *__pyx_v_location = NULL;
- PyObject *__pyx_v_fname_type = NULL;
- PyObject *__pyx_v_fname_token = NULL;
- PyObject *__pyx_v_fname_location = NULL;
- PyObject *__pyx_v_path = NULL;
- PyObject *__pyx_v_curpath = NULL;
- PyObject *__pyx_v_err = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- PyObject *__pyx_t_8 = NULL;
- PyObject *__pyx_t_9 = NULL;
- PyObject *(*__pyx_t_10)(PyObject *);
- int __pyx_t_11;
- int __pyx_t_12;
- int __pyx_t_13;
- Py_ssize_t __pyx_t_14;
- int __pyx_t_15;
- PyObject *__pyx_t_16 = NULL;
- PyObject *__pyx_t_17 = NULL;
- int __pyx_t_18;
- char const *__pyx_t_19;
- PyObject *__pyx_t_20 = NULL;
- PyObject *__pyx_t_21 = NULL;
- PyObject *__pyx_t_22 = NULL;
- PyObject *__pyx_t_23 = NULL;
- PyObject *__pyx_t_24 = NULL;
- PyObject *__pyx_t_25 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("__next__", 0);
-
- /* "fontTools/feaLib/lexer.py":232
- *
- * def __next__(self): # Python 3
- * while self.lexers_: # <<<<<<<<<<<<<<
- * lexer = self.lexers_[-1]
- * try:
- */
- while (1) {
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_lexers); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 232, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 232, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- if (!__pyx_t_2) break;
-
- /* "fontTools/feaLib/lexer.py":233
- * def __next__(self): # Python 3
- * while self.lexers_:
- * lexer = self.lexers_[-1] # <<<<<<<<<<<<<<
- * try:
- * token_type, token, location = next(lexer)
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_lexers); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 233, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_1, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 233, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_XDECREF_SET(__pyx_v_lexer, __pyx_t_3);
- __pyx_t_3 = 0;
-
- /* "fontTools/feaLib/lexer.py":234
- * while self.lexers_:
- * lexer = self.lexers_[-1]
- * try: # <<<<<<<<<<<<<<
- * token_type, token, location = next(lexer)
- * except StopIteration:
- */
- {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6);
- __Pyx_XGOTREF(__pyx_t_4);
- __Pyx_XGOTREF(__pyx_t_5);
- __Pyx_XGOTREF(__pyx_t_6);
- /*try:*/ {
-
- /* "fontTools/feaLib/lexer.py":235
- * lexer = self.lexers_[-1]
- * try:
- * token_type, token, location = next(lexer) # <<<<<<<<<<<<<<
- * except StopIteration:
- * self.lexers_.pop()
- */
- __pyx_t_3 = __Pyx_PyIter_Next(__pyx_v_lexer); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 235, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_3);
- if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
- PyObject* sequence = __pyx_t_3;
- Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
- if (unlikely(size != 3)) {
- if (size > 3) __Pyx_RaiseTooManyValuesError(3);
- else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
- __PYX_ERR(0, 235, __pyx_L5_error)
- }
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- if (likely(PyTuple_CheckExact(sequence))) {
- __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0);
- __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1);
- __pyx_t_8 = PyTuple_GET_ITEM(sequence, 2);
- } else {
- __pyx_t_1 = PyList_GET_ITEM(sequence, 0);
- __pyx_t_7 = PyList_GET_ITEM(sequence, 1);
- __pyx_t_8 = PyList_GET_ITEM(sequence, 2);
- }
- __Pyx_INCREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_t_7);
- __Pyx_INCREF(__pyx_t_8);
- #else
- __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 235, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 235, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_7);
- __pyx_t_8 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 235, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_8);
- #endif
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else {
- Py_ssize_t index = -1;
- __pyx_t_9 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 235, __pyx_L5_error)
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_10 = Py_TYPE(__pyx_t_9)->tp_iternext;
- index = 0; __pyx_t_1 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_1)) goto __pyx_L13_unpacking_failed;
- __Pyx_GOTREF(__pyx_t_1);
- index = 1; __pyx_t_7 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_7)) goto __pyx_L13_unpacking_failed;
- __Pyx_GOTREF(__pyx_t_7);
- index = 2; __pyx_t_8 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_8)) goto __pyx_L13_unpacking_failed;
- __Pyx_GOTREF(__pyx_t_8);
- if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 3) < 0) __PYX_ERR(0, 235, __pyx_L5_error)
- __pyx_t_10 = NULL;
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- goto __pyx_L14_unpacking_done;
- __pyx_L13_unpacking_failed:;
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- __pyx_t_10 = NULL;
- if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
- __PYX_ERR(0, 235, __pyx_L5_error)
- __pyx_L14_unpacking_done:;
- }
- __Pyx_XDECREF_SET(__pyx_v_token_type, __pyx_t_1);
- __pyx_t_1 = 0;
- __Pyx_XDECREF_SET(__pyx_v_token, __pyx_t_7);
- __pyx_t_7 = 0;
- __Pyx_XDECREF_SET(__pyx_v_location, __pyx_t_8);
- __pyx_t_8 = 0;
-
- /* "fontTools/feaLib/lexer.py":234
- * while self.lexers_:
- * lexer = self.lexers_[-1]
- * try: # <<<<<<<<<<<<<<
- * token_type, token, location = next(lexer)
- * except StopIteration:
- */
- }
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- goto __pyx_L12_try_end;
- __pyx_L5_error:;
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
-
- /* "fontTools/feaLib/lexer.py":236
- * try:
- * token_type, token, location = next(lexer)
- * except StopIteration: # <<<<<<<<<<<<<<
- * self.lexers_.pop()
- * continue
- */
- __pyx_t_11 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_StopIteration);
- if (__pyx_t_11) {
- __Pyx_AddTraceback("fontTools.feaLib.lexer.IncludingLexer.__next__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_8, &__pyx_t_7) < 0) __PYX_ERR(0, 236, __pyx_L7_except_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GOTREF(__pyx_t_8);
- __Pyx_GOTREF(__pyx_t_7);
-
- /* "fontTools/feaLib/lexer.py":237
- * token_type, token, location = next(lexer)
- * except StopIteration:
- * self.lexers_.pop() # <<<<<<<<<<<<<<
- * continue
- * if token_type is Lexer.NAME and token == "include":
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_lexers); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 237, __pyx_L7_except_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_9 = __Pyx_PyObject_Pop(__pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 237, __pyx_L7_except_error)
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
-
- /* "fontTools/feaLib/lexer.py":238
- * except StopIteration:
- * self.lexers_.pop()
- * continue # <<<<<<<<<<<<<<
- * if token_type is Lexer.NAME and token == "include":
- * fname_type, fname_token, fname_location = lexer.next()
- */
- goto __pyx_L16_except_continue;
- __pyx_L16_except_continue:;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- goto __pyx_L11_try_continue;
- }
- goto __pyx_L7_except_error;
- __pyx_L7_except_error:;
-
- /* "fontTools/feaLib/lexer.py":234
- * while self.lexers_:
- * lexer = self.lexers_[-1]
- * try: # <<<<<<<<<<<<<<
- * token_type, token, location = next(lexer)
- * except StopIteration:
- */
- __Pyx_XGIVEREF(__pyx_t_4);
- __Pyx_XGIVEREF(__pyx_t_5);
- __Pyx_XGIVEREF(__pyx_t_6);
- __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
- goto __pyx_L1_error;
- __pyx_L11_try_continue:;
- __Pyx_XGIVEREF(__pyx_t_4);
- __Pyx_XGIVEREF(__pyx_t_5);
- __Pyx_XGIVEREF(__pyx_t_6);
- __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
- goto __pyx_L3_continue;
- __pyx_L12_try_end:;
- }
-
- /* "fontTools/feaLib/lexer.py":239
- * self.lexers_.pop()
- * continue
- * if token_type is Lexer.NAME and token == "include": # <<<<<<<<<<<<<<
- * fname_type, fname_token, fname_location = lexer.next()
- * if fname_type is not Lexer.FILENAME:
- */
- __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_Lexer); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 239, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_NAME); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 239, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- __pyx_t_12 = (__pyx_v_token_type == __pyx_t_8);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- __pyx_t_13 = (__pyx_t_12 != 0);
- if (__pyx_t_13) {
- } else {
- __pyx_t_2 = __pyx_t_13;
- goto __pyx_L18_bool_binop_done;
- }
- __pyx_t_13 = (__Pyx_PyUnicode_Equals(__pyx_v_token, __pyx_n_u_include, Py_EQ)); if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 239, __pyx_L1_error)
- __pyx_t_2 = __pyx_t_13;
- __pyx_L18_bool_binop_done:;
- if (__pyx_t_2) {
-
- /* "fontTools/feaLib/lexer.py":240
- * continue
- * if token_type is Lexer.NAME and token == "include":
- * fname_type, fname_token, fname_location = lexer.next() # <<<<<<<<<<<<<<
- * if fname_type is not Lexer.FILENAME:
- * raise FeatureLibError("Expected file name", fname_location)
- */
- __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_lexer, __pyx_n_s_next_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 240, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_7);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_7, function);
- }
- }
- __pyx_t_8 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_7);
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 240, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- if ((likely(PyTuple_CheckExact(__pyx_t_8))) || (PyList_CheckExact(__pyx_t_8))) {
- PyObject* sequence = __pyx_t_8;
- Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
- if (unlikely(size != 3)) {
- if (size > 3) __Pyx_RaiseTooManyValuesError(3);
- else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
- __PYX_ERR(0, 240, __pyx_L1_error)
- }
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- if (likely(PyTuple_CheckExact(sequence))) {
- __pyx_t_7 = PyTuple_GET_ITEM(sequence, 0);
- __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1);
- __pyx_t_9 = PyTuple_GET_ITEM(sequence, 2);
- } else {
- __pyx_t_7 = PyList_GET_ITEM(sequence, 0);
- __pyx_t_3 = PyList_GET_ITEM(sequence, 1);
- __pyx_t_9 = PyList_GET_ITEM(sequence, 2);
- }
- __Pyx_INCREF(__pyx_t_7);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_9);
- #else
- __pyx_t_7 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 240, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 240, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_9 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 240, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- #endif
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- } else {
- Py_ssize_t index = -1;
- __pyx_t_1 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 240, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- __pyx_t_10 = Py_TYPE(__pyx_t_1)->tp_iternext;
- index = 0; __pyx_t_7 = __pyx_t_10(__pyx_t_1); if (unlikely(!__pyx_t_7)) goto __pyx_L20_unpacking_failed;
- __Pyx_GOTREF(__pyx_t_7);
- index = 1; __pyx_t_3 = __pyx_t_10(__pyx_t_1); if (unlikely(!__pyx_t_3)) goto __pyx_L20_unpacking_failed;
- __Pyx_GOTREF(__pyx_t_3);
- index = 2; __pyx_t_9 = __pyx_t_10(__pyx_t_1); if (unlikely(!__pyx_t_9)) goto __pyx_L20_unpacking_failed;
- __Pyx_GOTREF(__pyx_t_9);
- if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_1), 3) < 0) __PYX_ERR(0, 240, __pyx_L1_error)
- __pyx_t_10 = NULL;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- goto __pyx_L21_unpacking_done;
- __pyx_L20_unpacking_failed:;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_10 = NULL;
- if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
- __PYX_ERR(0, 240, __pyx_L1_error)
- __pyx_L21_unpacking_done:;
- }
- __Pyx_XDECREF_SET(__pyx_v_fname_type, __pyx_t_7);
- __pyx_t_7 = 0;
- __Pyx_XDECREF_SET(__pyx_v_fname_token, __pyx_t_3);
- __pyx_t_3 = 0;
- __Pyx_XDECREF_SET(__pyx_v_fname_location, __pyx_t_9);
- __pyx_t_9 = 0;
-
- /* "fontTools/feaLib/lexer.py":241
- * if token_type is Lexer.NAME and token == "include":
- * fname_type, fname_token, fname_location = lexer.next()
- * if fname_type is not Lexer.FILENAME: # <<<<<<<<<<<<<<
- * raise FeatureLibError("Expected file name", fname_location)
- * # semi_type, semi_token, semi_location = lexer.next()
- */
- __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_Lexer); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 241, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_FILENAME); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 241, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- __pyx_t_2 = (__pyx_v_fname_type != __pyx_t_9);
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- __pyx_t_13 = (__pyx_t_2 != 0);
- if (unlikely(__pyx_t_13)) {
-
- /* "fontTools/feaLib/lexer.py":242
- * fname_type, fname_token, fname_location = lexer.next()
- * if fname_type is not Lexer.FILENAME:
- * raise FeatureLibError("Expected file name", fname_location) # <<<<<<<<<<<<<<
- * # semi_type, semi_token, semi_location = lexer.next()
- * # if semi_type is not Lexer.SYMBOL or semi_token != ";":
- */
- __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_FeatureLibError); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 242, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- __pyx_t_3 = NULL;
- __pyx_t_11 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_8);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_8, function);
- __pyx_t_11 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_8)) {
- PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_kp_u_Expected_file_name, __pyx_v_fname_location};
- __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 242, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_9);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
- PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_kp_u_Expected_file_name, __pyx_v_fname_location};
- __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 242, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_9);
- } else
- #endif
- {
- __pyx_t_7 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 242, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- if (__pyx_t_3) {
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3); __pyx_t_3 = NULL;
- }
- __Pyx_INCREF(__pyx_kp_u_Expected_file_name);
- __Pyx_GIVEREF(__pyx_kp_u_Expected_file_name);
- PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_11, __pyx_kp_u_Expected_file_name);
- __Pyx_INCREF(__pyx_v_fname_location);
- __Pyx_GIVEREF(__pyx_v_fname_location);
- PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_11, __pyx_v_fname_location);
- __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_7, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 242, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- }
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_Raise(__pyx_t_9, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- __PYX_ERR(0, 242, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":241
- * if token_type is Lexer.NAME and token == "include":
- * fname_type, fname_token, fname_location = lexer.next()
- * if fname_type is not Lexer.FILENAME: # <<<<<<<<<<<<<<
- * raise FeatureLibError("Expected file name", fname_location)
- * # semi_type, semi_token, semi_location = lexer.next()
- */
- }
-
- /* "fontTools/feaLib/lexer.py":246
- * # if semi_type is not Lexer.SYMBOL or semi_token != ";":
- * # raise FeatureLibError("Expected ';'", semi_location)
- * if os.path.isabs(fname_token): # <<<<<<<<<<<<<<
- * path = fname_token
- * else:
- */
- __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_os); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 246, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_path); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 246, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_isabs); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 246, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- __pyx_t_7 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
- __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8);
- if (likely(__pyx_t_7)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
- __Pyx_INCREF(__pyx_t_7);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_8, function);
- }
- }
- __pyx_t_9 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_7, __pyx_v_fname_token) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_v_fname_token);
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 246, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 246, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- if (__pyx_t_13) {
-
- /* "fontTools/feaLib/lexer.py":247
- * # raise FeatureLibError("Expected ';'", semi_location)
- * if os.path.isabs(fname_token):
- * path = fname_token # <<<<<<<<<<<<<<
- * else:
- * if self.includeDir is not None:
- */
- __Pyx_INCREF(__pyx_v_fname_token);
- __Pyx_XDECREF_SET(__pyx_v_path, __pyx_v_fname_token);
-
- /* "fontTools/feaLib/lexer.py":246
- * # if semi_type is not Lexer.SYMBOL or semi_token != ";":
- * # raise FeatureLibError("Expected ';'", semi_location)
- * if os.path.isabs(fname_token): # <<<<<<<<<<<<<<
- * path = fname_token
- * else:
- */
- goto __pyx_L23;
- }
-
- /* "fontTools/feaLib/lexer.py":249
- * path = fname_token
- * else:
- * if self.includeDir is not None: # <<<<<<<<<<<<<<
- * curpath = self.includeDir
- * elif self.featurefilepath is not None:
- */
- /*else*/ {
- __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_includeDir); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 249, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- __pyx_t_13 = (__pyx_t_9 != Py_None);
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- __pyx_t_2 = (__pyx_t_13 != 0);
- if (__pyx_t_2) {
-
- /* "fontTools/feaLib/lexer.py":250
- * else:
- * if self.includeDir is not None:
- * curpath = self.includeDir # <<<<<<<<<<<<<<
- * elif self.featurefilepath is not None:
- * curpath = os.path.dirname(self.featurefilepath)
- */
- __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_includeDir); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 250, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_XDECREF_SET(__pyx_v_curpath, __pyx_t_9);
- __pyx_t_9 = 0;
-
- /* "fontTools/feaLib/lexer.py":249
- * path = fname_token
- * else:
- * if self.includeDir is not None: # <<<<<<<<<<<<<<
- * curpath = self.includeDir
- * elif self.featurefilepath is not None:
- */
- goto __pyx_L24;
- }
-
- /* "fontTools/feaLib/lexer.py":251
- * if self.includeDir is not None:
- * curpath = self.includeDir
- * elif self.featurefilepath is not None: # <<<<<<<<<<<<<<
- * curpath = os.path.dirname(self.featurefilepath)
- * else:
- */
- __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_featurefilepath); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 251, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- __pyx_t_2 = (__pyx_t_9 != Py_None);
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- __pyx_t_13 = (__pyx_t_2 != 0);
- if (__pyx_t_13) {
-
- /* "fontTools/feaLib/lexer.py":252
- * curpath = self.includeDir
- * elif self.featurefilepath is not None:
- * curpath = os.path.dirname(self.featurefilepath) # <<<<<<<<<<<<<<
- * else:
- * # if the IncludingLexer was initialized from an in-memory
- */
- __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_os); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 252, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_path); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 252, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_dirname); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 252, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_featurefilepath); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 252, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_8);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_8, function);
- }
- }
- __pyx_t_9 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_3, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7);
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 252, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_XDECREF_SET(__pyx_v_curpath, __pyx_t_9);
- __pyx_t_9 = 0;
-
- /* "fontTools/feaLib/lexer.py":251
- * if self.includeDir is not None:
- * curpath = self.includeDir
- * elif self.featurefilepath is not None: # <<<<<<<<<<<<<<
- * curpath = os.path.dirname(self.featurefilepath)
- * else:
- */
- goto __pyx_L24;
- }
-
- /* "fontTools/feaLib/lexer.py":258
- * # its filesystem path, therefore we fall back to using the
- * # current working directory to resolve relative includes
- * curpath = os.getcwd() # <<<<<<<<<<<<<<
- * path = os.path.join(curpath, fname_token)
- * if len(self.lexers_) >= 5:
- */
- /*else*/ {
- __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_os); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 258, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_getcwd); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 258, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- __pyx_t_8 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
- __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
- if (likely(__pyx_t_8)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
- __Pyx_INCREF(__pyx_t_8);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_7, function);
- }
- }
- __pyx_t_9 = (__pyx_t_8) ? __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_8) : __Pyx_PyObject_CallNoArg(__pyx_t_7);
- __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
- if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 258, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_XDECREF_SET(__pyx_v_curpath, __pyx_t_9);
- __pyx_t_9 = 0;
- }
- __pyx_L24:;
-
- /* "fontTools/feaLib/lexer.py":259
- * # current working directory to resolve relative includes
- * curpath = os.getcwd()
- * path = os.path.join(curpath, fname_token) # <<<<<<<<<<<<<<
- * if len(self.lexers_) >= 5:
- * raise FeatureLibError("Too many recursive includes", fname_location)
- */
- __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_os); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 259, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_path); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 259, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_join); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 259, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- __pyx_t_8 = NULL;
- __pyx_t_11 = 0;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
- __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
- if (likely(__pyx_t_8)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
- __Pyx_INCREF(__pyx_t_8);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_7, function);
- __pyx_t_11 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_7)) {
- PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_v_curpath, __pyx_v_fname_token};
- __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 259, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_GOTREF(__pyx_t_9);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
- PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_v_curpath, __pyx_v_fname_token};
- __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 259, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_GOTREF(__pyx_t_9);
- } else
- #endif
- {
- __pyx_t_3 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 259, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- if (__pyx_t_8) {
- __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_8); __pyx_t_8 = NULL;
- }
- __Pyx_INCREF(__pyx_v_curpath);
- __Pyx_GIVEREF(__pyx_v_curpath);
- PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_11, __pyx_v_curpath);
- __Pyx_INCREF(__pyx_v_fname_token);
- __Pyx_GIVEREF(__pyx_v_fname_token);
- PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_11, __pyx_v_fname_token);
- __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_3, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 259, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- }
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_XDECREF_SET(__pyx_v_path, __pyx_t_9);
- __pyx_t_9 = 0;
- }
- __pyx_L23:;
-
- /* "fontTools/feaLib/lexer.py":260
- * curpath = os.getcwd()
- * path = os.path.join(curpath, fname_token)
- * if len(self.lexers_) >= 5: # <<<<<<<<<<<<<<
- * raise FeatureLibError("Too many recursive includes", fname_location)
- * try:
- */
- __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_lexers); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 260, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- __pyx_t_14 = PyObject_Length(__pyx_t_9); if (unlikely(__pyx_t_14 == ((Py_ssize_t)-1))) __PYX_ERR(0, 260, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- __pyx_t_13 = ((__pyx_t_14 >= 5) != 0);
- if (unlikely(__pyx_t_13)) {
-
- /* "fontTools/feaLib/lexer.py":261
- * path = os.path.join(curpath, fname_token)
- * if len(self.lexers_) >= 5:
- * raise FeatureLibError("Too many recursive includes", fname_location) # <<<<<<<<<<<<<<
- * try:
- * self.lexers_.append(self.make_lexer_(path))
- */
- __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_FeatureLibError); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 261, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __pyx_t_3 = NULL;
- __pyx_t_11 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_7);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_7, function);
- __pyx_t_11 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_7)) {
- PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_kp_u_Too_many_recursive_includes, __pyx_v_fname_location};
- __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 261, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_9);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
- PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_kp_u_Too_many_recursive_includes, __pyx_v_fname_location};
- __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 261, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_9);
- } else
- #endif
- {
- __pyx_t_8 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 261, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- if (__pyx_t_3) {
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3); __pyx_t_3 = NULL;
- }
- __Pyx_INCREF(__pyx_kp_u_Too_many_recursive_includes);
- __Pyx_GIVEREF(__pyx_kp_u_Too_many_recursive_includes);
- PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_11, __pyx_kp_u_Too_many_recursive_includes);
- __Pyx_INCREF(__pyx_v_fname_location);
- __Pyx_GIVEREF(__pyx_v_fname_location);
- PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_11, __pyx_v_fname_location);
- __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_8, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 261, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- }
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_Raise(__pyx_t_9, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- __PYX_ERR(0, 261, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":260
- * curpath = os.getcwd()
- * path = os.path.join(curpath, fname_token)
- * if len(self.lexers_) >= 5: # <<<<<<<<<<<<<<
- * raise FeatureLibError("Too many recursive includes", fname_location)
- * try:
- */
- }
-
- /* "fontTools/feaLib/lexer.py":262
- * if len(self.lexers_) >= 5:
- * raise FeatureLibError("Too many recursive includes", fname_location)
- * try: # <<<<<<<<<<<<<<
- * self.lexers_.append(self.make_lexer_(path))
- * except FileNotFoundError as err:
- */
- {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ExceptionSave(&__pyx_t_6, &__pyx_t_5, &__pyx_t_4);
- __Pyx_XGOTREF(__pyx_t_6);
- __Pyx_XGOTREF(__pyx_t_5);
- __Pyx_XGOTREF(__pyx_t_4);
- /*try:*/ {
-
- /* "fontTools/feaLib/lexer.py":263
- * raise FeatureLibError("Too many recursive includes", fname_location)
- * try:
- * self.lexers_.append(self.make_lexer_(path)) # <<<<<<<<<<<<<<
- * except FileNotFoundError as err:
- * raise IncludedFeaNotFound(fname_token, fname_location) from err
- */
- __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_lexers); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 263, __pyx_L26_error)
- __Pyx_GOTREF(__pyx_t_9);
- __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_make_lexer); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 263, __pyx_L26_error)
- __Pyx_GOTREF(__pyx_t_8);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_8);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_8, function);
- }
- }
- __pyx_t_7 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_3, __pyx_v_path) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_v_path);
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 263, __pyx_L26_error)
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- __pyx_t_15 = __Pyx_PyObject_Append(__pyx_t_9, __pyx_t_7); if (unlikely(__pyx_t_15 == ((int)-1))) __PYX_ERR(0, 263, __pyx_L26_error)
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-
- /* "fontTools/feaLib/lexer.py":262
- * if len(self.lexers_) >= 5:
- * raise FeatureLibError("Too many recursive includes", fname_location)
- * try: # <<<<<<<<<<<<<<
- * self.lexers_.append(self.make_lexer_(path))
- * except FileNotFoundError as err:
- */
- }
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- goto __pyx_L33_try_end;
- __pyx_L26_error:;
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
-
- /* "fontTools/feaLib/lexer.py":264
- * try:
- * self.lexers_.append(self.make_lexer_(path))
- * except FileNotFoundError as err: # <<<<<<<<<<<<<<
- * raise IncludedFeaNotFound(fname_token, fname_location) from err
- * else:
- */
- __Pyx_ErrFetch(&__pyx_t_7, &__pyx_t_9, &__pyx_t_8);
- __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_FileNotFoundError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 264, __pyx_L28_except_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_11 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_7, __pyx_t_3);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_ErrRestore(__pyx_t_7, __pyx_t_9, __pyx_t_8);
- __pyx_t_7 = 0; __pyx_t_9 = 0; __pyx_t_8 = 0;
- if (__pyx_t_11) {
- __Pyx_AddTraceback("fontTools.feaLib.lexer.IncludingLexer.__next__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- if (__Pyx_GetException(&__pyx_t_8, &__pyx_t_9, &__pyx_t_7) < 0) __PYX_ERR(0, 264, __pyx_L28_except_error)
- __Pyx_GOTREF(__pyx_t_8);
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_INCREF(__pyx_t_9);
- __pyx_v_err = __pyx_t_9;
- /*try:*/ {
-
- /* "fontTools/feaLib/lexer.py":265
- * self.lexers_.append(self.make_lexer_(path))
- * except FileNotFoundError as err:
- * raise IncludedFeaNotFound(fname_token, fname_location) from err # <<<<<<<<<<<<<<
- * else:
- * return (token_type, token, location)
- */
- __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_IncludedFeaNotFound); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 265, __pyx_L39_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_16 = NULL;
- __pyx_t_11 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
- __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_1);
- if (likely(__pyx_t_16)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
- __Pyx_INCREF(__pyx_t_16);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_1, function);
- __pyx_t_11 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_1)) {
- PyObject *__pyx_temp[3] = {__pyx_t_16, __pyx_v_fname_token, __pyx_v_fname_location};
- __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 265, __pyx_L39_error)
- __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
- PyObject *__pyx_temp[3] = {__pyx_t_16, __pyx_v_fname_token, __pyx_v_fname_location};
- __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 265, __pyx_L39_error)
- __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
- __Pyx_GOTREF(__pyx_t_3);
- } else
- #endif
- {
- __pyx_t_17 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 265, __pyx_L39_error)
- __Pyx_GOTREF(__pyx_t_17);
- if (__pyx_t_16) {
- __Pyx_GIVEREF(__pyx_t_16); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_16); __pyx_t_16 = NULL;
- }
- __Pyx_INCREF(__pyx_v_fname_token);
- __Pyx_GIVEREF(__pyx_v_fname_token);
- PyTuple_SET_ITEM(__pyx_t_17, 0+__pyx_t_11, __pyx_v_fname_token);
- __Pyx_INCREF(__pyx_v_fname_location);
- __Pyx_GIVEREF(__pyx_v_fname_location);
- PyTuple_SET_ITEM(__pyx_t_17, 1+__pyx_t_11, __pyx_v_fname_location);
- __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_17, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 265, __pyx_L39_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
- }
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_Raise(__pyx_t_3, 0, 0, __pyx_v_err);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __PYX_ERR(0, 265, __pyx_L39_error)
- }
-
- /* "fontTools/feaLib/lexer.py":264
- * try:
- * self.lexers_.append(self.make_lexer_(path))
- * except FileNotFoundError as err: # <<<<<<<<<<<<<<
- * raise IncludedFeaNotFound(fname_token, fname_location) from err
- * else:
- */
- /*finally:*/ {
- __pyx_L39_error:;
- /*exception exit:*/{
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0;
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
- __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_23, &__pyx_t_24, &__pyx_t_25);
- if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22) < 0)) __Pyx_ErrFetch(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22);
- __Pyx_XGOTREF(__pyx_t_20);
- __Pyx_XGOTREF(__pyx_t_21);
- __Pyx_XGOTREF(__pyx_t_22);
- __Pyx_XGOTREF(__pyx_t_23);
- __Pyx_XGOTREF(__pyx_t_24);
- __Pyx_XGOTREF(__pyx_t_25);
- __pyx_t_11 = __pyx_lineno; __pyx_t_18 = __pyx_clineno; __pyx_t_19 = __pyx_filename;
- {
- __Pyx_DECREF(__pyx_v_err);
- __pyx_v_err = NULL;
- }
- if (PY_MAJOR_VERSION >= 3) {
- __Pyx_XGIVEREF(__pyx_t_23);
- __Pyx_XGIVEREF(__pyx_t_24);
- __Pyx_XGIVEREF(__pyx_t_25);
- __Pyx_ExceptionReset(__pyx_t_23, __pyx_t_24, __pyx_t_25);
- }
- __Pyx_XGIVEREF(__pyx_t_20);
- __Pyx_XGIVEREF(__pyx_t_21);
- __Pyx_XGIVEREF(__pyx_t_22);
- __Pyx_ErrRestore(__pyx_t_20, __pyx_t_21, __pyx_t_22);
- __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0;
- __pyx_lineno = __pyx_t_11; __pyx_clineno = __pyx_t_18; __pyx_filename = __pyx_t_19;
- goto __pyx_L28_except_error;
- }
- }
- }
- goto __pyx_L28_except_error;
- __pyx_L28_except_error:;
-
- /* "fontTools/feaLib/lexer.py":262
- * if len(self.lexers_) >= 5:
- * raise FeatureLibError("Too many recursive includes", fname_location)
- * try: # <<<<<<<<<<<<<<
- * self.lexers_.append(self.make_lexer_(path))
- * except FileNotFoundError as err:
- */
- __Pyx_XGIVEREF(__pyx_t_6);
- __Pyx_XGIVEREF(__pyx_t_5);
- __Pyx_XGIVEREF(__pyx_t_4);
- __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_5, __pyx_t_4);
- goto __pyx_L1_error;
- __pyx_L33_try_end:;
- }
-
- /* "fontTools/feaLib/lexer.py":239
- * self.lexers_.pop()
- * continue
- * if token_type is Lexer.NAME and token == "include": # <<<<<<<<<<<<<<
- * fname_type, fname_token, fname_location = lexer.next()
- * if fname_type is not Lexer.FILENAME:
- */
- goto __pyx_L17;
- }
-
- /* "fontTools/feaLib/lexer.py":267
- * raise IncludedFeaNotFound(fname_token, fname_location) from err
- * else:
- * return (token_type, token, location) # <<<<<<<<<<<<<<
- * raise StopIteration()
- *
- */
- /*else*/ {
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 267, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_INCREF(__pyx_v_token_type);
- __Pyx_GIVEREF(__pyx_v_token_type);
- PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_token_type);
- __Pyx_INCREF(__pyx_v_token);
- __Pyx_GIVEREF(__pyx_v_token);
- PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_v_token);
- __Pyx_INCREF(__pyx_v_location);
- __Pyx_GIVEREF(__pyx_v_location);
- PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_v_location);
- __pyx_r = __pyx_t_7;
- __pyx_t_7 = 0;
- goto __pyx_L0;
- }
- __pyx_L17:;
- __pyx_L3_continue:;
- }
-
- /* "fontTools/feaLib/lexer.py":268
- * else:
- * return (token_type, token, location)
- * raise StopIteration() # <<<<<<<<<<<<<<
- *
- * @staticmethod
- */
- __pyx_t_7 = __Pyx_PyObject_CallNoArg(__pyx_builtin_StopIteration); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 268, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_Raise(__pyx_t_7, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- __PYX_ERR(0, 268, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":231
- * return self.__next__()
- *
- * def __next__(self): # Python 3 # <<<<<<<<<<<<<<
- * while self.lexers_:
- * lexer = self.lexers_[-1]
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_XDECREF(__pyx_t_8);
- __Pyx_XDECREF(__pyx_t_9);
- __Pyx_XDECREF(__pyx_t_16);
- __Pyx_XDECREF(__pyx_t_17);
- __Pyx_AddTraceback("fontTools.feaLib.lexer.IncludingLexer.__next__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_lexer);
- __Pyx_XDECREF(__pyx_v_token_type);
- __Pyx_XDECREF(__pyx_v_token);
- __Pyx_XDECREF(__pyx_v_location);
- __Pyx_XDECREF(__pyx_v_fname_type);
- __Pyx_XDECREF(__pyx_v_fname_token);
- __Pyx_XDECREF(__pyx_v_fname_location);
- __Pyx_XDECREF(__pyx_v_path);
- __Pyx_XDECREF(__pyx_v_curpath);
- __Pyx_XDECREF(__pyx_v_err);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "fontTools/feaLib/lexer.py":271
- *
- * @staticmethod
- * def make_lexer_(file_or_path): # <<<<<<<<<<<<<<
- * if hasattr(file_or_path, "read"):
- * fileobj, closing = file_or_path, False
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_9fontTools_6feaLib_5lexer_14IncludingLexer_9make_lexer_(PyObject *__pyx_self, PyObject *__pyx_v_file_or_path); /*proto*/
-static char __pyx_doc_9fontTools_6feaLib_5lexer_14IncludingLexer_8make_lexer_[] = "IncludingLexer.make_lexer_(file_or_path)";
-static PyMethodDef __pyx_mdef_9fontTools_6feaLib_5lexer_14IncludingLexer_9make_lexer_ = {"make_lexer_", (PyCFunction)__pyx_pw_9fontTools_6feaLib_5lexer_14IncludingLexer_9make_lexer_, METH_O, __pyx_doc_9fontTools_6feaLib_5lexer_14IncludingLexer_8make_lexer_};
-static PyObject *__pyx_pw_9fontTools_6feaLib_5lexer_14IncludingLexer_9make_lexer_(PyObject *__pyx_self, PyObject *__pyx_v_file_or_path) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("make_lexer_ (wrapper)", 0);
- __pyx_r = __pyx_pf_9fontTools_6feaLib_5lexer_14IncludingLexer_8make_lexer_(__pyx_self, ((PyObject *)__pyx_v_file_or_path));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_9fontTools_6feaLib_5lexer_14IncludingLexer_8make_lexer_(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_file_or_path) {
- PyObject *__pyx_v_fileobj = NULL;
- int __pyx_v_closing;
- PyObject *__pyx_v_filename = NULL;
- PyObject *__pyx_v_data = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- int __pyx_t_6;
- PyObject *__pyx_t_7 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("make_lexer_", 0);
-
- /* "fontTools/feaLib/lexer.py":272
- * @staticmethod
- * def make_lexer_(file_or_path):
- * if hasattr(file_or_path, "read"): # <<<<<<<<<<<<<<
- * fileobj, closing = file_or_path, False
- * else:
- */
- __pyx_t_1 = __Pyx_HasAttr(__pyx_v_file_or_path, __pyx_n_u_read); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 272, __pyx_L1_error)
- __pyx_t_2 = (__pyx_t_1 != 0);
- if (__pyx_t_2) {
-
- /* "fontTools/feaLib/lexer.py":273
- * def make_lexer_(file_or_path):
- * if hasattr(file_or_path, "read"):
- * fileobj, closing = file_or_path, False # <<<<<<<<<<<<<<
- * else:
- * filename, closing = file_or_path, True
- */
- __pyx_t_3 = __pyx_v_file_or_path;
- __Pyx_INCREF(__pyx_t_3);
- __pyx_t_2 = 0;
- __pyx_v_fileobj = __pyx_t_3;
- __pyx_t_3 = 0;
- __pyx_v_closing = __pyx_t_2;
-
- /* "fontTools/feaLib/lexer.py":272
- * @staticmethod
- * def make_lexer_(file_or_path):
- * if hasattr(file_or_path, "read"): # <<<<<<<<<<<<<<
- * fileobj, closing = file_or_path, False
- * else:
- */
- goto __pyx_L3;
- }
-
- /* "fontTools/feaLib/lexer.py":275
- * fileobj, closing = file_or_path, False
- * else:
- * filename, closing = file_or_path, True # <<<<<<<<<<<<<<
- * fileobj = open(filename, "r", encoding="utf-8")
- * data = fileobj.read()
- */
- /*else*/ {
- __pyx_t_3 = __pyx_v_file_or_path;
- __Pyx_INCREF(__pyx_t_3);
- __pyx_t_2 = 1;
- __pyx_v_filename = __pyx_t_3;
- __pyx_t_3 = 0;
- __pyx_v_closing = __pyx_t_2;
-
- /* "fontTools/feaLib/lexer.py":276
- * else:
- * filename, closing = file_or_path, True
- * fileobj = open(filename, "r", encoding="utf-8") # <<<<<<<<<<<<<<
- * data = fileobj.read()
- * filename = getattr(fileobj, "name", None)
- */
- __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 276, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_INCREF(__pyx_v_filename);
- __Pyx_GIVEREF(__pyx_v_filename);
- PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_filename);
- __Pyx_INCREF(__pyx_n_u_r);
- __Pyx_GIVEREF(__pyx_n_u_r);
- PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_n_u_r);
- __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 276, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_encoding, __pyx_kp_u_utf_8) < 0) __PYX_ERR(0, 276, __pyx_L1_error)
- __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_open, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 276, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_v_fileobj = __pyx_t_5;
- __pyx_t_5 = 0;
- }
- __pyx_L3:;
-
- /* "fontTools/feaLib/lexer.py":277
- * filename, closing = file_or_path, True
- * fileobj = open(filename, "r", encoding="utf-8")
- * data = fileobj.read() # <<<<<<<<<<<<<<
- * filename = getattr(fileobj, "name", None)
- * if closing:
- */
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_fileobj, __pyx_n_s_read); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 277, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- }
- }
- __pyx_t_5 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 277, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_v_data = __pyx_t_5;
- __pyx_t_5 = 0;
-
- /* "fontTools/feaLib/lexer.py":278
- * fileobj = open(filename, "r", encoding="utf-8")
- * data = fileobj.read()
- * filename = getattr(fileobj, "name", None) # <<<<<<<<<<<<<<
- * if closing:
- * fileobj.close()
- */
- __pyx_t_5 = __Pyx_GetAttr3(__pyx_v_fileobj, __pyx_n_u_name, Py_None); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 278, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_XDECREF_SET(__pyx_v_filename, __pyx_t_5);
- __pyx_t_5 = 0;
-
- /* "fontTools/feaLib/lexer.py":279
- * data = fileobj.read()
- * filename = getattr(fileobj, "name", None)
- * if closing: # <<<<<<<<<<<<<<
- * fileobj.close()
- * return Lexer(data, filename)
- */
- __pyx_t_2 = (__pyx_v_closing != 0);
- if (__pyx_t_2) {
-
- /* "fontTools/feaLib/lexer.py":280
- * filename = getattr(fileobj, "name", None)
- * if closing:
- * fileobj.close() # <<<<<<<<<<<<<<
- * return Lexer(data, filename)
- *
- */
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_fileobj, __pyx_n_s_close); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 280, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- }
- }
- __pyx_t_5 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 280, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-
- /* "fontTools/feaLib/lexer.py":279
- * data = fileobj.read()
- * filename = getattr(fileobj, "name", None)
- * if closing: # <<<<<<<<<<<<<<
- * fileobj.close()
- * return Lexer(data, filename)
- */
- }
-
- /* "fontTools/feaLib/lexer.py":281
- * if closing:
- * fileobj.close()
- * return Lexer(data, filename) # <<<<<<<<<<<<<<
- *
- * def scan_anonymous_block(self, tag):
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_Lexer); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 281, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_3 = NULL;
- __pyx_t_6 = 0;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- __pyx_t_6 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_4)) {
- PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_data, __pyx_v_filename};
- __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 281, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_5);
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
- PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_v_data, __pyx_v_filename};
- __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 281, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_GOTREF(__pyx_t_5);
- } else
- #endif
- {
- __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 281, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- if (__pyx_t_3) {
- __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3); __pyx_t_3 = NULL;
- }
- __Pyx_INCREF(__pyx_v_data);
- __Pyx_GIVEREF(__pyx_v_data);
- PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_v_data);
- __Pyx_INCREF(__pyx_v_filename);
- __Pyx_GIVEREF(__pyx_v_filename);
- PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_v_filename);
- __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 281, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- }
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_r = __pyx_t_5;
- __pyx_t_5 = 0;
- goto __pyx_L0;
-
- /* "fontTools/feaLib/lexer.py":271
- *
- * @staticmethod
- * def make_lexer_(file_or_path): # <<<<<<<<<<<<<<
- * if hasattr(file_or_path, "read"):
- * fileobj, closing = file_or_path, False
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_AddTraceback("fontTools.feaLib.lexer.IncludingLexer.make_lexer_", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_fileobj);
- __Pyx_XDECREF(__pyx_v_filename);
- __Pyx_XDECREF(__pyx_v_data);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "fontTools/feaLib/lexer.py":283
- * return Lexer(data, filename)
- *
- * def scan_anonymous_block(self, tag): # <<<<<<<<<<<<<<
- * return self.lexers_[-1].scan_anonymous_block(tag)
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_9fontTools_6feaLib_5lexer_14IncludingLexer_11scan_anonymous_block(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_9fontTools_6feaLib_5lexer_14IncludingLexer_10scan_anonymous_block[] = "IncludingLexer.scan_anonymous_block(self, tag)";
-static PyMethodDef __pyx_mdef_9fontTools_6feaLib_5lexer_14IncludingLexer_11scan_anonymous_block = {"scan_anonymous_block", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_9fontTools_6feaLib_5lexer_14IncludingLexer_11scan_anonymous_block, METH_VARARGS|METH_KEYWORDS, __pyx_doc_9fontTools_6feaLib_5lexer_14IncludingLexer_10scan_anonymous_block};
-static PyObject *__pyx_pw_9fontTools_6feaLib_5lexer_14IncludingLexer_11scan_anonymous_block(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_self = 0;
- PyObject *__pyx_v_tag = 0;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("scan_anonymous_block (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_tag,0};
- PyObject* values[2] = {0,0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_tag)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("scan_anonymous_block", 1, 2, 2, 1); __PYX_ERR(0, 283, __pyx_L3_error)
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "scan_anonymous_block") < 0)) __PYX_ERR(0, 283, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- }
- __pyx_v_self = values[0];
- __pyx_v_tag = values[1];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("scan_anonymous_block", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 283, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("fontTools.feaLib.lexer.IncludingLexer.scan_anonymous_block", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_9fontTools_6feaLib_5lexer_14IncludingLexer_10scan_anonymous_block(__pyx_self, __pyx_v_self, __pyx_v_tag);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_9fontTools_6feaLib_5lexer_14IncludingLexer_10scan_anonymous_block(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_tag) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("scan_anonymous_block", 0);
-
- /* "fontTools/feaLib/lexer.py":284
- *
- * def scan_anonymous_block(self, tag):
- * return self.lexers_[-1].scan_anonymous_block(tag) # <<<<<<<<<<<<<<
- *
- *
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_lexers); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 284, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_2, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 284, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_scan_anonymous_block); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 284, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_3 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_3)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_tag) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_tag);
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 284, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "fontTools/feaLib/lexer.py":283
- * return Lexer(data, filename)
- *
- * def scan_anonymous_block(self, tag): # <<<<<<<<<<<<<<
- * return self.lexers_[-1].scan_anonymous_block(tag)
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("fontTools.feaLib.lexer.IncludingLexer.scan_anonymous_block", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "fontTools/feaLib/lexer.py":290
- * """Lexer that does not follow `include` statements, emits them as-is."""
- *
- * def __next__(self): # Python 3 # <<<<<<<<<<<<<<
- * return next(self.lexers_[0])
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_9fontTools_6feaLib_5lexer_17NonIncludingLexer_1__next__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
-static char __pyx_doc_9fontTools_6feaLib_5lexer_17NonIncludingLexer___next__[] = "NonIncludingLexer.__next__(self)";
-static PyMethodDef __pyx_mdef_9fontTools_6feaLib_5lexer_17NonIncludingLexer_1__next__ = {"__next__", (PyCFunction)__pyx_pw_9fontTools_6feaLib_5lexer_17NonIncludingLexer_1__next__, METH_O, __pyx_doc_9fontTools_6feaLib_5lexer_17NonIncludingLexer___next__};
-static PyObject *__pyx_pw_9fontTools_6feaLib_5lexer_17NonIncludingLexer_1__next__(PyObject *__pyx_self, PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__next__ (wrapper)", 0);
- __pyx_r = __pyx_pf_9fontTools_6feaLib_5lexer_17NonIncludingLexer___next__(__pyx_self, ((PyObject *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_9fontTools_6feaLib_5lexer_17NonIncludingLexer___next__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("__next__", 0);
-
- /* "fontTools/feaLib/lexer.py":291
- *
- * def __next__(self): # Python 3
- * return next(self.lexers_[0]) # <<<<<<<<<<<<<<
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_lexers); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 291, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 291, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_PyIter_Next(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 291, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "fontTools/feaLib/lexer.py":290
- * """Lexer that does not follow `include` statements, emits them as-is."""
- *
- * def __next__(self): # Python 3 # <<<<<<<<<<<<<<
- * return next(self.lexers_[0])
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("fontTools.feaLib.lexer.NonIncludingLexer.__next__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyMethodDef __pyx_methods[] = {
- {0, 0, 0, 0}
-};
-
-#if PY_MAJOR_VERSION >= 3
-#if CYTHON_PEP489_MULTI_PHASE_INIT
-static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
-static int __pyx_pymod_exec_lexer(PyObject* module); /*proto*/
-static PyModuleDef_Slot __pyx_moduledef_slots[] = {
- {Py_mod_create, (void*)__pyx_pymod_create},
- {Py_mod_exec, (void*)__pyx_pymod_exec_lexer},
- {0, NULL}
-};
-#endif
-
-static struct PyModuleDef __pyx_moduledef = {
- PyModuleDef_HEAD_INIT,
- "lexer",
- 0, /* m_doc */
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- 0, /* m_size */
- #else
- -1, /* m_size */
- #endif
- __pyx_methods /* m_methods */,
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- __pyx_moduledef_slots, /* m_slots */
- #else
- NULL, /* m_reload */
- #endif
- NULL, /* m_traverse */
- NULL, /* m_clear */
- NULL /* m_free */
-};
-#endif
-#ifndef CYTHON_SMALL_CODE
-#if defined(__clang__)
- #define CYTHON_SMALL_CODE
-#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
- #define CYTHON_SMALL_CODE __attribute__((cold))
-#else
- #define CYTHON_SMALL_CODE
-#endif
-#endif
-
-static __Pyx_StringTabEntry __pyx_string_tab[] = {
- {&__pyx_kp_u_, __pyx_k_, sizeof(__pyx_k_), 0, 1, 0, 0},
- {&__pyx_kp_u_0, __pyx_k_0, sizeof(__pyx_k_0), 0, 1, 0, 0},
- {&__pyx_kp_u_0123456789, __pyx_k_0123456789, sizeof(__pyx_k_0123456789), 0, 1, 0, 0},
- {&__pyx_kp_u_0123456789ABCDEFabcdef, __pyx_k_0123456789ABCDEFabcdef, sizeof(__pyx_k_0123456789ABCDEFabcdef), 0, 1, 0, 0},
- {&__pyx_n_u_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef, __pyx_k_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef, sizeof(__pyx_k_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef), 0, 1, 0, 1},
- {&__pyx_n_s_ANONYMOUS_BLOCK, __pyx_k_ANONYMOUS_BLOCK, sizeof(__pyx_k_ANONYMOUS_BLOCK), 0, 0, 1, 1},
- {&__pyx_n_u_ANONYMOUS_BLOCK, __pyx_k_ANONYMOUS_BLOCK, sizeof(__pyx_k_ANONYMOUS_BLOCK), 0, 1, 0, 1},
- {&__pyx_kp_s_A_Lexer_that_follows_include_sta, __pyx_k_A_Lexer_that_follows_include_sta, sizeof(__pyx_k_A_Lexer_that_follows_include_sta), 0, 0, 1, 0},
- {&__pyx_kp_u_A_Za_z_0_9, __pyx_k_A_Za_z_0_9, sizeof(__pyx_k_A_Za_z_0_9), 0, 1, 0, 0},
- {&__pyx_n_s_CHAR_DIGIT, __pyx_k_CHAR_DIGIT, sizeof(__pyx_k_CHAR_DIGIT), 0, 0, 1, 1},
- {&__pyx_n_s_CHAR_HEXDIGIT, __pyx_k_CHAR_HEXDIGIT, sizeof(__pyx_k_CHAR_HEXDIGIT), 0, 0, 1, 1},
- {&__pyx_n_s_CHAR_LETTER, __pyx_k_CHAR_LETTER, sizeof(__pyx_k_CHAR_LETTER), 0, 0, 1, 1},
- {&__pyx_n_s_CHAR_NAME_CONTINUATION, __pyx_k_CHAR_NAME_CONTINUATION, sizeof(__pyx_k_CHAR_NAME_CONTINUATION), 0, 0, 1, 1},
- {&__pyx_n_s_CHAR_NAME_START, __pyx_k_CHAR_NAME_START, sizeof(__pyx_k_CHAR_NAME_START), 0, 0, 1, 1},
- {&__pyx_n_s_CHAR_NEWLINE, __pyx_k_CHAR_NEWLINE, sizeof(__pyx_k_CHAR_NEWLINE), 0, 0, 1, 1},
- {&__pyx_n_s_CHAR_SYMBOL, __pyx_k_CHAR_SYMBOL, sizeof(__pyx_k_CHAR_SYMBOL), 0, 0, 1, 1},
- {&__pyx_n_s_CHAR_WHITESPACE, __pyx_k_CHAR_WHITESPACE, sizeof(__pyx_k_CHAR_WHITESPACE), 0, 0, 1, 1},
- {&__pyx_n_s_CID, __pyx_k_CID, sizeof(__pyx_k_CID), 0, 0, 1, 1},
- {&__pyx_n_u_CID, __pyx_k_CID, sizeof(__pyx_k_CID), 0, 1, 0, 1},
- {&__pyx_n_s_COMMENT, __pyx_k_COMMENT, sizeof(__pyx_k_COMMENT), 0, 0, 1, 1},
- {&__pyx_n_u_COMMENT, __pyx_k_COMMENT, sizeof(__pyx_k_COMMENT), 0, 1, 0, 1},
- {&__pyx_kp_u_Expected_after_file_name, __pyx_k_Expected_after_file_name, sizeof(__pyx_k_Expected_after_file_name), 0, 1, 0, 0},
- {&__pyx_kp_u_Expected_before_file_name, __pyx_k_Expected_before_file_name, sizeof(__pyx_k_Expected_before_file_name), 0, 1, 0, 0},
- {&__pyx_kp_u_Expected_file_name, __pyx_k_Expected_file_name, sizeof(__pyx_k_Expected_file_name), 0, 1, 0, 0},
- {&__pyx_kp_u_Expected_glyph_class_name, __pyx_k_Expected_glyph_class_name, sizeof(__pyx_k_Expected_glyph_class_name), 0, 1, 0, 0},
- {&__pyx_kp_u_Expected_s_to_terminate_anonymou, __pyx_k_Expected_s_to_terminate_anonymou, sizeof(__pyx_k_Expected_s_to_terminate_anonymou), 0, 1, 0, 0},
- {&__pyx_kp_u_Expected_to_terminate_string, __pyx_k_Expected_to_terminate_string, sizeof(__pyx_k_Expected_to_terminate_string), 0, 1, 0, 0},
- {&__pyx_n_s_FILENAME, __pyx_k_FILENAME, sizeof(__pyx_k_FILENAME), 0, 0, 1, 1},
- {&__pyx_n_u_FILENAME, __pyx_k_FILENAME, sizeof(__pyx_k_FILENAME), 0, 1, 0, 1},
- {&__pyx_n_s_FLOAT, __pyx_k_FLOAT, sizeof(__pyx_k_FLOAT), 0, 0, 1, 1},
- {&__pyx_n_u_FLOAT, __pyx_k_FLOAT, sizeof(__pyx_k_FLOAT), 0, 1, 0, 1},
- {&__pyx_n_s_FeatureLibError, __pyx_k_FeatureLibError, sizeof(__pyx_k_FeatureLibError), 0, 0, 1, 1},
- {&__pyx_n_s_FeatureLibLocation, __pyx_k_FeatureLibLocation, sizeof(__pyx_k_FeatureLibLocation), 0, 0, 1, 1},
- {&__pyx_n_s_FileNotFoundError, __pyx_k_FileNotFoundError, sizeof(__pyx_k_FileNotFoundError), 0, 0, 1, 1},
- {&__pyx_n_s_GLYPHCLASS, __pyx_k_GLYPHCLASS, sizeof(__pyx_k_GLYPHCLASS), 0, 0, 1, 1},
- {&__pyx_n_u_GLYPHCLASS, __pyx_k_GLYPHCLASS, sizeof(__pyx_k_GLYPHCLASS), 0, 1, 0, 1},
- {&__pyx_kp_u_Glyph_class_names_must_consist_o, __pyx_k_Glyph_class_names_must_consist_o, sizeof(__pyx_k_Glyph_class_names_must_consist_o), 0, 1, 0, 0},
- {&__pyx_kp_u_Glyph_class_names_must_not_be_lo, __pyx_k_Glyph_class_names_must_not_be_lo, sizeof(__pyx_k_Glyph_class_names_must_not_be_lo), 0, 1, 0, 0},
- {&__pyx_n_s_HEXADECIMAL, __pyx_k_HEXADECIMAL, sizeof(__pyx_k_HEXADECIMAL), 0, 0, 1, 1},
- {&__pyx_n_u_HEXADECIMAL, __pyx_k_HEXADECIMAL, sizeof(__pyx_k_HEXADECIMAL), 0, 1, 0, 1},
- {&__pyx_n_s_ImportError, __pyx_k_ImportError, sizeof(__pyx_k_ImportError), 0, 0, 1, 1},
- {&__pyx_n_s_IncludedFeaNotFound, __pyx_k_IncludedFeaNotFound, sizeof(__pyx_k_IncludedFeaNotFound), 0, 0, 1, 1},
- {&__pyx_n_s_IncludingLexer, __pyx_k_IncludingLexer, sizeof(__pyx_k_IncludingLexer), 0, 0, 1, 1},
- {&__pyx_n_s_IncludingLexer___init, __pyx_k_IncludingLexer___init, sizeof(__pyx_k_IncludingLexer___init), 0, 0, 1, 1},
- {&__pyx_n_s_IncludingLexer___iter, __pyx_k_IncludingLexer___iter, sizeof(__pyx_k_IncludingLexer___iter), 0, 0, 1, 1},
- {&__pyx_n_s_IncludingLexer___next, __pyx_k_IncludingLexer___next, sizeof(__pyx_k_IncludingLexer___next), 0, 0, 1, 1},
- {&__pyx_n_s_IncludingLexer_make_lexer, __pyx_k_IncludingLexer_make_lexer, sizeof(__pyx_k_IncludingLexer_make_lexer), 0, 0, 1, 1},
- {&__pyx_n_s_IncludingLexer_next, __pyx_k_IncludingLexer_next, sizeof(__pyx_k_IncludingLexer_next), 0, 0, 1, 1},
- {&__pyx_n_s_IncludingLexer_scan_anonymous_bl, __pyx_k_IncludingLexer_scan_anonymous_bl, sizeof(__pyx_k_IncludingLexer_scan_anonymous_bl), 0, 0, 1, 1},
- {&__pyx_n_s_Lexer, __pyx_k_Lexer, sizeof(__pyx_k_Lexer), 0, 0, 1, 1},
- {&__pyx_n_s_Lexer___init, __pyx_k_Lexer___init, sizeof(__pyx_k_Lexer___init), 0, 0, 1, 1},
- {&__pyx_n_s_Lexer___iter, __pyx_k_Lexer___iter, sizeof(__pyx_k_Lexer___iter), 0, 0, 1, 1},
- {&__pyx_n_s_Lexer___next, __pyx_k_Lexer___next, sizeof(__pyx_k_Lexer___next), 0, 0, 1, 1},
- {&__pyx_n_s_Lexer_location, __pyx_k_Lexer_location, sizeof(__pyx_k_Lexer_location), 0, 0, 1, 1},
- {&__pyx_n_s_Lexer_next, __pyx_k_Lexer_next, sizeof(__pyx_k_Lexer_next), 0, 0, 1, 1},
- {&__pyx_n_s_Lexer_next_2, __pyx_k_Lexer_next_2, sizeof(__pyx_k_Lexer_next_2), 0, 0, 1, 1},
- {&__pyx_n_s_Lexer_scan_anonymous_block, __pyx_k_Lexer_scan_anonymous_block, sizeof(__pyx_k_Lexer_scan_anonymous_block), 0, 0, 1, 1},
- {&__pyx_n_s_Lexer_scan_over, __pyx_k_Lexer_scan_over, sizeof(__pyx_k_Lexer_scan_over), 0, 0, 1, 1},
- {&__pyx_n_s_Lexer_scan_until, __pyx_k_Lexer_scan_until, sizeof(__pyx_k_Lexer_scan_until), 0, 0, 1, 1},
- {&__pyx_kp_s_Lexer_that_does_not_follow_inclu, __pyx_k_Lexer_that_does_not_follow_inclu, sizeof(__pyx_k_Lexer_that_does_not_follow_inclu), 0, 0, 1, 0},
- {&__pyx_kp_s_Lib_fontTools_feaLib_lexer_py, __pyx_k_Lib_fontTools_feaLib_lexer_py, sizeof(__pyx_k_Lib_fontTools_feaLib_lexer_py), 0, 0, 1, 0},
- {&__pyx_n_s_MODE_FILENAME, __pyx_k_MODE_FILENAME, sizeof(__pyx_k_MODE_FILENAME), 0, 0, 1, 1},
- {&__pyx_n_s_MODE_NORMAL, __pyx_k_MODE_NORMAL, sizeof(__pyx_k_MODE_NORMAL), 0, 0, 1, 1},
- {&__pyx_n_s_NAME, __pyx_k_NAME, sizeof(__pyx_k_NAME), 0, 0, 1, 1},
- {&__pyx_n_u_NAME, __pyx_k_NAME, sizeof(__pyx_k_NAME), 0, 1, 0, 1},
- {&__pyx_n_s_NEWLINE, __pyx_k_NEWLINE, sizeof(__pyx_k_NEWLINE), 0, 0, 1, 1},
- {&__pyx_n_u_NEWLINE, __pyx_k_NEWLINE, sizeof(__pyx_k_NEWLINE), 0, 1, 0, 1},
- {&__pyx_n_u_NORMAL, __pyx_k_NORMAL, sizeof(__pyx_k_NORMAL), 0, 1, 0, 1},
- {&__pyx_n_s_NUMBER, __pyx_k_NUMBER, sizeof(__pyx_k_NUMBER), 0, 0, 1, 1},
- {&__pyx_n_u_NUMBER, __pyx_k_NUMBER, sizeof(__pyx_k_NUMBER), 0, 1, 0, 1},
- {&__pyx_n_s_NUMBERS, __pyx_k_NUMBERS, sizeof(__pyx_k_NUMBERS), 0, 0, 1, 1},
- {&__pyx_n_s_NonIncludingLexer, __pyx_k_NonIncludingLexer, sizeof(__pyx_k_NonIncludingLexer), 0, 0, 1, 1},
- {&__pyx_n_s_NonIncludingLexer___next, __pyx_k_NonIncludingLexer___next, sizeof(__pyx_k_NonIncludingLexer___next), 0, 0, 1, 1},
- {&__pyx_n_s_OCTAL, __pyx_k_OCTAL, sizeof(__pyx_k_OCTAL), 0, 0, 1, 1},
- {&__pyx_n_u_OCTAL, __pyx_k_OCTAL, sizeof(__pyx_k_OCTAL), 0, 1, 0, 1},
- {&__pyx_n_s_RE_GLYPHCLASS, __pyx_k_RE_GLYPHCLASS, sizeof(__pyx_k_RE_GLYPHCLASS), 0, 0, 1, 1},
- {&__pyx_n_s_STRING, __pyx_k_STRING, sizeof(__pyx_k_STRING), 0, 0, 1, 1},
- {&__pyx_n_u_STRING, __pyx_k_STRING, sizeof(__pyx_k_STRING), 0, 1, 0, 1},
- {&__pyx_n_s_SYMBOL, __pyx_k_SYMBOL, sizeof(__pyx_k_SYMBOL), 0, 0, 1, 1},
- {&__pyx_n_u_SYMBOL, __pyx_k_SYMBOL, sizeof(__pyx_k_SYMBOL), 0, 1, 0, 1},
- {&__pyx_n_s_StopIteration, __pyx_k_StopIteration, sizeof(__pyx_k_StopIteration), 0, 0, 1, 1},
- {&__pyx_kp_u_Too_many_recursive_includes, __pyx_k_Too_many_recursive_includes, sizeof(__pyx_k_Too_many_recursive_includes), 0, 1, 0, 0},
- {&__pyx_kp_u_Unexpected_character_r, __pyx_k_Unexpected_character_r, sizeof(__pyx_k_Unexpected_character_r), 0, 1, 0, 0},
- {&__pyx_kp_u__10, __pyx_k__10, sizeof(__pyx_k__10), 0, 1, 0, 0},
- {&__pyx_kp_u__11, __pyx_k__11, sizeof(__pyx_k__11), 0, 1, 0, 0},
- {&__pyx_kp_u__12, __pyx_k__12, sizeof(__pyx_k__12), 0, 1, 0, 0},
- {&__pyx_kp_u__14, __pyx_k__14, sizeof(__pyx_k__14), 0, 1, 0, 0},
- {&__pyx_kp_u__15, __pyx_k__15, sizeof(__pyx_k__15), 0, 1, 0, 0},
- {&__pyx_kp_u__16, __pyx_k__16, sizeof(__pyx_k__16), 0, 1, 0, 0},
- {&__pyx_kp_u__17, __pyx_k__17, sizeof(__pyx_k__17), 0, 1, 0, 0},
- {&__pyx_kp_u__18, __pyx_k__18, sizeof(__pyx_k__18), 0, 1, 0, 0},
- {&__pyx_kp_u__2, __pyx_k__2, sizeof(__pyx_k__2), 0, 1, 0, 0},
- {&__pyx_kp_u__3, __pyx_k__3, sizeof(__pyx_k__3), 0, 1, 0, 0},
- {&__pyx_kp_u__4, __pyx_k__4, sizeof(__pyx_k__4), 0, 1, 0, 0},
- {&__pyx_kp_u__5, __pyx_k__5, sizeof(__pyx_k__5), 0, 1, 0, 0},
- {&__pyx_kp_u__6, __pyx_k__6, sizeof(__pyx_k__6), 0, 1, 0, 0},
- {&__pyx_kp_u__7, __pyx_k__7, sizeof(__pyx_k__7), 0, 1, 0, 0},
- {&__pyx_kp_u__8, __pyx_k__8, sizeof(__pyx_k__8), 0, 1, 0, 0},
- {&__pyx_kp_u__9, __pyx_k__9, sizeof(__pyx_k__9), 0, 1, 0, 0},
- {&__pyx_n_s_append, __pyx_k_append, sizeof(__pyx_k_append), 0, 0, 1, 1},
- {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
- {&__pyx_n_s_close, __pyx_k_close, sizeof(__pyx_k_close), 0, 0, 1, 1},
- {&__pyx_n_s_closing, __pyx_k_closing, sizeof(__pyx_k_closing), 0, 0, 1, 1},
- {&__pyx_n_s_column, __pyx_k_column, sizeof(__pyx_k_column), 0, 0, 1, 1},
- {&__pyx_n_s_compile, __pyx_k_compile, sizeof(__pyx_k_compile), 0, 0, 1, 1},
- {&__pyx_n_s_cur_char, __pyx_k_cur_char, sizeof(__pyx_k_cur_char), 0, 0, 1, 1},
- {&__pyx_n_s_curpath, __pyx_k_curpath, sizeof(__pyx_k_curpath), 0, 0, 1, 1},
- {&__pyx_n_s_data, __pyx_k_data, sizeof(__pyx_k_data), 0, 0, 1, 1},
- {&__pyx_n_s_dirname, __pyx_k_dirname, sizeof(__pyx_k_dirname), 0, 0, 1, 1},
- {&__pyx_n_s_doc, __pyx_k_doc, sizeof(__pyx_k_doc), 0, 0, 1, 1},
- {&__pyx_n_s_encoding, __pyx_k_encoding, sizeof(__pyx_k_encoding), 0, 0, 1, 1},
- {&__pyx_n_s_err, __pyx_k_err, sizeof(__pyx_k_err), 0, 0, 1, 1},
- {&__pyx_n_s_featurefile, __pyx_k_featurefile, sizeof(__pyx_k_featurefile), 0, 0, 1, 1},
- {&__pyx_n_s_featurefilepath, __pyx_k_featurefilepath, sizeof(__pyx_k_featurefilepath), 0, 0, 1, 1},
- {&__pyx_kp_u_features, __pyx_k_features, sizeof(__pyx_k_features), 0, 1, 0, 0},
- {&__pyx_n_s_file_or_path, __pyx_k_file_or_path, sizeof(__pyx_k_file_or_path), 0, 0, 1, 1},
- {&__pyx_n_s_filename, __pyx_k_filename, sizeof(__pyx_k_filename), 0, 0, 1, 1},
- {&__pyx_n_s_filename_2, __pyx_k_filename_2, sizeof(__pyx_k_filename_2), 0, 0, 1, 1},
- {&__pyx_n_s_fileobj, __pyx_k_fileobj, sizeof(__pyx_k_fileobj), 0, 0, 1, 1},
- {&__pyx_n_s_fname_location, __pyx_k_fname_location, sizeof(__pyx_k_fname_location), 0, 0, 1, 1},
- {&__pyx_n_s_fname_token, __pyx_k_fname_token, sizeof(__pyx_k_fname_token), 0, 0, 1, 1},
- {&__pyx_n_s_fname_type, __pyx_k_fname_type, sizeof(__pyx_k_fname_type), 0, 0, 1, 1},
- {&__pyx_n_s_fontTools_feaLib_error, __pyx_k_fontTools_feaLib_error, sizeof(__pyx_k_fontTools_feaLib_error), 0, 0, 1, 1},
- {&__pyx_n_s_fontTools_feaLib_lexer, __pyx_k_fontTools_feaLib_lexer, sizeof(__pyx_k_fontTools_feaLib_lexer), 0, 0, 1, 1},
- {&__pyx_n_s_fontTools_feaLib_location, __pyx_k_fontTools_feaLib_location, sizeof(__pyx_k_fontTools_feaLib_location), 0, 0, 1, 1},
- {&__pyx_n_s_getcwd, __pyx_k_getcwd, sizeof(__pyx_k_getcwd), 0, 0, 1, 1},
- {&__pyx_n_s_glyphclass, __pyx_k_glyphclass, sizeof(__pyx_k_glyphclass), 0, 0, 1, 1},
- {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
- {&__pyx_n_u_include, __pyx_k_include, sizeof(__pyx_k_include), 0, 1, 0, 1},
- {&__pyx_n_s_includeDir, __pyx_k_includeDir, sizeof(__pyx_k_includeDir), 0, 0, 1, 1},
- {&__pyx_n_s_init, __pyx_k_init, sizeof(__pyx_k_init), 0, 0, 1, 1},
- {&__pyx_n_s_isabs, __pyx_k_isabs, sizeof(__pyx_k_isabs), 0, 0, 1, 1},
- {&__pyx_n_s_iter, __pyx_k_iter, sizeof(__pyx_k_iter), 0, 0, 1, 1},
- {&__pyx_n_s_join, __pyx_k_join, sizeof(__pyx_k_join), 0, 0, 1, 1},
- {&__pyx_n_s_lexer, __pyx_k_lexer, sizeof(__pyx_k_lexer), 0, 0, 1, 1},
- {&__pyx_n_s_lexers, __pyx_k_lexers, sizeof(__pyx_k_lexers), 0, 0, 1, 1},
- {&__pyx_n_s_limit, __pyx_k_limit, sizeof(__pyx_k_limit), 0, 0, 1, 1},
- {&__pyx_n_s_line, __pyx_k_line, sizeof(__pyx_k_line), 0, 0, 1, 1},
- {&__pyx_n_s_line_start, __pyx_k_line_start, sizeof(__pyx_k_line_start), 0, 0, 1, 1},
- {&__pyx_n_s_location, __pyx_k_location, sizeof(__pyx_k_location), 0, 0, 1, 1},
- {&__pyx_n_s_location_2, __pyx_k_location_2, sizeof(__pyx_k_location_2), 0, 0, 1, 1},
- {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
- {&__pyx_n_s_make_lexer, __pyx_k_make_lexer, sizeof(__pyx_k_make_lexer), 0, 0, 1, 1},
- {&__pyx_n_s_match, __pyx_k_match, sizeof(__pyx_k_match), 0, 0, 1, 1},
- {&__pyx_n_s_maxsplit, __pyx_k_maxsplit, sizeof(__pyx_k_maxsplit), 0, 0, 1, 1},
- {&__pyx_n_s_metaclass, __pyx_k_metaclass, sizeof(__pyx_k_metaclass), 0, 0, 1, 1},
- {&__pyx_n_s_mode, __pyx_k_mode, sizeof(__pyx_k_mode), 0, 0, 1, 1},
- {&__pyx_n_s_module, __pyx_k_module, sizeof(__pyx_k_module), 0, 0, 1, 1},
- {&__pyx_n_u_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 1, 0, 1},
- {&__pyx_n_s_name_2, __pyx_k_name_2, sizeof(__pyx_k_name_2), 0, 0, 1, 1},
- {&__pyx_n_s_next, __pyx_k_next, sizeof(__pyx_k_next), 0, 0, 1, 1},
- {&__pyx_n_s_next_2, __pyx_k_next_2, sizeof(__pyx_k_next_2), 0, 0, 1, 1},
- {&__pyx_n_s_next_3, __pyx_k_next_3, sizeof(__pyx_k_next_3), 0, 0, 1, 1},
- {&__pyx_n_s_next_char, __pyx_k_next_char, sizeof(__pyx_k_next_char), 0, 0, 1, 1},
- {&__pyx_n_s_object, __pyx_k_object, sizeof(__pyx_k_object), 0, 0, 1, 1},
- {&__pyx_n_s_open, __pyx_k_open, sizeof(__pyx_k_open), 0, 0, 1, 1},
- {&__pyx_n_s_os, __pyx_k_os, sizeof(__pyx_k_os), 0, 0, 1, 1},
- {&__pyx_n_s_p, __pyx_k_p, sizeof(__pyx_k_p), 0, 0, 1, 1},
- {&__pyx_n_s_path, __pyx_k_path, sizeof(__pyx_k_path), 0, 0, 1, 1},
- {&__pyx_n_s_pop, __pyx_k_pop, sizeof(__pyx_k_pop), 0, 0, 1, 1},
- {&__pyx_n_s_pos, __pyx_k_pos, sizeof(__pyx_k_pos), 0, 0, 1, 1},
- {&__pyx_n_s_prepare, __pyx_k_prepare, sizeof(__pyx_k_prepare), 0, 0, 1, 1},
- {&__pyx_n_s_qualname, __pyx_k_qualname, sizeof(__pyx_k_qualname), 0, 0, 1, 1},
- {&__pyx_n_u_r, __pyx_k_r, sizeof(__pyx_k_r), 0, 1, 0, 1},
- {&__pyx_n_s_re, __pyx_k_re, sizeof(__pyx_k_re), 0, 0, 1, 1},
- {&__pyx_n_s_read, __pyx_k_read, sizeof(__pyx_k_read), 0, 0, 1, 1},
- {&__pyx_n_u_read, __pyx_k_read, sizeof(__pyx_k_read), 0, 1, 0, 1},
- {&__pyx_n_s_regexp, __pyx_k_regexp, sizeof(__pyx_k_regexp), 0, 0, 1, 1},
- {&__pyx_kp_u_s, __pyx_k_s, sizeof(__pyx_k_s), 0, 1, 0, 0},
- {&__pyx_kp_u_s_2, __pyx_k_s_2, sizeof(__pyx_k_s_2), 0, 1, 0, 0},
- {&__pyx_n_s_scan_anonymous_block, __pyx_k_scan_anonymous_block, sizeof(__pyx_k_scan_anonymous_block), 0, 0, 1, 1},
- {&__pyx_n_s_scan_over, __pyx_k_scan_over, sizeof(__pyx_k_scan_over), 0, 0, 1, 1},
- {&__pyx_n_s_scan_until, __pyx_k_scan_until, sizeof(__pyx_k_scan_until), 0, 0, 1, 1},
- {&__pyx_n_s_self, __pyx_k_self, sizeof(__pyx_k_self), 0, 0, 1, 1},
- {&__pyx_n_s_split, __pyx_k_split, sizeof(__pyx_k_split), 0, 0, 1, 1},
- {&__pyx_n_s_start, __pyx_k_start, sizeof(__pyx_k_start), 0, 0, 1, 1},
- {&__pyx_n_s_staticmethod, __pyx_k_staticmethod, sizeof(__pyx_k_staticmethod), 0, 0, 1, 1},
- {&__pyx_n_s_stop_at, __pyx_k_stop_at, sizeof(__pyx_k_stop_at), 0, 0, 1, 1},
- {&__pyx_n_s_string, __pyx_k_string, sizeof(__pyx_k_string), 0, 0, 1, 1},
- {&__pyx_n_s_strip, __pyx_k_strip, sizeof(__pyx_k_strip), 0, 0, 1, 1},
- {&__pyx_n_s_sub, __pyx_k_sub, sizeof(__pyx_k_sub), 0, 0, 1, 1},
- {&__pyx_n_s_tag, __pyx_k_tag, sizeof(__pyx_k_tag), 0, 0, 1, 1},
- {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
- {&__pyx_n_s_text, __pyx_k_text, sizeof(__pyx_k_text), 0, 0, 1, 1},
- {&__pyx_n_s_text_2, __pyx_k_text_2, sizeof(__pyx_k_text_2), 0, 0, 1, 1},
- {&__pyx_n_s_text_length, __pyx_k_text_length, sizeof(__pyx_k_text_length), 0, 0, 1, 1},
- {&__pyx_n_s_token, __pyx_k_token, sizeof(__pyx_k_token), 0, 0, 1, 1},
- {&__pyx_n_s_token_type, __pyx_k_token_type, sizeof(__pyx_k_token_type), 0, 0, 1, 1},
- {&__pyx_kp_u_utf_8, __pyx_k_utf_8, sizeof(__pyx_k_utf_8), 0, 1, 0, 0},
- {&__pyx_n_s_valid, __pyx_k_valid, sizeof(__pyx_k_valid), 0, 0, 1, 1},
- {&__pyx_n_u_xX, __pyx_k_xX, sizeof(__pyx_k_xX), 0, 1, 0, 1},
- {0, 0, 0, 0, 0, 0, 0}
-};
-static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
- __pyx_builtin_ImportError = __Pyx_GetBuiltinName(__pyx_n_s_ImportError); if (!__pyx_builtin_ImportError) __PYX_ERR(0, 8, __pyx_L1_error)
- __pyx_builtin_object = __Pyx_GetBuiltinName(__pyx_n_s_object); if (!__pyx_builtin_object) __PYX_ERR(0, 13, __pyx_L1_error)
- __pyx_builtin_staticmethod = __Pyx_GetBuiltinName(__pyx_n_s_staticmethod); if (!__pyx_builtin_staticmethod) __PYX_ERR(0, 270, __pyx_L1_error)
- __pyx_builtin_StopIteration = __Pyx_GetBuiltinName(__pyx_n_s_StopIteration); if (!__pyx_builtin_StopIteration) __PYX_ERR(0, 75, __pyx_L1_error)
- __pyx_builtin_open = __Pyx_GetBuiltinName(__pyx_n_s_open); if (!__pyx_builtin_open) __PYX_ERR(0, 276, __pyx_L1_error)
- return 0;
- __pyx_L1_error:;
- return -1;
-}
-
-static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
-
- /* "fontTools/feaLib/lexer.py":13
- *
- *
- * class Lexer(object): # <<<<<<<<<<<<<<
- * NUMBER = "NUMBER"
- * HEXADECIMAL = "HEXADECIMAL"
- */
- __pyx_tuple__13 = PyTuple_Pack(1, __pyx_builtin_object); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 13, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__13);
- __Pyx_GIVEREF(__pyx_tuple__13);
-
- /* "fontTools/feaLib/lexer.py":43
- * MODE_FILENAME_ = "FILENAME"
- *
- * def __init__(self, text, filename): # <<<<<<<<<<<<<<
- * self.filename_ = filename
- * self.line_ = 1
- */
- __pyx_tuple__19 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_text, __pyx_n_s_filename); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(0, 43, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__19);
- __Pyx_GIVEREF(__pyx_tuple__19);
- __pyx_codeobj__20 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__19, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Lib_fontTools_feaLib_lexer_py, __pyx_n_s_init, 43, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__20)) __PYX_ERR(0, 43, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":52
- * self.mode_ = Lexer.MODE_NORMAL_
- *
- * def __iter__(self): # <<<<<<<<<<<<<<
- * return self
- *
- */
- __pyx_tuple__21 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(0, 52, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__21);
- __Pyx_GIVEREF(__pyx_tuple__21);
- __pyx_codeobj__22 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__21, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Lib_fontTools_feaLib_lexer_py, __pyx_n_s_iter, 52, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__22)) __PYX_ERR(0, 52, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":55
- * return self
- *
- * def next(self): # Python 2 # <<<<<<<<<<<<<<
- * return self.__next__()
- *
- */
- __pyx_tuple__23 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(0, 55, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__23);
- __Pyx_GIVEREF(__pyx_tuple__23);
- __pyx_codeobj__24 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__23, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Lib_fontTools_feaLib_lexer_py, __pyx_n_s_next_3, 55, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__24)) __PYX_ERR(0, 55, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":58
- * return self.__next__()
- *
- * def __next__(self): # Python 3 # <<<<<<<<<<<<<<
- * while True:
- * token_type, token, location = self.next_()
- */
- __pyx_tuple__25 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_token_type, __pyx_n_s_token, __pyx_n_s_location_2); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(0, 58, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__25);
- __Pyx_GIVEREF(__pyx_tuple__25);
- __pyx_codeobj__26 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__25, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Lib_fontTools_feaLib_lexer_py, __pyx_n_s_next, 58, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__26)) __PYX_ERR(0, 58, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":64
- * return (token_type, token, location)
- *
- * def location_(self): # <<<<<<<<<<<<<<
- * column = self.pos_ - self.line_start_ + 1
- * return FeatureLibLocation(self.filename_ or "", self.line_, column)
- */
- __pyx_tuple__27 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_column); if (unlikely(!__pyx_tuple__27)) __PYX_ERR(0, 64, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__27);
- __Pyx_GIVEREF(__pyx_tuple__27);
- __pyx_codeobj__28 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__27, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Lib_fontTools_feaLib_lexer_py, __pyx_n_s_location, 64, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__28)) __PYX_ERR(0, 64, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":68
- * return FeatureLibLocation(self.filename_ or "", self.line_, column)
- *
- * def next_(self): # <<<<<<<<<<<<<<
- * self.scan_over_(Lexer.CHAR_WHITESPACE_)
- * location = self.location_()
- */
- __pyx_tuple__29 = PyTuple_Pack(10, __pyx_n_s_self, __pyx_n_s_location_2, __pyx_n_s_start, __pyx_n_s_text, __pyx_n_s_limit, __pyx_n_s_cur_char, __pyx_n_s_next_char, __pyx_n_s_glyphclass, __pyx_n_s_token, __pyx_n_s_string); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(0, 68, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__29);
- __Pyx_GIVEREF(__pyx_tuple__29);
- __pyx_codeobj__30 = (PyObject*)__Pyx_PyCode_New(1, 0, 10, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__29, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Lib_fontTools_feaLib_lexer_py, __pyx_n_s_next_2, 68, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__30)) __PYX_ERR(0, 68, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":169
- * raise FeatureLibError("Unexpected character: %r" % cur_char, location)
- *
- * def scan_over_(self, valid): # <<<<<<<<<<<<<<
- * p = self.pos_
- * while p < self.text_length_ and self.text_[p] in valid:
- */
- __pyx_tuple__31 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_valid, __pyx_n_s_p); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(0, 169, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__31);
- __Pyx_GIVEREF(__pyx_tuple__31);
- __pyx_codeobj__32 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__31, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Lib_fontTools_feaLib_lexer_py, __pyx_n_s_scan_over, 169, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__32)) __PYX_ERR(0, 169, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":175
- * self.pos_ = p
- *
- * def scan_until_(self, stop_at): # <<<<<<<<<<<<<<
- * p = self.pos_
- * while p < self.text_length_ and self.text_[p] not in stop_at:
- */
- __pyx_tuple__33 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_stop_at, __pyx_n_s_p); if (unlikely(!__pyx_tuple__33)) __PYX_ERR(0, 175, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__33);
- __Pyx_GIVEREF(__pyx_tuple__33);
- __pyx_codeobj__34 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__33, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Lib_fontTools_feaLib_lexer_py, __pyx_n_s_scan_until, 175, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__34)) __PYX_ERR(0, 175, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":181
- * self.pos_ = p
- *
- * def scan_anonymous_block(self, tag): # <<<<<<<<<<<<<<
- * location = self.location_()
- * tag = tag.strip()
- */
- __pyx_tuple__35 = PyTuple_Pack(5, __pyx_n_s_self, __pyx_n_s_tag, __pyx_n_s_location_2, __pyx_n_s_regexp, __pyx_n_s_split); if (unlikely(!__pyx_tuple__35)) __PYX_ERR(0, 181, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__35);
- __Pyx_GIVEREF(__pyx_tuple__35);
- __pyx_codeobj__36 = (PyObject*)__Pyx_PyCode_New(2, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__35, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Lib_fontTools_feaLib_lexer_py, __pyx_n_s_scan_anonymous_block, 181, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__36)) __PYX_ERR(0, 181, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":196
- *
- *
- * class IncludingLexer(object): # <<<<<<<<<<<<<<
- * """A Lexer that follows include statements.
- *
- */
- __pyx_tuple__37 = PyTuple_Pack(1, __pyx_builtin_object); if (unlikely(!__pyx_tuple__37)) __PYX_ERR(0, 196, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__37);
- __Pyx_GIVEREF(__pyx_tuple__37);
-
- /* "fontTools/feaLib/lexer.py":211
- * """
- *
- * def __init__(self, featurefile, *, includeDir=None): # <<<<<<<<<<<<<<
- * """Initializes an IncludingLexer.
- *
- */
- __pyx_tuple__38 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_featurefile, __pyx_n_s_includeDir); if (unlikely(!__pyx_tuple__38)) __PYX_ERR(0, 211, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__38);
- __Pyx_GIVEREF(__pyx_tuple__38);
- __pyx_codeobj__39 = (PyObject*)__Pyx_PyCode_New(2, 1, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__38, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Lib_fontTools_feaLib_lexer_py, __pyx_n_s_init, 211, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__39)) __PYX_ERR(0, 211, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":225
- * self.includeDir = includeDir
- *
- * def __iter__(self): # <<<<<<<<<<<<<<
- * return self
- *
- */
- __pyx_tuple__40 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__40)) __PYX_ERR(0, 225, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__40);
- __Pyx_GIVEREF(__pyx_tuple__40);
- __pyx_codeobj__41 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__40, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Lib_fontTools_feaLib_lexer_py, __pyx_n_s_iter, 225, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__41)) __PYX_ERR(0, 225, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":228
- * return self
- *
- * def next(self): # Python 2 # <<<<<<<<<<<<<<
- * return self.__next__()
- *
- */
- __pyx_tuple__42 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__42)) __PYX_ERR(0, 228, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__42);
- __Pyx_GIVEREF(__pyx_tuple__42);
- __pyx_codeobj__43 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__42, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Lib_fontTools_feaLib_lexer_py, __pyx_n_s_next_3, 228, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__43)) __PYX_ERR(0, 228, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":231
- * return self.__next__()
- *
- * def __next__(self): # Python 3 # <<<<<<<<<<<<<<
- * while self.lexers_:
- * lexer = self.lexers_[-1]
- */
- __pyx_tuple__44 = PyTuple_Pack(11, __pyx_n_s_self, __pyx_n_s_lexer, __pyx_n_s_token_type, __pyx_n_s_token, __pyx_n_s_location_2, __pyx_n_s_fname_type, __pyx_n_s_fname_token, __pyx_n_s_fname_location, __pyx_n_s_path, __pyx_n_s_curpath, __pyx_n_s_err); if (unlikely(!__pyx_tuple__44)) __PYX_ERR(0, 231, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__44);
- __Pyx_GIVEREF(__pyx_tuple__44);
- __pyx_codeobj__45 = (PyObject*)__Pyx_PyCode_New(1, 0, 11, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__44, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Lib_fontTools_feaLib_lexer_py, __pyx_n_s_next, 231, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__45)) __PYX_ERR(0, 231, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":271
- *
- * @staticmethod
- * def make_lexer_(file_or_path): # <<<<<<<<<<<<<<
- * if hasattr(file_or_path, "read"):
- * fileobj, closing = file_or_path, False
- */
- __pyx_tuple__46 = PyTuple_Pack(5, __pyx_n_s_file_or_path, __pyx_n_s_fileobj, __pyx_n_s_closing, __pyx_n_s_filename, __pyx_n_s_data); if (unlikely(!__pyx_tuple__46)) __PYX_ERR(0, 271, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__46);
- __Pyx_GIVEREF(__pyx_tuple__46);
- __pyx_codeobj__47 = (PyObject*)__Pyx_PyCode_New(1, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__46, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Lib_fontTools_feaLib_lexer_py, __pyx_n_s_make_lexer, 271, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__47)) __PYX_ERR(0, 271, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":283
- * return Lexer(data, filename)
- *
- * def scan_anonymous_block(self, tag): # <<<<<<<<<<<<<<
- * return self.lexers_[-1].scan_anonymous_block(tag)
- *
- */
- __pyx_tuple__48 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_tag); if (unlikely(!__pyx_tuple__48)) __PYX_ERR(0, 283, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__48);
- __Pyx_GIVEREF(__pyx_tuple__48);
- __pyx_codeobj__49 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__48, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Lib_fontTools_feaLib_lexer_py, __pyx_n_s_scan_anonymous_block, 283, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__49)) __PYX_ERR(0, 283, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":290
- * """Lexer that does not follow `include` statements, emits them as-is."""
- *
- * def __next__(self): # Python 3 # <<<<<<<<<<<<<<
- * return next(self.lexers_[0])
- */
- __pyx_tuple__50 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__50)) __PYX_ERR(0, 290, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__50);
- __Pyx_GIVEREF(__pyx_tuple__50);
- __pyx_codeobj__51 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__50, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Lib_fontTools_feaLib_lexer_py, __pyx_n_s_next, 290, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__51)) __PYX_ERR(0, 290, __pyx_L1_error)
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
- __pyx_umethod_PyList_Type_pop.type = (PyObject*)&PyList_Type;
- if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_int_8 = PyInt_FromLong(8); if (unlikely(!__pyx_int_8)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_int_10 = PyInt_FromLong(10); if (unlikely(!__pyx_int_10)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_int_16 = PyInt_FromLong(16); if (unlikely(!__pyx_int_16)) __PYX_ERR(0, 1, __pyx_L1_error)
- return 0;
- __pyx_L1_error:;
- return -1;
-}
-
-static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
-static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
-static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
-static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
-static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
-static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
-static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/
-
-static int __Pyx_modinit_global_init_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
- /*--- Global init code ---*/
- __Pyx_RefNannyFinishContext();
- return 0;
-}
-
-static int __Pyx_modinit_variable_export_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
- /*--- Variable export code ---*/
- __Pyx_RefNannyFinishContext();
- return 0;
-}
-
-static int __Pyx_modinit_function_export_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
- /*--- Function export code ---*/
- __Pyx_RefNannyFinishContext();
- return 0;
-}
-
-static int __Pyx_modinit_type_init_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
- /*--- Type init code ---*/
- __Pyx_RefNannyFinishContext();
- return 0;
-}
-
-static int __Pyx_modinit_type_import_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
- /*--- Type import code ---*/
- __Pyx_RefNannyFinishContext();
- return 0;
-}
-
-static int __Pyx_modinit_variable_import_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
- /*--- Variable import code ---*/
- __Pyx_RefNannyFinishContext();
- return 0;
-}
-
-static int __Pyx_modinit_function_import_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
- /*--- Function import code ---*/
- __Pyx_RefNannyFinishContext();
- return 0;
-}
-
-
-#ifndef CYTHON_NO_PYINIT_EXPORT
-#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
-#elif PY_MAJOR_VERSION < 3
-#ifdef __cplusplus
-#define __Pyx_PyMODINIT_FUNC extern "C" void
-#else
-#define __Pyx_PyMODINIT_FUNC void
-#endif
-#else
-#ifdef __cplusplus
-#define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
-#else
-#define __Pyx_PyMODINIT_FUNC PyObject *
-#endif
-#endif
-
-
-#if PY_MAJOR_VERSION < 3
-__Pyx_PyMODINIT_FUNC initlexer(void) CYTHON_SMALL_CODE; /*proto*/
-__Pyx_PyMODINIT_FUNC initlexer(void)
-#else
-__Pyx_PyMODINIT_FUNC PyInit_lexer(void) CYTHON_SMALL_CODE; /*proto*/
-__Pyx_PyMODINIT_FUNC PyInit_lexer(void)
-#if CYTHON_PEP489_MULTI_PHASE_INIT
-{
- return PyModuleDef_Init(&__pyx_moduledef);
-}
-static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
- #if PY_VERSION_HEX >= 0x030700A1
- static PY_INT64_T main_interpreter_id = -1;
- PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
- if (main_interpreter_id == -1) {
- main_interpreter_id = current_id;
- return (unlikely(current_id == -1)) ? -1 : 0;
- } else if (unlikely(main_interpreter_id != current_id))
- #else
- static PyInterpreterState *main_interpreter = NULL;
- PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
- if (!main_interpreter) {
- main_interpreter = current_interpreter;
- } else if (unlikely(main_interpreter != current_interpreter))
- #endif
- {
- PyErr_SetString(
- PyExc_ImportError,
- "Interpreter change detected - this module can only be loaded into one interpreter per process.");
- return -1;
- }
- return 0;
-}
-static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) {
- PyObject *value = PyObject_GetAttrString(spec, from_name);
- int result = 0;
- if (likely(value)) {
- if (allow_none || value != Py_None) {
- result = PyDict_SetItemString(moddict, to_name, value);
- }
- Py_DECREF(value);
- } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
- PyErr_Clear();
- } else {
- result = -1;
- }
- return result;
-}
-static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
- PyObject *module = NULL, *moddict, *modname;
- if (__Pyx_check_single_interpreter())
- return NULL;
- if (__pyx_m)
- return __Pyx_NewRef(__pyx_m);
- modname = PyObject_GetAttrString(spec, "name");
- if (unlikely(!modname)) goto bad;
- module = PyModule_NewObject(modname);
- Py_DECREF(modname);
- if (unlikely(!module)) goto bad;
- moddict = PyModule_GetDict(module);
- if (unlikely(!moddict)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
- return module;
-bad:
- Py_XDECREF(module);
- return NULL;
-}
-
-
-static CYTHON_SMALL_CODE int __pyx_pymod_exec_lexer(PyObject *__pyx_pyinit_module)
-#endif
-#endif
-{
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- PyObject *__pyx_t_8 = NULL;
- PyObject *__pyx_t_9 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannyDeclarations
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- if (__pyx_m) {
- if (__pyx_m == __pyx_pyinit_module) return 0;
- PyErr_SetString(PyExc_RuntimeError, "Module 'lexer' has already been imported. Re-initialisation is not supported.");
- return -1;
- }
- #elif PY_MAJOR_VERSION >= 3
- if (__pyx_m) return __Pyx_NewRef(__pyx_m);
- #endif
- #if CYTHON_REFNANNY
-__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
-if (!__Pyx_RefNanny) {
- PyErr_Clear();
- __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
- if (!__Pyx_RefNanny)
- Py_FatalError("failed to import 'refnanny' module");
-}
-#endif
- __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_lexer(void)", 0);
- if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #ifdef __Pxy_PyFrame_Initialize_Offsets
- __Pxy_PyFrame_Initialize_Offsets();
- #endif
- __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
- #ifdef __Pyx_CyFunction_USED
- if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_FusedFunction_USED
- if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_Coroutine_USED
- if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_Generator_USED
- if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_AsyncGen_USED
- if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_StopAsyncIteration_USED
- if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- /*--- Library function declarations ---*/
- /*--- Threads initialization code ---*/
- #if defined(WITH_THREAD) && PY_VERSION_HEX < 0x030700F0 && defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
- PyEval_InitThreads();
- #endif
- /*--- Module creation code ---*/
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- __pyx_m = __pyx_pyinit_module;
- Py_INCREF(__pyx_m);
- #else
- #if PY_MAJOR_VERSION < 3
- __pyx_m = Py_InitModule4("lexer", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
- #else
- __pyx_m = PyModule_Create(&__pyx_moduledef);
- #endif
- if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_INCREF(__pyx_d);
- __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_INCREF(__pyx_b);
- __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_INCREF(__pyx_cython_runtime);
- if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- /*--- Initialize various global constants etc. ---*/
- if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
- if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- if (__pyx_module_is_main_fontTools__feaLib__lexer) {
- if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name_2, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- }
- #if PY_MAJOR_VERSION >= 3
- {
- PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
- if (!PyDict_GetItemString(modules, "fontTools.feaLib.lexer")) {
- if (unlikely(PyDict_SetItemString(modules, "fontTools.feaLib.lexer", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
- }
- }
- #endif
- /*--- Builtin init code ---*/
- if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- /*--- Constants init code ---*/
- if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- /*--- Global type/function init code ---*/
- (void)__Pyx_modinit_global_init_code();
- (void)__Pyx_modinit_variable_export_code();
- (void)__Pyx_modinit_function_export_code();
- (void)__Pyx_modinit_type_init_code();
- (void)__Pyx_modinit_type_import_code();
- (void)__Pyx_modinit_variable_import_code();
- (void)__Pyx_modinit_function_import_code();
- /*--- Execution code ---*/
- #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
- if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
-
- /* "fontTools/feaLib/lexer.py":1
- * from fontTools.feaLib.error import FeatureLibError, IncludedFeaNotFound # <<<<<<<<<<<<<<
- * from fontTools.feaLib.location import FeatureLibLocation
- * import re
- */
- __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_n_s_FeatureLibError);
- __Pyx_GIVEREF(__pyx_n_s_FeatureLibError);
- PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_FeatureLibError);
- __Pyx_INCREF(__pyx_n_s_IncludedFeaNotFound);
- __Pyx_GIVEREF(__pyx_n_s_IncludedFeaNotFound);
- PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_IncludedFeaNotFound);
- __pyx_t_2 = __Pyx_Import(__pyx_n_s_fontTools_feaLib_error, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_FeatureLibError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_FeatureLibError, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_IncludedFeaNotFound); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_IncludedFeaNotFound, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "fontTools/feaLib/lexer.py":2
- * from fontTools.feaLib.error import FeatureLibError, IncludedFeaNotFound
- * from fontTools.feaLib.location import FeatureLibLocation # <<<<<<<<<<<<<<
- * import re
- * import os
- */
- __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_FeatureLibLocation);
- __Pyx_GIVEREF(__pyx_n_s_FeatureLibLocation);
- PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_FeatureLibLocation);
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_fontTools_feaLib_location, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_FeatureLibLocation); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_FeatureLibLocation, __pyx_t_2) < 0) __PYX_ERR(0, 2, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "fontTools/feaLib/lexer.py":3
- * from fontTools.feaLib.error import FeatureLibError, IncludedFeaNotFound
- * from fontTools.feaLib.location import FeatureLibLocation
- * import re # <<<<<<<<<<<<<<
- * import os
- *
- */
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_re, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_re, __pyx_t_1) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "fontTools/feaLib/lexer.py":4
- * from fontTools.feaLib.location import FeatureLibLocation
- * import re
- * import os # <<<<<<<<<<<<<<
- *
- * try:
- */
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_os, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_os, __pyx_t_1) < 0) __PYX_ERR(0, 4, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "fontTools/feaLib/lexer.py":6
- * import os
- *
- * try: # <<<<<<<<<<<<<<
- * import cython
- * except ImportError:
- */
- {
- (void)__pyx_t_3; (void)__pyx_t_4; (void)__pyx_t_5; /* mark used */
- /*try:*/ {
-
- /* "fontTools/feaLib/lexer.py":7
- *
- * try:
- * import cython # <<<<<<<<<<<<<<
- * except ImportError:
- * # if cython not installed, use mock module with no-op decorators and types
- */
- }
- }
-
- /* "fontTools/feaLib/lexer.py":13
- *
- *
- * class Lexer(object): # <<<<<<<<<<<<<<
- * NUMBER = "NUMBER"
- * HEXADECIMAL = "HEXADECIMAL"
- */
- __pyx_t_1 = __Pyx_CalculateMetaclass(NULL, __pyx_tuple__13); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 13, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_Py3MetaclassPrepare(__pyx_t_1, __pyx_tuple__13, __pyx_n_s_Lexer, __pyx_n_s_Lexer, (PyObject *) NULL, __pyx_n_s_fontTools_feaLib_lexer, (PyObject *) NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 13, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
-
- /* "fontTools/feaLib/lexer.py":14
- *
- * class Lexer(object):
- * NUMBER = "NUMBER" # <<<<<<<<<<<<<<
- * HEXADECIMAL = "HEXADECIMAL"
- * OCTAL = "OCTAL"
- */
- if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_NUMBER, __pyx_n_u_NUMBER) < 0) __PYX_ERR(0, 14, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":15
- * class Lexer(object):
- * NUMBER = "NUMBER"
- * HEXADECIMAL = "HEXADECIMAL" # <<<<<<<<<<<<<<
- * OCTAL = "OCTAL"
- * NUMBERS = (NUMBER, HEXADECIMAL, OCTAL)
- */
- if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_HEXADECIMAL, __pyx_n_u_HEXADECIMAL) < 0) __PYX_ERR(0, 15, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":16
- * NUMBER = "NUMBER"
- * HEXADECIMAL = "HEXADECIMAL"
- * OCTAL = "OCTAL" # <<<<<<<<<<<<<<
- * NUMBERS = (NUMBER, HEXADECIMAL, OCTAL)
- * FLOAT = "FLOAT"
- */
- if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_OCTAL, __pyx_n_u_OCTAL) < 0) __PYX_ERR(0, 16, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":17
- * HEXADECIMAL = "HEXADECIMAL"
- * OCTAL = "OCTAL"
- * NUMBERS = (NUMBER, HEXADECIMAL, OCTAL) # <<<<<<<<<<<<<<
- * FLOAT = "FLOAT"
- * STRING = "STRING"
- */
- __pyx_t_6 = PyObject_GetItem(__pyx_t_2, __pyx_n_s_NUMBER);
- if (unlikely(!__pyx_t_6)) {
- PyErr_Clear();
- __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_NUMBER);
- }
- if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 17, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __pyx_t_7 = PyObject_GetItem(__pyx_t_2, __pyx_n_s_HEXADECIMAL);
- if (unlikely(!__pyx_t_7)) {
- PyErr_Clear();
- __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_HEXADECIMAL);
- }
- if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 17, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __pyx_t_8 = PyObject_GetItem(__pyx_t_2, __pyx_n_s_OCTAL);
- if (unlikely(!__pyx_t_8)) {
- PyErr_Clear();
- __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_OCTAL);
- }
- if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 17, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 17, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_GIVEREF(__pyx_t_6);
- PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_6);
- __Pyx_GIVEREF(__pyx_t_7);
- PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_7);
- __Pyx_GIVEREF(__pyx_t_8);
- PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_8);
- __pyx_t_6 = 0;
- __pyx_t_7 = 0;
- __pyx_t_8 = 0;
- if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_NUMBERS, __pyx_t_9) < 0) __PYX_ERR(0, 17, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
-
- /* "fontTools/feaLib/lexer.py":18
- * OCTAL = "OCTAL"
- * NUMBERS = (NUMBER, HEXADECIMAL, OCTAL)
- * FLOAT = "FLOAT" # <<<<<<<<<<<<<<
- * STRING = "STRING"
- * NAME = "NAME"
- */
- if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_FLOAT, __pyx_n_u_FLOAT) < 0) __PYX_ERR(0, 18, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":19
- * NUMBERS = (NUMBER, HEXADECIMAL, OCTAL)
- * FLOAT = "FLOAT"
- * STRING = "STRING" # <<<<<<<<<<<<<<
- * NAME = "NAME"
- * FILENAME = "FILENAME"
- */
- if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_STRING, __pyx_n_u_STRING) < 0) __PYX_ERR(0, 19, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":20
- * FLOAT = "FLOAT"
- * STRING = "STRING"
- * NAME = "NAME" # <<<<<<<<<<<<<<
- * FILENAME = "FILENAME"
- * GLYPHCLASS = "GLYPHCLASS"
- */
- if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_NAME, __pyx_n_u_NAME) < 0) __PYX_ERR(0, 20, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":21
- * STRING = "STRING"
- * NAME = "NAME"
- * FILENAME = "FILENAME" # <<<<<<<<<<<<<<
- * GLYPHCLASS = "GLYPHCLASS"
- * CID = "CID"
- */
- if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_FILENAME, __pyx_n_u_FILENAME) < 0) __PYX_ERR(0, 21, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":22
- * NAME = "NAME"
- * FILENAME = "FILENAME"
- * GLYPHCLASS = "GLYPHCLASS" # <<<<<<<<<<<<<<
- * CID = "CID"
- * SYMBOL = "SYMBOL"
- */
- if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_GLYPHCLASS, __pyx_n_u_GLYPHCLASS) < 0) __PYX_ERR(0, 22, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":23
- * FILENAME = "FILENAME"
- * GLYPHCLASS = "GLYPHCLASS"
- * CID = "CID" # <<<<<<<<<<<<<<
- * SYMBOL = "SYMBOL"
- * COMMENT = "COMMENT"
- */
- if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_CID, __pyx_n_u_CID) < 0) __PYX_ERR(0, 23, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":24
- * GLYPHCLASS = "GLYPHCLASS"
- * CID = "CID"
- * SYMBOL = "SYMBOL" # <<<<<<<<<<<<<<
- * COMMENT = "COMMENT"
- * NEWLINE = "NEWLINE"
- */
- if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_SYMBOL, __pyx_n_u_SYMBOL) < 0) __PYX_ERR(0, 24, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":25
- * CID = "CID"
- * SYMBOL = "SYMBOL"
- * COMMENT = "COMMENT" # <<<<<<<<<<<<<<
- * NEWLINE = "NEWLINE"
- * ANONYMOUS_BLOCK = "ANONYMOUS_BLOCK"
- */
- if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_COMMENT, __pyx_n_u_COMMENT) < 0) __PYX_ERR(0, 25, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":26
- * SYMBOL = "SYMBOL"
- * COMMENT = "COMMENT"
- * NEWLINE = "NEWLINE" # <<<<<<<<<<<<<<
- * ANONYMOUS_BLOCK = "ANONYMOUS_BLOCK"
- *
- */
- if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_NEWLINE, __pyx_n_u_NEWLINE) < 0) __PYX_ERR(0, 26, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":27
- * COMMENT = "COMMENT"
- * NEWLINE = "NEWLINE"
- * ANONYMOUS_BLOCK = "ANONYMOUS_BLOCK" # <<<<<<<<<<<<<<
- *
- * CHAR_WHITESPACE_ = " \t"
- */
- if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_ANONYMOUS_BLOCK, __pyx_n_u_ANONYMOUS_BLOCK) < 0) __PYX_ERR(0, 27, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":29
- * ANONYMOUS_BLOCK = "ANONYMOUS_BLOCK"
- *
- * CHAR_WHITESPACE_ = " \t" # <<<<<<<<<<<<<<
- * CHAR_NEWLINE_ = "\r\n"
- * CHAR_SYMBOL_ = ",;:-+'{}[]<>()="
- */
- if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_CHAR_WHITESPACE, __pyx_kp_u__14) < 0) __PYX_ERR(0, 29, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":30
- *
- * CHAR_WHITESPACE_ = " \t"
- * CHAR_NEWLINE_ = "\r\n" # <<<<<<<<<<<<<<
- * CHAR_SYMBOL_ = ",;:-+'{}[]<>()="
- * CHAR_DIGIT_ = "0123456789"
- */
- if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_CHAR_NEWLINE, __pyx_kp_u__15) < 0) __PYX_ERR(0, 30, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":31
- * CHAR_WHITESPACE_ = " \t"
- * CHAR_NEWLINE_ = "\r\n"
- * CHAR_SYMBOL_ = ",;:-+'{}[]<>()=" # <<<<<<<<<<<<<<
- * CHAR_DIGIT_ = "0123456789"
- * CHAR_HEXDIGIT_ = "0123456789ABCDEFabcdef"
- */
- if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_CHAR_SYMBOL, __pyx_kp_u__16) < 0) __PYX_ERR(0, 31, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":32
- * CHAR_NEWLINE_ = "\r\n"
- * CHAR_SYMBOL_ = ",;:-+'{}[]<>()="
- * CHAR_DIGIT_ = "0123456789" # <<<<<<<<<<<<<<
- * CHAR_HEXDIGIT_ = "0123456789ABCDEFabcdef"
- * CHAR_LETTER_ = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
- */
- if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_CHAR_DIGIT, __pyx_kp_u_0123456789) < 0) __PYX_ERR(0, 32, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":33
- * CHAR_SYMBOL_ = ",;:-+'{}[]<>()="
- * CHAR_DIGIT_ = "0123456789"
- * CHAR_HEXDIGIT_ = "0123456789ABCDEFabcdef" # <<<<<<<<<<<<<<
- * CHAR_LETTER_ = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
- * CHAR_NAME_START_ = CHAR_LETTER_ + "_+*:.^~!\\"
- */
- if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_CHAR_HEXDIGIT, __pyx_kp_u_0123456789ABCDEFabcdef) < 0) __PYX_ERR(0, 33, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":34
- * CHAR_DIGIT_ = "0123456789"
- * CHAR_HEXDIGIT_ = "0123456789ABCDEFabcdef"
- * CHAR_LETTER_ = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" # <<<<<<<<<<<<<<
- * CHAR_NAME_START_ = CHAR_LETTER_ + "_+*:.^~!\\"
- * CHAR_NAME_CONTINUATION_ = CHAR_LETTER_ + CHAR_DIGIT_ + "_.+*:^~!/-"
- */
- if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_CHAR_LETTER, __pyx_n_u_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef) < 0) __PYX_ERR(0, 34, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":35
- * CHAR_HEXDIGIT_ = "0123456789ABCDEFabcdef"
- * CHAR_LETTER_ = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
- * CHAR_NAME_START_ = CHAR_LETTER_ + "_+*:.^~!\\" # <<<<<<<<<<<<<<
- * CHAR_NAME_CONTINUATION_ = CHAR_LETTER_ + CHAR_DIGIT_ + "_.+*:^~!/-"
- *
- */
- __pyx_t_9 = PyObject_GetItem(__pyx_t_2, __pyx_n_s_CHAR_LETTER);
- if (unlikely(!__pyx_t_9)) {
- PyErr_Clear();
- __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_CHAR_LETTER);
- }
- if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 35, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- __pyx_t_8 = PyNumber_Add(__pyx_t_9, __pyx_kp_u__17); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 35, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_CHAR_NAME_START, __pyx_t_8) < 0) __PYX_ERR(0, 35, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
-
- /* "fontTools/feaLib/lexer.py":36
- * CHAR_LETTER_ = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
- * CHAR_NAME_START_ = CHAR_LETTER_ + "_+*:.^~!\\"
- * CHAR_NAME_CONTINUATION_ = CHAR_LETTER_ + CHAR_DIGIT_ + "_.+*:^~!/-" # <<<<<<<<<<<<<<
- *
- * RE_GLYPHCLASS = re.compile(r"^[A-Za-z_0-9.\-]+$")
- */
- __pyx_t_8 = PyObject_GetItem(__pyx_t_2, __pyx_n_s_CHAR_LETTER);
- if (unlikely(!__pyx_t_8)) {
- PyErr_Clear();
- __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_CHAR_LETTER);
- }
- if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 36, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- __pyx_t_9 = PyObject_GetItem(__pyx_t_2, __pyx_n_s_CHAR_DIGIT);
- if (unlikely(!__pyx_t_9)) {
- PyErr_Clear();
- __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_CHAR_DIGIT);
- }
- if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 36, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- __pyx_t_7 = PyNumber_Add(__pyx_t_8, __pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 36, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- __pyx_t_9 = PyNumber_Add(__pyx_t_7, __pyx_kp_u__18); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 36, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_CHAR_NAME_CONTINUATION, __pyx_t_9) < 0) __PYX_ERR(0, 36, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
-
- /* "fontTools/feaLib/lexer.py":38
- * CHAR_NAME_CONTINUATION_ = CHAR_LETTER_ + CHAR_DIGIT_ + "_.+*:^~!/-"
- *
- * RE_GLYPHCLASS = re.compile(r"^[A-Za-z_0-9.\-]+$") # <<<<<<<<<<<<<<
- *
- * MODE_NORMAL_ = "NORMAL"
- */
- __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_re); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 38, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_compile); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 38, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- __pyx_t_7 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
- __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8);
- if (likely(__pyx_t_7)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
- __Pyx_INCREF(__pyx_t_7);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_8, function);
- }
- }
- __pyx_t_9 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_7, __pyx_kp_u_A_Za_z_0_9) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_kp_u_A_Za_z_0_9);
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 38, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_RE_GLYPHCLASS, __pyx_t_9) < 0) __PYX_ERR(0, 38, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
-
- /* "fontTools/feaLib/lexer.py":40
- * RE_GLYPHCLASS = re.compile(r"^[A-Za-z_0-9.\-]+$")
- *
- * MODE_NORMAL_ = "NORMAL" # <<<<<<<<<<<<<<
- * MODE_FILENAME_ = "FILENAME"
- *
- */
- if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_MODE_NORMAL, __pyx_n_u_NORMAL) < 0) __PYX_ERR(0, 40, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":41
- *
- * MODE_NORMAL_ = "NORMAL"
- * MODE_FILENAME_ = "FILENAME" # <<<<<<<<<<<<<<
- *
- * def __init__(self, text, filename):
- */
- if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_MODE_FILENAME, __pyx_n_u_FILENAME) < 0) __PYX_ERR(0, 41, __pyx_L1_error)
-
- /* "fontTools/feaLib/lexer.py":43
- * MODE_FILENAME_ = "FILENAME"
- *
- * def __init__(self, text, filename): # <<<<<<<<<<<<<<
- * self.filename_ = filename
- * self.line_ = 1
- */
- __pyx_t_9 = __Pyx_CyFunction_New(&__pyx_mdef_9fontTools_6feaLib_5lexer_5Lexer_1__init__, 0, __pyx_n_s_Lexer___init, NULL, __pyx_n_s_fontTools_feaLib_lexer, __pyx_d, ((PyObject *)__pyx_codeobj__20)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 43, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_init, __pyx_t_9) < 0) __PYX_ERR(0, 43, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
-
- /* "fontTools/feaLib/lexer.py":52
- * self.mode_ = Lexer.MODE_NORMAL_
- *
- * def __iter__(self): # <<<<<<<<<<<<<<
- * return self
- *
- */
- __pyx_t_9 = __Pyx_CyFunction_New(&__pyx_mdef_9fontTools_6feaLib_5lexer_5Lexer_3__iter__, 0, __pyx_n_s_Lexer___iter, NULL, __pyx_n_s_fontTools_feaLib_lexer, __pyx_d, ((PyObject *)__pyx_codeobj__22)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 52, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_iter, __pyx_t_9) < 0) __PYX_ERR(0, 52, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
-
- /* "fontTools/feaLib/lexer.py":55
- * return self
- *
- * def next(self): # Python 2 # <<<<<<<<<<<<<<
- * return self.__next__()
- *
- */
- __pyx_t_9 = __Pyx_CyFunction_New(&__pyx_mdef_9fontTools_6feaLib_5lexer_5Lexer_5next, 0, __pyx_n_s_Lexer_next, NULL, __pyx_n_s_fontTools_feaLib_lexer, __pyx_d, ((PyObject *)__pyx_codeobj__24)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 55, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_next_3, __pyx_t_9) < 0) __PYX_ERR(0, 55, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
-
- /* "fontTools/feaLib/lexer.py":58
- * return self.__next__()
- *
- * def __next__(self): # Python 3 # <<<<<<<<<<<<<<
- * while True:
- * token_type, token, location = self.next_()
- */
- __pyx_t_9 = __Pyx_CyFunction_New(&__pyx_mdef_9fontTools_6feaLib_5lexer_5Lexer_7__next__, 0, __pyx_n_s_Lexer___next, NULL, __pyx_n_s_fontTools_feaLib_lexer, __pyx_d, ((PyObject *)__pyx_codeobj__26)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 58, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_next, __pyx_t_9) < 0) __PYX_ERR(0, 58, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
-
- /* "fontTools/feaLib/lexer.py":64
- * return (token_type, token, location)
- *
- * def location_(self): # <<<<<<<<<<<<<<
- * column = self.pos_ - self.line_start_ + 1
- * return FeatureLibLocation(self.filename_ or "", self.line_, column)
- */
- __pyx_t_9 = __Pyx_CyFunction_New(&__pyx_mdef_9fontTools_6feaLib_5lexer_5Lexer_9location_, 0, __pyx_n_s_Lexer_location, NULL, __pyx_n_s_fontTools_feaLib_lexer, __pyx_d, ((PyObject *)__pyx_codeobj__28)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 64, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_location, __pyx_t_9) < 0) __PYX_ERR(0, 64, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
-
- /* "fontTools/feaLib/lexer.py":68
- * return FeatureLibLocation(self.filename_ or "", self.line_, column)
- *
- * def next_(self): # <<<<<<<<<<<<<<
- * self.scan_over_(Lexer.CHAR_WHITESPACE_)
- * location = self.location_()
- */
- __pyx_t_9 = __Pyx_CyFunction_New(&__pyx_mdef_9fontTools_6feaLib_5lexer_5Lexer_11next_, 0, __pyx_n_s_Lexer_next_2, NULL, __pyx_n_s_fontTools_feaLib_lexer, __pyx_d, ((PyObject *)__pyx_codeobj__30)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 68, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_next_2, __pyx_t_9) < 0) __PYX_ERR(0, 68, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
-
- /* "fontTools/feaLib/lexer.py":169
- * raise FeatureLibError("Unexpected character: %r" % cur_char, location)
- *
- * def scan_over_(self, valid): # <<<<<<<<<<<<<<
- * p = self.pos_
- * while p < self.text_length_ and self.text_[p] in valid:
- */
- __pyx_t_9 = __Pyx_CyFunction_New(&__pyx_mdef_9fontTools_6feaLib_5lexer_5Lexer_13scan_over_, 0, __pyx_n_s_Lexer_scan_over, NULL, __pyx_n_s_fontTools_feaLib_lexer, __pyx_d, ((PyObject *)__pyx_codeobj__32)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 169, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_scan_over, __pyx_t_9) < 0) __PYX_ERR(0, 169, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
-
- /* "fontTools/feaLib/lexer.py":175
- * self.pos_ = p
- *
- * def scan_until_(self, stop_at): # <<<<<<<<<<<<<<
- * p = self.pos_
- * while p < self.text_length_ and self.text_[p] not in stop_at:
- */
- __pyx_t_9 = __Pyx_CyFunction_New(&__pyx_mdef_9fontTools_6feaLib_5lexer_5Lexer_15scan_until_, 0, __pyx_n_s_Lexer_scan_until, NULL, __pyx_n_s_fontTools_feaLib_lexer, __pyx_d, ((PyObject *)__pyx_codeobj__34)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 175, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_scan_until, __pyx_t_9) < 0) __PYX_ERR(0, 175, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
-
- /* "fontTools/feaLib/lexer.py":181
- * self.pos_ = p
- *
- * def scan_anonymous_block(self, tag): # <<<<<<<<<<<<<<
- * location = self.location_()
- * tag = tag.strip()
- */
- __pyx_t_9 = __Pyx_CyFunction_New(&__pyx_mdef_9fontTools_6feaLib_5lexer_5Lexer_17scan_anonymous_block, 0, __pyx_n_s_Lexer_scan_anonymous_block, NULL, __pyx_n_s_fontTools_feaLib_lexer, __pyx_d, ((PyObject *)__pyx_codeobj__36)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 181, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_scan_anonymous_block, __pyx_t_9) < 0) __PYX_ERR(0, 181, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
-
- /* "fontTools/feaLib/lexer.py":13
- *
- *
- * class Lexer(object): # <<<<<<<<<<<<<<
- * NUMBER = "NUMBER"
- * HEXADECIMAL = "HEXADECIMAL"
- */
- __pyx_t_9 = __Pyx_Py3ClassCreate(__pyx_t_1, __pyx_n_s_Lexer, __pyx_tuple__13, __pyx_t_2, NULL, 0, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 13, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_Lexer, __pyx_t_9) < 0) __PYX_ERR(0, 13, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "fontTools/feaLib/lexer.py":196
- *
- *
- * class IncludingLexer(object): # <<<<<<<<<<<<<<
- * """A Lexer that follows include statements.
- *
- */
- __pyx_t_1 = __Pyx_CalculateMetaclass(NULL, __pyx_tuple__37); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 196, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_Py3MetaclassPrepare(__pyx_t_1, __pyx_tuple__37, __pyx_n_s_IncludingLexer, __pyx_n_s_IncludingLexer, (PyObject *) NULL, __pyx_n_s_fontTools_feaLib_lexer, __pyx_kp_s_A_Lexer_that_follows_include_sta); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 196, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
-
- /* "fontTools/feaLib/lexer.py":211
- * """
- *
- * def __init__(self, featurefile, *, includeDir=None): # <<<<<<<<<<<<<<
- * """Initializes an IncludingLexer.
- *
- */
- __pyx_t_9 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 211, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_includeDir, ((PyObject *)Py_None)) < 0) __PYX_ERR(0, 211, __pyx_L1_error)
- __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_9fontTools_6feaLib_5lexer_14IncludingLexer_1__init__, 0, __pyx_n_s_IncludingLexer___init, NULL, __pyx_n_s_fontTools_feaLib_lexer, __pyx_d, ((PyObject *)__pyx_codeobj__39)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 211, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- __Pyx_CyFunction_SetDefaultsKwDict(__pyx_t_8, __pyx_t_9);
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_init, __pyx_t_8) < 0) __PYX_ERR(0, 211, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
-
- /* "fontTools/feaLib/lexer.py":225
- * self.includeDir = includeDir
- *
- * def __iter__(self): # <<<<<<<<<<<<<<
- * return self
- *
- */
- __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_9fontTools_6feaLib_5lexer_14IncludingLexer_3__iter__, 0, __pyx_n_s_IncludingLexer___iter, NULL, __pyx_n_s_fontTools_feaLib_lexer, __pyx_d, ((PyObject *)__pyx_codeobj__41)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 225, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_iter, __pyx_t_8) < 0) __PYX_ERR(0, 225, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
-
- /* "fontTools/feaLib/lexer.py":228
- * return self
- *
- * def next(self): # Python 2 # <<<<<<<<<<<<<<
- * return self.__next__()
- *
- */
- __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_9fontTools_6feaLib_5lexer_14IncludingLexer_5next, 0, __pyx_n_s_IncludingLexer_next, NULL, __pyx_n_s_fontTools_feaLib_lexer, __pyx_d, ((PyObject *)__pyx_codeobj__43)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 228, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_next_3, __pyx_t_8) < 0) __PYX_ERR(0, 228, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
-
- /* "fontTools/feaLib/lexer.py":231
- * return self.__next__()
- *
- * def __next__(self): # Python 3 # <<<<<<<<<<<<<<
- * while self.lexers_:
- * lexer = self.lexers_[-1]
- */
- __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_9fontTools_6feaLib_5lexer_14IncludingLexer_7__next__, 0, __pyx_n_s_IncludingLexer___next, NULL, __pyx_n_s_fontTools_feaLib_lexer, __pyx_d, ((PyObject *)__pyx_codeobj__45)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 231, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_next, __pyx_t_8) < 0) __PYX_ERR(0, 231, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
-
- /* "fontTools/feaLib/lexer.py":271
- *
- * @staticmethod
- * def make_lexer_(file_or_path): # <<<<<<<<<<<<<<
- * if hasattr(file_or_path, "read"):
- * fileobj, closing = file_or_path, False
- */
- __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_9fontTools_6feaLib_5lexer_14IncludingLexer_9make_lexer_, __Pyx_CYFUNCTION_STATICMETHOD, __pyx_n_s_IncludingLexer_make_lexer, NULL, __pyx_n_s_fontTools_feaLib_lexer, __pyx_d, ((PyObject *)__pyx_codeobj__47)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 271, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
-
- /* "fontTools/feaLib/lexer.py":270
- * raise StopIteration()
- *
- * @staticmethod # <<<<<<<<<<<<<<
- * def make_lexer_(file_or_path):
- * if hasattr(file_or_path, "read"):
- */
- __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_staticmethod, __pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 270, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_make_lexer, __pyx_t_9) < 0) __PYX_ERR(0, 271, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
-
- /* "fontTools/feaLib/lexer.py":283
- * return Lexer(data, filename)
- *
- * def scan_anonymous_block(self, tag): # <<<<<<<<<<<<<<
- * return self.lexers_[-1].scan_anonymous_block(tag)
- *
- */
- __pyx_t_9 = __Pyx_CyFunction_New(&__pyx_mdef_9fontTools_6feaLib_5lexer_14IncludingLexer_11scan_anonymous_block, 0, __pyx_n_s_IncludingLexer_scan_anonymous_bl, NULL, __pyx_n_s_fontTools_feaLib_lexer, __pyx_d, ((PyObject *)__pyx_codeobj__49)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 283, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_scan_anonymous_block, __pyx_t_9) < 0) __PYX_ERR(0, 283, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
-
- /* "fontTools/feaLib/lexer.py":196
- *
- *
- * class IncludingLexer(object): # <<<<<<<<<<<<<<
- * """A Lexer that follows include statements.
- *
- */
- __pyx_t_9 = __Pyx_Py3ClassCreate(__pyx_t_1, __pyx_n_s_IncludingLexer, __pyx_tuple__37, __pyx_t_2, NULL, 0, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 196, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_IncludingLexer, __pyx_t_9) < 0) __PYX_ERR(0, 196, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "fontTools/feaLib/lexer.py":287
- *
- *
- * class NonIncludingLexer(IncludingLexer): # <<<<<<<<<<<<<<
- * """Lexer that does not follow `include` statements, emits them as-is."""
- *
- */
- __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_IncludingLexer); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 287, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 287, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
- __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_CalculateMetaclass(NULL, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 287, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_9 = __Pyx_Py3MetaclassPrepare(__pyx_t_1, __pyx_t_2, __pyx_n_s_NonIncludingLexer, __pyx_n_s_NonIncludingLexer, (PyObject *) NULL, __pyx_n_s_fontTools_feaLib_lexer, __pyx_kp_s_Lexer_that_does_not_follow_inclu); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 287, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
-
- /* "fontTools/feaLib/lexer.py":290
- * """Lexer that does not follow `include` statements, emits them as-is."""
- *
- * def __next__(self): # Python 3 # <<<<<<<<<<<<<<
- * return next(self.lexers_[0])
- */
- __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_9fontTools_6feaLib_5lexer_17NonIncludingLexer_1__next__, 0, __pyx_n_s_NonIncludingLexer___next, NULL, __pyx_n_s_fontTools_feaLib_lexer, __pyx_d, ((PyObject *)__pyx_codeobj__51)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 290, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_n_s_next, __pyx_t_8) < 0) __PYX_ERR(0, 290, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
-
- /* "fontTools/feaLib/lexer.py":287
- *
- *
- * class NonIncludingLexer(IncludingLexer): # <<<<<<<<<<<<<<
- * """Lexer that does not follow `include` statements, emits them as-is."""
- *
- */
- __pyx_t_8 = __Pyx_Py3ClassCreate(__pyx_t_1, __pyx_n_s_NonIncludingLexer, __pyx_t_2, __pyx_t_9, NULL, 0, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 287, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_NonIncludingLexer, __pyx_t_8) < 0) __PYX_ERR(0, 287, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "fontTools/feaLib/lexer.py":1
- * from fontTools.feaLib.error import FeatureLibError, IncludedFeaNotFound # <<<<<<<<<<<<<<
- * from fontTools.feaLib.location import FeatureLibLocation
- * import re
- */
- __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /*--- Wrapped vars code ---*/
-
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_XDECREF(__pyx_t_8);
- __Pyx_XDECREF(__pyx_t_9);
- if (__pyx_m) {
- if (__pyx_d) {
- __Pyx_AddTraceback("init fontTools.feaLib.lexer", __pyx_clineno, __pyx_lineno, __pyx_filename);
- }
- Py_CLEAR(__pyx_m);
- } else if (!PyErr_Occurred()) {
- PyErr_SetString(PyExc_ImportError, "init fontTools.feaLib.lexer");
- }
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- return (__pyx_m != NULL) ? 0 : -1;
- #elif PY_MAJOR_VERSION >= 3
- return __pyx_m;
- #else
- return;
- #endif
-}
-
-/* --- Runtime support code --- */
-/* Refnanny */
-#if CYTHON_REFNANNY
-static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
- PyObject *m = NULL, *p = NULL;
- void *r = NULL;
- m = PyImport_ImportModule(modname);
- if (!m) goto end;
- p = PyObject_GetAttrString(m, "RefNannyAPI");
- if (!p) goto end;
- r = PyLong_AsVoidPtr(p);
-end:
- Py_XDECREF(p);
- Py_XDECREF(m);
- return (__Pyx_RefNannyAPIStruct *)r;
-}
-#endif
-
-/* PyObjectGetAttrStr */
-#if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
- PyTypeObject* tp = Py_TYPE(obj);
- if (likely(tp->tp_getattro))
- return tp->tp_getattro(obj, attr_name);
-#if PY_MAJOR_VERSION < 3
- if (likely(tp->tp_getattr))
- return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
-#endif
- return PyObject_GetAttr(obj, attr_name);
-}
-#endif
-
-/* GetBuiltinName */
-static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
- PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
- if (unlikely(!result)) {
- PyErr_Format(PyExc_NameError,
-#if PY_MAJOR_VERSION >= 3
- "name '%U' is not defined", name);
-#else
- "name '%.200s' is not defined", PyString_AS_STRING(name));
-#endif
- }
- return result;
-}
-
-/* RaiseArgTupleInvalid */
-static void __Pyx_RaiseArgtupleInvalid(
- const char* func_name,
- int exact,
- Py_ssize_t num_min,
- Py_ssize_t num_max,
- Py_ssize_t num_found)
-{
- Py_ssize_t num_expected;
- const char *more_or_less;
- if (num_found < num_min) {
- num_expected = num_min;
- more_or_less = "at least";
- } else {
- num_expected = num_max;
- more_or_less = "at most";
- }
- if (exact) {
- more_or_less = "exactly";
- }
- PyErr_Format(PyExc_TypeError,
- "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
- func_name, more_or_less, num_expected,
- (num_expected == 1) ? "" : "s", num_found);
-}
-
-/* RaiseDoubleKeywords */
-static void __Pyx_RaiseDoubleKeywordsError(
- const char* func_name,
- PyObject* kw_name)
-{
- PyErr_Format(PyExc_TypeError,
- #if PY_MAJOR_VERSION >= 3
- "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
- #else
- "%s() got multiple values for keyword argument '%s'", func_name,
- PyString_AsString(kw_name));
- #endif
-}
-
-/* ParseKeywords */
-static int __Pyx_ParseOptionalKeywords(
- PyObject *kwds,
- PyObject **argnames[],
- PyObject *kwds2,
- PyObject *values[],
- Py_ssize_t num_pos_args,
- const char* function_name)
-{
- PyObject *key = 0, *value = 0;
- Py_ssize_t pos = 0;
- PyObject*** name;
- PyObject*** first_kw_arg = argnames + num_pos_args;
- while (PyDict_Next(kwds, &pos, &key, &value)) {
- name = first_kw_arg;
- while (*name && (**name != key)) name++;
- if (*name) {
- values[name-argnames] = value;
- continue;
- }
- name = first_kw_arg;
- #if PY_MAJOR_VERSION < 3
- if (likely(PyString_Check(key))) {
- while (*name) {
- if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
- && _PyString_Eq(**name, key)) {
- values[name-argnames] = value;
- break;
- }
- name++;
- }
- if (*name) continue;
- else {
- PyObject*** argname = argnames;
- while (argname != first_kw_arg) {
- if ((**argname == key) || (
- (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
- && _PyString_Eq(**argname, key))) {
- goto arg_passed_twice;
- }
- argname++;
- }
- }
- } else
- #endif
- if (likely(PyUnicode_Check(key))) {
- while (*name) {
- int cmp = (**name == key) ? 0 :
- #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
- (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
- #endif
- PyUnicode_Compare(**name, key);
- if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
- if (cmp == 0) {
- values[name-argnames] = value;
- break;
- }
- name++;
- }
- if (*name) continue;
- else {
- PyObject*** argname = argnames;
- while (argname != first_kw_arg) {
- int cmp = (**argname == key) ? 0 :
- #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
- (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
- #endif
- PyUnicode_Compare(**argname, key);
- if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
- if (cmp == 0) goto arg_passed_twice;
- argname++;
- }
- }
- } else
- goto invalid_keyword_type;
- if (kwds2) {
- if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
- } else {
- goto invalid_keyword;
- }
- }
- return 0;
-arg_passed_twice:
- __Pyx_RaiseDoubleKeywordsError(function_name, key);
- goto bad;
-invalid_keyword_type:
- PyErr_Format(PyExc_TypeError,
- "%.200s() keywords must be strings", function_name);
- goto bad;
-invalid_keyword:
- PyErr_Format(PyExc_TypeError,
- #if PY_MAJOR_VERSION < 3
- "%.200s() got an unexpected keyword argument '%.200s'",
- function_name, PyString_AsString(key));
- #else
- "%s() got an unexpected keyword argument '%U'",
- function_name, key);
- #endif
-bad:
- return -1;
-}
-
-/* PyObjectSetAttrStr */
-#if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) {
- PyTypeObject* tp = Py_TYPE(obj);
- if (likely(tp->tp_setattro))
- return tp->tp_setattro(obj, attr_name, value);
-#if PY_MAJOR_VERSION < 3
- if (likely(tp->tp_setattr))
- return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value);
-#endif
- return PyObject_SetAttr(obj, attr_name, value);
-}
-#endif
-
-/* PyDictVersioning */
-#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
- PyObject *dict = Py_TYPE(obj)->tp_dict;
- return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
-}
-static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
- PyObject **dictptr = NULL;
- Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
- if (offset) {
-#if CYTHON_COMPILING_IN_CPYTHON
- dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
-#else
- dictptr = _PyObject_GetDictPtr(obj);
-#endif
- }
- return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
-}
-static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
- PyObject *dict = Py_TYPE(obj)->tp_dict;
- if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
- return 0;
- return obj_dict_version == __Pyx_get_object_dict_version(obj);
-}
-#endif
-
-/* GetModuleGlobalName */
-#if CYTHON_USE_DICT_VERSIONS
-static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
-#else
-static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
-#endif
-{
- PyObject *result;
-#if !CYTHON_AVOID_BORROWED_REFS
-#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
- result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
- __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
- if (likely(result)) {
- return __Pyx_NewRef(result);
- } else if (unlikely(PyErr_Occurred())) {
- return NULL;
- }
-#else
- result = PyDict_GetItem(__pyx_d, name);
- __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
- if (likely(result)) {
- return __Pyx_NewRef(result);
- }
-#endif
-#else
- result = PyObject_GetItem(__pyx_d, name);
- __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
- if (likely(result)) {
- return __Pyx_NewRef(result);
- }
- PyErr_Clear();
-#endif
- return __Pyx_GetBuiltinName(name);
-}
-
-/* PyFunctionFastCall */
-#if CYTHON_FAST_PYCALL
-static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
- PyObject *globals) {
- PyFrameObject *f;
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- PyObject **fastlocals;
- Py_ssize_t i;
- PyObject *result;
- assert(globals != NULL);
- /* XXX Perhaps we should create a specialized
- PyFrame_New() that doesn't take locals, but does
- take builtins without sanity checking them.
- */
- assert(tstate != NULL);
- f = PyFrame_New(tstate, co, globals, NULL);
- if (f == NULL) {
- return NULL;
- }
- fastlocals = __Pyx_PyFrame_GetLocalsplus(f);
- for (i = 0; i < na; i++) {
- Py_INCREF(*args);
- fastlocals[i] = *args++;
- }
- result = PyEval_EvalFrameEx(f,0);
- ++tstate->recursion_depth;
- Py_DECREF(f);
- --tstate->recursion_depth;
- return result;
-}
-#if 1 || PY_VERSION_HEX < 0x030600B1
-static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) {
- PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
- PyObject *globals = PyFunction_GET_GLOBALS(func);
- PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
- PyObject *closure;
-#if PY_MAJOR_VERSION >= 3
- PyObject *kwdefs;
-#endif
- PyObject *kwtuple, **k;
- PyObject **d;
- Py_ssize_t nd;
- Py_ssize_t nk;
- PyObject *result;
- assert(kwargs == NULL || PyDict_Check(kwargs));
- nk = kwargs ? PyDict_Size(kwargs) : 0;
- if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
- return NULL;
- }
- if (
-#if PY_MAJOR_VERSION >= 3
- co->co_kwonlyargcount == 0 &&
-#endif
- likely(kwargs == NULL || nk == 0) &&
- co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
- if (argdefs == NULL && co->co_argcount == nargs) {
- result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
- goto done;
- }
- else if (nargs == 0 && argdefs != NULL
- && co->co_argcount == Py_SIZE(argdefs)) {
- /* function called with no arguments, but all parameters have
- a default value: use default values as arguments .*/
- args = &PyTuple_GET_ITEM(argdefs, 0);
- result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
- goto done;
- }
- }
- if (kwargs != NULL) {
- Py_ssize_t pos, i;
- kwtuple = PyTuple_New(2 * nk);
- if (kwtuple == NULL) {
- result = NULL;
- goto done;
- }
- k = &PyTuple_GET_ITEM(kwtuple, 0);
- pos = i = 0;
- while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
- Py_INCREF(k[i]);
- Py_INCREF(k[i+1]);
- i += 2;
- }
- nk = i / 2;
- }
- else {
- kwtuple = NULL;
- k = NULL;
- }
- closure = PyFunction_GET_CLOSURE(func);
-#if PY_MAJOR_VERSION >= 3
- kwdefs = PyFunction_GET_KW_DEFAULTS(func);
-#endif
- if (argdefs != NULL) {
- d = &PyTuple_GET_ITEM(argdefs, 0);
- nd = Py_SIZE(argdefs);
- }
- else {
- d = NULL;
- nd = 0;
- }
-#if PY_MAJOR_VERSION >= 3
- result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
- args, (int)nargs,
- k, (int)nk,
- d, (int)nd, kwdefs, closure);
-#else
- result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
- args, (int)nargs,
- k, (int)nk,
- d, (int)nd, closure);
-#endif
- Py_XDECREF(kwtuple);
-done:
- Py_LeaveRecursiveCall();
- return result;
-}
-#endif
-#endif
-
-/* PyObjectCall */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
- PyObject *result;
- ternaryfunc call = Py_TYPE(func)->tp_call;
- if (unlikely(!call))
- return PyObject_Call(func, arg, kw);
- if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
- return NULL;
- result = (*call)(func, arg, kw);
- Py_LeaveRecursiveCall();
- if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
- PyErr_SetString(
- PyExc_SystemError,
- "NULL result without error in PyObject_Call");
- }
- return result;
-}
-#endif
-
-/* PyObjectCallMethO */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
- PyObject *self, *result;
- PyCFunction cfunc;
- cfunc = PyCFunction_GET_FUNCTION(func);
- self = PyCFunction_GET_SELF(func);
- if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
- return NULL;
- result = cfunc(self, arg);
- Py_LeaveRecursiveCall();
- if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
- PyErr_SetString(
- PyExc_SystemError,
- "NULL result without error in PyObject_Call");
- }
- return result;
-}
-#endif
-
-/* PyObjectCallNoArg */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
-#if CYTHON_FAST_PYCALL
- if (PyFunction_Check(func)) {
- return __Pyx_PyFunction_FastCall(func, NULL, 0);
- }
-#endif
-#if defined(__Pyx_CyFunction_USED) && defined(NDEBUG)
- if (likely(PyCFunction_Check(func) || __Pyx_CyFunction_Check(func)))
-#else
- if (likely(PyCFunction_Check(func)))
-#endif
- {
- if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
- return __Pyx_PyObject_CallMethO(func, NULL);
- }
- }
- return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
-}
-#endif
-
-/* PyCFunctionFastCall */
-#if CYTHON_FAST_PYCCALL
-static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
- PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
- PyCFunction meth = PyCFunction_GET_FUNCTION(func);
- PyObject *self = PyCFunction_GET_SELF(func);
- int flags = PyCFunction_GET_FLAGS(func);
- assert(PyCFunction_Check(func));
- assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)));
- assert(nargs >= 0);
- assert(nargs == 0 || args != NULL);
- /* _PyCFunction_FastCallDict() must not be called with an exception set,
- because it may clear it (directly or indirectly) and so the
- caller loses its exception */
- assert(!PyErr_Occurred());
- if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
- return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL);
- } else {
- return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs);
- }
-}
-#endif
-
-/* PyObjectCallOneArg */
-#if CYTHON_COMPILING_IN_CPYTHON
-static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
- PyObject *result;
- PyObject *args = PyTuple_New(1);
- if (unlikely(!args)) return NULL;
- Py_INCREF(arg);
- PyTuple_SET_ITEM(args, 0, arg);
- result = __Pyx_PyObject_Call(func, args, NULL);
- Py_DECREF(args);
- return result;
-}
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
-#if CYTHON_FAST_PYCALL
- if (PyFunction_Check(func)) {
- return __Pyx_PyFunction_FastCall(func, &arg, 1);
- }
-#endif
- if (likely(PyCFunction_Check(func))) {
- if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
- return __Pyx_PyObject_CallMethO(func, arg);
-#if CYTHON_FAST_PYCCALL
- } else if (__Pyx_PyFastCFunction_Check(func)) {
- return __Pyx_PyCFunction_FastCall(func, &arg, 1);
-#endif
- }
- }
- return __Pyx__PyObject_CallOneArg(func, arg);
-}
-#else
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
- PyObject *result;
- PyObject *args = PyTuple_Pack(1, arg);
- if (unlikely(!args)) return NULL;
- result = __Pyx_PyObject_Call(func, args, NULL);
- Py_DECREF(args);
- return result;
-}
-#endif
-
-/* RaiseTooManyValuesToUnpack */
-static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
- PyErr_Format(PyExc_ValueError,
- "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
-}
-
-/* RaiseNeedMoreValuesToUnpack */
-static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
- PyErr_Format(PyExc_ValueError,
- "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
- index, (index == 1) ? "" : "s");
-}
-
-/* IterFinish */
-static CYTHON_INLINE int __Pyx_IterFinish(void) {
-#if CYTHON_FAST_THREAD_STATE
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- PyObject* exc_type = tstate->curexc_type;
- if (unlikely(exc_type)) {
- if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) {
- PyObject *exc_value, *exc_tb;
- exc_value = tstate->curexc_value;
- exc_tb = tstate->curexc_traceback;
- tstate->curexc_type = 0;
- tstate->curexc_value = 0;
- tstate->curexc_traceback = 0;
- Py_DECREF(exc_type);
- Py_XDECREF(exc_value);
- Py_XDECREF(exc_tb);
- return 0;
- } else {
- return -1;
- }
- }
- return 0;
-#else
- if (unlikely(PyErr_Occurred())) {
- if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
- PyErr_Clear();
- return 0;
- } else {
- return -1;
- }
- }
- return 0;
-#endif
-}
-
-/* UnpackItemEndCheck */
-static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
- if (unlikely(retval)) {
- Py_DECREF(retval);
- __Pyx_RaiseTooManyValuesError(expected);
- return -1;
- }
- return __Pyx_IterFinish();
-}
-
-/* PyIntBinop */
-#if !CYTHON_COMPILING_IN_PYPY
-static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) {
- (void)inplace;
- (void)zerodivision_check;
- #if PY_MAJOR_VERSION < 3
- if (likely(PyInt_CheckExact(op1))) {
- const long b = intval;
- long x;
- long a = PyInt_AS_LONG(op1);
- x = (long)((unsigned long)a + b);
- if (likely((x^a) >= 0 || (x^b) >= 0))
- return PyInt_FromLong(x);
- return PyLong_Type.tp_as_number->nb_add(op1, op2);
- }
- #endif
- #if CYTHON_USE_PYLONG_INTERNALS
- if (likely(PyLong_CheckExact(op1))) {
- const long b = intval;
- long a, x;
-#ifdef HAVE_LONG_LONG
- const PY_LONG_LONG llb = intval;
- PY_LONG_LONG lla, llx;
-#endif
- const digit* digits = ((PyLongObject*)op1)->ob_digit;
- const Py_ssize_t size = Py_SIZE(op1);
- if (likely(__Pyx_sst_abs(size) <= 1)) {
- a = likely(size) ? digits[0] : 0;
- if (size == -1) a = -a;
- } else {
- switch (size) {
- case -2:
- if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
- break;
-#ifdef HAVE_LONG_LONG
- } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
- lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
- goto long_long;
-#endif
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
- break;
-#ifdef HAVE_LONG_LONG
- } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
- lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
- goto long_long;
-#endif
- }
- CYTHON_FALLTHROUGH;
- case -3:
- if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
- break;
-#ifdef HAVE_LONG_LONG
- } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
- lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
- goto long_long;
-#endif
- }
- CYTHON_FALLTHROUGH;
- case 3:
- if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
- break;
-#ifdef HAVE_LONG_LONG
- } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
- lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
- goto long_long;
-#endif
- }
- CYTHON_FALLTHROUGH;
- case -4:
- if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
- a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
- break;
-#ifdef HAVE_LONG_LONG
- } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
- lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
- goto long_long;
-#endif
- }
- CYTHON_FALLTHROUGH;
- case 4:
- if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
- a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
- break;
-#ifdef HAVE_LONG_LONG
- } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
- lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
- goto long_long;
-#endif
- }
- CYTHON_FALLTHROUGH;
- default: return PyLong_Type.tp_as_number->nb_add(op1, op2);
- }
- }
- x = a + b;
- return PyLong_FromLong(x);
-#ifdef HAVE_LONG_LONG
- long_long:
- llx = lla + llb;
- return PyLong_FromLongLong(llx);
-#endif
-
-
- }
- #endif
- if (PyFloat_CheckExact(op1)) {
- const long b = intval;
- double a = PyFloat_AS_DOUBLE(op1);
- double result;
- PyFPE_START_PROTECT("add", return NULL)
- result = ((double)a) + (double)b;
- PyFPE_END_PROTECT(result)
- return PyFloat_FromDouble(result);
- }
- return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2);
-}
-#endif
-
-/* PyObjectCall2Args */
-static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) {
- PyObject *args, *result = NULL;
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(function)) {
- PyObject *args[2] = {arg1, arg2};
- return __Pyx_PyFunction_FastCall(function, args, 2);
- }
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(function)) {
- PyObject *args[2] = {arg1, arg2};
- return __Pyx_PyCFunction_FastCall(function, args, 2);
- }
- #endif
- args = PyTuple_New(2);
- if (unlikely(!args)) goto done;
- Py_INCREF(arg1);
- PyTuple_SET_ITEM(args, 0, arg1);
- Py_INCREF(arg2);
- PyTuple_SET_ITEM(args, 1, arg2);
- Py_INCREF(function);
- result = __Pyx_PyObject_Call(function, args, NULL);
- Py_DECREF(args);
- Py_DECREF(function);
-done:
- return result;
-}
-
-/* PyErrFetchRestore */
-#if CYTHON_FAST_THREAD_STATE
-static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- tmp_type = tstate->curexc_type;
- tmp_value = tstate->curexc_value;
- tmp_tb = tstate->curexc_traceback;
- tstate->curexc_type = type;
- tstate->curexc_value = value;
- tstate->curexc_traceback = tb;
- Py_XDECREF(tmp_type);
- Py_XDECREF(tmp_value);
- Py_XDECREF(tmp_tb);
-}
-static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
- *type = tstate->curexc_type;
- *value = tstate->curexc_value;
- *tb = tstate->curexc_traceback;
- tstate->curexc_type = 0;
- tstate->curexc_value = 0;
- tstate->curexc_traceback = 0;
-}
-#endif
-
-/* RaiseException */
-#if PY_MAJOR_VERSION < 3
-static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
- CYTHON_UNUSED PyObject *cause) {
- __Pyx_PyThreadState_declare
- Py_XINCREF(type);
- if (!value || value == Py_None)
- value = NULL;
- else
- Py_INCREF(value);
- if (!tb || tb == Py_None)
- tb = NULL;
- else {
- Py_INCREF(tb);
- if (!PyTraceBack_Check(tb)) {
- PyErr_SetString(PyExc_TypeError,
- "raise: arg 3 must be a traceback or None");
- goto raise_error;
- }
- }
- if (PyType_Check(type)) {
-#if CYTHON_COMPILING_IN_PYPY
- if (!value) {
- Py_INCREF(Py_None);
- value = Py_None;
- }
-#endif
- PyErr_NormalizeException(&type, &value, &tb);
- } else {
- if (value) {
- PyErr_SetString(PyExc_TypeError,
- "instance exception may not have a separate value");
- goto raise_error;
- }
- value = type;
- type = (PyObject*) Py_TYPE(type);
- Py_INCREF(type);
- if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
- PyErr_SetString(PyExc_TypeError,
- "raise: exception class must be a subclass of BaseException");
- goto raise_error;
- }
- }
- __Pyx_PyThreadState_assign
- __Pyx_ErrRestore(type, value, tb);
- return;
-raise_error:
- Py_XDECREF(value);
- Py_XDECREF(type);
- Py_XDECREF(tb);
- return;
-}
-#else
-static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
- PyObject* owned_instance = NULL;
- if (tb == Py_None) {
- tb = 0;
- } else if (tb && !PyTraceBack_Check(tb)) {
- PyErr_SetString(PyExc_TypeError,
- "raise: arg 3 must be a traceback or None");
- goto bad;
- }
- if (value == Py_None)
- value = 0;
- if (PyExceptionInstance_Check(type)) {
- if (value) {
- PyErr_SetString(PyExc_TypeError,
- "instance exception may not have a separate value");
- goto bad;
- }
- value = type;
- type = (PyObject*) Py_TYPE(value);
- } else if (PyExceptionClass_Check(type)) {
- PyObject *instance_class = NULL;
- if (value && PyExceptionInstance_Check(value)) {
- instance_class = (PyObject*) Py_TYPE(value);
- if (instance_class != type) {
- int is_subclass = PyObject_IsSubclass(instance_class, type);
- if (!is_subclass) {
- instance_class = NULL;
- } else if (unlikely(is_subclass == -1)) {
- goto bad;
- } else {
- type = instance_class;
- }
- }
- }
- if (!instance_class) {
- PyObject *args;
- if (!value)
- args = PyTuple_New(0);
- else if (PyTuple_Check(value)) {
- Py_INCREF(value);
- args = value;
- } else
- args = PyTuple_Pack(1, value);
- if (!args)
- goto bad;
- owned_instance = PyObject_Call(type, args, NULL);
- Py_DECREF(args);
- if (!owned_instance)
- goto bad;
- value = owned_instance;
- if (!PyExceptionInstance_Check(value)) {
- PyErr_Format(PyExc_TypeError,
- "calling %R should have returned an instance of "
- "BaseException, not %R",
- type, Py_TYPE(value));
- goto bad;
- }
- }
- } else {
- PyErr_SetString(PyExc_TypeError,
- "raise: exception class must be a subclass of BaseException");
- goto bad;
- }
- if (cause) {
- PyObject *fixed_cause;
- if (cause == Py_None) {
- fixed_cause = NULL;
- } else if (PyExceptionClass_Check(cause)) {
- fixed_cause = PyObject_CallObject(cause, NULL);
- if (fixed_cause == NULL)
- goto bad;
- } else if (PyExceptionInstance_Check(cause)) {
- fixed_cause = cause;
- Py_INCREF(fixed_cause);
- } else {
- PyErr_SetString(PyExc_TypeError,
- "exception causes must derive from "
- "BaseException");
- goto bad;
- }
- PyException_SetCause(value, fixed_cause);
- }
- PyErr_SetObject(type, value);
- if (tb) {
-#if CYTHON_FAST_THREAD_STATE
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- PyObject* tmp_tb = tstate->curexc_traceback;
- if (tb != tmp_tb) {
- Py_INCREF(tb);
- tstate->curexc_traceback = tb;
- Py_XDECREF(tmp_tb);
- }
-#else
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
- Py_INCREF(tb);
- PyErr_Restore(tmp_type, tmp_value, tb);
- Py_XDECREF(tmp_tb);
-#endif
- }
-bad:
- Py_XDECREF(owned_instance);
- return;
-}
-#endif
-
-/* GetItemInt */
-static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
- PyObject *r;
- if (!j) return NULL;
- r = PyObject_GetItem(o, j);
- Py_DECREF(j);
- return r;
-}
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
- CYTHON_NCP_UNUSED int wraparound,
- CYTHON_NCP_UNUSED int boundscheck) {
-#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- Py_ssize_t wrapped_i = i;
- if (wraparound & unlikely(i < 0)) {
- wrapped_i += PyList_GET_SIZE(o);
- }
- if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) {
- PyObject *r = PyList_GET_ITEM(o, wrapped_i);
- Py_INCREF(r);
- return r;
- }
- return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
-#else
- return PySequence_GetItem(o, i);
-#endif
-}
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
- CYTHON_NCP_UNUSED int wraparound,
- CYTHON_NCP_UNUSED int boundscheck) {
-#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- Py_ssize_t wrapped_i = i;
- if (wraparound & unlikely(i < 0)) {
- wrapped_i += PyTuple_GET_SIZE(o);
- }
- if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) {
- PyObject *r = PyTuple_GET_ITEM(o, wrapped_i);
- Py_INCREF(r);
- return r;
- }
- return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
-#else
- return PySequence_GetItem(o, i);
-#endif
-}
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
- CYTHON_NCP_UNUSED int wraparound,
- CYTHON_NCP_UNUSED int boundscheck) {
-#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
- if (is_list || PyList_CheckExact(o)) {
- Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
- if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) {
- PyObject *r = PyList_GET_ITEM(o, n);
- Py_INCREF(r);
- return r;
- }
- }
- else if (PyTuple_CheckExact(o)) {
- Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
- if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) {
- PyObject *r = PyTuple_GET_ITEM(o, n);
- Py_INCREF(r);
- return r;
- }
- } else {
- PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
- if (likely(m && m->sq_item)) {
- if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
- Py_ssize_t l = m->sq_length(o);
- if (likely(l >= 0)) {
- i += l;
- } else {
- if (!PyErr_ExceptionMatches(PyExc_OverflowError))
- return NULL;
- PyErr_Clear();
- }
- }
- return m->sq_item(o, i);
- }
- }
-#else
- if (is_list || PySequence_Check(o)) {
- return PySequence_GetItem(o, i);
- }
-#endif
- return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
-}
-
-/* ObjectGetItem */
-#if CYTHON_USE_TYPE_SLOTS
-static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject* index) {
- PyObject *runerr = NULL;
- Py_ssize_t key_value;
- PySequenceMethods *m = Py_TYPE(obj)->tp_as_sequence;
- if (unlikely(!(m && m->sq_item))) {
- PyErr_Format(PyExc_TypeError, "'%.200s' object is not subscriptable", Py_TYPE(obj)->tp_name);
- return NULL;
- }
- key_value = __Pyx_PyIndex_AsSsize_t(index);
- if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) {
- return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1);
- }
- if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) {
- PyErr_Clear();
- PyErr_Format(PyExc_IndexError, "cannot fit '%.200s' into an index-sized integer", Py_TYPE(index)->tp_name);
- }
- return NULL;
-}
-static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key) {
- PyMappingMethods *m = Py_TYPE(obj)->tp_as_mapping;
- if (likely(m && m->mp_subscript)) {
- return m->mp_subscript(obj, key);
- }
- return __Pyx_PyObject_GetIndex(obj, key);
-}
-#endif
-
-/* BytesEquals */
-static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
-#if CYTHON_COMPILING_IN_PYPY
- return PyObject_RichCompareBool(s1, s2, equals);
-#else
- if (s1 == s2) {
- return (equals == Py_EQ);
- } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
- const char *ps1, *ps2;
- Py_ssize_t length = PyBytes_GET_SIZE(s1);
- if (length != PyBytes_GET_SIZE(s2))
- return (equals == Py_NE);
- ps1 = PyBytes_AS_STRING(s1);
- ps2 = PyBytes_AS_STRING(s2);
- if (ps1[0] != ps2[0]) {
- return (equals == Py_NE);
- } else if (length == 1) {
- return (equals == Py_EQ);
- } else {
- int result;
-#if CYTHON_USE_UNICODE_INTERNALS && (PY_VERSION_HEX < 0x030B0000)
- Py_hash_t hash1, hash2;
- hash1 = ((PyBytesObject*)s1)->ob_shash;
- hash2 = ((PyBytesObject*)s2)->ob_shash;
- if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
- return (equals == Py_NE);
- }
-#endif
- result = memcmp(ps1, ps2, (size_t)length);
- return (equals == Py_EQ) ? (result == 0) : (result != 0);
- }
- } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
- return (equals == Py_NE);
- } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
- return (equals == Py_NE);
- } else {
- int result;
- PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
- if (!py_result)
- return -1;
- result = __Pyx_PyObject_IsTrue(py_result);
- Py_DECREF(py_result);
- return result;
- }
-#endif
-}
-
-/* UnicodeEquals */
-static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
-#if CYTHON_COMPILING_IN_PYPY
- return PyObject_RichCompareBool(s1, s2, equals);
-#else
-#if PY_MAJOR_VERSION < 3
- PyObject* owned_ref = NULL;
-#endif
- int s1_is_unicode, s2_is_unicode;
- if (s1 == s2) {
- goto return_eq;
- }
- s1_is_unicode = PyUnicode_CheckExact(s1);
- s2_is_unicode = PyUnicode_CheckExact(s2);
-#if PY_MAJOR_VERSION < 3
- if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) {
- owned_ref = PyUnicode_FromObject(s2);
- if (unlikely(!owned_ref))
- return -1;
- s2 = owned_ref;
- s2_is_unicode = 1;
- } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) {
- owned_ref = PyUnicode_FromObject(s1);
- if (unlikely(!owned_ref))
- return -1;
- s1 = owned_ref;
- s1_is_unicode = 1;
- } else if (((!s2_is_unicode) & (!s1_is_unicode))) {
- return __Pyx_PyBytes_Equals(s1, s2, equals);
- }
-#endif
- if (s1_is_unicode & s2_is_unicode) {
- Py_ssize_t length;
- int kind;
- void *data1, *data2;
- if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0))
- return -1;
- length = __Pyx_PyUnicode_GET_LENGTH(s1);
- if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) {
- goto return_ne;
- }
-#if CYTHON_USE_UNICODE_INTERNALS
- {
- Py_hash_t hash1, hash2;
- #if CYTHON_PEP393_ENABLED
- hash1 = ((PyASCIIObject*)s1)->hash;
- hash2 = ((PyASCIIObject*)s2)->hash;
- #else
- hash1 = ((PyUnicodeObject*)s1)->hash;
- hash2 = ((PyUnicodeObject*)s2)->hash;
- #endif
- if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
- goto return_ne;
- }
- }
-#endif
- kind = __Pyx_PyUnicode_KIND(s1);
- if (kind != __Pyx_PyUnicode_KIND(s2)) {
- goto return_ne;
- }
- data1 = __Pyx_PyUnicode_DATA(s1);
- data2 = __Pyx_PyUnicode_DATA(s2);
- if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
- goto return_ne;
- } else if (length == 1) {
- goto return_eq;
- } else {
- int result = memcmp(data1, data2, (size_t)(length * kind));
- #if PY_MAJOR_VERSION < 3
- Py_XDECREF(owned_ref);
- #endif
- return (equals == Py_EQ) ? (result == 0) : (result != 0);
- }
- } else if ((s1 == Py_None) & s2_is_unicode) {
- goto return_ne;
- } else if ((s2 == Py_None) & s1_is_unicode) {
- goto return_ne;
- } else {
- int result;
- PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
- #if PY_MAJOR_VERSION < 3
- Py_XDECREF(owned_ref);
- #endif
- if (!py_result)
- return -1;
- result = __Pyx_PyObject_IsTrue(py_result);
- Py_DECREF(py_result);
- return result;
- }
-return_eq:
- #if PY_MAJOR_VERSION < 3
- Py_XDECREF(owned_ref);
- #endif
- return (equals == Py_EQ);
-return_ne:
- #if PY_MAJOR_VERSION < 3
- Py_XDECREF(owned_ref);
- #endif
- return (equals == Py_NE);
-#endif
-}
-
-/* SliceObject */
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(PyObject* obj,
- Py_ssize_t cstart, Py_ssize_t cstop,
- PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice,
- int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) {
-#if CYTHON_USE_TYPE_SLOTS
- PyMappingMethods* mp;
-#if PY_MAJOR_VERSION < 3
- PySequenceMethods* ms = Py_TYPE(obj)->tp_as_sequence;
- if (likely(ms && ms->sq_slice)) {
- if (!has_cstart) {
- if (_py_start && (*_py_start != Py_None)) {
- cstart = __Pyx_PyIndex_AsSsize_t(*_py_start);
- if ((cstart == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
- } else
- cstart = 0;
- }
- if (!has_cstop) {
- if (_py_stop && (*_py_stop != Py_None)) {
- cstop = __Pyx_PyIndex_AsSsize_t(*_py_stop);
- if ((cstop == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
- } else
- cstop = PY_SSIZE_T_MAX;
- }
- if (wraparound && unlikely((cstart < 0) | (cstop < 0)) && likely(ms->sq_length)) {
- Py_ssize_t l = ms->sq_length(obj);
- if (likely(l >= 0)) {
- if (cstop < 0) {
- cstop += l;
- if (cstop < 0) cstop = 0;
- }
- if (cstart < 0) {
- cstart += l;
- if (cstart < 0) cstart = 0;
- }
- } else {
- if (!PyErr_ExceptionMatches(PyExc_OverflowError))
- goto bad;
- PyErr_Clear();
- }
- }
- return ms->sq_slice(obj, cstart, cstop);
- }
-#endif
- mp = Py_TYPE(obj)->tp_as_mapping;
- if (likely(mp && mp->mp_subscript))
-#endif
- {
- PyObject* result;
- PyObject *py_slice, *py_start, *py_stop;
- if (_py_slice) {
- py_slice = *_py_slice;
- } else {
- PyObject* owned_start = NULL;
- PyObject* owned_stop = NULL;
- if (_py_start) {
- py_start = *_py_start;
- } else {
- if (has_cstart) {
- owned_start = py_start = PyInt_FromSsize_t(cstart);
- if (unlikely(!py_start)) goto bad;
- } else
- py_start = Py_None;
- }
- if (_py_stop) {
- py_stop = *_py_stop;
- } else {
- if (has_cstop) {
- owned_stop = py_stop = PyInt_FromSsize_t(cstop);
- if (unlikely(!py_stop)) {
- Py_XDECREF(owned_start);
- goto bad;
- }
- } else
- py_stop = Py_None;
- }
- py_slice = PySlice_New(py_start, py_stop, Py_None);
- Py_XDECREF(owned_start);
- Py_XDECREF(owned_stop);
- if (unlikely(!py_slice)) goto bad;
- }
-#if CYTHON_USE_TYPE_SLOTS
- result = mp->mp_subscript(obj, py_slice);
-#else
- result = PyObject_GetItem(obj, py_slice);
-#endif
- if (!_py_slice) {
- Py_DECREF(py_slice);
- }
- return result;
- }
- PyErr_Format(PyExc_TypeError,
- "'%.200s' object is unsliceable", Py_TYPE(obj)->tp_name);
-bad:
- return NULL;
-}
-
-/* PyIntBinop */
-#if !CYTHON_COMPILING_IN_PYPY
-static PyObject* __Pyx_PyInt_SubtractObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) {
- (void)inplace;
- (void)zerodivision_check;
- #if PY_MAJOR_VERSION < 3
- if (likely(PyInt_CheckExact(op1))) {
- const long b = intval;
- long x;
- long a = PyInt_AS_LONG(op1);
- x = (long)((unsigned long)a - b);
- if (likely((x^a) >= 0 || (x^~b) >= 0))
- return PyInt_FromLong(x);
- return PyLong_Type.tp_as_number->nb_subtract(op1, op2);
- }
- #endif
- #if CYTHON_USE_PYLONG_INTERNALS
- if (likely(PyLong_CheckExact(op1))) {
- const long b = intval;
- long a, x;
-#ifdef HAVE_LONG_LONG
- const PY_LONG_LONG llb = intval;
- PY_LONG_LONG lla, llx;
-#endif
- const digit* digits = ((PyLongObject*)op1)->ob_digit;
- const Py_ssize_t size = Py_SIZE(op1);
- if (likely(__Pyx_sst_abs(size) <= 1)) {
- a = likely(size) ? digits[0] : 0;
- if (size == -1) a = -a;
- } else {
- switch (size) {
- case -2:
- if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
- break;
-#ifdef HAVE_LONG_LONG
- } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
- lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
- goto long_long;
-#endif
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
- break;
-#ifdef HAVE_LONG_LONG
- } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
- lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
- goto long_long;
-#endif
- }
- CYTHON_FALLTHROUGH;
- case -3:
- if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
- break;
-#ifdef HAVE_LONG_LONG
- } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
- lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
- goto long_long;
-#endif
- }
- CYTHON_FALLTHROUGH;
- case 3:
- if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
- break;
-#ifdef HAVE_LONG_LONG
- } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
- lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
- goto long_long;
-#endif
- }
- CYTHON_FALLTHROUGH;
- case -4:
- if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
- a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
- break;
-#ifdef HAVE_LONG_LONG
- } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
- lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
- goto long_long;
-#endif
- }
- CYTHON_FALLTHROUGH;
- case 4:
- if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
- a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
- break;
-#ifdef HAVE_LONG_LONG
- } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
- lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
- goto long_long;
-#endif
- }
- CYTHON_FALLTHROUGH;
- default: return PyLong_Type.tp_as_number->nb_subtract(op1, op2);
- }
- }
- x = a - b;
- return PyLong_FromLong(x);
-#ifdef HAVE_LONG_LONG
- long_long:
- llx = lla - llb;
- return PyLong_FromLongLong(llx);
-#endif
-
-
- }
- #endif
- if (PyFloat_CheckExact(op1)) {
- const long b = intval;
- double a = PyFloat_AS_DOUBLE(op1);
- double result;
- PyFPE_START_PROTECT("subtract", return NULL)
- result = ((double)a) - (double)b;
- PyFPE_END_PROTECT(result)
- return PyFloat_FromDouble(result);
- }
- return (inplace ? PyNumber_InPlaceSubtract : PyNumber_Subtract)(op1, op2);
-}
-#endif
-
-/* IterNext */
-static PyObject *__Pyx_PyIter_Next2Default(PyObject* defval) {
- PyObject* exc_type;
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- exc_type = __Pyx_PyErr_Occurred();
- if (unlikely(exc_type)) {
- if (!defval || unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))
- return NULL;
- __Pyx_PyErr_Clear();
- Py_INCREF(defval);
- return defval;
- }
- if (defval) {
- Py_INCREF(defval);
- return defval;
- }
- __Pyx_PyErr_SetNone(PyExc_StopIteration);
- return NULL;
-}
-static void __Pyx_PyIter_Next_ErrorNoIterator(PyObject *iterator) {
- PyErr_Format(PyExc_TypeError,
- "%.200s object is not an iterator", Py_TYPE(iterator)->tp_name);
-}
-static CYTHON_INLINE PyObject *__Pyx_PyIter_Next2(PyObject* iterator, PyObject* defval) {
- PyObject* next;
- iternextfunc iternext = Py_TYPE(iterator)->tp_iternext;
- if (likely(iternext)) {
-#if CYTHON_USE_TYPE_SLOTS || CYTHON_COMPILING_IN_PYPY
- next = iternext(iterator);
- if (likely(next))
- return next;
- #if PY_VERSION_HEX >= 0x02070000 && CYTHON_COMPILING_IN_CPYTHON
- if (unlikely(iternext == &_PyObject_NextNotImplemented))
- return NULL;
- #endif
-#else
- next = PyIter_Next(iterator);
- if (likely(next))
- return next;
-#endif
- } else if (CYTHON_USE_TYPE_SLOTS || unlikely(!PyIter_Check(iterator))) {
- __Pyx_PyIter_Next_ErrorNoIterator(iterator);
- return NULL;
- }
-#if !CYTHON_USE_TYPE_SLOTS
- else {
- next = PyIter_Next(iterator);
- if (likely(next))
- return next;
- }
-#endif
- return __Pyx_PyIter_Next2Default(defval);
-}
-
-/* GetTopmostException */
-#if CYTHON_USE_EXC_INFO_STACK
-static _PyErr_StackItem *
-__Pyx_PyErr_GetTopmostException(PyThreadState *tstate)
-{
- _PyErr_StackItem *exc_info = tstate->exc_info;
- while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) &&
- exc_info->previous_item != NULL)
- {
- exc_info = exc_info->previous_item;
- }
- return exc_info;
-}
-#endif
-
-/* SaveResetException */
-#if CYTHON_FAST_THREAD_STATE
-static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
- #if CYTHON_USE_EXC_INFO_STACK
- _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
- *type = exc_info->exc_type;
- *value = exc_info->exc_value;
- *tb = exc_info->exc_traceback;
- #else
- *type = tstate->exc_type;
- *value = tstate->exc_value;
- *tb = tstate->exc_traceback;
- #endif
- Py_XINCREF(*type);
- Py_XINCREF(*value);
- Py_XINCREF(*tb);
-}
-static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- #if CYTHON_USE_EXC_INFO_STACK
- _PyErr_StackItem *exc_info = tstate->exc_info;
- tmp_type = exc_info->exc_type;
- tmp_value = exc_info->exc_value;
- tmp_tb = exc_info->exc_traceback;
- exc_info->exc_type = type;
- exc_info->exc_value = value;
- exc_info->exc_traceback = tb;
- #else
- tmp_type = tstate->exc_type;
- tmp_value = tstate->exc_value;
- tmp_tb = tstate->exc_traceback;
- tstate->exc_type = type;
- tstate->exc_value = value;
- tstate->exc_traceback = tb;
- #endif
- Py_XDECREF(tmp_type);
- Py_XDECREF(tmp_value);
- Py_XDECREF(tmp_tb);
-}
-#endif
-
-/* PyErrExceptionMatches */
-#if CYTHON_FAST_THREAD_STATE
-static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
- Py_ssize_t i, n;
- n = PyTuple_GET_SIZE(tuple);
-#if PY_MAJOR_VERSION >= 3
- for (i=0; icurexc_type;
- if (exc_type == err) return 1;
- if (unlikely(!exc_type)) return 0;
- if (unlikely(PyTuple_Check(err)))
- return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
- return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
-}
-#endif
-
-/* GetException */
-#if CYTHON_FAST_THREAD_STATE
-static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb)
-#else
-static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
-#endif
-{
- PyObject *local_type, *local_value, *local_tb;
-#if CYTHON_FAST_THREAD_STATE
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- local_type = tstate->curexc_type;
- local_value = tstate->curexc_value;
- local_tb = tstate->curexc_traceback;
- tstate->curexc_type = 0;
- tstate->curexc_value = 0;
- tstate->curexc_traceback = 0;
-#else
- PyErr_Fetch(&local_type, &local_value, &local_tb);
-#endif
- PyErr_NormalizeException(&local_type, &local_value, &local_tb);
-#if CYTHON_FAST_THREAD_STATE
- if (unlikely(tstate->curexc_type))
-#else
- if (unlikely(PyErr_Occurred()))
-#endif
- goto bad;
- #if PY_MAJOR_VERSION >= 3
- if (local_tb) {
- if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
- goto bad;
- }
- #endif
- Py_XINCREF(local_tb);
- Py_XINCREF(local_type);
- Py_XINCREF(local_value);
- *type = local_type;
- *value = local_value;
- *tb = local_tb;
-#if CYTHON_FAST_THREAD_STATE
- #if CYTHON_USE_EXC_INFO_STACK
- {
- _PyErr_StackItem *exc_info = tstate->exc_info;
- tmp_type = exc_info->exc_type;
- tmp_value = exc_info->exc_value;
- tmp_tb = exc_info->exc_traceback;
- exc_info->exc_type = local_type;
- exc_info->exc_value = local_value;
- exc_info->exc_traceback = local_tb;
- }
- #else
- tmp_type = tstate->exc_type;
- tmp_value = tstate->exc_value;
- tmp_tb = tstate->exc_traceback;
- tstate->exc_type = local_type;
- tstate->exc_value = local_value;
- tstate->exc_traceback = local_tb;
- #endif
- Py_XDECREF(tmp_type);
- Py_XDECREF(tmp_value);
- Py_XDECREF(tmp_tb);
-#else
- PyErr_SetExcInfo(local_type, local_value, local_tb);
-#endif
- return 0;
-bad:
- *type = 0;
- *value = 0;
- *tb = 0;
- Py_XDECREF(local_type);
- Py_XDECREF(local_value);
- Py_XDECREF(local_tb);
- return -1;
-}
-
-/* PyObjectGetMethod */
-static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method) {
- PyObject *attr;
-#if CYTHON_UNPACK_METHODS && CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_PYTYPE_LOOKUP
- PyTypeObject *tp = Py_TYPE(obj);
- PyObject *descr;
- descrgetfunc f = NULL;
- PyObject **dictptr, *dict;
- int meth_found = 0;
- assert (*method == NULL);
- if (unlikely(tp->tp_getattro != PyObject_GenericGetAttr)) {
- attr = __Pyx_PyObject_GetAttrStr(obj, name);
- goto try_unpack;
- }
- if (unlikely(tp->tp_dict == NULL) && unlikely(PyType_Ready(tp) < 0)) {
- return 0;
- }
- descr = _PyType_Lookup(tp, name);
- if (likely(descr != NULL)) {
- Py_INCREF(descr);
-#if PY_MAJOR_VERSION >= 3
- #ifdef __Pyx_CyFunction_USED
- if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type) || __Pyx_CyFunction_Check(descr)))
- #else
- if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type)))
- #endif
-#else
- #ifdef __Pyx_CyFunction_USED
- if (likely(PyFunction_Check(descr) || __Pyx_CyFunction_Check(descr)))
- #else
- if (likely(PyFunction_Check(descr)))
- #endif
-#endif
- {
- meth_found = 1;
- } else {
- f = Py_TYPE(descr)->tp_descr_get;
- if (f != NULL && PyDescr_IsData(descr)) {
- attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
- Py_DECREF(descr);
- goto try_unpack;
- }
- }
- }
- dictptr = _PyObject_GetDictPtr(obj);
- if (dictptr != NULL && (dict = *dictptr) != NULL) {
- Py_INCREF(dict);
- attr = __Pyx_PyDict_GetItemStr(dict, name);
- if (attr != NULL) {
- Py_INCREF(attr);
- Py_DECREF(dict);
- Py_XDECREF(descr);
- goto try_unpack;
- }
- Py_DECREF(dict);
- }
- if (meth_found) {
- *method = descr;
- return 1;
- }
- if (f != NULL) {
- attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
- Py_DECREF(descr);
- goto try_unpack;
- }
- if (descr != NULL) {
- *method = descr;
- return 0;
- }
- PyErr_Format(PyExc_AttributeError,
-#if PY_MAJOR_VERSION >= 3
- "'%.50s' object has no attribute '%U'",
- tp->tp_name, name);
-#else
- "'%.50s' object has no attribute '%.400s'",
- tp->tp_name, PyString_AS_STRING(name));
-#endif
- return 0;
-#else
- attr = __Pyx_PyObject_GetAttrStr(obj, name);
- goto try_unpack;
-#endif
-try_unpack:
-#if CYTHON_UNPACK_METHODS
- if (likely(attr) && PyMethod_Check(attr) && likely(PyMethod_GET_SELF(attr) == obj)) {
- PyObject *function = PyMethod_GET_FUNCTION(attr);
- Py_INCREF(function);
- Py_DECREF(attr);
- *method = function;
- return 1;
- }
-#endif
- *method = attr;
- return 0;
-}
-
-/* PyObjectCallMethod0 */
-static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name) {
- PyObject *method = NULL, *result = NULL;
- int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method);
- if (likely(is_method)) {
- result = __Pyx_PyObject_CallOneArg(method, obj);
- Py_DECREF(method);
- return result;
- }
- if (unlikely(!method)) goto bad;
- result = __Pyx_PyObject_CallNoArg(method);
- Py_DECREF(method);
-bad:
- return result;
-}
-
-/* UnpackUnboundCMethod */
-static int __Pyx_TryUnpackUnboundCMethod(__Pyx_CachedCFunction* target) {
- PyObject *method;
- method = __Pyx_PyObject_GetAttrStr(target->type, *target->method_name);
- if (unlikely(!method))
- return -1;
- target->method = method;
-#if CYTHON_COMPILING_IN_CPYTHON
- #if PY_MAJOR_VERSION >= 3
- if (likely(__Pyx_TypeCheck(method, &PyMethodDescr_Type)))
- #endif
- {
- PyMethodDescrObject *descr = (PyMethodDescrObject*) method;
- target->func = descr->d_method->ml_meth;
- target->flag = descr->d_method->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_STACKLESS);
- }
-#endif
- return 0;
-}
-
-/* CallUnboundCMethod0 */
-static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self) {
- PyObject *args, *result = NULL;
- if (unlikely(!cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
-#if CYTHON_ASSUME_SAFE_MACROS
- args = PyTuple_New(1);
- if (unlikely(!args)) goto bad;
- Py_INCREF(self);
- PyTuple_SET_ITEM(args, 0, self);
-#else
- args = PyTuple_Pack(1, self);
- if (unlikely(!args)) goto bad;
-#endif
- result = __Pyx_PyObject_Call(cfunc->method, args, NULL);
- Py_DECREF(args);
-bad:
- return result;
-}
-
-/* pop */
-static CYTHON_INLINE PyObject* __Pyx__PyObject_Pop(PyObject* L) {
- if (Py_TYPE(L) == &PySet_Type) {
- return PySet_Pop(L);
- }
- return __Pyx_PyObject_CallMethod0(L, __pyx_n_s_pop);
-}
-#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
-static CYTHON_INLINE PyObject* __Pyx_PyList_Pop(PyObject* L) {
- if (likely(PyList_GET_SIZE(L) > (((PyListObject*)L)->allocated >> 1))) {
- __Pyx_SET_SIZE(L, Py_SIZE(L) - 1);
- return PyList_GET_ITEM(L, PyList_GET_SIZE(L));
- }
- return __Pyx_CallUnboundCMethod0(&__pyx_umethod_PyList_Type_pop, L);
-}
-#endif
-
-/* PyObjectCallMethod1 */
-static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg) {
- PyObject *result = __Pyx_PyObject_CallOneArg(method, arg);
- Py_DECREF(method);
- return result;
-}
-static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) {
- PyObject *method = NULL, *result;
- int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method);
- if (likely(is_method)) {
- result = __Pyx_PyObject_Call2Args(method, obj, arg);
- Py_DECREF(method);
- return result;
- }
- if (unlikely(!method)) return NULL;
- return __Pyx__PyObject_CallMethod1(method, arg);
-}
-
-/* append */
-static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x) {
- if (likely(PyList_CheckExact(L))) {
- if (unlikely(__Pyx_PyList_Append(L, x) < 0)) return -1;
- } else {
- PyObject* retval = __Pyx_PyObject_CallMethod1(L, __pyx_n_s_append, x);
- if (unlikely(!retval))
- return -1;
- Py_DECREF(retval);
- }
- return 0;
-}
-
-/* FastTypeChecks */
-#if CYTHON_COMPILING_IN_CPYTHON
-static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
- while (a) {
- a = a->tp_base;
- if (a == b)
- return 1;
- }
- return b == &PyBaseObject_Type;
-}
-static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
- PyObject *mro;
- if (a == b) return 1;
- mro = a->tp_mro;
- if (likely(mro)) {
- Py_ssize_t i, n;
- n = PyTuple_GET_SIZE(mro);
- for (i = 0; i < n; i++) {
- if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
- return 1;
- }
- return 0;
- }
- return __Pyx_InBases(a, b);
-}
-#if PY_MAJOR_VERSION == 2
-static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
- PyObject *exception, *value, *tb;
- int res;
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ErrFetch(&exception, &value, &tb);
- res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
- if (unlikely(res == -1)) {
- PyErr_WriteUnraisable(err);
- res = 0;
- }
- if (!res) {
- res = PyObject_IsSubclass(err, exc_type2);
- if (unlikely(res == -1)) {
- PyErr_WriteUnraisable(err);
- res = 0;
- }
- }
- __Pyx_ErrRestore(exception, value, tb);
- return res;
-}
-#else
-static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
- int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
- if (!res) {
- res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
- }
- return res;
-}
-#endif
-static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
- Py_ssize_t i, n;
- assert(PyExceptionClass_Check(exc_type));
- n = PyTuple_GET_SIZE(tuple);
-#if PY_MAJOR_VERSION >= 3
- for (i=0; iexc_info;
- tmp_type = exc_info->exc_type;
- tmp_value = exc_info->exc_value;
- tmp_tb = exc_info->exc_traceback;
- exc_info->exc_type = *type;
- exc_info->exc_value = *value;
- exc_info->exc_traceback = *tb;
- #else
- tmp_type = tstate->exc_type;
- tmp_value = tstate->exc_value;
- tmp_tb = tstate->exc_traceback;
- tstate->exc_type = *type;
- tstate->exc_value = *value;
- tstate->exc_traceback = *tb;
- #endif
- *type = tmp_type;
- *value = tmp_value;
- *tb = tmp_tb;
-}
-#else
-static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
- PyErr_SetExcInfo(*type, *value, *tb);
- *type = tmp_type;
- *value = tmp_value;
- *tb = tmp_tb;
-}
-#endif
-
-/* GetAttr */
-static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
-#if CYTHON_USE_TYPE_SLOTS
-#if PY_MAJOR_VERSION >= 3
- if (likely(PyUnicode_Check(n)))
-#else
- if (likely(PyString_Check(n)))
-#endif
- return __Pyx_PyObject_GetAttrStr(o, n);
-#endif
- return PyObject_GetAttr(o, n);
-}
-
-/* HasAttr */
-static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) {
- PyObject *r;
- if (unlikely(!__Pyx_PyBaseString_Check(n))) {
- PyErr_SetString(PyExc_TypeError,
- "hasattr(): attribute name must be string");
- return -1;
- }
- r = __Pyx_GetAttr(o, n);
- if (unlikely(!r)) {
- PyErr_Clear();
- return 0;
- } else {
- Py_DECREF(r);
- return 1;
- }
-}
-
-/* GetAttr3 */
-static PyObject *__Pyx_GetAttr3Default(PyObject *d) {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
- return NULL;
- __Pyx_PyErr_Clear();
- Py_INCREF(d);
- return d;
-}
-static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) {
- PyObject *r = __Pyx_GetAttr(o, n);
- return (likely(r)) ? r : __Pyx_GetAttr3Default(d);
-}
-
-/* Import */
-static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
- PyObject *empty_list = 0;
- PyObject *module = 0;
- PyObject *global_dict = 0;
- PyObject *empty_dict = 0;
- PyObject *list;
- #if PY_MAJOR_VERSION < 3
- PyObject *py_import;
- py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
- if (!py_import)
- goto bad;
- #endif
- if (from_list)
- list = from_list;
- else {
- empty_list = PyList_New(0);
- if (!empty_list)
- goto bad;
- list = empty_list;
- }
- global_dict = PyModule_GetDict(__pyx_m);
- if (!global_dict)
- goto bad;
- empty_dict = PyDict_New();
- if (!empty_dict)
- goto bad;
- {
- #if PY_MAJOR_VERSION >= 3
- if (level == -1) {
- if ((1) && (strchr(__Pyx_MODULE_NAME, '.'))) {
- module = PyImport_ImportModuleLevelObject(
- name, global_dict, empty_dict, list, 1);
- if (!module) {
- if (!PyErr_ExceptionMatches(PyExc_ImportError))
- goto bad;
- PyErr_Clear();
- }
- }
- level = 0;
- }
- #endif
- if (!module) {
- #if PY_MAJOR_VERSION < 3
- PyObject *py_level = PyInt_FromLong(level);
- if (!py_level)
- goto bad;
- module = PyObject_CallFunctionObjArgs(py_import,
- name, global_dict, empty_dict, list, py_level, (PyObject *)NULL);
- Py_DECREF(py_level);
- #else
- module = PyImport_ImportModuleLevelObject(
- name, global_dict, empty_dict, list, level);
- #endif
- }
- }
-bad:
- #if PY_MAJOR_VERSION < 3
- Py_XDECREF(py_import);
- #endif
- Py_XDECREF(empty_list);
- Py_XDECREF(empty_dict);
- return module;
-}
-
-/* ImportFrom */
-static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
- PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
- if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
- PyErr_Format(PyExc_ImportError,
- #if PY_MAJOR_VERSION < 3
- "cannot import name %.230s", PyString_AS_STRING(name));
- #else
- "cannot import name %S", name);
- #endif
- }
- return value;
-}
-
-/* CalculateMetaclass */
-static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases) {
- Py_ssize_t i, nbases = PyTuple_GET_SIZE(bases);
- for (i=0; i < nbases; i++) {
- PyTypeObject *tmptype;
- PyObject *tmp = PyTuple_GET_ITEM(bases, i);
- tmptype = Py_TYPE(tmp);
-#if PY_MAJOR_VERSION < 3
- if (tmptype == &PyClass_Type)
- continue;
-#endif
- if (!metaclass) {
- metaclass = tmptype;
- continue;
- }
- if (PyType_IsSubtype(metaclass, tmptype))
- continue;
- if (PyType_IsSubtype(tmptype, metaclass)) {
- metaclass = tmptype;
- continue;
- }
- PyErr_SetString(PyExc_TypeError,
- "metaclass conflict: "
- "the metaclass of a derived class "
- "must be a (non-strict) subclass "
- "of the metaclasses of all its bases");
- return NULL;
- }
- if (!metaclass) {
-#if PY_MAJOR_VERSION < 3
- metaclass = &PyClass_Type;
-#else
- metaclass = &PyType_Type;
-#endif
- }
- Py_INCREF((PyObject*) metaclass);
- return (PyObject*) metaclass;
-}
-
-/* FetchCommonType */
-static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
- PyObject* fake_module;
- PyTypeObject* cached_type = NULL;
- fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
- if (!fake_module) return NULL;
- Py_INCREF(fake_module);
- cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
- if (cached_type) {
- if (!PyType_Check((PyObject*)cached_type)) {
- PyErr_Format(PyExc_TypeError,
- "Shared Cython type %.200s is not a type object",
- type->tp_name);
- goto bad;
- }
- if (cached_type->tp_basicsize != type->tp_basicsize) {
- PyErr_Format(PyExc_TypeError,
- "Shared Cython type %.200s has the wrong size, try recompiling",
- type->tp_name);
- goto bad;
- }
- } else {
- if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
- PyErr_Clear();
- if (PyType_Ready(type) < 0) goto bad;
- if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
- goto bad;
- Py_INCREF(type);
- cached_type = type;
- }
-done:
- Py_DECREF(fake_module);
- return cached_type;
-bad:
- Py_XDECREF(cached_type);
- cached_type = NULL;
- goto done;
-}
-
-/* CythonFunctionShared */
-#include
-static PyObject *
-__Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure)
-{
- if (unlikely(op->func_doc == NULL)) {
- if (op->func.m_ml->ml_doc) {
-#if PY_MAJOR_VERSION >= 3
- op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc);
-#else
- op->func_doc = PyString_FromString(op->func.m_ml->ml_doc);
-#endif
- if (unlikely(op->func_doc == NULL))
- return NULL;
- } else {
- Py_INCREF(Py_None);
- return Py_None;
- }
- }
- Py_INCREF(op->func_doc);
- return op->func_doc;
-}
-static int
-__Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
-{
- PyObject *tmp = op->func_doc;
- if (value == NULL) {
- value = Py_None;
- }
- Py_INCREF(value);
- op->func_doc = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
-{
- if (unlikely(op->func_name == NULL)) {
-#if PY_MAJOR_VERSION >= 3
- op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name);
-#else
- op->func_name = PyString_InternFromString(op->func.m_ml->ml_name);
-#endif
- if (unlikely(op->func_name == NULL))
- return NULL;
- }
- Py_INCREF(op->func_name);
- return op->func_name;
-}
-static int
-__Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
-{
- PyObject *tmp;
-#if PY_MAJOR_VERSION >= 3
- if (unlikely(value == NULL || !PyUnicode_Check(value)))
-#else
- if (unlikely(value == NULL || !PyString_Check(value)))
-#endif
- {
- PyErr_SetString(PyExc_TypeError,
- "__name__ must be set to a string object");
- return -1;
- }
- tmp = op->func_name;
- Py_INCREF(value);
- op->func_name = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
-{
- Py_INCREF(op->func_qualname);
- return op->func_qualname;
-}
-static int
-__Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
-{
- PyObject *tmp;
-#if PY_MAJOR_VERSION >= 3
- if (unlikely(value == NULL || !PyUnicode_Check(value)))
-#else
- if (unlikely(value == NULL || !PyString_Check(value)))
-#endif
- {
- PyErr_SetString(PyExc_TypeError,
- "__qualname__ must be set to a string object");
- return -1;
- }
- tmp = op->func_qualname;
- Py_INCREF(value);
- op->func_qualname = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure)
-{
- PyObject *self;
- self = m->func_closure;
- if (self == NULL)
- self = Py_None;
- Py_INCREF(self);
- return self;
-}
-static PyObject *
-__Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
-{
- if (unlikely(op->func_dict == NULL)) {
- op->func_dict = PyDict_New();
- if (unlikely(op->func_dict == NULL))
- return NULL;
- }
- Py_INCREF(op->func_dict);
- return op->func_dict;
-}
-static int
-__Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
-{
- PyObject *tmp;
- if (unlikely(value == NULL)) {
- PyErr_SetString(PyExc_TypeError,
- "function's dictionary may not be deleted");
- return -1;
- }
- if (unlikely(!PyDict_Check(value))) {
- PyErr_SetString(PyExc_TypeError,
- "setting function's dictionary to a non-dict");
- return -1;
- }
- tmp = op->func_dict;
- Py_INCREF(value);
- op->func_dict = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
-{
- Py_INCREF(op->func_globals);
- return op->func_globals;
-}
-static PyObject *
-__Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
-{
- Py_INCREF(Py_None);
- return Py_None;
-}
-static PyObject *
-__Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
-{
- PyObject* result = (op->func_code) ? op->func_code : Py_None;
- Py_INCREF(result);
- return result;
-}
-static int
-__Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
- int result = 0;
- PyObject *res = op->defaults_getter((PyObject *) op);
- if (unlikely(!res))
- return -1;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
- Py_INCREF(op->defaults_tuple);
- op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
- Py_INCREF(op->defaults_kwdict);
- #else
- op->defaults_tuple = PySequence_ITEM(res, 0);
- if (unlikely(!op->defaults_tuple)) result = -1;
- else {
- op->defaults_kwdict = PySequence_ITEM(res, 1);
- if (unlikely(!op->defaults_kwdict)) result = -1;
- }
- #endif
- Py_DECREF(res);
- return result;
-}
-static int
-__Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) {
- PyObject* tmp;
- if (!value) {
- value = Py_None;
- } else if (value != Py_None && !PyTuple_Check(value)) {
- PyErr_SetString(PyExc_TypeError,
- "__defaults__ must be set to a tuple object");
- return -1;
- }
- Py_INCREF(value);
- tmp = op->defaults_tuple;
- op->defaults_tuple = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) {
- PyObject* result = op->defaults_tuple;
- if (unlikely(!result)) {
- if (op->defaults_getter) {
- if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
- result = op->defaults_tuple;
- } else {
- result = Py_None;
- }
- }
- Py_INCREF(result);
- return result;
-}
-static int
-__Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) {
- PyObject* tmp;
- if (!value) {
- value = Py_None;
- } else if (value != Py_None && !PyDict_Check(value)) {
- PyErr_SetString(PyExc_TypeError,
- "__kwdefaults__ must be set to a dict object");
- return -1;
- }
- Py_INCREF(value);
- tmp = op->defaults_kwdict;
- op->defaults_kwdict = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) {
- PyObject* result = op->defaults_kwdict;
- if (unlikely(!result)) {
- if (op->defaults_getter) {
- if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
- result = op->defaults_kwdict;
- } else {
- result = Py_None;
- }
- }
- Py_INCREF(result);
- return result;
-}
-static int
-__Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) {
- PyObject* tmp;
- if (!value || value == Py_None) {
- value = NULL;
- } else if (!PyDict_Check(value)) {
- PyErr_SetString(PyExc_TypeError,
- "__annotations__ must be set to a dict object");
- return -1;
- }
- Py_XINCREF(value);
- tmp = op->func_annotations;
- op->func_annotations = value;
- Py_XDECREF(tmp);
- return 0;
-}
-static PyObject *
-__Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) {
- PyObject* result = op->func_annotations;
- if (unlikely(!result)) {
- result = PyDict_New();
- if (unlikely(!result)) return NULL;
- op->func_annotations = result;
- }
- Py_INCREF(result);
- return result;
-}
-static PyGetSetDef __pyx_CyFunction_getsets[] = {
- {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
- {(char *) "__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
- {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
- {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
- {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
- {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0},
- {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
- {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
- {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
- {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
- {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
- {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
- {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
- {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
- {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
- {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
- {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
- {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
- {0, 0, 0, 0, 0}
-};
-static PyMemberDef __pyx_CyFunction_members[] = {
- {(char *) "__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), PY_WRITE_RESTRICTED, 0},
- {0, 0, 0, 0, 0}
-};
-static PyObject *
-__Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args)
-{
-#if PY_MAJOR_VERSION >= 3
- Py_INCREF(m->func_qualname);
- return m->func_qualname;
-#else
- return PyString_FromString(m->func.m_ml->ml_name);
-#endif
-}
-static PyMethodDef __pyx_CyFunction_methods[] = {
- {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
- {0, 0, 0, 0}
-};
-#if PY_VERSION_HEX < 0x030500A0
-#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist)
-#else
-#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist)
-#endif
-static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject *op, PyMethodDef *ml, int flags, PyObject* qualname,
- PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
- if (unlikely(op == NULL))
- return NULL;
- op->flags = flags;
- __Pyx_CyFunction_weakreflist(op) = NULL;
- op->func.m_ml = ml;
- op->func.m_self = (PyObject *) op;
- Py_XINCREF(closure);
- op->func_closure = closure;
- Py_XINCREF(module);
- op->func.m_module = module;
- op->func_dict = NULL;
- op->func_name = NULL;
- Py_INCREF(qualname);
- op->func_qualname = qualname;
- op->func_doc = NULL;
- op->func_classobj = NULL;
- op->func_globals = globals;
- Py_INCREF(op->func_globals);
- Py_XINCREF(code);
- op->func_code = code;
- op->defaults_pyobjects = 0;
- op->defaults_size = 0;
- op->defaults = NULL;
- op->defaults_tuple = NULL;
- op->defaults_kwdict = NULL;
- op->defaults_getter = NULL;
- op->func_annotations = NULL;
- return (PyObject *) op;
-}
-static int
-__Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
-{
- Py_CLEAR(m->func_closure);
- Py_CLEAR(m->func.m_module);
- Py_CLEAR(m->func_dict);
- Py_CLEAR(m->func_name);
- Py_CLEAR(m->func_qualname);
- Py_CLEAR(m->func_doc);
- Py_CLEAR(m->func_globals);
- Py_CLEAR(m->func_code);
- Py_CLEAR(m->func_classobj);
- Py_CLEAR(m->defaults_tuple);
- Py_CLEAR(m->defaults_kwdict);
- Py_CLEAR(m->func_annotations);
- if (m->defaults) {
- PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
- int i;
- for (i = 0; i < m->defaults_pyobjects; i++)
- Py_XDECREF(pydefaults[i]);
- PyObject_Free(m->defaults);
- m->defaults = NULL;
- }
- return 0;
-}
-static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m)
-{
- if (__Pyx_CyFunction_weakreflist(m) != NULL)
- PyObject_ClearWeakRefs((PyObject *) m);
- __Pyx_CyFunction_clear(m);
- PyObject_GC_Del(m);
-}
-static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
-{
- PyObject_GC_UnTrack(m);
- __Pyx__CyFunction_dealloc(m);
-}
-static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
-{
- Py_VISIT(m->func_closure);
- Py_VISIT(m->func.m_module);
- Py_VISIT(m->func_dict);
- Py_VISIT(m->func_name);
- Py_VISIT(m->func_qualname);
- Py_VISIT(m->func_doc);
- Py_VISIT(m->func_globals);
- Py_VISIT(m->func_code);
- Py_VISIT(m->func_classobj);
- Py_VISIT(m->defaults_tuple);
- Py_VISIT(m->defaults_kwdict);
- if (m->defaults) {
- PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
- int i;
- for (i = 0; i < m->defaults_pyobjects; i++)
- Py_VISIT(pydefaults[i]);
- }
- return 0;
-}
-static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type)
-{
-#if PY_MAJOR_VERSION < 3
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
- Py_INCREF(func);
- return func;
- }
- if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) {
- if (type == NULL)
- type = (PyObject *)(Py_TYPE(obj));
- return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type)));
- }
- if (obj == Py_None)
- obj = NULL;
-#endif
- return __Pyx_PyMethod_New(func, obj, type);
-}
-static PyObject*
-__Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
-{
-#if PY_MAJOR_VERSION >= 3
- return PyUnicode_FromFormat("",
- op->func_qualname, (void *)op);
-#else
- return PyString_FromFormat("",
- PyString_AsString(op->func_qualname), (void *)op);
-#endif
-}
-static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) {
- PyCFunctionObject* f = (PyCFunctionObject*)func;
- PyCFunction meth = f->m_ml->ml_meth;
- Py_ssize_t size;
- switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) {
- case METH_VARARGS:
- if (likely(kw == NULL || PyDict_Size(kw) == 0))
- return (*meth)(self, arg);
- break;
- case METH_VARARGS | METH_KEYWORDS:
- return (*(PyCFunctionWithKeywords)(void*)meth)(self, arg, kw);
- case METH_NOARGS:
- if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
- size = PyTuple_GET_SIZE(arg);
- if (likely(size == 0))
- return (*meth)(self, NULL);
- PyErr_Format(PyExc_TypeError,
- "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)",
- f->m_ml->ml_name, size);
- return NULL;
- }
- break;
- case METH_O:
- if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
- size = PyTuple_GET_SIZE(arg);
- if (likely(size == 1)) {
- PyObject *result, *arg0;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- arg0 = PyTuple_GET_ITEM(arg, 0);
- #else
- arg0 = PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL;
- #endif
- result = (*meth)(self, arg0);
- #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
- Py_DECREF(arg0);
- #endif
- return result;
- }
- PyErr_Format(PyExc_TypeError,
- "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)",
- f->m_ml->ml_name, size);
- return NULL;
- }
- break;
- default:
- PyErr_SetString(PyExc_SystemError, "Bad call flags in "
- "__Pyx_CyFunction_Call. METH_OLDARGS is no "
- "longer supported!");
- return NULL;
- }
- PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
- f->m_ml->ml_name);
- return NULL;
-}
-static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
- return __Pyx_CyFunction_CallMethod(func, ((PyCFunctionObject*)func)->m_self, arg, kw);
-}
-static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) {
- PyObject *result;
- __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func;
- if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
- Py_ssize_t argc;
- PyObject *new_args;
- PyObject *self;
- argc = PyTuple_GET_SIZE(args);
- new_args = PyTuple_GetSlice(args, 1, argc);
- if (unlikely(!new_args))
- return NULL;
- self = PyTuple_GetItem(args, 0);
- if (unlikely(!self)) {
- Py_DECREF(new_args);
-#if PY_MAJOR_VERSION > 2
- PyErr_Format(PyExc_TypeError,
- "unbound method %.200S() needs an argument",
- cyfunc->func_qualname);
-#else
- PyErr_SetString(PyExc_TypeError,
- "unbound method needs an argument");
-#endif
- return NULL;
- }
- result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw);
- Py_DECREF(new_args);
- } else {
- result = __Pyx_CyFunction_Call(func, args, kw);
- }
- return result;
-}
-static PyTypeObject __pyx_CyFunctionType_type = {
- PyVarObject_HEAD_INIT(0, 0)
- "cython_function_or_method",
- sizeof(__pyx_CyFunctionObject),
- 0,
- (destructor) __Pyx_CyFunction_dealloc,
- 0,
- 0,
- 0,
-#if PY_MAJOR_VERSION < 3
- 0,
-#else
- 0,
-#endif
- (reprfunc) __Pyx_CyFunction_repr,
- 0,
- 0,
- 0,
- 0,
- __Pyx_CyFunction_CallAsMethod,
- 0,
- 0,
- 0,
- 0,
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
- 0,
- (traverseproc) __Pyx_CyFunction_traverse,
- (inquiry) __Pyx_CyFunction_clear,
- 0,
-#if PY_VERSION_HEX < 0x030500A0
- offsetof(__pyx_CyFunctionObject, func_weakreflist),
-#else
- offsetof(PyCFunctionObject, m_weakreflist),
-#endif
- 0,
- 0,
- __pyx_CyFunction_methods,
- __pyx_CyFunction_members,
- __pyx_CyFunction_getsets,
- 0,
- 0,
- __Pyx_CyFunction_descr_get,
- 0,
- offsetof(__pyx_CyFunctionObject, func_dict),
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
-#if PY_VERSION_HEX >= 0x030400a1
- 0,
-#endif
-#if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800)
- 0,
-#endif
-#if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
- 0,
-#endif
-#if PY_VERSION_HEX >= 0x030C0000
- 0,
-#endif
-#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
- 0,
-#endif
-};
-static int __pyx_CyFunction_init(void) {
- __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type);
- if (unlikely(__pyx_CyFunctionType == NULL)) {
- return -1;
- }
- return 0;
-}
-static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->defaults = PyObject_Malloc(size);
- if (unlikely(!m->defaults))
- return PyErr_NoMemory();
- memset(m->defaults, 0, size);
- m->defaults_pyobjects = pyobjects;
- m->defaults_size = size;
- return m->defaults;
-}
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->defaults_tuple = tuple;
- Py_INCREF(tuple);
-}
-static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->defaults_kwdict = dict;
- Py_INCREF(dict);
-}
-static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
- __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
- m->func_annotations = dict;
- Py_INCREF(dict);
-}
-
-/* CythonFunction */
-static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml, int flags, PyObject* qualname,
- PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
- PyObject *op = __Pyx_CyFunction_Init(
- PyObject_GC_New(__pyx_CyFunctionObject, __pyx_CyFunctionType),
- ml, flags, qualname, closure, module, globals, code
- );
- if (likely(op)) {
- PyObject_GC_Track(op);
- }
- return op;
-}
-
-/* Py3ClassCreate */
-static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name,
- PyObject *qualname, PyObject *mkw, PyObject *modname, PyObject *doc) {
- PyObject *ns;
- if (metaclass) {
- PyObject *prep = __Pyx_PyObject_GetAttrStr(metaclass, __pyx_n_s_prepare);
- if (prep) {
- PyObject *pargs = PyTuple_Pack(2, name, bases);
- if (unlikely(!pargs)) {
- Py_DECREF(prep);
- return NULL;
- }
- ns = PyObject_Call(prep, pargs, mkw);
- Py_DECREF(prep);
- Py_DECREF(pargs);
- } else {
- if (unlikely(!PyErr_ExceptionMatches(PyExc_AttributeError)))
- return NULL;
- PyErr_Clear();
- ns = PyDict_New();
- }
- } else {
- ns = PyDict_New();
- }
- if (unlikely(!ns))
- return NULL;
- if (unlikely(PyObject_SetItem(ns, __pyx_n_s_module, modname) < 0)) goto bad;
- if (unlikely(PyObject_SetItem(ns, __pyx_n_s_qualname, qualname) < 0)) goto bad;
- if (unlikely(doc && PyObject_SetItem(ns, __pyx_n_s_doc, doc) < 0)) goto bad;
- return ns;
-bad:
- Py_DECREF(ns);
- return NULL;
-}
-static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases,
- PyObject *dict, PyObject *mkw,
- int calculate_metaclass, int allow_py2_metaclass) {
- PyObject *result, *margs;
- PyObject *owned_metaclass = NULL;
- if (allow_py2_metaclass) {
- owned_metaclass = PyObject_GetItem(dict, __pyx_n_s_metaclass);
- if (owned_metaclass) {
- metaclass = owned_metaclass;
- } else if (likely(PyErr_ExceptionMatches(PyExc_KeyError))) {
- PyErr_Clear();
- } else {
- return NULL;
- }
- }
- if (calculate_metaclass && (!metaclass || PyType_Check(metaclass))) {
- metaclass = __Pyx_CalculateMetaclass((PyTypeObject*) metaclass, bases);
- Py_XDECREF(owned_metaclass);
- if (unlikely(!metaclass))
- return NULL;
- owned_metaclass = metaclass;
- }
- margs = PyTuple_Pack(3, name, bases, dict);
- if (unlikely(!margs)) {
- result = NULL;
- } else {
- result = PyObject_Call(metaclass, margs, mkw);
- Py_DECREF(margs);
- }
- Py_XDECREF(owned_metaclass);
- return result;
-}
-
-/* CLineInTraceback */
-#ifndef CYTHON_CLINE_IN_TRACEBACK
-static int __Pyx_CLineForTraceback(CYTHON_UNUSED PyThreadState *tstate, int c_line) {
- PyObject *use_cline;
- PyObject *ptype, *pvalue, *ptraceback;
-#if CYTHON_COMPILING_IN_CPYTHON
- PyObject **cython_runtime_dict;
-#endif
- if (unlikely(!__pyx_cython_runtime)) {
- return c_line;
- }
- __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
-#if CYTHON_COMPILING_IN_CPYTHON
- cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
- if (likely(cython_runtime_dict)) {
- __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
- use_cline, *cython_runtime_dict,
- __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
- } else
-#endif
- {
- PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
- if (use_cline_obj) {
- use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
- Py_DECREF(use_cline_obj);
- } else {
- PyErr_Clear();
- use_cline = NULL;
- }
- }
- if (!use_cline) {
- c_line = 0;
- (void) PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
- }
- else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
- c_line = 0;
- }
- __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
- return c_line;
-}
-#endif
-
-/* CodeObjectCache */
-static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
- int start = 0, mid = 0, end = count - 1;
- if (end >= 0 && code_line > entries[end].code_line) {
- return count;
- }
- while (start < end) {
- mid = start + (end - start) / 2;
- if (code_line < entries[mid].code_line) {
- end = mid;
- } else if (code_line > entries[mid].code_line) {
- start = mid + 1;
- } else {
- return mid;
- }
- }
- if (code_line <= entries[mid].code_line) {
- return mid;
- } else {
- return mid + 1;
- }
-}
-static PyCodeObject *__pyx_find_code_object(int code_line) {
- PyCodeObject* code_object;
- int pos;
- if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
- return NULL;
- }
- pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
- if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
- return NULL;
- }
- code_object = __pyx_code_cache.entries[pos].code_object;
- Py_INCREF(code_object);
- return code_object;
-}
-static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
- int pos, i;
- __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
- if (unlikely(!code_line)) {
- return;
- }
- if (unlikely(!entries)) {
- entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
- if (likely(entries)) {
- __pyx_code_cache.entries = entries;
- __pyx_code_cache.max_count = 64;
- __pyx_code_cache.count = 1;
- entries[0].code_line = code_line;
- entries[0].code_object = code_object;
- Py_INCREF(code_object);
- }
- return;
- }
- pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
- if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
- PyCodeObject* tmp = entries[pos].code_object;
- entries[pos].code_object = code_object;
- Py_DECREF(tmp);
- return;
- }
- if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
- int new_max = __pyx_code_cache.max_count + 64;
- entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
- __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
- if (unlikely(!entries)) {
- return;
- }
- __pyx_code_cache.entries = entries;
- __pyx_code_cache.max_count = new_max;
- }
- for (i=__pyx_code_cache.count; i>pos; i--) {
- entries[i] = entries[i-1];
- }
- entries[pos].code_line = code_line;
- entries[pos].code_object = code_object;
- __pyx_code_cache.count++;
- Py_INCREF(code_object);
-}
-
-/* AddTraceback */
-#include "compile.h"
-#include "frameobject.h"
-#include "traceback.h"
-#if PY_VERSION_HEX >= 0x030b00a6
- #ifndef Py_BUILD_CORE
- #define Py_BUILD_CORE 1
- #endif
- #include "internal/pycore_frame.h"
-#endif
-static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
- const char *funcname, int c_line,
- int py_line, const char *filename) {
- PyCodeObject *py_code = NULL;
- PyObject *py_funcname = NULL;
- #if PY_MAJOR_VERSION < 3
- PyObject *py_srcfile = NULL;
- py_srcfile = PyString_FromString(filename);
- if (!py_srcfile) goto bad;
- #endif
- if (c_line) {
- #if PY_MAJOR_VERSION < 3
- py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
- if (!py_funcname) goto bad;
- #else
- py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
- if (!py_funcname) goto bad;
- funcname = PyUnicode_AsUTF8(py_funcname);
- if (!funcname) goto bad;
- #endif
- }
- else {
- #if PY_MAJOR_VERSION < 3
- py_funcname = PyString_FromString(funcname);
- if (!py_funcname) goto bad;
- #endif
- }
- #if PY_MAJOR_VERSION < 3
- py_code = __Pyx_PyCode_New(
- 0,
- 0,
- 0,
- 0,
- 0,
- __pyx_empty_bytes, /*PyObject *code,*/
- __pyx_empty_tuple, /*PyObject *consts,*/
- __pyx_empty_tuple, /*PyObject *names,*/
- __pyx_empty_tuple, /*PyObject *varnames,*/
- __pyx_empty_tuple, /*PyObject *freevars,*/
- __pyx_empty_tuple, /*PyObject *cellvars,*/
- py_srcfile, /*PyObject *filename,*/
- py_funcname, /*PyObject *name,*/
- py_line,
- __pyx_empty_bytes /*PyObject *lnotab*/
- );
- Py_DECREF(py_srcfile);
- #else
- py_code = PyCode_NewEmpty(filename, funcname, py_line);
- #endif
- Py_XDECREF(py_funcname); // XDECREF since it's only set on Py3 if cline
- return py_code;
-bad:
- Py_XDECREF(py_funcname);
- #if PY_MAJOR_VERSION < 3
- Py_XDECREF(py_srcfile);
- #endif
- return NULL;
-}
-static void __Pyx_AddTraceback(const char *funcname, int c_line,
- int py_line, const char *filename) {
- PyCodeObject *py_code = 0;
- PyFrameObject *py_frame = 0;
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- PyObject *ptype, *pvalue, *ptraceback;
- if (c_line) {
- c_line = __Pyx_CLineForTraceback(tstate, c_line);
- }
- py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
- if (!py_code) {
- __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
- py_code = __Pyx_CreateCodeObjectForTraceback(
- funcname, c_line, py_line, filename);
- if (!py_code) {
- /* If the code object creation fails, then we should clear the
- fetched exception references and propagate the new exception */
- Py_XDECREF(ptype);
- Py_XDECREF(pvalue);
- Py_XDECREF(ptraceback);
- goto bad;
- }
- __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
- __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
- }
- py_frame = PyFrame_New(
- tstate, /*PyThreadState *tstate,*/
- py_code, /*PyCodeObject *code,*/
- __pyx_d, /*PyObject *globals,*/
- 0 /*PyObject *locals*/
- );
- if (!py_frame) goto bad;
- __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
- PyTraceBack_Here(py_frame);
-bad:
- Py_XDECREF(py_code);
- Py_XDECREF(py_frame);
-}
-
-/* CIntToPy */
-static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
-#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"
-#endif
- const long neg_one = (long) -1, const_zero = (long) 0;
-#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
-#pragma GCC diagnostic pop
-#endif
- const int is_unsigned = neg_one > const_zero;
- if (is_unsigned) {
- if (sizeof(long) < sizeof(long)) {
- return PyInt_FromLong((long) value);
- } else if (sizeof(long) <= sizeof(unsigned long)) {
- return PyLong_FromUnsignedLong((unsigned long) value);
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
- return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
-#endif
- }
- } else {
- if (sizeof(long) <= sizeof(long)) {
- return PyInt_FromLong((long) value);
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
- return PyLong_FromLongLong((PY_LONG_LONG) value);
-#endif
- }
- }
- {
- int one = 1; int little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&value;
- return _PyLong_FromByteArray(bytes, sizeof(long),
- little, !is_unsigned);
- }
-}
-
-/* CIntFromPyVerify */
-#define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
- __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
-#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
- __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
-#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
- {\
- func_type value = func_value;\
- if (sizeof(target_type) < sizeof(func_type)) {\
- if (unlikely(value != (func_type) (target_type) value)) {\
- func_type zero = 0;\
- if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
- return (target_type) -1;\
- if (is_unsigned && unlikely(value < zero))\
- goto raise_neg_overflow;\
- else\
- goto raise_overflow;\
- }\
- }\
- return (target_type) value;\
- }
-
-/* CIntFromPy */
-static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
-#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"
-#endif
- const long neg_one = (long) -1, const_zero = (long) 0;
-#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
-#pragma GCC diagnostic pop
-#endif
- const int is_unsigned = neg_one > const_zero;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_Check(x))) {
- if (sizeof(long) < sizeof(long)) {
- __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
- } else {
- long val = PyInt_AS_LONG(x);
- if (is_unsigned && unlikely(val < 0)) {
- goto raise_neg_overflow;
- }
- return (long) val;
- }
- } else
-#endif
- if (likely(PyLong_Check(x))) {
- if (is_unsigned) {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (long) 0;
- case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
- case 2:
- if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
- return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
- }
- }
- break;
- case 3:
- if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
- return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
- }
- }
- break;
- case 4:
- if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
- return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
- }
- }
- break;
- }
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7
- if (unlikely(Py_SIZE(x) < 0)) {
- goto raise_neg_overflow;
- }
-#else
- {
- int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
- if (unlikely(result < 0))
- return (long) -1;
- if (unlikely(result == 1))
- goto raise_neg_overflow;
- }
-#endif
- if (sizeof(long) <= sizeof(unsigned long)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
-#endif
- }
- } else {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (long) 0;
- case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
- case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
- case -2:
- if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case 2:
- if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case -3:
- if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case 3:
- if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case -4:
- if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
- return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case 4:
- if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
- return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- }
-#endif
- if (sizeof(long) <= sizeof(long)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
-#endif
- }
- }
- {
-#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
- PyErr_SetString(PyExc_RuntimeError,
- "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
-#else
- long val;
- PyObject *v = __Pyx_PyNumber_IntOrLong(x);
- #if PY_MAJOR_VERSION < 3
- if (likely(v) && !PyLong_Check(v)) {
- PyObject *tmp = v;
- v = PyNumber_Long(tmp);
- Py_DECREF(tmp);
- }
- #endif
- if (likely(v)) {
- int one = 1; int is_little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&val;
- int ret = _PyLong_AsByteArray((PyLongObject *)v,
- bytes, sizeof(val),
- is_little, !is_unsigned);
- Py_DECREF(v);
- if (likely(!ret))
- return val;
- }
-#endif
- return (long) -1;
- }
- } else {
- long val;
- PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
- if (!tmp) return (long) -1;
- val = __Pyx_PyInt_As_long(tmp);
- Py_DECREF(tmp);
- return val;
- }
-raise_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "value too large to convert to long");
- return (long) -1;
-raise_neg_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "can't convert negative value to long");
- return (long) -1;
-}
-
-/* CIntFromPy */
-static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
-#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"
-#endif
- const int neg_one = (int) -1, const_zero = (int) 0;
-#ifdef __Pyx_HAS_GCC_DIAGNOSTIC
-#pragma GCC diagnostic pop
-#endif
- const int is_unsigned = neg_one > const_zero;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_Check(x))) {
- if (sizeof(int) < sizeof(long)) {
- __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
- } else {
- long val = PyInt_AS_LONG(x);
- if (is_unsigned && unlikely(val < 0)) {
- goto raise_neg_overflow;
- }
- return (int) val;
- }
- } else
-#endif
- if (likely(PyLong_Check(x))) {
- if (is_unsigned) {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (int) 0;
- case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
- case 2:
- if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
- return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
- }
- }
- break;
- case 3:
- if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
- return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
- }
- }
- break;
- case 4:
- if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
- return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
- }
- }
- break;
- }
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7
- if (unlikely(Py_SIZE(x) < 0)) {
- goto raise_neg_overflow;
- }
-#else
- {
- int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
- if (unlikely(result < 0))
- return (int) -1;
- if (unlikely(result == 1))
- goto raise_neg_overflow;
- }
-#endif
- if (sizeof(int) <= sizeof(unsigned long)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
-#endif
- }
- } else {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (int) 0;
- case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
- case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
- case -2:
- if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
- return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case 2:
- if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
- return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case -3:
- if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
- return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case 3:
- if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
- return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case -4:
- if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
- return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case 4:
- if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
- return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- }
-#endif
- if (sizeof(int) <= sizeof(long)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
-#endif
- }
- }
- {
-#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
- PyErr_SetString(PyExc_RuntimeError,
- "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
-#else
- int val;
- PyObject *v = __Pyx_PyNumber_IntOrLong(x);
- #if PY_MAJOR_VERSION < 3
- if (likely(v) && !PyLong_Check(v)) {
- PyObject *tmp = v;
- v = PyNumber_Long(tmp);
- Py_DECREF(tmp);
- }
- #endif
- if (likely(v)) {
- int one = 1; int is_little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&val;
- int ret = _PyLong_AsByteArray((PyLongObject *)v,
- bytes, sizeof(val),
- is_little, !is_unsigned);
- Py_DECREF(v);
- if (likely(!ret))
- return val;
- }
-#endif
- return (int) -1;
- }
- } else {
- int val;
- PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
- if (!tmp) return (int) -1;
- val = __Pyx_PyInt_As_int(tmp);
- Py_DECREF(tmp);
- return val;
- }
-raise_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "value too large to convert to int");
- return (int) -1;
-raise_neg_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "can't convert negative value to int");
- return (int) -1;
-}
-
-/* CheckBinaryVersion */
-static int __Pyx_check_binary_version(void) {
- char ctversion[5];
- int same=1, i, found_dot;
- const char* rt_from_call = Py_GetVersion();
- PyOS_snprintf(ctversion, 5, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
- found_dot = 0;
- for (i = 0; i < 4; i++) {
- if (!ctversion[i]) {
- same = (rt_from_call[i] < '0' || rt_from_call[i] > '9');
- break;
- }
- if (rt_from_call[i] != ctversion[i]) {
- same = 0;
- break;
- }
- }
- if (!same) {
- char rtversion[5] = {'\0'};
- char message[200];
- for (i=0; i<4; ++i) {
- if (rt_from_call[i] == '.') {
- if (found_dot) break;
- found_dot = 1;
- } else if (rt_from_call[i] < '0' || rt_from_call[i] > '9') {
- break;
- }
- rtversion[i] = rt_from_call[i];
- }
- PyOS_snprintf(message, sizeof(message),
- "compiletime version %s of module '%.100s' "
- "does not match runtime version %s",
- ctversion, __Pyx_MODULE_NAME, rtversion);
- return PyErr_WarnEx(NULL, message, 1);
- }
- return 0;
-}
-
-/* InitStrings */
-static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
- while (t->p) {
- #if PY_MAJOR_VERSION < 3
- if (t->is_unicode) {
- *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
- } else if (t->intern) {
- *t->p = PyString_InternFromString(t->s);
- } else {
- *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
- }
- #else
- if (t->is_unicode | t->is_str) {
- if (t->intern) {
- *t->p = PyUnicode_InternFromString(t->s);
- } else if (t->encoding) {
- *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
- } else {
- *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
- }
- } else {
- *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
- }
- #endif
- if (!*t->p)
- return -1;
- if (PyObject_Hash(*t->p) == -1)
- return -1;
- ++t;
- }
- return 0;
-}
-
-static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
- return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
-}
-static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
- Py_ssize_t ignore;
- return __Pyx_PyObject_AsStringAndSize(o, &ignore);
-}
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
-#if !CYTHON_PEP393_ENABLED
-static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
- char* defenc_c;
- PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
- if (!defenc) return NULL;
- defenc_c = PyBytes_AS_STRING(defenc);
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
- {
- char* end = defenc_c + PyBytes_GET_SIZE(defenc);
- char* c;
- for (c = defenc_c; c < end; c++) {
- if ((unsigned char) (*c) >= 128) {
- PyUnicode_AsASCIIString(o);
- return NULL;
- }
- }
- }
-#endif
- *length = PyBytes_GET_SIZE(defenc);
- return defenc_c;
-}
-#else
-static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
- if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
- if (likely(PyUnicode_IS_ASCII(o))) {
- *length = PyUnicode_GET_LENGTH(o);
- return PyUnicode_AsUTF8(o);
- } else {
- PyUnicode_AsASCIIString(o);
- return NULL;
- }
-#else
- return PyUnicode_AsUTF8AndSize(o, length);
-#endif
-}
-#endif
-#endif
-static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
- if (
-#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
- __Pyx_sys_getdefaultencoding_not_ascii &&
-#endif
- PyUnicode_Check(o)) {
- return __Pyx_PyUnicode_AsStringAndSize(o, length);
- } else
-#endif
-#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
- if (PyByteArray_Check(o)) {
- *length = PyByteArray_GET_SIZE(o);
- return PyByteArray_AS_STRING(o);
- } else
-#endif
- {
- char* result;
- int r = PyBytes_AsStringAndSize(o, &result, length);
- if (unlikely(r < 0)) {
- return NULL;
- } else {
- return result;
- }
- }
-}
-static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
- int is_true = x == Py_True;
- if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
- else return PyObject_IsTrue(x);
-}
-static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
- int retval;
- if (unlikely(!x)) return -1;
- retval = __Pyx_PyObject_IsTrue(x);
- Py_DECREF(x);
- return retval;
-}
-static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
-#if PY_MAJOR_VERSION >= 3
- if (PyLong_Check(result)) {
- if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
- "__int__ returned non-int (type %.200s). "
- "The ability to return an instance of a strict subclass of int "
- "is deprecated, and may be removed in a future version of Python.",
- Py_TYPE(result)->tp_name)) {
- Py_DECREF(result);
- return NULL;
- }
- return result;
- }
-#endif
- PyErr_Format(PyExc_TypeError,
- "__%.4s__ returned non-%.4s (type %.200s)",
- type_name, type_name, Py_TYPE(result)->tp_name);
- Py_DECREF(result);
- return NULL;
-}
-static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
-#if CYTHON_USE_TYPE_SLOTS
- PyNumberMethods *m;
-#endif
- const char *name = NULL;
- PyObject *res = NULL;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_Check(x) || PyLong_Check(x)))
-#else
- if (likely(PyLong_Check(x)))
-#endif
- return __Pyx_NewRef(x);
-#if CYTHON_USE_TYPE_SLOTS
- m = Py_TYPE(x)->tp_as_number;
- #if PY_MAJOR_VERSION < 3
- if (m && m->nb_int) {
- name = "int";
- res = m->nb_int(x);
- }
- else if (m && m->nb_long) {
- name = "long";
- res = m->nb_long(x);
- }
- #else
- if (likely(m && m->nb_int)) {
- name = "int";
- res = m->nb_int(x);
- }
- #endif
-#else
- if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
- res = PyNumber_Int(x);
- }
-#endif
- if (likely(res)) {
-#if PY_MAJOR_VERSION < 3
- if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
-#else
- if (unlikely(!PyLong_CheckExact(res))) {
-#endif
- return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
- }
- }
- else if (!PyErr_Occurred()) {
- PyErr_SetString(PyExc_TypeError,
- "an integer is required");
- }
- return res;
-}
-static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
- Py_ssize_t ival;
- PyObject *x;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_CheckExact(b))) {
- if (sizeof(Py_ssize_t) >= sizeof(long))
- return PyInt_AS_LONG(b);
- else
- return PyInt_AsSsize_t(b);
- }
-#endif
- if (likely(PyLong_CheckExact(b))) {
- #if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)b)->ob_digit;
- const Py_ssize_t size = Py_SIZE(b);
- if (likely(__Pyx_sst_abs(size) <= 1)) {
- ival = likely(size) ? digits[0] : 0;
- if (size == -1) ival = -ival;
- return ival;
- } else {
- switch (size) {
- case 2:
- if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
- return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case -2:
- if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
- return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case 3:
- if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
- return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case -3:
- if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
- return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case 4:
- if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
- return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case -4:
- if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
- return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- }
- }
- #endif
- return PyLong_AsSsize_t(b);
- }
- x = PyNumber_Index(b);
- if (!x) return -1;
- ival = PyInt_AsSsize_t(x);
- Py_DECREF(x);
- return ival;
-}
-static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject* o) {
- if (sizeof(Py_hash_t) == sizeof(Py_ssize_t)) {
- return (Py_hash_t) __Pyx_PyIndex_AsSsize_t(o);
-#if PY_MAJOR_VERSION < 3
- } else if (likely(PyInt_CheckExact(o))) {
- return PyInt_AS_LONG(o);
-#endif
- } else {
- Py_ssize_t ival;
- PyObject *x;
- x = PyNumber_Index(o);
- if (!x) return -1;
- ival = PyInt_AsLong(x);
- Py_DECREF(x);
- return ival;
- }
-}
-static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
- return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
-}
-static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
- return PyInt_FromSize_t(ival);
-}
-
-
-#endif /* Py_PYTHON_H */
diff --git a/spaces/Dagfinn1962/stablediffusion-models/README.md b/spaces/Dagfinn1962/stablediffusion-models/README.md
deleted file mode 100644
index 5bd79f1f137204e77aaebfb8b3fc111fb0e7236f..0000000000000000000000000000000000000000
--- a/spaces/Dagfinn1962/stablediffusion-models/README.md
+++ /dev/null
@@ -1,13 +0,0 @@
----
-title: Maximum Multiplier
-emoji: 🛕🛕
-colorFrom: green
-colorTo: blue
-sdk: gradio
-sdk_version: 3.15.0
-app_file: app.py
-pinned: true
-duplicated_from: blueorigin6/stablediffusion-models
----
-
-Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
diff --git a/spaces/DataRaptor/ActionNet/README.md b/spaces/DataRaptor/ActionNet/README.md
deleted file mode 100644
index d45a9c80d111991258335ffb401890a5580982cd..0000000000000000000000000000000000000000
--- a/spaces/DataRaptor/ActionNet/README.md
+++ /dev/null
@@ -1,12 +0,0 @@
----
-title: ActionNet
-emoji: 😻
-colorFrom: green
-colorTo: green
-sdk: streamlit
-sdk_version: 1.21.0
-app_file: app.py
-pinned: false
----
-
-Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
diff --git a/spaces/Datasculptor/StyleGAN-NADA/e4e/models/encoders/psp_encoders.py b/spaces/Datasculptor/StyleGAN-NADA/e4e/models/encoders/psp_encoders.py
deleted file mode 100644
index dc49acd11f062cbd29f839ee3c04bce7fa84f479..0000000000000000000000000000000000000000
--- a/spaces/Datasculptor/StyleGAN-NADA/e4e/models/encoders/psp_encoders.py
+++ /dev/null
@@ -1,200 +0,0 @@
-from enum import Enum
-import math
-import numpy as np
-import torch
-from torch import nn
-from torch.nn import Conv2d, BatchNorm2d, PReLU, Sequential, Module
-
-from e4e.models.encoders.helpers import get_blocks, bottleneck_IR, bottleneck_IR_SE, _upsample_add
-from e4e.models.stylegan2.model import EqualLinear
-
-
-class ProgressiveStage(Enum):
- WTraining = 0
- Delta1Training = 1
- Delta2Training = 2
- Delta3Training = 3
- Delta4Training = 4
- Delta5Training = 5
- Delta6Training = 6
- Delta7Training = 7
- Delta8Training = 8
- Delta9Training = 9
- Delta10Training = 10
- Delta11Training = 11
- Delta12Training = 12
- Delta13Training = 13
- Delta14Training = 14
- Delta15Training = 15
- Delta16Training = 16
- Delta17Training = 17
- Inference = 18
-
-
-class GradualStyleBlock(Module):
- def __init__(self, in_c, out_c, spatial):
- super(GradualStyleBlock, self).__init__()
- self.out_c = out_c
- self.spatial = spatial
- num_pools = int(np.log2(spatial))
- modules = []
- modules += [Conv2d(in_c, out_c, kernel_size=3, stride=2, padding=1),
- nn.LeakyReLU()]
- for i in range(num_pools - 1):
- modules += [
- Conv2d(out_c, out_c, kernel_size=3, stride=2, padding=1),
- nn.LeakyReLU()
- ]
- self.convs = nn.Sequential(*modules)
- self.linear = EqualLinear(out_c, out_c, lr_mul=1)
-
- def forward(self, x):
- x = self.convs(x)
- x = x.view(-1, self.out_c)
- x = self.linear(x)
- return x
-
-
-class GradualStyleEncoder(Module):
- def __init__(self, num_layers, mode='ir', opts=None):
- super(GradualStyleEncoder, self).__init__()
- assert num_layers in [50, 100, 152], 'num_layers should be 50,100, or 152'
- assert mode in ['ir', 'ir_se'], 'mode should be ir or ir_se'
- blocks = get_blocks(num_layers)
- if mode == 'ir':
- unit_module = bottleneck_IR
- elif mode == 'ir_se':
- unit_module = bottleneck_IR_SE
- self.input_layer = Sequential(Conv2d(3, 64, (3, 3), 1, 1, bias=False),
- BatchNorm2d(64),
- PReLU(64))
- modules = []
- for block in blocks:
- for bottleneck in block:
- modules.append(unit_module(bottleneck.in_channel,
- bottleneck.depth,
- bottleneck.stride))
- self.body = Sequential(*modules)
-
- self.styles = nn.ModuleList()
- log_size = int(math.log(opts.stylegan_size, 2))
- self.style_count = 2 * log_size - 2
- self.coarse_ind = 3
- self.middle_ind = 7
- for i in range(self.style_count):
- if i < self.coarse_ind:
- style = GradualStyleBlock(512, 512, 16)
- elif i < self.middle_ind:
- style = GradualStyleBlock(512, 512, 32)
- else:
- style = GradualStyleBlock(512, 512, 64)
- self.styles.append(style)
- self.latlayer1 = nn.Conv2d(256, 512, kernel_size=1, stride=1, padding=0)
- self.latlayer2 = nn.Conv2d(128, 512, kernel_size=1, stride=1, padding=0)
-
- def forward(self, x):
- x = self.input_layer(x)
-
- latents = []
- modulelist = list(self.body._modules.values())
- for i, l in enumerate(modulelist):
- x = l(x)
- if i == 6:
- c1 = x
- elif i == 20:
- c2 = x
- elif i == 23:
- c3 = x
-
- for j in range(self.coarse_ind):
- latents.append(self.styles[j](c3))
-
- p2 = _upsample_add(c3, self.latlayer1(c2))
- for j in range(self.coarse_ind, self.middle_ind):
- latents.append(self.styles[j](p2))
-
- p1 = _upsample_add(p2, self.latlayer2(c1))
- for j in range(self.middle_ind, self.style_count):
- latents.append(self.styles[j](p1))
-
- out = torch.stack(latents, dim=1)
- return out
-
-
-class Encoder4Editing(Module):
- def __init__(self, num_layers, mode='ir', opts=None):
- super(Encoder4Editing, self).__init__()
- assert num_layers in [50, 100, 152], 'num_layers should be 50,100, or 152'
- assert mode in ['ir', 'ir_se'], 'mode should be ir or ir_se'
- blocks = get_blocks(num_layers)
- if mode == 'ir':
- unit_module = bottleneck_IR
- elif mode == 'ir_se':
- unit_module = bottleneck_IR_SE
- self.input_layer = Sequential(Conv2d(3, 64, (3, 3), 1, 1, bias=False),
- BatchNorm2d(64),
- PReLU(64))
- modules = []
- for block in blocks:
- for bottleneck in block:
- modules.append(unit_module(bottleneck.in_channel,
- bottleneck.depth,
- bottleneck.stride))
- self.body = Sequential(*modules)
-
- self.styles = nn.ModuleList()
- log_size = int(math.log(opts.stylegan_size, 2))
- self.style_count = 2 * log_size - 2
- self.coarse_ind = 3
- self.middle_ind = 7
-
- for i in range(self.style_count):
- if i < self.coarse_ind:
- style = GradualStyleBlock(512, 512, 16)
- elif i < self.middle_ind:
- style = GradualStyleBlock(512, 512, 32)
- else:
- style = GradualStyleBlock(512, 512, 64)
- self.styles.append(style)
-
- self.latlayer1 = nn.Conv2d(256, 512, kernel_size=1, stride=1, padding=0)
- self.latlayer2 = nn.Conv2d(128, 512, kernel_size=1, stride=1, padding=0)
-
- self.progressive_stage = ProgressiveStage.Inference
-
- def get_deltas_starting_dimensions(self):
- ''' Get a list of the initial dimension of every delta from which it is applied '''
- return list(range(self.style_count)) # Each dimension has a delta applied to it
-
- def set_progressive_stage(self, new_stage: ProgressiveStage):
- self.progressive_stage = new_stage
- print('Changed progressive stage to: ', new_stage)
-
- def forward(self, x):
- x = self.input_layer(x)
-
- modulelist = list(self.body._modules.values())
- for i, l in enumerate(modulelist):
- x = l(x)
- if i == 6:
- c1 = x
- elif i == 20:
- c2 = x
- elif i == 23:
- c3 = x
-
- # Infer main W and duplicate it
- w0 = self.styles[0](c3)
- w = w0.repeat(self.style_count, 1, 1).permute(1, 0, 2)
- stage = self.progressive_stage.value
- features = c3
- for i in range(1, min(stage + 1, self.style_count)): # Infer additional deltas
- if i == self.coarse_ind:
- p2 = _upsample_add(c3, self.latlayer1(c2)) # FPN's middle features
- features = p2
- elif i == self.middle_ind:
- p1 = _upsample_add(p2, self.latlayer2(c1)) # FPN's fine features
- features = p1
- delta_i = self.styles[i](features)
- w[:, i] += delta_i
- return w
diff --git a/spaces/EPFL-VILAB/MultiMAE/mask2former/modeling/meta_arch/__init__.py b/spaces/EPFL-VILAB/MultiMAE/mask2former/modeling/meta_arch/__init__.py
deleted file mode 100644
index 9020c2df23e2af280b7bb168b996ae9eaf312eb8..0000000000000000000000000000000000000000
--- a/spaces/EPFL-VILAB/MultiMAE/mask2former/modeling/meta_arch/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-# Copyright (c) Facebook, Inc. and its affiliates.
diff --git a/spaces/ERICTORRALBA/CAD/README.md b/spaces/ERICTORRALBA/CAD/README.md
deleted file mode 100644
index 2ab4aebe218676d37a6fb194259d911ab2f49b79..0000000000000000000000000000000000000000
--- a/spaces/ERICTORRALBA/CAD/README.md
+++ /dev/null
@@ -1,11 +0,0 @@
----
-title: AutoTrain Advanced
-emoji: 🚀
-colorFrom: blue
-colorTo: green
-sdk: docker
-pinned: false
-license: apache-2.0
----
-
-Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
diff --git a/spaces/ElainaFanBoy/MusicGen/audiocraft/utils/__init__.py b/spaces/ElainaFanBoy/MusicGen/audiocraft/utils/__init__.py
deleted file mode 100644
index 0952fcc3f57e34b3747962e9ebd6fc57aeea63fa..0000000000000000000000000000000000000000
--- a/spaces/ElainaFanBoy/MusicGen/audiocraft/utils/__init__.py
+++ /dev/null
@@ -1,5 +0,0 @@
-# Copyright (c) Meta Platforms, Inc. and affiliates.
-# All rights reserved.
-#
-# This source code is licensed under the license found in the
-# LICENSE file in the root directory of this source tree.
diff --git a/spaces/Fernando22/freegpt-webui/g4f/Provider/Providers/helpers/phind.py b/spaces/Fernando22/freegpt-webui/g4f/Provider/Providers/helpers/phind.py
deleted file mode 100644
index 70525d51d849c43bd1cf29c7f9b18f22bff1e982..0000000000000000000000000000000000000000
--- a/spaces/Fernando22/freegpt-webui/g4f/Provider/Providers/helpers/phind.py
+++ /dev/null
@@ -1,69 +0,0 @@
-import sys
-import json
-import datetime
-import urllib.parse
-
-from curl_cffi import requests
-
-config = json.loads(sys.argv[1])
-prompt = config['messages'][-1]['content']
-
-skill = 'expert' if config['model'] == 'gpt-4' else 'intermediate'
-
-json_data = json.dumps({
- 'question': prompt,
- 'options': {
- 'skill': skill,
- 'date': datetime.datetime.now().strftime('%d/%m/%Y'),
- 'language': 'en',
- 'detailed': True,
- 'creative': True,
- 'customLinks': []}}, separators=(',', ':'))
-
-headers = {
- 'Content-Type': 'application/json',
- 'Pragma': 'no-cache',
- 'Accept': '*/*',
- 'Sec-Fetch-Site': 'same-origin',
- 'Accept-Language': 'en-GB,en;q=0.9',
- 'Cache-Control': 'no-cache',
- 'Sec-Fetch-Mode': 'cors',
- 'Content-Length': str(len(json_data)),
- 'Origin': 'https://www.phind.com',
- 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.4 Safari/605.1.15',
- 'Referer': f'https://www.phind.com/search?q={urllib.parse.quote(prompt)}&source=searchbox',
- 'Connection': 'keep-alive',
- 'Host': 'www.phind.com',
- 'Sec-Fetch-Dest': 'empty'
-}
-
-
-def output(chunk):
- try:
- if b'PHIND_METADATA' in chunk:
- return
-
- if chunk == b'data: \r\ndata: \r\ndata: \r\n\r\n':
- chunk = b'data: \n\r\n\r\n'
-
- chunk = chunk.decode()
-
- chunk = chunk.replace('data: \r\n\r\ndata: ', 'data: \n')
- chunk = chunk.replace('\r\ndata: \r\ndata: \r\n\r\n', '\n\r\n\r\n')
- chunk = chunk.replace('data: ', '').replace('\r\n\r\n', '')
-
- print(chunk, flush=True, end = '')
-
- except json.decoder.JSONDecodeError:
- pass
-
-while True:
- try:
- response = requests.post('https://www.phind.com/api/infer/answer',
- headers=headers, data=json_data, content_callback=output, timeout=999999, impersonate='safari15_5')
-
- exit(0)
-
- except Exception as e:
- print('an error occured, retrying... |', e, flush=True)
- continue
\ No newline at end of file
diff --git a/spaces/FloydianSound/Redline_Diffusion_V1-5/app.py b/spaces/FloydianSound/Redline_Diffusion_V1-5/app.py
deleted file mode 100644
index 943aaae60d5f541506f76dc5ba3f8f865d6dd999..0000000000000000000000000000000000000000
--- a/spaces/FloydianSound/Redline_Diffusion_V1-5/app.py
+++ /dev/null
@@ -1,137 +0,0 @@
-from diffusers import StableDiffusionPipeline, StableDiffusionImg2ImgPipeline, DPMSolverMultistepScheduler
-import gradio as gr
-import torch
-from PIL import Image
-
-model_id = 'FloydianSound/Redline_Diffusion_V1-5'
-prefix = 'redline'
-
-scheduler = DPMSolverMultistepScheduler.from_pretrained(model_id, subfolder="scheduler")
-
-pipe = StableDiffusionPipeline.from_pretrained(
- model_id,
- torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
- scheduler=scheduler)
-
-pipe_i2i = StableDiffusionImg2ImgPipeline.from_pretrained(
- model_id,
- torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
- scheduler=scheduler)
-
-if torch.cuda.is_available():
- pipe = pipe.to("cuda")
- pipe_i2i = pipe_i2i.to("cuda")
-
-def error_str(error, title="Error"):
- return f"""#### {title}
- {error}""" if error else ""
-
-def inference(prompt, guidance, steps, width=512, height=512, seed=0, img=None, strength=0.5, neg_prompt="", auto_prefix=False):
-
- generator = torch.Generator('cuda').manual_seed(seed) if seed != 0 else None
- prompt = f"{prefix} {prompt}" if auto_prefix else prompt
-
- try:
- if img is not None:
- return img_to_img(prompt, neg_prompt, img, strength, guidance, steps, width, height, generator), None
- else:
- return txt_to_img(prompt, neg_prompt, guidance, steps, width, height, generator), None
- except Exception as e:
- return None, error_str(e)
-
-def txt_to_img(prompt, neg_prompt, guidance, steps, width, height, generator):
-
- result = pipe(
- prompt,
- negative_prompt = neg_prompt,
- num_inference_steps = int(steps),
- guidance_scale = guidance,
- width = width,
- height = height,
- generator = generator)
-
- return result.images[0]
-
-def img_to_img(prompt, neg_prompt, img, strength, guidance, steps, width, height, generator):
-
- ratio = min(height / img.height, width / img.width)
- img = img.resize((int(img.width * ratio), int(img.height * ratio)), Image.LANCZOS)
- result = pipe_i2i(
- prompt,
- negative_prompt = neg_prompt,
- init_image = img,
- num_inference_steps = int(steps),
- strength = strength,
- guidance_scale = guidance,
- width = width,
- height = height,
- generator = generator)
-
- return result.images[0]
-
-css = """.main-div div{display:inline-flex;align-items:center;gap:.8rem;font-size:1.75rem}.main-div div h1{font-weight:900;margin-bottom:7px}.main-div p{margin-bottom:10px;font-size:94%}a{text-decoration:underline}.tabs{margin-top:0;margin-bottom:0}#gallery{min-height:20rem}
-"""
-with gr.Blocks(css=css) as demo:
- gr.HTML(
- f"""
-
-
-
Redline Diffusion V1 5
-
-
- Demo for Redline Diffusion V1 5 Stable Diffusion model.
- {"Add the following tokens to your prompts for the model to work properly: prefix " if prefix else ""}
-
- Running on {"
GPU 🔥 " if torch.cuda.is_available() else f"
CPU 🥶 . For faster inference it is recommended to
upgrade to GPU in Settings "} after duplicating the space
-
-
- """
- )
- with gr.Row():
-
- with gr.Column(scale=55):
- with gr.Group():
- with gr.Row():
- prompt = gr.Textbox(label="Prompt", show_label=False, max_lines=2,placeholder=f"{prefix} [your prompt]").style(container=False)
- generate = gr.Button(value="Generate").style(rounded=(False, True, True, False))
-
- image_out = gr.Image(height=512)
- error_output = gr.Markdown()
-
- with gr.Column(scale=45):
- with gr.Tab("Options"):
- with gr.Group():
- neg_prompt = gr.Textbox(label="Negative prompt", placeholder="What to exclude from the image")
- auto_prefix = gr.Checkbox(label="Prefix styling tokens automatically (redline)", value=prefix, visible=prefix)
-
- with gr.Row():
- guidance = gr.Slider(label="Guidance scale", value=7.5, maximum=15)
- steps = gr.Slider(label="Steps", value=25, minimum=2, maximum=75, step=1)
-
- with gr.Row():
- width = gr.Slider(label="Width", value=512, minimum=64, maximum=1024, step=8)
- height = gr.Slider(label="Height", value=512, minimum=64, maximum=1024, step=8)
-
- seed = gr.Slider(0, 2147483647, label='Seed (0 = random)', value=0, step=1)
-
- with gr.Tab("Image to image"):
- with gr.Group():
- image = gr.Image(label="Image", height=256, tool="editor", type="pil")
- strength = gr.Slider(label="Transformation strength", minimum=0, maximum=1, step=0.01, value=0.5)
-
- auto_prefix.change(lambda x: gr.update(placeholder=f"{prefix} [your prompt]" if x else "[Your prompt]"), inputs=auto_prefix, outputs=prompt, queue=False)
-
- inputs = [prompt, guidance, steps, width, height, seed, image, strength, neg_prompt, auto_prefix]
- outputs = [image_out, error_output]
- prompt.submit(inference, inputs=inputs, outputs=outputs)
- generate.click(inference, inputs=inputs, outputs=outputs)
-
- gr.HTML("""
-
- """)
-
-demo.queue(concurrency_count=1)
-demo.launch()
diff --git a/spaces/FridaZuley/RVC_HFKawaii/tools/infer/trans_weights.py b/spaces/FridaZuley/RVC_HFKawaii/tools/infer/trans_weights.py
deleted file mode 100644
index 1c54eefd6e7c678238d31e251a2e15479bf35d5b..0000000000000000000000000000000000000000
--- a/spaces/FridaZuley/RVC_HFKawaii/tools/infer/trans_weights.py
+++ /dev/null
@@ -1,18 +0,0 @@
-import pdb
-
-import torch
-
-# a=torch.load(r"E:\codes\py39\vits_vc_gpu_train\logs\ft-mi-suc\G_1000.pth")["model"]#sim_nsf#
-# a=torch.load(r"E:\codes\py39\vits_vc_gpu_train\logs\ft-mi-freeze-vocoder-flow-enc_q\G_1000.pth")["model"]#sim_nsf#
-# a=torch.load(r"E:\codes\py39\vits_vc_gpu_train\logs\ft-mi-freeze-vocoder\G_1000.pth")["model"]#sim_nsf#
-# a=torch.load(r"E:\codes\py39\vits_vc_gpu_train\logs\ft-mi-test\G_1000.pth")["model"]#sim_nsf#
-a = torch.load(
- r"E:\codes\py39\vits_vc_gpu_train\logs\ft-mi-no_opt-no_dropout\G_1000.pth"
-)[
- "model"
-] # sim_nsf#
-for key in a.keys():
- a[key] = a[key].half()
-# torch.save(a,"ft-mi-freeze-vocoder_true_1k.pt")#
-# torch.save(a,"ft-mi-sim1k.pt")#
-torch.save(a, "ft-mi-no_opt-no_dropout.pt") #
diff --git a/spaces/GipAdonimus/Real-Time-Voice-Cloning/README.md b/spaces/GipAdonimus/Real-Time-Voice-Cloning/README.md
deleted file mode 100644
index 753600359817925a36e07b3b5c944567a2f0d946..0000000000000000000000000000000000000000
--- a/spaces/GipAdonimus/Real-Time-Voice-Cloning/README.md
+++ /dev/null
@@ -1,39 +0,0 @@
----
-title: Real Time Voice Cloning
-emoji: 📈
-colorFrom: blue
-colorTo: red
-sdk: gradio
-app_file: app.py
-sdk_version: 3.17.1
-pinned: false
-duplicated_from: akhaliq/Real-Time-Voice-Cloning
----
-
-# Configuration
-
-`title`: _string_
-Display title for the Space
-
-`emoji`: _string_
-Space emoji (emoji-only character allowed)
-
-`colorFrom`: _string_
-Color for Thumbnail gradient (red, yellow, green, blue, indigo, purple, pink, gray)
-
-`colorTo`: _string_
-Color for Thumbnail gradient (red, yellow, green, blue, indigo, purple, pink, gray)
-
-`sdk`: _string_
-Can be either `gradio` or `streamlit`
-
-`sdk_version` : _string_
-Only applicable for `streamlit` SDK.
-See [doc](https://hf.co/docs/hub/spaces) for more info on supported versions.
-
-`app_file`: _string_
-Path to your main application file (which contains either `gradio` or `streamlit` Python code).
-Path is relative to the root of the repository.
-
-`pinned`: _boolean_
-Whether the Space stays on top of your list.
diff --git a/spaces/Gmq-x/gpt-academic/.github/ISSUE_TEMPLATE/feature_request.md b/spaces/Gmq-x/gpt-academic/.github/ISSUE_TEMPLATE/feature_request.md
deleted file mode 100644
index e46a4c01e804aa4b649bd40af6c13d5981c873d4..0000000000000000000000000000000000000000
--- a/spaces/Gmq-x/gpt-academic/.github/ISSUE_TEMPLATE/feature_request.md
+++ /dev/null
@@ -1,10 +0,0 @@
----
-name: Feature request
-about: Suggest an idea for this project
-title: ''
-labels: ''
-assignees: ''
-
----
-
-
diff --git a/spaces/Gradio-Blocks/uniformer_image_detection/configs/hrnet/faster_rcnn_hrnetv2p_w40_2x_coco.py b/spaces/Gradio-Blocks/uniformer_image_detection/configs/hrnet/faster_rcnn_hrnetv2p_w40_2x_coco.py
deleted file mode 100644
index 585cc2c332fd88a9f0164b14084d45d7a3783b11..0000000000000000000000000000000000000000
--- a/spaces/Gradio-Blocks/uniformer_image_detection/configs/hrnet/faster_rcnn_hrnetv2p_w40_2x_coco.py
+++ /dev/null
@@ -1,4 +0,0 @@
-_base_ = './faster_rcnn_hrnetv2p_w40_1x_coco.py'
-# learning policy
-lr_config = dict(step=[16, 22])
-runner = dict(type='EpochBasedRunner', max_epochs=24)
diff --git a/spaces/GrandaddyShmax/MusicGen_Plus_hfv2/audiocraft/modules/seanet.py b/spaces/GrandaddyShmax/MusicGen_Plus_hfv2/audiocraft/modules/seanet.py
deleted file mode 100644
index 3e5998e9153afb6e68ea410d565e00ea835db248..0000000000000000000000000000000000000000
--- a/spaces/GrandaddyShmax/MusicGen_Plus_hfv2/audiocraft/modules/seanet.py
+++ /dev/null
@@ -1,258 +0,0 @@
-# Copyright (c) Meta Platforms, Inc. and affiliates.
-# All rights reserved.
-#
-# This source code is licensed under the license found in the
-# LICENSE file in the root directory of this source tree.
-
-import typing as tp
-
-import numpy as np
-import torch.nn as nn
-
-from .conv import StreamableConv1d, StreamableConvTranspose1d
-from .lstm import StreamableLSTM
-
-
-class SEANetResnetBlock(nn.Module):
- """Residual block from SEANet model.
-
- Args:
- dim (int): Dimension of the input/output.
- kernel_sizes (list): List of kernel sizes for the convolutions.
- dilations (list): List of dilations for the convolutions.
- activation (str): Activation function.
- activation_params (dict): Parameters to provide to the activation function.
- norm (str): Normalization method.
- norm_params (dict): Parameters to provide to the underlying normalization used along with the convolution.
- causal (bool): Whether to use fully causal convolution.
- pad_mode (str): Padding mode for the convolutions.
- compress (int): Reduced dimensionality in residual branches (from Demucs v3).
- true_skip (bool): Whether to use true skip connection or a simple
- (streamable) convolution as the skip connection.
- """
- def __init__(self, dim: int, kernel_sizes: tp.List[int] = [3, 1], dilations: tp.List[int] = [1, 1],
- activation: str = 'ELU', activation_params: dict = {'alpha': 1.0},
- norm: str = 'none', norm_params: tp.Dict[str, tp.Any] = {}, causal: bool = False,
- pad_mode: str = 'reflect', compress: int = 2, true_skip: bool = True):
- super().__init__()
- assert len(kernel_sizes) == len(dilations), 'Number of kernel sizes should match number of dilations'
- act = getattr(nn, activation)
- hidden = dim // compress
- block = []
- for i, (kernel_size, dilation) in enumerate(zip(kernel_sizes, dilations)):
- in_chs = dim if i == 0 else hidden
- out_chs = dim if i == len(kernel_sizes) - 1 else hidden
- block += [
- act(**activation_params),
- StreamableConv1d(in_chs, out_chs, kernel_size=kernel_size, dilation=dilation,
- norm=norm, norm_kwargs=norm_params,
- causal=causal, pad_mode=pad_mode),
- ]
- self.block = nn.Sequential(*block)
- self.shortcut: nn.Module
- if true_skip:
- self.shortcut = nn.Identity()
- else:
- self.shortcut = StreamableConv1d(dim, dim, kernel_size=1, norm=norm, norm_kwargs=norm_params,
- causal=causal, pad_mode=pad_mode)
-
- def forward(self, x):
- return self.shortcut(x) + self.block(x)
-
-
-class SEANetEncoder(nn.Module):
- """SEANet encoder.
-
- Args:
- channels (int): Audio channels.
- dimension (int): Intermediate representation dimension.
- n_filters (int): Base width for the model.
- n_residual_layers (int): nb of residual layers.
- ratios (Sequence[int]): kernel size and stride ratios. The encoder uses downsampling ratios instead of
- upsampling ratios, hence it will use the ratios in the reverse order to the ones specified here
- that must match the decoder order. We use the decoder order as some models may only employ the decoder.
- activation (str): Activation function.
- activation_params (dict): Parameters to provide to the activation function.
- norm (str): Normalization method.
- norm_params (dict): Parameters to provide to the underlying normalization used along with the convolution.
- kernel_size (int): Kernel size for the initial convolution.
- last_kernel_size (int): Kernel size for the initial convolution.
- residual_kernel_size (int): Kernel size for the residual layers.
- dilation_base (int): How much to increase the dilation with each layer.
- causal (bool): Whether to use fully causal convolution.
- pad_mode (str): Padding mode for the convolutions.
- true_skip (bool): Whether to use true skip connection or a simple
- (streamable) convolution as the skip connection in the residual network blocks.
- compress (int): Reduced dimensionality in residual branches (from Demucs v3).
- lstm (int): Number of LSTM layers at the end of the encoder.
- disable_norm_outer_blocks (int): Number of blocks for which we don't apply norm.
- For the encoder, it corresponds to the N first blocks.
- """
- def __init__(self, channels: int = 1, dimension: int = 128, n_filters: int = 32, n_residual_layers: int = 3,
- ratios: tp.List[int] = [8, 5, 4, 2], activation: str = 'ELU', activation_params: dict = {'alpha': 1.0},
- norm: str = 'none', norm_params: tp.Dict[str, tp.Any] = {}, kernel_size: int = 7,
- last_kernel_size: int = 7, residual_kernel_size: int = 3, dilation_base: int = 2, causal: bool = False,
- pad_mode: str = 'reflect', true_skip: bool = True, compress: int = 2, lstm: int = 0,
- disable_norm_outer_blocks: int = 0):
- super().__init__()
- self.channels = channels
- self.dimension = dimension
- self.n_filters = n_filters
- self.ratios = list(reversed(ratios))
- del ratios
- self.n_residual_layers = n_residual_layers
- self.hop_length = np.prod(self.ratios)
- self.n_blocks = len(self.ratios) + 2 # first and last conv + residual blocks
- self.disable_norm_outer_blocks = disable_norm_outer_blocks
- assert self.disable_norm_outer_blocks >= 0 and self.disable_norm_outer_blocks <= self.n_blocks, \
- "Number of blocks for which to disable norm is invalid." \
- "It should be lower or equal to the actual number of blocks in the network and greater or equal to 0."
-
- act = getattr(nn, activation)
- mult = 1
- model: tp.List[nn.Module] = [
- StreamableConv1d(channels, mult * n_filters, kernel_size,
- norm='none' if self.disable_norm_outer_blocks >= 1 else norm,
- norm_kwargs=norm_params, causal=causal, pad_mode=pad_mode)
- ]
- # Downsample to raw audio scale
- for i, ratio in enumerate(self.ratios):
- block_norm = 'none' if self.disable_norm_outer_blocks >= i + 2 else norm
- # Add residual layers
- for j in range(n_residual_layers):
- model += [
- SEANetResnetBlock(mult * n_filters, kernel_sizes=[residual_kernel_size, 1],
- dilations=[dilation_base ** j, 1],
- norm=block_norm, norm_params=norm_params,
- activation=activation, activation_params=activation_params,
- causal=causal, pad_mode=pad_mode, compress=compress, true_skip=true_skip)]
-
- # Add downsampling layers
- model += [
- act(**activation_params),
- StreamableConv1d(mult * n_filters, mult * n_filters * 2,
- kernel_size=ratio * 2, stride=ratio,
- norm=block_norm, norm_kwargs=norm_params,
- causal=causal, pad_mode=pad_mode),
- ]
- mult *= 2
-
- if lstm:
- model += [StreamableLSTM(mult * n_filters, num_layers=lstm)]
-
- model += [
- act(**activation_params),
- StreamableConv1d(mult * n_filters, dimension, last_kernel_size,
- norm='none' if self.disable_norm_outer_blocks == self.n_blocks else norm,
- norm_kwargs=norm_params, causal=causal, pad_mode=pad_mode)
- ]
-
- self.model = nn.Sequential(*model)
-
- def forward(self, x):
- return self.model(x)
-
-
-class SEANetDecoder(nn.Module):
- """SEANet decoder.
-
- Args:
- channels (int): Audio channels.
- dimension (int): Intermediate representation dimension.
- n_filters (int): Base width for the model.
- n_residual_layers (int): nb of residual layers.
- ratios (Sequence[int]): kernel size and stride ratios.
- activation (str): Activation function.
- activation_params (dict): Parameters to provide to the activation function.
- final_activation (str): Final activation function after all convolutions.
- final_activation_params (dict): Parameters to provide to the activation function.
- norm (str): Normalization method.
- norm_params (dict): Parameters to provide to the underlying normalization used along with the convolution.
- kernel_size (int): Kernel size for the initial convolution.
- last_kernel_size (int): Kernel size for the initial convolution.
- residual_kernel_size (int): Kernel size for the residual layers.
- dilation_base (int): How much to increase the dilation with each layer.
- causal (bool): Whether to use fully causal convolution.
- pad_mode (str): Padding mode for the convolutions.
- true_skip (bool): Whether to use true skip connection or a simple.
- (streamable) convolution as the skip connection in the residual network blocks.
- compress (int): Reduced dimensionality in residual branches (from Demucs v3).
- lstm (int): Number of LSTM layers at the end of the encoder.
- disable_norm_outer_blocks (int): Number of blocks for which we don't apply norm.
- For the decoder, it corresponds to the N last blocks.
- trim_right_ratio (float): Ratio for trimming at the right of the transposed convolution under the causal setup.
- If equal to 1.0, it means that all the trimming is done at the right.
- """
- def __init__(self, channels: int = 1, dimension: int = 128, n_filters: int = 32, n_residual_layers: int = 3,
- ratios: tp.List[int] = [8, 5, 4, 2], activation: str = 'ELU', activation_params: dict = {'alpha': 1.0},
- final_activation: tp.Optional[str] = None, final_activation_params: tp.Optional[dict] = None,
- norm: str = 'none', norm_params: tp.Dict[str, tp.Any] = {}, kernel_size: int = 7,
- last_kernel_size: int = 7, residual_kernel_size: int = 3, dilation_base: int = 2, causal: bool = False,
- pad_mode: str = 'reflect', true_skip: bool = True, compress: int = 2, lstm: int = 0,
- disable_norm_outer_blocks: int = 0, trim_right_ratio: float = 1.0):
- super().__init__()
- self.dimension = dimension
- self.channels = channels
- self.n_filters = n_filters
- self.ratios = ratios
- del ratios
- self.n_residual_layers = n_residual_layers
- self.hop_length = np.prod(self.ratios)
- self.n_blocks = len(self.ratios) + 2 # first and last conv + residual blocks
- self.disable_norm_outer_blocks = disable_norm_outer_blocks
- assert self.disable_norm_outer_blocks >= 0 and self.disable_norm_outer_blocks <= self.n_blocks, \
- "Number of blocks for which to disable norm is invalid." \
- "It should be lower or equal to the actual number of blocks in the network and greater or equal to 0."
-
- act = getattr(nn, activation)
- mult = int(2 ** len(self.ratios))
- model: tp.List[nn.Module] = [
- StreamableConv1d(dimension, mult * n_filters, kernel_size,
- norm='none' if self.disable_norm_outer_blocks == self.n_blocks else norm,
- norm_kwargs=norm_params, causal=causal, pad_mode=pad_mode)
- ]
-
- if lstm:
- model += [StreamableLSTM(mult * n_filters, num_layers=lstm)]
-
- # Upsample to raw audio scale
- for i, ratio in enumerate(self.ratios):
- block_norm = 'none' if self.disable_norm_outer_blocks >= self.n_blocks - (i + 1) else norm
- # Add upsampling layers
- model += [
- act(**activation_params),
- StreamableConvTranspose1d(mult * n_filters, mult * n_filters // 2,
- kernel_size=ratio * 2, stride=ratio,
- norm=block_norm, norm_kwargs=norm_params,
- causal=causal, trim_right_ratio=trim_right_ratio),
- ]
- # Add residual layers
- for j in range(n_residual_layers):
- model += [
- SEANetResnetBlock(mult * n_filters // 2, kernel_sizes=[residual_kernel_size, 1],
- dilations=[dilation_base ** j, 1],
- activation=activation, activation_params=activation_params,
- norm=block_norm, norm_params=norm_params, causal=causal,
- pad_mode=pad_mode, compress=compress, true_skip=true_skip)]
-
- mult //= 2
-
- # Add final layers
- model += [
- act(**activation_params),
- StreamableConv1d(n_filters, channels, last_kernel_size,
- norm='none' if self.disable_norm_outer_blocks >= 1 else norm,
- norm_kwargs=norm_params, causal=causal, pad_mode=pad_mode)
- ]
- # Add optional final activation to decoder (eg. tanh)
- if final_activation is not None:
- final_act = getattr(nn, final_activation)
- final_activation_params = final_activation_params or {}
- model += [
- final_act(**final_activation_params)
- ]
- self.model = nn.Sequential(*model)
-
- def forward(self, z):
- y = self.model(z)
- return y
diff --git a/spaces/Hallucinate/demo/ldm/modules/x_transformer.py b/spaces/Hallucinate/demo/ldm/modules/x_transformer.py
deleted file mode 100644
index 5fc15bf9cfe0111a910e7de33d04ffdec3877576..0000000000000000000000000000000000000000
--- a/spaces/Hallucinate/demo/ldm/modules/x_transformer.py
+++ /dev/null
@@ -1,641 +0,0 @@
-"""shout-out to https://github.com/lucidrains/x-transformers/tree/main/x_transformers"""
-import torch
-from torch import nn, einsum
-import torch.nn.functional as F
-from functools import partial
-from inspect import isfunction
-from collections import namedtuple
-from einops import rearrange, repeat, reduce
-
-# constants
-
-DEFAULT_DIM_HEAD = 64
-
-Intermediates = namedtuple('Intermediates', [
- 'pre_softmax_attn',
- 'post_softmax_attn'
-])
-
-LayerIntermediates = namedtuple('Intermediates', [
- 'hiddens',
- 'attn_intermediates'
-])
-
-
-class AbsolutePositionalEmbedding(nn.Module):
- def __init__(self, dim, max_seq_len):
- super().__init__()
- self.emb = nn.Embedding(max_seq_len, dim)
- self.init_()
-
- def init_(self):
- nn.init.normal_(self.emb.weight, std=0.02)
-
- def forward(self, x):
- n = torch.arange(x.shape[1], device=x.device)
- return self.emb(n)[None, :, :]
-
-
-class FixedPositionalEmbedding(nn.Module):
- def __init__(self, dim):
- super().__init__()
- inv_freq = 1. / (10000 ** (torch.arange(0, dim, 2).float() / dim))
- self.register_buffer('inv_freq', inv_freq)
-
- def forward(self, x, seq_dim=1, offset=0):
- t = torch.arange(x.shape[seq_dim], device=x.device).type_as(self.inv_freq) + offset
- sinusoid_inp = torch.einsum('i , j -> i j', t, self.inv_freq)
- emb = torch.cat((sinusoid_inp.sin(), sinusoid_inp.cos()), dim=-1)
- return emb[None, :, :]
-
-
-# helpers
-
-def exists(val):
- return val is not None
-
-
-def default(val, d):
- if exists(val):
- return val
- return d() if isfunction(d) else d
-
-
-def always(val):
- def inner(*args, **kwargs):
- return val
- return inner
-
-
-def not_equals(val):
- def inner(x):
- return x != val
- return inner
-
-
-def equals(val):
- def inner(x):
- return x == val
- return inner
-
-
-def max_neg_value(tensor):
- return -torch.finfo(tensor.dtype).max
-
-
-# keyword argument helpers
-
-def pick_and_pop(keys, d):
- values = list(map(lambda key: d.pop(key), keys))
- return dict(zip(keys, values))
-
-
-def group_dict_by_key(cond, d):
- return_val = [dict(), dict()]
- for key in d.keys():
- match = bool(cond(key))
- ind = int(not match)
- return_val[ind][key] = d[key]
- return (*return_val,)
-
-
-def string_begins_with(prefix, str):
- return str.startswith(prefix)
-
-
-def group_by_key_prefix(prefix, d):
- return group_dict_by_key(partial(string_begins_with, prefix), d)
-
-
-def groupby_prefix_and_trim(prefix, d):
- kwargs_with_prefix, kwargs = group_dict_by_key(partial(string_begins_with, prefix), d)
- kwargs_without_prefix = dict(map(lambda x: (x[0][len(prefix):], x[1]), tuple(kwargs_with_prefix.items())))
- return kwargs_without_prefix, kwargs
-
-
-# classes
-class Scale(nn.Module):
- def __init__(self, value, fn):
- super().__init__()
- self.value = value
- self.fn = fn
-
- def forward(self, x, **kwargs):
- x, *rest = self.fn(x, **kwargs)
- return (x * self.value, *rest)
-
-
-class Rezero(nn.Module):
- def __init__(self, fn):
- super().__init__()
- self.fn = fn
- self.g = nn.Parameter(torch.zeros(1))
-
- def forward(self, x, **kwargs):
- x, *rest = self.fn(x, **kwargs)
- return (x * self.g, *rest)
-
-
-class ScaleNorm(nn.Module):
- def __init__(self, dim, eps=1e-5):
- super().__init__()
- self.scale = dim ** -0.5
- self.eps = eps
- self.g = nn.Parameter(torch.ones(1))
-
- def forward(self, x):
- norm = torch.norm(x, dim=-1, keepdim=True) * self.scale
- return x / norm.clamp(min=self.eps) * self.g
-
-
-class RMSNorm(nn.Module):
- def __init__(self, dim, eps=1e-8):
- super().__init__()
- self.scale = dim ** -0.5
- self.eps = eps
- self.g = nn.Parameter(torch.ones(dim))
-
- def forward(self, x):
- norm = torch.norm(x, dim=-1, keepdim=True) * self.scale
- return x / norm.clamp(min=self.eps) * self.g
-
-
-class Residual(nn.Module):
- def forward(self, x, residual):
- return x + residual
-
-
-class GRUGating(nn.Module):
- def __init__(self, dim):
- super().__init__()
- self.gru = nn.GRUCell(dim, dim)
-
- def forward(self, x, residual):
- gated_output = self.gru(
- rearrange(x, 'b n d -> (b n) d'),
- rearrange(residual, 'b n d -> (b n) d')
- )
-
- return gated_output.reshape_as(x)
-
-
-# feedforward
-
-class GEGLU(nn.Module):
- def __init__(self, dim_in, dim_out):
- super().__init__()
- self.proj = nn.Linear(dim_in, dim_out * 2)
-
- def forward(self, x):
- x, gate = self.proj(x).chunk(2, dim=-1)
- return x * F.gelu(gate)
-
-
-class FeedForward(nn.Module):
- def __init__(self, dim, dim_out=None, mult=4, glu=False, dropout=0.):
- super().__init__()
- inner_dim = int(dim * mult)
- dim_out = default(dim_out, dim)
- project_in = nn.Sequential(
- nn.Linear(dim, inner_dim),
- nn.GELU()
- ) if not glu else GEGLU(dim, inner_dim)
-
- self.net = nn.Sequential(
- project_in,
- nn.Dropout(dropout),
- nn.Linear(inner_dim, dim_out)
- )
-
- def forward(self, x):
- return self.net(x)
-
-
-# attention.
-class Attention(nn.Module):
- def __init__(
- self,
- dim,
- dim_head=DEFAULT_DIM_HEAD,
- heads=8,
- causal=False,
- mask=None,
- talking_heads=False,
- sparse_topk=None,
- use_entmax15=False,
- num_mem_kv=0,
- dropout=0.,
- on_attn=False
- ):
- super().__init__()
- if use_entmax15:
- raise NotImplementedError("Check out entmax activation instead of softmax activation!")
- self.scale = dim_head ** -0.5
- self.heads = heads
- self.causal = causal
- self.mask = mask
-
- inner_dim = dim_head * heads
-
- self.to_q = nn.Linear(dim, inner_dim, bias=False)
- self.to_k = nn.Linear(dim, inner_dim, bias=False)
- self.to_v = nn.Linear(dim, inner_dim, bias=False)
- self.dropout = nn.Dropout(dropout)
-
- # talking heads
- self.talking_heads = talking_heads
- if talking_heads:
- self.pre_softmax_proj = nn.Parameter(torch.randn(heads, heads))
- self.post_softmax_proj = nn.Parameter(torch.randn(heads, heads))
-
- # explicit topk sparse attention
- self.sparse_topk = sparse_topk
-
- # entmax
- #self.attn_fn = entmax15 if use_entmax15 else F.softmax
- self.attn_fn = F.softmax
-
- # add memory key / values
- self.num_mem_kv = num_mem_kv
- if num_mem_kv > 0:
- self.mem_k = nn.Parameter(torch.randn(heads, num_mem_kv, dim_head))
- self.mem_v = nn.Parameter(torch.randn(heads, num_mem_kv, dim_head))
-
- # attention on attention
- self.attn_on_attn = on_attn
- self.to_out = nn.Sequential(nn.Linear(inner_dim, dim * 2), nn.GLU()) if on_attn else nn.Linear(inner_dim, dim)
-
- def forward(
- self,
- x,
- context=None,
- mask=None,
- context_mask=None,
- rel_pos=None,
- sinusoidal_emb=None,
- prev_attn=None,
- mem=None
- ):
- b, n, _, h, talking_heads, device = *x.shape, self.heads, self.talking_heads, x.device
- kv_input = default(context, x)
-
- q_input = x
- k_input = kv_input
- v_input = kv_input
-
- if exists(mem):
- k_input = torch.cat((mem, k_input), dim=-2)
- v_input = torch.cat((mem, v_input), dim=-2)
-
- if exists(sinusoidal_emb):
- # in shortformer, the query would start at a position offset depending on the past cached memory
- offset = k_input.shape[-2] - q_input.shape[-2]
- q_input = q_input + sinusoidal_emb(q_input, offset=offset)
- k_input = k_input + sinusoidal_emb(k_input)
-
- q = self.to_q(q_input)
- k = self.to_k(k_input)
- v = self.to_v(v_input)
-
- q, k, v = map(lambda t: rearrange(t, 'b n (h d) -> b h n d', h=h), (q, k, v))
-
- input_mask = None
- if any(map(exists, (mask, context_mask))):
- q_mask = default(mask, lambda: torch.ones((b, n), device=device).bool())
- k_mask = q_mask if not exists(context) else context_mask
- k_mask = default(k_mask, lambda: torch.ones((b, k.shape[-2]), device=device).bool())
- q_mask = rearrange(q_mask, 'b i -> b () i ()')
- k_mask = rearrange(k_mask, 'b j -> b () () j')
- input_mask = q_mask * k_mask
-
- if self.num_mem_kv > 0:
- mem_k, mem_v = map(lambda t: repeat(t, 'h n d -> b h n d', b=b), (self.mem_k, self.mem_v))
- k = torch.cat((mem_k, k), dim=-2)
- v = torch.cat((mem_v, v), dim=-2)
- if exists(input_mask):
- input_mask = F.pad(input_mask, (self.num_mem_kv, 0), value=True)
-
- dots = einsum('b h i d, b h j d -> b h i j', q, k) * self.scale
- mask_value = max_neg_value(dots)
-
- if exists(prev_attn):
- dots = dots + prev_attn
-
- pre_softmax_attn = dots
-
- if talking_heads:
- dots = einsum('b h i j, h k -> b k i j', dots, self.pre_softmax_proj).contiguous()
-
- if exists(rel_pos):
- dots = rel_pos(dots)
-
- if exists(input_mask):
- dots.masked_fill_(~input_mask, mask_value)
- del input_mask
-
- if self.causal:
- i, j = dots.shape[-2:]
- r = torch.arange(i, device=device)
- mask = rearrange(r, 'i -> () () i ()') < rearrange(r, 'j -> () () () j')
- mask = F.pad(mask, (j - i, 0), value=False)
- dots.masked_fill_(mask, mask_value)
- del mask
-
- if exists(self.sparse_topk) and self.sparse_topk < dots.shape[-1]:
- top, _ = dots.topk(self.sparse_topk, dim=-1)
- vk = top[..., -1].unsqueeze(-1).expand_as(dots)
- mask = dots < vk
- dots.masked_fill_(mask, mask_value)
- del mask
-
- attn = self.attn_fn(dots, dim=-1)
- post_softmax_attn = attn
-
- attn = self.dropout(attn)
-
- if talking_heads:
- attn = einsum('b h i j, h k -> b k i j', attn, self.post_softmax_proj).contiguous()
-
- out = einsum('b h i j, b h j d -> b h i d', attn, v)
- out = rearrange(out, 'b h n d -> b n (h d)')
-
- intermediates = Intermediates(
- pre_softmax_attn=pre_softmax_attn,
- post_softmax_attn=post_softmax_attn
- )
-
- return self.to_out(out), intermediates
-
-
-class AttentionLayers(nn.Module):
- def __init__(
- self,
- dim,
- depth,
- heads=8,
- causal=False,
- cross_attend=False,
- only_cross=False,
- use_scalenorm=False,
- use_rmsnorm=False,
- use_rezero=False,
- rel_pos_num_buckets=32,
- rel_pos_max_distance=128,
- position_infused_attn=False,
- custom_layers=None,
- sandwich_coef=None,
- par_ratio=None,
- residual_attn=False,
- cross_residual_attn=False,
- macaron=False,
- pre_norm=True,
- gate_residual=False,
- **kwargs
- ):
- super().__init__()
- ff_kwargs, kwargs = groupby_prefix_and_trim('ff_', kwargs)
- attn_kwargs, _ = groupby_prefix_and_trim('attn_', kwargs)
-
- dim_head = attn_kwargs.get('dim_head', DEFAULT_DIM_HEAD)
-
- self.dim = dim
- self.depth = depth
- self.layers = nn.ModuleList([])
-
- self.has_pos_emb = position_infused_attn
- self.pia_pos_emb = FixedPositionalEmbedding(dim) if position_infused_attn else None
- self.rotary_pos_emb = always(None)
-
- assert rel_pos_num_buckets <= rel_pos_max_distance, 'number of relative position buckets must be less than the relative position max distance'
- self.rel_pos = None
-
- self.pre_norm = pre_norm
-
- self.residual_attn = residual_attn
- self.cross_residual_attn = cross_residual_attn
-
- norm_class = ScaleNorm if use_scalenorm else nn.LayerNorm
- norm_class = RMSNorm if use_rmsnorm else norm_class
- norm_fn = partial(norm_class, dim)
-
- norm_fn = nn.Identity if use_rezero else norm_fn
- branch_fn = Rezero if use_rezero else None
-
- if cross_attend and not only_cross:
- default_block = ('a', 'c', 'f')
- elif cross_attend and only_cross:
- default_block = ('c', 'f')
- else:
- default_block = ('a', 'f')
-
- if macaron:
- default_block = ('f',) + default_block
-
- if exists(custom_layers):
- layer_types = custom_layers
- elif exists(par_ratio):
- par_depth = depth * len(default_block)
- assert 1 < par_ratio <= par_depth, 'par ratio out of range'
- default_block = tuple(filter(not_equals('f'), default_block))
- par_attn = par_depth // par_ratio
- depth_cut = par_depth * 2 // 3 # 2 / 3 attention layer cutoff suggested by PAR paper
- par_width = (depth_cut + depth_cut // par_attn) // par_attn
- assert len(default_block) <= par_width, 'default block is too large for par_ratio'
- par_block = default_block + ('f',) * (par_width - len(default_block))
- par_head = par_block * par_attn
- layer_types = par_head + ('f',) * (par_depth - len(par_head))
- elif exists(sandwich_coef):
- assert sandwich_coef > 0 and sandwich_coef <= depth, 'sandwich coefficient should be less than the depth'
- layer_types = ('a',) * sandwich_coef + default_block * (depth - sandwich_coef) + ('f',) * sandwich_coef
- else:
- layer_types = default_block * depth
-
- self.layer_types = layer_types
- self.num_attn_layers = len(list(filter(equals('a'), layer_types)))
-
- for layer_type in self.layer_types:
- if layer_type == 'a':
- layer = Attention(dim, heads=heads, causal=causal, **attn_kwargs)
- elif layer_type == 'c':
- layer = Attention(dim, heads=heads, **attn_kwargs)
- elif layer_type == 'f':
- layer = FeedForward(dim, **ff_kwargs)
- layer = layer if not macaron else Scale(0.5, layer)
- else:
- raise Exception(f'invalid layer type {layer_type}')
-
- if isinstance(layer, Attention) and exists(branch_fn):
- layer = branch_fn(layer)
-
- if gate_residual:
- residual_fn = GRUGating(dim)
- else:
- residual_fn = Residual()
-
- self.layers.append(nn.ModuleList([
- norm_fn(),
- layer,
- residual_fn
- ]))
-
- def forward(
- self,
- x,
- context=None,
- mask=None,
- context_mask=None,
- mems=None,
- return_hiddens=False
- ):
- hiddens = []
- intermediates = []
- prev_attn = None
- prev_cross_attn = None
-
- mems = mems.copy() if exists(mems) else [None] * self.num_attn_layers
-
- for ind, (layer_type, (norm, block, residual_fn)) in enumerate(zip(self.layer_types, self.layers)):
- is_last = ind == (len(self.layers) - 1)
-
- if layer_type == 'a':
- hiddens.append(x)
- layer_mem = mems.pop(0)
-
- residual = x
-
- if self.pre_norm:
- x = norm(x)
-
- if layer_type == 'a':
- out, inter = block(x, mask=mask, sinusoidal_emb=self.pia_pos_emb, rel_pos=self.rel_pos,
- prev_attn=prev_attn, mem=layer_mem)
- elif layer_type == 'c':
- out, inter = block(x, context=context, mask=mask, context_mask=context_mask, prev_attn=prev_cross_attn)
- elif layer_type == 'f':
- out = block(x)
-
- x = residual_fn(out, residual)
-
- if layer_type in ('a', 'c'):
- intermediates.append(inter)
-
- if layer_type == 'a' and self.residual_attn:
- prev_attn = inter.pre_softmax_attn
- elif layer_type == 'c' and self.cross_residual_attn:
- prev_cross_attn = inter.pre_softmax_attn
-
- if not self.pre_norm and not is_last:
- x = norm(x)
-
- if return_hiddens:
- intermediates = LayerIntermediates(
- hiddens=hiddens,
- attn_intermediates=intermediates
- )
-
- return x, intermediates
-
- return x
-
-
-class Encoder(AttentionLayers):
- def __init__(self, **kwargs):
- assert 'causal' not in kwargs, 'cannot set causality on encoder'
- super().__init__(causal=False, **kwargs)
-
-
-
-class TransformerWrapper(nn.Module):
- def __init__(
- self,
- *,
- num_tokens,
- max_seq_len,
- attn_layers,
- emb_dim=None,
- max_mem_len=0.,
- emb_dropout=0.,
- num_memory_tokens=None,
- tie_embedding=False,
- use_pos_emb=True
- ):
- super().__init__()
- assert isinstance(attn_layers, AttentionLayers), 'attention layers must be one of Encoder or Decoder'
-
- dim = attn_layers.dim
- emb_dim = default(emb_dim, dim)
-
- self.max_seq_len = max_seq_len
- self.max_mem_len = max_mem_len
- self.num_tokens = num_tokens
-
- self.token_emb = nn.Embedding(num_tokens, emb_dim)
- self.pos_emb = AbsolutePositionalEmbedding(emb_dim, max_seq_len) if (
- use_pos_emb and not attn_layers.has_pos_emb) else always(0)
- self.emb_dropout = nn.Dropout(emb_dropout)
-
- self.project_emb = nn.Linear(emb_dim, dim) if emb_dim != dim else nn.Identity()
- self.attn_layers = attn_layers
- self.norm = nn.LayerNorm(dim)
-
- self.init_()
-
- self.to_logits = nn.Linear(dim, num_tokens) if not tie_embedding else lambda t: t @ self.token_emb.weight.t()
-
- # memory tokens (like [cls]) from Memory Transformers paper
- num_memory_tokens = default(num_memory_tokens, 0)
- self.num_memory_tokens = num_memory_tokens
- if num_memory_tokens > 0:
- self.memory_tokens = nn.Parameter(torch.randn(num_memory_tokens, dim))
-
- # let funnel encoder know number of memory tokens, if specified
- if hasattr(attn_layers, 'num_memory_tokens'):
- attn_layers.num_memory_tokens = num_memory_tokens
-
- def init_(self):
- nn.init.normal_(self.token_emb.weight, std=0.02)
-
- def forward(
- self,
- x,
- return_embeddings=False,
- mask=None,
- return_mems=False,
- return_attn=False,
- mems=None,
- **kwargs
- ):
- b, n, device, num_mem = *x.shape, x.device, self.num_memory_tokens
- x = self.token_emb(x)
- x += self.pos_emb(x)
- x = self.emb_dropout(x)
-
- x = self.project_emb(x)
-
- if num_mem > 0:
- mem = repeat(self.memory_tokens, 'n d -> b n d', b=b)
- x = torch.cat((mem, x), dim=1)
-
- # auto-handle masking after appending memory tokens
- if exists(mask):
- mask = F.pad(mask, (num_mem, 0), value=True)
-
- x, intermediates = self.attn_layers(x, mask=mask, mems=mems, return_hiddens=True, **kwargs)
- x = self.norm(x)
-
- mem, x = x[:, :num_mem], x[:, num_mem:]
-
- out = self.to_logits(x) if not return_embeddings else x
-
- if return_mems:
- hiddens = intermediates.hiddens
- new_mems = list(map(lambda pair: torch.cat(pair, dim=-2), zip(mems, hiddens))) if exists(mems) else hiddens
- new_mems = list(map(lambda t: t[..., -self.max_mem_len:, :].detach(), new_mems))
- return out, new_mems
-
- if return_attn:
- attn_maps = list(map(lambda t: t.post_softmax_attn, intermediates.attn_intermediates))
- return out, attn_maps
-
- return out
-
diff --git a/spaces/Hamda/AraJARIR/app.py b/spaces/Hamda/AraJARIR/app.py
deleted file mode 100644
index 885a8d0fa2327554876d2f743552f4f8044fffd3..0000000000000000000000000000000000000000
--- a/spaces/Hamda/AraJARIR/app.py
+++ /dev/null
@@ -1,129 +0,0 @@
-import streamlit as st
-import transformers
-from transformers import pipeline
-from transformers import AutoTokenizer, AutoModelForMaskedLM
-import pandas as pd
-import string
-from time import time
-from PIL import Image
-
-
-image = Image.open('./Logo_APP.jpg')
-n_image = image.resize((150, 150))
-st.image(n_image)
-
-st.title("المساعدة اللغوية في التنبؤ بالمتلازمات والمتصاحبات وتصحيحها")
-default_value = "أستاذ التعليم"
-
-# sent is the variable holding the user's input
-sent = st.text_area('المدخل',default_value)
-
-tokenizer = AutoTokenizer.from_pretrained("moussaKam/AraBART", max_length=128, padding=True, pad_to_max_length = True, truncation=True)
-
-model = AutoModelForMaskedLM.from_pretrained("Hamda/test-1-finetuned-AraBART")
-pipe = pipeline("fill-mask", tokenizer=tokenizer, model=model, top_k=10)
-
-def next_word(text, pipe):
- res_dict= {
- 'الكلمة المقترحة':[],
- 'العلامة':[],
- }
- for e in pipe(text):
- if all(c not in list(string.punctuation) for c in e['token_str']):
- res_dict['الكلمة المقترحة'].append(e['token_str'])
- res_dict['العلامة'].append(e['score'])
- return res_dict
-
-if (st.button('بحث', disabled=False)):
- text_st = sent+ ' '
- dict_next_words = next_word(text_st, pipe)
- df = pd.DataFrame.from_dict(dict_next_words)
- st.dataframe(df)
-#using Graph
-
-if (st.checkbox('الاستعانة بالرسم البياني المعرفي الاحتمالي', value=False)):
- a = time()
- VocMap = './voc.csv'
- ScoreMap = './BM25.csv'
-
- #@st.cache
- def reading_df(path1, path2):
- df_voc = pd.read_csv(path1, delimiter='\t')
- df_graph = pd.read_csv(path2, delimiter='\t')
- df_graph.set_index(['ID1','ID2'], inplace=True)
- df_gr = pd.read_csv(ScoreMap, delimiter='\t')
- df_gr.set_index(['ID1'], inplace=True)
- return df_voc, df_graph, df_gr
-
- df3, df_g, df_in = reading_df(VocMap, ScoreMap)
-
-
- def Query2id(voc, query):
- res= []
- for word in query.split():
- try:
- res.append(voc.index[voc['word'] == word].values[0])
- except (IndexError, KeyError) as e:
- st.write('Token not found')
- continue
- return res
-
- id_list = Query2id(df3, sent)
-
- def setQueriesVoc(df, id_list):
- res = []
- for e in id_list:
- try:
- res.extend(list(df.loc[e]['ID2'].values))
- except (KeyError, AttributeError) as f:
- st.write('Token not found')
- continue
- return list(set(res))
-
- L = setQueriesVoc(df_in, id_list)
- @st.cache
- def compute_score(L_terms, id_l):
- tmt = {}
- for nc in L_terms:
- score = 0.0
- temp = []
- for ni in id_l:
- try:
- score = score + df_g.loc[(ni, nc),'score']
- except KeyError:
- continue
- key = df3.loc[nc].values[0]
- tmt[key] = score
- return tmt
- tmt = compute_score(L, id_list)
- exp_terms = []
- t_li = tmt.values()
- tmexp = sorted(tmt.items(), key=lambda x: x[1], reverse=True)
- i = 0
- dict_res = {'الكلمة المقترحة':[],
- 'العلامة':[]}
- for key, value in tmexp:
- new_score=((value-min(t_li))/(max(t_li)-min(t_li)))-0.0001
- dict_res['العلامة'].append(str(new_score)[:6])
- dict_res['الكلمة المقترحة'].append(key)
- i+=1
- if (i==10):
- break
- res_df = pd.DataFrame.from_dict(dict_res)
- res_df.index += 1
- b = time()
- exec_time = (b-a)
- text_st = sent+ ' '
- dict_next_words = next_word(text_st, pipe)
- df = pd.DataFrame.from_dict(dict_next_words)
- df.index += 1
- str_time = str(exec_time)[:3]
-
- st.markdown("""---""")
- st.header("الكلمات المقترحة باستعمال النموذج اللغوي")
- st.dataframe(df)
- st.markdown("""---""")
- st.header("الكلمات المقترحة باستعمال الرسم البياني")
- st.dataframe(res_df)
- st.markdown("""---""")
- st.write(f'{str_time} s :الوقت المستغرق باستعمال الرسم البياني')
\ No newline at end of file
diff --git a/spaces/HarryLee/eCommerceImageCaptioning/app.py b/spaces/HarryLee/eCommerceImageCaptioning/app.py
deleted file mode 100644
index 0c0a564561fb481f382a40197c42d6edc9b6ca5a..0000000000000000000000000000000000000000
--- a/spaces/HarryLee/eCommerceImageCaptioning/app.py
+++ /dev/null
@@ -1,125 +0,0 @@
-# author : LiHE
-import os
-
-os.system('cd fairseq;'
- 'pip install --use-feature=in-tree-build ./; cd ..')
-os.system('ls -l')
-
-import torch
-import numpy as np
-from fairseq import utils, tasks
-from fairseq import checkpoint_utils
-from utils.eval_utils import eval_step
-from tasks.mm_tasks.caption import CaptionTask
-from models.ofa import OFAModel
-from PIL import Image
-from torchvision import transforms
-import gradio as gr
-
-# Register caption task
-tasks.register_task('caption', CaptionTask)
-# turn on cuda if GPU is available
-use_cuda = torch.cuda.is_available()
-# use fp16 only when GPU is available
-use_fp16 = False
-
-os.system('wget https://ofa-silicon.oss-us-west-1.aliyuncs.com/checkpoints/caption_large_best_clean.pt; '
- 'mkdir -p checkpoints; mv caption_large_best_clean.pt checkpoints/caption.pt')
-
-# Load pretrained ckpt & config
-overrides = {"bpe_dir": "utils/BPE", "eval_cider": False, "beam": 5,
- "max_len_b": 16, "no_repeat_ngram_size": 3, "seed": 7}
-models, cfg, task = checkpoint_utils.load_model_ensemble_and_task(
- utils.split_paths('checkpoints/caption.pt'),
- arg_overrides=overrides
-)
-
-# Move models to GPU
-for model in models:
- model.eval()
- if use_fp16:
- model.half()
- if use_cuda and not cfg.distributed_training.pipeline_model_parallel:
- model.cuda()
- model.prepare_for_inference_(cfg)
-
-# Initialize generator
-generator = task.build_generator(models, cfg.generation)
-
-mean = [0.5, 0.5, 0.5]
-std = [0.5, 0.5, 0.5]
-
-patch_resize_transform = transforms.Compose([
- lambda image: image.convert("RGB"),
- transforms.Resize((cfg.task.patch_image_size, cfg.task.patch_image_size), interpolation=Image.BICUBIC),
- transforms.ToTensor(),
- transforms.Normalize(mean=mean, std=std),
-])
-
-# Text preprocess
-bos_item = torch.LongTensor([task.src_dict.bos()])
-eos_item = torch.LongTensor([task.src_dict.eos()])
-pad_idx = task.src_dict.pad()
-
-
-def encode_text(text, length=None, append_bos=False, append_eos=False):
- s = task.tgt_dict.encode_line(
- line=task.bpe.encode(text),
- add_if_not_exist=False,
- append_eos=False
- ).long()
- if length is not None:
- s = s[:length]
- if append_bos:
- s = torch.cat([bos_item, s])
- if append_eos:
- s = torch.cat([s, eos_item])
- return s
-
-
-# Construct input for caption task
-def construct_sample(image: Image):
- patch_image = patch_resize_transform(image).unsqueeze(0)
- patch_mask = torch.tensor([True])
- src_text = encode_text(" what does the image describe?", append_bos=True, append_eos=True).unsqueeze(0)
- src_length = torch.LongTensor([s.ne(pad_idx).long().sum() for s in src_text])
- sample = {
- "id": np.array(['42']),
- "net_input": {
- "src_tokens": src_text,
- "src_lengths": src_length,
- "patch_images": patch_image,
- "patch_masks": patch_mask
- }
- }
- return sample
-
-
-# Function to turn FP32 to FP16
-def apply_half(t):
- if t.dtype is torch.float32:
- return t.to(dtype=torch.half)
- return t
-
-
-# Function for image captioning
-def image_caption(Image):
- sample = construct_sample(Image)
- sample = utils.move_to_cuda(sample) if use_cuda else sample
- sample = utils.apply_to_sample(apply_half, sample) if use_fp16 else sample
- with torch.no_grad():
- result, scores = eval_step(task, generator, models, sample)
- return result[0]['caption']
-
-
-title = "eRupt e-Commerce Image Captioning"
-description = "Online Demo for e-Commerce Image Captioning. Upload your own image or click any one of the examples, and click " \
- "\"Submit\" and then wait for the generated caption. "
-article = "LIHE Github " \
- "Repo
"
-examples = [['0001.jpg'], ['0002.jpg'], ['0003.jpg'], ['0004.jpg'], ['0005.jpg']]
-io = gr.Interface(fn=image_caption, inputs=gr.inputs.Image(type='pil'), outputs=gr.outputs.Textbox(label="Caption"),
- title=title, description=description, article=article, examples=examples,
- allow_flagging=False, allow_screenshot=False)
-#io.launch(cache_examples=True)
-io.launch()
diff --git a/spaces/HarryLee/eCommerceImageCaptioning/fairseq/fairseq/optim/bmuf.py b/spaces/HarryLee/eCommerceImageCaptioning/fairseq/fairseq/optim/bmuf.py
deleted file mode 100644
index d6d0e04e86eb894efe59e13a78843d01ca9e651d..0000000000000000000000000000000000000000
--- a/spaces/HarryLee/eCommerceImageCaptioning/fairseq/fairseq/optim/bmuf.py
+++ /dev/null
@@ -1,200 +0,0 @@
-# Copyright (c) Facebook, Inc. and its affiliates.
-#
-# This source code is licensed under the MIT license found in the
-# LICENSE file in the root directory of this source tree.
-
-from dataclasses import dataclass, field
-
-import torch
-import torch.distributed as dist
-from fairseq.dataclass.configs import FairseqBMUFConfig
-from fairseq.dataclass.utils import gen_parser_from_dataclass
-from fairseq.optim.fairseq_optimizer import FairseqOptimizer
-
-
-class FairseqBMUF(FairseqOptimizer):
- """
- Implements incremental block distributed data parallelism similar to
- https://ieeexplore.ieee.org/document/7472805
-
- Paper title: Scalable training of deep learning machines by incremental
- block training with intra-block parallel optimization and blockwise
- model-update filtering
- """
-
- def __init__(self, cfg: FairseqBMUFConfig, optimizer):
- super().__init__(cfg)
- self._optimizer = optimizer
- self._num_updates = 0
- self.sync_iter = cfg.global_sync_iter
- self.block_momentum = cfg.block_momentum
- self.block_lr = cfg.block_lr
- self._reset_local_data()
- self.warmup_iteration = cfg.warmup_iterations
- self.use_nbm = cfg.use_nbm
- self.initial_state = self._optimizer.state_dict()
- self.average_sync = self.cfg.average_sync
- self.world_size = self.cfg.distributed_world_size
-
- @staticmethod
- def add_args(parser):
- """Add optimizer-specific arguments to the parser."""
- gen_parser_from_dataclass(parser, FairseqBMUFConfig())
-
- @property
- def optimizer(self):
- return self._optimizer.optimizer
-
- @property
- def optimizer_config(self):
- return self._optimizer.optimizer_config
-
- def get_lr(self):
- return self._optimizer.get_lr()
-
- def set_lr(self, lr):
- self._optimizer.set_lr(lr)
-
- def state_dict(self):
- return self._optimizer.state_dict()
-
- def load_state_dict(self, state_dict, optimizer_overrides=None):
- self._optimizer.load_state_dict(state_dict, optimizer_overrides)
- self.initial_state = self._optimizer.state_dict()
-
- def multiply_grads(self, c):
- """Multiplies grads by a constant *c*."""
- self._optimizer.multiply_grads(c)
-
- def clip_grad_norm(self, max_norm, aggregate_norm_fn=None):
- """Clips gradient norm."""
- return self._optimizer.clip_grad_norm(max_norm, aggregate_norm_fn)
-
- def average_params(self):
- self._optimizer.average_params()
-
- def _block_sync(self):
- if self.world_size <= 1:
- return
- # Update the global model using local models from all GPUs
- # (Step-1) Calculate grad between previously synced model and
- # currrent local model
- if self.block_momentum != 0:
- self._calc_grad()
-
- # (Step-2) Average gradient from all GPUs
- self._avg_grad_from_all_gpus()
-
- # (Step-3) Calculate global momentum and update the global model
- if self.block_momentum != 0:
- self._update_global_model()
-
- # (Step-4) Average local optimizer params
- if self.average_sync:
- self.average_params()
-
- def _is_warmup_end(self):
- # Check whether train iterations is equal to warmup iter
- if self.get_num_updates() == self.warmup_iteration:
- return True
- return False
-
- def _is_bmuf_iter(self):
- # Check whether train iterations is equal to bmuf sync iter
- if (self.get_num_updates() > self.warmup_iteration) and (
- self.get_num_updates() % self.sync_iter == 0
- ):
- return True
- return False
-
- def _warmup_sync(self, root_rank=0):
- if self.world_size <= 1:
- return
- # Broadcast the local model to all gpus
- for param in self.params:
- dist.broadcast(param.data, src=root_rank)
-
- # Update local optimizer state
- if self.average_sync:
- self._optimizer.average_params()
- else:
- self._optimizer.load_state_dict(self.initial_state)
-
- self._reset_local_data()
-
- def step(self, closure=None):
- """Performs a single optimization step."""
- self._optimizer.step(closure)
- self.set_num_updates(self.get_num_updates() + 1)
- if self._is_warmup_end():
- self._warmup_sync()
- elif self._is_bmuf_iter():
- self._block_sync()
-
- def zero_grad(self):
- """Clears the gradients of all optimized parameters."""
- self._optimizer.zero_grad()
-
- def get_num_updates(self):
- """Get the number of parameters updates."""
- return self._num_updates
-
- def set_num_updates(self, num_updates):
- """Set the number of parameters updates."""
- self._num_updates = num_updates
-
- @torch.no_grad()
- def _reset_local_data(self):
- # (Step-0) Initialize global momentum parameters and store global copy on each gpu
- self.global_params = [torch.zeros_like(p.data) for p in self.params]
- self.smoothed_grads = [p.data.new_zeros(p.data.size()) for p in self.params]
- self.grads = [p.data.new_zeros(p.data.size()) for p in self.params]
-
- # saving the global model locally for calculating gradient during bmuf sync
- for param, global_param in zip(self.params, self.global_params):
- global_param.copy_(param.data)
-
- @torch.no_grad()
- def _calc_grad(self):
- # global_params is basically the global copy from the previously finished
- # synchronisation. param.data is local parameter after block_sync_freq
- # for the local gpu. so grad is difference between previously synced
- # model and currrent local model.
- for index, (param, global_param) in enumerate(
- zip(self.params, self.global_params)
- ):
- self.grads[index] = global_param - param.data
-
- def _avg_grad_from_all_gpus(self):
- for index, param in enumerate(self.params):
- sync_para = param.data if self.block_momentum == 0 else self.grads[index]
- sync_para /= float(dist.get_world_size())
- dist.all_reduce(sync_para, op=dist.ReduceOp.SUM)
-
- @torch.no_grad()
- def _update_global_model(self):
- for index, (param, global_param, smoothed_grad, grad) in enumerate(
- zip(
- self.params,
- self.global_params,
- self.smoothed_grads,
- # all gpus would share the same value of smoothed_grad, since it is
- # always computed on synchronized gradients.
- self.grads,
- )
- ):
- # global_param is basically last syncrhornized parameter. though
- # smoothed_grad is local, all processes will have same value of
- # smoothed_grad and hence param is globally synchronized copy.
- # smoothed_grad(t) = BM * smoothed_grad(t-1) + BM_lr * grad(t)
- smoothed_grad = self.block_momentum * smoothed_grad + self.block_lr * grad
- param.data.copy_(global_param - smoothed_grad)
-
- # A Nesterov momentum here is to do a partial weight update before
- # calculating the gradient
- if self.use_nbm:
- param.data.copy_(param.data - self.block_momentum * smoothed_grad)
-
- # backup for the next synchronization.
- self.smoothed_grads[index] = smoothed_grad
- global_param.copy_(param.data)
diff --git a/spaces/HarryLee/eCommerceImageCaptioning/fairseq/scripts/convert_dictionary.lua b/spaces/HarryLee/eCommerceImageCaptioning/fairseq/scripts/convert_dictionary.lua
deleted file mode 100644
index 14ee8c997f642c8ff196617c2dcd0584037a60c4..0000000000000000000000000000000000000000
--- a/spaces/HarryLee/eCommerceImageCaptioning/fairseq/scripts/convert_dictionary.lua
+++ /dev/null
@@ -1,34 +0,0 @@
--- Copyright (c) Facebook, Inc. and its affiliates.
---
--- This source code is licensed under the MIT license found in the
--- LICENSE file in the root directory of this source tree.
---
--- Usage: convert_dictionary.lua
-require 'fairseq'
-require 'torch'
-require 'paths'
-
-if #arg < 1 then
- print('usage: convert_dictionary.lua ')
- os.exit(1)
-end
-if not paths.filep(arg[1]) then
- print('error: file does not exit: ' .. arg[1])
- os.exit(1)
-end
-
-dict = torch.load(arg[1])
-dst = paths.basename(arg[1]):gsub('.th7', '.txt')
-assert(dst:match('.txt$'))
-
-f = io.open(dst, 'w')
-for idx, symbol in ipairs(dict.index_to_symbol) do
- if idx > dict.cutoff then
- break
- end
- f:write(symbol)
- f:write(' ')
- f:write(dict.index_to_freq[idx])
- f:write('\n')
-end
-f:close()
diff --git a/spaces/Harshveer/Finetuned_Diffusion_Max/utils.py b/spaces/Harshveer/Finetuned_Diffusion_Max/utils.py
deleted file mode 100644
index ff1c065d186347ca51b47d010a697dbe1814695c..0000000000000000000000000000000000000000
--- a/spaces/Harshveer/Finetuned_Diffusion_Max/utils.py
+++ /dev/null
@@ -1,6 +0,0 @@
-def is_google_colab():
- try:
- import google.colab
- return True
- except:
- return False
\ No newline at end of file
diff --git a/spaces/Harveenchadha/Hindi_TTS/vakyansh_tts/tts_infer/num_to_word_on_sent.py b/spaces/Harveenchadha/Hindi_TTS/vakyansh_tts/tts_infer/num_to_word_on_sent.py
deleted file mode 100644
index ee9bd2de5f0b1a6d6b3c788d9c3934a7475d7307..0000000000000000000000000000000000000000
--- a/spaces/Harveenchadha/Hindi_TTS/vakyansh_tts/tts_infer/num_to_word_on_sent.py
+++ /dev/null
@@ -1,1314 +0,0 @@
-import re
-import string
-
-# ----------------------------- indic_num.py -----------------------------
-supported_lang = {"en", "hi", "gu", "mr", "bn", "te", "ta", "kn", "or", "pa"}
-# supported_lang = {'eng', 'hin', 'guj', 'mar', 'ben', 'tel', 'tam', 'kan', 'ori', 'pan'} # Three alphabet lang code
-
-all_num = {
- "en": ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
- "hi": ["०", "१", "२", "३", "४", "५", "६", "७", "८", "९"],
- "gu": ["૦", "૧", "૨", "૩", "૪", "૫", "૬", "૭", "૮", "૯"],
- "mr": ["०", "१", "२", "३", "४", "५", "६", "७", "८", "९"],
- "bn": ["০", "১", "২", "৩", "৪", "৫", "৬", "৭", "৮", "৯"],
- "te": ["౦", "౧", "౨", "౩", "౪", "౫", "౬", "౭", "౮", "౯"],
- "ta": ["0", "௧", "௨", "௩", "௪", "௫", "௬", "௭", "௮", "௯", "௰"],
- "kn": ["೦", "೧", "೨", "೩", "೪", "೫", "೬", "೭", "೮", "೯"],
- "or": ["୦", "୧", "୨", "୩", "୪", "୫", "୬", "୭", "୮", "୯"],
- "pa": ["੦", "੧", "੨", "੩", "੪", "੫", "੬", "੭", "੮", "੯"],
-}
-
-num_dict = dict()
-num_dict["en"] = {
- "0": "zero",
- "1": "one",
- "2": "two",
- "3": "three",
- "4": "four",
- "5": "five",
- "6": "six",
- "7": "seven",
- "8": "eight",
- "9": "nine",
- "10": "ten",
- "11": "eleven",
- "12": "twelve",
- "13": "thirteen",
- "14": "fourteen",
- "15": "fifteen",
- "16": "sixteen",
- "17": "seventeen",
- "18": "eighteen",
- "19": "nineteen",
- "20": "twenty",
- "21": "twenty-one",
- "22": "twenty-two",
- "23": "twenty-three",
- "24": "twenty-four",
- "25": "twenty-five",
- "26": "twenty-six",
- "27": "twenty-seven",
- "28": "twenty-eight",
- "29": "twenty-nine",
- "30": "thirty",
- "31": "thirty-one",
- "32": "thirty-two",
- "33": "thirty-three",
- "34": "thirty-four",
- "35": "thirty-five",
- "36": "thirty-six",
- "37": "thirty-seven",
- "38": "thirty-eight",
- "39": "thirty-nine",
- "40": "forty",
- "41": "forty-one",
- "42": "forty-two",
- "43": "forty-three",
- "44": "forty-four",
- "45": "forty-five",
- "46": "forty-six",
- "47": "forty-seven",
- "48": "forty-eight",
- "49": "forty-nine",
- "50": "fifty",
- "51": "fifty-one",
- "52": "fifty-two",
- "53": "fifty-three",
- "54": "fifty-four",
- "55": "fifty-five",
- "56": "fifty-six",
- "57": "fifty-seven",
- "58": "fifty-eight",
- "59": "fifty-nine",
- "60": "sixty",
- "61": "sixty-one",
- "62": "sixty-two",
- "63": "sixty-three",
- "64": "sixty-four",
- "65": "sixty-five",
- "66": "sixty-six",
- "67": "sixty-seven",
- "68": "sixty-eight",
- "69": "sixty-nine",
- "70": "seventy",
- "71": "seventy-one",
- "72": "seventy-two",
- "73": "seventy-three",
- "74": "seventy-four",
- "75": "seventy-five",
- "76": "seventy-six",
- "77": "seventy-seven",
- "78": "seventy-eight",
- "79": "seventy-nine",
- "80": "eighty",
- "81": "eighty-one",
- "82": "eighty-two",
- "83": "eighty-three",
- "84": "eighty-four",
- "85": "eighty-five",
- "86": "eighty-six",
- "87": "eighty-seven",
- "88": "eighty-eight",
- "89": "eighty-nine",
- "90": "ninety",
- "91": "ninety-one",
- "92": "ninety-two",
- "93": "ninety-three",
- "94": "ninety-four",
- "95": "ninety-five",
- "96": "ninety-six",
- "97": "ninety-seven",
- "98": "ninety-eight",
- "99": "ninety-nine",
- "100": "hundred",
- "1000": "thousand",
- "100000": "lakh",
- "10000000": "crore",
- "1000000000": "arab",
-} # English-India
-num_dict["hi"] = {
- "0": "शून्य",
- "1": "एक",
- "2": "दो",
- "3": "तीन",
- "4": "चार",
- "5": "पाँच",
- "6": "छः",
- "7": "सात",
- "8": "आठ",
- "9": "नौ",
- "10": "दस",
- "11": "ग्यारह",
- "12": "बारह",
- "13": "तेरह",
- "14": "चौदह",
- "15": "पंद्रह",
- "16": "सोलह",
- "17": "सत्रह",
- "18": "अट्ठारह",
- "19": "उन्नीस",
- "20": "बीस",
- "21": "इक्कीस",
- "22": "बाईस",
- "23": "तेईस",
- "24": "चौबिस",
- "25": "पच्चीस",
- "26": "छब्बीस",
- "27": "सत्ताईस",
- "28": "अट्ठाईस",
- "29": "उनतीस",
- "30": "तीस",
- "31": "इकतीस",
- "32": "बत्तीस",
- "33": "तैंतीस",
- "34": "चौंतीस",
- "35": "पैंतीस",
- "36": "छत्तीस",
- "37": "सैंतीस",
- "38": "अड़तीस",
- "39": "उनतालीस",
- "40": "चालीस",
- "41": "इकतालीस",
- "42": "बयालीस",
- "43": "तैंतालीस",
- "44": "चौंतालीस",
- "45": "पैंतालीस",
- "46": "छियालीस",
- "47": "सैंतालीस",
- "48": "अड़तालीस",
- "49": "उनचास",
- "50": "पचास",
- "51": "इक्यावन",
- "52": "बावन",
- "53": "तिरेपन",
- "54": "चौवन",
- "55": "पचपन",
- "56": "छप्पन",
- "57": "सत्तावन",
- "58": "अट्ठावन",
- "59": "उनसठ",
- "60": "साठ",
- "61": "इकसठ",
- "62": "बासठ",
- "63": "तिरेसठ",
- "64": "चौंसठ",
- "65": "पैंसठ",
- "66": "छयासठ",
- "67": "सरसठ",
- "68": "अड़सठ",
- "69": "उनहत्तर",
- "70": "सत्तर",
- "71": "इकहत्तर",
- "72": "बहत्तर",
- "73": "तिहत्तर",
- "74": "चौहत्तर",
- "75": "पचहत्तर",
- "76": "छिहत्तर",
- "77": "सतहत्तर",
- "78": "अठहत्तर",
- "79": "उन्यासी",
- "80": "अस्सी",
- "81": "इक्यासी",
- "82": "बयासी",
- "83": "तिरासी",
- "84": "चौरासी",
- "85": "पचासी",
- "86": "छियासी",
- "87": "सत्तासी",
- "88": "अठासी",
- "89": "नवासी",
- "90": "नब्बे",
- "91": "इक्यानवे",
- "92": "बानवे",
- "93": "तिरानवे",
- "94": "चौरानवे",
- "95": "पचानवे",
- "96": "छियानवे",
- "97": "सत्तानवे",
- "98": "अट्ठानवे",
- "99": "निन्यानवे",
- "100": "सौ",
- "1000": "हज़ार",
- "100000": "लाख",
- "10000000": "करोड़",
- "1000000000": "अरब",
-} # Hindi
-num_dict["gu"] = {
- "0": "શૂન્ય",
- "1": "એક",
- "2": "બે",
- "3": "ત્રણ",
- "4": "ચાર",
- "5": "પાંચ",
- "6": "છ",
- "7": "સાત",
- "8": "આઠ",
- "9": "નવ",
- "10": "દસ",
- "11": "અગિયાર",
- "12": "બાર",
- "13": "તેર",
- "14": "ચૌદ",
- "15": "પંદર",
- "16": "સોળ",
- "17": "સત્તર",
- "18": "અઢાર",
- "19": "ઓગણિસ",
- "20": "વીસ",
- "21": "એકવીસ",
- "22": "બાવીસ",
- "23": "તેવીસ",
- "24": "ચોવીસ",
- "25": "પચ્ચીસ",
- "26": "છવીસ",
- "27": "સત્તાવીસ",
- "28": "અઠ્ઠાવીસ",
- "29": "ઓગણત્રીસ",
- "30": "ત્રીસ",
- "31": "એકત્રીસ",
- "32": "બત્રીસ",
- "33": "તેત્રીસ",
- "34": "ચોત્રીસ",
- "35": "પાંત્રીસ",
- "36": "છત્રીસ",
- "37": "સડત્રીસ",
- "38": "અડત્રીસ",
- "39": "ઓગણચાલીસ",
- "40": "ચાલીસ",
- "41": "એકતાલીસ",
- "42": "બેતાલીસ",
- "43": "ત્રેતાલીસ",
- "44": "ચુંમાલીસ",
- "45": "પિસ્તાલીસ",
- "46": "છેતાલીસ",
- "47": "સુડતાલીસ",
- "48": "અડતાલીસ",
- "49": "ઓગણપચાસ",
- "50": "પચાસ",
- "51": "એકાવન",
- "52": "બાવન",
- "53": "ત્રેપન",
- "54": "ચોપન",
- "55": "પંચાવન",
- "56": "છપ્પન",
- "57": "સત્તાવન",
- "58": "અઠ્ઠાવન",
- "59": "ઓગણસાઠ",
- "60": "સાઈઠ",
- "61": "એકસઠ",
- "62": "બાસઠ",
- "63": "ત્રેસઠ",
- "64": "ચોસઠ",
- "65": "પાંસઠ",
- "66": "છાસઠ",
- "67": "સડસઠ",
- "68": "અડસઠ",
- "69": "અગણોસિત્તેર",
- "70": "સિત્તેર",
- "71": "એકોતેર",
- "72": "બોતેર",
- "73": "તોતેર",
- "74": "ચુમોતેર",
- "75": "પંચોતેર",
- "76": "છોતેર",
- "77": "સિત્યોતેર",
- "78": "ઇઠ્યોતેર",
- "79": "ઓગણાએંસી",
- "80": "એંસી",
- "81": "એક્યાસી",
- "82": "બ્યાસી",
- "83": "ત્યાસી",
- "84": "ચોર્યાસી",
- "85": "પંચાસી",
- "86": "છ્યાસી",
- "87": "સિત્યાસી",
- "88": "ઈઠ્યાસી",
- "89": "નેવ્યાસી",
- "90": "નેવું",
- "91": "એકાણું",
- "92": "બાણું",
- "93": "ત્રાણું",
- "94": "ચોરાણું",
- "95": "પંચાણું",
- "96": "છન્નું",
- "97": "સત્તાણું",
- "98": "અઠ્ઠાણું",
- "99": "નવ્વાણું",
- "100": "સો",
- "1000": "હજાર",
- "100000": "લાખ",
- "1000000": "દસ લાખ",
- "10000000": "કરોડ઼",
-} # Gujarati
-num_dict["mr"] = {
- "0": "शून्य",
- "1": "एक",
- "2": "दोन",
- "3": "तीन",
- "4": "चार",
- "5": "पाच",
- "6": "सहा",
- "7": "सात",
- "8": "आठ",
- "9": "नऊ",
- "10": "दहा",
- "11": "अकरा",
- "12": "बारा",
- "13": "तेरा",
- "14": "चौदा",
- "15": "पंधरा",
- "16": "सोळा",
- "17": "सतरा",
- "18": "अठरा",
- "19": "एकोणीस",
- "20": "वीस",
- "21": "एकवीस",
- "22": "बावीस",
- "23": "तेवीस",
- "24": "चोवीस",
- "25": "पंचवीस",
- "26": "सव्वीस",
- "27": "सत्तावीस",
- "28": "अठ्ठावीस",
- "29": "एकोणतीस",
- "30": "तीस",
- "31": "एकतीस",
- "32": "बत्तीस",
- "33": "तेहेतीस",
- "34": "चौतीस",
- "35": "पस्तीस",
- "36": "छत्तीस",
- "37": "सदतीस",
- "38": "अडतीस",
- "39": "एकोणचाळीस",
- "40": "चाळीस",
- "41": "एक्केचाळीस",
- "42": "बेचाळीस",
- "43": "त्रेचाळीस",
- "44": "चव्वेचाळीस",
- "45": "पंचेचाळीस",
- "46": "सेहेचाळीस",
- "47": "सत्तेचाळीस",
- "48": "अठ्ठेचाळीस",
- "49": "एकोणपन्नास",
- "50": "पन्नास",
- "51": "एक्कावन्न",
- "52": "बावन्न",
- "53": "त्रेपन्न",
- "54": "चोपन्न",
- "55": "पंचावन्न",
- "56": "छप्पन्न",
- "57": "सत्तावन्न",
- "58": "अठ्ठावन्न",
- "59": "एकोणसाठ",
- "60": "साठ",
- "61": "एकसष्ठ",
- "62": "बासष्ठ",
- "63": "त्रेसष्ठ",
- "64": "चौसष्ठ",
- "65": "पासष्ठ",
- "66": "सहासष्ठ",
- "67": "सदुसष्ठ",
- "68": "अडुसष्ठ",
- "69": "एकोणसत्तर",
- "70": "सत्तर",
- "71": "एक्काहत्तर",
- "72": "बाहत्तर",
- "73": "त्र्याहत्तर",
- "74": "चौर्याहत्तर",
- "75": "पंच्याहत्तर",
- "76": "शहात्तर",
- "77": "सत्याहत्तर",
- "78": "अठ्ठ्याहत्तर",
- "79": "एकोण ऐंशी",
- "80": "ऐंशी",
- "81": "एक्क्याऐंशी",
- "82": "ब्याऐंशी",
- "83": "त्र्याऐंशी",
- "84": "चौऱ्याऐंशी",
- "85": "पंच्याऐंशी",
- "86": "शहाऐंशी",
- "87": "सत्त्याऐंशी",
- "88": "अठ्ठ्याऐंशी",
- "89": "एकोणनव्वद",
- "90": "नव्वद",
- "91": "एक्क्याण्णव",
- "92": "ब्याण्णव",
- "93": "त्र्याण्णव",
- "94": "चौऱ्याण्णव",
- "95": "पंच्याण्णव",
- "96": "शहाण्णव",
- "97": "सत्त्याण्णव",
- "98": "अठ्ठ्याण्णव",
- "99": "नव्व्याण्णव",
- "100": "शे",
- "1000": "हजार",
- "100000": "लाख",
- "10000000": "कोटी",
- "1000000000": "अब्ज",
-} # Marathi
-num_dict["bn"] = {
- "0": "শূন্য",
- "1": "এক",
- "2": "দুই",
- "3": "তিন",
- "4": "চার",
- "5": "পাঁচ",
- "6": "ছয়",
- "7": "সাত",
- "8": "আট",
- "9": "নয়",
- "10": "দশ",
- "11": "এগার",
- "12": "বার",
- "13": "তের",
- "14": "চৌদ্দ",
- "15": "পনের",
- "16": "ষোল",
- "17": "সতের",
- "18": "আঠার",
- "19": "ঊনিশ",
- "20": "বিশ",
- "21": "একুশ",
- "22": "বাইশ",
- "23": "তেইশ",
- "24": "চব্বিশ",
- "25": "পঁচিশ",
- "26": "ছাব্বিশ",
- "27": "সাতাশ",
- "28": "আঠাশ",
- "29": "ঊনত্রিশ",
- "30": "ত্রিশ",
- "31": "একত্রিশ",
- "32": "বত্রিশ",
- "33": "তেত্রিশ",
- "34": "চৌত্রিশ",
- "35": "পঁয়ত্রিশ",
- "36": "ছত্রিশ",
- "37": "সাঁইত্রিশ",
- "38": "আটত্রিশ",
- "39": "ঊনচল্লিশ",
- "40": "চল্লিশ",
- "41": "একচল্লিশ",
- "42": "বিয়াল্লিশ",
- "43": "তেতাল্লিশ",
- "44": "চুয়াল্লিশ",
- "45": "পঁয়তাল্লিশ",
- "46": "ছেচল্লিশ",
- "47": "সাতচল্লিশ",
- "48": "আটচল্লিশ",
- "49": "ঊনপঞ্চাশ",
- "50": "পঞ্চাশ",
- "51": "একান্ন",
- "52": "বায়ান্ন",
- "53": "তিপ্পান্ন",
- "54": "চুয়ান্ন",
- "55": "পঞ্চান্ন",
- "56": "ছাপ্পান্ন",
- "57": "সাতান্ন",
- "58": "আটান্ন",
- "59": "ঊনষাট",
- "60": "ষাট",
- "61": "একষট্টি",
- "62": "বাষট্টি",
- "63": "তেষট্টি",
- "64": "চৌষট্টি",
- "65": "পঁয়ষট্টি",
- "66": "ছেষট্টি",
- "67": "সাতষট্টি",
- "68": "আটষট্টি",
- "69": "ঊনসত্তর",
- "70": "সত্তর",
- "71": "একাত্তর",
- "72": "বাহাত্তর",
- "73": "তিয়াত্তর",
- "74": "চুয়াত্তর",
- "75": "পঁচাত্তর",
- "76": "ছিয়াত্তর",
- "77": "সাতাত্তর",
- "78": "আটাত্তর",
- "79": "ঊনআশি",
- "80": "আশি",
- "81": "একাশি",
- "82": "বিরাশি",
- "83": "তিরাশি",
- "84": "চুরাশি",
- "85": "পঁচাশি",
- "86": "ছিয়াশি",
- "87": "সাতাশি",
- "88": "আটাশি",
- "89": "ঊননব্বই",
- "90": "নব্বই",
- "91": "একানব্বই",
- "92": "বিরানব্বই",
- "93": "তিরানব্বই",
- "94": "চুরানব্বই",
- "95": "পঁচানব্বই",
- "96": "ছিয়ানব্বই",
- "97": "সাতানব্বই",
- "98": "আটানব্বই",
- "99": "নিরানব্বই",
- "100": "শো",
- "1000": "হাজার",
- "100000": "লাখ",
- "10000000": "কোটি",
- "1000000000": "একশ’ কোটি",
-} # Bengali
-num_dict["te"] = {
- "0": "సున్నా",
- "1": "ఒకటి",
- "2": "రెండు",
- "3": "మూడు",
- "4": "నాలుగు",
- "5": "ఐదు",
- "6": "ఆరు",
- "7": "ఏడు",
- "8": "ఎనిమిది",
- "9": "తొమ్మిది",
- "10": "పది",
- "11": "పదకొండు",
- "12": "పన్నెండు",
- "13": "పదమూడు",
- "14": "పద్నాలుగు",
- "15": "పదిహేను",
- "16": "పదహారు",
- "17": "పదిహేడు",
- "18": "పద్దెనిమిది",
- "19": "పందొమ్మిది",
- "20": "ఇరవై",
- "21": "ఇరవై ఒకటి",
- "22": "ఇరవై రెండు",
- "23": "ఇరవై మూడు",
- "24": "ఇరవై నాలుగు",
- "25": "ఇరవై ఐదు",
- "26": "ఇరవై ఆరు",
- "27": "ఇరవై ఏడు",
- "28": "ఇరవై ఎనిమిది",
- "29": "ఇరవై తొమ్మిది",
- "30": "ముప్పై",
- "31": "ముప్పై ఒకటి",
- "32": "ముప్పై రెండు",
- "33": "ముప్పై మూడు",
- "34": "ముప్పై నాలుగు",
- "35": "ముప్పై ఐదు",
- "36": "ముప్పై ఆరు",
- "37": "ముప్పై ఏడు",
- "38": "ముప్పై ఎనిమిది",
- "39": "ముప్పై తొమ్మిది",
- "40": "నలభై",
- "41": "నలభై ఒకటి",
- "42": "నలభై రెండు",
- "43": "నలభై మూడు",
- "44": "నలభై నాలుగు",
- "45": "నలభై ఐదు",
- "46": "నలభై ఆరు",
- "47": "నలభై ఏడు",
- "48": "నలభై ఎనిమిది",
- "49": "నలభై తొమ్మిది",
- "50": "యాభై",
- "51": "యాభై ఒకటి",
- "52": "యాభై రెండు",
- "53": "యాభై మూడు",
- "54": "యాభై నాలుగు",
- "55": "యాభై ఐదు",
- "56": "యాభై ఆరు",
- "57": "యాభై ఏడు",
- "58": "యాభై ఎనిమిది",
- "59": "యాభై తొమ్మిది",
- "60": "అరవై",
- "61": "అరవై ఒకటి",
- "62": "అరవై రెండు",
- "63": "అరవై మూడు",
- "64": "అరవై నాలుగు",
- "65": "అరవై ఐదు",
- "66": "అరవై ఆరు",
- "67": "అరవై ఏడు",
- "68": "అరవై ఎనిమిది",
- "69": "అరవై తొమ్మిది",
- "70": "డెబ్బై",
- "71": "డెబ్బై ఒకటి",
- "72": "డెబ్బై రెండు",
- "73": "డెబ్బై మూడు",
- "74": "డెబ్బై నాలుగు",
- "75": "డెబ్బై ఐదు",
- "76": "డెబ్బై ఆరు",
- "77": "డెబ్బై ఏడు",
- "78": "డెబ్బై ఎనిమిది",
- "79": "డెబ్బై తొమ్మిది",
- "80": "ఎనభై",
- "81": "ఎనభై ఒకటి",
- "82": "ఎనభై రెండు",
- "83": "ఎనభై మూడు",
- "84": "ఎనభై నాలుగు",
- "85": "ఎనభై ఐదు",
- "86": "ఎనభై ఆరు",
- "87": "ఎనభై ఏడు",
- "88": "ఎనభై ఎనిమిది",
- "89": "ఎనభై తొమ్మిది",
- "90": "తొంభై",
- "91": "తొంభై ఒకటి",
- "92": "తొంభై రెండు",
- "93": "తొంభై మూడు",
- "94": "తొంభై నాలుగు",
- "95": "తొంభై ఐదు",
- "96": "తొంభై ఆరు",
- "97": "తొంభై ఏడు",
- "98": "తొంభై ఎనిమిది",
- "99": "తొంభై తొమ్మిది",
- "100": "వందల",
- "1000": "వేల",
- "100000": "లక్షల",
- "10000000": "కోట్ల",
- "1000000000": "బిలియన్",
-} # Telugu
-num_dict["ta"] = {
- "0": "பூஜ்ஜியம்",
- "1": "ஒன்று",
- "2": "இரண்டு",
- "3": "மூன்று",
- "4": "நான்கு",
- "5": "ஐந்து",
- "6": "ஆறு",
- "7": "ஏழு",
- "8": "எட்டு",
- "9": "ஒன்பது",
- "10": "பத்து",
- "11": "பதினொன்று",
- "12": "பன்னிரண்டு",
- "13": "பதிமூன்று",
- "14": "பதினான்கு",
- "15": "பதினைந்து",
- "16": "பதினாறு",
- "17": "பதினேழு",
- "18": "பதினெட்டு",
- "19": "பத்தொன்பது",
- "20": "இருபது",
- "21": "இருபது ஒன்று",
- "22": "இருபத்து இரண்டு",
- "23": "இருபத்து மூன்று",
- "24": "இருபத்து நான்கு",
- "25": "இருபத்து ஐந்து",
- "26": "இருபத்து ஆறு",
- "27": "இருபத்து ஏழு",
- "28": "இருபத்து எட்டு",
- "29": "இருபத்து ஒன்பது",
- "30": "முப்பது",
- "31": "முப்பத்து ஒன்று",
- "32": "முப்பத்து இரண்டு",
- "33": "முப்பத்து மூன்று",
- "34": "முப்பத்து நான்கு",
- "35": "முப்பத்து ஐந்து",
- "36": "முப்பத்து ஆறு",
- "37": "முப்பத்து ஏழு",
- "38": "முப்பத்து எட்டு",
- "39": "முப்பத்து ஒன்பது",
- "40": "நாற்பது",
- "41": "நாற்பத்து ஒன்று",
- "42": "நாற்பத்து இரண்டு",
- "43": "நாற்பத்து மூன்று",
- "44": "நாற்பத்து நான்கு",
- "45": "நாற்பத்து ஐந்து",
- "46": "நாற்பத்து ஆறு",
- "47": " நாற்பத்து ஏழு",
- "48": "நாற்பத்து எட்டு",
- "49": "நாற்பத்து ஒன்பது",
- "50": "ஐம்பது",
- "51": "ஐம்பத்து ஒன்று",
- "52": "ஐம்பத்து இரண்டு",
- "53": "ஐம்பத்து மூன்று",
- "54": "ஐம்பத்து நான்கு",
- "55": "ஐம்பத்து ஐந்து",
- "56": "ஐம்பத்து ஆறு",
- "57": "ஐம்பத்து ஏழு",
- "58": "ஐம்பத்து எட்டு",
- "59": "ஐம்பத்து ஒன்பது",
- "60": "அறுபது",
- "61": "அறுபத்து ஒன்று",
- "62": "அறுபத்து இரண்டு",
- "63": "அறுபத்து மூன்று",
- "64": "அறுபத்து நான்கு",
- "65": "அறுபத்து ஐந்து",
- "66": "அறுபத்து ஆறு",
- "67": "அறுபத்து ஏழு",
- "68": "அறுபத்து எட்டு",
- "69": "அறுபத்து ஒன்பது",
- "70": "எழுபது",
- "71": "எழுபத்தி ஒன்று",
- "72": "எழுபத்தி இரண்டு",
- "73": "எழுபத்தி முச்சக்கர",
- "74": "எழுபத்தி நான்கு",
- "75": "எழுபத்தி ஐந்து",
- "76": "எழுபத்தி ஆறு",
- "77": "எழுபத்தி ஏழு",
- "78": "எழுபத்தி எட்டு",
- "79": "எழுபத்தி ஒன்பது",
- "80": "எண்பது",
- "81": "எண்பத்தியொன்று",
- "82": "எண்பத்திரண்டு",
- "83": "எண்பத்திமூன்று",
- "84": "என்பதினான்கு",
- "85": "என்பதினைந்து",
- "86": "எண்பத்திஆறு",
- "87": "எண்பத்திஏழு",
- "88": "எண்பத்தியெட்டு",
- "89": "எண்பத்தியொன்பது",
- "90": "தொன்னூறு",
- "91": "தொண்ணூற்றியொன்று",
- "92": "தொண்ணூற்றிரண்டு",
- "93": "தொண்ணூற்றிமூன்று",
- "94": "தொண்ணூற்றிநான்கு",
- "95": "தொண்ணூற்றிஐந்து",
- "96": "தொண்ணூற்றியாறு",
- "97": "தொண்ணூற்றியேழு",
- "98": "தொண்ணூற்றியெட்டு",
- "99": "தொண்ணூற்றிஒன்பது",
- "100": "நூறு",
- "1000": "ஆயிரம்",
- "100000": "இலட்சம்",
- "10000000": "கோடி",
- "1000000000": "பில்லியன்",
-} # Tamil
-num_dict["kn"] = {
- "0": "ಸೊನ್ನೆ",
- "1": "ಒಂದು",
- "2": "ಎರಡು",
- "3": "ಮೂರು",
- "4": "ನಾಲ್ಕು",
- "5": "ಅಯ್ದು",
- "6": "ಆರು",
- "7": "ಏಳು",
- "8": "ಎಂಟು",
- "9": "ಒಂಬತ್ತು",
- "10": "ಹತ್ತು",
- "11": "ಹನ್ನೊಂದು",
- "12": "ಹನ್ನೆರಡು",
- "13": "ಹದಿಮೂರು",
- "14": "ಹದಿನಾಲ್ಕು",
- "15": "ಹದಿನೈದು",
- "16": "ಹದಿನಾರು",
- "17": "ಹದಿನೇಳು",
- "18": "ಹದಿನೆಂಟು",
- "19": "ಹತ್ತೊಂಬತ್ತು",
- "20": "ಇಪ್ಪತ್ತು",
- "21": "ಇಪ್ಪತ್ತ್’ಒಂದು",
- "22": "ಇಪ್ಪತ್ತ್’ಎರಡು",
- "23": "ಇಪ್ಪತ್ತ್’ಮೂರು",
- "24": "ಇಪ್ಪತ್ತ್’ನಾಲ್ಕು",
- "25": "ಇಪ್ಪತ್ತ್’ಐದು",
- "26": "ಇಪ್ಪತ್ತ್’ಆರು",
- "27": "ಇಪ್ಪತ್ತ್’ಏಳು",
- "28": "ಇಪ್ಪತ್ತ್’ಎಂಟು",
- "29": "ಇಪ್ಪತ್ತ್’ಒಂಬತ್ತು",
- "30": "ಮೂವತ್ತು",
- "31": "ಮುವತ್ತ್’ಒಂದು",
- "32": "ಮುವತ್ತ್’ಎರಡು",
- "33": "ಮುವತ್ತ್’ಮೂರು",
- "34": "ಮೂವತ್ತ್’ನಾಲ್ಕು",
- "35": "ಮೂವತ್ತ್’ಐದು",
- "36": "ಮೂವತ್ತ್’ಆರು",
- "37": "ಮೂವತ್ತ್’ಏಳು",
- "38": "ಮೂವತ್ತ್’ಎಂಟು",
- "39": "ಮೂವತ್ತ್’ಒಂಬತ್ತು",
- "40": "ನಲವತ್ತು",
- "41": "ನಲವತ್ತೊಂದು",
- "42": "ನಲವತ್ತ್ ಎರಡು",
- "43": "ನಲವತ್ತ್ ಮೂರು",
- "44": "ನಲವತ್ತ್ ನಾಲ್ಕು",
- "45": "ನಲವತ್ತೈದು",
- "46": "ನಲವತ್ತಾರು",
- "47": "ನಲವತ್ತೇಳು",
- "48": "ನಲವತ್ತೆಂಟು",
- "49": "ನಲವತ್ತೊಂಬತ್ತು",
- "50": "ಐವತ್ತು",
- "51": "ಐವತ್ತೊಂದು",
- "52": "ಐವತ್ತೆರಡು",
- "53": "ಐವತ್ತಮೂರು",
- "54": "ಐವತ್ತ್ನಾಲ್ಕು",
- "55": "ಐವತ್ತೈದು",
- "56": "ಐವತ್ತಾರು",
- "57": "ಐವತ್ತೇಳು",
- "58": "ಐವತ್ತೆಂಟು",
- "59": "ಐವತ್ತೊಂಬತ್ತು",
- "60": "ಅರವತ್ತು",
- "61": "ಅರವತ್ತೊಂದು",
- "62": "ಅರವತ್ತೆರಡು",
- "63": "ಅರವತ್ತ್ ಮೂರು",
- "64": "ಅರವತ್ತ್ ನಾಲ್ಕು",
- "65": "ಅರವತ್ತೈದು",
- "66": "ಅರವತ್ತಾರು",
- "67": "ಅರವತ್ತೇಳು",
- "68": "ಅರವತ್ತೆಂಟು",
- "69": "ಅರವತ್ತೊಂಬತ್ತು",
- "70": "ಎಪ್ಪತ್ತು",
- "71": "ಎಪ್ಪತ್ತೊಂದು",
- "72": "ಎಪ್ಪತ್ತೆರಡು",
- "73": "ಎಪ್ಪತ್ತ್ ಮೂರು",
- "74": "ಎಪ್ಪತ್ತ್ ನಾಲ್ಕು",
- "75": "ಎಪ್ಪತ್ತೈದು",
- "76": "ಎಪ್ಪತ್ತಾರು",
- "77": "ಎಪ್ಪತ್ತೇಳು",
- "78": "ಎಪ್ಪತ್ತೆಂಟು",
- "79": "ಎಪ್ಪತ್ತೊಂಬತ್ತು",
- "80": "ಎಂಬತ್ತು",
- "81": "ಎಂಬತ್ತೊಂದು",
- "82": "ಎಂಬತ್ತೆರಡು",
- "83": "ಎಂಬತ್ತ್ ಮೂರು",
- "84": "ಎಂಬತ್ತ್ ನಾಲ್ಕು",
- "85": "ಎಂಬತ್ತೈದು",
- "86": "ಎಂಬತ್ತಾರು",
- "87": "ಎಂಬತ್ತೇಳು",
- "88": "ಎಂಬತ್ತೆಂಟು",
- "89": "ಎಂಬತ್ತೊಂಬತ್ತು",
- "90": "ತೊಂಬತ್ತು",
- "91": "ತೊಂಬತ್ತೊಂದು",
- "92": "ತೊಂಬತ್ತೆರಡು",
- "93": "ತೊಂಬತ್ತ ಮೂರು",
- "94": "ತೊಂಬತ್ತ ನಾಲ್ಕು",
- "95": "ತೊಂಬತ್ತೈದು",
- "96": "ತೊಂಬತ್ತಾರು",
- "97": "ತೊಂಬತ್ತೇಳು",
- "98": "ತೊಂಬತ್ತೆಂಟು",
- "99": "ತೊಂಬತ್ತೊಂಬತ್ತು",
- "100": "ನೂರ",
- "1000": "ಸಾವಿರದ",
- "100000": "ಲಕ್ಷದ",
- "10000000": "ಕೋಟಿ",
- "1000000000": "ಶತಕೋಟಿ",
-} # Kannada
-num_dict["or"] = {
- "0": "ଶୁନ୍ୟ",
- "1": "ଏକ",
- "2": "ଦୁଇ",
- "3": "ତିନି",
- "4": "ଚାରି",
- "5": "ପାଞ୍ଚ",
- "6": "ଛଅ",
- "7": "ସାତ",
- "8": "ଆଠ",
- "9": "ନଅ",
- "10": "ନଅ",
- "11": "ଏଗାର",
- "12": "ବାର",
- "13": "ତେର",
- "14": "ଚଉଦ",
- "15": "ପନ୍ଦର",
- "16": "ଷୋହଳ",
- "17": "ସତର",
- "18": "ଅଠର",
- "19": "ଊଣାଇଶ",
- "20": "କୋଡିଏ",
- "21": "ଏକୋଇଶି",
- "22": "ବାଇଶି",
- "23": "ତେଇଶି",
- "24": "ଚବିଶି",
- "25": "ପଚିଶି",
- "26": "ଛବିଶି",
- "27": "ସତାଇଶି",
- "28": "ଅଠାଇଶି",
- "29": "ଅଣତିରିଶି",
- "30": "ତିରିଶି",
- "31": "ଏକତିରିଶି",
- "32": "ବତିଶି",
- "33": "ତେତିଶି",
- "34": "ଚଉତିରିଶି",
- "35": "ପଞ୍ଚତିରିଶି",
- "36": "ଛତିଶି",
- "37": "ସଂଇତିରିଶି",
- "38": "ଅଠତିରିଶି",
- "39": "ଅଣଚାଳିଶି",
- "40": "ଚାଳିଶି",
- "41": "ଏକଚାଳିଶି",
- "42": "ବୟାଳିଶି",
- "43": "ତେୟାଳିଶି",
- "44": "ଚଉରାଳିଶି",
- "45": "ପଞ୍ଚଚାଳିଶି",
- "46": "ଛୟାଳିଶି",
- "47": "ସତଚାଳିଶି",
- "48": "ଅଠଚାଳିଶି",
- "49": "ଅଣଚାଶ",
- "50": "ପଚାଶ",
- "51": "ଏକାବନ",
- "52": "ବାଉନ",
- "53": "ତେପନ",
- "54": "ଚଉବନ",
- "55": "ପଞ୍ଚାବନ",
- "56": "ଛପନ",
- "57": "ସତାବନ",
- "58": "ଅଠାବନ",
- "59": "ଅଣଷଠି",
- "60": "ଷାଠିଏ",
- "61": "ଏକଷଠି",
- "62": "ବାଷଠି",
- "63": "ତେଷଠି",
- "64": "ଚଉଷଠି",
- "65": "ପଞ୍ଚଷଠି",
- "66": "ଛଅଷଠି",
- "67": "ସତଷଠି",
- "68": "ଅଠଷଠି",
- "69": "ଅଣସ୍ତରୀ",
- "70": "ସତୂରୀ",
- "71": "ଏକସ୍ତରୀ",
- "72": "ବାସ୍ତରୀ",
- "73": "ତେସ୍ତରୀ",
- "74": "ଚଉସ୍ତରୀ",
- "75": "ପଞ୍ଚସ୍ତରୀ",
- "76": "ଛଅସ୍ତରୀ",
- "77": "ସତସ୍ତରୀ",
- "78": "ଅଠସ୍ତରୀ",
- "79": "ଅଣାଅଶୀ",
- "80": "ଅଶୀ",
- "81": "ଏକାଅଶୀ",
- "82": "ବୟାଅଶୀ",
- "83": "ତେୟାଅଶୀ",
- "84": "ଚଉରାଅଶୀ",
- "85": "ପଞ୍ଚାଅଶୀ",
- "86": "ଛୟାଅଶୀ",
- "87": "ସତାଅଶୀ",
- "88": "ଅଠାଅଶୀ",
- "89": "ଅଣାନବେ",
- "90": "ନବେ",
- "91": "ଏକାନବେ",
- "92": "ବୟାନବେ",
- "93": "ତେୟାନବେ",
- "94": "ଚଉରାନବେ",
- "95": "ପଞ୍ଚାନବେ",
- "96": "ଛୟାନବେ",
- "97": "ସତାନବେ",
- "98": "ଅଠାନବେ",
- "99": "ଅନେଶତ",
- "100": "ଶହେ",
- "1000": "ହଜାର",
- "100000": "ଲକ୍ଷ",
- "10000000": "କୋଟି",
- "1000000000": "କୋଟି",
-} # Oriya
-num_dict["pa"] = {
- "0": "ਸਿਫਰ ",
- "1": "ਇੱਕ",
- "2": "ਦੋ",
- "3": "ਤਿੰਨ",
- "4": "ਚਾਰ",
- "5": "ਪੰਜ",
- "6": "ਛੇ",
- "7": "ਸੱਤ",
- "8": "ਅੱਠ",
- "9": "ਨੌਂ",
- "10": "ਦੱਸ",
- "11": "ਗਿਆਰਾਂ",
- "12": "ਬਾਰਾਂ",
- "13": "ਤੇਰਾਂ",
- "14": "ਚੌਦਾਂ",
- "15": "ਪੰਦਰਾਂ",
- "16": "ਸੋਲ਼ਾਂ",
- "17": "ਸਤਾਰਾਂ",
- "18": "ਅਠਾਰਾਂ",
- "19": "ਉਨੀ",
- "20": "ਵੀਹ",
- "21": "ਇੱਕੀ",
- "22": "ਬਾਈ",
- "23": "ਤੇਈ",
- "24": "ਚੌਵੀ",
- "25": "ਪੰਝੀ",
- "26": "ਛੱਬੀ",
- "27": "ਸਤਾਈ",
- "28": "ਅਠਾਈ",
- "29": "ਉਨੱਤੀ",
- "30": "ਤੀਹ",
- "31": "ਇਕੱਤੀ",
- "32": "ਬੱਤੀ",
- "33": "ਤੇਤੀ",
- "34": "ਚੌਂਤੀ",
- "35": "ਪੈਂਤੀ",
- "36": "ਛੱਤੀ",
- "37": "ਸੈਂਤੀ",
- "38": "ਅਠੱਤੀ",
- "39": "ਉਨਤਾਲੀ",
- "40": "ਚਾਲੀ",
- "41": "ਇਕਤਾਲੀ",
- "42": "ਬਤਾਲੀ",
- "43": "ਤਰਤਾਲੀ",
- "44": "ਚੌਤਾਲੀ",
- "45": "ਪੰਜਤਾਲੀ",
- "46": "ਛਿਆਲੀ",
- "47": "ਸੰਤਾਲੀ",
- "48": "ਅੱਠਤਾਲੀ",
- "49": "ਉਣਿੰਜਾ",
- "50": "ਪੰਜਾਹ",
- "51": "ਇਕਵਿੰਜਾ",
- "52": "ਬਵਿੰਜਾ",
- "53": "ਤਰਵਿੰਜਾ",
- "54": "ਚਰਿੰਜਾ",
- "55": "ਪਚਵਿੰਜਾ",
- "56": "ਛਪਿੰਜਾ",
- "57": "ਸਤਵਿੰਜਾ",
- "58": "ਅੱਠਵਿੰਜਾ",
- "59": "ਉਣਾਠ",
- "60": "ਸੱਠ",
- "61": "ਇਕਾਠ",
- "62": "ਬਾਠ੍ਹ",
- "63": "ਤਰੇਠ੍ਹ",
- "64": "ਚੌਠ੍ਹ",
- "65": "ਪੈਂਠ",
- "66": "ਛਿਆਠ",
- "67": "ਸਤਾਹਠ",
- "68": "ਅੱਠਾਠ",
- "69": "ਉਣੱਤਰ",
- "70": "ਸੱਤਰ",
- "71": "ਇਕ੍ਹੱਤਰ",
- "72": "ਬਹੱਤਰ",
- "73": "ਤਹੱਤਰ",
- "74": "ਚੌਹੱਤਰ",
- "75": "ਪੰਜੱਤਰ",
- "76": "ਛਿਹੱਤਰ",
- "77": "ਸਤੱਤਰ",
- "78": "ਅਠੱਤਰ",
- "79": "ਉਣਾਸੀ",
- "80": "ਅੱਸੀ",
- "81": "ਇਕਾਸੀ",
- "82": "ਬਿਆਸੀ",
- "83": "ਤਰਾਸੀ",
- "84": "ਚਰਾਸੀ",
- "85": "ਪੰਜਾਸੀ",
- "86": "ਛਿਆਸੀ",
- "87": "ਸਤਾਸੀ",
- "88": "ਅਠਾਸੀ",
- "89": "ਉਣਾਨਵੇਂ",
- "90": "ਨੱਬੇ",
- "91": "ਇਕਾਨਵੇਂ",
- "92": "ਬਿਆਨਵੇਂ",
- "93": "ਤਰਾਨਵੇਂ",
- "94": "ਚਰਾਨਵੇਂ",
- "95": "ਪਚਾਨਵੇਂ",
- "96": "ਛਿਆਨਵੇਂ",
- "97": "ਸਤਾਨਵੇਂ",
- "98": "ਅਠਾਨਵੇਂ",
- "99": "ਨਿੜਾਨਵੇਂ",
- "100": "ਸੌ",
- "1000": "ਹਜਾਰ",
- "100000": "ਲੱਖ",
- "10000000": "ਕਰੋੜ",
- "1000000000": "ਅਰਬ",
-} # Punjabi
-
-# --------------------------- num_to_word.py ------------------------------
-"""
-Method to convert Numbers to Words
-for indian languages
-
-Use cases:-
-1) Speech recognition pre-processing
-2) Language modeling Data pre-processing
-
--------------------------
-check indic_numbers.py to add support
-for any indian language
-"""
-
-
-def language_specific_exception(words, lang, combiner):
- """
- Language Specific Exception will come here
- """
-
- def occurs_at_end(piece):
- return words[-len(piece) :] == piece
-
- if lang == "mr":
- words = words.replace("एक" + combiner + "शे", "शंभर")
- elif lang == "gu":
- words = words.replace("બે" + combiner + "સો", "બસ્સો")
- elif lang == "te":
- exception_dict = {
- "1": "ఒక",
- "100": "వంద",
- "100+": "వందలు",
- "1000": "వెయ్యి",
- "1000+": "వేలు",
- "100000": "లక్ష",
- "100000+": "లక్షలు",
- "10000000": "కోటి",
- "10000000+": "కోట్లు",
- }
-
- test_case = ["100", "1000", "100000", "10000000"]
- for test in test_case:
- test_word = num_dict["te"][test]
- match = num_dict["te"]["1"] + combiner + test_word
- # for numbers like : 100, 1000, 100000
- if words == match:
- return exception_dict[test]
- # for numbers like : 200, 4000, 800000
- elif occurs_at_end(test_word):
- words = words.replace(test_word, exception_dict[test + "+"])
- # for numbers like : 105, 1076, 123993
- elif not occurs_at_end(match):
- replacement = exception_dict["1"] + combiner + exception_dict[test]
- words = words.replace(match, replacement)
-
- # Exception case for 101...199
- special_case = "ఒక" + combiner + "వంద"
- words = words.replace(special_case, "నూట")
- elif lang == "kn":
- # special case for 100
- if words == ("ಒಂದು" + combiner + "ನೂರ"):
- return "ನೂರು"
- exception_dict = {
- "ನೂರ": "ನೂರು",
- "ಸಾವಿರದ": "ಸಾವಿರ",
- "ಲಕ್ಷದ": "ಲಕ್ಷ",
- "ಕೋಟಿಯ": "ಕೋಟಿ",
- }
- for expt in exception_dict:
- if occurs_at_end(expt):
- words = words.replace(expt, exception_dict[expt])
- return words
-
-
-def num_to_word(num, lang, separator=", ", combiner=" "):
- """
- Main Method
- :param num: Number digits from any indian language
- :param lang: Language Code from supported Language
- :param separator: Separator character i.e. separator = '-' --> 'two hundred-sixty'
- :param combiner: combine number with position i.e. combiner = '-' --> 'two-hundred sixty'
- :return: UTF-8 String of numbers in words
- """
- lang = lang.lower()
- num = str(num)
-
- # Load dictionary according to language code
- assert lang in supported_lang, "Language not supported"
- num_dic = num_dict[lang]
-
- # dash default combiner for english-india
- if (lang == "en") & (combiner == " "):
- combiner = "-"
-
- # Remove punctuations from numbers
- num = str(num).replace(",", "").replace(" ", "")
-
- # Replace native language numbers with english digits
- for language in supported_lang:
- for num_index in range(10):
- num = num.replace(all_num[language][num_index], all_num["en"][num_index])
-
- # Assert that input contains only integer number
- for digit in num:
- assert digit in all_num["en"], "Give proper input"
-
- # Process
- # For Number longer than 9 digits
- def all_two_digit(digits_2):
- if len(digits_2) <= 1: # Provided only one/zero digit
- return num_dic.get(digits_2, "")
- elif digits_2 == "00": # Two Zero provided
- return num_dic["0"] + separator + num_dic["0"]
- elif digits_2[0] == "0": # First digit is zero
- return num_dic["0"] + separator + num_dic[digits_2[1]]
- else: # Both digit provided
- return num_dic[digits_2]
-
- # For Number less than 9 digits
- def two_digit(digits_2):
- digits_2 = digits_2.lstrip("0")
- if len(digits_2) != 0:
- return num_dic[digits_2]
- else:
- return ""
-
- def all_digit(digits):
- digits = digits.lstrip("0")
- digit_len = len(digits)
- if digit_len > 3:
- num_of_digits_to_process = (digit_len % 2) + 1
- process_digits = digits[:num_of_digits_to_process]
- base = str(10 ** (int(digit_len / 2) * 2 - 1))
- remain_digits = digits[num_of_digits_to_process:]
- return (
- num_dic[process_digits]
- + combiner
- + num_dic[base]
- + separator
- + all_digit(remain_digits)
- )
- elif len(digits) == 3:
- return (
- num_dic[digits[:1]]
- + combiner
- + num_dic["100"]
- + separator
- + two_digit(digits[1:])
- )
- else:
- return two_digit(digits)
-
- num = num.lstrip("0")
- full_digit_len = len(num)
-
- if full_digit_len == 0:
- output = num_dic["0"]
- elif full_digit_len <= 9:
- output = all_digit(num)
- else:
- iteration = round(full_digit_len / 2)
- output = all_two_digit(num[:2]) # First to digit
- for i in range(1, iteration):
- output = (
- output + separator + all_two_digit(num[i * 2 : (i + 1) * 2])
- ) # Next two digit pairs
- remaining_digits = num[iteration * 2 :]
- if not all_two_digit(remaining_digits) == "":
- output = (
- output + separator + all_two_digit(remaining_digits)
- ) # remaining Last one/two digits
-
- output = output.strip(separator)
-
- output = language_specific_exception(output, lang, combiner)
-
- return output
-
-
-# --------------------------------- num_to_word_on_a_sent ---------------------------------
-
-
-def is_digit(word, digit_pattern):
- return re.search(digit_pattern, word)
-
-
-def remove_punct(sent):
- clean = re.sub("[%s]" % re.escape(string.punctuation), " ", sent)
- return " ".join([word for word in clean.split() if word])
-
-
-def normalize_nums(text, lang):
- """
- text: str (eg)
- lang: lang code ['en', 'hi']
-
- returns: str
- (eg)
- """
-
- if lang in supported_lang:
- words = text.split()
- lang_digits = [str(i) for i in range(0, 10)]
-
- digit_pattern = "[" + "".join(lang_digits) + "]"
- num_indices = [
- ind for ind, word in enumerate(words) if is_digit(word, digit_pattern)
- ]
-
- words_up = [
- num_to_word(word, lang, separator=" ", combiner=" ")
- if ind in num_indices
- else word
- for ind, word in enumerate(words)
- ]
- return " ".join(words_up)
- else:
- return text
-
-
-if __name__ == "__main__":
- print(normalize_nums("रीटा के पास 16 बिल्लियाँ हैं।", "hi"))
diff --git a/spaces/Harveenchadha/en_to_indic_translation/indic_nlp_library/contrib/README.md b/spaces/Harveenchadha/en_to_indic_translation/indic_nlp_library/contrib/README.md
deleted file mode 100644
index 0a99b9ddd9e9bcc72bae930fc8a778f3094fea50..0000000000000000000000000000000000000000
--- a/spaces/Harveenchadha/en_to_indic_translation/indic_nlp_library/contrib/README.md
+++ /dev/null
@@ -1,7 +0,0 @@
-# Contrib
-
-Contains additional utilities and applications using Indic NLP library core
-
-- `indic_scraper_project_sample.ipynb`: A simple pipeline for building monolingual corpora for Indian languages from crawled web content, Wikipedia, etc. An extensible framework which allows incorporation of website specific extractors, whereas generic NLP tasks like tokenization, sentence splitting, normalization, etc. are handled by the framework.
-- `correct_moses_tokenizer.py`: This script corrects the incorrect tokenization done by Moses tokenizer. The Moses tokenizer splits on nukta and halant characters.
-- `hindi_to_kannada_transliterator.py`: This script transliterates Hindi to Kannada. It removes/remaps characters only found in Hindi. It also adds halanta to words ending with consonant - as is the convention in Kannada.
diff --git a/spaces/HgMenon/Transcribe_V0.2/src/utils.py b/spaces/HgMenon/Transcribe_V0.2/src/utils.py
deleted file mode 100644
index 576244c9cf8b8e8aa888b0a51312ddf56db928ce..0000000000000000000000000000000000000000
--- a/spaces/HgMenon/Transcribe_V0.2/src/utils.py
+++ /dev/null
@@ -1,245 +0,0 @@
-import textwrap
-import unicodedata
-import re
-
-import zlib
-from typing import Iterator, TextIO, Union
-import tqdm
-
-import urllib3
-
-
-def exact_div(x, y):
- assert x % y == 0
- return x // y
-
-
-def str2bool(string):
- str2val = {"True": True, "False": False}
- if string in str2val:
- return str2val[string]
- else:
- raise ValueError(f"Expected one of {set(str2val.keys())}, got {string}")
-
-
-def optional_int(string):
- return None if string == "None" else int(string)
-
-
-def optional_float(string):
- return None if string == "None" else float(string)
-
-
-def compression_ratio(text) -> float:
- return len(text) / len(zlib.compress(text.encode("utf-8")))
-
-
-def format_timestamp(seconds: float, always_include_hours: bool = False, fractionalSeperator: str = '.'):
- assert seconds >= 0, "non-negative timestamp expected"
- milliseconds = round(seconds * 1000.0)
-
- hours = milliseconds // 3_600_000
- milliseconds -= hours * 3_600_000
-
- minutes = milliseconds // 60_000
- milliseconds -= minutes * 60_000
-
- seconds = milliseconds // 1_000
- milliseconds -= seconds * 1_000
-
- hours_marker = f"{hours:02d}:" if always_include_hours or hours > 0 else ""
- return f"{hours_marker}{minutes:02d}:{seconds:02d}{fractionalSeperator}{milliseconds:03d}"
-
-
-def write_txt(transcript: Iterator[dict], file: TextIO):
- for segment in transcript:
- print(segment['text'].strip(), file=file, flush=True)
-
-
-def write_vtt(transcript: Iterator[dict], file: TextIO,
- maxLineWidth=None, highlight_words: bool = False):
- iterator = __subtitle_preprocessor_iterator(transcript, maxLineWidth, highlight_words)
-
- print("WEBVTT\n", file=file)
-
- for segment in iterator:
- text = segment['text'].replace('-->', '->')
-
- print(
- f"{format_timestamp(segment['start'])} --> {format_timestamp(segment['end'])}\n"
- f"{text}\n",
- file=file,
- flush=True,
- )
-
-def write_srt(transcript: Iterator[dict], file: TextIO,
- maxLineWidth=None, highlight_words: bool = False):
- """
- Write a transcript to a file in SRT format.
- Example usage:
- from pathlib import Path
- from whisper.utils import write_srt
- result = transcribe(model, audio_path, temperature=temperature, **args)
- # save SRT
- audio_basename = Path(audio_path).stem
- with open(Path(output_dir) / (audio_basename + ".srt"), "w", encoding="utf-8") as srt:
- write_srt(result["segments"], file=srt)
- """
- iterator = __subtitle_preprocessor_iterator(transcript, maxLineWidth, highlight_words)
-
- for i, segment in enumerate(iterator, start=1):
- text = segment['text'].replace('-->', '->')
-
- # write srt lines
- print(
- f"{i}\n"
- f"{format_timestamp(segment['start'], always_include_hours=True, fractionalSeperator=',')} --> "
- f"{format_timestamp(segment['end'], always_include_hours=True, fractionalSeperator=',')}\n"
- f"{text}\n",
- file=file,
- flush=True,
- )
-
-def __subtitle_preprocessor_iterator(transcript: Iterator[dict], maxLineWidth: int = None, highlight_words: bool = False):
- for segment in transcript:
- words = segment.get('words', [])
-
- if len(words) == 0:
- # Yield the segment as-is or processed
- if maxLineWidth is None or maxLineWidth < 0:
- yield segment
- else:
- yield {
- 'start': segment['start'],
- 'end': segment['end'],
- 'text': process_text(segment['text'].strip(), maxLineWidth)
- }
- # We are done
- continue
-
- subtitle_start = segment['start']
- subtitle_end = segment['end']
-
- text_words = [ this_word["word"] for this_word in words ]
- subtitle_text = __join_words(text_words, maxLineWidth)
-
- # Iterate over the words in the segment
- if highlight_words:
- last = subtitle_start
-
- for i, this_word in enumerate(words):
- start = this_word['start']
- end = this_word['end']
-
- if last != start:
- # Display the text up to this point
- yield {
- 'start': last,
- 'end': start,
- 'text': subtitle_text
- }
-
- # Display the text with the current word highlighted
- yield {
- 'start': start,
- 'end': end,
- 'text': __join_words(
- [
- {
- "word": re.sub(r"^(\s*)(.*)$", r"\1\2 ", word)
- if j == i
- else word,
- # The HTML tags and are not displayed,
- # # so they should not be counted in the word length
- "length": len(word)
- } for j, word in enumerate(text_words)
- ], maxLineWidth)
- }
- last = end
-
- if last != subtitle_end:
- # Display the last part of the text
- yield {
- 'start': last,
- 'end': subtitle_end,
- 'text': subtitle_text
- }
-
- # Just return the subtitle text
- else:
- yield {
- 'start': subtitle_start,
- 'end': subtitle_end,
- 'text': subtitle_text
- }
-
-def __join_words(words: Iterator[Union[str, dict]], maxLineWidth: int = None):
- if maxLineWidth is None or maxLineWidth < 0:
- return " ".join(words)
-
- lines = []
- current_line = ""
- current_length = 0
-
- for entry in words:
- # Either accept a string or a dict with a 'word' and 'length' field
- if isinstance(entry, dict):
- word = entry['word']
- word_length = entry['length']
- else:
- word = entry
- word_length = len(word)
-
- if current_length > 0 and current_length + word_length > maxLineWidth:
- lines.append(current_line)
- current_line = ""
- current_length = 0
-
- current_length += word_length
- # The word will be prefixed with a space by Whisper, so we don't need to add one here
- current_line += word
-
- if len(current_line) > 0:
- lines.append(current_line)
-
- return "\n".join(lines)
-
-def process_text(text: str, maxLineWidth=None):
- if (maxLineWidth is None or maxLineWidth < 0):
- return text
-
- lines = textwrap.wrap(text, width=maxLineWidth, tabsize=4)
- return '\n'.join(lines)
-
-def slugify(value, allow_unicode=False):
- """
- Taken from https://github.com/django/django/blob/master/django/utils/text.py
- Convert to ASCII if 'allow_unicode' is False. Convert spaces or repeated
- dashes to single dashes. Remove characters that aren't alphanumerics,
- underscores, or hyphens. Convert to lowercase. Also strip leading and
- trailing whitespace, dashes, and underscores.
- """
- value = str(value)
- if allow_unicode:
- value = unicodedata.normalize('NFKC', value)
- else:
- value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore').decode('ascii')
- value = re.sub(r'[^\w\s-]', '', value.lower())
- return re.sub(r'[-\s]+', '-', value).strip('-_')
-
-def download_file(url: str, destination: str):
- with urllib3.request.urlopen(url) as source, open(destination, "wb") as output:
- with tqdm(
- total=int(source.info().get("Content-Length")),
- ncols=80,
- unit="iB",
- unit_scale=True,
- unit_divisor=1024,
- ) as loop:
- while True:
- buffer = source.read(8192)
- if not buffer:
- break
-
- output.write(buffer)
- loop.update(len(buffer))
\ No newline at end of file
diff --git a/spaces/ICML2022/Leaderboard/app.py b/spaces/ICML2022/Leaderboard/app.py
deleted file mode 100644
index 958950af83dae605628e0d97e0daa5bbd709f1a4..0000000000000000000000000000000000000000
--- a/spaces/ICML2022/Leaderboard/app.py
+++ /dev/null
@@ -1,39 +0,0 @@
-import os
-import requests
-import pandas as pd
-import gradio as gr
-from huggingface_hub.hf_api import SpaceInfo
-from pathlib import Path
-
-
-path = f"https://huggingface.co/api/spaces"
-
-
-def get_blocks_party_spaces():
- r = requests.get(path)
- d = r.json()
- spaces = [SpaceInfo(**x) for x in d]
- blocks_spaces = {}
- for i in range(0,len(spaces)):
- if spaces[i].id.split('/')[0] == 'ICML2022' and hasattr(spaces[i], 'likes') and spaces[i].id != 'ICML2022/Leaderboard' and spaces[i].id != 'ICML2022/README':
- blocks_spaces[spaces[i].id]=spaces[i].likes
- df = pd.DataFrame(
- [{"Spaces_Name": Spaces, "likes": likes} for Spaces,likes in blocks_spaces.items()])
- df = df.sort_values(by=['likes'],ascending=False)
- return df
-
-
-block = gr.Blocks()
-
-with block:
- gr.Markdown("""Leaderboard for the most popular ICML 2022 Spaces. To learn more and join, see ICML 2022 Event """)
- with gr.Tabs():
- with gr.TabItem("ICML 2022 Leaderboard"):
- with gr.Row():
- data = gr.outputs.Dataframe(type="pandas")
- with gr.Row():
- data_run = gr.Button("Refresh")
- data_run.click(get_blocks_party_spaces, inputs=None, outputs=data)
-
- block.load(get_blocks_party_spaces, inputs=None, outputs=data)
-block.launch()
diff --git a/spaces/ICML2022/OFA/fairseq/examples/backtranslation/README.md b/spaces/ICML2022/OFA/fairseq/examples/backtranslation/README.md
deleted file mode 100644
index 73675f1125d80f58aa824db67d8970504d4d6b2a..0000000000000000000000000000000000000000
--- a/spaces/ICML2022/OFA/fairseq/examples/backtranslation/README.md
+++ /dev/null
@@ -1,297 +0,0 @@
-# Understanding Back-Translation at Scale (Edunov et al., 2018)
-
-This page includes pre-trained models from the paper [Understanding Back-Translation at Scale (Edunov et al., 2018)](https://arxiv.org/abs/1808.09381).
-
-## Pre-trained models
-
-Model | Description | Dataset | Download
----|---|---|---
-`transformer.wmt18.en-de` | Transformer ([Edunov et al., 2018](https://arxiv.org/abs/1808.09381)) WMT'18 winner | [WMT'18 English-German](http://www.statmt.org/wmt18/translation-task.html) | [download (.tar.gz)](https://dl.fbaipublicfiles.com/fairseq/models/wmt18.en-de.ensemble.tar.gz) See NOTE in the archive
-
-## Example usage (torch.hub)
-
-We require a few additional Python dependencies for preprocessing:
-```bash
-pip install subword_nmt sacremoses
-```
-
-Then to generate translations from the full model ensemble:
-```python
-import torch
-
-# List available models
-torch.hub.list('pytorch/fairseq') # [..., 'transformer.wmt18.en-de', ... ]
-
-# Load the WMT'18 En-De ensemble
-en2de_ensemble = torch.hub.load(
- 'pytorch/fairseq', 'transformer.wmt18.en-de',
- checkpoint_file='wmt18.model1.pt:wmt18.model2.pt:wmt18.model3.pt:wmt18.model4.pt:wmt18.model5.pt',
- tokenizer='moses', bpe='subword_nmt')
-
-# The ensemble contains 5 models
-len(en2de_ensemble.models)
-# 5
-
-# Translate
-en2de_ensemble.translate('Hello world!')
-# 'Hallo Welt!'
-```
-
-## Training your own model (WMT'18 English-German)
-
-The following instructions can be adapted to reproduce the models from the paper.
-
-
-#### Step 1. Prepare parallel data and optionally train a baseline (English-German) model
-
-First download and preprocess the data:
-```bash
-# Download and prepare the data
-cd examples/backtranslation/
-bash prepare-wmt18en2de.sh
-cd ../..
-
-# Binarize the data
-TEXT=examples/backtranslation/wmt18_en_de
-fairseq-preprocess \
- --joined-dictionary \
- --source-lang en --target-lang de \
- --trainpref $TEXT/train --validpref $TEXT/valid --testpref $TEXT/test \
- --destdir data-bin/wmt18_en_de --thresholdtgt 0 --thresholdsrc 0 \
- --workers 20
-
-# Copy the BPE code into the data-bin directory for future use
-cp examples/backtranslation/wmt18_en_de/code data-bin/wmt18_en_de/code
-```
-
-(Optionally) Train a baseline model (English-German) using just the parallel data:
-```bash
-CHECKPOINT_DIR=checkpoints_en_de_parallel
-fairseq-train --fp16 \
- data-bin/wmt18_en_de \
- --source-lang en --target-lang de \
- --arch transformer_wmt_en_de_big --share-all-embeddings \
- --dropout 0.3 --weight-decay 0.0 \
- --criterion label_smoothed_cross_entropy --label-smoothing 0.1 \
- --optimizer adam --adam-betas '(0.9, 0.98)' --clip-norm 0.0 \
- --lr 0.001 --lr-scheduler inverse_sqrt --warmup-updates 4000 \
- --max-tokens 3584 --update-freq 16 \
- --max-update 30000 \
- --save-dir $CHECKPOINT_DIR
-# Note: the above command assumes 8 GPUs. Adjust `--update-freq` if you have a
-# different number of GPUs.
-```
-
-Average the last 10 checkpoints:
-```bash
-python scripts/average_checkpoints.py \
- --inputs $CHECKPOINT_DIR \
- --num-epoch-checkpoints 10 \
- --output $CHECKPOINT_DIR/checkpoint.avg10.pt
-```
-
-Evaluate BLEU:
-```bash
-# tokenized BLEU on newstest2017:
-bash examples/backtranslation/tokenized_bleu.sh \
- wmt17 \
- en-de \
- data-bin/wmt18_en_de \
- data-bin/wmt18_en_de/code \
- $CHECKPOINT_DIR/checkpoint.avg10.pt
-# BLEU4 = 29.57, 60.9/35.4/22.9/15.5 (BP=1.000, ratio=1.014, syslen=63049, reflen=62152)
-# compare to 29.46 in Table 1, which is also for tokenized BLEU
-
-# generally it's better to report (detokenized) sacrebleu though:
-bash examples/backtranslation/sacrebleu.sh \
- wmt17 \
- en-de \
- data-bin/wmt18_en_de \
- data-bin/wmt18_en_de/code \
- $CHECKPOINT_DIR/checkpoint.avg10.pt
-# BLEU+case.mixed+lang.en-de+numrefs.1+smooth.exp+test.wmt17+tok.13a+version.1.4.3 = 29.0 60.6/34.7/22.4/14.9 (BP = 1.000 ratio = 1.013 hyp_len = 62099 ref_len = 61287)
-```
-
-
-#### Step 2. Back-translate monolingual German data
-
-Train a reverse model (German-English) to do the back-translation:
-```bash
-CHECKPOINT_DIR=checkpoints_de_en_parallel
-fairseq-train --fp16 \
- data-bin/wmt18_en_de \
- --source-lang de --target-lang en \
- --arch transformer_wmt_en_de_big --share-all-embeddings \
- --dropout 0.3 --weight-decay 0.0 \
- --criterion label_smoothed_cross_entropy --label-smoothing 0.1 \
- --optimizer adam --adam-betas '(0.9, 0.98)' --clip-norm 0.0 \
- --lr 0.001 --lr-scheduler inverse_sqrt --warmup-updates 4000 \
- --max-tokens 3584 --update-freq 16 \
- --max-update 30000 \
- --save-dir $CHECKPOINT_DIR
-# Note: the above command assumes 8 GPUs. Adjust `--update-freq` if you have a
-# different number of GPUs.
-```
-
-Let's evaluate the back-translation (BT) model to make sure it is well trained:
-```bash
-bash examples/backtranslation/sacrebleu.sh \
- wmt17 \
- de-en \
- data-bin/wmt18_en_de \
- data-bin/wmt18_en_de/code \
- $CHECKPOINT_DIR/checkpoint_best.py
-# BLEU+case.mixed+lang.de-en+numrefs.1+smooth.exp+test.wmt17+tok.13a+version.1.4.3 = 34.9 66.9/41.8/28.5/19.9 (BP = 0.983 ratio = 0.984 hyp_len = 63342 ref_len = 64399)
-# compare to the best system from WMT'17 which scored 35.1: http://matrix.statmt.org/matrix/systems_list/1868
-```
-
-Next prepare the monolingual data:
-```bash
-# Download and prepare the monolingual data
-# By default the script samples 25M monolingual sentences, which after
-# deduplication should be just over 24M sentences. These are split into 25
-# shards, each with 1M sentences (except for the last shard).
-cd examples/backtranslation/
-bash prepare-de-monolingual.sh
-cd ../..
-
-# Binarize each shard of the monolingual data
-TEXT=examples/backtranslation/wmt18_de_mono
-for SHARD in $(seq -f "%02g" 0 24); do \
- fairseq-preprocess \
- --only-source \
- --source-lang de --target-lang en \
- --joined-dictionary \
- --srcdict data-bin/wmt18_en_de/dict.de.txt \
- --testpref $TEXT/bpe.monolingual.dedup.${SHARD} \
- --destdir data-bin/wmt18_de_mono/shard${SHARD} \
- --workers 20; \
- cp data-bin/wmt18_en_de/dict.en.txt data-bin/wmt18_de_mono/shard${SHARD}/; \
-done
-```
-
-Now we're ready to perform back-translation over the monolingual data. The
-following command generates via sampling, but it's possible to use greedy
-decoding (`--beam 1`), beam search (`--beam 5`),
-top-k sampling (`--sampling --beam 1 --sampling-topk 10`), etc.:
-```bash
-mkdir backtranslation_output
-for SHARD in $(seq -f "%02g" 0 24); do \
- fairseq-generate --fp16 \
- data-bin/wmt18_de_mono/shard${SHARD} \
- --path $CHECKPOINT_DIR/checkpoint_best.pt \
- --skip-invalid-size-inputs-valid-test \
- --max-tokens 4096 \
- --sampling --beam 1 \
- > backtranslation_output/sampling.shard${SHARD}.out; \
-done
-```
-
-After BT, use the `extract_bt_data.py` script to re-combine the shards, extract
-the back-translations and apply length ratio filters:
-```bash
-python examples/backtranslation/extract_bt_data.py \
- --minlen 1 --maxlen 250 --ratio 1.5 \
- --output backtranslation_output/bt_data --srclang en --tgtlang de \
- backtranslation_output/sampling.shard*.out
-
-# Ensure lengths are the same:
-# wc -l backtranslation_output/bt_data.{en,de}
-# 21795614 backtranslation_output/bt_data.en
-# 21795614 backtranslation_output/bt_data.de
-# 43591228 total
-```
-
-Binarize the filtered BT data and combine it with the parallel data:
-```bash
-TEXT=backtranslation_output
-fairseq-preprocess \
- --source-lang en --target-lang de \
- --joined-dictionary \
- --srcdict data-bin/wmt18_en_de/dict.en.txt \
- --trainpref $TEXT/bt_data \
- --destdir data-bin/wmt18_en_de_bt \
- --workers 20
-
-# We want to train on the combined data, so we'll symlink the parallel + BT data
-# in the wmt18_en_de_para_plus_bt directory. We link the parallel data as "train"
-# and the BT data as "train1", so that fairseq will combine them automatically
-# and so that we can use the `--upsample-primary` option to upsample the
-# parallel data (if desired).
-PARA_DATA=$(readlink -f data-bin/wmt18_en_de)
-BT_DATA=$(readlink -f data-bin/wmt18_en_de_bt)
-COMB_DATA=data-bin/wmt18_en_de_para_plus_bt
-mkdir -p $COMB_DATA
-for LANG in en de; do \
- ln -s ${PARA_DATA}/dict.$LANG.txt ${COMB_DATA}/dict.$LANG.txt; \
- for EXT in bin idx; do \
- ln -s ${PARA_DATA}/train.en-de.$LANG.$EXT ${COMB_DATA}/train.en-de.$LANG.$EXT; \
- ln -s ${BT_DATA}/train.en-de.$LANG.$EXT ${COMB_DATA}/train1.en-de.$LANG.$EXT; \
- ln -s ${PARA_DATA}/valid.en-de.$LANG.$EXT ${COMB_DATA}/valid.en-de.$LANG.$EXT; \
- ln -s ${PARA_DATA}/test.en-de.$LANG.$EXT ${COMB_DATA}/test.en-de.$LANG.$EXT; \
- done; \
-done
-```
-
-
-#### 3. Train an English-German model over the combined parallel + BT data
-
-Finally we can train a model over the parallel + BT data:
-```bash
-CHECKPOINT_DIR=checkpoints_en_de_parallel_plus_bt
-fairseq-train --fp16 \
- data-bin/wmt18_en_de_para_plus_bt \
- --upsample-primary 16 \
- --source-lang en --target-lang de \
- --arch transformer_wmt_en_de_big --share-all-embeddings \
- --dropout 0.3 --weight-decay 0.0 \
- --criterion label_smoothed_cross_entropy --label-smoothing 0.1 \
- --optimizer adam --adam-betas '(0.9, 0.98)' --clip-norm 0.0 \
- --lr 0.0007 --lr-scheduler inverse_sqrt --warmup-updates 4000 \
- --max-tokens 3584 --update-freq 16 \
- --max-update 100000 \
- --save-dir $CHECKPOINT_DIR
-# Note: the above command assumes 8 GPUs. Adjust `--update-freq` if you have a
-# different number of GPUs.
-```
-
-Average the last 10 checkpoints:
-```bash
-python scripts/average_checkpoints.py \
- --inputs $CHECKPOINT_DIR \
- --num-epoch-checkpoints 10 \
- --output $CHECKPOINT_DIR/checkpoint.avg10.pt
-```
-
-Evaluate BLEU:
-```bash
-# tokenized BLEU on newstest2017:
-bash examples/backtranslation/tokenized_bleu.sh \
- wmt17 \
- en-de \
- data-bin/wmt18_en_de \
- data-bin/wmt18_en_de/code \
- $CHECKPOINT_DIR/checkpoint.avg10.pt
-# BLEU4 = 32.35, 64.4/38.9/26.2/18.3 (BP=0.977, ratio=0.977, syslen=60729, reflen=62152)
-# compare to 32.35 in Table 1, which is also for tokenized BLEU
-
-# generally it's better to report (detokenized) sacrebleu:
-bash examples/backtranslation/sacrebleu.sh \
- wmt17 \
- en-de \
- data-bin/wmt18_en_de \
- data-bin/wmt18_en_de/code \
- $CHECKPOINT_DIR/checkpoint.avg10.pt
-# BLEU+case.mixed+lang.en-de+numrefs.1+smooth.exp+test.wmt17+tok.13a+version.1.4.3 = 31.5 64.3/38.2/25.6/17.6 (BP = 0.971 ratio = 0.971 hyp_len = 59515 ref_len = 61287)
-```
-
-
-## Citation
-```bibtex
-@inproceedings{edunov2018backtranslation,
- title = {Understanding Back-Translation at Scale},
- author = {Edunov, Sergey and Ott, Myle and Auli, Michael and Grangier, David},
- booktitle = {Conference of the Association for Computational Linguistics (ACL)},
- year = 2018,
-}
-```
diff --git a/spaces/ICML2022/OFA/fairseq/examples/criss/unsupervised_mt/eval.sh b/spaces/ICML2022/OFA/fairseq/examples/criss/unsupervised_mt/eval.sh
deleted file mode 100644
index 03b773ed5a522eb82186fea8ffbb6c557e14b6d3..0000000000000000000000000000000000000000
--- a/spaces/ICML2022/OFA/fairseq/examples/criss/unsupervised_mt/eval.sh
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/bin/bash
-# Copyright (c) Facebook, Inc. and its affiliates.
-# All rights reserved.
-#
-# This source code is licensed under the license found in the
-# LICENSE file in the root directory of this source tree.
-#
-SRC=si_LK
-TGT=en_XX
-MODEL=criss_checkpoints/criss.3rd.pt
-
-MULTIBLEU=mosesdecoder/scripts/generic/multi-bleu.perl
-MOSES=mosesdecoder
-REPLACE_UNICODE_PUNCT=$MOSES/scripts/tokenizer/replace-unicode-punctuation.perl
-NORM_PUNC=$MOSES/scripts/tokenizer/normalize-punctuation.perl
-REM_NON_PRINT_CHAR=$MOSES/scripts/tokenizer/remove-non-printing-char.perl
-TOKENIZER=$MOSES/scripts/tokenizer/tokenizer.perl
-GEN_TMP_DIR=gen_tmp
-LANG_DICT=criss_checkpoints/lang_dict.txt
-
-if [ ! -d "mosesdecoder" ]; then
- git clone https://github.com/moses-smt/mosesdecoder
-fi
-mkdir -p $GEN_TMP_DIR
-fairseq-generate data_tmp/${SRC}-${TGT}-flores \
- --task translation_multi_simple_epoch \
- --max-tokens 2000 \
- --path ${MODEL} \
- --skip-invalid-size-inputs-valid-test \
- --beam 5 --lenpen 1.0 --gen-subset test \
- --remove-bpe=sentencepiece \
- --source-lang ${SRC} --target-lang ${TGT} \
- --decoder-langtok --lang-pairs 'en_XX-ar_AR,en_XX-de_DE,en_XX-es_XX,en_XX-fr_XX,en_XX-hi_IN,en_XX-it_IT,en_XX-ja_XX,en_XX-ko_KR,en_XX-nl_XX,en_XX-ru_RU,en_XX-zh_CN,en_XX-tr_TR,en_XX-vi_VN,en_XX-ro_RO,en_XX-my_MM,en_XX-ne_NP,en_XX-si_LK,en_XX-cs_CZ,en_XX-lt_LT,en_XX-kk_KZ,en_XX-gu_IN,en_XX-fi_FI,en_XX-et_EE,en_XX-lv_LV,ar_AR-en_XX,cs_CZ-en_XX,de_DE-en_XX,es_XX-en_XX,et_EE-en_XX,fi_FI-en_XX,fr_XX-en_XX,gu_IN-en_XX,hi_IN-en_XX,it_IT-en_XX,ja_XX-en_XX,kk_KZ-en_XX,ko_KR-en_XX,lt_LT-en_XX,lv_LV-en_XX,my_MM-en_XX,ne_NP-en_XX,nl_XX-en_XX,ro_RO-en_XX,ru_RU-en_XX,si_LK-en_XX,tr_TR-en_XX,vi_VN-en_XX,zh_CN-en_XX,ar_AR-es_XX,es_XX-ar_AR,ar_AR-hi_IN,hi_IN-ar_AR,ar_AR-zh_CN,zh_CN-ar_AR,cs_CZ-es_XX,es_XX-cs_CZ,cs_CZ-hi_IN,hi_IN-cs_CZ,cs_CZ-zh_CN,zh_CN-cs_CZ,de_DE-es_XX,es_XX-de_DE,de_DE-hi_IN,hi_IN-de_DE,de_DE-zh_CN,zh_CN-de_DE,es_XX-hi_IN,hi_IN-es_XX,es_XX-zh_CN,zh_CN-es_XX,et_EE-es_XX,es_XX-et_EE,et_EE-hi_IN,hi_IN-et_EE,et_EE-zh_CN,zh_CN-et_EE,fi_FI-es_XX,es_XX-fi_FI,fi_FI-hi_IN,hi_IN-fi_FI,fi_FI-zh_CN,zh_CN-fi_FI,fr_XX-es_XX,es_XX-fr_XX,fr_XX-hi_IN,hi_IN-fr_XX,fr_XX-zh_CN,zh_CN-fr_XX,gu_IN-es_XX,es_XX-gu_IN,gu_IN-hi_IN,hi_IN-gu_IN,gu_IN-zh_CN,zh_CN-gu_IN,hi_IN-zh_CN,zh_CN-hi_IN,it_IT-es_XX,es_XX-it_IT,it_IT-hi_IN,hi_IN-it_IT,it_IT-zh_CN,zh_CN-it_IT,ja_XX-es_XX,es_XX-ja_XX,ja_XX-hi_IN,hi_IN-ja_XX,ja_XX-zh_CN,zh_CN-ja_XX,kk_KZ-es_XX,es_XX-kk_KZ,kk_KZ-hi_IN,hi_IN-kk_KZ,kk_KZ-zh_CN,zh_CN-kk_KZ,ko_KR-es_XX,es_XX-ko_KR,ko_KR-hi_IN,hi_IN-ko_KR,ko_KR-zh_CN,zh_CN-ko_KR,lt_LT-es_XX,es_XX-lt_LT,lt_LT-hi_IN,hi_IN-lt_LT,lt_LT-zh_CN,zh_CN-lt_LT,lv_LV-es_XX,es_XX-lv_LV,lv_LV-hi_IN,hi_IN-lv_LV,lv_LV-zh_CN,zh_CN-lv_LV,my_MM-es_XX,es_XX-my_MM,my_MM-hi_IN,hi_IN-my_MM,my_MM-zh_CN,zh_CN-my_MM,ne_NP-es_XX,es_XX-ne_NP,ne_NP-hi_IN,hi_IN-ne_NP,ne_NP-zh_CN,zh_CN-ne_NP,nl_XX-es_XX,es_XX-nl_XX,nl_XX-hi_IN,hi_IN-nl_XX,nl_XX-zh_CN,zh_CN-nl_XX,ro_RO-es_XX,es_XX-ro_RO,ro_RO-hi_IN,hi_IN-ro_RO,ro_RO-zh_CN,zh_CN-ro_RO,ru_RU-es_XX,es_XX-ru_RU,ru_RU-hi_IN,hi_IN-ru_RU,ru_RU-zh_CN,zh_CN-ru_RU,si_LK-es_XX,es_XX-si_LK,si_LK-hi_IN,hi_IN-si_LK,si_LK-zh_CN,zh_CN-si_LK,tr_TR-es_XX,es_XX-tr_TR,tr_TR-hi_IN,hi_IN-tr_TR,tr_TR-zh_CN,zh_CN-tr_TR,vi_VN-es_XX,es_XX-vi_VN,vi_VN-hi_IN,hi_IN-vi_VN,vi_VN-zh_CN,zh_CN-vi_VN' \
- --lang-dict ${LANG_DICT} --lang-tok-style 'mbart' --sampling-method 'temperature' --sampling-temperature '1.0' > $GEN_TMP_DIR/${SRC}_${TGT}.gen
-cat $GEN_TMP_DIR/${SRC}_${TGT}.gen | grep -P "^T-" | cut -f2 | $REPLACE_UNICODE_PUNCT | $NORM_PUNC -l ${TGT:0:2} | $REM_NON_PRINT_CHAR | $TOKENIZER -no-escape ${TGT:0:2} > $GEN_TMP_DIR/${SRC}_${TGT}.hyp
-cat $GEN_TMP_DIR/${SRC}_${TGT}.gen | grep -P "^H-" | cut -f3 | $REPLACE_UNICODE_PUNCT | $NORM_PUNC -l ${TGT:0:2} | $REM_NON_PRINT_CHAR | $TOKENIZER -no-escape ${TGT:0:2} > $GEN_TMP_DIR/${SRC}_${TGT}.ref
-${MULTIBLEU} $GEN_TMP_DIR/${SRC}_${TGT}.ref < $GEN_TMP_DIR/${SRC}_${TGT}.hyp
diff --git a/spaces/IcelandAI/Foods-and-Drinks-of-Iceland/README.md b/spaces/IcelandAI/Foods-and-Drinks-of-Iceland/README.md
deleted file mode 100644
index 9ad7617b01eee8b2ca79ee999cbc5d6004eb6cd9..0000000000000000000000000000000000000000
--- a/spaces/IcelandAI/Foods-and-Drinks-of-Iceland/README.md
+++ /dev/null
@@ -1,13 +0,0 @@
----
-title: Foods And Drinks Of Iceland
-emoji: 🚀
-colorFrom: gray
-colorTo: green
-sdk: streamlit
-sdk_version: 1.17.0
-app_file: app.py
-pinned: false
-license: mit
----
-
-Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
diff --git a/spaces/Iqbaljanitra/brandshoesprediction_nike_converse_adidas/README.md b/spaces/Iqbaljanitra/brandshoesprediction_nike_converse_adidas/README.md
deleted file mode 100644
index cd03df6cebebaa11c99ae43562b18fdeb64a1daa..0000000000000000000000000000000000000000
--- a/spaces/Iqbaljanitra/brandshoesprediction_nike_converse_adidas/README.md
+++ /dev/null
@@ -1,12 +0,0 @@
----
-title: Brandshoesprediction Nike Converse Adidas
-emoji: 🐠
-colorFrom: yellow
-colorTo: pink
-sdk: streamlit
-sdk_version: 1.17.0
-app_file: app.py
-pinned: false
----
-
-Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
diff --git a/spaces/Izal887/rvc-ram12/lib/infer_pack/modules/F0Predictor/__init__.py b/spaces/Izal887/rvc-ram12/lib/infer_pack/modules/F0Predictor/__init__.py
deleted file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000
diff --git a/spaces/JUNGU/gpt4kids/README.md b/spaces/JUNGU/gpt4kids/README.md
deleted file mode 100644
index 7903b155e84daf8ecc150f2c64f18aae360ff3ee..0000000000000000000000000000000000000000
--- a/spaces/JUNGU/gpt4kids/README.md
+++ /dev/null
@@ -1,14 +0,0 @@
----
-title: Talktosayno
-emoji: 📉
-colorFrom: green
-colorTo: pink
-sdk: gradio
-sdk_version: 3.34.0
-app_file: app.py
-pinned: false
-license: openrail
-duplicated_from: JUNGU/talktosayno
----
-
-Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
diff --git a/spaces/JeffJing/ZookChatBot/steamship/plugin/outputs/model_checkpoint.py b/spaces/JeffJing/ZookChatBot/steamship/plugin/outputs/model_checkpoint.py
deleted file mode 100644
index 7211818d3381de83098b839b8709ada2367756ee..0000000000000000000000000000000000000000
--- a/spaces/JeffJing/ZookChatBot/steamship/plugin/outputs/model_checkpoint.py
+++ /dev/null
@@ -1,140 +0,0 @@
-import logging
-import tempfile
-from pathlib import Path
-from typing import ClassVar, Optional
-
-from steamship import Steamship, SteamshipError
-from steamship.base.client import Client
-from steamship.base.model import CamelModel
-from steamship.data.workspace import SignedUrl, Workspace
-from steamship.utils.signed_urls import download_from_signed_url, upload_to_signed_url
-from steamship.utils.zip_archives import unzip_folder, zip_folder
-
-
-class ModelCheckpoint(CamelModel):
- # The default model checkpoint handle unless one is provided.
- DEFAULT_HANDLE: ClassVar[str] = "default"
-
- """Represents the saved state of a trained PluginInstance.
- """
- client: Client
- workspace: Optional[Workspace] = None
- plugin_instance_id: str
-
- parent_directory: Optional[Path] = None # e.g. /tmp
- handle: str = None # The handle of this ModelCheckpoint.
- plugin_instance_id: str = None #
-
- def __init__(
- self,
- client: Steamship,
- parent_directory: Optional[Path] = None,
- handle: str = DEFAULT_HANDLE,
- plugin_instance_id: str = None,
- ):
- super().__init__(
- client=client,
- parent_directory=parent_directory,
- plugin_instance_id=plugin_instance_id,
- handle=handle or ModelCheckpoint.DEFAULT_HANDLE,
- )
-
- if self.plugin_instance_id is None:
- raise SteamshipError("Null plugin_instance_id provided ModelCheckpoint")
-
- self.workspace = client.get_workspace()
-
- if parent_directory is None:
- # TODO(ted): We may want to not use a tempdir so that we can cache it.
- self.parent_directory = Path(tempfile.mkdtemp())
-
- # Create the folder path on disk.
- logging.info(f"Making sure Checkpoint path exists: {self.folder_path_on_disk()}")
- self.folder_path_on_disk().mkdir(parents=True, exist_ok=True)
-
- def folder_path_on_disk(self) -> Path:
- """Returns the path to this checkpoint on the local disk.
-
- On disk, the model checkpoint is the folder:
- `{parent_directory}/{checkpoint_handle}/`
- """
- return self.parent_directory / Path(self.handle)
-
- def archive_path_on_disk(self) -> Path:
- """Returns the path to the checkpoint archive on disk.
-
- On disk, the model checkpoint is the folder:
- `{parent_directory}/{checkpoint_handle}.zip`
- """
- return self.parent_directory / Path(f"{self.handle}.zip")
-
- def archive_path_in_steamship(self, as_handle: str = None) -> str:
- """Returns the path to the checkpoint archive on Steamship.
-
- On steamship, the checkpoint is archived in the Workspace's PluginInstance bucket as:
- `{plugin_instance_bucket}/{plugin_instance_id}/{checkpoint_handle}.zip`
-
- Here we only return the following path since the bucket is specified separately
- in the required Steamship API calls: `{plugin_instance_id}/{checkpoint_handle}.zip`
- """
- return f"{self.plugin_instance_id}/{as_handle or self.handle}.zip"
-
- def download_model_bundle(self) -> Path:
- """Download's the model from Steamship and unzips to `parent_directory`"""
- download_resp = self.workspace.create_signed_url(
- SignedUrl.Request(
- bucket=SignedUrl.Bucket.PLUGIN_DATA,
- filepath=self.archive_path_in_steamship(),
- operation=SignedUrl.Operation.READ,
- )
- )
- if not download_resp or not download_resp.signed_url:
- raise SteamshipError(
- message=f"Received empty Signed URL for model download of '{self.handle}."
- )
- download_from_signed_url(download_resp.signed_url, to_file=self.archive_path_on_disk())
- unzip_folder(self.archive_path_on_disk(), into_folder=self.folder_path_on_disk())
- if not download_resp or not download_resp.signed_url:
- raise SteamshipError(
- message=f"Received empty Signed URL for model download of '{self.handle}."
- )
- download_from_signed_url(download_resp.signed_url, to_file=self.archive_path_on_disk())
- unzip_folder(self.archive_path_on_disk(), into_folder=self.folder_path_on_disk())
- return self.folder_path_on_disk()
-
- def _upload_model_zip(self, as_handle: str = None):
- """Assumes a pre-zipped model, uploads to the requested zip.
-
- This is an internal function. Please use upload_model_bundle as an caller."""
- logging.info(f"ModelCheckpoint:_upload_model_zip - handle={as_handle}")
- signed_url_resp = self.workspace.create_signed_url(
- SignedUrl.Request(
- bucket=SignedUrl.Bucket.PLUGIN_DATA,
- filepath=self.archive_path_in_steamship(as_handle=as_handle),
- operation=SignedUrl.Operation.WRITE,
- )
- )
-
- if not signed_url_resp:
- raise SteamshipError(
- message="Empty result on Signed URL request while uploading model checkpoint"
- )
- if not signed_url_resp.signed_url:
- raise SteamshipError(
- message="Empty signedUrl on Signed URL request while uploading model checkpoint"
- )
-
- upload_to_signed_url(signed_url_resp.signed_url, filepath=self.archive_path_on_disk())
-
- def upload_model_bundle(self, set_as_default: bool = True):
- """Zips and uploads the Model to steamship"""
- logging.info("ModelCheckpoint:upload_model_bundle")
- zip_folder(self.folder_path_on_disk(), into_file=self.archive_path_on_disk())
- self._upload_model_zip()
-
- if set_as_default:
- # For simplicity, we'll assume the checkpoint named `default` is the one to be loaded unless otherwise
- # specified. This means that we need to double-upload some checkpoints:
- # - Once under the actual checkpoint name (e.g. `epoch-10`)
- # - Again under the name: default
- self._upload_model_zip(as_handle=ModelCheckpoint.DEFAULT_HANDLE)
diff --git a/spaces/Jesuscriss301/prueba/app.py b/spaces/Jesuscriss301/prueba/app.py
deleted file mode 100644
index f12964b627c76ac565b1115d16b0d4a707c78476..0000000000000000000000000000000000000000
--- a/spaces/Jesuscriss301/prueba/app.py
+++ /dev/null
@@ -1,38 +0,0 @@
-#Librerias para cargar imagenes
-import numpy as np
-from keras.preprocessing.image import load_img, img_to_array
-from keras.models import load_model
-import streamlit as st
-
-dim = 200
-modelo = './modelo.h5'
-pesos = './pesos.h5'
-cnn = load_model(modelo)
-cnn.load_weights(pesos)
-
-st.title("Upload + Classification Example")
-uploaded_file = st.file_uploader("Choose an image...", type="jpg")
-if uploaded_file is not None:
- image = Image.open(uploaded_file)
- st.image(image, caption='Uploaded Image.', use_column_width=True)
- st.write("")
- st.write("Classifying...")
- label = predict(uploaded_file) ##aqui va el llamado a la IA
- st.write('%s (%.2f%%)' % (label[1], label[2]*100))
-
-def clasificar(uploaded_file):
- x = load_img(uploaded_file, target_size=(dim, dim), color_mode = "grayscale")
- x = img_to_array(x)
- x = np.expand_dims(x, axis=0)
- arreglo = cnn.predict(x)
- resultado = arreglo[0]
- respuesta = np.argmax(resultado)
-
- if respuesta==0:
- print('NORMAL')
- else:
- print('TUMOR CEREBRAL')
-
- return respuesta
-
-clasificar(uploaded_file)
\ No newline at end of file
diff --git a/spaces/JohnnyPittt/audio-styling/deepafx_st/system.py b/spaces/JohnnyPittt/audio-styling/deepafx_st/system.py
deleted file mode 100644
index 449afa586bf80bbafd858999670a2c364c6a9c2b..0000000000000000000000000000000000000000
--- a/spaces/JohnnyPittt/audio-styling/deepafx_st/system.py
+++ /dev/null
@@ -1,563 +0,0 @@
-import torch
-import auraloss
-import torchaudio
-from itertools import chain
-import pytorch_lightning as pl
-from argparse import ArgumentParser
-from typing import Tuple, List, Dict
-
-import deepafx_st.utils as utils
-from deepafx_st.utils import DSPMode
-from deepafx_st.data.dataset import AudioDataset
-from deepafx_st.models.encoder import SpectralEncoder
-from deepafx_st.models.controller import StyleTransferController
-from deepafx_st.processors.spsa.channel import SPSAChannel
-from deepafx_st.processors.spsa.eps_scheduler import EpsilonScheduler
-from deepafx_st.processors.proxy.channel import ProxyChannel
-from deepafx_st.processors.autodiff.channel import AutodiffChannel
-
-
-class System(pl.LightningModule):
- def __init__(
- self,
- ext="wav",
- dsp_sample_rate=24000,
- **kwargs,
- ):
- super().__init__()
- self.save_hyperparameters()
-
- self.eps_scheduler = EpsilonScheduler(
- self.hparams.spsa_epsilon,
- self.hparams.spsa_patience,
- self.hparams.spsa_factor,
- self.hparams.spsa_verbose,
- )
-
- self.hparams.dsp_mode = DSPMode.NONE
-
- # first construct the processor, since this will dictate encoder
- if self.hparams.processor_model == "spsa":
- self.processor = SPSAChannel(
- self.hparams.dsp_sample_rate,
- self.hparams.spsa_parallel,
- self.hparams.batch_size,
- )
- elif self.hparams.processor_model == "autodiff":
- self.processor = AutodiffChannel(self.hparams.dsp_sample_rate)
- elif self.hparams.processor_model == "proxy0":
- # print('self.hparams.proxy_ckpts,',self.hparams.proxy_ckpts)
- self.hparams.dsp_mode = DSPMode.NONE
- self.processor = ProxyChannel(
- self.hparams.proxy_ckpts,
- self.hparams.freeze_proxies,
- self.hparams.dsp_mode,
- sample_rate=self.hparams.dsp_sample_rate,
- )
- elif self.hparams.processor_model == "proxy1":
- # print('self.hparams.proxy_ckpts,',self.hparams.proxy_ckpts)
- self.hparams.dsp_mode = DSPMode.INFER
- self.processor = ProxyChannel(
- self.hparams.proxy_ckpts,
- self.hparams.freeze_proxies,
- self.hparams.dsp_mode,
- sample_rate=self.hparams.dsp_sample_rate,
- )
- elif self.hparams.processor_model == "proxy2":
- # print('self.hparams.proxy_ckpts,',self.hparams.proxy_ckpts)
- self.hparams.dsp_mode = DSPMode.TRAIN_INFER
- self.processor = ProxyChannel(
- self.hparams.proxy_ckpts,
- self.hparams.freeze_proxies,
- self.hparams.dsp_mode,
- sample_rate=self.hparams.dsp_sample_rate,
- )
- elif self.hparams.processor_model == "tcn1":
- # self.processor = ConditionalTCN(self.hparams.sample_rate)
- self.hparams.dsp_mode = DSPMode.NONE
- self.processor = ProxyChannel(
- [],
- freeze_proxies=False,
- dsp_mode=self.hparams.dsp_mode,
- tcn_nblocks=self.hparams.tcn_nblocks,
- tcn_dilation_growth=self.hparams.tcn_dilation_growth,
- tcn_channel_width=self.hparams.tcn_channel_width,
- tcn_kernel_size=self.hparams.tcn_kernel_size,
- num_tcns=1,
- sample_rate=self.hparams.sample_rate,
- )
- elif self.hparams.processor_model == "tcn2":
- self.hparams.dsp_mode = DSPMode.NONE
- self.processor = ProxyChannel(
- [],
- freeze_proxies=False,
- dsp_mode=self.hparams.dsp_mode,
- tcn_nblocks=self.hparams.tcn_nblocks,
- tcn_dilation_growth=self.hparams.tcn_dilation_growth,
- tcn_channel_width=self.hparams.tcn_channel_width,
- tcn_kernel_size=self.hparams.tcn_kernel_size,
- num_tcns=2,
- sample_rate=self.hparams.sample_rate,
- )
- else:
- raise ValueError(f"Invalid processor_model: {self.hparams.processor_model}")
-
- if self.hparams.encoder_ckpt is not None:
- # load encoder weights from a pre-trained system
- system = System.load_from_checkpoint(self.hparams.encoder_ckpt)
- self.encoder = system.encoder
- self.hparams.encoder_embed_dim = system.encoder.embed_dim
- else:
- self.encoder = SpectralEncoder(
- self.processor.num_control_params,
- self.hparams.sample_rate,
- encoder_model=self.hparams.encoder_model,
- embed_dim=self.hparams.encoder_embed_dim,
- width_mult=self.hparams.encoder_width_mult,
- )
-
- if self.hparams.encoder_freeze:
- for param in self.encoder.parameters():
- param.requires_grad = False
-
- self.controller = StyleTransferController(
- self.processor.num_control_params,
- self.hparams.encoder_embed_dim,
- )
-
- if len(self.hparams.recon_losses) != len(self.hparams.recon_loss_weights):
- raise ValueError("Must supply same number of weights as losses.")
-
- self.recon_losses = torch.nn.ModuleDict()
- for recon_loss in self.hparams.recon_losses:
- if recon_loss == "mrstft":
- self.recon_losses[recon_loss] = auraloss.freq.MultiResolutionSTFTLoss(
- fft_sizes=[32, 128, 512, 2048, 8192, 32768],
- hop_sizes=[16, 64, 256, 1024, 4096, 16384],
- win_lengths=[32, 128, 512, 2048, 8192, 32768],
- w_sc=0.0,
- w_phs=0.0,
- w_lin_mag=1.0,
- w_log_mag=1.0,
- )
- elif recon_loss == "mrstft-md":
- self.recon_losses[recon_loss] = auraloss.freq.MultiResolutionSTFTLoss(
- fft_sizes=[128, 512, 2048, 8192],
- hop_sizes=[32, 128, 512, 2048], # 1 / 4
- win_lengths=[128, 512, 2048, 8192],
- w_sc=0.0,
- w_phs=0.0,
- w_lin_mag=1.0,
- w_log_mag=1.0,
- )
- elif recon_loss == "mrstft-sm":
- self.recon_losses[recon_loss] = auraloss.freq.MultiResolutionSTFTLoss(
- fft_sizes=[512, 2048, 8192],
- hop_sizes=[256, 1024, 4096], # 1 / 4
- win_lengths=[512, 2048, 8192],
- w_sc=0.0,
- w_phs=0.0,
- w_lin_mag=1.0,
- w_log_mag=1.0,
- )
- elif recon_loss == "melfft":
- self.recon_losses[recon_loss] = auraloss.freq.MelSTFTLoss(
- self.hparams.sample_rate,
- fft_size=self.hparams.train_length,
- hop_size=self.hparams.train_length // 2,
- win_length=self.hparams.train_length,
- n_mels=128,
- w_sc=0.0,
- device="cuda" if self.hparams.gpus > 0 else "cpu",
- )
- elif recon_loss == "melstft":
- self.recon_losses[recon_loss] = auraloss.freq.MelSTFTLoss(
- self.hparams.sample_rate,
- device="cuda" if self.hparams.gpus > 0 else "cpu",
- )
- elif recon_loss == "l1":
- self.recon_losses[recon_loss] = torch.nn.L1Loss()
- elif recon_loss == "sisdr":
- self.recon_losses[recon_loss] = auraloss.time.SISDRLoss()
- else:
- raise ValueError(
- f"Invalid reconstruction loss: {self.hparams.recon_losses}"
- )
-
- def forward(
- self,
- x: torch.Tensor,
- y: torch.Tensor = None,
- e_y: torch.Tensor = None,
- z: torch.Tensor = None,
- dsp_mode: DSPMode = DSPMode.NONE,
- analysis_length: int = 0,
- sample_rate: int = 24000,
- ):
- """Forward pass through the system subnetworks.
-
- Args:
- x (tensor): Input audio tensor with shape (batch x 1 x samples)
- y (tensor): Target audio tensor with shape (batch x 1 x samples)
- e_y (tensor): Target embedding with shape (batch x edim)
- z (tensor): Bottleneck latent.
- dsp_mode (DSPMode): Mode of operation for the DSP blocks.
- analysis_length (optional, int): Only analyze the first N samples.
- sample_rate (optional, int): Desired sampling rate for the DSP blocks.
-
- You must supply target audio `y`, `z`, or an embedding for the target `e_y`.
-
- Returns:
- y_hat (tensor): Output audio.
- p (tensor):
- e (tensor):
-
- """
- bs, chs, samp = x.size()
-
- if sample_rate != self.hparams.sample_rate:
- x_enc = torchaudio.transforms.Resample(
- sample_rate, self.hparams.sample_rate
- ).to(x.device)(x)
- if y is not None:
- y_enc = torchaudio.transforms.Resample(
- sample_rate, self.hparams.sample_rate
- ).to(x.device)(y)
- else:
- x_enc = x
- y_enc = y
-
- if analysis_length > 0:
- x_enc = x_enc[..., :analysis_length]
- if y is not None:
- y_enc = y_enc[..., :analysis_length]
-
- e_x = self.encoder(x_enc) # generate latent embedding for input
-
- if y is not None:
- e_y = self.encoder(y_enc) # generate latent embedding for target
- elif e_y is None:
- raise RuntimeError("Must supply y, z, or e_y. None supplied.")
-
- # learnable comparision
- p = self.controller(e_x, e_y, z=z)
-
- # process audio conditioned on parameters
- # if there are multiple channels process them using same parameters
- y_hat = torch.zeros(x.shape).type_as(x)
- for ch_idx in range(chs):
- y_hat_ch = self.processor(
- x[:, ch_idx : ch_idx + 1, :],
- p,
- epsilon=self.eps_scheduler.epsilon,
- dsp_mode=dsp_mode,
- sample_rate=sample_rate,
- )
- y_hat[:, ch_idx : ch_idx + 1, :] = y_hat_ch
-
- return y_hat, p, e_x
-
- def common_paired_step(
- self,
- batch: Tuple,
- batch_idx: int,
- optimizer_idx: int = 0,
- train: bool = False,
- ):
- """Model step used for validation and training.
-
- Args:
- batch (Tuple[Tensor, Tensor]): Batch items containing input audio (x) and target audio (y).
- batch_idx (int): Index of the batch within the current epoch.
- optimizer_idx (int): Index of the optimizer, this step is called once for each optimizer.
- The firs optimizer corresponds to the generator and the second optimizer,
- corresponds to the adversarial loss (when in use).
- train (bool): Whether step is called during training (True) or validation (False).
- """
- x, y = batch
- loss = 0
- dsp_mode = self.hparams.dsp_mode
-
- if train and dsp_mode.INFER.name == DSPMode.INFER.name:
- dsp_mode = DSPMode.NONE
-
- # proces input audio through model
- if self.hparams.style_transfer:
- length = x.shape[-1]
-
- x_A = x[..., : length // 2]
- x_B = x[..., length // 2 :]
-
- y_A = y[..., : length // 2]
- y_B = y[..., length // 2 :]
-
- if torch.rand(1).sum() > 0.5:
- y_ref = y_B
- y = y_A
- x = x_A
- else:
- y_ref = y_A
- y = y_B
- x = x_B
-
- y_hat, p, e = self(x, y=y_ref, dsp_mode=dsp_mode)
- else:
- y_ref = None
- y_hat, p, e = self(x, dsp_mode=dsp_mode)
-
- # compute reconstruction loss terms
- for loss_idx, (loss_name, recon_loss_fn) in enumerate(
- self.recon_losses.items()
- ):
- temp_loss = recon_loss_fn(y_hat, y) # reconstruction loss
- loss += float(self.hparams.recon_loss_weights[loss_idx]) * temp_loss
-
- self.log(
- ("train" if train else "val") + f"_loss/{loss_name}",
- temp_loss,
- on_step=True,
- on_epoch=True,
- prog_bar=False,
- logger=True,
- sync_dist=True,
- )
-
- # log the overall aggregate loss
- self.log(
- ("train" if train else "val") + "_loss/loss",
- loss,
- on_step=True,
- on_epoch=True,
- prog_bar=False,
- logger=True,
- sync_dist=True,
- )
-
- # store audio data
- data_dict = {
- "x": x.cpu(),
- "y": y.cpu(),
- "p": p.cpu(),
- "e": e.cpu(),
- "y_hat": y_hat.cpu(),
- }
-
- if y_ref is not None:
- data_dict["y_ref"] = y_ref.cpu()
-
- return loss, data_dict
-
- def training_step(self, batch, batch_idx, optimizer_idx=0):
- loss, _ = self.common_paired_step(
- batch,
- batch_idx,
- optimizer_idx,
- train=True,
- )
-
- return loss
-
- def training_epoch_end(self, training_step_outputs):
- if self.hparams.spsa_schedule and self.hparams.processor_model == "spsa":
- self.eps_scheduler.step(
- self.trainer.callback_metrics[self.hparams.train_monitor],
- )
-
- def validation_step(self, batch, batch_idx):
- loss, data_dict = self.common_paired_step(batch, batch_idx)
-
- return data_dict
-
- def optimizer_step(
- self,
- epoch,
- batch_idx,
- optimizer,
- optimizer_idx,
- optimizer_closure,
- on_tpu=False,
- using_native_amp=False,
- using_lbfgs=False,
- ):
- if optimizer_idx == 0:
- optimizer.step(closure=optimizer_closure)
-
- def configure_optimizers(self):
- # we need additional optimizer for the discriminator
- optimizers = []
- g_optimizer = torch.optim.Adam(
- chain(
- self.encoder.parameters(),
- self.processor.parameters(),
- self.controller.parameters(),
- ),
- lr=self.hparams.lr,
- betas=(0.9, 0.999),
- )
- optimizers.append(g_optimizer)
-
- g_scheduler = torch.optim.lr_scheduler.ReduceLROnPlateau(
- g_optimizer,
- patience=self.hparams.lr_patience,
- verbose=True,
- )
- ms1 = int(self.hparams.max_epochs * 0.8)
- ms2 = int(self.hparams.max_epochs * 0.95)
- print(
- "Learning rate schedule:",
- f"0 {self.hparams.lr:0.2e} -> ",
- f"{ms1} {self.hparams.lr*0.1:0.2e} -> ",
- f"{ms2} {self.hparams.lr*0.01:0.2e}",
- )
- g_scheduler = torch.optim.lr_scheduler.MultiStepLR(
- g_optimizer,
- milestones=[ms1, ms2],
- gamma=0.1,
- )
-
- lr_schedulers = {
- "scheduler": g_scheduler,
- }
-
- return optimizers, lr_schedulers
-
- def train_dataloader(self):
-
- train_dataset = AudioDataset(
- self.hparams.audio_dir,
- subset="train",
- train_frac=self.hparams.train_frac,
- half=self.hparams.half,
- length=self.hparams.train_length,
- input_dirs=self.hparams.input_dirs,
- random_scale_input=self.hparams.random_scale_input,
- random_scale_target=self.hparams.random_scale_target,
- buffer_size_gb=self.hparams.buffer_size_gb,
- buffer_reload_rate=self.hparams.buffer_reload_rate,
- num_examples_per_epoch=self.hparams.train_examples_per_epoch,
- augmentations={
- "pitch": {"sr": self.hparams.sample_rate},
- "tempo": {"sr": self.hparams.sample_rate},
- },
- freq_corrupt=self.hparams.freq_corrupt,
- drc_corrupt=self.hparams.drc_corrupt,
- ext=self.hparams.ext,
- )
-
- g = torch.Generator()
- g.manual_seed(0)
-
- return torch.utils.data.DataLoader(
- train_dataset,
- num_workers=self.hparams.num_workers,
- batch_size=self.hparams.batch_size,
- worker_init_fn=utils.seed_worker,
- generator=g,
- pin_memory=True,
- persistent_workers=True,
- timeout=60,
- )
-
- def val_dataloader(self):
-
- val_dataset = AudioDataset(
- self.hparams.audio_dir,
- subset="val",
- half=self.hparams.half,
- train_frac=self.hparams.train_frac,
- length=self.hparams.val_length,
- input_dirs=self.hparams.input_dirs,
- buffer_size_gb=self.hparams.buffer_size_gb,
- buffer_reload_rate=self.hparams.buffer_reload_rate,
- random_scale_input=self.hparams.random_scale_input,
- random_scale_target=self.hparams.random_scale_target,
- num_examples_per_epoch=self.hparams.val_examples_per_epoch,
- augmentations={},
- freq_corrupt=self.hparams.freq_corrupt,
- drc_corrupt=self.hparams.drc_corrupt,
- ext=self.hparams.ext,
- )
-
- self.val_dataset = val_dataset
-
- g = torch.Generator()
- g.manual_seed(0)
-
- return torch.utils.data.DataLoader(
- val_dataset,
- num_workers=1,
- batch_size=self.hparams.batch_size,
- worker_init_fn=utils.seed_worker,
- generator=g,
- pin_memory=True,
- persistent_workers=True,
- timeout=60,
- )
- def shutdown(self):
- del self.processor
-
- # add any model hyperparameters here
- @staticmethod
- def add_model_specific_args(parent_parser):
- parser = ArgumentParser(parents=[parent_parser], add_help=False)
- # --- Training ---
- parser.add_argument("--batch_size", type=int, default=32)
- parser.add_argument("--lr", type=float, default=3e-4)
- parser.add_argument("--lr_patience", type=int, default=20)
- parser.add_argument("--recon_losses", nargs="+", default=["l1"])
- parser.add_argument("--recon_loss_weights", nargs="+", default=[1.0])
- # --- Controller ---
- parser.add_argument(
- "--processor_model",
- type=str,
- help="autodiff, spsa, tcn1, tcn2, proxy0, proxy1, proxy2",
- )
- parser.add_argument("--controller_hidden_dim", type=int, default=256)
- parser.add_argument("--style_transfer", action="store_true")
- # --- Encoder ---
- parser.add_argument("--encoder_model", type=str, default="mobilenet_v2")
- parser.add_argument("--encoder_embed_dim", type=int, default=128)
- parser.add_argument("--encoder_width_mult", type=int, default=2)
- parser.add_argument("--encoder_ckpt", type=str, default=None)
- parser.add_argument("--encoder_freeze", action="store_true", default=False)
- # --- TCN ---
- parser.add_argument("--tcn_causal", action="store_true")
- parser.add_argument("--tcn_nblocks", type=int, default=4)
- parser.add_argument("--tcn_dilation_growth", type=int, default=8)
- parser.add_argument("--tcn_channel_width", type=int, default=32)
- parser.add_argument("--tcn_kernel_size", type=int, default=13)
- # --- SPSA ---
- parser.add_argument("--plugin_config_file", type=str, default=None)
- parser.add_argument("--spsa_epsilon", type=float, default=0.001)
- parser.add_argument("--spsa_schedule", action="store_true")
- parser.add_argument("--spsa_patience", type=int, default=10)
- parser.add_argument("--spsa_verbose", action="store_true")
- parser.add_argument("--spsa_factor", type=float, default=0.5)
- parser.add_argument("--spsa_parallel", action="store_true")
- # --- Proxy ----
- parser.add_argument("--proxy_ckpts", nargs="+")
- parser.add_argument("--freeze_proxies", action="store_true", default=False)
- parser.add_argument("--use_dsp", action="store_true", default=False)
- parser.add_argument("--dsp_mode", choices=DSPMode, type=DSPMode)
- # --- Dataset ---
- parser.add_argument("--audio_dir", type=str)
- parser.add_argument("--ext", type=str, default="wav")
- parser.add_argument("--input_dirs", nargs="+")
- parser.add_argument("--buffer_reload_rate", type=int, default=1000)
- parser.add_argument("--buffer_size_gb", type=float, default=1.0)
- parser.add_argument("--sample_rate", type=int, default=24000)
- parser.add_argument("--dsp_sample_rate", type=int, default=24000)
- parser.add_argument("--shuffle", type=bool, default=True)
- parser.add_argument("--random_scale_input", action="store_true")
- parser.add_argument("--random_scale_target", action="store_true")
- parser.add_argument("--freq_corrupt", action="store_true")
- parser.add_argument("--drc_corrupt", action="store_true")
- parser.add_argument("--train_length", type=int, default=65536)
- parser.add_argument("--train_frac", type=float, default=0.8)
- parser.add_argument("--half", action="store_true")
- parser.add_argument("--train_examples_per_epoch", type=int, default=10000)
- parser.add_argument("--val_length", type=int, default=131072)
- parser.add_argument("--val_examples_per_epoch", type=int, default=1000)
- parser.add_argument("--num_workers", type=int, default=16)
-
- return parser
diff --git a/spaces/KaygNas/cut-it/mocks/index.ts b/spaces/KaygNas/cut-it/mocks/index.ts
deleted file mode 100644
index bccbe9f94b782f98031582b874b50d92c1315d77..0000000000000000000000000000000000000000
--- a/spaces/KaygNas/cut-it/mocks/index.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-// Mock Service Worker is an API mocking library that uses Service Worker API to intercept actual requests.
-// https://mswjs.io/docs/
-import { setupWorker } from 'msw';
-
-import { handlers } from './handlers';
-
-export const worker = setupWorker(...handlers);
diff --git a/spaces/KrishnaBakshi1/YoutubeVideoSummarizer/README.md b/spaces/KrishnaBakshi1/YoutubeVideoSummarizer/README.md
deleted file mode 100644
index e3a1cac07b4de72e15c1d23219e6daea1f7aaf9a..0000000000000000000000000000000000000000
--- a/spaces/KrishnaBakshi1/YoutubeVideoSummarizer/README.md
+++ /dev/null
@@ -1,12 +0,0 @@
----
-title: YoutubeVideoSummarizer
-emoji: 🏢
-colorFrom: gray
-colorTo: indigo
-sdk: gradio
-sdk_version: 3.14.0
-app_file: app.py
-pinned: false
----
-
-Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
diff --git a/spaces/KyanChen/RSPrompter/mmpl/models/backbones/base_backbone.py b/spaces/KyanChen/RSPrompter/mmpl/models/backbones/base_backbone.py
deleted file mode 100644
index 1ed65b7bac50568b5fd9101c967be6f0f43e7ebb..0000000000000000000000000000000000000000
--- a/spaces/KyanChen/RSPrompter/mmpl/models/backbones/base_backbone.py
+++ /dev/null
@@ -1,31 +0,0 @@
-from abc import ABCMeta, abstractmethod
-from mmengine.model import BaseModule
-
-
-class BaseBackbone(BaseModule, metaclass=ABCMeta):
- """Base backbone.
-
- This class defines the basic functions of a backbone. Any backbone that
- inherits this class should at least define its own `forward` function.
- """
-
- def __init__(self, init_cfg=None):
- super(BaseBackbone, self).__init__(init_cfg)
-
- @abstractmethod
- def forward(self, x):
- """Forward computation.
-
- Args:
- x (tensor | tuple[tensor]): x could be a Torch.tensor or a tuple of
- Torch.tensor, containing input data for forward computation.
- """
- pass
-
- def train(self, mode=True):
- """Set module status before forward computation.
-
- Args:
- mode (bool): Whether it is train_mode or test_mode
- """
- super(BaseBackbone, self).train(mode)
diff --git a/spaces/LDJA/iris/app/templates/index_exemple.html b/spaces/LDJA/iris/app/templates/index_exemple.html
deleted file mode 100644
index 382cb2e40634ccacf8b534c576cbe5879da1bf95..0000000000000000000000000000000000000000
--- a/spaces/LDJA/iris/app/templates/index_exemple.html
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
- VIVADATA | Profile
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Hello {{mon_nom}} 👋🙋🕺
-
This is your custom page
-
-
-
-
-
-
-
-
diff --git a/spaces/LamaAl/chatbot/app.py b/spaces/LamaAl/chatbot/app.py
deleted file mode 100644
index 1341c91405966065b5d5dd0e0ed5da8c0141f0ff..0000000000000000000000000000000000000000
--- a/spaces/LamaAl/chatbot/app.py
+++ /dev/null
@@ -1,38 +0,0 @@
-import streamlit as st
-from streamlit_chat import message as st_message
-from transformers import BlenderbotTokenizer
-from transformers import BlenderbotForConditionalGeneration
-
-
-@st.experimental_singleton
-def get_models():
- # pytorch keeps an internal state of the conversation
- model_name = "facebook/blenderbot-400M-distill"
- tokenizer = BlenderbotTokenizer.from_pretrained(model_name)
- model = BlenderbotForConditionalGeneration.from_pretrained(model_name)
- return tokenizer, model
-
-
-if "history" not in st.session_state:
- st.session_state.history = []
-
-st.title("Hello Chatbot")
-
-
-def generate_answer():
- tokenizer, model = get_models()
- user_message = st.session_state.input_text
- inputs = tokenizer(st.session_state.input_text, return_tensors="pt")
- result = model.generate(**inputs)
- message_bot = tokenizer.decode(
- result[0], skip_special_tokens=True
- ) # .replace("", "").replace(" ", "")
-
- st.session_state.history.append({"message": user_message, "is_user": True})
- st.session_state.history.append({"message": message_bot, "is_user": False})
-
-
-st.text_input("Talk to the bot", key="input_text", on_change=generate_answer)
-
-for chat in st.session_state.history:
- st_message(**chat) # unpacking
\ No newline at end of file
diff --git a/spaces/LandonBurlingham/04GR-StoryGen-Memory/app.py b/spaces/LandonBurlingham/04GR-StoryGen-Memory/app.py
deleted file mode 100644
index 087bdd6afad343607b5b1838d7f9c86943f38f57..0000000000000000000000000000000000000000
--- a/spaces/LandonBurlingham/04GR-StoryGen-Memory/app.py
+++ /dev/null
@@ -1,99 +0,0 @@
-import gradio as gr
-import os
-
-# PersistDataset -----
-import os
-import csv
-import gradio as gr
-from gradio import inputs, outputs
-import huggingface_hub
-from huggingface_hub import Repository, hf_hub_download, upload_file
-from datetime import datetime
-
-# created new dataset as awacke1/MindfulStory.csv
-DATASET_REPO_URL = "https://huggingface.co/datasets/awacke1/MindfulStory.csv"
-DATASET_REPO_ID = "awacke1/MindfulStory.csv"
-DATA_FILENAME = "MindfulStory.csv"
-DATA_FILE = os.path.join("data", DATA_FILENAME)
-HF_TOKEN = os.environ.get("HF_TOKEN")
-# Download dataset repo using hub download
-try:
- hf_hub_download(
- repo_id=DATASET_REPO_ID,
- filename=DATA_FILENAME,
- cache_dir=DATA_DIRNAME,
- force_filename=DATA_FILENAME
- )
-except:
- print("file not found")
-
-def AIMemory(title: str, story: str):
- if title and story:
- with open(DATA_FILE, "a") as csvfile:
- writer = csv.DictWriter(csvfile, fieldnames=["title", "story", "time"])
- writer.writerow({"title": title, "story": story, "time": str(datetime.now())})
- commit_url = repo.push_to_hub()
- return ""
-
-
-# Set up cloned dataset from repo for operations
-repo = Repository(
- local_dir="data", clone_from=DATASET_REPO_URL, use_auth_token=HF_TOKEN
-)
-
-#generator1 = gr.Interface.load("bigscience/bloom", api_key=HF_TOKEN)
-
-
-generator1 = gr.Interface.load("huggingface/gpt2-large", api_key=HF_TOKEN)
-generator2 = gr.Interface.load("huggingface/EleutherAI/gpt-neo-2.7B", api_key=HF_TOKEN)
-generator3 = gr.Interface.load("huggingface/EleutherAI/gpt-j-6B", api_key=HF_TOKEN)
-
-
-def calculator(intro, operator, outro):
- if operator == "add":
- output = generator2(intro) + generator3(outro)
- title = intro + " " + outro
- saved = AIMemory(title, output)
- return output
- elif operator == "subtract":
- output = generator2(outro) + generator3(intro)
- title = outro + " " + intro
- saved = AIMemory(title, output)
- output = output.replace(intro, "").replace(outro, "")
- return output
- elif operator == "multiply":
- output = generator1(intro) + generator2(outro) + generator3(intro)
- title = intro + " " + outro + " " + intro
- saved = AIMemory(title, output)
- return output
- elif operator == "divide":
- output = generator1(outro) + generator2(intro) + generator3(outro)
- title = outro + " " + intro + " " + outro
- saved = AIMemory(title, output)
- output = output.replace(intro, "").replace(outro, "")
- return output
-
-#with open('Mindfulness.txt', 'r') as file:
-# context = file.read()
-#contextBox = gr.Textbox(lines=3, default=context, label="Story starter")
-#Two space marines named Liev Schreiber and Will Sasso take up arms to save the planet from an alien invasion. These two dashing strong men play a comedic role in the science fiction movie of the future where even barnaby bunny is willing to join their wacky gang of space marines to save the planet with good looks and comedy.
-
-examples = [
- ["Two space marines take up arms to save the planet from an alien invasion.", "multiply", "These two dashing strong actors play a comedic role in the science fiction movie of the future"],
- ["These two dashing strong actors play a comedic role in the science fiction movie of the future", "add", "Barnaby bunny is willing to join their wacky gang of space marines"],
- ["to save the planet with good looks and comedy", "add", "Two space marines become best friends as they assist with saving the world from the alien invasion"]
-]
-
-demo = gr.Interface(
- calculator,
- [
- "text",
- gr.Radio(["add", "subtract", "multiply", "divide"]),
- "text"
- ],
- "text",
- examples=examples,
- article="Saved story memory dataset: https://huggingface.co/datasets/awacke1/MindfulStory.csv with available models to use from text gen: https://huggingface.co/models?pipeline_tag=text-generation&sort=downloads",
- live=True,
-)
-demo.launch()
\ No newline at end of file
diff --git a/spaces/LaynzKunz/Aesthetic_RVC_Inference_HF/lib/infer/infer_libs/uvr5_pack/demucs/wav.py b/spaces/LaynzKunz/Aesthetic_RVC_Inference_HF/lib/infer/infer_libs/uvr5_pack/demucs/wav.py
deleted file mode 100644
index a65c3b2ba5aacb1fcab3753f1f85ff7b8db7fc11..0000000000000000000000000000000000000000
--- a/spaces/LaynzKunz/Aesthetic_RVC_Inference_HF/lib/infer/infer_libs/uvr5_pack/demucs/wav.py
+++ /dev/null
@@ -1,174 +0,0 @@
-# Copyright (c) Facebook, Inc. and its affiliates.
-# All rights reserved.
-#
-# This source code is licensed under the license found in the
-# LICENSE file in the root directory of this source tree.
-
-from collections import OrderedDict
-import hashlib
-import math
-import json
-from pathlib import Path
-
-import julius
-import torch as th
-from torch import distributed
-import torchaudio as ta
-from torch.nn import functional as F
-
-from .audio import convert_audio_channels
-from .compressed import get_musdb_tracks
-
-MIXTURE = "mixture"
-EXT = ".wav"
-
-
-def _track_metadata(track, sources):
- track_length = None
- track_samplerate = None
- for source in sources + [MIXTURE]:
- file = track / f"{source}{EXT}"
- info = ta.info(str(file))
- length = info.num_frames
- if track_length is None:
- track_length = length
- track_samplerate = info.sample_rate
- elif track_length != length:
- raise ValueError(
- f"Invalid length for file {file}: "
- f"expecting {track_length} but got {length}.")
- elif info.sample_rate != track_samplerate:
- raise ValueError(
- f"Invalid sample rate for file {file}: "
- f"expecting {track_samplerate} but got {info.sample_rate}.")
- if source == MIXTURE:
- wav, _ = ta.load(str(file))
- wav = wav.mean(0)
- mean = wav.mean().item()
- std = wav.std().item()
-
- return {"length": length, "mean": mean, "std": std, "samplerate": track_samplerate}
-
-
-def _build_metadata(path, sources):
- meta = {}
- path = Path(path)
- for file in path.iterdir():
- meta[file.name] = _track_metadata(file, sources)
- return meta
-
-
-class Wavset:
- def __init__(
- self,
- root, metadata, sources,
- length=None, stride=None, normalize=True,
- samplerate=44100, channels=2):
- """
- Waveset (or mp3 set for that matter). Can be used to train
- with arbitrary sources. Each track should be one folder inside of `path`.
- The folder should contain files named `{source}.{ext}`.
- Files will be grouped according to `sources` (each source is a list of
- filenames).
-
- Sample rate and channels will be converted on the fly.
-
- `length` is the sample size to extract (in samples, not duration).
- `stride` is how many samples to move by between each example.
- """
- self.root = Path(root)
- self.metadata = OrderedDict(metadata)
- self.length = length
- self.stride = stride or length
- self.normalize = normalize
- self.sources = sources
- self.channels = channels
- self.samplerate = samplerate
- self.num_examples = []
- for name, meta in self.metadata.items():
- track_length = int(self.samplerate * meta['length'] / meta['samplerate'])
- if length is None or track_length < length:
- examples = 1
- else:
- examples = int(math.ceil((track_length - self.length) / self.stride) + 1)
- self.num_examples.append(examples)
-
- def __len__(self):
- return sum(self.num_examples)
-
- def get_file(self, name, source):
- return self.root / name / f"{source}{EXT}"
-
- def __getitem__(self, index):
- for name, examples in zip(self.metadata, self.num_examples):
- if index >= examples:
- index -= examples
- continue
- meta = self.metadata[name]
- num_frames = -1
- offset = 0
- if self.length is not None:
- offset = int(math.ceil(
- meta['samplerate'] * self.stride * index / self.samplerate))
- num_frames = int(math.ceil(
- meta['samplerate'] * self.length / self.samplerate))
- wavs = []
- for source in self.sources:
- file = self.get_file(name, source)
- wav, _ = ta.load(str(file), frame_offset=offset, num_frames=num_frames)
- wav = convert_audio_channels(wav, self.channels)
- wavs.append(wav)
-
- example = th.stack(wavs)
- example = julius.resample_frac(example, meta['samplerate'], self.samplerate)
- if self.normalize:
- example = (example - meta['mean']) / meta['std']
- if self.length:
- example = example[..., :self.length]
- example = F.pad(example, (0, self.length - example.shape[-1]))
- return example
-
-
-def get_wav_datasets(args, samples, sources):
- sig = hashlib.sha1(str(args.wav).encode()).hexdigest()[:8]
- metadata_file = args.metadata / (sig + ".json")
- train_path = args.wav / "train"
- valid_path = args.wav / "valid"
- if not metadata_file.is_file() and args.rank == 0:
- train = _build_metadata(train_path, sources)
- valid = _build_metadata(valid_path, sources)
- json.dump([train, valid], open(metadata_file, "w"))
- if args.world_size > 1:
- distributed.barrier()
- train, valid = json.load(open(metadata_file))
- train_set = Wavset(train_path, train, sources,
- length=samples, stride=args.data_stride,
- samplerate=args.samplerate, channels=args.audio_channels,
- normalize=args.norm_wav)
- valid_set = Wavset(valid_path, valid, [MIXTURE] + sources,
- samplerate=args.samplerate, channels=args.audio_channels,
- normalize=args.norm_wav)
- return train_set, valid_set
-
-
-def get_musdb_wav_datasets(args, samples, sources):
- metadata_file = args.metadata / "musdb_wav.json"
- root = args.musdb / "train"
- if not metadata_file.is_file() and args.rank == 0:
- metadata = _build_metadata(root, sources)
- json.dump(metadata, open(metadata_file, "w"))
- if args.world_size > 1:
- distributed.barrier()
- metadata = json.load(open(metadata_file))
-
- train_tracks = get_musdb_tracks(args.musdb, is_wav=True, subsets=["train"], split="train")
- metadata_train = {name: meta for name, meta in metadata.items() if name in train_tracks}
- metadata_valid = {name: meta for name, meta in metadata.items() if name not in train_tracks}
- train_set = Wavset(root, metadata_train, sources,
- length=samples, stride=args.data_stride,
- samplerate=args.samplerate, channels=args.audio_channels,
- normalize=args.norm_wav)
- valid_set = Wavset(root, metadata_valid, [MIXTURE] + sources,
- samplerate=args.samplerate, channels=args.audio_channels,
- normalize=args.norm_wav)
- return train_set, valid_set
diff --git a/spaces/LecJackS/wolfram-alpha-query/wolfram_alpha_tool.py b/spaces/LecJackS/wolfram-alpha-query/wolfram_alpha_tool.py
deleted file mode 100644
index 28141ce1cb51ad16c435c907043399e1b4a2f076..0000000000000000000000000000000000000000
--- a/spaces/LecJackS/wolfram-alpha-query/wolfram_alpha_tool.py
+++ /dev/null
@@ -1,62 +0,0 @@
-import os
-import requests
-from transformers import Tool
-
-class WolframAlpha(Tool):
- name = "wolfram_alpha"
- description = ("This is a tool that uses WolframAlpha to compute any mathematical query. It takes one input query, and returns a verbose result in xml format, which includes the solution.")
-
- inputs = ["query"]
- outputs = ["result"]
-
- def __init__(self, *args, **kwargs):
- self.base_url = 'http://api.wolframalpha.com/v2/query'
-
- self.app_id = os.environ.get('WOLFRAM_APP_ID')
- if self.app_id is None:
- raise ValueError("Please set the `WOLFRAM_APP_ID` as an environment variable in order to instantiate the Wolfram tool.\nTo do so, before instantiating the class, run:\nos.environ['WOLFRAM_APP_ID'] = 'YOUR_WOLFRAM_APP_ID'")
-
- print("Making sure APP_ID is valid... ", end="")
- dummy_params = {
- 'input': '1+1',
- 'output': 'xml',
- 'appid': self.app_id,
- }
- response = self.make_request(params=dummy_params)
- if "Invalid appid" in response:
- appid_url = 'https://developer.wolframalpha.com/portal/myapps/index.html'
- raise ValueError(f"Please set a valid `WOLFRAM_APP_ID` as an environment variable.\nWolframAlpha is not validating APP_ID: {self.app_id}\nTo get an APP_ID, go to:\n{appid_url}\nand click on [Get an AppID]")
- print("APP_ID validated! Tool ready to use.")
-
- def __call__(self, query, output='xml', pod_format='plaintext'):
-
-
- output_opts = ['xml','json']
- format_opts = ['plaintext', 'image', 'image,imagemap', 'mathml', 'sound', 'wav']
-
- if output not in output_opts:
- return f"{output} is not a correct output parameter! It must be one of these: {output_opts}"
-
- if pod_format not in format_opts:
- return f"{pod_format} is not a correct pod_format parameter! It must be one of these: {format_opts}"
-
- params = {
- 'input': query,
- 'output': output,
- 'appid': self.app_id,
- }
-
- response = self.make_request(params)
-
- return response
-
- def make_request(self, params):
- response = requests.get(self.base_url, params=params)
- if response.status_code == 200:
- if params['output'] == 'xml':
- return response.text
- elif params['output'] == 'json':
- # Remove unnecessary empty spaces
- return str(response.json())
- else:
- return f"There was an error with the request, with response: {response}"
\ No newline at end of file
diff --git a/spaces/MRroboto/Loacker_app/postprocessing.py b/spaces/MRroboto/Loacker_app/postprocessing.py
deleted file mode 100644
index c77745d872f708aea56c3aa50a741f5e27011af6..0000000000000000000000000000000000000000
--- a/spaces/MRroboto/Loacker_app/postprocessing.py
+++ /dev/null
@@ -1,148 +0,0 @@
-# should work for all apporaches (Deep learning or not)
-# should work on segmentation masks
-# should include a smoothing and an max-area threshold
-# should try to work with the tortina circle (or maybe better estimate it again)
-# maybe even to apply before thresholding, directly on anomaly maps/other outputs to have better smoothing
-# output should be again a segmentation mask
-
-import numpy as np
-import cv2
-
-
-
-
-
-def get_points_in_circle(circle):
- x0, y0, radius = circle.astype(np.int32)
- x_ = np.arange(x0 - radius - 1, x0 + radius + 1, dtype=np.int32)
- y_ = np.arange(y0 - radius - 1, y0 + radius + 1, dtype=np.int32)
- x, y = np.where((x_[:,np.newaxis] - x0)**2 + (y_ - y0)**2 <= radius**2)
- # for x, y in zip(x_[x], y_[y]): # yield x, y
- return (x_[x], y_[y])
-
-
-
-
-def find_single_tortina_circle(image):
- height, width, num_channels = image.shape
-
- #find the biggest circle (tortina) in the image
- #init with default circle
- selected_circle = np.array((width//2, height//2, int(height/2*0.9)))
- try:
- #circles = find_tortinas(image, 1, force_num_tortinas=True)
- height, width = image.shape[:2]
- if (image.ndim == 2) or (image.shape[-1] == 1):
- gray = image
- else:
- gray = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)
- blur = cv2.blur(gray, (7,7))
- circles = cv2.HoughCircles(blur, cv2.HOUGH_GRADIENT, 3, minDist=width//2)
- if circles is None:
- circles = []
- else:
- circles = circles[0].astype(np.uint32)
-
- except:
- circles = []
-
- if len(circles) > 0:
- max_r = 0
- for x,y,r in circles:
- if r > max_r:
- max_r = r
- selected_circle = np.array((x,y,r))
-
- return selected_circle
-
-
-
-def postprocessing(image, segmask, fat_bloom_id=1):
-
- if segmask.shape != image.shape[:2]:
- raise ValueError(
- """segmask argument should represent a segmentation mask with 2 dimensions (height, width)!
- This means that its values should already be thresholded and (in case of rgb) reduced to
- a single channel.
- """)
-
- height, width = image.shape[:2]
- selected_circle = find_single_tortina_circle(image)
-
- #debugging
- #plot_image_with_circle(image, selected_circle)
-
- # smooth the segmask
- binary = (segmask == fat_bloom_id).astype(np.uint8)
- kernel = np.ones((5,5),np.uint8)
- closing = cv2.morphologyEx(binary, cv2.MORPH_CLOSE, kernel)
- opening = cv2.morphologyEx(closing, cv2.MORPH_OPEN, kernel)
-
- #the opening values should overwrite the fat_bloom of the input
- #segmask. Where we had fat bloom in the input but not anymore in the
- #opening we need to determine whether it is backgorund or tortina. We
- #can do so using the estimated circle.
-
- #initialize everything to background. background = 0
- new_segmask = np.zeros_like(segmask)
- tortina_indices = get_points_in_circle(selected_circle)
- #correction
- out_of_width_0 = (tortina_indices[0] < 0)
- out_of_width_1 = (tortina_indices[0] >= width)
- out_of_height_0 = (tortina_indices[1] < 0)
- out_of_height_1 = (tortina_indices[1] >= height)
- tortina_indices[0][out_of_width_0] = 0
- tortina_indices[0][out_of_width_1] = width - 1
- tortina_indices[1][out_of_height_0] = 0
- tortina_indices[1][out_of_height_1] = height - 1
- # remove_indices = (tortina_indices[0] < 0) | (tortina_indices[0] >= height) | \
- # (tortina_indices[1] < 0) | (tortina_indices[1] >= width)
- # keep_indices = np.setdiff1d(np.arange(len(tortina_indices[0])), remove_indices)
- # tortina_indices = (tortina_indices[0][keep_indices], tortina_indices[1][keep_indices])
-
-
- is_tortina = np.zeros_like(segmask, dtype=bool)
- is_tortina[tortina_indices] = True
- #tortina = 1
- new_segmask[is_tortina] = 1
- #fat_bloom = 2
- new_segmask[(opening == 1) & is_tortina] = 2
-
- return new_segmask
-
-
-def final_prediction(anomaly_map, segmask):
-
- fat_bloom_area = np.count_nonzero(segmask == 2)
- tortina_area = np.count_nonzero(segmask == 1) + fat_bloom_area
-
- relative_area = fat_bloom_area / tortina_area
-
- area = 0
- if (relative_area > 0) and (relative_area <= 0.25):
- area = 1
- elif (relative_area > 0.25) and (relative_area <= 0.5):
- area = 2
- elif (relative_area > 0.5) and (relative_area <= 0.75):
- area = 3
- elif relative_area > 0.75:
- area = 4
-
- relative_intensity = 0.0
- if fat_bloom_area > 0.0:
- relative_intensity = anomaly_map[segmask==2].mean()
-
- #TODO: intensity should be depending on colour of underlying tortina
- # i.e. for a darker tortina intesity is automatically higher,
- # but that should be relativiert.
- intensity = 0
- if (relative_intensity > 0) and (relative_intensity <= 0.25):
- intensity = 1
- elif (relative_intensity > 0.25) and (relative_intensity <= 0.5):
- intensity = 2
- elif (relative_intensity > 0.5) and (relative_intensity <= 0.75):
- intensity = 3
- elif relative_intensity > 0.75:
- intensity = 4
-
- return area, intensity
\ No newline at end of file
diff --git a/spaces/Manjushri/MusicGen/tests/data/test_audio_utils.py b/spaces/Manjushri/MusicGen/tests/data/test_audio_utils.py
deleted file mode 100644
index 0480671bb17281d61ce02bce6373a5ccec89fece..0000000000000000000000000000000000000000
--- a/spaces/Manjushri/MusicGen/tests/data/test_audio_utils.py
+++ /dev/null
@@ -1,110 +0,0 @@
-# Copyright (c) Meta Platforms, Inc. and affiliates.
-# All rights reserved.
-#
-# This source code is licensed under the license found in the
-# LICENSE file in the root directory of this source tree.
-
-import julius
-import torch
-import pytest
-
-from audiocraft.data.audio_utils import (
- _clip_wav,
- convert_audio_channels,
- convert_audio,
- normalize_audio
-)
-from ..common_utils import get_batch_white_noise
-
-
-class TestConvertAudioChannels:
-
- def test_convert_audio_channels_downmix(self):
- b, c, t = 2, 3, 100
- audio = get_batch_white_noise(b, c, t)
- mixed = convert_audio_channels(audio, channels=2)
- assert list(mixed.shape) == [b, 2, t]
-
- def test_convert_audio_channels_nochange(self):
- b, c, t = 2, 3, 100
- audio = get_batch_white_noise(b, c, t)
- mixed = convert_audio_channels(audio, channels=c)
- assert list(mixed.shape) == list(audio.shape)
-
- def test_convert_audio_channels_upmix(self):
- b, c, t = 2, 1, 100
- audio = get_batch_white_noise(b, c, t)
- mixed = convert_audio_channels(audio, channels=3)
- assert list(mixed.shape) == [b, 3, t]
-
- def test_convert_audio_channels_upmix_error(self):
- b, c, t = 2, 2, 100
- audio = get_batch_white_noise(b, c, t)
- with pytest.raises(ValueError):
- convert_audio_channels(audio, channels=3)
-
-
-class TestConvertAudio:
-
- def test_convert_audio_channels_downmix(self):
- b, c, dur = 2, 3, 4.
- sr = 128
- audio = get_batch_white_noise(b, c, int(sr * dur))
- out = convert_audio(audio, from_rate=sr, to_rate=sr, to_channels=2)
- assert list(out.shape) == [audio.shape[0], 2, audio.shape[-1]]
-
- def test_convert_audio_channels_upmix(self):
- b, c, dur = 2, 1, 4.
- sr = 128
- audio = get_batch_white_noise(b, c, int(sr * dur))
- out = convert_audio(audio, from_rate=sr, to_rate=sr, to_channels=3)
- assert list(out.shape) == [audio.shape[0], 3, audio.shape[-1]]
-
- def test_convert_audio_upsample(self):
- b, c, dur = 2, 1, 4.
- sr = 2
- new_sr = 3
- audio = get_batch_white_noise(b, c, int(sr * dur))
- out = convert_audio(audio, from_rate=sr, to_rate=new_sr, to_channels=c)
- out_j = julius.resample.resample_frac(audio, old_sr=sr, new_sr=new_sr)
- assert torch.allclose(out, out_j)
-
- def test_convert_audio_resample(self):
- b, c, dur = 2, 1, 4.
- sr = 3
- new_sr = 2
- audio = get_batch_white_noise(b, c, int(sr * dur))
- out = convert_audio(audio, from_rate=sr, to_rate=new_sr, to_channels=c)
- out_j = julius.resample.resample_frac(audio, old_sr=sr, new_sr=new_sr)
- assert torch.allclose(out, out_j)
-
-
-class TestNormalizeAudio:
-
- def test_clip_wav(self):
- b, c, dur = 2, 1, 4.
- sr = 3
- audio = 10.0 * get_batch_white_noise(b, c, int(sr * dur))
- _clip_wav(audio)
- assert audio.abs().max() <= 1
-
- def test_normalize_audio_clip(self):
- b, c, dur = 2, 1, 4.
- sr = 3
- audio = 10.0 * get_batch_white_noise(b, c, int(sr * dur))
- norm_audio = normalize_audio(audio, strategy='clip')
- assert norm_audio.abs().max() <= 1
-
- def test_normalize_audio_rms(self):
- b, c, dur = 2, 1, 4.
- sr = 3
- audio = 10.0 * get_batch_white_noise(b, c, int(sr * dur))
- norm_audio = normalize_audio(audio, strategy='rms')
- assert norm_audio.abs().max() <= 1
-
- def test_normalize_audio_peak(self):
- b, c, dur = 2, 1, 4.
- sr = 3
- audio = 10.0 * get_batch_white_noise(b, c, int(sr * dur))
- norm_audio = normalize_audio(audio, strategy='peak')
- assert norm_audio.abs().max() <= 1
diff --git a/spaces/Marshalls/testmtd/models/residualflower_model.py b/spaces/Marshalls/testmtd/models/residualflower_model.py
deleted file mode 100644
index 736b0fcffc7014052382dc64bfa5d2dd4f2442db..0000000000000000000000000000000000000000
--- a/spaces/Marshalls/testmtd/models/residualflower_model.py
+++ /dev/null
@@ -1,155 +0,0 @@
-import torch
-from torch import nn
-from .transformer import BasicTransformerModel
-from models import BaseModel
-from models.flowplusplus import FlowPlusPlus
-import ast
-
-from .util.generation import autoregressive_generation_multimodal
-from .transformer_model import TransformerModel
-
-#TODO: refactor a whole bunch of stuff
-
-class ResidualflowerModel(BaseModel):
- def __init__(self, opt):
- super().__init__(opt)
- self.opt = opt
- input_mods = self.input_mods
- output_mods = self.output_mods
- input_lengths = self.input_lengths
- output_lengths = self.output_lengths
- dins = self.dins
- douts = self.douts
- if self.opt.conditioning_seq_lens is not None:
- self.conditioning_seq_lens = [int(x) for x in str(self.opt.conditioning_seq_lens).split(",")]
- else:
- self.conditioning_seq_lens = [int(x) for x in str(self.opt.output_lengths).split(",")]
-
- self.input_mod_nets = []
- self.output_mod_nets = []
- self.output_mod_glows = []
- self.module_names = []
- for i, mod in enumerate(input_mods):
- net = BasicTransformerModel(opt.dhid, dins[i], opt.nhead, opt.dhid, 2, opt.dropout, self.device, use_pos_emb=True, input_length=input_lengths[i]).to(self.device)
- name = "_input_"+mod
- setattr(self,"net"+name, net)
- self.input_mod_nets.append(net)
- self.module_names.append(name)
- for i, mod in enumerate(output_mods):
- if self.opt.cond_concat_dims:
- net = BasicTransformerModel(opt.dhid, opt.dhid, opt.nhead, opt.dhid, opt.nlayers, opt.dropout, self.device, use_pos_emb=opt.use_pos_emb_output, input_length=sum(input_lengths)).to(self.device)
- else:
- net = BasicTransformerModel(douts[i]//2, opt.dhid, opt.nhead, opt.dhid, opt.nlayers, opt.dropout, self.device, use_pos_emb=opt.use_pos_emb_output, input_length=sum(input_lengths)).to(self.device)
- name = "_output_"+mod
- setattr(self, "net"+name, net)
- self.output_mod_nets.append(net)
- self.module_names.append(name)
-
- # import pdb;pdb.set_trace()
- glow = FlowPlusPlus(scales=ast.literal_eval(opt.scales),
- in_shape=(douts[i], output_lengths[i], 1),
- cond_dim=opt.dhid,
- mid_channels=opt.dhid_flow,
- num_blocks=opt.num_glow_coupling_blocks,
- num_components=opt.num_mixture_components,
- use_attn=opt.glow_use_attn,
- use_logmix=opt.num_mixture_components>0,
- drop_prob=opt.dropout,
- num_heads=opt.num_heads_flow,
- use_transformer_nn=opt.use_transformer_nn,
- use_pos_emb=opt.use_pos_emb_coupling,
- norm_layer = opt.glow_norm_layer,
- bn_momentum = opt.glow_bn_momentum,
- cond_concat_dims=opt.cond_concat_dims,
- cond_seq_len=self.conditioning_seq_lens[i],
- )
- name = "_output_glow_"+mod
- setattr(self, "net"+name, glow)
- self.output_mod_glows.append(glow)
-
- self.mean_model = TransformerModel(opt)
-
- self.inputs = []
- self.targets = []
- self.criterion = nn.MSELoss()
-
- def name(self):
- return "Transflower"
-
- @staticmethod
- def modify_commandline_options(parser, opt):
- parser.add_argument('--dhid', type=int, default=512)
- parser.add_argument('--dhid_flow', type=int, default=512)
- parser.add_argument('--predicted_inputs', default="0")
- parser.add_argument('--conditioning_seq_lens', type=str, default=None, help="the number of outputs of the conditioning transformers to feed (meaning the number of elements along the sequence dimension)")
- parser.add_argument('--nlayers', type=int, default=6)
- parser.add_argument('--nhead', type=int, default=8)
- parser.add_argument('--num_heads_flow', type=int, default=8)
- parser.add_argument('--dropout', type=float, default=0.1)
- parser.add_argument('--scales', type=str, default="[[10,0]]")
- parser.add_argument('--glow_norm_layer', type=str, default=None)
- parser.add_argument('--glow_bn_momentum', type=float, default=0.1)
- parser.add_argument('--num_glow_coupling_blocks', type=int, default=10)
- parser.add_argument('--num_mixture_components', type=int, default=0)
- parser.add_argument('--glow_use_attn', action='store_true', help="whether to use the internal attention for the FlowPlusPLus model")
- parser.add_argument('--use_transformer_nn', action='store_true', help="whether to use the internal attention for the FlowPlusPLus model")
- parser.add_argument('--use_pos_emb_output', action='store_true', help="whether to use positional embeddings for output modality transformers")
- parser.add_argument('--use_pos_emb_coupling', action='store_true', help="whether to use positional embeddings for the coupling layer transformers")
- parser.add_argument('--cond_concat_dims', action='store_true', help="if set we concatenate along the channel dimension with with the x for the coupling layer; otherwise we concatenate along the sequence dimesion")
- return parser
-
- def forward(self, data):
- # in lightning, forward defines the prediction/inference actions
- predicted_means = self.mean_model(data)
- latents = []
- for i, mod in enumerate(self.input_mods):
- latents.append(self.input_mod_nets[i].forward(data[i]))
- latent = torch.cat(latents)
- outputs = []
- for i, mod in enumerate(self.output_mods):
- trans_output = self.output_mod_nets[i].forward(latent)[:self.conditioning_seq_lens[i]]
- output, _ = self.output_mod_glows[i](x=None, cond=trans_output.permute(1,0,2), reverse=True)
- outputs.append(predicted_means[i]+output.permute(1,0,2))
-
- return outputs
-
- def training_step(self, batch, batch_idx):
- self.set_inputs(batch)
- predicted_means = self.mean_model(self.inputs)
- mse_loss = 0
- for i, mod in enumerate(self.output_mods):
- mse_loss += 100*self.criterion(predicted_means[i], self.targets[i])
- #print("mse_loss: ", mse_loss)
- latents = []
- for i, mod in enumerate(self.input_mods):
- latents.append(self.input_mod_nets[i].forward(self.inputs[i]))
-
- latent = torch.cat(latents)
- nll_loss=0
- for i, mod in enumerate(self.output_mods):
- output = self.output_mod_nets[i].forward(latent)[:self.conditioning_seq_lens[i]]
- glow = self.output_mod_glows[i]
- # import pdb;pdb.set_trace()
- z, sldj = glow(x=self.targets[i].permute(1,0,2)-predicted_means[i].detach().permute(1,0,2), cond=output.permute(1,0,2)) #time, batch, features -> batch, time, features
- #print(sldj)
- n_timesteps = self.targets[i].shape[1]
- nll_loss += glow.loss_generative(z, sldj)
-
- loss = mse_loss + nll_loss
- #print("nll_loss: ", nll_loss)
- self.log('mse_loss', mse_loss)
- self.log('nll_loss', nll_loss)
- self.log('loss', loss)
- return loss
-
- #to help debug XLA stuff, like missing ops, or data loading/compiling bottlenecks
- # see https://youtu.be/iwtpwQRdb3Y?t=1056
- # def on_epoch_end(self):
- # import torch_xla.core.xla_model as xm
- # import torch_xla.debug.metrics as met
- # xm.master_print(met.metrics_report())
-
-
- #def optimizer_step(self, epoch, batch_idx, optimizer, optimizer_idx,
- # optimizer_closure, on_tpu, using_native_amp, using_lbfgs):
- # optimizer.zero_grad()
diff --git a/spaces/Mellow-ai/PhotoAI_Mellow/annotator/midas/midas/blocks.py b/spaces/Mellow-ai/PhotoAI_Mellow/annotator/midas/midas/blocks.py
deleted file mode 100644
index 2145d18fa98060a618536d9a64fe6589e9be4f78..0000000000000000000000000000000000000000
--- a/spaces/Mellow-ai/PhotoAI_Mellow/annotator/midas/midas/blocks.py
+++ /dev/null
@@ -1,342 +0,0 @@
-import torch
-import torch.nn as nn
-
-from .vit import (
- _make_pretrained_vitb_rn50_384,
- _make_pretrained_vitl16_384,
- _make_pretrained_vitb16_384,
- forward_vit,
-)
-
-def _make_encoder(backbone, features, use_pretrained, groups=1, expand=False, exportable=True, hooks=None, use_vit_only=False, use_readout="ignore",):
- if backbone == "vitl16_384":
- pretrained = _make_pretrained_vitl16_384(
- use_pretrained, hooks=hooks, use_readout=use_readout
- )
- scratch = _make_scratch(
- [256, 512, 1024, 1024], features, groups=groups, expand=expand
- ) # ViT-L/16 - 85.0% Top1 (backbone)
- elif backbone == "vitb_rn50_384":
- pretrained = _make_pretrained_vitb_rn50_384(
- use_pretrained,
- hooks=hooks,
- use_vit_only=use_vit_only,
- use_readout=use_readout,
- )
- scratch = _make_scratch(
- [256, 512, 768, 768], features, groups=groups, expand=expand
- ) # ViT-H/16 - 85.0% Top1 (backbone)
- elif backbone == "vitb16_384":
- pretrained = _make_pretrained_vitb16_384(
- use_pretrained, hooks=hooks, use_readout=use_readout
- )
- scratch = _make_scratch(
- [96, 192, 384, 768], features, groups=groups, expand=expand
- ) # ViT-B/16 - 84.6% Top1 (backbone)
- elif backbone == "resnext101_wsl":
- pretrained = _make_pretrained_resnext101_wsl(use_pretrained)
- scratch = _make_scratch([256, 512, 1024, 2048], features, groups=groups, expand=expand) # efficientnet_lite3
- elif backbone == "efficientnet_lite3":
- pretrained = _make_pretrained_efficientnet_lite3(use_pretrained, exportable=exportable)
- scratch = _make_scratch([32, 48, 136, 384], features, groups=groups, expand=expand) # efficientnet_lite3
- else:
- print(f"Backbone '{backbone}' not implemented")
- assert False
-
- return pretrained, scratch
-
-
-def _make_scratch(in_shape, out_shape, groups=1, expand=False):
- scratch = nn.Module()
-
- out_shape1 = out_shape
- out_shape2 = out_shape
- out_shape3 = out_shape
- out_shape4 = out_shape
- if expand==True:
- out_shape1 = out_shape
- out_shape2 = out_shape*2
- out_shape3 = out_shape*4
- out_shape4 = out_shape*8
-
- scratch.layer1_rn = nn.Conv2d(
- in_shape[0], out_shape1, kernel_size=3, stride=1, padding=1, bias=False, groups=groups
- )
- scratch.layer2_rn = nn.Conv2d(
- in_shape[1], out_shape2, kernel_size=3, stride=1, padding=1, bias=False, groups=groups
- )
- scratch.layer3_rn = nn.Conv2d(
- in_shape[2], out_shape3, kernel_size=3, stride=1, padding=1, bias=False, groups=groups
- )
- scratch.layer4_rn = nn.Conv2d(
- in_shape[3], out_shape4, kernel_size=3, stride=1, padding=1, bias=False, groups=groups
- )
-
- return scratch
-
-
-def _make_pretrained_efficientnet_lite3(use_pretrained, exportable=False):
- efficientnet = torch.hub.load(
- "rwightman/gen-efficientnet-pytorch",
- "tf_efficientnet_lite3",
- pretrained=use_pretrained,
- exportable=exportable
- )
- return _make_efficientnet_backbone(efficientnet)
-
-
-def _make_efficientnet_backbone(effnet):
- pretrained = nn.Module()
-
- pretrained.layer1 = nn.Sequential(
- effnet.conv_stem, effnet.bn1, effnet.act1, *effnet.blocks[0:2]
- )
- pretrained.layer2 = nn.Sequential(*effnet.blocks[2:3])
- pretrained.layer3 = nn.Sequential(*effnet.blocks[3:5])
- pretrained.layer4 = nn.Sequential(*effnet.blocks[5:9])
-
- return pretrained
-
-
-def _make_resnet_backbone(resnet):
- pretrained = nn.Module()
- pretrained.layer1 = nn.Sequential(
- resnet.conv1, resnet.bn1, resnet.relu, resnet.maxpool, resnet.layer1
- )
-
- pretrained.layer2 = resnet.layer2
- pretrained.layer3 = resnet.layer3
- pretrained.layer4 = resnet.layer4
-
- return pretrained
-
-
-def _make_pretrained_resnext101_wsl(use_pretrained):
- resnet = torch.hub.load("facebookresearch/WSL-Images", "resnext101_32x8d_wsl")
- return _make_resnet_backbone(resnet)
-
-
-
-class Interpolate(nn.Module):
- """Interpolation module.
- """
-
- def __init__(self, scale_factor, mode, align_corners=False):
- """Init.
-
- Args:
- scale_factor (float): scaling
- mode (str): interpolation mode
- """
- super(Interpolate, self).__init__()
-
- self.interp = nn.functional.interpolate
- self.scale_factor = scale_factor
- self.mode = mode
- self.align_corners = align_corners
-
- def forward(self, x):
- """Forward pass.
-
- Args:
- x (tensor): input
-
- Returns:
- tensor: interpolated data
- """
-
- x = self.interp(
- x, scale_factor=self.scale_factor, mode=self.mode, align_corners=self.align_corners
- )
-
- return x
-
-
-class ResidualConvUnit(nn.Module):
- """Residual convolution module.
- """
-
- def __init__(self, features):
- """Init.
-
- Args:
- features (int): number of features
- """
- super().__init__()
-
- self.conv1 = nn.Conv2d(
- features, features, kernel_size=3, stride=1, padding=1, bias=True
- )
-
- self.conv2 = nn.Conv2d(
- features, features, kernel_size=3, stride=1, padding=1, bias=True
- )
-
- self.relu = nn.ReLU(inplace=True)
-
- def forward(self, x):
- """Forward pass.
-
- Args:
- x (tensor): input
-
- Returns:
- tensor: output
- """
- out = self.relu(x)
- out = self.conv1(out)
- out = self.relu(out)
- out = self.conv2(out)
-
- return out + x
-
-
-class FeatureFusionBlock(nn.Module):
- """Feature fusion block.
- """
-
- def __init__(self, features):
- """Init.
-
- Args:
- features (int): number of features
- """
- super(FeatureFusionBlock, self).__init__()
-
- self.resConfUnit1 = ResidualConvUnit(features)
- self.resConfUnit2 = ResidualConvUnit(features)
-
- def forward(self, *xs):
- """Forward pass.
-
- Returns:
- tensor: output
- """
- output = xs[0]
-
- if len(xs) == 2:
- output += self.resConfUnit1(xs[1])
-
- output = self.resConfUnit2(output)
-
- output = nn.functional.interpolate(
- output, scale_factor=2, mode="bilinear", align_corners=True
- )
-
- return output
-
-
-
-
-class ResidualConvUnit_custom(nn.Module):
- """Residual convolution module.
- """
-
- def __init__(self, features, activation, bn):
- """Init.
-
- Args:
- features (int): number of features
- """
- super().__init__()
-
- self.bn = bn
-
- self.groups=1
-
- self.conv1 = nn.Conv2d(
- features, features, kernel_size=3, stride=1, padding=1, bias=True, groups=self.groups
- )
-
- self.conv2 = nn.Conv2d(
- features, features, kernel_size=3, stride=1, padding=1, bias=True, groups=self.groups
- )
-
- if self.bn==True:
- self.bn1 = nn.BatchNorm2d(features)
- self.bn2 = nn.BatchNorm2d(features)
-
- self.activation = activation
-
- self.skip_add = nn.quantized.FloatFunctional()
-
- def forward(self, x):
- """Forward pass.
-
- Args:
- x (tensor): input
-
- Returns:
- tensor: output
- """
-
- out = self.activation(x)
- out = self.conv1(out)
- if self.bn==True:
- out = self.bn1(out)
-
- out = self.activation(out)
- out = self.conv2(out)
- if self.bn==True:
- out = self.bn2(out)
-
- if self.groups > 1:
- out = self.conv_merge(out)
-
- return self.skip_add.add(out, x)
-
- # return out + x
-
-
-class FeatureFusionBlock_custom(nn.Module):
- """Feature fusion block.
- """
-
- def __init__(self, features, activation, deconv=False, bn=False, expand=False, align_corners=True):
- """Init.
-
- Args:
- features (int): number of features
- """
- super(FeatureFusionBlock_custom, self).__init__()
-
- self.deconv = deconv
- self.align_corners = align_corners
-
- self.groups=1
-
- self.expand = expand
- out_features = features
- if self.expand==True:
- out_features = features//2
-
- self.out_conv = nn.Conv2d(features, out_features, kernel_size=1, stride=1, padding=0, bias=True, groups=1)
-
- self.resConfUnit1 = ResidualConvUnit_custom(features, activation, bn)
- self.resConfUnit2 = ResidualConvUnit_custom(features, activation, bn)
-
- self.skip_add = nn.quantized.FloatFunctional()
-
- def forward(self, *xs):
- """Forward pass.
-
- Returns:
- tensor: output
- """
- output = xs[0]
-
- if len(xs) == 2:
- res = self.resConfUnit1(xs[1])
- output = self.skip_add.add(output, res)
- # output += res
-
- output = self.resConfUnit2(output)
-
- output = nn.functional.interpolate(
- output, scale_factor=2, mode="bilinear", align_corners=self.align_corners
- )
-
- output = self.out_conv(output)
-
- return output
-
diff --git a/spaces/Mellow-ai/PhotoAI_Mellow/annotator/uniformer/mmcv/video/optflow.py b/spaces/Mellow-ai/PhotoAI_Mellow/annotator/uniformer/mmcv/video/optflow.py
deleted file mode 100644
index 84160f8d6ef9fceb5a2f89e7481593109fc1905d..0000000000000000000000000000000000000000
--- a/spaces/Mellow-ai/PhotoAI_Mellow/annotator/uniformer/mmcv/video/optflow.py
+++ /dev/null
@@ -1,254 +0,0 @@
-# Copyright (c) OpenMMLab. All rights reserved.
-import warnings
-
-import cv2
-import numpy as np
-
-from annotator.uniformer.mmcv.arraymisc import dequantize, quantize
-from annotator.uniformer.mmcv.image import imread, imwrite
-from annotator.uniformer.mmcv.utils import is_str
-
-
-def flowread(flow_or_path, quantize=False, concat_axis=0, *args, **kwargs):
- """Read an optical flow map.
-
- Args:
- flow_or_path (ndarray or str): A flow map or filepath.
- quantize (bool): whether to read quantized pair, if set to True,
- remaining args will be passed to :func:`dequantize_flow`.
- concat_axis (int): The axis that dx and dy are concatenated,
- can be either 0 or 1. Ignored if quantize is False.
-
- Returns:
- ndarray: Optical flow represented as a (h, w, 2) numpy array
- """
- if isinstance(flow_or_path, np.ndarray):
- if (flow_or_path.ndim != 3) or (flow_or_path.shape[-1] != 2):
- raise ValueError(f'Invalid flow with shape {flow_or_path.shape}')
- return flow_or_path
- elif not is_str(flow_or_path):
- raise TypeError(f'"flow_or_path" must be a filename or numpy array, '
- f'not {type(flow_or_path)}')
-
- if not quantize:
- with open(flow_or_path, 'rb') as f:
- try:
- header = f.read(4).decode('utf-8')
- except Exception:
- raise IOError(f'Invalid flow file: {flow_or_path}')
- else:
- if header != 'PIEH':
- raise IOError(f'Invalid flow file: {flow_or_path}, '
- 'header does not contain PIEH')
-
- w = np.fromfile(f, np.int32, 1).squeeze()
- h = np.fromfile(f, np.int32, 1).squeeze()
- flow = np.fromfile(f, np.float32, w * h * 2).reshape((h, w, 2))
- else:
- assert concat_axis in [0, 1]
- cat_flow = imread(flow_or_path, flag='unchanged')
- if cat_flow.ndim != 2:
- raise IOError(
- f'{flow_or_path} is not a valid quantized flow file, '
- f'its dimension is {cat_flow.ndim}.')
- assert cat_flow.shape[concat_axis] % 2 == 0
- dx, dy = np.split(cat_flow, 2, axis=concat_axis)
- flow = dequantize_flow(dx, dy, *args, **kwargs)
-
- return flow.astype(np.float32)
-
-
-def flowwrite(flow, filename, quantize=False, concat_axis=0, *args, **kwargs):
- """Write optical flow to file.
-
- If the flow is not quantized, it will be saved as a .flo file losslessly,
- otherwise a jpeg image which is lossy but of much smaller size. (dx and dy
- will be concatenated horizontally into a single image if quantize is True.)
-
- Args:
- flow (ndarray): (h, w, 2) array of optical flow.
- filename (str): Output filepath.
- quantize (bool): Whether to quantize the flow and save it to 2 jpeg
- images. If set to True, remaining args will be passed to
- :func:`quantize_flow`.
- concat_axis (int): The axis that dx and dy are concatenated,
- can be either 0 or 1. Ignored if quantize is False.
- """
- if not quantize:
- with open(filename, 'wb') as f:
- f.write('PIEH'.encode('utf-8'))
- np.array([flow.shape[1], flow.shape[0]], dtype=np.int32).tofile(f)
- flow = flow.astype(np.float32)
- flow.tofile(f)
- f.flush()
- else:
- assert concat_axis in [0, 1]
- dx, dy = quantize_flow(flow, *args, **kwargs)
- dxdy = np.concatenate((dx, dy), axis=concat_axis)
- imwrite(dxdy, filename)
-
-
-def quantize_flow(flow, max_val=0.02, norm=True):
- """Quantize flow to [0, 255].
-
- After this step, the size of flow will be much smaller, and can be
- dumped as jpeg images.
-
- Args:
- flow (ndarray): (h, w, 2) array of optical flow.
- max_val (float): Maximum value of flow, values beyond
- [-max_val, max_val] will be truncated.
- norm (bool): Whether to divide flow values by image width/height.
-
- Returns:
- tuple[ndarray]: Quantized dx and dy.
- """
- h, w, _ = flow.shape
- dx = flow[..., 0]
- dy = flow[..., 1]
- if norm:
- dx = dx / w # avoid inplace operations
- dy = dy / h
- # use 255 levels instead of 256 to make sure 0 is 0 after dequantization.
- flow_comps = [
- quantize(d, -max_val, max_val, 255, np.uint8) for d in [dx, dy]
- ]
- return tuple(flow_comps)
-
-
-def dequantize_flow(dx, dy, max_val=0.02, denorm=True):
- """Recover from quantized flow.
-
- Args:
- dx (ndarray): Quantized dx.
- dy (ndarray): Quantized dy.
- max_val (float): Maximum value used when quantizing.
- denorm (bool): Whether to multiply flow values with width/height.
-
- Returns:
- ndarray: Dequantized flow.
- """
- assert dx.shape == dy.shape
- assert dx.ndim == 2 or (dx.ndim == 3 and dx.shape[-1] == 1)
-
- dx, dy = [dequantize(d, -max_val, max_val, 255) for d in [dx, dy]]
-
- if denorm:
- dx *= dx.shape[1]
- dy *= dx.shape[0]
- flow = np.dstack((dx, dy))
- return flow
-
-
-def flow_warp(img, flow, filling_value=0, interpolate_mode='nearest'):
- """Use flow to warp img.
-
- Args:
- img (ndarray, float or uint8): Image to be warped.
- flow (ndarray, float): Optical Flow.
- filling_value (int): The missing pixels will be set with filling_value.
- interpolate_mode (str): bilinear -> Bilinear Interpolation;
- nearest -> Nearest Neighbor.
-
- Returns:
- ndarray: Warped image with the same shape of img
- """
- warnings.warn('This function is just for prototyping and cannot '
- 'guarantee the computational efficiency.')
- assert flow.ndim == 3, 'Flow must be in 3D arrays.'
- height = flow.shape[0]
- width = flow.shape[1]
- channels = img.shape[2]
-
- output = np.ones(
- (height, width, channels), dtype=img.dtype) * filling_value
-
- grid = np.indices((height, width)).swapaxes(0, 1).swapaxes(1, 2)
- dx = grid[:, :, 0] + flow[:, :, 1]
- dy = grid[:, :, 1] + flow[:, :, 0]
- sx = np.floor(dx).astype(int)
- sy = np.floor(dy).astype(int)
- valid = (sx >= 0) & (sx < height - 1) & (sy >= 0) & (sy < width - 1)
-
- if interpolate_mode == 'nearest':
- output[valid, :] = img[dx[valid].round().astype(int),
- dy[valid].round().astype(int), :]
- elif interpolate_mode == 'bilinear':
- # dirty walkround for integer positions
- eps_ = 1e-6
- dx, dy = dx + eps_, dy + eps_
- left_top_ = img[np.floor(dx[valid]).astype(int),
- np.floor(dy[valid]).astype(int), :] * (
- np.ceil(dx[valid]) - dx[valid])[:, None] * (
- np.ceil(dy[valid]) - dy[valid])[:, None]
- left_down_ = img[np.ceil(dx[valid]).astype(int),
- np.floor(dy[valid]).astype(int), :] * (
- dx[valid] - np.floor(dx[valid]))[:, None] * (
- np.ceil(dy[valid]) - dy[valid])[:, None]
- right_top_ = img[np.floor(dx[valid]).astype(int),
- np.ceil(dy[valid]).astype(int), :] * (
- np.ceil(dx[valid]) - dx[valid])[:, None] * (
- dy[valid] - np.floor(dy[valid]))[:, None]
- right_down_ = img[np.ceil(dx[valid]).astype(int),
- np.ceil(dy[valid]).astype(int), :] * (
- dx[valid] - np.floor(dx[valid]))[:, None] * (
- dy[valid] - np.floor(dy[valid]))[:, None]
- output[valid, :] = left_top_ + left_down_ + right_top_ + right_down_
- else:
- raise NotImplementedError(
- 'We only support interpolation modes of nearest and bilinear, '
- f'but got {interpolate_mode}.')
- return output.astype(img.dtype)
-
-
-def flow_from_bytes(content):
- """Read dense optical flow from bytes.
-
- .. note::
- This load optical flow function works for FlyingChairs, FlyingThings3D,
- Sintel, FlyingChairsOcc datasets, but cannot load the data from
- ChairsSDHom.
-
- Args:
- content (bytes): Optical flow bytes got from files or other streams.
-
- Returns:
- ndarray: Loaded optical flow with the shape (H, W, 2).
- """
-
- # header in first 4 bytes
- header = content[:4]
- if header.decode('utf-8') != 'PIEH':
- raise Exception('Flow file header does not contain PIEH')
- # width in second 4 bytes
- width = np.frombuffer(content[4:], np.int32, 1).squeeze()
- # height in third 4 bytes
- height = np.frombuffer(content[8:], np.int32, 1).squeeze()
- # after first 12 bytes, all bytes are flow
- flow = np.frombuffer(content[12:], np.float32, width * height * 2).reshape(
- (height, width, 2))
-
- return flow
-
-
-def sparse_flow_from_bytes(content):
- """Read the optical flow in KITTI datasets from bytes.
-
- This function is modified from RAFT load the `KITTI datasets
- `_.
-
- Args:
- content (bytes): Optical flow bytes got from files or other streams.
-
- Returns:
- Tuple(ndarray, ndarray): Loaded optical flow with the shape (H, W, 2)
- and flow valid mask with the shape (H, W).
- """ # nopa
-
- content = np.frombuffer(content, np.uint8)
- flow = cv2.imdecode(content, cv2.IMREAD_ANYDEPTH | cv2.IMREAD_COLOR)
- flow = flow[:, :, ::-1].astype(np.float32)
- # flow shape (H, W, 2) valid shape (H, W)
- flow, valid = flow[:, :, :2], flow[:, :, 2]
- flow = (flow - 2**15) / 64.0
- return flow, valid
diff --git a/spaces/Michale1017/Auto-keep-online/README.md b/spaces/Michale1017/Auto-keep-online/README.md
deleted file mode 100644
index 04f8bbb0cf1aa866057895161fb1a070280c14f2..0000000000000000000000000000000000000000
--- a/spaces/Michale1017/Auto-keep-online/README.md
+++ /dev/null
@@ -1,10 +0,0 @@
----
-title: Auto Keep Online
-emoji: 📈
-colorFrom: indigo
-colorTo: purple
-sdk: docker
-pinned: false
----
-
-Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
diff --git a/spaces/Miuzarte/SUI-svc-4.0/vdecoder/hifigan/nvSTFT.py b/spaces/Miuzarte/SUI-svc-4.0/vdecoder/hifigan/nvSTFT.py
deleted file mode 100644
index 88597d62a505715091f9ba62d38bf0a85a31b95a..0000000000000000000000000000000000000000
--- a/spaces/Miuzarte/SUI-svc-4.0/vdecoder/hifigan/nvSTFT.py
+++ /dev/null
@@ -1,111 +0,0 @@
-import math
-import os
-os.environ["LRU_CACHE_CAPACITY"] = "3"
-import random
-import torch
-import torch.utils.data
-import numpy as np
-import librosa
-from librosa.util import normalize
-from librosa.filters import mel as librosa_mel_fn
-from scipy.io.wavfile import read
-import soundfile as sf
-
-def load_wav_to_torch(full_path, target_sr=None, return_empty_on_exception=False):
- sampling_rate = None
- try:
- data, sampling_rate = sf.read(full_path, always_2d=True)# than soundfile.
- except Exception as ex:
- print(f"'{full_path}' failed to load.\nException:")
- print(ex)
- if return_empty_on_exception:
- return [], sampling_rate or target_sr or 32000
- else:
- raise Exception(ex)
-
- if len(data.shape) > 1:
- data = data[:, 0]
- assert len(data) > 2# check duration of audio file is > 2 samples (because otherwise the slice operation was on the wrong dimension)
-
- if np.issubdtype(data.dtype, np.integer): # if audio data is type int
- max_mag = -np.iinfo(data.dtype).min # maximum magnitude = min possible value of intXX
- else: # if audio data is type fp32
- max_mag = max(np.amax(data), -np.amin(data))
- max_mag = (2**31)+1 if max_mag > (2**15) else ((2**15)+1 if max_mag > 1.01 else 1.0) # data should be either 16-bit INT, 32-bit INT or [-1 to 1] float32
-
- data = torch.FloatTensor(data.astype(np.float32))/max_mag
-
- if (torch.isinf(data) | torch.isnan(data)).any() and return_empty_on_exception:# resample will crash with inf/NaN inputs. return_empty_on_exception will return empty arr instead of except
- return [], sampling_rate or target_sr or 32000
- if target_sr is not None and sampling_rate != target_sr:
- data = torch.from_numpy(librosa.core.resample(data.numpy(), orig_sr=sampling_rate, target_sr=target_sr))
- sampling_rate = target_sr
-
- return data, sampling_rate
-
-def dynamic_range_compression(x, C=1, clip_val=1e-5):
- return np.log(np.clip(x, a_min=clip_val, a_max=None) * C)
-
-def dynamic_range_decompression(x, C=1):
- return np.exp(x) / C
-
-def dynamic_range_compression_torch(x, C=1, clip_val=1e-5):
- return torch.log(torch.clamp(x, min=clip_val) * C)
-
-def dynamic_range_decompression_torch(x, C=1):
- return torch.exp(x) / C
-
-class STFT():
- def __init__(self, sr=22050, n_mels=80, n_fft=1024, win_size=1024, hop_length=256, fmin=20, fmax=11025, clip_val=1e-5):
- self.target_sr = sr
-
- self.n_mels = n_mels
- self.n_fft = n_fft
- self.win_size = win_size
- self.hop_length = hop_length
- self.fmin = fmin
- self.fmax = fmax
- self.clip_val = clip_val
- self.mel_basis = {}
- self.hann_window = {}
-
- def get_mel(self, y, center=False):
- sampling_rate = self.target_sr
- n_mels = self.n_mels
- n_fft = self.n_fft
- win_size = self.win_size
- hop_length = self.hop_length
- fmin = self.fmin
- fmax = self.fmax
- clip_val = self.clip_val
-
- if torch.min(y) < -1.:
- print('min value is ', torch.min(y))
- if torch.max(y) > 1.:
- print('max value is ', torch.max(y))
-
- if fmax not in self.mel_basis:
- mel = librosa_mel_fn(sr=sampling_rate, n_fft=n_fft, n_mels=n_mels, fmin=fmin, fmax=fmax)
- self.mel_basis[str(fmax)+'_'+str(y.device)] = torch.from_numpy(mel).float().to(y.device)
- self.hann_window[str(y.device)] = torch.hann_window(self.win_size).to(y.device)
-
- y = torch.nn.functional.pad(y.unsqueeze(1), (int((n_fft-hop_length)/2), int((n_fft-hop_length)/2)), mode='reflect')
- y = y.squeeze(1)
-
- spec = torch.stft(y, n_fft, hop_length=hop_length, win_length=win_size, window=self.hann_window[str(y.device)],
- center=center, pad_mode='reflect', normalized=False, onesided=True)
- # print(111,spec)
- spec = torch.sqrt(spec.pow(2).sum(-1)+(1e-9))
- # print(222,spec)
- spec = torch.matmul(self.mel_basis[str(fmax)+'_'+str(y.device)], spec)
- # print(333,spec)
- spec = dynamic_range_compression_torch(spec, clip_val=clip_val)
- # print(444,spec)
- return spec
-
- def __call__(self, audiopath):
- audio, sr = load_wav_to_torch(audiopath, target_sr=self.target_sr)
- spect = self.get_mel(audio.unsqueeze(0)).squeeze(0)
- return spect
-
-stft = STFT()
diff --git a/spaces/Mostafa92/detecting_plant_leaf_diseases/article.md b/spaces/Mostafa92/detecting_plant_leaf_diseases/article.md
deleted file mode 100644
index b6563f7641b9a764682796e9b7ba91b8223ed69c..0000000000000000000000000000000000000000
--- a/spaces/Mostafa92/detecting_plant_leaf_diseases/article.md
+++ /dev/null
@@ -1,82 +0,0 @@
-## EXAMPLES
-- We added a test_data folder which contains around 740 images from our **test dataset of 5000 images**, that's around 15 to 20 image per class and all of these images are shuffled and used as examples in this demo web app.
-**Can you see which images the model got it wrong?**
-
-
-## Dataset
-
-In this data-set, 39 different classes of plant leaf and background images are available. The data-set containing 61,486 images. This data comes with six different augmentation techniques for increasing the data-set size. The techniques are image flipping, Gamma correction, noise injection, PCA color augmentation, rotation, and Scaling. [see more](https://data.mendeley.com/datasets/tywbtsjrjv/1)
-
-
-## Model Architecture
-----------------------------------------------------------------
-| Layer (type) | Output Shape | Param |
-|-----------------------|:------------------------:|-------------:|
-| Conv2d-1 | [-1, 64, 256, 256] | 1,792 |
-| BatchNorm2d-2 | [-1, 64, 256, 256] | 128 |
-| ReLU-3 | [-1, 64, 256, 256] | 0 |
-| Conv2d-4 | [-1, 128, 256, 256] | 73,856 |
-| BatchNorm2d-5 | [-1, 128, 256, 256] | 256 |
-| ReLU-6 | [-1, 128, 256, 256] | 0 |
-| MaxPool2d-7 | [-1, 128, 64, 64] | 0 |
-| Conv2d-8 | [-1, 128, 64, 64] | 147,584 |
-| BatchNorm2d-9 | [-1, 128, 64, 64] | 256 |
-| ReLU-10 | [-1, 128, 64, 64] | 0 |
-| Conv2d-11 | [-1, 128, 64, 64] | 147,584 |
-| BatchNorm2d-12 | [-1, 128, 64, 64] | 256 |
-| ReLU-13 | [-1, 128, 64, 64] | 0 |
-| Conv2d-14 | [-1, 256, 64, 64] | 295,168 |
-| BatchNorm2d-15 | [-1, 256, 64, 64] | 512 |
-| ReLU-16 | [-1, 256, 64, 64] | 0 |
-| MaxPool2d-17 | [-1, 256, 16, 16] | 0 |
-| Conv2d-18 | [-1, 512, 16, 16] | 1,180,160 |
-| BatchNorm2d-19 | [-1, 512, 16, 16] | 1,024 |
-| ReLU-20 | [-1, 512, 16, 16] | 0 |
-| MaxPool2d-21 | [-1, 512, 4, 4] | 0 |
-| Conv2d-22 | [-1, 512, 4, 4] | 2,359,808 |
-| BatchNorm2d-23 | [-1, 512, 4, 4] | 1,024 |
-| ReLU-24 | [-1, 512, 4, 4] | 0 |
-| Conv2d-25 | [-1, 512, 4, 4] | 2,359,808 |
-| BatchNorm2d-26 | [-1, 512, 4, 4] | 1,024 |
-| ReLU-27 | [-1, 512, 4, 4] | 0 |
-| MaxPool2d-28 | [-1, 512, 1, 1] | 0 |
-| Flatten-29 | [-1, 512] | 0 |
-| Dropout-30 | [-1, 512] | 0 |
-| Linear-31 | [-1, 39] | 20,007 |
-
-
-- **Total params: `6,590,247`**
-- **Trainable params: `6,590,247`**
-- **Non-trainable params: `0`**
-
-- **Input size (MB): `0.75`**
-- **Forward/backward pass size (MB): `343.95`**
-- **Params size (MB): `25.14`**
-- **Estimated Total Size (MB): 369.84`**
-
-----------------------------------------------------------------
-## Training
-
-- **Epoch [1], last_lr: `0.00696`, train_loss: `0.9292`, val_loss: `0.4448`, val_acc: `0.8572`**
-- **Epoch [2], last_lr: `0.00324`, train_loss: `0.2816`, val_loss: `0.3342`, val_acc: `0.8999`**
-- **Epoch [3], last_lr: `0.00000`, train_loss: `0.0851`, val_loss: `0.0355`, val_acc: `0.9931`**
-- **CPU times: user 18min 48s, sys: 14min 36s, total: 33min 25s**
-**Wall time: `33min 29s`**
-
-### Params
-- **EPOCHS = `3`**
-- **MAX_LR = `0.007`**
-- **GRAD_CLIP = `0.1`**
-- **WEIGHT_DECAY = `1e-4`**
-- **OPTIMIZER = `torch.optim.Adam`**
-
-----------------------------------------------------------------
-
-## Important Info
-- **Model size is: `(25.17M)`**
-- **Validation Accuracy is: `99.3%`**
-- **Last validation Loss is: `0.0355`**
-- **Last Train Loss is: `0.0851`**
-- **Test Accuracy is: `99.1%`**
-
-----------------------------------------------------------------
\ No newline at end of file
diff --git a/spaces/Mountchicken/MAERec-Gradio/mmocr/models/textrecog/decoders/sar_decoder.py b/spaces/Mountchicken/MAERec-Gradio/mmocr/models/textrecog/decoders/sar_decoder.py
deleted file mode 100644
index d156c30fd144a5256965c7bc376ab5645c925792..0000000000000000000000000000000000000000
--- a/spaces/Mountchicken/MAERec-Gradio/mmocr/models/textrecog/decoders/sar_decoder.py
+++ /dev/null
@@ -1,574 +0,0 @@
-# Copyright (c) OpenMMLab. All rights reserved.
-import math
-from typing import Dict, List, Optional, Sequence, Union
-
-import torch
-import torch.nn as nn
-import torch.nn.functional as F
-
-from mmocr.models.common.dictionary import Dictionary
-from mmocr.registry import MODELS
-from mmocr.structures import TextRecogDataSample
-from .base import BaseDecoder
-
-
-@MODELS.register_module()
-class ParallelSARDecoder(BaseDecoder):
- """Implementation Parallel Decoder module in `SAR.
-
- `_.
-
- Args:
- dictionary (dict or :obj:`Dictionary`): The config for `Dictionary` or
- the instance of `Dictionary`.
- module_loss (dict, optional): Config to build module_loss. Defaults
- to None.
- postprocessor (dict, optional): Config to build postprocessor.
- Defaults to None.
- enc_bi_rnn (bool): If True, use bidirectional RNN in encoder.
- Defaults to False.
- dec_bi_rnn (bool): If True, use bidirectional RNN in decoder.
- Defaults to False.
- dec_rnn_dropout (float): Dropout of RNN layer in decoder.
- Defaults to 0.0.
- dec_gru (bool): If True, use GRU, else LSTM in decoder. Defaults to
- False.
- d_model (int): Dim of channels from backbone :math:`D_i`. Defaults
- to 512.
- d_enc (int): Dim of encoder RNN layer :math:`D_m`. Defaults to 512.
- d_k (int): Dim of channels of attention module. Defaults to 64.
- pred_dropout (float): Dropout probability of prediction layer. Defaults
- to 0.0.
- max_seq_len (int): Maximum sequence length for decoding. Defaults to
- 30.
- mask (bool): If True, mask padding in feature map. Defaults to True.
- pred_concat (bool): If True, concat glimpse feature from
- attention with holistic feature and hidden state. Defaults to
- False.
- init_cfg (dict or list[dict], optional): Initialization configs.
- Defaults to None.
- """
-
- def __init__(self,
- dictionary: Union[Dict, Dictionary],
- module_loss: Optional[Dict] = None,
- postprocessor: Optional[Dict] = None,
- enc_bi_rnn: bool = False,
- dec_bi_rnn: bool = False,
- dec_rnn_dropout: Union[int, float] = 0.0,
- dec_gru: bool = False,
- d_model: int = 512,
- d_enc: int = 512,
- d_k: int = 64,
- pred_dropout: float = 0.0,
- max_seq_len: int = 30,
- mask: bool = True,
- pred_concat: bool = False,
- init_cfg: Optional[Union[Dict, List[Dict]]] = None,
- **kwargs) -> None:
- super().__init__(
- dictionary=dictionary,
- module_loss=module_loss,
- max_seq_len=max_seq_len,
- postprocessor=postprocessor,
- init_cfg=init_cfg)
-
- self.num_classes = self.dictionary.num_classes
- self.enc_bi_rnn = enc_bi_rnn
- self.d_k = d_k
- self.start_idx = self.dictionary.start_idx
- self.mask = mask
- self.pred_concat = pred_concat
-
- encoder_rnn_out_size = d_enc * (int(enc_bi_rnn) + 1)
- decoder_rnn_out_size = encoder_rnn_out_size * (int(dec_bi_rnn) + 1)
- # 2D attention layer
- self.conv1x1_1 = nn.Linear(decoder_rnn_out_size, d_k)
- self.conv3x3_1 = nn.Conv2d(
- d_model, d_k, kernel_size=3, stride=1, padding=1)
- self.conv1x1_2 = nn.Linear(d_k, 1)
-
- # Decoder RNN layer
- kwargs = dict(
- input_size=encoder_rnn_out_size,
- hidden_size=encoder_rnn_out_size,
- num_layers=2,
- batch_first=True,
- dropout=dec_rnn_dropout,
- bidirectional=dec_bi_rnn)
- if dec_gru:
- self.rnn_decoder = nn.GRU(**kwargs)
- else:
- self.rnn_decoder = nn.LSTM(**kwargs)
-
- # Decoder input embedding
- self.embedding = nn.Embedding(
- self.num_classes,
- encoder_rnn_out_size,
- padding_idx=self.dictionary.padding_idx)
-
- # Prediction layer
- self.pred_dropout = nn.Dropout(pred_dropout)
- if pred_concat:
- fc_in_channel = decoder_rnn_out_size + d_model + \
- encoder_rnn_out_size
- else:
- fc_in_channel = d_model
- self.prediction = nn.Linear(fc_in_channel, self.num_classes)
- self.softmax = nn.Softmax(dim=-1)
-
- def _2d_attention(self,
- decoder_input: torch.Tensor,
- feat: torch.Tensor,
- holistic_feat: torch.Tensor,
- valid_ratios: Optional[Sequence[float]] = None
- ) -> torch.Tensor:
- """2D attention layer.
-
- Args:
- decoder_input (torch.Tensor): Input of decoder RNN.
- feat (torch.Tensor): Feature map of encoder.
- holistic_feat (torch.Tensor): Feature map of holistic encoder.
- valid_ratios (Sequence[float]): Valid ratios of attention.
- Defaults to None.
-
- Returns:
- torch.Tensor: Output of 2D attention layer.
- """
- y = self.rnn_decoder(decoder_input)[0]
- # y: bsz * (seq_len + 1) * hidden_size
-
- attn_query = self.conv1x1_1(y) # bsz * (seq_len + 1) * attn_size
- bsz, seq_len, attn_size = attn_query.size()
- attn_query = attn_query.view(bsz, seq_len, attn_size, 1, 1)
-
- attn_key = self.conv3x3_1(feat)
- # bsz * attn_size * h * w
- attn_key = attn_key.unsqueeze(1)
- # bsz * 1 * attn_size * h * w
-
- attn_weight = torch.tanh(torch.add(attn_key, attn_query, alpha=1))
- # bsz * (seq_len + 1) * attn_size * h * w
- attn_weight = attn_weight.permute(0, 1, 3, 4, 2).contiguous()
- # bsz * (seq_len + 1) * h * w * attn_size
- attn_weight = self.conv1x1_2(attn_weight)
- # bsz * (seq_len + 1) * h * w * 1
- bsz, T, h, w, c = attn_weight.size()
- assert c == 1
-
- if valid_ratios is not None:
- # cal mask of attention weight
- attn_mask = torch.zeros_like(attn_weight)
- for i, valid_ratio in enumerate(valid_ratios):
- valid_width = min(w, math.ceil(w * valid_ratio))
- attn_mask[i, :, :, valid_width:, :] = 1
- attn_weight = attn_weight.masked_fill(attn_mask.bool(),
- float('-inf'))
-
- attn_weight = attn_weight.view(bsz, T, -1)
- attn_weight = F.softmax(attn_weight, dim=-1)
- attn_weight = attn_weight.view(bsz, T, h, w,
- c).permute(0, 1, 4, 2, 3).contiguous()
-
- attn_feat = torch.sum(
- torch.mul(feat.unsqueeze(1), attn_weight), (3, 4), keepdim=False)
- # bsz * (seq_len + 1) * C
-
- # linear transformation
- if self.pred_concat:
- hf_c = holistic_feat.size(-1)
- holistic_feat = holistic_feat.expand(bsz, seq_len, hf_c)
- y = self.prediction(torch.cat((y, attn_feat, holistic_feat), 2))
- else:
- y = self.prediction(attn_feat)
- # bsz * (seq_len + 1) * num_classes
- y = self.pred_dropout(y)
-
- return y
-
- def forward_train(self, feat: torch.Tensor, out_enc: torch.Tensor,
- data_samples: Sequence[TextRecogDataSample]
- ) -> torch.Tensor:
- """
- Args:
- feat (Tensor): Tensor of shape :math:`(N, D_i, H, W)`.
- out_enc (Tensor): Encoder output of shape
- :math:`(N, D_m, H, W)`.
- data_samples (list[TextRecogDataSample]): Batch of
- TextRecogDataSample, containing gt_text and valid_ratio
- information.
-
- Returns:
- Tensor: A raw logit tensor of shape :math:`(N, T, C)`.
- """
- if data_samples is not None:
- assert len(data_samples) == feat.size(0)
-
- valid_ratios = [
- img_meta.get('valid_ratio', 1.0) for img_meta in data_samples
- ] if self.mask else None
-
- padded_targets = [
- data_sample.gt_text.padded_indexes for data_sample in data_samples
- ]
- padded_targets = torch.stack(padded_targets, dim=0).to(feat.device)
- tgt_embedding = self.embedding(padded_targets)
- # bsz * seq_len * emb_dim
- out_enc = out_enc.unsqueeze(1)
- # bsz * 1 * emb_dim
- in_dec = torch.cat((out_enc, tgt_embedding), dim=1)
- # bsz * (seq_len + 1) * C
- out_dec = self._2d_attention(
- in_dec, feat, out_enc, valid_ratios=valid_ratios)
- # bsz * (seq_len + 1) * num_classes
-
- return out_dec[:, 1:, :] # bsz * seq_len * num_classes
-
- def forward_test(
- self,
- feat: torch.Tensor,
- out_enc: torch.Tensor,
- data_samples: Optional[Sequence[TextRecogDataSample]] = None
- ) -> torch.Tensor:
- """
- Args:
- feat (Tensor): Tensor of shape :math:`(N, D_i, H, W)`.
- out_enc (Tensor): Encoder output of shape
- :math:`(N, D_m, H, W)`.
- data_samples (list[TextRecogDataSample], optional): Batch of
- TextRecogDataSample, containing valid_ratio
- information. Defaults to None.
-
- Returns:
- Tensor: Character probabilities. of shape
- :math:`(N, self.max_seq_len, C)` where :math:`C` is
- ``num_classes``.
- """
- if data_samples is not None:
- assert len(data_samples) == feat.size(0)
-
- valid_ratios = None
- if data_samples is not None:
- valid_ratios = [
- data_sample.get('valid_ratio', 1.0)
- for data_sample in data_samples
- ] if self.mask else None
-
- seq_len = self.max_seq_len
-
- bsz = feat.size(0)
- start_token = torch.full((bsz, ),
- self.start_idx,
- device=feat.device,
- dtype=torch.long)
- # bsz
- start_token = self.embedding(start_token)
- # bsz * emb_dim
- start_token = start_token.unsqueeze(1).expand(-1, seq_len, -1)
- # bsz * seq_len * emb_dim
- out_enc = out_enc.unsqueeze(1)
- # bsz * 1 * emb_dim
- decoder_input = torch.cat((out_enc, start_token), dim=1)
- # bsz * (seq_len + 1) * emb_dim
-
- outputs = []
- for i in range(1, seq_len + 1):
- decoder_output = self._2d_attention(
- decoder_input, feat, out_enc, valid_ratios=valid_ratios)
- char_output = decoder_output[:, i, :] # bsz * num_classes
- outputs.append(char_output)
- _, max_idx = torch.max(char_output, dim=1, keepdim=False)
- char_embedding = self.embedding(max_idx) # bsz * emb_dim
- if i < seq_len:
- decoder_input[:, i + 1, :] = char_embedding
-
- outputs = torch.stack(outputs, 1) # bsz * seq_len * num_classes
-
- return self.softmax(outputs)
-
-
-@MODELS.register_module()
-class SequentialSARDecoder(BaseDecoder):
- """Implementation Sequential Decoder module in `SAR.
-
- `_.
-
- Args:
- dictionary (dict or :obj:`Dictionary`): The config for `Dictionary` or
- the instance of `Dictionary`.
- module_loss (dict, optional): Config to build module_loss. Defaults
- to None.
- postprocessor (dict, optional): Config to build postprocessor.
- Defaults to None.
- enc_bi_rnn (bool): If True, use bidirectional RNN in encoder. Defaults
- to False.
- dec_bi_rnn (bool): If True, use bidirectional RNN in decoder. Defaults
- to False.
- dec_do_rnn (float): Dropout of RNN layer in decoder. Defaults to 0.
- dec_gru (bool): If True, use GRU, else LSTM in decoder. Defaults to
- False.
- d_k (int): Dim of conv layers in attention module. Defaults to 64.
- d_model (int): Dim of channels from backbone :math:`D_i`. Defaults to
- 512.
- d_enc (int): Dim of encoder RNN layer :math:`D_m`. Defaults to 512.
- pred_dropout (float): Dropout probability of prediction layer. Defaults
- to 0.
- max_seq_len (int): Maximum sequence length during decoding. Defaults to
- 40.
- mask (bool): If True, mask padding in feature map. Defaults to False.
- pred_concat (bool): If True, concat glimpse feature from
- attention with holistic feature and hidden state. Defaults to
- False.
- init_cfg (dict or list[dict], optional): Initialization configs.
- Defaults to None.
- """
-
- def __init__(self,
- dictionary: Optional[Union[Dict, Dictionary]] = None,
- module_loss: Optional[Dict] = None,
- postprocessor: Optional[Dict] = None,
- enc_bi_rnn: bool = False,
- dec_bi_rnn: bool = False,
- dec_gru: bool = False,
- d_k: int = 64,
- d_model: int = 512,
- d_enc: int = 512,
- pred_dropout: float = 0.0,
- mask: bool = True,
- max_seq_len: int = 40,
- pred_concat: bool = False,
- init_cfg: Optional[Union[Dict, List[Dict]]] = None,
- **kwargs):
- super().__init__(
- dictionary=dictionary,
- module_loss=module_loss,
- postprocessor=postprocessor,
- max_seq_len=max_seq_len,
- init_cfg=init_cfg)
-
- self.num_classes = self.dictionary.num_classes
- self.enc_bi_rnn = enc_bi_rnn
- self.d_k = d_k
- self.start_idx = self.dictionary.start_idx
- self.dec_gru = dec_gru
- self.mask = mask
- self.pred_concat = pred_concat
-
- encoder_rnn_out_size = d_enc * (int(enc_bi_rnn) + 1)
- decoder_rnn_out_size = encoder_rnn_out_size * (int(dec_bi_rnn) + 1)
- # 2D attention layer
- self.conv1x1_1 = nn.Conv2d(
- decoder_rnn_out_size, d_k, kernel_size=1, stride=1)
- self.conv3x3_1 = nn.Conv2d(
- d_model, d_k, kernel_size=3, stride=1, padding=1)
- self.conv1x1_2 = nn.Conv2d(d_k, 1, kernel_size=1, stride=1)
-
- # Decoder rnn layer
- if dec_gru:
- self.rnn_decoder_layer1 = nn.GRUCell(encoder_rnn_out_size,
- encoder_rnn_out_size)
- self.rnn_decoder_layer2 = nn.GRUCell(encoder_rnn_out_size,
- encoder_rnn_out_size)
- else:
- self.rnn_decoder_layer1 = nn.LSTMCell(encoder_rnn_out_size,
- encoder_rnn_out_size)
- self.rnn_decoder_layer2 = nn.LSTMCell(encoder_rnn_out_size,
- encoder_rnn_out_size)
-
- # Decoder input embedding
- self.embedding = nn.Embedding(
- self.num_classes,
- encoder_rnn_out_size,
- padding_idx=self.dictionary.padding_idx)
-
- # Prediction layer
- self.pred_dropout = nn.Dropout(pred_dropout)
- if pred_concat:
- fc_in_channel = decoder_rnn_out_size + d_model + d_enc
- else:
- fc_in_channel = d_model
- self.prediction = nn.Linear(fc_in_channel, self.num_classes)
- self.softmax = nn.Softmax(dim=-1)
-
- def _2d_attention(self,
- y_prev: torch.Tensor,
- feat: torch.Tensor,
- holistic_feat: torch.Tensor,
- hx1: torch.Tensor,
- cx1: torch.Tensor,
- hx2: torch.Tensor,
- cx2: torch.Tensor,
- valid_ratios: Optional[Sequence[float]] = None
- ) -> torch.Tensor:
- """2D attention layer.
-
- Args:
- y_prev (torch.Tensor): Previous decoder hidden state.
- feat (torch.Tensor): Feature map.
- holistic_feat (torch.Tensor): Holistic feature map.
- hx1 (torch.Tensor): rnn decoder layer 1 hidden state.
- cx1 (torch.Tensor): rnn decoder layer 1 cell state.
- hx2 (torch.Tensor): rnn decoder layer 2 hidden state.
- cx2 (torch.Tensor): rnn decoder layer 2 cell state.
- valid_ratios (Optional[Sequence[float]]): Valid ratios of
- attention. Defaults to None.
- """
- _, _, h_feat, w_feat = feat.size()
- if self.dec_gru:
- hx1 = cx1 = self.rnn_decoder_layer1(y_prev, hx1)
- hx2 = cx2 = self.rnn_decoder_layer2(hx1, hx2)
- else:
- hx1, cx1 = self.rnn_decoder_layer1(y_prev, (hx1, cx1))
- hx2, cx2 = self.rnn_decoder_layer2(hx1, (hx2, cx2))
-
- tile_hx2 = hx2.view(hx2.size(0), hx2.size(1), 1, 1)
- attn_query = self.conv1x1_1(tile_hx2) # bsz * attn_size * 1 * 1
- attn_query = attn_query.expand(-1, -1, h_feat, w_feat)
- attn_key = self.conv3x3_1(feat)
- attn_weight = torch.tanh(torch.add(attn_key, attn_query, alpha=1))
- attn_weight = self.conv1x1_2(attn_weight)
- bsz, c, h, w = attn_weight.size()
- assert c == 1
-
- if valid_ratios is not None:
- # cal mask of attention weight
- attn_mask = torch.zeros_like(attn_weight)
- for i, valid_ratio in enumerate(valid_ratios):
- valid_width = min(w, math.ceil(w * valid_ratio))
- attn_mask[i, :, :, valid_width:] = 1
- attn_weight = attn_weight.masked_fill(attn_mask.bool(),
- float('-inf'))
-
- attn_weight = F.softmax(attn_weight.view(bsz, -1), dim=-1)
- attn_weight = attn_weight.view(bsz, c, h, w)
-
- attn_feat = torch.sum(
- torch.mul(feat, attn_weight), (2, 3), keepdim=False) # n * c
-
- # linear transformation
- if self.pred_concat:
- y = self.prediction(torch.cat((hx2, attn_feat, holistic_feat), 1))
- else:
- y = self.prediction(attn_feat)
-
- return y, hx1, hx1, hx2, hx2
-
- def forward_train(
- self,
- feat: torch.Tensor,
- out_enc: torch.Tensor,
- data_samples: Optional[Sequence[TextRecogDataSample]] = None
- ) -> torch.Tensor:
- """
- Args:
- feat (Tensor): Tensor of shape :math:`(N, D_i, H, W)`.
- out_enc (Tensor): Encoder output of shape
- :math:`(N, D_m, H, W)`.
- data_samples (list[TextRecogDataSample]): Batch of
- TextRecogDataSample, containing gt_text and valid_ratio
- information.
-
- Returns:
- Tensor: A raw logit tensor of shape :math:`(N, T, C)`.
- """
- valid_ratios = None
- if data_samples is not None:
- valid_ratios = [
- data_sample.get('valid_ratio', 1.0)
- for data_sample in data_samples
- ] if self.mask else None
-
- padded_targets = [
- data_sample.gt_text.padded_indexes for data_sample in data_samples
- ]
- padded_targets = torch.stack(padded_targets, dim=0).to(feat.device)
- tgt_embedding = self.embedding(padded_targets)
-
- outputs = []
- for i in range(-1, self.max_seq_len):
- if i == -1:
- if self.dec_gru:
- hx1 = cx1 = self.rnn_decoder_layer1(out_enc)
- hx2 = cx2 = self.rnn_decoder_layer2(hx1)
- else:
- hx1, cx1 = self.rnn_decoder_layer1(out_enc)
- hx2, cx2 = self.rnn_decoder_layer2(hx1)
- else:
- y_prev = tgt_embedding[:, i, :]
- y, hx1, cx1, hx2, cx2 = self._2d_attention(
- y_prev,
- feat,
- out_enc,
- hx1,
- cx1,
- hx2,
- cx2,
- valid_ratios=valid_ratios)
- y = self.pred_dropout(y)
-
- outputs.append(y)
-
- outputs = torch.stack(outputs, 1)
-
- return outputs
-
- def forward_test(
- self,
- feat: torch.Tensor,
- out_enc: torch.Tensor,
- data_samples: Optional[Sequence[TextRecogDataSample]] = None
- ) -> torch.Tensor:
- """
- Args:
- feat (Tensor): Tensor of shape :math:`(N, D_i, H, W)`.
- out_enc (Tensor): Encoder output of shape
- :math:`(N, D_m, H, W)`.
- data_samples (list[TextRecogDataSample]): Batch of
- TextRecogDataSample, containing valid_ratio
- information.
-
- Returns:
- Tensor: Character probabilities. of shape
- :math:`(N, self.max_seq_len, C)` where :math:`C` is
- ``num_classes``.
- """
- valid_ratios = None
- if data_samples is not None:
- valid_ratios = [
- data_sample.get('valid_ratio', 1.0)
- for data_sample in data_samples
- ] if self.mask else None
-
- outputs = []
- start_token = torch.full((feat.size(0), ),
- self.start_idx,
- device=feat.device,
- dtype=torch.long)
- start_token = self.embedding(start_token)
- for i in range(-1, self.max_seq_len):
- if i == -1:
- if self.dec_gru:
- hx1 = cx1 = self.rnn_decoder_layer1(out_enc)
- hx2 = cx2 = self.rnn_decoder_layer2(hx1)
- else:
- hx1, cx1 = self.rnn_decoder_layer1(out_enc)
- hx2, cx2 = self.rnn_decoder_layer2(hx1)
- y_prev = start_token
- else:
- y, hx1, cx1, hx2, cx2 = self._2d_attention(
- y_prev,
- feat,
- out_enc,
- hx1,
- cx1,
- hx2,
- cx2,
- valid_ratios=valid_ratios)
- _, max_idx = torch.max(y, dim=1, keepdim=False)
- char_embedding = self.embedding(max_idx)
- y_prev = char_embedding
- outputs.append(y)
-
- outputs = torch.stack(outputs, 1)
-
- return self.softmax(outputs)
diff --git a/spaces/Mountchicken/MAERec-Gradio/tools/dataset_converters/textrecog/art_converter.py b/spaces/Mountchicken/MAERec-Gradio/tools/dataset_converters/textrecog/art_converter.py
deleted file mode 100644
index 24acaad289be221558701d19a95ea7ce24a7e0f9..0000000000000000000000000000000000000000
--- a/spaces/Mountchicken/MAERec-Gradio/tools/dataset_converters/textrecog/art_converter.py
+++ /dev/null
@@ -1,108 +0,0 @@
-# Copyright (c) OpenMMLab. All rights reserved.
-import argparse
-import math
-import os.path as osp
-
-import mmengine
-
-from mmocr.utils import dump_ocr_data
-
-
-def parse_args():
- parser = argparse.ArgumentParser(
- description='Generate training and validation set of ArT ')
- parser.add_argument('root_path', help='Root dir path of ArT')
- parser.add_argument(
- '--val-ratio', help='Split ratio for val set', default=0.0, type=float)
- parser.add_argument(
- '--nproc', default=1, type=int, help='Number of processes')
- args = parser.parse_args()
- return args
-
-
-def convert_art(root_path, split, ratio):
- """Collect the annotation information and crop the images.
-
- The annotation format is as the following:
- {
- "gt_2836_0": [
- {
- "transcription": "URDER",
- "points": [
- [25, 51],
- [0, 2],
- [21, 0],
- [42, 43]
- ],
- "language": "Latin",
- "illegibility": false
- }
- ], ...
- }
-
- Args:
- root_path (str): The root path of the dataset
- split (str): The split of dataset. Namely: training or val
- ratio (float): Split ratio for val set
-
- Returns:
- img_info (dict): The dict of the img and annotation information
- """
-
- annotation_path = osp.join(root_path,
- 'annotations/train_task2_labels.json')
- if not osp.exists(annotation_path):
- raise Exception(
- f'{annotation_path} not exists, please check and try again.')
-
- annotation = mmengine.load(annotation_path)
- img_prefixes = annotation.keys()
-
- trn_files, val_files = [], []
- if ratio > 0:
- for i, file in enumerate(img_prefixes):
- if i % math.floor(1 / ratio):
- trn_files.append(file)
- else:
- val_files.append(file)
- else:
- trn_files, val_files = img_prefixes, []
- print(f'training #{len(trn_files)}, val #{len(val_files)}')
-
- if split == 'train':
- img_prefixes = trn_files
- elif split == 'val':
- img_prefixes = val_files
- else:
- raise NotImplementedError
-
- img_info = []
- for prefix in img_prefixes:
- text_label = annotation[prefix][0]['transcription']
- dst_img_name = prefix + '.jpg'
-
- img_info.append({
- 'file_name': dst_img_name,
- 'anno_info': [{
- 'text': text_label
- }]
- })
-
- ensure_ascii = dict(ensure_ascii=False)
- dump_ocr_data(img_info, osp.join(root_path, f'{split.lower()}_label.json'),
- 'textrecog', **ensure_ascii)
-
-
-def main():
- args = parse_args()
- root_path = args.root_path
- print('Processing training set...')
- convert_art(root_path=root_path, split='train', ratio=args.val_ratio)
- if args.val_ratio > 0:
- print('Processing validation set...')
- convert_art(root_path=root_path, split='val', ratio=args.val_ratio)
- print('Finish')
-
-
-if __name__ == '__main__':
- main()
diff --git a/spaces/NCTCMumbai/NCTC/models/official/vision/detection/configs/maskrcnn_config.py b/spaces/NCTCMumbai/NCTC/models/official/vision/detection/configs/maskrcnn_config.py
deleted file mode 100644
index 70c9b31448d3d83754c439c87ce9f0d0a04f88c9..0000000000000000000000000000000000000000
--- a/spaces/NCTCMumbai/NCTC/models/official/vision/detection/configs/maskrcnn_config.py
+++ /dev/null
@@ -1,116 +0,0 @@
-# Copyright 2019 The TensorFlow Authors. All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-# ==============================================================================
-"""Config template to train Mask R-CNN."""
-
-from official.modeling.hyperparams import params_dict
-from official.vision.detection.configs import base_config
-
-
-# pylint: disable=line-too-long
-MASKRCNN_CFG = params_dict.ParamsDict(base_config.BASE_CFG)
-MASKRCNN_CFG.override({
- 'type': 'mask_rcnn',
- 'eval': {
- 'type': 'box_and_mask',
- 'num_images_to_visualize': 0,
- },
- 'architecture': {
- 'parser': 'maskrcnn_parser',
- 'min_level': 2,
- 'max_level': 6,
- 'include_mask': True,
- 'mask_target_size': 28,
- },
- 'maskrcnn_parser': {
- 'output_size': [1024, 1024],
- 'num_channels': 3,
- 'rpn_match_threshold': 0.7,
- 'rpn_unmatched_threshold': 0.3,
- 'rpn_batch_size_per_im': 256,
- 'rpn_fg_fraction': 0.5,
- 'aug_rand_hflip': True,
- 'aug_scale_min': 1.0,
- 'aug_scale_max': 1.0,
- 'skip_crowd_during_training': True,
- 'max_num_instances': 100,
- 'mask_crop_size': 112,
- },
- 'anchor': {
- 'num_scales': 1,
- 'anchor_size': 8,
- },
- 'rpn_head': {
- 'anchors_per_location': 3,
- 'num_convs': 2,
- 'num_filters': 256,
- 'use_separable_conv': False,
- 'use_batch_norm': False,
- },
- 'frcnn_head': {
- 'num_convs': 0,
- 'num_filters': 256,
- 'use_separable_conv': False,
- 'num_fcs': 2,
- 'fc_dims': 1024,
- 'use_batch_norm': False,
- },
- 'mrcnn_head': {
- 'num_convs': 4,
- 'num_filters': 256,
- 'use_separable_conv': False,
- 'use_batch_norm': False,
- },
- 'rpn_score_loss': {
- 'rpn_batch_size_per_im': 256,
- },
- 'rpn_box_loss': {
- 'huber_loss_delta': 1.0 / 9.0,
- },
- 'frcnn_box_loss': {
- 'huber_loss_delta': 1.0,
- },
- 'roi_proposal': {
- 'rpn_pre_nms_top_k': 2000,
- 'rpn_post_nms_top_k': 1000,
- 'rpn_nms_threshold': 0.7,
- 'rpn_score_threshold': 0.0,
- 'rpn_min_size_threshold': 0.0,
- 'test_rpn_pre_nms_top_k': 1000,
- 'test_rpn_post_nms_top_k': 1000,
- 'test_rpn_nms_threshold': 0.7,
- 'test_rpn_score_threshold': 0.0,
- 'test_rpn_min_size_threshold': 0.0,
- 'use_batched_nms': False,
- },
- 'roi_sampling': {
- 'num_samples_per_image': 512,
- 'fg_fraction': 0.25,
- 'fg_iou_thresh': 0.5,
- 'bg_iou_thresh_hi': 0.5,
- 'bg_iou_thresh_lo': 0.0,
- 'mix_gt_boxes': True,
- },
- 'mask_sampling': {
- 'num_mask_samples_per_image': 128, # Typically = `num_samples_per_image` * `fg_fraction`.
- },
- 'postprocess': {
- 'pre_nms_num_boxes': 1000,
- },
-}, is_strict=False)
-
-
-MASKRCNN_RESTRICTIONS = [
-]
-# pylint: enable=line-too-long
diff --git a/spaces/NCTCMumbai/NCTC/models/official/vision/image_classification/resnet/__init__.py b/spaces/NCTCMumbai/NCTC/models/official/vision/image_classification/resnet/__init__.py
deleted file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000
diff --git a/spaces/NeoonN/Aurora/app.py b/spaces/NeoonN/Aurora/app.py
deleted file mode 100644
index 85bf55364c3584ab5eb78b40b49c35ded16f572f..0000000000000000000000000000000000000000
--- a/spaces/NeoonN/Aurora/app.py
+++ /dev/null
@@ -1,57 +0,0 @@
-import gradio as gr
-import numpy as np
-import pandas as pd
-from pandas.core.frame import DataFrame
-from PIL import Image
-import requests
-
-import hopsworks
-import joblib
-
-project = hopsworks.login()
-fs = project.get_feature_store()
-
-mr = project.get_model_registry()
-model = mr.get_model("aurora_model", version=1)
-model_dir = model.download()
-model = joblib.load(model_dir+"/aurora_model.pkl")
-
-
-def tb_aurora(Kp_index, visibility, icon):
- input_list = []
- input_list.append(Kp_index)
- input_list.append(visibility)
- input_icon = icon
-
- icon_feature_list = ['clear_day', 'clear_night', 'cloudy', 'fog', 'partly_cloudy_day', 'partly_cloudy_night', 'rain',
- 'snow', 'wind']
-
- icon_feature_list.append(input_icon)
-
- icon_df = DataFrame(icon_feature_list)
- icon_df_one = pd.get_dummies(icon_df)
- icon = icon_df_one.values.tolist()[9]
-
- input_list.extend(icon)
- print(input_list)
-
- # 'res' is a list of predictions returned as the label.
- # global res
- res = model.predict(np.asarray(input_list).reshape(1, 11))
- aurora_url = "https://raw.githubusercontent.com/NeoForNew/ID2223_scalable_machine_learning_and_deep_learning/main/Project/pic/" + str(res[0]) + ".png"
- img = Image.open(requests.get(aurora_url, stream=True).raw)
- return img
-
-demo = gr.Interface(
- fn=tb_aurora,
- title="Aurora Predictive Analytics",
- description="Predict aurora 0 for not occur and 1 for occur. ",
- inputs=[
- gr.inputs.Number(default=0.0, label="Kp_index"),
- gr.inputs.Number(default=0.0, label="visibility"),
- gr.inputs.Dropdown(['clear_day', 'clear_night', 'cloudy', 'fog', 'partly_cloudy_day', 'partly_cloudy_night', 'rain',
- 'snow', 'wind'], label="icon"),
- ],
- outputs=gr.Image(type="pil"))
-
-demo.launch()
\ No newline at end of file
diff --git a/spaces/Nultx/VITS-TTS/monotonic_align/setup.py b/spaces/Nultx/VITS-TTS/monotonic_align/setup.py
deleted file mode 100644
index 30c224807a70faa9df9c9eb75f8e80c8c867b16b..0000000000000000000000000000000000000000
--- a/spaces/Nultx/VITS-TTS/monotonic_align/setup.py
+++ /dev/null
@@ -1,9 +0,0 @@
-from distutils.core import setup
-from Cython.Build import cythonize
-import numpy
-
-setup(
- name = 'monotonic_align',
- ext_modules = cythonize("core.pyx"),
- include_dirs=[numpy.get_include()]
-)
diff --git a/spaces/OAOA/DifFace/basicsr/archs/srresnet_arch.py b/spaces/OAOA/DifFace/basicsr/archs/srresnet_arch.py
deleted file mode 100644
index 7f571557cd7d9ba8791bd6462fccf648c57186d2..0000000000000000000000000000000000000000
--- a/spaces/OAOA/DifFace/basicsr/archs/srresnet_arch.py
+++ /dev/null
@@ -1,65 +0,0 @@
-from torch import nn as nn
-from torch.nn import functional as F
-
-from basicsr.utils.registry import ARCH_REGISTRY
-from .arch_util import ResidualBlockNoBN, default_init_weights, make_layer
-
-
-@ARCH_REGISTRY.register()
-class MSRResNet(nn.Module):
- """Modified SRResNet.
-
- A compacted version modified from SRResNet in
- "Photo-Realistic Single Image Super-Resolution Using a Generative Adversarial Network"
- It uses residual blocks without BN, similar to EDSR.
- Currently, it supports x2, x3 and x4 upsampling scale factor.
-
- Args:
- num_in_ch (int): Channel number of inputs. Default: 3.
- num_out_ch (int): Channel number of outputs. Default: 3.
- num_feat (int): Channel number of intermediate features. Default: 64.
- num_block (int): Block number in the body network. Default: 16.
- upscale (int): Upsampling factor. Support x2, x3 and x4. Default: 4.
- """
-
- def __init__(self, num_in_ch=3, num_out_ch=3, num_feat=64, num_block=16, upscale=4):
- super(MSRResNet, self).__init__()
- self.upscale = upscale
-
- self.conv_first = nn.Conv2d(num_in_ch, num_feat, 3, 1, 1)
- self.body = make_layer(ResidualBlockNoBN, num_block, num_feat=num_feat)
-
- # upsampling
- if self.upscale in [2, 3]:
- self.upconv1 = nn.Conv2d(num_feat, num_feat * self.upscale * self.upscale, 3, 1, 1)
- self.pixel_shuffle = nn.PixelShuffle(self.upscale)
- elif self.upscale == 4:
- self.upconv1 = nn.Conv2d(num_feat, num_feat * 4, 3, 1, 1)
- self.upconv2 = nn.Conv2d(num_feat, num_feat * 4, 3, 1, 1)
- self.pixel_shuffle = nn.PixelShuffle(2)
-
- self.conv_hr = nn.Conv2d(num_feat, num_feat, 3, 1, 1)
- self.conv_last = nn.Conv2d(num_feat, num_out_ch, 3, 1, 1)
-
- # activation function
- self.lrelu = nn.LeakyReLU(negative_slope=0.1, inplace=True)
-
- # initialization
- default_init_weights([self.conv_first, self.upconv1, self.conv_hr, self.conv_last], 0.1)
- if self.upscale == 4:
- default_init_weights(self.upconv2, 0.1)
-
- def forward(self, x):
- feat = self.lrelu(self.conv_first(x))
- out = self.body(feat)
-
- if self.upscale == 4:
- out = self.lrelu(self.pixel_shuffle(self.upconv1(out)))
- out = self.lrelu(self.pixel_shuffle(self.upconv2(out)))
- elif self.upscale in [2, 3]:
- out = self.lrelu(self.pixel_shuffle(self.upconv1(out)))
-
- out = self.conv_last(self.lrelu(self.conv_hr(out)))
- base = F.interpolate(x, scale_factor=self.upscale, mode='bilinear', align_corners=False)
- out += base
- return out
diff --git a/spaces/OAOA/DifFace/basicsr/data/data_util.py b/spaces/OAOA/DifFace/basicsr/data/data_util.py
deleted file mode 100644
index bf4c494b7715399395a7d23dd87202d09592c725..0000000000000000000000000000000000000000
--- a/spaces/OAOA/DifFace/basicsr/data/data_util.py
+++ /dev/null
@@ -1,315 +0,0 @@
-import cv2
-import numpy as np
-import torch
-from os import path as osp
-from torch.nn import functional as F
-
-from basicsr.data.transforms import mod_crop
-from basicsr.utils import img2tensor, scandir
-
-
-def read_img_seq(path, require_mod_crop=False, scale=1, return_imgname=False):
- """Read a sequence of images from a given folder path.
-
- Args:
- path (list[str] | str): List of image paths or image folder path.
- require_mod_crop (bool): Require mod crop for each image.
- Default: False.
- scale (int): Scale factor for mod_crop. Default: 1.
- return_imgname(bool): Whether return image names. Default False.
-
- Returns:
- Tensor: size (t, c, h, w), RGB, [0, 1].
- list[str]: Returned image name list.
- """
- if isinstance(path, list):
- img_paths = path
- else:
- img_paths = sorted(list(scandir(path, full_path=True)))
- imgs = [cv2.imread(v).astype(np.float32) / 255. for v in img_paths]
-
- if require_mod_crop:
- imgs = [mod_crop(img, scale) for img in imgs]
- imgs = img2tensor(imgs, bgr2rgb=True, float32=True)
- imgs = torch.stack(imgs, dim=0)
-
- if return_imgname:
- imgnames = [osp.splitext(osp.basename(path))[0] for path in img_paths]
- return imgs, imgnames
- else:
- return imgs
-
-
-def generate_frame_indices(crt_idx, max_frame_num, num_frames, padding='reflection'):
- """Generate an index list for reading `num_frames` frames from a sequence
- of images.
-
- Args:
- crt_idx (int): Current center index.
- max_frame_num (int): Max number of the sequence of images (from 1).
- num_frames (int): Reading num_frames frames.
- padding (str): Padding mode, one of
- 'replicate' | 'reflection' | 'reflection_circle' | 'circle'
- Examples: current_idx = 0, num_frames = 5
- The generated frame indices under different padding mode:
- replicate: [0, 0, 0, 1, 2]
- reflection: [2, 1, 0, 1, 2]
- reflection_circle: [4, 3, 0, 1, 2]
- circle: [3, 4, 0, 1, 2]
-
- Returns:
- list[int]: A list of indices.
- """
- assert num_frames % 2 == 1, 'num_frames should be an odd number.'
- assert padding in ('replicate', 'reflection', 'reflection_circle', 'circle'), f'Wrong padding mode: {padding}.'
-
- max_frame_num = max_frame_num - 1 # start from 0
- num_pad = num_frames // 2
-
- indices = []
- for i in range(crt_idx - num_pad, crt_idx + num_pad + 1):
- if i < 0:
- if padding == 'replicate':
- pad_idx = 0
- elif padding == 'reflection':
- pad_idx = -i
- elif padding == 'reflection_circle':
- pad_idx = crt_idx + num_pad - i
- else:
- pad_idx = num_frames + i
- elif i > max_frame_num:
- if padding == 'replicate':
- pad_idx = max_frame_num
- elif padding == 'reflection':
- pad_idx = max_frame_num * 2 - i
- elif padding == 'reflection_circle':
- pad_idx = (crt_idx - num_pad) - (i - max_frame_num)
- else:
- pad_idx = i - num_frames
- else:
- pad_idx = i
- indices.append(pad_idx)
- return indices
-
-
-def paired_paths_from_lmdb(folders, keys):
- """Generate paired paths from lmdb files.
-
- Contents of lmdb. Taking the `lq.lmdb` for example, the file structure is:
-
- ::
-
- lq.lmdb
- ├── data.mdb
- ├── lock.mdb
- ├── meta_info.txt
-
- The data.mdb and lock.mdb are standard lmdb files and you can refer to
- https://lmdb.readthedocs.io/en/release/ for more details.
-
- The meta_info.txt is a specified txt file to record the meta information
- of our datasets. It will be automatically created when preparing
- datasets by our provided dataset tools.
- Each line in the txt file records
- 1)image name (with extension),
- 2)image shape,
- 3)compression level, separated by a white space.
- Example: `baboon.png (120,125,3) 1`
-
- We use the image name without extension as the lmdb key.
- Note that we use the same key for the corresponding lq and gt images.
-
- Args:
- folders (list[str]): A list of folder path. The order of list should
- be [input_folder, gt_folder].
- keys (list[str]): A list of keys identifying folders. The order should
- be in consistent with folders, e.g., ['lq', 'gt'].
- Note that this key is different from lmdb keys.
-
- Returns:
- list[str]: Returned path list.
- """
- assert len(folders) == 2, ('The len of folders should be 2 with [input_folder, gt_folder]. '
- f'But got {len(folders)}')
- assert len(keys) == 2, f'The len of keys should be 2 with [input_key, gt_key]. But got {len(keys)}'
- input_folder, gt_folder = folders
- input_key, gt_key = keys
-
- if not (input_folder.endswith('.lmdb') and gt_folder.endswith('.lmdb')):
- raise ValueError(f'{input_key} folder and {gt_key} folder should both in lmdb '
- f'formats. But received {input_key}: {input_folder}; '
- f'{gt_key}: {gt_folder}')
- # ensure that the two meta_info files are the same
- with open(osp.join(input_folder, 'meta_info.txt')) as fin:
- input_lmdb_keys = [line.split('.')[0] for line in fin]
- with open(osp.join(gt_folder, 'meta_info.txt')) as fin:
- gt_lmdb_keys = [line.split('.')[0] for line in fin]
- if set(input_lmdb_keys) != set(gt_lmdb_keys):
- raise ValueError(f'Keys in {input_key}_folder and {gt_key}_folder are different.')
- else:
- paths = []
- for lmdb_key in sorted(input_lmdb_keys):
- paths.append(dict([(f'{input_key}_path', lmdb_key), (f'{gt_key}_path', lmdb_key)]))
- return paths
-
-
-def paired_paths_from_meta_info_file(folders, keys, meta_info_file, filename_tmpl):
- """Generate paired paths from an meta information file.
-
- Each line in the meta information file contains the image names and
- image shape (usually for gt), separated by a white space.
-
- Example of an meta information file:
- ```
- 0001_s001.png (480,480,3)
- 0001_s002.png (480,480,3)
- ```
-
- Args:
- folders (list[str]): A list of folder path. The order of list should
- be [input_folder, gt_folder].
- keys (list[str]): A list of keys identifying folders. The order should
- be in consistent with folders, e.g., ['lq', 'gt'].
- meta_info_file (str): Path to the meta information file.
- filename_tmpl (str): Template for each filename. Note that the
- template excludes the file extension. Usually the filename_tmpl is
- for files in the input folder.
-
- Returns:
- list[str]: Returned path list.
- """
- assert len(folders) == 2, ('The len of folders should be 2 with [input_folder, gt_folder]. '
- f'But got {len(folders)}')
- assert len(keys) == 2, f'The len of keys should be 2 with [input_key, gt_key]. But got {len(keys)}'
- input_folder, gt_folder = folders
- input_key, gt_key = keys
-
- with open(meta_info_file, 'r') as fin:
- gt_names = [line.strip().split(' ')[0] for line in fin]
-
- paths = []
- for gt_name in gt_names:
- basename, ext = osp.splitext(osp.basename(gt_name))
- input_name = f'{filename_tmpl.format(basename)}{ext}'
- input_path = osp.join(input_folder, input_name)
- gt_path = osp.join(gt_folder, gt_name)
- paths.append(dict([(f'{input_key}_path', input_path), (f'{gt_key}_path', gt_path)]))
- return paths
-
-
-def paired_paths_from_folder(folders, keys, filename_tmpl):
- """Generate paired paths from folders.
-
- Args:
- folders (list[str]): A list of folder path. The order of list should
- be [input_folder, gt_folder].
- keys (list[str]): A list of keys identifying folders. The order should
- be in consistent with folders, e.g., ['lq', 'gt'].
- filename_tmpl (str): Template for each filename. Note that the
- template excludes the file extension. Usually the filename_tmpl is
- for files in the input folder.
-
- Returns:
- list[str]: Returned path list.
- """
- assert len(folders) == 2, ('The len of folders should be 2 with [input_folder, gt_folder]. '
- f'But got {len(folders)}')
- assert len(keys) == 2, f'The len of keys should be 2 with [input_key, gt_key]. But got {len(keys)}'
- input_folder, gt_folder = folders
- input_key, gt_key = keys
-
- input_paths = list(scandir(input_folder))
- gt_paths = list(scandir(gt_folder))
- assert len(input_paths) == len(gt_paths), (f'{input_key} and {gt_key} datasets have different number of images: '
- f'{len(input_paths)}, {len(gt_paths)}.')
- paths = []
- for gt_path in gt_paths:
- basename, ext = osp.splitext(osp.basename(gt_path))
- input_name = f'{filename_tmpl.format(basename)}{ext}'
- input_path = osp.join(input_folder, input_name)
- assert input_name in input_paths, f'{input_name} is not in {input_key}_paths.'
- gt_path = osp.join(gt_folder, gt_path)
- paths.append(dict([(f'{input_key}_path', input_path), (f'{gt_key}_path', gt_path)]))
- return paths
-
-
-def paths_from_folder(folder):
- """Generate paths from folder.
-
- Args:
- folder (str): Folder path.
-
- Returns:
- list[str]: Returned path list.
- """
-
- paths = list(scandir(folder))
- paths = [osp.join(folder, path) for path in paths]
- return paths
-
-
-def paths_from_lmdb(folder):
- """Generate paths from lmdb.
-
- Args:
- folder (str): Folder path.
-
- Returns:
- list[str]: Returned path list.
- """
- if not folder.endswith('.lmdb'):
- raise ValueError(f'Folder {folder}folder should in lmdb format.')
- with open(osp.join(folder, 'meta_info.txt')) as fin:
- paths = [line.split('.')[0] for line in fin]
- return paths
-
-
-def generate_gaussian_kernel(kernel_size=13, sigma=1.6):
- """Generate Gaussian kernel used in `duf_downsample`.
-
- Args:
- kernel_size (int): Kernel size. Default: 13.
- sigma (float): Sigma of the Gaussian kernel. Default: 1.6.
-
- Returns:
- np.array: The Gaussian kernel.
- """
- from scipy.ndimage import filters as filters
- kernel = np.zeros((kernel_size, kernel_size))
- # set element at the middle to one, a dirac delta
- kernel[kernel_size // 2, kernel_size // 2] = 1
- # gaussian-smooth the dirac, resulting in a gaussian filter
- return filters.gaussian_filter(kernel, sigma)
-
-
-def duf_downsample(x, kernel_size=13, scale=4):
- """Downsamping with Gaussian kernel used in the DUF official code.
-
- Args:
- x (Tensor): Frames to be downsampled, with shape (b, t, c, h, w).
- kernel_size (int): Kernel size. Default: 13.
- scale (int): Downsampling factor. Supported scale: (2, 3, 4).
- Default: 4.
-
- Returns:
- Tensor: DUF downsampled frames.
- """
- assert scale in (2, 3, 4), f'Only support scale (2, 3, 4), but got {scale}.'
-
- squeeze_flag = False
- if x.ndim == 4:
- squeeze_flag = True
- x = x.unsqueeze(0)
- b, t, c, h, w = x.size()
- x = x.view(-1, 1, h, w)
- pad_w, pad_h = kernel_size // 2 + scale * 2, kernel_size // 2 + scale * 2
- x = F.pad(x, (pad_w, pad_w, pad_h, pad_h), 'reflect')
-
- gaussian_filter = generate_gaussian_kernel(kernel_size, 0.4 * scale)
- gaussian_filter = torch.from_numpy(gaussian_filter).type_as(x).unsqueeze(0).unsqueeze(0)
- x = F.conv2d(x, gaussian_filter, stride=scale)
- x = x[:, :, 2:-2, 2:-2]
- x = x.view(b, t, c, x.size(2), x.size(3))
- if squeeze_flag:
- x = x.squeeze(0)
- return x
diff --git a/spaces/OFA-Sys/OFA-Generic_Interface/fairseq/examples/multilingual/data_scripts/download_ted_and_extract.py b/spaces/OFA-Sys/OFA-Generic_Interface/fairseq/examples/multilingual/data_scripts/download_ted_and_extract.py
deleted file mode 100644
index eb756680fa7dc31a14ba45c216776a6d60c16b60..0000000000000000000000000000000000000000
--- a/spaces/OFA-Sys/OFA-Generic_Interface/fairseq/examples/multilingual/data_scripts/download_ted_and_extract.py
+++ /dev/null
@@ -1,338 +0,0 @@
-# Copyright (c) Facebook, Inc. and its affiliates.
-#
-# This source code is licensed under the MIT license found in the
-# LICENSE file in the root directory of this source tree.
-
-
-import itertools
-import os
-import csv
-from collections import defaultdict
-from six.moves import zip
-import io
-import wget
-import sys
-
-from subprocess import check_call, check_output
-
-# scripts and data locations
-CWD = os.getcwd()
-UTILS = f"{CWD}/utils"
-
-MOSES = f"{UTILS}/mosesdecoder"
-
-WORKDIR_ROOT = os.environ.get('WORKDIR_ROOT', None)
-
-if WORKDIR_ROOT is None or not WORKDIR_ROOT.strip():
- print('please specify your working directory root in OS environment variable WORKDIR_ROOT. Exitting..."')
- sys.exit(-1)
-
-
-# please donwload mosesdecoder here:
-detok_cmd = f'{MOSES}/scripts/tokenizer/detokenizer.perl'
-
-
-def call(cmd):
- print(f"Executing: {cmd}")
- check_call(cmd, shell=True)
-
-class MultiLingualAlignedCorpusReader(object):
- """A class to read TED talk dataset
- """
-
- def __init__(self, corpus_path, delimiter='\t',
- target_token=True, bilingual=True, corpus_type='file',
- lang_dict={'source': ['fr'], 'target': ['en']},
- eval_lang_dict=None, zero_shot=False,
- detok=True,
- ):
-
- self.empty_line_flag = 'NULL'
- self.corpus_path = corpus_path
- self.delimiter = delimiter
- self.bilingual = bilingual
- self.lang_dict = lang_dict
- self.lang_set = set()
- self.target_token = target_token
- self.zero_shot = zero_shot
- self.eval_lang_dict = eval_lang_dict
- self.corpus_type = corpus_type
- self.detok = detok
-
- for list_ in self.lang_dict.values():
- for lang in list_:
- self.lang_set.add(lang)
-
- self.data = dict()
- self.data['train'] = self.read_aligned_corpus(split_type='train')
- self.data['test'] = self.read_aligned_corpus(split_type='test')
- self.data['dev'] = self.read_aligned_corpus(split_type='dev')
-
- def read_data(self, file_loc_):
- data_list = list()
- with io.open(file_loc_, 'r', encoding='utf8') as fp:
- for line in fp:
- try:
- text = line.strip()
- except IndexError:
- text = self.empty_line_flag
- data_list.append(text)
- return data_list
-
- def filter_text(self, dict_):
- if self.target_token:
- field_index = 1
- else:
- field_index = 0
- data_dict = defaultdict(list)
- list1 = dict_['source']
- list2 = dict_['target']
- for sent1, sent2 in zip(list1, list2):
- try:
- src_sent = ' '.join(sent1.split()[field_index: ])
- except IndexError:
- src_sent = 'NULL'
-
- if src_sent.find(self.empty_line_flag) != -1 or len(src_sent) == 0:
- continue
-
- elif sent2.find(self.empty_line_flag) != -1 or len(sent2) == 0:
- continue
-
- else:
- data_dict['source'].append(sent1)
- data_dict['target'].append(sent2)
- return data_dict
-
- def read_file(self, split_type, data_type):
- return self.data[split_type][data_type]
-
- def save_file(self, path_, split_type, data_type, lang):
- tok_file = tok_file_name(path_, lang)
- with io.open(tok_file, 'w', encoding='utf8') as fp:
- for line in self.data[split_type][data_type]:
- fp.write(line + '\n')
- if self.detok:
- de_tok(tok_file, lang)
-
- def add_target_token(self, list_, lang_id):
- new_list = list()
- token = '__' + lang_id + '__'
- for sent in list_:
- new_list.append(token + ' ' + sent)
- return new_list
-
- def read_from_single_file(self, path_, s_lang, t_lang):
- data_dict = defaultdict(list)
- with io.open(path_, 'r', encoding='utf8') as fp:
- reader = csv.DictReader(fp, delimiter='\t', quoting=csv.QUOTE_NONE)
- for row in reader:
- data_dict['source'].append(row[s_lang])
- data_dict['target'].append(row[t_lang])
-
- if self.target_token:
- text = self.add_target_token(data_dict['source'], t_lang)
- data_dict['source'] = text
-
- return data_dict['source'], data_dict['target']
-
- def read_aligned_corpus(self, split_type='train'):
- data_dict = defaultdict(list)
- iterable = []
- s_list = []
- t_list = []
-
- if self.zero_shot:
- if split_type == "train":
- iterable = zip(self.lang_dict['source'], self.lang_dict['target'])
- else:
- iterable = zip(self.eval_lang_dict['source'], self.eval_lang_dict['target'])
-
- elif self.bilingual:
- iterable = itertools.product(self.lang_dict['source'], self.lang_dict['target'])
-
- for s_lang, t_lang in iterable:
- if s_lang == t_lang:
- continue
- if self.corpus_type == 'file':
- split_type_file_path = os.path.join(self.corpus_path,
- "all_talks_{}.tsv".format(split_type))
- s_list, t_list = self.read_from_single_file(split_type_file_path,
- s_lang=s_lang,
- t_lang=t_lang)
- data_dict['source'] += s_list
- data_dict['target'] += t_list
- new_data_dict = self.filter_text(data_dict)
- return new_data_dict
-
-
-def read_langs(corpus_path):
- split_type_file_path = os.path.join(corpus_path, 'extracted',
- "all_talks_dev.tsv")
- with io.open(split_type_file_path, 'r', encoding='utf8') as fp:
- reader = csv.DictReader(fp, delimiter='\t', quoting=csv.QUOTE_NONE)
- header = next(reader)
- return [k for k in header.keys() if k != 'talk_name']
-
-def extra_english(corpus_path, split):
- split_type_file_path = os.path.join(corpus_path,
- f"all_talks_{split}.tsv")
- output_split_type_file_path = os.path.join(corpus_path,
- f"all_talks_{split}.en")
- with io.open(split_type_file_path, 'r', encoding='utf8') as fp, io.open(output_split_type_file_path, 'w', encoding='utf8') as fw:
- reader = csv.DictReader(fp, delimiter='\t', quoting=csv.QUOTE_NONE)
- for row in reader:
- line = row['en']
- fw.write(line + '\n')
- de_tok(output_split_type_file_path, 'en')
-
-
-
-def tok_file_name(filename, lang):
- seps = filename.split('.')
- seps.insert(-1, 'tok')
- tok_file = '.'.join(seps)
- return tok_file
-
-def de_tok(tok_file, lang):
- # seps = tok_file.split('.')
- # seps.insert(-1, 'detok')
- # de_tok_file = '.'.join(seps)
- de_tok_file = tok_file.replace('.tok.', '.')
- cmd = 'perl {detok_cmd} -l {lang} < {tok_file} > {de_tok_file}'.format(
- detok_cmd=detok_cmd, tok_file=tok_file,
- de_tok_file=de_tok_file, lang=lang[:2])
- call(cmd)
-
-def extra_bitex(
- ted_data_path,
- lsrc_lang,
- ltrg_lang,
- target_token,
- output_data_path,
-):
- def get_ted_lang(lang):
- long_langs = ['pt-br', 'zh-cn', 'zh-tw', 'fr-ca']
- if lang[:5] in long_langs:
- return lang[:5]
- elif lang[:4] =='calv':
- return lang[:5]
- elif lang in ['pt_BR', 'zh_CN', 'zh_TW', 'fr_CA']:
- return lang.lower().replace('_', '-')
- return lang[:2]
- src_lang = get_ted_lang(lsrc_lang)
- trg_lang = get_ted_lang(ltrg_lang)
- train_lang_dict={'source': [src_lang], 'target': [trg_lang]}
- eval_lang_dict = {'source': [src_lang], 'target': [trg_lang]}
-
- obj = MultiLingualAlignedCorpusReader(corpus_path=ted_data_path,
- lang_dict=train_lang_dict,
- target_token=target_token,
- corpus_type='file',
- eval_lang_dict=eval_lang_dict,
- zero_shot=False,
- bilingual=True)
-
- os.makedirs(output_data_path, exist_ok=True)
- lsrc_lang = lsrc_lang.replace('-', '_')
- ltrg_lang = ltrg_lang.replace('-', '_')
- obj.save_file(output_data_path + f"/train.{lsrc_lang}-{ltrg_lang}.{lsrc_lang}",
- split_type='train', data_type='source', lang=src_lang)
- obj.save_file(output_data_path + f"/train.{lsrc_lang}-{ltrg_lang}.{ltrg_lang}",
- split_type='train', data_type='target', lang=trg_lang)
-
- obj.save_file(output_data_path + f"/test.{lsrc_lang}-{ltrg_lang}.{lsrc_lang}",
- split_type='test', data_type='source', lang=src_lang)
- obj.save_file(output_data_path + f"/test.{lsrc_lang}-{ltrg_lang}.{ltrg_lang}",
- split_type='test', data_type='target', lang=trg_lang)
-
- obj.save_file(output_data_path + f"/valid.{lsrc_lang}-{ltrg_lang}.{lsrc_lang}",
- split_type='dev', data_type='source', lang=src_lang)
- obj.save_file(output_data_path + f"/valid.{lsrc_lang}-{ltrg_lang}.{ltrg_lang}",
- split_type='dev', data_type='target', lang=trg_lang)
-
-
-def bar_custom(current, total, width=80):
- print("Downloading: %d%% [%d / %d] Ks" % (current / total * 100, current / 1000, total / 1000), end='\r')
-
-
-def download_and_extract(download_to, extract_to):
- url = 'http://phontron.com/data/ted_talks.tar.gz'
- filename = f"{download_to}/ted_talks.tar.gz"
- if os.path.exists(filename):
- print(f'{filename} has already been downloaded so skip')
- else:
- filename = wget.download(url, filename, bar=bar_custom)
- if os.path.exists(f'{extract_to}/all_talks_train.tsv'):
- print(f'Already extracted so skip')
- else:
- extract_cmd = f'tar xzfv "{filename}" -C "{extract_to}"'
- call(extract_cmd)
-
-
-if __name__ == "__main__":
- import argparse
- parser = argparse.ArgumentParser()
- parser.add_argument('--ted_data_path', type=str, default=WORKDIR_ROOT, required=False)
- parser.add_argument(
- '--direction-list',
- type=str,
- # default=None,
- #for ML50
- default=(
- "bn_IN-en_XX,he_IL-en_XX,fa_IR-en_XX,id_ID-en_XX,sv_SE-en_XX,pt_XX-en_XX,ka_GE-en_XX,ka_GE-en_XX,th_TH-en_XX,"
- "mr_IN-en_XX,hr_HR-en_XX,uk_UA-en_XX,az_AZ-en_XX,mk_MK-en_XX,gl_ES-en_XX,sl_SI-en_XX,mn_MN-en_XX,"
- #non-english directions
- # "fr_XX-de_DE," # replaced with wmt20
- # "ja_XX-ko_KR,es_XX-pt_XX,ru_RU-sv_SE,hi_IN-bn_IN,id_ID-ar_AR,cs_CZ-pl_PL,ar_AR-tr_TR"
- ),
- required=False)
- parser.add_argument('--target-token', action='store_true', default=False)
- parser.add_argument('--extract-all-english', action='store_true', default=False)
-
- args = parser.parse_args()
-
- import sys
- import json
-
- # TED Talks data directory
- ted_data_path = args.ted_data_path
-
- download_to = f'{ted_data_path}/downloads'
- extract_to = f'{ted_data_path}/extracted'
-
- #DESTDIR=${WORKDIR_ROOT}/ML50/raw/
- output_path = f'{ted_data_path}/ML50/raw'
- os.makedirs(download_to, exist_ok=True)
- os.makedirs(extract_to, exist_ok=True)
- os.makedirs(output_path, exist_ok=True)
- download_and_extract(download_to, extract_to)
-
-
- if args.extract_all_english:
- for split in ['train', 'dev', 'test']:
- extra_english(ted_data_path, split)
- exit(0)
- if args.direction_list is not None:
- directions = args.direction_list.strip().split(',')
- directions = [tuple(d.strip().split('-', 1)) for d in directions if d]
- else:
- langs = read_langs(ted_data_path)
- # directions = [
- # '{}.{}'.format(src, tgt)
- # for src in langs
- # for tgt in langs
- # if src < tgt
- # ]
- directions = [('en', tgt) for tgt in langs if tgt != 'en']
- print(f'num directions={len(directions)}: {directions}')
-
- for src_lang, trg_lang in directions:
- print('--working on {}-{}'.format(src_lang, trg_lang))
- extra_bitex(
- extract_to,
- src_lang,
- trg_lang,
- target_token=args.target_token,
- output_data_path=output_path
- )
diff --git a/spaces/OFA-Sys/OFA-Generic_Interface/fairseq/fairseq/models/speech_to_text/s2t_transformer.py b/spaces/OFA-Sys/OFA-Generic_Interface/fairseq/fairseq/models/speech_to_text/s2t_transformer.py
deleted file mode 100644
index aff9d0ffc7b7e671c476ff28d1cd945e9ff41519..0000000000000000000000000000000000000000
--- a/spaces/OFA-Sys/OFA-Generic_Interface/fairseq/fairseq/models/speech_to_text/s2t_transformer.py
+++ /dev/null
@@ -1,502 +0,0 @@
-#!/usr/bin/env python3
-
-import logging
-import math
-from typing import Dict, List, Optional, Tuple
-from pathlib import Path
-
-import torch
-import torch.nn as nn
-from fairseq import checkpoint_utils, utils
-from fairseq.data.data_utils import lengths_to_padding_mask
-from fairseq.models import (
- FairseqEncoder,
- FairseqEncoderDecoderModel,
- register_model,
- register_model_architecture,
-)
-from fairseq.models.transformer import Embedding, TransformerDecoder
-from fairseq.modules import (
- FairseqDropout,
- LayerNorm,
- PositionalEmbedding,
- TransformerEncoderLayer,
-)
-from torch import Tensor
-
-
-logger = logging.getLogger(__name__)
-
-
-class Conv1dSubsampler(nn.Module):
- """Convolutional subsampler: a stack of 1D convolution (along temporal
- dimension) followed by non-linear activation via gated linear units
- (https://arxiv.org/abs/1911.08460)
-
- Args:
- in_channels (int): the number of input channels
- mid_channels (int): the number of intermediate channels
- out_channels (int): the number of output channels
- kernel_sizes (List[int]): the kernel size for each convolutional layer
- """
-
- def __init__(
- self,
- in_channels: int,
- mid_channels: int,
- out_channels: int,
- kernel_sizes: List[int] = (3, 3),
- ):
- super(Conv1dSubsampler, self).__init__()
- self.n_layers = len(kernel_sizes)
- self.conv_layers = nn.ModuleList(
- nn.Conv1d(
- in_channels if i == 0 else mid_channels // 2,
- mid_channels if i < self.n_layers - 1 else out_channels * 2,
- k,
- stride=2,
- padding=k // 2,
- )
- for i, k in enumerate(kernel_sizes)
- )
-
- def get_out_seq_lens_tensor(self, in_seq_lens_tensor):
- out = in_seq_lens_tensor.clone()
- for _ in range(self.n_layers):
- out = ((out.float() - 1) / 2 + 1).floor().long()
- return out
-
- def forward(self, src_tokens, src_lengths):
- bsz, in_seq_len, _ = src_tokens.size() # B x T x (C x D)
- x = src_tokens.transpose(1, 2).contiguous() # -> B x (C x D) x T
- for conv in self.conv_layers:
- x = conv(x)
- x = nn.functional.glu(x, dim=1)
- _, _, out_seq_len = x.size()
- x = x.transpose(1, 2).transpose(0, 1).contiguous() # -> T x B x (C x D)
- return x, self.get_out_seq_lens_tensor(src_lengths)
-
-
-@register_model("s2t_transformer")
-class S2TTransformerModel(FairseqEncoderDecoderModel):
- """Adapted Transformer model (https://arxiv.org/abs/1706.03762) for
- speech-to-text tasks. The Transformer encoder/decoder remains the same.
- A trainable input subsampler is prepended to the Transformer encoder to
- project inputs into the encoder dimension as well as downsample input
- sequence for computational efficiency."""
-
- def __init__(self, encoder, decoder):
- super().__init__(encoder, decoder)
-
- @staticmethod
- def add_args(parser):
- """Add model-specific arguments to the parser."""
- # input
- parser.add_argument(
- "--conv-kernel-sizes",
- type=str,
- metavar="N",
- help="kernel sizes of Conv1d subsampling layers",
- )
- parser.add_argument(
- "--conv-channels",
- type=int,
- metavar="N",
- help="# of channels in Conv1d subsampling layers",
- )
- # Transformer
- parser.add_argument(
- "--activation-fn",
- type=str,
- default="relu",
- choices=utils.get_available_activation_fns(),
- help="activation function to use",
- )
- parser.add_argument(
- "--dropout", type=float, metavar="D", help="dropout probability"
- )
- parser.add_argument(
- "--attention-dropout",
- type=float,
- metavar="D",
- help="dropout probability for attention weights",
- )
- parser.add_argument(
- "--activation-dropout",
- "--relu-dropout",
- type=float,
- metavar="D",
- help="dropout probability after activation in FFN.",
- )
- parser.add_argument(
- "--encoder-embed-dim",
- type=int,
- metavar="N",
- help="encoder embedding dimension",
- )
- parser.add_argument(
- "--encoder-ffn-embed-dim",
- type=int,
- metavar="N",
- help="encoder embedding dimension for FFN",
- )
- parser.add_argument(
- "--encoder-layers", type=int, metavar="N", help="num encoder layers"
- )
- parser.add_argument(
- "--encoder-attention-heads",
- type=int,
- metavar="N",
- help="num encoder attention heads",
- )
- parser.add_argument(
- "--encoder-normalize-before",
- action="store_true",
- help="apply layernorm before each encoder block",
- )
- parser.add_argument(
- "--decoder-embed-dim",
- type=int,
- metavar="N",
- help="decoder embedding dimension",
- )
- parser.add_argument(
- "--decoder-ffn-embed-dim",
- type=int,
- metavar="N",
- help="decoder embedding dimension for FFN",
- )
- parser.add_argument(
- "--decoder-layers", type=int, metavar="N", help="num decoder layers"
- )
- parser.add_argument(
- "--decoder-attention-heads",
- type=int,
- metavar="N",
- help="num decoder attention heads",
- )
- parser.add_argument(
- "--decoder-normalize-before",
- action="store_true",
- help="apply layernorm before each decoder block",
- )
- parser.add_argument(
- "--share-decoder-input-output-embed",
- action="store_true",
- help="share decoder input and output embeddings",
- )
- parser.add_argument(
- "--layernorm-embedding",
- action="store_true",
- help="add layernorm to embedding",
- )
- parser.add_argument(
- "--no-scale-embedding",
- action="store_true",
- help="if True, dont scale embeddings",
- )
- parser.add_argument(
- "--load-pretrained-encoder-from",
- type=str,
- metavar="STR",
- help="model to take encoder weights from (for initialization)",
- )
- parser.add_argument(
- '--encoder-freezing-updates',
- type=int,
- metavar='N',
- help='freeze encoder for first N updates'
- )
-
- @classmethod
- def build_encoder(cls, args):
- encoder = S2TTransformerEncoder(args)
- pretraining_path = getattr(args, "load_pretrained_encoder_from", None)
- if pretraining_path is not None:
- if not Path(pretraining_path).exists():
- logger.warning(
- f"skipped pretraining because {pretraining_path} does not exist"
- )
- else:
- encoder = checkpoint_utils.load_pretrained_component_from_model(
- component=encoder, checkpoint=pretraining_path
- )
- logger.info(f"loaded pretrained encoder from: {pretraining_path}")
- return encoder
-
- @classmethod
- def build_decoder(cls, args, task, embed_tokens):
- return TransformerDecoderScriptable(args, task.target_dictionary, embed_tokens)
-
- @classmethod
- def build_model(cls, args, task):
- """Build a new model instance."""
-
- # make sure all arguments are present in older models
- base_architecture(args)
-
- def build_embedding(dictionary, embed_dim):
- num_embeddings = len(dictionary)
- padding_idx = dictionary.pad()
- return Embedding(num_embeddings, embed_dim, padding_idx)
-
- decoder_embed_tokens = build_embedding(
- task.target_dictionary, args.decoder_embed_dim
- )
- encoder = cls.build_encoder(args)
- decoder = cls.build_decoder(args, task, decoder_embed_tokens)
- return cls(encoder, decoder)
-
- def get_normalized_probs(
- self,
- net_output: Tuple[Tensor, Optional[Dict[str, List[Optional[Tensor]]]]],
- log_probs: bool,
- sample: Optional[Dict[str, Tensor]] = None,
- ):
- # net_output['encoder_out'] is a (B, T, D) tensor
- lprobs = self.get_normalized_probs_scriptable(net_output, log_probs, sample)
- lprobs.batch_first = True
- return lprobs
-
- def forward(self, src_tokens, src_lengths, prev_output_tokens):
- """
- The forward method inherited from the base class has a **kwargs
- argument in its input, which is not supported in torchscript. This
- method overwrites the forward method definition without **kwargs.
- """
- encoder_out = self.encoder(src_tokens=src_tokens, src_lengths=src_lengths)
- decoder_out = self.decoder(
- prev_output_tokens=prev_output_tokens, encoder_out=encoder_out
- )
- return decoder_out
-
-
-class S2TTransformerEncoder(FairseqEncoder):
- """Speech-to-text Transformer encoder that consists of input subsampler and
- Transformer encoder."""
-
- def __init__(self, args):
- super().__init__(None)
-
- self.encoder_freezing_updates = args.encoder_freezing_updates
- self.num_updates = 0
-
- self.dropout_module = FairseqDropout(
- p=args.dropout, module_name=self.__class__.__name__
- )
- self.embed_scale = math.sqrt(args.encoder_embed_dim)
- if args.no_scale_embedding:
- self.embed_scale = 1.0
- self.padding_idx = 1
-
- self.subsample = Conv1dSubsampler(
- args.input_feat_per_channel * args.input_channels,
- args.conv_channels,
- args.encoder_embed_dim,
- [int(k) for k in args.conv_kernel_sizes.split(",")],
- )
-
- self.embed_positions = PositionalEmbedding(
- args.max_source_positions, args.encoder_embed_dim, self.padding_idx
- )
-
- self.transformer_layers = nn.ModuleList(
- [TransformerEncoderLayer(args) for _ in range(args.encoder_layers)]
- )
- if args.encoder_normalize_before:
- self.layer_norm = LayerNorm(args.encoder_embed_dim)
- else:
- self.layer_norm = None
-
- def _forward(self, src_tokens, src_lengths, return_all_hiddens=False):
- x, input_lengths = self.subsample(src_tokens, src_lengths)
- x = self.embed_scale * x
-
- encoder_padding_mask = lengths_to_padding_mask(input_lengths)
- positions = self.embed_positions(encoder_padding_mask).transpose(0, 1)
- x += positions
- x = self.dropout_module(x)
-
- encoder_states = []
-
- for layer in self.transformer_layers:
- x = layer(x, encoder_padding_mask)
- if return_all_hiddens:
- encoder_states.append(x)
-
- if self.layer_norm is not None:
- x = self.layer_norm(x)
-
- return {
- "encoder_out": [x], # T x B x C
- "encoder_padding_mask": [encoder_padding_mask] if encoder_padding_mask.any() else [], # B x T
- "encoder_embedding": [], # B x T x C
- "encoder_states": encoder_states, # List[T x B x C]
- "src_tokens": [],
- "src_lengths": [],
- }
-
- def forward(self, src_tokens, src_lengths, return_all_hiddens=False):
- if self.num_updates < self.encoder_freezing_updates:
- with torch.no_grad():
- x = self._forward(src_tokens, src_lengths,
- return_all_hiddens=return_all_hiddens)
- else:
- x = self._forward(src_tokens, src_lengths,
- return_all_hiddens=return_all_hiddens)
- return x
-
- def reorder_encoder_out(self, encoder_out, new_order):
- new_encoder_out = (
- [] if len(encoder_out["encoder_out"]) == 0
- else [x.index_select(1, new_order) for x in encoder_out["encoder_out"]]
- )
-
- new_encoder_padding_mask = (
- [] if len(encoder_out["encoder_padding_mask"]) == 0
- else [x.index_select(0, new_order) for x in encoder_out["encoder_padding_mask"]]
- )
-
- new_encoder_embedding = (
- [] if len(encoder_out["encoder_embedding"]) == 0
- else [x.index_select(0, new_order) for x in encoder_out["encoder_embedding"]]
- )
-
- encoder_states = encoder_out["encoder_states"]
- if len(encoder_states) > 0:
- for idx, state in enumerate(encoder_states):
- encoder_states[idx] = state.index_select(1, new_order)
-
- return {
- "encoder_out": new_encoder_out, # T x B x C
- "encoder_padding_mask": new_encoder_padding_mask, # B x T
- "encoder_embedding": new_encoder_embedding, # B x T x C
- "encoder_states": encoder_states, # List[T x B x C]
- "src_tokens": [], # B x T
- "src_lengths": [], # B x 1
- }
-
- def set_num_updates(self, num_updates):
- super().set_num_updates(num_updates)
- self.num_updates = num_updates
-
-
-class TransformerDecoderScriptable(TransformerDecoder):
- def extract_features(
- self,
- prev_output_tokens,
- encoder_out: Optional[Dict[str, List[Tensor]]] = None,
- incremental_state: Optional[Dict[str, Dict[str, Optional[Tensor]]]] = None,
- full_context_alignment: bool = False,
- alignment_layer: Optional[int] = None,
- alignment_heads: Optional[int] = None,
- ):
- # call scriptable method from parent class
- x, _ = self.extract_features_scriptable(
- prev_output_tokens,
- encoder_out,
- incremental_state,
- full_context_alignment,
- alignment_layer,
- alignment_heads,
- )
- return x, None
-
-
-@register_model_architecture(model_name="s2t_transformer", arch_name="s2t_transformer")
-def base_architecture(args):
- args.encoder_freezing_updates = getattr(args, "encoder_freezing_updates", 0)
- # Convolutional subsampler
- args.conv_kernel_sizes = getattr(args, "conv_kernel_sizes", "5,5")
- args.conv_channels = getattr(args, "conv_channels", 1024)
- # Transformer
- args.encoder_embed_dim = getattr(args, "encoder_embed_dim", 512)
- args.encoder_ffn_embed_dim = getattr(args, "encoder_ffn_embed_dim", 2048)
- args.encoder_layers = getattr(args, "encoder_layers", 12)
- args.encoder_attention_heads = getattr(args, "encoder_attention_heads", 8)
- args.encoder_normalize_before = getattr(args, "encoder_normalize_before", True)
- args.decoder_embed_dim = getattr(args, "decoder_embed_dim", args.encoder_embed_dim)
- args.decoder_ffn_embed_dim = getattr(
- args, "decoder_ffn_embed_dim", args.encoder_ffn_embed_dim
- )
- args.decoder_layers = getattr(args, "decoder_layers", 6)
- args.decoder_attention_heads = getattr(args, "decoder_attention_heads", 8)
- args.decoder_normalize_before = getattr(args, "decoder_normalize_before", True)
- args.decoder_learned_pos = getattr(args, "decoder_learned_pos", False)
- args.dropout = getattr(args, "dropout", 0.1)
- args.attention_dropout = getattr(args, "attention_dropout", args.dropout)
- args.activation_dropout = getattr(args, "activation_dropout", args.dropout)
- args.activation_fn = getattr(args, "activation_fn", "relu")
- args.adaptive_softmax_cutoff = getattr(args, "adaptive_softmax_cutoff", None)
- args.adaptive_softmax_dropout = getattr(args, "adaptive_softmax_dropout", 0)
- args.share_decoder_input_output_embed = getattr(
- args, "share_decoder_input_output_embed", False
- )
- args.no_token_positional_embeddings = getattr(
- args, "no_token_positional_embeddings", False
- )
- args.adaptive_input = getattr(args, "adaptive_input", False)
- args.decoder_layerdrop = getattr(args, "decoder_layerdrop", 0.0)
- args.decoder_output_dim = getattr(
- args, "decoder_output_dim", args.decoder_embed_dim
- )
- args.decoder_input_dim = getattr(args, "decoder_input_dim", args.decoder_embed_dim)
- args.no_scale_embedding = getattr(args, "no_scale_embedding", False)
- args.quant_noise_pq = getattr(args, "quant_noise_pq", 0)
-
-
-@register_model_architecture("s2t_transformer", "s2t_transformer_s")
-def s2t_transformer_s(args):
- args.encoder_embed_dim = getattr(args, "encoder_embed_dim", 256)
- args.encoder_ffn_embed_dim = getattr(args, "encoder_ffn_embed_dim", 256 * 8)
- args.encoder_attention_heads = getattr(args, "encoder_attention_heads", 4)
- args.decoder_attention_heads = getattr(args, "decoder_attention_heads", 4)
- args.dropout = getattr(args, "dropout", 0.1)
- base_architecture(args)
-
-
-@register_model_architecture("s2t_transformer", "s2t_transformer_xs")
-def s2t_transformer_xs(args):
- args.encoder_layers = getattr(args, "encoder_layers", 6)
- args.decoder_layers = getattr(args, "decoder_layers", 3)
- args.encoder_ffn_embed_dim = getattr(args, "encoder_ffn_embed_dim", 256 * 4)
- args.dropout = getattr(args, "dropout", 0.3)
- s2t_transformer_s(args)
-
-
-@register_model_architecture("s2t_transformer", "s2t_transformer_sp")
-def s2t_transformer_sp(args):
- args.encoder_layers = getattr(args, "encoder_layers", 16)
- s2t_transformer_s(args)
-
-
-@register_model_architecture("s2t_transformer", "s2t_transformer_m")
-def s2t_transformer_m(args):
- args.encoder_embed_dim = getattr(args, "encoder_embed_dim", 512)
- args.encoder_ffn_embed_dim = getattr(args, "encoder_ffn_embed_dim", 512 * 4)
- args.encoder_attention_heads = getattr(args, "encoder_attention_heads", 8)
- args.decoder_attention_heads = getattr(args, "decoder_attention_heads", 8)
- args.dropout = getattr(args, "dropout", 0.15)
- base_architecture(args)
-
-
-@register_model_architecture("s2t_transformer", "s2t_transformer_mp")
-def s2t_transformer_mp(args):
- args.encoder_layers = getattr(args, "encoder_layers", 16)
- s2t_transformer_m(args)
-
-
-@register_model_architecture("s2t_transformer", "s2t_transformer_l")
-def s2t_transformer_l(args):
- args.encoder_embed_dim = getattr(args, "encoder_embed_dim", 1024)
- args.encoder_ffn_embed_dim = getattr(args, "encoder_ffn_embed_dim", 1024 * 4)
- args.encoder_attention_heads = getattr(args, "encoder_attention_heads", 16)
- args.decoder_attention_heads = getattr(args, "decoder_attention_heads", 16)
- args.dropout = getattr(args, "dropout", 0.2)
- base_architecture(args)
-
-
-@register_model_architecture("s2t_transformer", "s2t_transformer_lp")
-def s2t_transformer_lp(args):
- args.encoder_layers = getattr(args, "encoder_layers", 16)
- s2t_transformer_l(args)
diff --git a/spaces/OFA-Sys/OFA-Generic_Interface/fairseq/fairseq/modules/kmeans_attention.py b/spaces/OFA-Sys/OFA-Generic_Interface/fairseq/fairseq/modules/kmeans_attention.py
deleted file mode 100644
index 11a7debcf2ac025fb02ba5e672987f87dbbc49a4..0000000000000000000000000000000000000000
--- a/spaces/OFA-Sys/OFA-Generic_Interface/fairseq/fairseq/modules/kmeans_attention.py
+++ /dev/null
@@ -1,609 +0,0 @@
-import torch
-import torch.nn as nn
-import torch.nn.functional as F
-import math
-from inspect import isfunction
-from operator import mul
-from functools import reduce, wraps
-
-from aml.multimodal_video.utils.einops.lib import rearrange, repeat
-from aml.multimodal_video.utils.einops.lib.layers.torch import Rearrange
-
-from fairseq.modules.local_attention import LocalAttention
-
-# constants
-
-TOKEN_SELF_ATTN_VALUE = -5e4
-KMEAN_INIT_ITERS = 10
-
-# helper functions
-
-
-def exists(val):
- return val is not None
-
-
-def identity(x, *args, **kwargs):
- return x
-
-
-def default(x, d):
- if not exists(x):
- return d if not isfunction(d) else d()
- return x
-
-
-def cast_tuple(x):
- return x if isinstance(x, tuple) else (x,)
-
-
-def cache_fn(f):
- cache = None
-
- @wraps(f)
- def cached_fn(*args, **kwargs):
- nonlocal cache
- if exists(cache):
- return cache
- cache = f(*args, **kwargs)
- return cache
- return cached_fn
-
-
-def to(t):
- return {'device': t.device, 'dtype': t.dtype}
-
-
-def find_modules(nn_module, type):
- return [module for module in nn_module.modules() if isinstance(module, type)]
-
-
-def is_empty(t):
- return t.nelement() == 0
-
-
-def max_neg_value(tensor):
- return -torch.finfo(tensor.dtype).max
-
-
-def batched_index_select(values, indices):
- last_dim = values.shape[-1]
- return values.gather(2, expand_dim(indices, -1, last_dim))
-
-
-def merge_dims(ind_from, ind_to, tensor):
- shape = list(tensor.shape)
- arr_slice = slice(ind_from, ind_to + 1)
- shape[arr_slice] = [reduce(mul, shape[arr_slice])]
- return tensor.reshape(*shape)
-
-
-def expand_dim(t, dim, k):
- t = t.unsqueeze(dim)
- expand_shape = [-1] * len(t.shape)
- expand_shape[dim] = k
- return t.expand(*expand_shape)
-
-
-def scatter_mean(src, t, index, dim, eps=1e-5):
- numer = src.scatter_add(dim, index, t)
- denom = src.scatter_add(dim, index, torch.ones_like(t))
- return numer / (denom + eps)
-
-
-def split_at_index(dim, index, t):
- pre_slices = (slice(None),) * dim
- l = (*pre_slices, slice(None, index))
- r = (*pre_slices, slice(index, None))
- return t[l], t[r]
-
-
-def reshape_dim(t, dim, split_dims):
- shape = list(t.shape)
- num_dims = len(shape)
- dim = (dim + num_dims) % num_dims
- shape[dim:dim+1] = split_dims
- return t.reshape(shape)
-
-
-def ema(old, new, decay):
- if not exists(old):
- return new
- return old * decay + new * (1 - decay)
-
-
-def ema_inplace(moving_avg, new, decay):
- if is_empty(moving_avg):
- moving_avg.data.copy_(new)
- return
- moving_avg.data.mul_(decay).add_(new, alpha=(1 - decay))
-
-# helper classes
-
-
-def map_first_tuple_or_el(x, fn):
- if isinstance(x, tuple):
- return (fn(x[0]),) + x[1:]
- return fn(x)
-
-
-class Chunk(nn.Module):
- def __init__(self, chunks, fn, along_dim=-1):
- super().__init__()
- self.dim = along_dim
- self.chunks = chunks
- self.fn = fn
-
- def forward(self, x, **kwargs):
- if self.chunks <= 1:
- return self.fn(x, **kwargs)
- chunks = x.chunk(self.chunks, dim=self.dim)
- return torch.cat([self.fn(c, **kwargs) for c in chunks], dim=self.dim)
-
-
-class PreNorm(nn.ModuleList):
- def __init__(self, norm_class, dim, fn):
- super().__init__()
- self.norm = norm_class(dim)
- self.fn = fn
-
- def forward(self, x, **kwargs):
- x = self.norm(x)
- return self.fn(x, **kwargs)
-
-
-class ReZero(nn.Module):
- def __init__(self, fn):
- super().__init__()
- self.residual_weight = nn.Parameter(torch.zeros(1))
- self.fn = fn
-
- def forward(self, x, **kwargs):
- x = self.fn(x, **kwargs)
- return map_first_tuple_or_el(x, lambda t: t * self.residual_weight)
-
-
-class ScaleNorm(nn.Module):
- def __init__(self, dim, eps=1e-5):
- super().__init__()
- self.g = nn.Parameter(torch.ones(1))
- self.eps = eps
-
- def forward(self, x):
- def norm(t):
- n = torch.norm(t, dim=-1, keepdim=True).clamp(min=self.eps)
- return t / n * self.g
- return map_first_tuple_or_el(x, norm)
-
-
-class ProjectInOut(nn.Module):
- def __init__(self, fn, dim_in, dim_out, project_out=True):
- super().__init__()
- self.fn = fn
- self.project_in = nn.Linear(dim_in, dim_out)
- self.project_out = nn.Linear(dim_out, dim_in) if project_out else identity
-
- def forward(self, x, **kwargs):
- x = self.project_in(x)
- x, loss = self.fn(x, **kwargs)
- x = self.project_out(x)
- return x, loss
-
-
-class MatrixMultiply(nn.Module):
- def __init__(self, tensor, transpose=False):
- super().__init__()
- self.tensor = tensor
- self.transpose = transpose
-
- def forward(self, x):
- tensor = self.tensor
- if self.transpose:
- tensor = tensor.t()
- return x @ tensor
-
-# positional embeddings
-
-
-class DepthWiseConv1d(nn.Module):
- def __init__(self, dim_in, dim_out, kernel_size, stride=1, bias=True, causal=False):
- super().__init__()
- self.padding = ((kernel_size - 1), 0) if causal else (kernel_size // 2, kernel_size // 2)
-
- self.net = nn.Sequential(
- nn.Conv1d(dim_in, dim_in, kernel_size=kernel_size, groups=dim_in, stride=stride, bias=bias),
- nn.Conv1d(dim_in, dim_out, 1, bias=bias)
- )
-
- def forward(self, x):
- x = F.pad(x, self.padding, value=0.)
- return self.net(x)
-
-
-class FixedPositionalEmbedding(nn.Module):
- def __init__(self, dim, max_seq_len):
- super().__init__()
- inv_freq = 1. / (10000 ** (torch.arange(0, dim, 2).float() / dim))
- position = torch.arange(0, max_seq_len, dtype=torch.float)
- sinusoid_inp = torch.einsum("i,j->ij", position, inv_freq)
- emb = torch.cat((sinusoid_inp.sin(), sinusoid_inp.cos()), dim=-1)
- self.register_buffer('emb', emb)
-
- def forward(self, x):
- return self.emb[None, :x.shape[1], :].to(x)
-
-
-def rotate_every_two(x):
- x = rearrange(x, '... (d j) -> ... d j', j=2)
- x1, x2 = x.unbind(dim=-1)
- x = torch.stack((-x2, x1), dim=-1)
- return rearrange(x, '... d j -> ... (d j)')
-
-
-def apply_rotary_pos_emb(q, k, sinu_pos):
- sinu_pos = rearrange(sinu_pos, '() n (j d) -> n j d', j=2)
- sin, cos = sinu_pos.unbind(dim=-2)
- sin, cos = map(lambda t: repeat(t, 'b n -> b (n j)', j=2), (sin, cos))
- q, k = map(lambda t: (t * cos) + (rotate_every_two(t) * sin), (q, k))
- return q, k
-
-# kmeans related function and class
-
-
-def update_kmeans_on_backwards(module):
- module.kmean_modules = find_modules(module, Kmeans)
-
- def hook(_, grad_in, grad_out):
- for m in module.kmean_modules:
- m.update()
-
- return module.register_backward_hook(hook)
-
-
-def similarity(x, means):
- return torch.einsum('bhld,hcd->bhlc', x, means)
-
-
-def dists_and_buckets(x, means):
- dists = similarity(x, means)
- _, buckets = torch.max(dists, dim=-1)
- return dists, buckets
-
-
-def batched_bincount(index, num_classes, dim=-1):
- shape = list(index.shape)
- shape[dim] = num_classes
- out = index.new_zeros(shape)
- out.scatter_add_(dim, index, torch.ones_like(index, dtype=index.dtype))
- return out
-
-
-def kmeans_iter(x, means, buckets=None):
- b, h, _, d, dtype, num_clusters = *x.shape, x.dtype, means.shape[1]
-
- if not exists(buckets):
- _, buckets = dists_and_buckets(x, means)
-
- bins = batched_bincount(buckets, num_clusters).sum(0, keepdim=True)
- zero_mask = bins.long() == 0
-
- means_ = buckets.new_zeros(b, h, num_clusters, d, dtype=dtype)
- means_.scatter_add_(-2, expand_dim(buckets, -1, d), x)
- means_ = F.normalize(means_.sum(0, keepdim=True), dim=-1).type(dtype)
-
- means = torch.where(zero_mask.unsqueeze(-1), means, means_)
- means = means.squeeze(0)
- return means
-
-
-def distribution(dists, window_size):
- _, topk_indices = dists.topk(k=window_size, dim=-2)
- indices = topk_indices.transpose(-2, -1)
- return indices.reshape(*indices.size()[:2], -1)
-
-
-class Kmeans(nn.Module):
- def __init__(self, num_heads, head_dim, num_clusters, ema_decay=0.999, commitment=1e-4):
- super().__init__()
- self.commitment = commitment
- self.ema_decay = ema_decay
-
- self.register_buffer('means', torch.randn(num_heads, num_clusters, head_dim))
- self.register_buffer('initted', torch.tensor(False))
- self.num_new_means = 0
- self.new_means = None
-
- @torch.no_grad()
- def init(self, x):
- if self.initted:
- return
- _, h, _, d, device, _ = *x.shape, x.device, x.dtype
-
- num_clusters = self.means.shape[1]
-
- means = x.transpose(0, 1).contiguous().view(h, -1, d)
- num_samples = means.shape[1]
-
- if num_samples >= num_clusters:
- indices = torch.randperm(num_samples, device=device)[:num_clusters]
- else:
- indices = torch.randint(0, num_samples, (num_clusters,), device=device)
-
- means = means[:, indices]
-
- for _ in range(KMEAN_INIT_ITERS):
- means = kmeans_iter(x, means)
-
- self.num_new_means = 0
- self.means.data.copy_(means)
- self.initted.data.copy_(torch.tensor(True))
-
- @torch.no_grad()
- def update(self, new_means=None):
- new_means = default(new_means, self.new_means)
- assert exists(new_means), 'new kmeans has not been supplied'
- ema_inplace(self.means, new_means, self.ema_decay)
-
- del self.new_means
- self.new_means = None
- self.num_new_means = 0
-
- def forward(self, x, update_means=False):
- self.init(x)
-
- b, dtype = x.shape[0], x.dtype
- means = self.means.type(dtype)
- x = F.normalize(x, 2, dim=-1).type(dtype)
-
- with torch.no_grad():
- dists, buckets = dists_and_buckets(x, means)
-
- routed_means = batched_index_select(expand_dim(means, 0, b), buckets)
- loss = F.mse_loss(x, routed_means) * self.commitment
-
- if update_means:
- with torch.no_grad():
- means = kmeans_iter(x, means, buckets)
- self.new_means = ema(self.new_means, means, self.num_new_means / (self.num_new_means + 1))
- self.num_new_means += 1
-
- return dists, loss
-
-# kmeans attention class
-
-
-class KmeansAttention(nn.Module):
- def __init__(self, num_clusters, window_size, num_heads, head_dim, causal=False, dropout=0., ema_decay=0.999, commitment=1e-4, context_window_size=None, receives_context=False, num_mem_kv=0, shared_qk=False):
- super().__init__()
- self.num_heads = num_heads
- self.num_clusters = num_clusters
- self.head_dim = head_dim
-
- self.window_size = window_size
- self.context_window_size = default(context_window_size, window_size)
- self.causal = causal
-
- self.shared_qk = shared_qk
- self.receives_context = receives_context
- self.kmeans = Kmeans(num_heads, head_dim, num_clusters, ema_decay, commitment)
- self.dropout = nn.Dropout(dropout)
-
- self.num_mem_kv = max(num_mem_kv, 1 if causal and not shared_qk else 0)
- self.mem_key = nn.Parameter(torch.randn(num_heads, num_clusters, self.num_mem_kv, head_dim))
- self.mem_value = nn.Parameter(torch.randn(num_heads, num_clusters, self.num_mem_kv, head_dim))
-
- def forward(self, q, k, v, query_mask=None, key_mask=None, **kwargs):
- b, h, t, d, kv_t, wsz, c_wsz, nc, device, dtype = *q.shape, k.shape[2], self.window_size, self.context_window_size, self.num_clusters, q.device, q.dtype
- is_reverse = kwargs.pop('_reverse', False)
-
- out = torch.zeros_like(q, dtype=dtype)
-
- update_kmeans = self.training and not is_reverse
-
- key_mask = default(key_mask, query_mask) if not self.receives_context else key_mask
- kv_wsz = wsz if not self.receives_context else c_wsz
-
- wsz = min(wsz, t)
- kv_wsz = min(kv_wsz, kv_t)
-
- if not self.shared_qk or self.receives_context:
- dists, aux_loss = self.kmeans(torch.cat((q, k), dim=2), update_kmeans)
- q_dists, k_dists = split_at_index(2, t, dists)
- indices = distribution(q_dists, wsz)
- kv_indices = distribution(k_dists, kv_wsz)
- else:
- dists, aux_loss = self.kmeans(q, update_kmeans)
- k = F.normalize(k, dim=-1).to(q)
- indices = distribution(dists, wsz)
- kv_indices = indices
-
- q = batched_index_select(q, indices)
- k = batched_index_select(k, kv_indices)
- v = batched_index_select(v, kv_indices)
-
- reshape_with_window = lambda x: x.reshape(b, h, nc, -1, d)
- q, k, v = map(reshape_with_window, (q, k, v))
-
- m_k, m_v = map(lambda x: expand_dim(x, 0, b).to(q), (self.mem_key, self.mem_value))
- k, v = map(lambda x: torch.cat(x, dim=3), ((m_k, k), (m_v, v)))
-
- dots = torch.einsum('bhnid,bhnjd->bhnij', q, k) * (d ** -0.5)
-
- mask_value = max_neg_value(dots)
-
- if exists(query_mask) or exists(key_mask):
- query_mask = default(query_mask, lambda: torch.ones((b, t), device=device).bool())
- key_mask = default(key_mask, lambda: torch.ones((b, kv_t), device=device).bool())
-
- q_mask = expand_dim(query_mask, 1, h).gather(2, indices)
- kv_mask = expand_dim(key_mask, 1, h).gather(2, kv_indices)
- q_mask, kv_mask = map(lambda t: t.reshape(b, h, nc, -1), (q_mask, kv_mask))
- mask = q_mask[:, :, :, :, None] * kv_mask[:, :, :, None, :]
- mask = F.pad(mask, (self.num_mem_kv, 0), value=1)
- dots.masked_fill_(~mask, mask_value)
- del mask
-
- if self.causal:
- q_mask, kv_mask = map(lambda t: t.reshape(b, h, nc, -1), (indices, kv_indices))
- mask = q_mask[:, :, :, :, None] >= kv_mask[:, :, :, None, :]
- mask = F.pad(mask, (self.num_mem_kv, 0), value=1)
- dots.masked_fill_(~mask, mask_value)
- del mask
-
- if self.shared_qk:
- q_mask, kv_mask = map(lambda t: t.reshape(b, h, nc, -1), (indices, kv_indices))
- mask = q_mask[:, :, :, :, None] == kv_mask[:, :, :, None, :]
- mask = F.pad(mask, (self.num_mem_kv, 0), value=0)
- dots.masked_fill_(mask, TOKEN_SELF_ATTN_VALUE)
- del mask
-
- dots = dots.softmax(dim=-1)
- dots = self.dropout(dots)
-
- bo = torch.einsum('bhcij,bhcjd->bhcid', dots, v)
- so = torch.reshape(bo, (b, h, -1, bo.shape[-1])).type(dtype)
- out = scatter_mean(out, so, indices.unsqueeze(-1).expand_as(so), -2)
- return out, aux_loss
-
-# feedforward
-
-
-class GELU_(nn.Module):
- def forward(self, x):
- return 0.5 * x * (1 + torch.tanh(math.sqrt(2 / math.pi) * (x + 0.044715 * torch.pow(x, 3))))
-
-
-GELU = nn.GELU if hasattr(nn, 'GELU') else GELU_
-
-
-class FeedForward(nn.Module):
- def __init__(self, dim, mult=4, dropout=0., activation=None, glu=False):
- super().__init__()
- activation = default(activation, GELU)
-
- self.glu = glu
- self.w1 = nn.Linear(dim, dim * mult * (2 if glu else 1))
- self.act = activation()
- self.dropout = nn.Dropout(dropout)
- self.w2 = nn.Linear(dim * mult, dim)
-
- def forward(self, x, **kwargs):
- if not self.glu:
- x = self.w1(x)
- x = self.act(x)
- else:
- x, v = self.w1(x).chunk(2, dim=-1)
- x = self.act(x) * v
-
- x = self.dropout(x)
- x = self.w2(x)
- return x
-
-# self attention
-
-
-class SelfAttention(nn.Module):
- def __init__(self, dim, max_seq_len, heads, local_attn_heads, window_size, dim_head=None, local_attn_window_size=None, local_attn_radius_blocks=1, causal=False, attn_dropout=0., dropout=0., kmeans_ema_decay=0.999, commitment_factor=1e-4, receives_context=False, context_window_size=None, rel_pos_emb=True, num_mem_kv=0, shared_qk=False, conv_query_kernel=9):
- super().__init__()
- assert dim_head or (dim % heads) == 0, 'hidden dimension must be divisible by number of heads'
- assert (max_seq_len % window_size) == 0, 'maximum sequence length must be divisible by the target window size'
- assert local_attn_heads <= heads, 'number of local attention heads must be less than total heads'
- assert not (receives_context and local_attn_heads > 0), 'local attention cannot be used for self attention with context'
- assert not (receives_context and causal), 'contextual attention layer cannot be causal'
-
- local_attn_window_size = default(local_attn_window_size, window_size)
- context_window_size = default(context_window_size, window_size)
-
- self.shared_qk = shared_qk
- self.receives_context = receives_context
- self.heads = heads
- self.local_attn_heads = local_attn_heads
- self.global_attn_heads = heads - local_attn_heads
-
- self.causal = causal
- self.window_size = window_size
-
- dim_head = default(dim_head, dim // heads)
- dim_heads = dim_head * heads
- self.dim_head = dim_head
-
- num_clusters = max_seq_len // window_size
-
- # local
-
- local_dim_heads = dim_head * self.local_attn_heads
-
- if self.local_attn_heads > 0:
- rel_pos_emb_config = (dim_head, local_attn_heads) if rel_pos_emb else None
- self.local_attn = LocalAttention(dim=dim_head, window_size=local_attn_window_size, causal=causal, dropout=attn_dropout, rel_pos_emb_config=rel_pos_emb_config, look_backward=local_attn_radius_blocks, look_forward=0 if causal else local_attn_radius_blocks)
- self.local_to_qkv = nn.Linear(dim, 3 * local_dim_heads)
-
- # global
-
- global_dim_heads = dim_head * self.global_attn_heads
-
- if self.global_attn_heads > 0:
- self.global_attn = KmeansAttention(num_clusters, window_size, self.global_attn_heads, dim_head, causal=causal, dropout=attn_dropout, ema_decay=kmeans_ema_decay, commitment=commitment_factor, receives_context=receives_context, num_mem_kv=num_mem_kv, shared_qk=shared_qk)
-
- self.to_q = nn.Sequential(
- Rearrange('b n c -> b c n'),
- DepthWiseConv1d(dim, global_dim_heads, conv_query_kernel, causal=causal),
- Rearrange('b c n -> b n c')
- )
-
- self.to_v = nn.Linear(dim, global_dim_heads, bias=False)
-
- if not self.shared_qk:
- self.to_k = nn.Linear(dim, global_dim_heads, bias=False)
-
- # out
-
- self.to_out = nn.Linear(dim_heads, dim, bias=False)
- self.dropout = nn.Dropout(dropout)
-
- def forward(self, query, key, value, context=None, key_padding_mask=None, context_mask=None, pos_emb=None, **kwargs):
- assert not (self.receives_context and not exists(context)), 'context must be passed if self attention is set to receive context'
- input_mask = key_padding_mask
- x = query.transpose(0, 1)
- b, t, _, h, dh = *x.shape, self.heads, self.dim_head
- has_local, has_global = map(lambda x: x > 0, (self.local_attn_heads, self.global_attn_heads))
-
- split_heads = lambda v: reshape_dim(v, -1, (-1, dh)).transpose(1, 2).contiguous()
-
- if has_local:
- local_qkv = self.local_to_qkv(x).chunk(3, dim=-1)
- lq, lk, lv = map(split_heads, local_qkv)
-
- if has_global:
- kv_input = x if not self.receives_context else context
-
- q, v = self.to_q(x), self.to_v(kv_input)
-
- if not self.shared_qk:
- k = self.to_k(kv_input)
- else:
- k = self.to_q(kv_input) if self.receives_context else q
-
- q, k, v = map(split_heads, (q, k, v))
-
- out = []
- total_loss = torch.tensor(0., requires_grad=True, **to(x))
-
- if has_local:
- local_out = self.local_attn(lq, lk, lv, input_mask=input_mask)
- out.append(local_out)
-
- if has_global:
- if not self.receives_context and exists(pos_emb):
- q, k = apply_rotary_pos_emb(q, k, pos_emb)
-
- global_out, loss = self.global_attn(q, k, v, query_mask=input_mask, key_mask=context_mask)
- total_loss = total_loss + loss
-
- out.append(global_out)
-
- out = torch.cat(out, dim=1)
- out = out.reshape(b, h, t, -1).transpose(1, 2).reshape(b, t, -1)
- out = self.dropout(out.transpose(0, 1))
- # out = self.to_out(out)
- return out, total_loss
diff --git a/spaces/OFA-Sys/OFA-Image_Caption/fairseq/examples/shuffled_word_order/README.md b/spaces/OFA-Sys/OFA-Image_Caption/fairseq/examples/shuffled_word_order/README.md
deleted file mode 100644
index f20483849a8ca33bf349b57882a79155ba593bf1..0000000000000000000000000000000000000000
--- a/spaces/OFA-Sys/OFA-Image_Caption/fairseq/examples/shuffled_word_order/README.md
+++ /dev/null
@@ -1,84 +0,0 @@
-# Masked Language Modeling and the Distributional Hypothesis: Order Word Matters Pre-training for Little
-
-[https://arxiv.org/abs/2104.06644](https://arxiv.org/abs/2104.06644)
-
-## Introduction
-
-In this work, we pre-train [RoBERTa](../roberta) base on various word shuffled variants of BookWiki corpus (16GB). We observe that a word shuffled pre-trained model achieves surprisingly good scores on GLUE, PAWS and several parametric probing tasks. Please read our paper for more details on the experiments.
-
-## Pre-trained models
-
-| Model | Description | Download |
-| ------------------------------------- | -------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
-| `roberta.base.orig` | RoBERTa (base) trained on natural corpus | [roberta.base.orig.tar.gz](https://dl.fbaipublicfiles.com/unnatural_pretraining/roberta.base.orig.tar.gz) |
-| `roberta.base.shuffle.n1` | RoBERTa (base) trained on n=1 gram sentence word shuffled data | [roberta.base.shuffle.n1.tar.gz](https://dl.fbaipublicfiles.com/unnatural_pretraining/roberta.base.shuffle.n1.tar.gz) |
-| `roberta.base.shuffle.n2` | RoBERTa (base) trained on n=2 gram sentence word shuffled data | [roberta.base.shuffle.n2.tar.gz](https://dl.fbaipublicfiles.com/unnatural_pretraining/roberta.base.shuffle.n2.tar.gz) |
-| `roberta.base.shuffle.n3` | RoBERTa (base) trained on n=3 gram sentence word shuffled data | [roberta.base.shuffle.n3.tar.gz](https://dl.fbaipublicfiles.com/unnatural_pretraining/roberta.base.shuffle.n3.tar.gz) |
-| `roberta.base.shuffle.n4` | RoBERTa (base) trained on n=4 gram sentence word shuffled data | [roberta.base.shuffle.n4.tar.gz](https://dl.fbaipublicfiles.com/unnatural_pretraining/roberta.base.shuffle.n4.tar.gz) |
-| `roberta.base.shuffle.512` | RoBERTa (base) trained on unigram 512 word block shuffled data | [roberta.base.shuffle.512.tar.gz](https://dl.fbaipublicfiles.com/unnatural_pretraining/roberta.base.shuffle.512.tar.gz) |
-| `roberta.base.shuffle.corpus` | RoBERTa (base) trained on unigram corpus word shuffled data | [roberta.base.shuffle.corpus.tar.gz](https://dl.fbaipublicfiles.com/unnatural_pretraining/roberta.base.shuffle.corpus.tar.gz) |
-| `roberta.base.shuffle.corpus_uniform` | RoBERTa (base) trained on unigram corpus word shuffled data, where all words are uniformly sampled | [roberta.base.shuffle.corpus_uniform.tar.gz](https://dl.fbaipublicfiles.com/unnatural_pretraining/roberta.base.shuffle.corpus_uniform.tar.gz) |
-| `roberta.base.nopos` | RoBERTa (base) without positional embeddings, trained on natural corpus | [roberta.base.nopos.tar.gz](https://dl.fbaipublicfiles.com/unnatural_pretraining/roberta.base.nopos.tar.gz) |
-
-## Results
-
-[GLUE (Wang et al, 2019)](https://gluebenchmark.com/) & [PAWS (Zhang et al, 2019)](https://github.com/google-research-datasets/paws) _(dev set, single model, single-task fine-tuning, median of 5 seeds)_
-
-| name | CoLA | MNLI | MRPC | PAWS | QNLI | QQP | RTE | SST-2 |
-| :----------------------------------- | ----: | ----: | ----: | ----: | ----: | ----: | ----: | ----: |
-| `roberta.base.orig` | 61.4 | 86.11 | 89.19 | 94.46 | 92.53 | 91.26 | 74.64 | 93.92 |
-| `roberta.base.shuffle.n1` | 35.15 | 82.64 | 86 | 89.97 | 89.02 | 91.01 | 69.02 | 90.47 |
-| `roberta.base.shuffle.n2` | 54.37 | 83.43 | 86.24 | 93.46 | 90.44 | 91.36 | 70.83 | 91.79 |
-| `roberta.base.shuffle.n3` | 48.72 | 83.85 | 86.36 | 94.05 | 91.69 | 91.24 | 70.65 | 92.02 |
-| `roberta.base.shuffle.n4` | 58.64 | 83.77 | 86.98 | 94.32 | 91.69 | 91.4 | 70.83 | 92.48 |
-| `roberta.base.shuffle.512` | 12.76 | 77.52 | 79.61 | 84.77 | 85.19 | 90.2 | 56.52 | 86.34 |
-| `roberta.base.shuffle.corpus` | 0 | 71.9 | 70.52 | 58.52 | 71.11 | 85.52 | 53.99 | 83.35 |
-| `roberta.base.shuffle.corpus_random` | 9.19 | 72.33 | 70.76 | 58.42 | 77.76 | 85.93 | 53.99 | 84.04 |
-| `roberta.base.nopos` | 0 | 63.5 | 72.73 | 57.08 | 77.72 | 87.87 | 54.35 | 83.24 |
-
-For more results on probing tasks, please refer to [our paper](https://arxiv.org/abs/2104.06644).
-
-## Example Usage
-
-Follow the same usage as in [RoBERTa](https://github.com/pytorch/fairseq/tree/main/examples/roberta) to load and test your models:
-
-```python
-# Download roberta.base.shuffle.n1 model
-wget https://dl.fbaipublicfiles.com/unnatural_pretraining/roberta.base.shuffle.n1.tar.gz
-tar -xzvf roberta.base.shuffle.n1.tar.gz
-
-# Load the model in fairseq
-from fairseq.models.roberta import RoBERTaModel
-roberta = RoBERTaModel.from_pretrained('/path/to/roberta.base.shuffle.n1', checkpoint_file='model.pt')
-roberta.eval() # disable dropout (or leave in train mode to finetune)
-```
-
-**Note**: The model trained without positional embeddings (`roberta.base.nopos`) is a modified `RoBERTa` model, where the positional embeddings are not used. Thus, the typical `from_pretrained` method on fairseq version of RoBERTa will not be able to load the above model weights. To do so, construct a new `RoBERTaModel` object by setting the flag `use_positional_embeddings` to `False` (or [in the latest code](https://github.com/pytorch/fairseq/blob/main/fairseq/models/roberta/model.py#L543), set `no_token_positional_embeddings` to `True`), and then load the individual weights.
-
-## Fine-tuning Evaluation
-
-We provide the trained fine-tuned models on MNLI here for each model above for quick evaluation (1 seed for each model). Please refer to [finetuning details](README.finetuning.md) for the parameters of these models. Follow [RoBERTa](https://github.com/pytorch/fairseq/tree/main/examples/roberta) instructions to evaluate these models.
-
-| Model | MNLI M Dev Accuracy | Link |
-| :----------------------------------------- | :------------------ | :--------------------------------------------------------------------------------------------------------------- |
-| `roberta.base.orig.mnli` | 86.14 | [Download](https://dl.fbaipublicfiles.com/unnatural_pretraining/roberta.base.orig.mnli.tar.gz) |
-| `roberta.base.shuffle.n1.mnli` | 82.55 | [Download](https://dl.fbaipublicfiles.com/unnatural_pretraining/roberta.base.shuffle.n1.mnli.tar.gz) |
-| `roberta.base.shuffle.n2.mnli` | 83.21 | [Download](https://dl.fbaipublicfiles.com/unnatural_pretraining/roberta.base.shuffle.n2.mnli.tar.gz) |
-| `roberta.base.shuffle.n3.mnli` | 83.89 | [Download](https://dl.fbaipublicfiles.com/unnatural_pretraining/roberta.base.shuffle.n3.mnli.tar.gz) |
-| `roberta.base.shuffle.n4.mnli` | 84.00 | [Download](https://dl.fbaipublicfiles.com/unnatural_pretraining/roberta.base.shuffle.n4.mnli.tar.gz) |
-| `roberta.base.shuffle.512.mnli` | 77.22 | [Download](https://dl.fbaipublicfiles.com/unnatural_pretraining/roberta.base.shuffle.512.mnli.tar.gz) |
-| `roberta.base.shuffle.corpus.mnli` | 71.88 | [Download](https://dl.fbaipublicfiles.com/unnatural_pretraining/roberta.base.shuffle.corpus.mnli.tar.gz) |
-| `roberta.base.shuffle.corpus_uniform.mnli` | 72.46 | [Download](https://dl.fbaipublicfiles.com/unnatural_pretraining/roberta.base.shuffle.corpus_uniform.mnli.tar.gz) |
-
-## Citation
-
-```bibtex
-@misc{sinha2021masked,
- title={Masked Language Modeling and the Distributional Hypothesis: Order Word Matters Pre-training for Little},
- author={Koustuv Sinha and Robin Jia and Dieuwke Hupkes and Joelle Pineau and Adina Williams and Douwe Kiela},
- year={2021},
- eprint={2104.06644},
- archivePrefix={arXiv},
- primaryClass={cs.CL}
-}
-```
diff --git a/spaces/OFA-Sys/OFA-Image_Caption/fairseq/examples/simultaneous_translation/utils/__init__.py b/spaces/OFA-Sys/OFA-Image_Caption/fairseq/examples/simultaneous_translation/utils/__init__.py
deleted file mode 100644
index 1e9ce844f59a4211061392084cc81075e6bab19f..0000000000000000000000000000000000000000
--- a/spaces/OFA-Sys/OFA-Image_Caption/fairseq/examples/simultaneous_translation/utils/__init__.py
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright (c) Facebook, Inc. and its affiliates.
-#
-# This source code is licensed under the MIT license found in the
-# LICENSE file in the root directory of this source tree.
-
-import importlib
-import os
-
-
-# automatically import any Python files in the criterions/ directory
-for file in sorted(os.listdir(os.path.dirname(__file__))):
- if file.endswith(".py") and not file.startswith("_"):
- module = file[: file.find(".py")]
- importlib.import_module("examples.simultaneous_translation.utils." + module)
diff --git a/spaces/OFA-Sys/OFA-Visual_Grounding/fairseq/examples/adaptive_span/adaptive_span_attention.py b/spaces/OFA-Sys/OFA-Visual_Grounding/fairseq/examples/adaptive_span/adaptive_span_attention.py
deleted file mode 100644
index 07f757bb8e1a8a67b1124175ee338c8735aa8d65..0000000000000000000000000000000000000000
--- a/spaces/OFA-Sys/OFA-Visual_Grounding/fairseq/examples/adaptive_span/adaptive_span_attention.py
+++ /dev/null
@@ -1,160 +0,0 @@
-# Copyright (c) Facebook, Inc. and its affiliates.
-#
-# This source code is licensed under the MIT license found in the
-# LICENSE file in the root directory of this source tree.
-import math
-
-import torch
-import torch.nn as nn
-import torch.nn.functional as F
-
-
-class AdaptiveMask(nn.Module):
- """Soft masking function for adaptive size.
- It masks out the last K values of an input. The masking value
- goes from 1 to 0 gradually, so K can be learned with
- back-propagation.
- Args:
- max_size: maximum size (i.e. input dimension)
- ramp_size: size of the ramp going from 0 to 1
- init_val: initial size proportion not to be masked out
- shape: learn multiple sizes independent of each other
- """
-
- def __init__(self, max_size, ramp_size, init_val=0, shape=(1,)):
- nn.Module.__init__(self)
- self._max_size = max_size
- self._ramp_size = ramp_size
- self.current_val = nn.Parameter(torch.zeros(*shape) + init_val)
- mask_template = torch.linspace(1 - max_size, 0, steps=max_size)
- self.register_buffer("mask_template", mask_template)
-
- def forward(self, x):
- mask = self.mask_template.float() + self.current_val.float() * self._max_size
- mask = mask / self._ramp_size + 1
- mask = mask.clamp(0, 1)
- if x.size(-1) < self._max_size:
- # the input could have been trimmed beforehand to save computation
- mask = mask.narrow(-1, self._max_size - x.size(-1), x.size(-1))
- x = (x * mask).type_as(x)
- return x
-
- def get_current_max_size(self, include_ramp=True):
- current_size = math.ceil(self.current_val.max().item() * self._max_size)
- if include_ramp:
- current_size += self._ramp_size
- current_size = max(0, min(self._max_size, current_size))
- return current_size
-
- def get_current_avg_size(self, include_ramp=True):
- current_size = math.ceil(
- self.current_val.float().mean().item() * self._max_size
- )
- if include_ramp:
- current_size += self._ramp_size
- current_size = max(0, min(self._max_size, current_size))
- return current_size
-
- def clamp_param(self):
- """this need to be called after each update"""
- self.current_val.data.clamp_(0, 1)
-
-
-class AdaptiveSpan(nn.Module):
- """Adaptive attention span for Transformerself.
- This module learns an attention span length from data for each
- self-attention head.
- Args:
- attn_span: maximum attention span
- adapt_span_loss: loss coefficient for the span length
- adapt_span_ramp: length of the masking ramp
- adapt_span_init: initial size ratio
- adapt_span_cache: adapt cache size to reduce memory usage
- """
-
- def __init__(
- self,
- attn_span,
- adapt_span_ramp,
- adapt_span_init,
- n_head,
- adapt_span_layer,
- **kargs
- ):
- nn.Module.__init__(self)
- self._max_span = attn_span
- self._n_head = n_head
- self._adapt_span_layer = adapt_span_layer
- if self._adapt_span_layer:
- self._mask = AdaptiveMask(
- max_size=self._max_span,
- ramp_size=adapt_span_ramp,
- init_val=adapt_span_init,
- )
- else:
- self._mask = AdaptiveMask(
- max_size=self._max_span,
- ramp_size=adapt_span_ramp,
- init_val=adapt_span_init,
- shape=(n_head, 1, 1),
- )
-
- def forward(self, attn, normalize=True):
- """mask attention with the right span"""
- # batch and head dimensions are merged together, so separate them first
- self.clamp_param()
- if self._adapt_span_layer:
- attn = self._mask(attn)
- else:
- B = attn.size(0) # batch size
- M = attn.size(1) # block size
- attn = attn.reshape(B // self._n_head, self._n_head, M, -1)
- attn = self._mask(attn)
- attn = attn.view(B, M, -1)
- return attn
-
- def get_trim_len(self):
- """how much of memory can be trimmed to reduce computation"""
- L = self._max_span
- trim_len = min(L - 1, L - self._mask.get_current_max_size())
- # too fine granularity might be bad for the memory management
- trim_len = math.floor(trim_len / 64) * 64
- return trim_len
-
- def trim_memory(self, query, key, value, key_pe):
- """trim out unnecessary memory beforehand to reduce computation"""
- trim_len = self.get_trim_len()
- cache_size = key.size(1) - query.size(1)
- trim_len_cache = trim_len - (self._max_span - cache_size)
- if trim_len_cache > 0:
- key = key[:, trim_len_cache:, :]
- value = value[:, trim_len_cache:, :]
- elif trim_len_cache < 0:
- # cache is too short! this happens when validation resumes
- # after a lot of updates.
- key = F.pad(key, [0, 0, -trim_len_cache, 0])
- value = F.pad(value, [0, 0, -trim_len_cache, 0])
- if trim_len > 0:
- if key_pe is not None:
- key_pe = key_pe[:, :, trim_len:]
- return key, value, key_pe
-
- def get_cache_size(self):
- """determine how long the cache should be"""
- trim_len = self.get_trim_len()
- # give a buffer of 64 steps since a span might increase
- # in future updates
- return min(self._max_span, self._max_span - trim_len + 64)
-
- def get_loss(self):
- """a loss term for regularizing the span length"""
- return self._max_span * self._mask.current_val.float().mean()
-
- def get_current_max_span(self):
- return self._mask.get_current_max_size()
-
- def get_current_avg_span(self):
- return self._mask.get_current_avg_size()
-
- def clamp_param(self):
- self._mask.clamp_param()
diff --git a/spaces/OFA-Sys/OFA-vqa/fairseq/examples/wav2vec/unsupervised/kaldi_self_train/st/local/score.sh b/spaces/OFA-Sys/OFA-vqa/fairseq/examples/wav2vec/unsupervised/kaldi_self_train/st/local/score.sh
deleted file mode 100644
index cb5bbb7277bfb9f2d5440da0514bf7b16da8140d..0000000000000000000000000000000000000000
--- a/spaces/OFA-Sys/OFA-vqa/fairseq/examples/wav2vec/unsupervised/kaldi_self_train/st/local/score.sh
+++ /dev/null
@@ -1,63 +0,0 @@
-#!/usr/bin/env bash
-# Copyright 2012 Johns Hopkins University (Author: Daniel Povey)
-# 2014 Guoguo Chen
-# Apache 2.0
-
-[ -f ./path.sh ] && . ./path.sh
-
-# begin configuration section.
-cmd=run.pl
-stage=0
-decode_mbr=true
-word_ins_penalty=0.0,0.5,1.0
-min_lmwt=7
-max_lmwt=17
-iter=final
-#end configuration section.
-
-[ -f ./path.sh ] && . ./path.sh
-. parse_options.sh || exit 1;
-
-if [ $# -ne 3 ]; then
- echo "Usage: local/score.sh [--cmd (run.pl|queue.pl...)] "
- echo " Options:"
- echo " --cmd (run.pl|queue.pl...) # specify how to run the sub-processes."
- echo " --stage (0|1|2) # start scoring script from part-way through."
- echo " --decode_mbr (true/false) # maximum bayes risk decoding (confusion network)."
- echo " --min_lmwt # minumum LM-weight for lattice rescoring "
- echo " --max_lmwt # maximum LM-weight for lattice rescoring "
- exit 1;
-fi
-
-data=$1
-lang_or_graph=$2
-dir=$3
-
-symtab=$lang_or_graph/words.txt
-
-for f in $symtab $dir/lat.1.gz $data/text; do
- [ ! -f $f ] && echo "score.sh: no such file $f" && exit 1;
-done
-
-mkdir -p $dir/scoring/log
-
-cat $data/text | sed 's:::g' | sed 's:::g' > $dir/scoring/test_filt.txt
-
-for wip in $(echo $word_ins_penalty | sed 's/,/ /g'); do
- $cmd LMWT=$min_lmwt:$max_lmwt $dir/scoring/log/best_path.LMWT.$wip.log \
- lattice-scale --inv-acoustic-scale=LMWT "ark:gunzip -c $dir/lat.*.gz|" ark:- \| \
- lattice-add-penalty --word-ins-penalty=$wip ark:- ark:- \| \
- lattice-best-path --word-symbol-table=$symtab \
- ark:- ark,t:$dir/scoring/LMWT.$wip.tra || exit 1;
-done
-
-# Note: the double level of quoting for the sed command
-for wip in $(echo $word_ins_penalty | sed 's/,/ /g'); do
- $cmd LMWT=$min_lmwt:$max_lmwt $dir/scoring/log/score.LMWT.$wip.log \
- cat $dir/scoring/LMWT.$wip.tra \| \
- utils/int2sym.pl -f 2- $symtab \| sed 's:\::g' \| \
- compute-wer --text --mode=present \
- ark:$dir/scoring/test_filt.txt ark,p:- ">&" $dir/wer_LMWT_$wip || exit 1;
-done
-
-exit 0;
diff --git a/spaces/OFA-Sys/OFA-vqa/fairseq/fairseq/logging/metrics.py b/spaces/OFA-Sys/OFA-vqa/fairseq/fairseq/logging/metrics.py
deleted file mode 100644
index 58c2fb64e186ed9d5e9a06c73194d98a21bb7560..0000000000000000000000000000000000000000
--- a/spaces/OFA-Sys/OFA-vqa/fairseq/fairseq/logging/metrics.py
+++ /dev/null
@@ -1,314 +0,0 @@
-# Copyright (c) Facebook, Inc. and its affiliates.
-#
-# This source code is licensed under the MIT license found in the
-# LICENSE file in the root directory of this source tree.
-"""
-A standalone module for aggregating metrics.
-
-Metrics can be logged from anywhere using the `log_*` functions defined
-in this module. The logged values will be aggregated dynamically based
-on the aggregation context in which the logging occurs. See the
-:func:`aggregate` context manager for more details.
-"""
-
-import contextlib
-import uuid
-from collections import defaultdict
-from typing import Callable, List, Optional
-
-from .meters import *
-
-
-# Aggregation contexts are considered "active" when inside the scope
-# created by the :func:`aggregate` context manager.
-_aggregators = OrderedDict()
-_active_aggregators = OrderedDict()
-_active_aggregators_cnt = defaultdict(lambda: 0)
-
-
-def reset() -> None:
- """Reset all metrics aggregators."""
- _aggregators.clear()
- _active_aggregators.clear()
- _active_aggregators_cnt.clear()
-
- # The "default" aggregator observes all logged values.
- _aggregators["default"] = MetersDict()
- _active_aggregators["default"] = _aggregators["default"]
- _active_aggregators_cnt["default"] = 1
-
-
-reset()
-
-
-@contextlib.contextmanager
-def aggregate(name: Optional[str] = None, new_root: bool = False):
- """Context manager to aggregate metrics under a given name.
-
- Aggregations can be nested. If *new_root* is ``False``, then logged
- metrics will be recorded along the entire stack of nested
- aggregators, including a global "default" aggregator. If *new_root*
- is ``True``, then this aggregator will be the root of a new
- aggregation stack, thus bypassing any parent aggregators.
-
- Note that aggregation contexts are uniquely identified by their
- *name* (e.g., train, valid). Creating a context with an existing
- name will reuse the corresponding :class:`MetersDict` instance.
- If no name is given, then a temporary aggregator will be created.
-
- Usage::
-
- with metrics.aggregate("train"):
- for step, batch in enumerate(epoch):
- with metrics.aggregate("train_inner") as agg:
- metrics.log_scalar("loss", get_loss(batch))
- if step % log_interval == 0:
- print(agg.get_smoothed_value("loss"))
- agg.reset()
- print(metrics.get_smoothed_values("train")["loss"])
-
- Args:
- name (str): name of the aggregation. Defaults to a
- random/temporary name if not given explicitly.
- new_root (bool): make this aggregation the root of a new
- aggregation stack.
- """
- if name is None:
- # generate a temporary name
- name = str(uuid.uuid4())
- assert name not in _aggregators
- agg = MetersDict()
- else:
- assert name != "default"
- agg = _aggregators.setdefault(name, MetersDict())
-
- if new_root:
- backup_aggregators = _active_aggregators.copy()
- _active_aggregators.clear()
- backup_aggregators_cnt = _active_aggregators_cnt.copy()
- _active_aggregators_cnt.clear()
-
- _active_aggregators[name] = agg
- _active_aggregators_cnt[name] += 1
-
- yield agg
-
- _active_aggregators_cnt[name] -= 1
- if _active_aggregators_cnt[name] == 0 and name in _active_aggregators:
- del _active_aggregators[name]
-
- if new_root:
- _active_aggregators.clear()
- _active_aggregators.update(backup_aggregators)
- _active_aggregators_cnt.clear()
- _active_aggregators_cnt.update(backup_aggregators_cnt)
-
-
-def get_active_aggregators() -> List[MetersDict]:
- return list(_active_aggregators.values())
-
-
-def log_scalar(
- key: str,
- value: float,
- weight: float = 1,
- priority: int = 10,
- round: Optional[int] = None,
-):
- """Log a scalar value.
-
- Args:
- key (str): name of the field to log
- value (float): value to log
- weight (float): weight that this value contributes to the average.
- A weight of 0 will always log the latest value.
- priority (int): smaller values are logged earlier in the output
- round (Optional[int]): number of digits to round to when displaying
- """
- for agg in get_active_aggregators():
- if key not in agg:
- agg.add_meter(key, AverageMeter(round=round), priority)
- agg[key].update(value, weight)
-
-def log_scalar_sum(
- key: str,
- value: float,
- priority: int = 10,
- round: Optional[int] = None,
-):
- """Log a scalar value that is summed for reporting.
-
- Args:
- key (str): name of the field to log
- value (float): value to log
- priority (int): smaller values are logged earlier in the output
- round (Optional[int]): number of digits to round to when displaying
- """
- for agg in get_active_aggregators():
- if key not in agg:
- agg.add_meter(key, SumMeter(round=round), priority)
- agg[key].update(value)
-
-
-def log_derived(key: str, fn: Callable[[MetersDict], float], priority: int = 20):
- """Log a scalar value derived from other meters.
-
- Args:
- key (str): name of the field to log
- fn (Callable[[MetersDict], float]): function that takes a single
- argument *meters* and returns the derived value
- priority (int): smaller values are logged earlier in the output
- """
- for agg in get_active_aggregators():
- if key not in agg:
- agg.add_meter(key, MetersDict._DerivedMeter(fn), priority)
-
-
-def log_speed(
- key: str,
- value: float,
- priority: int = 30,
- round: Optional[int] = None,
-):
- """Log the rate of some quantity per second.
-
- Args:
- key (str): name of the field to log
- value (float): value to log
- priority (int): smaller values are logged earlier in the output
- round (Optional[int]): number of digits to round to when displaying
- """
- for agg in get_active_aggregators():
- if key not in agg:
- agg.add_meter(key, TimeMeter(round=round), priority)
- agg[key].reset() # reset meter on the first call
- else:
- agg[key].update(value)
-
-
-def log_start_time(key: str, priority: int = 40, round: Optional[int] = None):
- """Log the duration of some event in seconds.
-
- The duration will be computed once :func:`log_stop_time` is called.
-
- Args:
- key (str): name of the field to log
- priority (int): smaller values are logged earlier in the output
- round (Optional[int]): number of digits to round to when displaying
- """
- for agg in get_active_aggregators():
- if key not in agg:
- agg.add_meter(key, StopwatchMeter(round=round), priority)
- agg[key].start()
-
-
-def log_stop_time(key: str, weight: float = 0.0, prehook=None):
- """Log the duration of some event in seconds.
-
- The duration will be computed since :func:`log_start_time` was called.
- Set weight > 0 to report the average time instead of the sum.
-
- Args:
- key (str): name of the field to log
- weight (float): weight that this time contributes to the average
- prehook (function, no arguments): will be called before the timer
- is stopped. For example, use prehook=torch.cuda.synchronize to
- make sure all gpu operations are done before timer is stopped.
- """
- for agg in get_active_aggregators():
- if key in agg:
- agg[key].stop(weight, prehook)
-
-
-def log_custom(
- new_meter_fn: Callable[[], Meter],
- key: str,
- *args,
- priority: int = 50,
- **kwargs,
-):
- """Log using a custom Meter.
-
- Any extra *args* or *kwargs* will be passed through to the Meter's
- *update* method.
-
- Args:
- new_meter_fn (Callable[[], Meter]): function that returns a new
- Meter instance
- key (str): name of the field to log
- priority (int): smaller values are logged earlier in the output
- """
- for agg in get_active_aggregators():
- if key not in agg:
- agg.add_meter(key, new_meter_fn(), priority)
- agg[key].update(*args, **kwargs)
-
-
-def reset_meter(name: str, key: str) -> None:
- """Reset Meter instance aggregated under a given *name* and *key*."""
- meter = get_meter(name, key)
- if meter is not None:
- meter.reset()
-
-
-def reset_meters(name: str) -> None:
- """Reset Meter instances aggregated under a given *name*."""
- meters = get_meters(name)
- if meters is not None:
- meters.reset()
-
-
-def get_meter(name: str, key: str) -> Meter:
- """Get a single Meter instance aggregated under *name* and *key*.
-
- Returns:
- Meter or None if no metrics have been logged under *name* and *key*.
- """
- if name not in _aggregators:
- return None
- return _aggregators[name].get(key, None)
-
-
-def get_meters(name: str) -> MetersDict:
- """Get Meter instances aggregated under a given *name*.
-
- Returns:
- MetersDict or None if no metrics have been logged under *name*.
- """
- return _aggregators.get(name, None)
-
-
-def get_smoothed_value(name: str, key: str) -> float:
- """Get a single smoothed value.
-
- Raises:
- KeyError: if no metrics have been logged under *name* and *key*.
- """
- return _aggregators[name].get_smoothed_value(key)
-
-
-def get_smoothed_values(name: str) -> Dict[str, float]:
- """Get smoothed values aggregated under a given *name*.
-
- Raises:
- KeyError: if no metrics have been logged under *name*.
- """
- return _aggregators[name].get_smoothed_values()
-
-
-def state_dict():
- return OrderedDict([(name, agg.state_dict()) for name, agg in _aggregators.items()])
-
-
-def load_state_dict(state_dict):
- for name, agg_state in state_dict.items():
- _aggregators[name] = MetersDict()
- _aggregators[name].load_state_dict(agg_state)
-
-
-def xla_metrics_report():
- try:
- import torch_xla.debug.metrics as met
- print(met.metrics_report())
- except ImportError:
- return
diff --git a/spaces/OFA-Sys/OFA-vqa/fairseq/fairseq/optim/shard.py b/spaces/OFA-Sys/OFA-vqa/fairseq/fairseq/optim/shard.py
deleted file mode 100644
index 9d7f2eb9e5de6086fe2435d432bde7521ebb8155..0000000000000000000000000000000000000000
--- a/spaces/OFA-Sys/OFA-vqa/fairseq/fairseq/optim/shard.py
+++ /dev/null
@@ -1,58 +0,0 @@
-# Copyright (c) Facebook, Inc. and its affiliates.
-#
-# This source code is licensed under the MIT license found in the
-# LICENSE file in the root directory of this source tree.
-
-from typing import Any, Dict
-
-from fairseq.distributed import utils
-
-
-try:
- from fairscale.optim import OSS
-
- _has_fairscale = True
-except ImportError:
- _has_fairscale = False
-
-
-def shard_(optimizer, group):
- if not _has_fairscale:
- raise ImportError(
- "\n\nPlease install the fairscale package:" "\n\n pip install fairscale"
- )
-
- class FairseqOSS(OSS):
- @property
- def disable_mem_eff_fp16_loading_hack(self):
- return True
-
- def __getattr__(self, name):
- if name.startswith("supports") and hasattr(self.optim, name):
- return getattr(self.optim, name)
- raise AttributeError(
- "'FairseqOSS' object has no attribute {0!r}".format(name)
- )
-
- def broadcast_global_state_dict(
- self, state_dict: Dict[str, Any]
- ) -> Dict[str, Any]:
- """
- Broadcasts the entire state_dict to all other ranks
- each rank is responsible to load their own partition of data
- """
- return utils.broadcast_object(
- state_dict,
- src_rank=0,
- group=self.group,
- )
-
- torch_optimizer = optimizer.optimizer
- optim_cls = type(torch_optimizer)
-
- optimizer.optimizer = FairseqOSS(
- torch_optimizer.param_groups,
- optim_cls,
- group=group,
- **optimizer.optimizer_config
- )
diff --git a/spaces/OptimalScale/Robin-7b/lmflow/utils/data_utils.py b/spaces/OptimalScale/Robin-7b/lmflow/utils/data_utils.py
deleted file mode 100644
index 25ff71ef3d5e953e7dd26fb595e5b35a3b0a273e..0000000000000000000000000000000000000000
--- a/spaces/OptimalScale/Robin-7b/lmflow/utils/data_utils.py
+++ /dev/null
@@ -1,212 +0,0 @@
-"""The program includes several functions: setting a random seed,
-loading data from a JSON file, batching data, and extracting answers from generated text.
-"""
-
-import random
-import numpy as np
-import torch
-import json
-import re
-def set_random_seed(seed: int):
- """
- Set the random seed for `random`, `numpy`, `torch`, `torch.cuda`.
-
- Parameters
- ------------
- seed : int
- The default seed.
-
- """
- random.seed(seed)
- np.random.seed(seed)
- torch.manual_seed(seed)
- if torch.cuda.is_available():
- torch.cuda.manual_seed_all(seed)
-
-def load_data(file_name: str):
- """
- Load data with file name.
-
- Parameters
- ------------
- file_name : str.
- The dataset file name.
-
- Returns
- ------------
- inputs : list.
- The input texts of the dataset.
- outputs : list.
- The output texts file datasets.
- len : int.
- The length of the dataset.
- """
- inputs = []
- outputs = []
- type = ""
- with open(file_name, encoding='utf-8') as f:
- json_data = json.load(f)
- type = json_data["type"]
- for line in json_data["instances"]:
- inputs.append(line["input"])
- outputs.append(line["output"])
-
- print(f"load dataset {file_name} success.\n")
- print(f"Type : {type}, datasize : {len(outputs)}")
-
- return inputs, outputs, len(outputs)
-
-def batchlize(examples: list, batch_size: int, random_shuffle: bool):
- """
- Convert examples to a dataloader.
-
- Parameters
- ------------
- examples : list.
- Data list.
- batch_size : int.
-
- random_shuffle : bool
- If true, the dataloader shuffle the training data.
-
- Returns
- ------------
- dataloader:
- Dataloader with batch generator.
- """
- size = 0
- dataloader = []
- length = len(examples)
- if (random_shuffle):
- random.shuffle(examples)
- while size < length:
- if length - size > batch_size:
- dataloader.append(examples[size : size+batch_size])
- size += batch_size
- else:
- dataloader.append(examples[size : size+(length-size)])
- size += (length - size)
- return dataloader
-
-
-
-def answer_extraction(response, answer_type=None): #use this funtion to extract answers from generated text
-
- """
- Use this funtion to extract answers from generated text
-
- Parameters
- ------------
- args :
- Arguments.
- response : str
- plain string response.
-
-
- Returns
- ------------
- answer:
- Decoded answer (such as A, B, C, D, E for mutiple-choice QA).
- """
-
- # temp = response["generated_text"]
- temp = response
- if answer_type in ("gsm8k", "svamp", "asdiv", "addsub", "singleeq", "multiarith", "math"):
- temp = temp.replace(",", "")
- temp = [s for s in re.findall(r'-?\d+\.?\d*', temp)]
- elif answer_type in ("aqua", "csqa", "multiple_choice"):
- temp = re.findall(r'A|B|C|D|E', temp)
- elif answer_type in ("strategyqa", "coin_flip"):
- temp = temp.lower()
- temp = re.sub("\"|\'|\n|\.|\s|\:|\,"," ", temp)
- temp = temp.split(" ")
- temp = [i for i in temp if i in ("yes", "no")]
- elif answer_type in ("last_letters"):
- temp = re.sub("\"|\'|\n|\.|\s","", temp)
- temp = [temp]
- elif answer_type in ("pubmedqa", "binary_choice"):
- # pattern = "Output: (yes|no|maybe)"
- # sttr = re.search(pattern, temp)
- # answer = sttr.group(0)[8:] if sttr is not None else "N/A"
- pattern = "(answer|Answer|ANSWER|output|Output|OUTPUT|A): \(*(yes|Yes|YES|no|No|NO|maybe|Maybe|MAYBE)"
- sttr = re.search(pattern, temp)
- if sttr is not None:
- mid_answer = sttr.group(0)
- mid_answer = mid_answer.split(":")[-1].strip()
- answer = mid_answer.lower()
- else:
- pattern = "(yes|Yes|YES|no|No|NO|maybe|Maybe|MAYBE)(\.|\s)"
- sttr = re.search(pattern, temp)
- if sttr is not None:
- answer = sttr.group(0)[:-1].lower()
- else:
- answer = "N/A"
- return answer
- elif answer_type == "medmcqa":
- # pattern = "Output: (A|B|C|D)."
- # sttr = re.search(pattern, temp)
- # answer = sttr.group(0)[8:-1].lower() if sttr is not None else "N/A"
- pattern = "(answer|Answer|ANSWER|output|Output|OUTPUT|A): \(*(A|B|C|D|a|b|c|d)"
- sttr = re.search(pattern, temp)
- if sttr is not None:
- mid_answer = sttr.group(0)
- answer = mid_answer[-1].lower()
- else:
- pattern = "\(*(A|B|C|D|a|b|c|d)\)*(\.|\s)"
- sttr = re.search(pattern, temp)
- if sttr is not None:
- if '(' in sttr.group(0):
- answer = sttr.group(0)[1].lower()
- else:
- answer = sttr.group(0)[0].lower()
- else:
- answer = "N/A"
- return answer
-
- elif answer_type == "usmle":
- # pattern = "Output: (A|B|C|D)."
- # sttr = re.search(pattern, temp)
- # answer = sttr.group(0)[8:-1].lower() if sttr is not None else "N/A"
- pattern = "(Answer|Output|A): \(*(A|B|C|D|a|b|c|d)"
- sttr = re.search(pattern, temp)
- if sttr is not None:
- mid_answer = sttr.group(0)
- answer = mid_answer[-1].lower()
- else:
- pattern = "\(*(A|B|C|D|a|b|c|d)\)*(\.|\s)"
- sttr = re.search(pattern, temp)
- if sttr is not None:
- if '(' in sttr.group(0):
- answer = sttr.group(0)[1].lower()
- else:
- answer = sttr.group(0)[0].lower()
- else:
- answer = "N/A"
- return answer
- elif answer_type == "text":
- return response
- else:
- raise NotImplementedError(f"Unsupported answer type: {answer_type}")
-
- if len(temp) != 0:
- answer = temp[-1]
- # if there is . at the end of answer, remove it
- # e.g. answer = 64.
- if answer != "":
- if answer[-1] == ".":
- answer = answer[:-1]
-
- # round the answer to nearest integer
- if answer_type in ("gsm8k", "svamp"):
- try:
- answer = str(round(float(answer)))
- except:
- answer = "" # no sol or sol doesn't have valid format
- elif answer_type in ("last_letters"):
- try:
- answer = answer[-args.concat_length:]
- except:
- answer = ""
- else:
- answer = ""
- return answer
diff --git a/spaces/OptimalScale/Robin-7b/lmflow/version.py b/spaces/OptimalScale/Robin-7b/lmflow/version.py
deleted file mode 100644
index b3c06d488393abb3b3829e5590d42409c995b4cf..0000000000000000000000000000000000000000
--- a/spaces/OptimalScale/Robin-7b/lmflow/version.py
+++ /dev/null
@@ -1 +0,0 @@
-__version__ = "0.0.1"
\ No newline at end of file
diff --git a/spaces/OptorAI/site/index.html b/spaces/OptorAI/site/index.html
deleted file mode 100644
index d2eb5b58bf79f513862e21db3f47594b1b35124a..0000000000000000000000000000000000000000
--- a/spaces/OptorAI/site/index.html
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
- OPTOR.redirect
-
-
-
-
-OPTOR.redirect to our site
-Redirecting in 2 seconds...
-
\ No newline at end of file
diff --git a/spaces/Osborn-bh/ChatGLM3-6B-Osborn/openai_api.py b/spaces/Osborn-bh/ChatGLM3-6B-Osborn/openai_api.py
deleted file mode 100644
index 7d372dc9cd1e085a04f9d94c25302e0843078338..0000000000000000000000000000000000000000
--- a/spaces/Osborn-bh/ChatGLM3-6B-Osborn/openai_api.py
+++ /dev/null
@@ -1,229 +0,0 @@
-# coding=utf-8
-# Implements API for ChatGLM3-6B in OpenAI's format. (https://platform.openai.com/docs/api-reference/chat)
-# Usage: python openai_api.py
-# Visit http://localhost:8000/docs for documents.
-
-
-import json
-import time
-from contextlib import asynccontextmanager
-from typing import List, Literal, Optional, Union
-
-import torch
-import uvicorn
-from fastapi import FastAPI, HTTPException
-from fastapi.middleware.cors import CORSMiddleware
-from pydantic import BaseModel, Field
-from sse_starlette.sse import EventSourceResponse
-from transformers import AutoTokenizer, AutoModel
-
-from utils import process_response, generate_chatglm3, generate_stream_chatglm3
-
-
-@asynccontextmanager
-async def lifespan(app: FastAPI): # collects GPU memory
- yield
- if torch.cuda.is_available():
- torch.cuda.empty_cache()
- torch.cuda.ipc_collect()
-
-
-app = FastAPI(lifespan=lifespan)
-
-app.add_middleware(
- CORSMiddleware,
- allow_origins=["*"],
- allow_credentials=True,
- allow_methods=["*"],
- allow_headers=["*"],
-)
-
-
-class ModelCard(BaseModel):
- id: str
- object: str = "model"
- created: int = Field(default_factory=lambda: int(time.time()))
- owned_by: str = "owner"
- root: Optional[str] = None
- parent: Optional[str] = None
- permission: Optional[list] = None
-
-
-class ModelList(BaseModel):
- object: str = "list"
- data: List[ModelCard] = []
-
-
-class ChatMessage(BaseModel):
- role: Literal["user", "assistant", "system", "observation"]
- content: str = None
- metadata: Optional[str] = None
- tools: Optional[List[dict]] = None
-
-
-class DeltaMessage(BaseModel):
- role: Optional[Literal["user", "assistant", "system"]] = None
- content: Optional[str] = None
-
-
-class ChatCompletionRequest(BaseModel):
- model: str
- messages: List[ChatMessage]
- temperature: Optional[float] = 0.7
- top_p: Optional[float] = 1.0
- max_tokens: Optional[int] = None
- stop: Optional[Union[str, List[str]]] = None
- stream: Optional[bool] = False
-
- # Additional parameters support for stop generation
- stop_token_ids: Optional[List[int]] = None
- repetition_penalty: Optional[float] = 1.1
-
- # Additional parameters supported by tools
- return_function_call: Optional[bool] = False
-
-
-class ChatCompletionResponseChoice(BaseModel):
- index: int
- message: ChatMessage
- finish_reason: Literal["stop", "length", "function_call"]
- history: Optional[List[dict]] = None
-
-
-class ChatCompletionResponseStreamChoice(BaseModel):
- index: int
- delta: DeltaMessage
- finish_reason: Optional[Literal["stop", "length"]]
-
-
-class UsageInfo(BaseModel):
- prompt_tokens: int = 0
- total_tokens: int = 0
- completion_tokens: Optional[int] = 0
-
-
-class ChatCompletionResponse(BaseModel):
- model: str
- object: Literal["chat.completion", "chat.completion.chunk"]
- choices: List[Union[ChatCompletionResponseChoice, ChatCompletionResponseStreamChoice]]
- created: Optional[int] = Field(default_factory=lambda: int(time.time()))
- usage: Optional[UsageInfo] = None
-
-
-@app.get("/v1/models", response_model=ModelList)
-async def list_models():
- model_card = ModelCard(id="gpt-3.5-turbo")
- return ModelList(data=[model_card])
-
-
-@app.post("/v1/chat/completions", response_model=ChatCompletionResponse)
-async def create_chat_completion(request: ChatCompletionRequest):
- global model, tokenizer
-
- if request.messages[-1].role == "assistant":
- raise HTTPException(status_code=400, detail="Invalid request")
-
- with_function_call = bool(request.messages[0].role == "system" and request.messages[0].tools is not None)
-
- # stop settings
- request.stop = request.stop or []
- if isinstance(request.stop, str):
- request.stop = [request.stop]
-
- request.stop_token_ids = request.stop_token_ids or []
-
- gen_params = dict(
- messages=request.messages,
- temperature=request.temperature,
- top_p=request.top_p,
- max_tokens=request.max_tokens or 1024,
- echo=False,
- stream=request.stream,
- stop_token_ids=request.stop_token_ids,
- stop=request.stop,
- repetition_penalty=request.repetition_penalty,
- with_function_call=with_function_call,
- )
-
- if request.stream:
- generate = predict(request.model, gen_params)
- return EventSourceResponse(generate, media_type="text/event-stream")
-
- response = generate_chatglm3(model, tokenizer, gen_params)
- usage = UsageInfo()
-
- finish_reason, history = "stop", None
- if with_function_call and request.return_function_call:
- history = [m.dict(exclude_none=True) for m in request.messages]
- content, history = process_response(response["text"], history)
- if isinstance(content, dict):
- message, finish_reason = ChatMessage(
- role="assistant",
- content=json.dumps(content, ensure_ascii=False),
- ), "function_call"
- else:
- message = ChatMessage(role="assistant", content=content)
- else:
- message = ChatMessage(role="assistant", content=response["text"])
-
- choice_data = ChatCompletionResponseChoice(
- index=0,
- message=message,
- finish_reason=finish_reason,
- history=history
- )
-
- task_usage = UsageInfo.parse_obj(response["usage"])
- for usage_key, usage_value in task_usage.dict().items():
- setattr(usage, usage_key, getattr(usage, usage_key) + usage_value)
-
- return ChatCompletionResponse(model=request.model, choices=[choice_data], object="chat.completion", usage=usage)
-
-
-async def predict(model_id: str, params: dict):
- global model, tokenizer
-
- choice_data = ChatCompletionResponseStreamChoice(
- index=0,
- delta=DeltaMessage(role="assistant"),
- finish_reason=None
- )
- chunk = ChatCompletionResponse(model=model_id, choices=[choice_data], object="chat.completion.chunk")
- yield "{}".format(chunk.json(exclude_unset=True, ensure_ascii=False))
-
- previous_text = ""
- for new_response in generate_stream_chatglm3(model, tokenizer, params):
- decoded_unicode = new_response["text"]
- delta_text = decoded_unicode[len(previous_text):]
- previous_text = decoded_unicode
-
- if len(delta_text) == 0:
- delta_text = None
-
- choice_data = ChatCompletionResponseStreamChoice(
- index=0,
- delta=DeltaMessage(content=delta_text),
- finish_reason=None
- )
- chunk = ChatCompletionResponse(model=model_id, choices=[choice_data], object="chat.completion.chunk")
- yield "{}".format(chunk.json(exclude_unset=True, ensure_ascii=False))
-
- choice_data = ChatCompletionResponseStreamChoice(
- index=0,
- delta=DeltaMessage(),
- finish_reason="stop"
- )
- chunk = ChatCompletionResponse(model=model_id, choices=[choice_data], object="chat.completion.chunk")
- yield "{}".format(chunk.json(exclude_unset=True, ensure_ascii=False))
- yield '[DONE]'
-
-
-if __name__ == "__main__":
- tokenizer = AutoTokenizer.from_pretrained("THUDM/chatglm3-6b", trust_remote_code=True)
- model = AutoModel.from_pretrained("THUDM/chatglm3-6b", trust_remote_code=True).cuda()
- # 多显卡支持,使用下面两行代替上面一行,将num_gpus改为你实际的显卡数量
- # from utils import load_model_on_gpus
- # model = load_model_on_gpus("THUDM/chatglm3-6b", num_gpus=2)
- model = model.eval()
-
- uvicorn.run(app, host='0.0.0.0', port=8000, workers=1)
diff --git a/spaces/PAIR/Text2Video-Zero/annotator/uniformer/configs/_base_/models/upernet_r50.py b/spaces/PAIR/Text2Video-Zero/annotator/uniformer/configs/_base_/models/upernet_r50.py
deleted file mode 100644
index 10974962fdd7136031fd06de1700f497d355ceaa..0000000000000000000000000000000000000000
--- a/spaces/PAIR/Text2Video-Zero/annotator/uniformer/configs/_base_/models/upernet_r50.py
+++ /dev/null
@@ -1,44 +0,0 @@
-# model settings
-norm_cfg = dict(type='SyncBN', requires_grad=True)
-model = dict(
- type='EncoderDecoder',
- pretrained='open-mmlab://resnet50_v1c',
- backbone=dict(
- type='ResNetV1c',
- depth=50,
- num_stages=4,
- out_indices=(0, 1, 2, 3),
- dilations=(1, 1, 1, 1),
- strides=(1, 2, 2, 2),
- norm_cfg=norm_cfg,
- norm_eval=False,
- style='pytorch',
- contract_dilation=True),
- decode_head=dict(
- type='UPerHead',
- in_channels=[256, 512, 1024, 2048],
- in_index=[0, 1, 2, 3],
- pool_scales=(1, 2, 3, 6),
- channels=512,
- dropout_ratio=0.1,
- num_classes=19,
- norm_cfg=norm_cfg,
- align_corners=False,
- loss_decode=dict(
- type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)),
- auxiliary_head=dict(
- type='FCNHead',
- in_channels=1024,
- in_index=2,
- channels=256,
- num_convs=1,
- concat_input=False,
- dropout_ratio=0.1,
- num_classes=19,
- norm_cfg=norm_cfg,
- align_corners=False,
- loss_decode=dict(
- type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)),
- # model training and testing settings
- train_cfg=dict(),
- test_cfg=dict(mode='whole'))
diff --git a/spaces/PAIR/Text2Video-Zero/annotator/uniformer/mmcv/cnn/bricks/drop.py b/spaces/PAIR/Text2Video-Zero/annotator/uniformer/mmcv/cnn/bricks/drop.py
deleted file mode 100644
index b7b4fccd457a0d51fb10c789df3c8537fe7b67c1..0000000000000000000000000000000000000000
--- a/spaces/PAIR/Text2Video-Zero/annotator/uniformer/mmcv/cnn/bricks/drop.py
+++ /dev/null
@@ -1,65 +0,0 @@
-# Copyright (c) OpenMMLab. All rights reserved.
-import torch
-import torch.nn as nn
-
-from annotator.uniformer.mmcv import build_from_cfg
-from .registry import DROPOUT_LAYERS
-
-
-def drop_path(x, drop_prob=0., training=False):
- """Drop paths (Stochastic Depth) per sample (when applied in main path of
- residual blocks).
-
- We follow the implementation
- https://github.com/rwightman/pytorch-image-models/blob/a2727c1bf78ba0d7b5727f5f95e37fb7f8866b1f/timm/models/layers/drop.py # noqa: E501
- """
- if drop_prob == 0. or not training:
- return x
- keep_prob = 1 - drop_prob
- # handle tensors with different dimensions, not just 4D tensors.
- shape = (x.shape[0], ) + (1, ) * (x.ndim - 1)
- random_tensor = keep_prob + torch.rand(
- shape, dtype=x.dtype, device=x.device)
- output = x.div(keep_prob) * random_tensor.floor()
- return output
-
-
-@DROPOUT_LAYERS.register_module()
-class DropPath(nn.Module):
- """Drop paths (Stochastic Depth) per sample (when applied in main path of
- residual blocks).
-
- We follow the implementation
- https://github.com/rwightman/pytorch-image-models/blob/a2727c1bf78ba0d7b5727f5f95e37fb7f8866b1f/timm/models/layers/drop.py # noqa: E501
-
- Args:
- drop_prob (float): Probability of the path to be zeroed. Default: 0.1
- """
-
- def __init__(self, drop_prob=0.1):
- super(DropPath, self).__init__()
- self.drop_prob = drop_prob
-
- def forward(self, x):
- return drop_path(x, self.drop_prob, self.training)
-
-
-@DROPOUT_LAYERS.register_module()
-class Dropout(nn.Dropout):
- """A wrapper for ``torch.nn.Dropout``, We rename the ``p`` of
- ``torch.nn.Dropout`` to ``drop_prob`` so as to be consistent with
- ``DropPath``
-
- Args:
- drop_prob (float): Probability of the elements to be
- zeroed. Default: 0.5.
- inplace (bool): Do the operation inplace or not. Default: False.
- """
-
- def __init__(self, drop_prob=0.5, inplace=False):
- super().__init__(p=drop_prob, inplace=inplace)
-
-
-def build_dropout(cfg, default_args=None):
- """Builder for drop out layers."""
- return build_from_cfg(cfg, DROPOUT_LAYERS, default_args)
diff --git a/spaces/PKaushik/humandetect/yolov6/utils/nms.py b/spaces/PKaushik/humandetect/yolov6/utils/nms.py
deleted file mode 100644
index 9c61b7cc4567b03cd2977b505b89c76e0e1d6769..0000000000000000000000000000000000000000
--- a/spaces/PKaushik/humandetect/yolov6/utils/nms.py
+++ /dev/null
@@ -1,106 +0,0 @@
-#!/usr/bin/env python3
-# -*- coding:utf-8 -*-
-# The code is based on
-# https://github.com/ultralytics/yolov5/blob/master/utils/general.py
-
-import os
-import time
-import numpy as np
-import cv2
-import torch
-import torchvision
-
-
-# Settings
-torch.set_printoptions(linewidth=320, precision=5, profile='long')
-np.set_printoptions(linewidth=320, formatter={'float_kind': '{:11.5g}'.format}) # format short g, %precision=5
-cv2.setNumThreads(0) # prevent OpenCV from multithreading (incompatible with PyTorch DataLoader)
-os.environ['NUMEXPR_MAX_THREADS'] = str(min(os.cpu_count(), 8)) # NumExpr max threads
-
-
-def xywh2xyxy(x):
- # Convert boxes with shape [n, 4] from [x, y, w, h] to [x1, y1, x2, y2] where x1y1 is top-left, x2y2=bottom-right
- y = x.clone() if isinstance(x, torch.Tensor) else np.copy(x)
- y[:, 0] = x[:, 0] - x[:, 2] / 2 # top left x
- y[:, 1] = x[:, 1] - x[:, 3] / 2 # top left y
- y[:, 2] = x[:, 0] + x[:, 2] / 2 # bottom right x
- y[:, 3] = x[:, 1] + x[:, 3] / 2 # bottom right y
- return y
-
-
-def non_max_suppression(prediction, conf_thres=0.25, iou_thres=0.45, classes=None, agnostic=False, multi_label=False, max_det=300):
- """Runs Non-Maximum Suppression (NMS) on inference results.
- This code is borrowed from: https://github.com/ultralytics/yolov5/blob/47233e1698b89fc437a4fb9463c815e9171be955/utils/general.py#L775
- Args:
- prediction: (tensor), with shape [N, 5 + num_classes], N is the number of bboxes.
- conf_thres: (float) confidence threshold.
- iou_thres: (float) iou threshold.
- classes: (None or list[int]), if a list is provided, nms only keep the classes you provide.
- agnostic: (bool), when it is set to True, we do class-independent nms, otherwise, different class would do nms respectively.
- multi_label: (bool), when it is set to True, one box can have multi labels, otherwise, one box only huave one label.
- max_det:(int), max number of output bboxes.
-
- Returns:
- list of detections, echo item is one tensor with shape (num_boxes, 6), 6 is for [xyxy, conf, cls].
- """
-
- num_classes = prediction.shape[2] - 5 # number of classes
- pred_candidates = prediction[..., 4] > conf_thres # candidates
-
- # Check the parameters.
- assert 0 <= conf_thres <= 1, f'conf_thresh must be in 0.0 to 1.0, however {conf_thres} is provided.'
- assert 0 <= iou_thres <= 1, f'iou_thres must be in 0.0 to 1.0, however {iou_thres} is provided.'
-
- # Function settings.
- max_wh = 4096 # maximum box width and height
- max_nms = 30000 # maximum number of boxes put into torchvision.ops.nms()
- time_limit = 10.0 # quit the function when nms cost time exceed the limit time.
- multi_label &= num_classes > 1 # multiple labels per box
-
- tik = time.time()
- output = [torch.zeros((0, 6), device=prediction.device)] * prediction.shape[0]
- for img_idx, x in enumerate(prediction): # image index, image inference
- x = x[pred_candidates[img_idx]] # confidence
-
- # If no box remains, skip the next process.
- if not x.shape[0]:
- continue
-
- # confidence multiply the objectness
- x[:, 5:] *= x[:, 4:5] # conf = obj_conf * cls_conf
-
- # (center x, center y, width, height) to (x1, y1, x2, y2)
- box = xywh2xyxy(x[:, :4])
-
- # Detections matrix's shape is (n,6), each row represents (xyxy, conf, cls)
- if multi_label:
- box_idx, class_idx = (x[:, 5:] > conf_thres).nonzero(as_tuple=False).T
- x = torch.cat((box[box_idx], x[box_idx, class_idx + 5, None], class_idx[:, None].float()), 1)
- else: # Only keep the class with highest scores.
- conf, class_idx = x[:, 5:].max(1, keepdim=True)
- x = torch.cat((box, conf, class_idx.float()), 1)[conf.view(-1) > conf_thres]
-
- # Filter by class, only keep boxes whose category is in classes.
- if classes is not None:
- x = x[(x[:, 5:6] == torch.tensor(classes, device=x.device)).any(1)]
-
- # Check shape
- num_box = x.shape[0] # number of boxes
- if not num_box: # no boxes kept.
- continue
- elif num_box > max_nms: # excess max boxes' number.
- x = x[x[:, 4].argsort(descending=True)[:max_nms]] # sort by confidence
-
- # Batched NMS
- class_offset = x[:, 5:6] * (0 if agnostic else max_wh) # classes
- boxes, scores = x[:, :4] + class_offset, x[:, 4] # boxes (offset by class), scores
- keep_box_idx = torchvision.ops.nms(boxes, scores, iou_thres) # NMS
- if keep_box_idx.shape[0] > max_det: # limit detections
- keep_box_idx = keep_box_idx[:max_det]
-
- output[img_idx] = x[keep_box_idx]
- if (time.time() - tik) > time_limit:
- print(f'WARNING: NMS cost time exceed the limited {time_limit}s.')
- break # time limit exceeded
-
- return output
diff --git a/spaces/PaddlePaddle/PaddleOCR/app.py b/spaces/PaddlePaddle/PaddleOCR/app.py
deleted file mode 100644
index eb8e5c2628f259ae9917a4c2bd70c119474aa081..0000000000000000000000000000000000000000
--- a/spaces/PaddlePaddle/PaddleOCR/app.py
+++ /dev/null
@@ -1,40 +0,0 @@
-import os
-os.system('pip install paddlepaddle')
-os.system('pip install paddleocr')
-from paddleocr import PaddleOCR, draw_ocr
-from PIL import Image
-import gradio as gr
-import torch
-
-torch.hub.download_url_to_file('https://i.imgur.com/aqMBT0i.jpg', 'example.jpg')
-
-def inference(img, lang):
- ocr = PaddleOCR(use_angle_cls=True, lang=lang,use_gpu=False)
- img_path = img.name
- result = ocr.ocr(img_path, cls=True)[0]
- image = Image.open(img_path).convert('RGB')
- boxes = [line[0] for line in result]
- txts = [line[1][0] for line in result]
- scores = [line[1][1] for line in result]
- im_show = draw_ocr(image, boxes, txts, scores,
- font_path='simfang.ttf')
- im_show = Image.fromarray(im_show)
- im_show.save('result.jpg')
- return 'result.jpg'
-
-title = 'PaddleOCR'
-description = 'Gradio demo for PaddleOCR. PaddleOCR demo supports Chinese, English, French, German, Korean and Japanese. To use it, simply upload your image and choose a language from the dropdown menu, or click one of the examples to load them. Read more at the links below.'
-article = "Awesome multilingual OCR toolkits based on PaddlePaddle (practical ultra lightweight OCR system, support 80+ languages recognition, provide data annotation and synthesis tools, support training and deployment among server, mobile, embedded and IoT devices) | Github Repo
"
-examples = [['example.jpg','en']]
-css = ".output_image, .input_image {height: 40rem !important; width: 100% !important;}"
-gr.Interface(
- inference,
- [gr.inputs.Image(type='file', label='Input'),gr.inputs.Dropdown(choices=['ch', 'en', 'fr', 'german', 'korean', 'japan'], type="value", default='en', label='language')],
- gr.outputs.Image(type='file', label='Output'),
- title=title,
- description=description,
- article=article,
- examples=examples,
- css=css,
- enable_queue=True
- ).launch(debug=True)
\ No newline at end of file
diff --git a/spaces/ParityError/Interstellar/README.md b/spaces/ParityError/Interstellar/README.md
deleted file mode 100644
index e471b5ce80e3b1119e42fbd94ce2359e4ed96add..0000000000000000000000000000000000000000
--- a/spaces/ParityError/Interstellar/README.md
+++ /dev/null
@@ -1,17 +0,0 @@
----
-tags: [gradio-theme, track-1, track-4, minimalist-theme, custom-gradio-theme]
-title: Interstellar
-colorFrom: orange
-colorTo: purple
-sdk: gradio
-sdk_version: 3.24.1
-app_file: app.py
-pinned: false
-license: apache-2.0
-emoji: 🚀
----
-# Interstellar
-## Description
-A clean dark purple and violet theme that is out of this world!
-## Contributions
-Thanks to [@ParityError](https://huggingface.co/ParityError) for adding this gradio theme!
\ No newline at end of file
diff --git a/spaces/Pie31415/control-animation/annotator/uniformer/mmcv/utils/timer.py b/spaces/Pie31415/control-animation/annotator/uniformer/mmcv/utils/timer.py
deleted file mode 100644
index e3db7d497d8b374e18b5297e0a1d6eb186fd8cba..0000000000000000000000000000000000000000
--- a/spaces/Pie31415/control-animation/annotator/uniformer/mmcv/utils/timer.py
+++ /dev/null
@@ -1,118 +0,0 @@
-# Copyright (c) OpenMMLab. All rights reserved.
-from time import time
-
-
-class TimerError(Exception):
-
- def __init__(self, message):
- self.message = message
- super(TimerError, self).__init__(message)
-
-
-class Timer:
- """A flexible Timer class.
-
- :Example:
-
- >>> import time
- >>> import annotator.uniformer.mmcv as mmcv
- >>> with mmcv.Timer():
- >>> # simulate a code block that will run for 1s
- >>> time.sleep(1)
- 1.000
- >>> with mmcv.Timer(print_tmpl='it takes {:.1f} seconds'):
- >>> # simulate a code block that will run for 1s
- >>> time.sleep(1)
- it takes 1.0 seconds
- >>> timer = mmcv.Timer()
- >>> time.sleep(0.5)
- >>> print(timer.since_start())
- 0.500
- >>> time.sleep(0.5)
- >>> print(timer.since_last_check())
- 0.500
- >>> print(timer.since_start())
- 1.000
- """
-
- def __init__(self, start=True, print_tmpl=None):
- self._is_running = False
- self.print_tmpl = print_tmpl if print_tmpl else '{:.3f}'
- if start:
- self.start()
-
- @property
- def is_running(self):
- """bool: indicate whether the timer is running"""
- return self._is_running
-
- def __enter__(self):
- self.start()
- return self
-
- def __exit__(self, type, value, traceback):
- print(self.print_tmpl.format(self.since_last_check()))
- self._is_running = False
-
- def start(self):
- """Start the timer."""
- if not self._is_running:
- self._t_start = time()
- self._is_running = True
- self._t_last = time()
-
- def since_start(self):
- """Total time since the timer is started.
-
- Returns (float): Time in seconds.
- """
- if not self._is_running:
- raise TimerError('timer is not running')
- self._t_last = time()
- return self._t_last - self._t_start
-
- def since_last_check(self):
- """Time since the last checking.
-
- Either :func:`since_start` or :func:`since_last_check` is a checking
- operation.
-
- Returns (float): Time in seconds.
- """
- if not self._is_running:
- raise TimerError('timer is not running')
- dur = time() - self._t_last
- self._t_last = time()
- return dur
-
-
-_g_timers = {} # global timers
-
-
-def check_time(timer_id):
- """Add check points in a single line.
-
- This method is suitable for running a task on a list of items. A timer will
- be registered when the method is called for the first time.
-
- :Example:
-
- >>> import time
- >>> import annotator.uniformer.mmcv as mmcv
- >>> for i in range(1, 6):
- >>> # simulate a code block
- >>> time.sleep(i)
- >>> mmcv.check_time('task1')
- 2.000
- 3.000
- 4.000
- 5.000
-
- Args:
- timer_id (str): Timer identifier.
- """
- if timer_id not in _g_timers:
- _g_timers[timer_id] = Timer()
- return 0
- else:
- return _g_timers[timer_id].since_last_check()
diff --git a/spaces/Plachta/VITS-Umamusume-voice-synthesizer/monotonic_align/core.c b/spaces/Plachta/VITS-Umamusume-voice-synthesizer/monotonic_align/core.c
deleted file mode 100644
index 5631d20a9a00db29e143a6e8e4e5c378d6bb850a..0000000000000000000000000000000000000000
--- a/spaces/Plachta/VITS-Umamusume-voice-synthesizer/monotonic_align/core.c
+++ /dev/null
@@ -1,21299 +0,0 @@
-/* Generated by Cython 0.29.21 */
-
-/* BEGIN: Cython Metadata
-{
- "distutils": {
- "name": "monotonic_align.core",
- "sources": [
- "core.pyx"
- ]
- },
- "module_name": "monotonic_align.core"
-}
-END: Cython Metadata */
-
-#define PY_SSIZE_T_CLEAN
-#include "Python.h"
-#ifndef Py_PYTHON_H
- #error Python headers needed to compile C extensions, please install development version of Python.
-#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
- #error Cython requires Python 2.6+ or Python 3.3+.
-#else
-#define CYTHON_ABI "0_29_21"
-#define CYTHON_HEX_VERSION 0x001D15F0
-#define CYTHON_FUTURE_DIVISION 0
-#include
-#ifndef offsetof
- #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
-#endif
-#if !defined(WIN32) && !defined(MS_WINDOWS)
- #ifndef __stdcall
- #define __stdcall
- #endif
- #ifndef __cdecl
- #define __cdecl
- #endif
- #ifndef __fastcall
- #define __fastcall
- #endif
-#endif
-#ifndef DL_IMPORT
- #define DL_IMPORT(t) t
-#endif
-#ifndef DL_EXPORT
- #define DL_EXPORT(t) t
-#endif
-#define __PYX_COMMA ,
-#ifndef HAVE_LONG_LONG
- #if PY_VERSION_HEX >= 0x02070000
- #define HAVE_LONG_LONG
- #endif
-#endif
-#ifndef PY_LONG_LONG
- #define PY_LONG_LONG LONG_LONG
-#endif
-#ifndef Py_HUGE_VAL
- #define Py_HUGE_VAL HUGE_VAL
-#endif
-#ifdef PYPY_VERSION
- #define CYTHON_COMPILING_IN_PYPY 1
- #define CYTHON_COMPILING_IN_PYSTON 0
- #define CYTHON_COMPILING_IN_CPYTHON 0
- #undef CYTHON_USE_TYPE_SLOTS
- #define CYTHON_USE_TYPE_SLOTS 0
- #undef CYTHON_USE_PYTYPE_LOOKUP
- #define CYTHON_USE_PYTYPE_LOOKUP 0
- #if PY_VERSION_HEX < 0x03050000
- #undef CYTHON_USE_ASYNC_SLOTS
- #define CYTHON_USE_ASYNC_SLOTS 0
- #elif !defined(CYTHON_USE_ASYNC_SLOTS)
- #define CYTHON_USE_ASYNC_SLOTS 1
- #endif
- #undef CYTHON_USE_PYLIST_INTERNALS
- #define CYTHON_USE_PYLIST_INTERNALS 0
- #undef CYTHON_USE_UNICODE_INTERNALS
- #define CYTHON_USE_UNICODE_INTERNALS 0
- #undef CYTHON_USE_UNICODE_WRITER
- #define CYTHON_USE_UNICODE_WRITER 0
- #undef CYTHON_USE_PYLONG_INTERNALS
- #define CYTHON_USE_PYLONG_INTERNALS 0
- #undef CYTHON_AVOID_BORROWED_REFS
- #define CYTHON_AVOID_BORROWED_REFS 1
- #undef CYTHON_ASSUME_SAFE_MACROS
- #define CYTHON_ASSUME_SAFE_MACROS 0
- #undef CYTHON_UNPACK_METHODS
- #define CYTHON_UNPACK_METHODS 0
- #undef CYTHON_FAST_THREAD_STATE
- #define CYTHON_FAST_THREAD_STATE 0
- #undef CYTHON_FAST_PYCALL
- #define CYTHON_FAST_PYCALL 0
- #undef CYTHON_PEP489_MULTI_PHASE_INIT
- #define CYTHON_PEP489_MULTI_PHASE_INIT 0
- #undef CYTHON_USE_TP_FINALIZE
- #define CYTHON_USE_TP_FINALIZE 0
- #undef CYTHON_USE_DICT_VERSIONS
- #define CYTHON_USE_DICT_VERSIONS 0
- #undef CYTHON_USE_EXC_INFO_STACK
- #define CYTHON_USE_EXC_INFO_STACK 0
-#elif defined(PYSTON_VERSION)
- #define CYTHON_COMPILING_IN_PYPY 0
- #define CYTHON_COMPILING_IN_PYSTON 1
- #define CYTHON_COMPILING_IN_CPYTHON 0
- #ifndef CYTHON_USE_TYPE_SLOTS
- #define CYTHON_USE_TYPE_SLOTS 1
- #endif
- #undef CYTHON_USE_PYTYPE_LOOKUP
- #define CYTHON_USE_PYTYPE_LOOKUP 0
- #undef CYTHON_USE_ASYNC_SLOTS
- #define CYTHON_USE_ASYNC_SLOTS 0
- #undef CYTHON_USE_PYLIST_INTERNALS
- #define CYTHON_USE_PYLIST_INTERNALS 0
- #ifndef CYTHON_USE_UNICODE_INTERNALS
- #define CYTHON_USE_UNICODE_INTERNALS 1
- #endif
- #undef CYTHON_USE_UNICODE_WRITER
- #define CYTHON_USE_UNICODE_WRITER 0
- #undef CYTHON_USE_PYLONG_INTERNALS
- #define CYTHON_USE_PYLONG_INTERNALS 0
- #ifndef CYTHON_AVOID_BORROWED_REFS
- #define CYTHON_AVOID_BORROWED_REFS 0
- #endif
- #ifndef CYTHON_ASSUME_SAFE_MACROS
- #define CYTHON_ASSUME_SAFE_MACROS 1
- #endif
- #ifndef CYTHON_UNPACK_METHODS
- #define CYTHON_UNPACK_METHODS 1
- #endif
- #undef CYTHON_FAST_THREAD_STATE
- #define CYTHON_FAST_THREAD_STATE 0
- #undef CYTHON_FAST_PYCALL
- #define CYTHON_FAST_PYCALL 0
- #undef CYTHON_PEP489_MULTI_PHASE_INIT
- #define CYTHON_PEP489_MULTI_PHASE_INIT 0
- #undef CYTHON_USE_TP_FINALIZE
- #define CYTHON_USE_TP_FINALIZE 0
- #undef CYTHON_USE_DICT_VERSIONS
- #define CYTHON_USE_DICT_VERSIONS 0
- #undef CYTHON_USE_EXC_INFO_STACK
- #define CYTHON_USE_EXC_INFO_STACK 0
-#else
- #define CYTHON_COMPILING_IN_PYPY 0
- #define CYTHON_COMPILING_IN_PYSTON 0
- #define CYTHON_COMPILING_IN_CPYTHON 1
- #ifndef CYTHON_USE_TYPE_SLOTS
- #define CYTHON_USE_TYPE_SLOTS 1
- #endif
- #if PY_VERSION_HEX < 0x02070000
- #undef CYTHON_USE_PYTYPE_LOOKUP
- #define CYTHON_USE_PYTYPE_LOOKUP 0
- #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
- #define CYTHON_USE_PYTYPE_LOOKUP 1
- #endif
- #if PY_MAJOR_VERSION < 3
- #undef CYTHON_USE_ASYNC_SLOTS
- #define CYTHON_USE_ASYNC_SLOTS 0
- #elif !defined(CYTHON_USE_ASYNC_SLOTS)
- #define CYTHON_USE_ASYNC_SLOTS 1
- #endif
- #if PY_VERSION_HEX < 0x02070000
- #undef CYTHON_USE_PYLONG_INTERNALS
- #define CYTHON_USE_PYLONG_INTERNALS 0
- #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
- #define CYTHON_USE_PYLONG_INTERNALS 1
- #endif
- #ifndef CYTHON_USE_PYLIST_INTERNALS
- #define CYTHON_USE_PYLIST_INTERNALS 1
- #endif
- #ifndef CYTHON_USE_UNICODE_INTERNALS
- #define CYTHON_USE_UNICODE_INTERNALS 1
- #endif
- #if PY_VERSION_HEX < 0x030300F0
- #undef CYTHON_USE_UNICODE_WRITER
- #define CYTHON_USE_UNICODE_WRITER 0
- #elif !defined(CYTHON_USE_UNICODE_WRITER)
- #define CYTHON_USE_UNICODE_WRITER 1
- #endif
- #ifndef CYTHON_AVOID_BORROWED_REFS
- #define CYTHON_AVOID_BORROWED_REFS 0
- #endif
- #ifndef CYTHON_ASSUME_SAFE_MACROS
- #define CYTHON_ASSUME_SAFE_MACROS 1
- #endif
- #ifndef CYTHON_UNPACK_METHODS
- #define CYTHON_UNPACK_METHODS 1
- #endif
- #ifndef CYTHON_FAST_THREAD_STATE
- #define CYTHON_FAST_THREAD_STATE 1
- #endif
- #ifndef CYTHON_FAST_PYCALL
- #define CYTHON_FAST_PYCALL 1
- #endif
- #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
- #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
- #endif
- #ifndef CYTHON_USE_TP_FINALIZE
- #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
- #endif
- #ifndef CYTHON_USE_DICT_VERSIONS
- #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1)
- #endif
- #ifndef CYTHON_USE_EXC_INFO_STACK
- #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3)
- #endif
-#endif
-#if !defined(CYTHON_FAST_PYCCALL)
-#define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
-#endif
-#if CYTHON_USE_PYLONG_INTERNALS
- #include "longintrepr.h"
- #undef SHIFT
- #undef BASE
- #undef MASK
- #ifdef SIZEOF_VOID_P
- enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
- #endif
-#endif
-#ifndef __has_attribute
- #define __has_attribute(x) 0
-#endif
-#ifndef __has_cpp_attribute
- #define __has_cpp_attribute(x) 0
-#endif
-#ifndef CYTHON_RESTRICT
- #if defined(__GNUC__)
- #define CYTHON_RESTRICT __restrict__
- #elif defined(_MSC_VER) && _MSC_VER >= 1400
- #define CYTHON_RESTRICT __restrict
- #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- #define CYTHON_RESTRICT restrict
- #else
- #define CYTHON_RESTRICT
- #endif
-#endif
-#ifndef CYTHON_UNUSED
-# if defined(__GNUC__)
-# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
-# define CYTHON_UNUSED __attribute__ ((__unused__))
-# else
-# define CYTHON_UNUSED
-# endif
-# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
-# define CYTHON_UNUSED __attribute__ ((__unused__))
-# else
-# define CYTHON_UNUSED
-# endif
-#endif
-#ifndef CYTHON_MAYBE_UNUSED_VAR
-# if defined(__cplusplus)
- template void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
-# else
-# define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
-# endif
-#endif
-#ifndef CYTHON_NCP_UNUSED
-# if CYTHON_COMPILING_IN_CPYTHON
-# define CYTHON_NCP_UNUSED
-# else
-# define CYTHON_NCP_UNUSED CYTHON_UNUSED
-# endif
-#endif
-#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
-#ifdef _MSC_VER
- #ifndef _MSC_STDINT_H_
- #if _MSC_VER < 1300
- typedef unsigned char uint8_t;
- typedef unsigned int uint32_t;
- #else
- typedef unsigned __int8 uint8_t;
- typedef unsigned __int32 uint32_t;
- #endif
- #endif
-#else
- #include
-#endif
-#ifndef CYTHON_FALLTHROUGH
- #if defined(__cplusplus) && __cplusplus >= 201103L
- #if __has_cpp_attribute(fallthrough)
- #define CYTHON_FALLTHROUGH [[fallthrough]]
- #elif __has_cpp_attribute(clang::fallthrough)
- #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
- #elif __has_cpp_attribute(gnu::fallthrough)
- #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
- #endif
- #endif
- #ifndef CYTHON_FALLTHROUGH
- #if __has_attribute(fallthrough)
- #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
- #else
- #define CYTHON_FALLTHROUGH
- #endif
- #endif
- #if defined(__clang__ ) && defined(__apple_build_version__)
- #if __apple_build_version__ < 7000000
- #undef CYTHON_FALLTHROUGH
- #define CYTHON_FALLTHROUGH
- #endif
- #endif
-#endif
-
-#ifndef CYTHON_INLINE
- #if defined(__clang__)
- #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
- #elif defined(__GNUC__)
- #define CYTHON_INLINE __inline__
- #elif defined(_MSC_VER)
- #define CYTHON_INLINE __inline
- #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- #define CYTHON_INLINE inline
- #else
- #define CYTHON_INLINE
- #endif
-#endif
-
-#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
- #define Py_OptimizeFlag 0
-#endif
-#define __PYX_BUILD_PY_SSIZE_T "n"
-#define CYTHON_FORMAT_SSIZE_T "z"
-#if PY_MAJOR_VERSION < 3
- #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
- #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
- PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
- #define __Pyx_DefaultClassType PyClass_Type
-#else
- #define __Pyx_BUILTIN_MODULE_NAME "builtins"
-#if PY_VERSION_HEX >= 0x030800A4 && PY_VERSION_HEX < 0x030800B2
- #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
- PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
-#else
- #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
- PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
-#endif
- #define __Pyx_DefaultClassType PyType_Type
-#endif
-#ifndef Py_TPFLAGS_CHECKTYPES
- #define Py_TPFLAGS_CHECKTYPES 0
-#endif
-#ifndef Py_TPFLAGS_HAVE_INDEX
- #define Py_TPFLAGS_HAVE_INDEX 0
-#endif
-#ifndef Py_TPFLAGS_HAVE_NEWBUFFER
- #define Py_TPFLAGS_HAVE_NEWBUFFER 0
-#endif
-#ifndef Py_TPFLAGS_HAVE_FINALIZE
- #define Py_TPFLAGS_HAVE_FINALIZE 0
-#endif
-#ifndef METH_STACKLESS
- #define METH_STACKLESS 0
-#endif
-#if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
- #ifndef METH_FASTCALL
- #define METH_FASTCALL 0x80
- #endif
- typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
- typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
- Py_ssize_t nargs, PyObject *kwnames);
-#else
- #define __Pyx_PyCFunctionFast _PyCFunctionFast
- #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
-#endif
-#if CYTHON_FAST_PYCCALL
-#define __Pyx_PyFastCFunction_Check(func)\
- ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)))))
-#else
-#define __Pyx_PyFastCFunction_Check(func) 0
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
- #define PyObject_Malloc(s) PyMem_Malloc(s)
- #define PyObject_Free(p) PyMem_Free(p)
- #define PyObject_Realloc(p) PyMem_Realloc(p)
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1
- #define PyMem_RawMalloc(n) PyMem_Malloc(n)
- #define PyMem_RawRealloc(p, n) PyMem_Realloc(p, n)
- #define PyMem_RawFree(p) PyMem_Free(p)
-#endif
-#if CYTHON_COMPILING_IN_PYSTON
- #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co)
- #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
-#else
- #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
- #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
-#endif
-#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
- #define __Pyx_PyThreadState_Current PyThreadState_GET()
-#elif PY_VERSION_HEX >= 0x03060000
- #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
-#elif PY_VERSION_HEX >= 0x03000000
- #define __Pyx_PyThreadState_Current PyThreadState_GET()
-#else
- #define __Pyx_PyThreadState_Current _PyThreadState_Current
-#endif
-#if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
-#include "pythread.h"
-#define Py_tss_NEEDS_INIT 0
-typedef int Py_tss_t;
-static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
- *key = PyThread_create_key();
- return 0;
-}
-static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
- Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
- *key = Py_tss_NEEDS_INIT;
- return key;
-}
-static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
- PyObject_Free(key);
-}
-static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
- return *key != Py_tss_NEEDS_INIT;
-}
-static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
- PyThread_delete_key(*key);
- *key = Py_tss_NEEDS_INIT;
-}
-static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
- return PyThread_set_key_value(*key, value);
-}
-static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
- return PyThread_get_key_value(*key);
-}
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
-#define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
-#else
-#define __Pyx_PyDict_NewPresized(n) PyDict_New()
-#endif
-#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
- #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
- #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
-#else
- #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
- #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
-#define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
-#else
-#define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name)
-#endif
-#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
- #define CYTHON_PEP393_ENABLED 1
- #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
- 0 : _PyUnicode_Ready((PyObject *)(op)))
- #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
- #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
- #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
- #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
- #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
- #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
- #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
- #if defined(PyUnicode_IS_READY) && defined(PyUnicode_GET_SIZE)
- #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
- #else
- #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_LENGTH(u))
- #endif
-#else
- #define CYTHON_PEP393_ENABLED 0
- #define PyUnicode_1BYTE_KIND 1
- #define PyUnicode_2BYTE_KIND 2
- #define PyUnicode_4BYTE_KIND 4
- #define __Pyx_PyUnicode_READY(op) (0)
- #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
- #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
- #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
- #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
- #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
- #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
- #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
- #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
-#endif
-#if CYTHON_COMPILING_IN_PYPY
- #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
- #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
-#else
- #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
- #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
- PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
- #define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
- #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
-#endif
-#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
- #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
-#endif
-#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
-#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
-#if PY_MAJOR_VERSION >= 3
- #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
-#else
- #define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
-#endif
-#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
- #define PyObject_ASCII(o) PyObject_Repr(o)
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define PyBaseString_Type PyUnicode_Type
- #define PyStringObject PyUnicodeObject
- #define PyString_Type PyUnicode_Type
- #define PyString_Check PyUnicode_Check
- #define PyString_CheckExact PyUnicode_CheckExact
-#ifndef PyObject_Unicode
- #define PyObject_Unicode PyObject_Str
-#endif
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
- #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
-#else
- #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
- #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
-#endif
-#ifndef PySet_CheckExact
- #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
-#endif
-#if PY_VERSION_HEX >= 0x030900A4
- #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt)
- #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size)
-#else
- #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt)
- #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size)
-#endif
-#if CYTHON_ASSUME_SAFE_MACROS
- #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
-#else
- #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq)
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define PyIntObject PyLongObject
- #define PyInt_Type PyLong_Type
- #define PyInt_Check(op) PyLong_Check(op)
- #define PyInt_CheckExact(op) PyLong_CheckExact(op)
- #define PyInt_FromString PyLong_FromString
- #define PyInt_FromUnicode PyLong_FromUnicode
- #define PyInt_FromLong PyLong_FromLong
- #define PyInt_FromSize_t PyLong_FromSize_t
- #define PyInt_FromSsize_t PyLong_FromSsize_t
- #define PyInt_AsLong PyLong_AsLong
- #define PyInt_AS_LONG PyLong_AS_LONG
- #define PyInt_AsSsize_t PyLong_AsSsize_t
- #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
- #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
- #define PyNumber_Int PyNumber_Long
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define PyBoolObject PyLongObject
-#endif
-#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
- #ifndef PyUnicode_InternFromString
- #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
- #endif
-#endif
-#if PY_VERSION_HEX < 0x030200A4
- typedef long Py_hash_t;
- #define __Pyx_PyInt_FromHash_t PyInt_FromLong
- #define __Pyx_PyInt_AsHash_t PyInt_AsLong
-#else
- #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
- #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
-#endif
-#if PY_MAJOR_VERSION >= 3
- #define __Pyx_PyMethod_New(func, self, klass) ((self) ? ((void)(klass), PyMethod_New(func, self)) : __Pyx_NewRef(func))
-#else
- #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
-#endif
-#if CYTHON_USE_ASYNC_SLOTS
- #if PY_VERSION_HEX >= 0x030500B1
- #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
- #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
- #else
- #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
- #endif
-#else
- #define __Pyx_PyType_AsAsync(obj) NULL
-#endif
-#ifndef __Pyx_PyAsyncMethodsStruct
- typedef struct {
- unaryfunc am_await;
- unaryfunc am_aiter;
- unaryfunc am_anext;
- } __Pyx_PyAsyncMethodsStruct;
-#endif
-
-#if defined(WIN32) || defined(MS_WINDOWS)
- #define _USE_MATH_DEFINES
-#endif
-#include
-#ifdef NAN
-#define __PYX_NAN() ((float) NAN)
-#else
-static CYTHON_INLINE float __PYX_NAN() {
- float value;
- memset(&value, 0xFF, sizeof(value));
- return value;
-}
-#endif
-#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
-#define __Pyx_truncl trunc
-#else
-#define __Pyx_truncl truncl
-#endif
-
-#define __PYX_MARK_ERR_POS(f_index, lineno) \
- { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; }
-#define __PYX_ERR(f_index, lineno, Ln_error) \
- { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }
-
-#ifndef __PYX_EXTERN_C
- #ifdef __cplusplus
- #define __PYX_EXTERN_C extern "C"
- #else
- #define __PYX_EXTERN_C extern
- #endif
-#endif
-
-#define __PYX_HAVE__monotonic_align__core
-#define __PYX_HAVE_API__monotonic_align__core
-/* Early includes */
-#include "pythread.h"
-#include
-#include
-#include
-#include "pystate.h"
-#ifdef _OPENMP
-#include
-#endif /* _OPENMP */
-
-#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
-#define CYTHON_WITHOUT_ASSERTIONS
-#endif
-
-typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
- const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
-
-#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
-#define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0
-#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8)
-#define __PYX_DEFAULT_STRING_ENCODING ""
-#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
-#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
-#define __Pyx_uchar_cast(c) ((unsigned char)c)
-#define __Pyx_long_cast(x) ((long)x)
-#define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
- (sizeof(type) < sizeof(Py_ssize_t)) ||\
- (sizeof(type) > sizeof(Py_ssize_t) &&\
- likely(v < (type)PY_SSIZE_T_MAX ||\
- v == (type)PY_SSIZE_T_MAX) &&\
- (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
- v == (type)PY_SSIZE_T_MIN))) ||\
- (sizeof(type) == sizeof(Py_ssize_t) &&\
- (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
- v == (type)PY_SSIZE_T_MAX))) )
-static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
- return (size_t) i < (size_t) limit;
-}
-#if defined (__cplusplus) && __cplusplus >= 201103L
- #include
- #define __Pyx_sst_abs(value) std::abs(value)
-#elif SIZEOF_INT >= SIZEOF_SIZE_T
- #define __Pyx_sst_abs(value) abs(value)
-#elif SIZEOF_LONG >= SIZEOF_SIZE_T
- #define __Pyx_sst_abs(value) labs(value)
-#elif defined (_MSC_VER)
- #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
-#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
- #define __Pyx_sst_abs(value) llabs(value)
-#elif defined (__GNUC__)
- #define __Pyx_sst_abs(value) __builtin_llabs(value)
-#else
- #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
-#endif
-static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
-static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
-#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
-#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
-#define __Pyx_PyBytes_FromString PyBytes_FromString
-#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
-static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
-#if PY_MAJOR_VERSION < 3
- #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
- #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
-#else
- #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
- #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
-#endif
-#define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s))
-#define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s))
-#define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
-#define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
-#define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
-#define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
-#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
-static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
- const Py_UNICODE *u_end = u;
- while (*u_end++) ;
- return (size_t)(u_end - u - 1);
-}
-#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
-#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
-#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
-#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
-#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
-static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
-static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
-static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
-static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
-#define __Pyx_PySequence_Tuple(obj)\
- (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
-static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
-static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
-#if CYTHON_ASSUME_SAFE_MACROS
-#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
-#else
-#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
-#endif
-#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
-#if PY_MAJOR_VERSION >= 3
-#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
-#else
-#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
-#endif
-#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
-#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
-static int __Pyx_sys_getdefaultencoding_not_ascii;
-static int __Pyx_init_sys_getdefaultencoding_params(void) {
- PyObject* sys;
- PyObject* default_encoding = NULL;
- PyObject* ascii_chars_u = NULL;
- PyObject* ascii_chars_b = NULL;
- const char* default_encoding_c;
- sys = PyImport_ImportModule("sys");
- if (!sys) goto bad;
- default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
- Py_DECREF(sys);
- if (!default_encoding) goto bad;
- default_encoding_c = PyBytes_AsString(default_encoding);
- if (!default_encoding_c) goto bad;
- if (strcmp(default_encoding_c, "ascii") == 0) {
- __Pyx_sys_getdefaultencoding_not_ascii = 0;
- } else {
- char ascii_chars[128];
- int c;
- for (c = 0; c < 128; c++) {
- ascii_chars[c] = c;
- }
- __Pyx_sys_getdefaultencoding_not_ascii = 1;
- ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
- if (!ascii_chars_u) goto bad;
- ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
- if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
- PyErr_Format(
- PyExc_ValueError,
- "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
- default_encoding_c);
- goto bad;
- }
- Py_DECREF(ascii_chars_u);
- Py_DECREF(ascii_chars_b);
- }
- Py_DECREF(default_encoding);
- return 0;
-bad:
- Py_XDECREF(default_encoding);
- Py_XDECREF(ascii_chars_u);
- Py_XDECREF(ascii_chars_b);
- return -1;
-}
-#endif
-#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
-#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
-#else
-#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
-#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
-static char* __PYX_DEFAULT_STRING_ENCODING;
-static int __Pyx_init_sys_getdefaultencoding_params(void) {
- PyObject* sys;
- PyObject* default_encoding = NULL;
- char* default_encoding_c;
- sys = PyImport_ImportModule("sys");
- if (!sys) goto bad;
- default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
- Py_DECREF(sys);
- if (!default_encoding) goto bad;
- default_encoding_c = PyBytes_AsString(default_encoding);
- if (!default_encoding_c) goto bad;
- __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1);
- if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
- strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
- Py_DECREF(default_encoding);
- return 0;
-bad:
- Py_XDECREF(default_encoding);
- return -1;
-}
-#endif
-#endif
-
-
-/* Test for GCC > 2.95 */
-#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
- #define likely(x) __builtin_expect(!!(x), 1)
- #define unlikely(x) __builtin_expect(!!(x), 0)
-#else /* !__GNUC__ or GCC < 2.95 */
- #define likely(x) (x)
- #define unlikely(x) (x)
-#endif /* __GNUC__ */
-static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
-
-static PyObject *__pyx_m = NULL;
-static PyObject *__pyx_d;
-static PyObject *__pyx_b;
-static PyObject *__pyx_cython_runtime = NULL;
-static PyObject *__pyx_empty_tuple;
-static PyObject *__pyx_empty_bytes;
-static PyObject *__pyx_empty_unicode;
-static int __pyx_lineno;
-static int __pyx_clineno = 0;
-static const char * __pyx_cfilenm= __FILE__;
-static const char *__pyx_filename;
-
-
-static const char *__pyx_f[] = {
- "core.pyx",
- "stringsource",
-};
-/* NoFastGil.proto */
-#define __Pyx_PyGILState_Ensure PyGILState_Ensure
-#define __Pyx_PyGILState_Release PyGILState_Release
-#define __Pyx_FastGIL_Remember()
-#define __Pyx_FastGIL_Forget()
-#define __Pyx_FastGilFuncInit()
-
-/* MemviewSliceStruct.proto */
-struct __pyx_memoryview_obj;
-typedef struct {
- struct __pyx_memoryview_obj *memview;
- char *data;
- Py_ssize_t shape[8];
- Py_ssize_t strides[8];
- Py_ssize_t suboffsets[8];
-} __Pyx_memviewslice;
-#define __Pyx_MemoryView_Len(m) (m.shape[0])
-
-/* Atomics.proto */
-#include
-#ifndef CYTHON_ATOMICS
- #define CYTHON_ATOMICS 1
-#endif
-#define __pyx_atomic_int_type int
-#if CYTHON_ATOMICS && __GNUC__ >= 4 && (__GNUC_MINOR__ > 1 ||\
- (__GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL >= 2)) &&\
- !defined(__i386__)
- #define __pyx_atomic_incr_aligned(value, lock) __sync_fetch_and_add(value, 1)
- #define __pyx_atomic_decr_aligned(value, lock) __sync_fetch_and_sub(value, 1)
- #ifdef __PYX_DEBUG_ATOMICS
- #warning "Using GNU atomics"
- #endif
-#elif CYTHON_ATOMICS && defined(_MSC_VER) && 0
- #include
- #undef __pyx_atomic_int_type
- #define __pyx_atomic_int_type LONG
- #define __pyx_atomic_incr_aligned(value, lock) InterlockedIncrement(value)
- #define __pyx_atomic_decr_aligned(value, lock) InterlockedDecrement(value)
- #ifdef __PYX_DEBUG_ATOMICS
- #pragma message ("Using MSVC atomics")
- #endif
-#elif CYTHON_ATOMICS && (defined(__ICC) || defined(__INTEL_COMPILER)) && 0
- #define __pyx_atomic_incr_aligned(value, lock) _InterlockedIncrement(value)
- #define __pyx_atomic_decr_aligned(value, lock) _InterlockedDecrement(value)
- #ifdef __PYX_DEBUG_ATOMICS
- #warning "Using Intel atomics"
- #endif
-#else
- #undef CYTHON_ATOMICS
- #define CYTHON_ATOMICS 0
- #ifdef __PYX_DEBUG_ATOMICS
- #warning "Not using atomics"
- #endif
-#endif
-typedef volatile __pyx_atomic_int_type __pyx_atomic_int;
-#if CYTHON_ATOMICS
- #define __pyx_add_acquisition_count(memview)\
- __pyx_atomic_incr_aligned(__pyx_get_slice_count_pointer(memview), memview->lock)
- #define __pyx_sub_acquisition_count(memview)\
- __pyx_atomic_decr_aligned(__pyx_get_slice_count_pointer(memview), memview->lock)
-#else
- #define __pyx_add_acquisition_count(memview)\
- __pyx_add_acquisition_count_locked(__pyx_get_slice_count_pointer(memview), memview->lock)
- #define __pyx_sub_acquisition_count(memview)\
- __pyx_sub_acquisition_count_locked(__pyx_get_slice_count_pointer(memview), memview->lock)
-#endif
-
-/* ForceInitThreads.proto */
-#ifndef __PYX_FORCE_INIT_THREADS
- #define __PYX_FORCE_INIT_THREADS 0
-#endif
-
-/* BufferFormatStructs.proto */
-#define IS_UNSIGNED(type) (((type) -1) > 0)
-struct __Pyx_StructField_;
-#define __PYX_BUF_FLAGS_PACKED_STRUCT (1 << 0)
-typedef struct {
- const char* name;
- struct __Pyx_StructField_* fields;
- size_t size;
- size_t arraysize[8];
- int ndim;
- char typegroup;
- char is_unsigned;
- int flags;
-} __Pyx_TypeInfo;
-typedef struct __Pyx_StructField_ {
- __Pyx_TypeInfo* type;
- const char* name;
- size_t offset;
-} __Pyx_StructField;
-typedef struct {
- __Pyx_StructField* field;
- size_t parent_offset;
-} __Pyx_BufFmt_StackElem;
-typedef struct {
- __Pyx_StructField root;
- __Pyx_BufFmt_StackElem* head;
- size_t fmt_offset;
- size_t new_count, enc_count;
- size_t struct_alignment;
- int is_complex;
- char enc_type;
- char new_packmode;
- char enc_packmode;
- char is_valid_array;
-} __Pyx_BufFmt_Context;
-
-
-/*--- Type declarations ---*/
-struct __pyx_array_obj;
-struct __pyx_MemviewEnum_obj;
-struct __pyx_memoryview_obj;
-struct __pyx_memoryviewslice_obj;
-struct __pyx_opt_args_15monotonic_align_4core_maximum_path_each;
-
-/* "monotonic_align/core.pyx":7
- * @cython.boundscheck(False)
- * @cython.wraparound(False)
- * cdef void maximum_path_each(int[:,::1] path, float[:,::1] value, int t_y, int t_x, float max_neg_val=-1e9) nogil: # <<<<<<<<<<<<<<
- * cdef int x
- * cdef int y
- */
-struct __pyx_opt_args_15monotonic_align_4core_maximum_path_each {
- int __pyx_n;
- float max_neg_val;
-};
-
-/* "View.MemoryView":105
- *
- * @cname("__pyx_array")
- * cdef class array: # <<<<<<<<<<<<<<
- *
- * cdef:
- */
-struct __pyx_array_obj {
- PyObject_HEAD
- struct __pyx_vtabstruct_array *__pyx_vtab;
- char *data;
- Py_ssize_t len;
- char *format;
- int ndim;
- Py_ssize_t *_shape;
- Py_ssize_t *_strides;
- Py_ssize_t itemsize;
- PyObject *mode;
- PyObject *_format;
- void (*callback_free_data)(void *);
- int free_data;
- int dtype_is_object;
-};
-
-
-/* "View.MemoryView":279
- *
- * @cname('__pyx_MemviewEnum')
- * cdef class Enum(object): # <<<<<<<<<<<<<<
- * cdef object name
- * def __init__(self, name):
- */
-struct __pyx_MemviewEnum_obj {
- PyObject_HEAD
- PyObject *name;
-};
-
-
-/* "View.MemoryView":330
- *
- * @cname('__pyx_memoryview')
- * cdef class memoryview(object): # <<<<<<<<<<<<<<
- *
- * cdef object obj
- */
-struct __pyx_memoryview_obj {
- PyObject_HEAD
- struct __pyx_vtabstruct_memoryview *__pyx_vtab;
- PyObject *obj;
- PyObject *_size;
- PyObject *_array_interface;
- PyThread_type_lock lock;
- __pyx_atomic_int acquisition_count[2];
- __pyx_atomic_int *acquisition_count_aligned_p;
- Py_buffer view;
- int flags;
- int dtype_is_object;
- __Pyx_TypeInfo *typeinfo;
-};
-
-
-/* "View.MemoryView":965
- *
- * @cname('__pyx_memoryviewslice')
- * cdef class _memoryviewslice(memoryview): # <<<<<<<<<<<<<<
- * "Internal class for passing memoryview slices to Python"
- *
- */
-struct __pyx_memoryviewslice_obj {
- struct __pyx_memoryview_obj __pyx_base;
- __Pyx_memviewslice from_slice;
- PyObject *from_object;
- PyObject *(*to_object_func)(char *);
- int (*to_dtype_func)(char *, PyObject *);
-};
-
-
-
-/* "View.MemoryView":105
- *
- * @cname("__pyx_array")
- * cdef class array: # <<<<<<<<<<<<<<
- *
- * cdef:
- */
-
-struct __pyx_vtabstruct_array {
- PyObject *(*get_memview)(struct __pyx_array_obj *);
-};
-static struct __pyx_vtabstruct_array *__pyx_vtabptr_array;
-
-
-/* "View.MemoryView":330
- *
- * @cname('__pyx_memoryview')
- * cdef class memoryview(object): # <<<<<<<<<<<<<<
- *
- * cdef object obj
- */
-
-struct __pyx_vtabstruct_memoryview {
- char *(*get_item_pointer)(struct __pyx_memoryview_obj *, PyObject *);
- PyObject *(*is_slice)(struct __pyx_memoryview_obj *, PyObject *);
- PyObject *(*setitem_slice_assignment)(struct __pyx_memoryview_obj *, PyObject *, PyObject *);
- PyObject *(*setitem_slice_assign_scalar)(struct __pyx_memoryview_obj *, struct __pyx_memoryview_obj *, PyObject *);
- PyObject *(*setitem_indexed)(struct __pyx_memoryview_obj *, PyObject *, PyObject *);
- PyObject *(*convert_item_to_object)(struct __pyx_memoryview_obj *, char *);
- PyObject *(*assign_item_from_object)(struct __pyx_memoryview_obj *, char *, PyObject *);
-};
-static struct __pyx_vtabstruct_memoryview *__pyx_vtabptr_memoryview;
-
-
-/* "View.MemoryView":965
- *
- * @cname('__pyx_memoryviewslice')
- * cdef class _memoryviewslice(memoryview): # <<<<<<<<<<<<<<
- * "Internal class for passing memoryview slices to Python"
- *
- */
-
-struct __pyx_vtabstruct__memoryviewslice {
- struct __pyx_vtabstruct_memoryview __pyx_base;
-};
-static struct __pyx_vtabstruct__memoryviewslice *__pyx_vtabptr__memoryviewslice;
-
-/* --- Runtime support code (head) --- */
-/* Refnanny.proto */
-#ifndef CYTHON_REFNANNY
- #define CYTHON_REFNANNY 0
-#endif
-#if CYTHON_REFNANNY
- typedef struct {
- void (*INCREF)(void*, PyObject*, int);
- void (*DECREF)(void*, PyObject*, int);
- void (*GOTREF)(void*, PyObject*, int);
- void (*GIVEREF)(void*, PyObject*, int);
- void* (*SetupContext)(const char*, int, const char*);
- void (*FinishContext)(void**);
- } __Pyx_RefNannyAPIStruct;
- static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
- static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
- #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
-#ifdef WITH_THREAD
- #define __Pyx_RefNannySetupContext(name, acquire_gil)\
- if (acquire_gil) {\
- PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
- __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
- PyGILState_Release(__pyx_gilstate_save);\
- } else {\
- __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
- }
-#else
- #define __Pyx_RefNannySetupContext(name, acquire_gil)\
- __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
-#endif
- #define __Pyx_RefNannyFinishContext()\
- __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
- #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
- #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
- #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
- #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
- #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
-#else
- #define __Pyx_RefNannyDeclarations
- #define __Pyx_RefNannySetupContext(name, acquire_gil)
- #define __Pyx_RefNannyFinishContext()
- #define __Pyx_INCREF(r) Py_INCREF(r)
- #define __Pyx_DECREF(r) Py_DECREF(r)
- #define __Pyx_GOTREF(r)
- #define __Pyx_GIVEREF(r)
- #define __Pyx_XINCREF(r) Py_XINCREF(r)
- #define __Pyx_XDECREF(r) Py_XDECREF(r)
- #define __Pyx_XGOTREF(r)
- #define __Pyx_XGIVEREF(r)
-#endif
-#define __Pyx_XDECREF_SET(r, v) do {\
- PyObject *tmp = (PyObject *) r;\
- r = v; __Pyx_XDECREF(tmp);\
- } while (0)
-#define __Pyx_DECREF_SET(r, v) do {\
- PyObject *tmp = (PyObject *) r;\
- r = v; __Pyx_DECREF(tmp);\
- } while (0)
-#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
-#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
-
-/* PyObjectGetAttrStr.proto */
-#if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
-#else
-#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
-#endif
-
-/* GetBuiltinName.proto */
-static PyObject *__Pyx_GetBuiltinName(PyObject *name);
-
-/* MemviewSliceInit.proto */
-#define __Pyx_BUF_MAX_NDIMS %(BUF_MAX_NDIMS)d
-#define __Pyx_MEMVIEW_DIRECT 1
-#define __Pyx_MEMVIEW_PTR 2
-#define __Pyx_MEMVIEW_FULL 4
-#define __Pyx_MEMVIEW_CONTIG 8
-#define __Pyx_MEMVIEW_STRIDED 16
-#define __Pyx_MEMVIEW_FOLLOW 32
-#define __Pyx_IS_C_CONTIG 1
-#define __Pyx_IS_F_CONTIG 2
-static int __Pyx_init_memviewslice(
- struct __pyx_memoryview_obj *memview,
- int ndim,
- __Pyx_memviewslice *memviewslice,
- int memview_is_new_reference);
-static CYTHON_INLINE int __pyx_add_acquisition_count_locked(
- __pyx_atomic_int *acquisition_count, PyThread_type_lock lock);
-static CYTHON_INLINE int __pyx_sub_acquisition_count_locked(
- __pyx_atomic_int *acquisition_count, PyThread_type_lock lock);
-#define __pyx_get_slice_count_pointer(memview) (memview->acquisition_count_aligned_p)
-#define __pyx_get_slice_count(memview) (*__pyx_get_slice_count_pointer(memview))
-#define __PYX_INC_MEMVIEW(slice, have_gil) __Pyx_INC_MEMVIEW(slice, have_gil, __LINE__)
-#define __PYX_XDEC_MEMVIEW(slice, have_gil) __Pyx_XDEC_MEMVIEW(slice, have_gil, __LINE__)
-static CYTHON_INLINE void __Pyx_INC_MEMVIEW(__Pyx_memviewslice *, int, int);
-static CYTHON_INLINE void __Pyx_XDEC_MEMVIEW(__Pyx_memviewslice *, int, int);
-
-/* RaiseArgTupleInvalid.proto */
-static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
- Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
-
-/* RaiseDoubleKeywords.proto */
-static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
-
-/* ParseKeywords.proto */
-static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
- PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
- const char* function_name);
-
-/* None.proto */
-static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname);
-
-/* ArgTypeTest.proto */
-#define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\
- ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\
- __Pyx__ArgTypeTest(obj, type, name, exact))
-static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact);
-
-/* PyObjectCall.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
-#else
-#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
-#endif
-
-/* PyThreadStateGet.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
-#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current;
-#define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type
-#else
-#define __Pyx_PyThreadState_declare
-#define __Pyx_PyThreadState_assign
-#define __Pyx_PyErr_Occurred() PyErr_Occurred()
-#endif
-
-/* PyErrFetchRestore.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
-#define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
-#define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
-#define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
-#define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
-static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#if CYTHON_COMPILING_IN_CPYTHON
-#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
-#else
-#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
-#endif
-#else
-#define __Pyx_PyErr_Clear() PyErr_Clear()
-#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
-#define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
-#define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
-#define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
-#define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
-#define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
-#define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
-#endif
-
-/* RaiseException.proto */
-static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
-
-/* PyCFunctionFastCall.proto */
-#if CYTHON_FAST_PYCCALL
-static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
-#else
-#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL)
-#endif
-
-/* PyFunctionFastCall.proto */
-#if CYTHON_FAST_PYCALL
-#define __Pyx_PyFunction_FastCall(func, args, nargs)\
- __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
-#if 1 || PY_VERSION_HEX < 0x030600B1
-static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs);
-#else
-#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
-#endif
-#define __Pyx_BUILD_ASSERT_EXPR(cond)\
- (sizeof(char [1 - 2*!(cond)]) - 1)
-#ifndef Py_MEMBER_SIZE
-#define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
-#endif
- static size_t __pyx_pyframe_localsplus_offset = 0;
- #include "frameobject.h"
- #define __Pxy_PyFrame_Initialize_Offsets()\
- ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
- (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
- #define __Pyx_PyFrame_GetLocalsplus(frame)\
- (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
-#endif
-
-/* PyObjectCall2Args.proto */
-static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2);
-
-/* PyObjectCallMethO.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
-#endif
-
-/* PyObjectCallOneArg.proto */
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
-
-/* IncludeStringH.proto */
-#include
-
-/* BytesEquals.proto */
-static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals);
-
-/* UnicodeEquals.proto */
-static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals);
-
-/* StrEquals.proto */
-#if PY_MAJOR_VERSION >= 3
-#define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals
-#else
-#define __Pyx_PyString_Equals __Pyx_PyBytes_Equals
-#endif
-
-/* None.proto */
-static CYTHON_INLINE Py_ssize_t __Pyx_div_Py_ssize_t(Py_ssize_t, Py_ssize_t);
-
-/* UnaryNegOverflows.proto */
-#define UNARY_NEG_WOULD_OVERFLOW(x)\
- (((x) < 0) & ((unsigned long)(x) == 0-(unsigned long)(x)))
-
-static CYTHON_UNUSED int __pyx_array_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
-static PyObject *__pyx_array_get_memview(struct __pyx_array_obj *); /*proto*/
-/* GetAttr.proto */
-static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);
-
-/* GetItemInt.proto */
-#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
- (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
- __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
- (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
- __Pyx_GetItemInt_Generic(o, to_py_func(i))))
-#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
- (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
- __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
- (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
- int wraparound, int boundscheck);
-#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
- (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
- __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
- (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
- int wraparound, int boundscheck);
-static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
- int is_list, int wraparound, int boundscheck);
-
-/* ObjectGetItem.proto */
-#if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key);
-#else
-#define __Pyx_PyObject_GetItem(obj, key) PyObject_GetItem(obj, key)
-#endif
-
-/* decode_c_string_utf16.proto */
-static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16(const char *s, Py_ssize_t size, const char *errors) {
- int byteorder = 0;
- return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
-}
-static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16LE(const char *s, Py_ssize_t size, const char *errors) {
- int byteorder = -1;
- return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
-}
-static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16BE(const char *s, Py_ssize_t size, const char *errors) {
- int byteorder = 1;
- return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
-}
-
-/* decode_c_string.proto */
-static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
- const char* cstring, Py_ssize_t start, Py_ssize_t stop,
- const char* encoding, const char* errors,
- PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors));
-
-/* PyErrExceptionMatches.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
-static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
-#else
-#define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
-#endif
-
-/* GetAttr3.proto */
-static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *);
-
-/* PyDictVersioning.proto */
-#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
-#define __PYX_DICT_VERSION_INIT ((PY_UINT64_T) -1)
-#define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag)
-#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
- (version_var) = __PYX_GET_DICT_VERSION(dict);\
- (cache_var) = (value);
-#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
- static PY_UINT64_T __pyx_dict_version = 0;\
- static PyObject *__pyx_dict_cached_value = NULL;\
- if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
- (VAR) = __pyx_dict_cached_value;\
- } else {\
- (VAR) = __pyx_dict_cached_value = (LOOKUP);\
- __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
- }\
-}
-static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
-static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
-static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
-#else
-#define __PYX_GET_DICT_VERSION(dict) (0)
-#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
-#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP);
-#endif
-
-/* GetModuleGlobalName.proto */
-#if CYTHON_USE_DICT_VERSIONS
-#define __Pyx_GetModuleGlobalName(var, name) {\
- static PY_UINT64_T __pyx_dict_version = 0;\
- static PyObject *__pyx_dict_cached_value = NULL;\
- (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\
- (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\
- __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
-}
-#define __Pyx_GetModuleGlobalNameUncached(var, name) {\
- PY_UINT64_T __pyx_dict_version;\
- PyObject *__pyx_dict_cached_value;\
- (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
-}
-static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value);
-#else
-#define __Pyx_GetModuleGlobalName(var, name) (var) = __Pyx__GetModuleGlobalName(name)
-#define __Pyx_GetModuleGlobalNameUncached(var, name) (var) = __Pyx__GetModuleGlobalName(name)
-static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name);
-#endif
-
-/* RaiseTooManyValuesToUnpack.proto */
-static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
-
-/* RaiseNeedMoreValuesToUnpack.proto */
-static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
-
-/* RaiseNoneIterError.proto */
-static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);
-
-/* ExtTypeTest.proto */
-static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type);
-
-/* GetTopmostException.proto */
-#if CYTHON_USE_EXC_INFO_STACK
-static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate);
-#endif
-
-/* SaveResetException.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
-#else
-#define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb)
-#define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb)
-#endif
-
-/* GetException.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb)
-static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#else
-static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
-#endif
-
-/* SwapException.proto */
-#if CYTHON_FAST_THREAD_STATE
-#define __Pyx_ExceptionSwap(type, value, tb) __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb)
-static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
-#else
-static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
-#endif
-
-/* Import.proto */
-static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
-
-/* FastTypeChecks.proto */
-#if CYTHON_COMPILING_IN_CPYTHON
-#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
-static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
-static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
-#else
-#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
-#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
-#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
-#endif
-#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
-
-static CYTHON_UNUSED int __pyx_memoryview_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
-/* ListCompAppend.proto */
-#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
-static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) {
- PyListObject* L = (PyListObject*) list;
- Py_ssize_t len = Py_SIZE(list);
- if (likely(L->allocated > len)) {
- Py_INCREF(x);
- PyList_SET_ITEM(list, len, x);
- __Pyx_SET_SIZE(list, len + 1);
- return 0;
- }
- return PyList_Append(list, x);
-}
-#else
-#define __Pyx_ListComp_Append(L,x) PyList_Append(L,x)
-#endif
-
-/* PyIntBinop.proto */
-#if !CYTHON_COMPILING_IN_PYPY
-static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
-#else
-#define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace, zerodivision_check)\
- (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2))
-#endif
-
-/* ListExtend.proto */
-static CYTHON_INLINE int __Pyx_PyList_Extend(PyObject* L, PyObject* v) {
-#if CYTHON_COMPILING_IN_CPYTHON
- PyObject* none = _PyList_Extend((PyListObject*)L, v);
- if (unlikely(!none))
- return -1;
- Py_DECREF(none);
- return 0;
-#else
- return PyList_SetSlice(L, PY_SSIZE_T_MAX, PY_SSIZE_T_MAX, v);
-#endif
-}
-
-/* ListAppend.proto */
-#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
-static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
- PyListObject* L = (PyListObject*) list;
- Py_ssize_t len = Py_SIZE(list);
- if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
- Py_INCREF(x);
- PyList_SET_ITEM(list, len, x);
- __Pyx_SET_SIZE(list, len + 1);
- return 0;
- }
- return PyList_Append(list, x);
-}
-#else
-#define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
-#endif
-
-/* None.proto */
-static CYTHON_INLINE long __Pyx_div_long(long, long);
-
-/* ImportFrom.proto */
-static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
-
-/* HasAttr.proto */
-static CYTHON_INLINE int __Pyx_HasAttr(PyObject *, PyObject *);
-
-/* PyObject_GenericGetAttrNoDict.proto */
-#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
-#else
-#define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
-#endif
-
-/* PyObject_GenericGetAttr.proto */
-#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
-#else
-#define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
-#endif
-
-/* SetVTable.proto */
-static int __Pyx_SetVtable(PyObject *dict, void *vtable);
-
-/* PyObjectGetAttrStrNoError.proto */
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name);
-
-/* SetupReduce.proto */
-static int __Pyx_setup_reduce(PyObject* type_obj);
-
-/* CLineInTraceback.proto */
-#ifdef CYTHON_CLINE_IN_TRACEBACK
-#define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
-#else
-static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
-#endif
-
-/* CodeObjectCache.proto */
-typedef struct {
- PyCodeObject* code_object;
- int code_line;
-} __Pyx_CodeObjectCacheEntry;
-struct __Pyx_CodeObjectCache {
- int count;
- int max_count;
- __Pyx_CodeObjectCacheEntry* entries;
-};
-static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
-static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
-static PyCodeObject *__pyx_find_code_object(int code_line);
-static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
-
-/* AddTraceback.proto */
-static void __Pyx_AddTraceback(const char *funcname, int c_line,
- int py_line, const char *filename);
-
-#if PY_MAJOR_VERSION < 3
- static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags);
- static void __Pyx_ReleaseBuffer(Py_buffer *view);
-#else
- #define __Pyx_GetBuffer PyObject_GetBuffer
- #define __Pyx_ReleaseBuffer PyBuffer_Release
-#endif
-
-
-/* BufferStructDeclare.proto */
-typedef struct {
- Py_ssize_t shape, strides, suboffsets;
-} __Pyx_Buf_DimInfo;
-typedef struct {
- size_t refcount;
- Py_buffer pybuffer;
-} __Pyx_Buffer;
-typedef struct {
- __Pyx_Buffer *rcbuffer;
- char *data;
- __Pyx_Buf_DimInfo diminfo[8];
-} __Pyx_LocalBuf_ND;
-
-/* MemviewSliceIsContig.proto */
-static int __pyx_memviewslice_is_contig(const __Pyx_memviewslice mvs, char order, int ndim);
-
-/* OverlappingSlices.proto */
-static int __pyx_slices_overlap(__Pyx_memviewslice *slice1,
- __Pyx_memviewslice *slice2,
- int ndim, size_t itemsize);
-
-/* Capsule.proto */
-static CYTHON_INLINE PyObject *__pyx_capsule_create(void *p, const char *sig);
-
-/* IsLittleEndian.proto */
-static CYTHON_INLINE int __Pyx_Is_Little_Endian(void);
-
-/* BufferFormatCheck.proto */
-static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts);
-static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx,
- __Pyx_BufFmt_StackElem* stack,
- __Pyx_TypeInfo* type);
-
-/* TypeInfoCompare.proto */
-static int __pyx_typeinfo_cmp(__Pyx_TypeInfo *a, __Pyx_TypeInfo *b);
-
-/* MemviewSliceValidateAndInit.proto */
-static int __Pyx_ValidateAndInit_memviewslice(
- int *axes_specs,
- int c_or_f_flag,
- int buf_flags,
- int ndim,
- __Pyx_TypeInfo *dtype,
- __Pyx_BufFmt_StackElem stack[],
- __Pyx_memviewslice *memviewslice,
- PyObject *original_obj);
-
-/* ObjectToMemviewSlice.proto */
-static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_int(PyObject *, int writable_flag);
-
-/* ObjectToMemviewSlice.proto */
-static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_float(PyObject *, int writable_flag);
-
-/* ObjectToMemviewSlice.proto */
-static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dc_int(PyObject *, int writable_flag);
-
-/* CIntToPy.proto */
-static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
-
-/* CIntToPy.proto */
-static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
-
-/* MemviewSliceCopyTemplate.proto */
-static __Pyx_memviewslice
-__pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs,
- const char *mode, int ndim,
- size_t sizeof_dtype, int contig_flag,
- int dtype_is_object);
-
-/* CIntFromPy.proto */
-static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
-
-/* CIntFromPy.proto */
-static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
-
-/* CIntFromPy.proto */
-static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *);
-
-/* CheckBinaryVersion.proto */
-static int __Pyx_check_binary_version(void);
-
-/* InitStrings.proto */
-static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
-
-static PyObject *__pyx_array_get_memview(struct __pyx_array_obj *__pyx_v_self); /* proto*/
-static char *__pyx_memoryview_get_item_pointer(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index); /* proto*/
-static PyObject *__pyx_memoryview_is_slice(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj); /* proto*/
-static PyObject *__pyx_memoryview_setitem_slice_assignment(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_dst, PyObject *__pyx_v_src); /* proto*/
-static PyObject *__pyx_memoryview_setitem_slice_assign_scalar(struct __pyx_memoryview_obj *__pyx_v_self, struct __pyx_memoryview_obj *__pyx_v_dst, PyObject *__pyx_v_value); /* proto*/
-static PyObject *__pyx_memoryview_setitem_indexed(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value); /* proto*/
-static PyObject *__pyx_memoryview_convert_item_to_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp); /* proto*/
-static PyObject *__pyx_memoryview_assign_item_from_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value); /* proto*/
-static PyObject *__pyx_memoryviewslice_convert_item_to_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp); /* proto*/
-static PyObject *__pyx_memoryviewslice_assign_item_from_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value); /* proto*/
-
-/* Module declarations from 'cython.view' */
-
-/* Module declarations from 'cython' */
-
-/* Module declarations from 'monotonic_align.core' */
-static PyTypeObject *__pyx_array_type = 0;
-static PyTypeObject *__pyx_MemviewEnum_type = 0;
-static PyTypeObject *__pyx_memoryview_type = 0;
-static PyTypeObject *__pyx_memoryviewslice_type = 0;
-static PyObject *generic = 0;
-static PyObject *strided = 0;
-static PyObject *indirect = 0;
-static PyObject *contiguous = 0;
-static PyObject *indirect_contiguous = 0;
-static int __pyx_memoryview_thread_locks_used;
-static PyThread_type_lock __pyx_memoryview_thread_locks[8];
-static void __pyx_f_15monotonic_align_4core_maximum_path_each(__Pyx_memviewslice, __Pyx_memviewslice, int, int, struct __pyx_opt_args_15monotonic_align_4core_maximum_path_each *__pyx_optional_args); /*proto*/
-static void __pyx_f_15monotonic_align_4core_maximum_path_c(__Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice, __Pyx_memviewslice, int __pyx_skip_dispatch); /*proto*/
-static struct __pyx_array_obj *__pyx_array_new(PyObject *, Py_ssize_t, char *, char *, char *); /*proto*/
-static void *__pyx_align_pointer(void *, size_t); /*proto*/
-static PyObject *__pyx_memoryview_new(PyObject *, int, int, __Pyx_TypeInfo *); /*proto*/
-static CYTHON_INLINE int __pyx_memoryview_check(PyObject *); /*proto*/
-static PyObject *_unellipsify(PyObject *, int); /*proto*/
-static PyObject *assert_direct_dimensions(Py_ssize_t *, int); /*proto*/
-static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_obj *, PyObject *); /*proto*/
-static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *, Py_ssize_t, Py_ssize_t, Py_ssize_t, int, int, int *, Py_ssize_t, Py_ssize_t, Py_ssize_t, int, int, int, int); /*proto*/
-static char *__pyx_pybuffer_index(Py_buffer *, char *, Py_ssize_t, Py_ssize_t); /*proto*/
-static int __pyx_memslice_transpose(__Pyx_memviewslice *); /*proto*/
-static PyObject *__pyx_memoryview_fromslice(__Pyx_memviewslice, int, PyObject *(*)(char *), int (*)(char *, PyObject *), int); /*proto*/
-static __Pyx_memviewslice *__pyx_memoryview_get_slice_from_memoryview(struct __pyx_memoryview_obj *, __Pyx_memviewslice *); /*proto*/
-static void __pyx_memoryview_slice_copy(struct __pyx_memoryview_obj *, __Pyx_memviewslice *); /*proto*/
-static PyObject *__pyx_memoryview_copy_object(struct __pyx_memoryview_obj *); /*proto*/
-static PyObject *__pyx_memoryview_copy_object_from_slice(struct __pyx_memoryview_obj *, __Pyx_memviewslice *); /*proto*/
-static Py_ssize_t abs_py_ssize_t(Py_ssize_t); /*proto*/
-static char __pyx_get_best_slice_order(__Pyx_memviewslice *, int); /*proto*/
-static void _copy_strided_to_strided(char *, Py_ssize_t *, char *, Py_ssize_t *, Py_ssize_t *, Py_ssize_t *, int, size_t); /*proto*/
-static void copy_strided_to_strided(__Pyx_memviewslice *, __Pyx_memviewslice *, int, size_t); /*proto*/
-static Py_ssize_t __pyx_memoryview_slice_get_size(__Pyx_memviewslice *, int); /*proto*/
-static Py_ssize_t __pyx_fill_contig_strides_array(Py_ssize_t *, Py_ssize_t *, Py_ssize_t, int, char); /*proto*/
-static void *__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice *, __Pyx_memviewslice *, char, int); /*proto*/
-static int __pyx_memoryview_err_extents(int, Py_ssize_t, Py_ssize_t); /*proto*/
-static int __pyx_memoryview_err_dim(PyObject *, char *, int); /*proto*/
-static int __pyx_memoryview_err(PyObject *, char *); /*proto*/
-static int __pyx_memoryview_copy_contents(__Pyx_memviewslice, __Pyx_memviewslice, int, int, int); /*proto*/
-static void __pyx_memoryview_broadcast_leading(__Pyx_memviewslice *, int, int); /*proto*/
-static void __pyx_memoryview_refcount_copying(__Pyx_memviewslice *, int, int, int); /*proto*/
-static void __pyx_memoryview_refcount_objects_in_slice_with_gil(char *, Py_ssize_t *, Py_ssize_t *, int, int); /*proto*/
-static void __pyx_memoryview_refcount_objects_in_slice(char *, Py_ssize_t *, Py_ssize_t *, int, int); /*proto*/
-static void __pyx_memoryview_slice_assign_scalar(__Pyx_memviewslice *, int, size_t, void *, int); /*proto*/
-static void __pyx_memoryview__slice_assign_scalar(char *, Py_ssize_t *, Py_ssize_t *, int, size_t, void *); /*proto*/
-static PyObject *__pyx_unpickle_Enum__set_state(struct __pyx_MemviewEnum_obj *, PyObject *); /*proto*/
-static __Pyx_TypeInfo __Pyx_TypeInfo_int = { "int", NULL, sizeof(int), { 0 }, 0, IS_UNSIGNED(int) ? 'U' : 'I', IS_UNSIGNED(int), 0 };
-static __Pyx_TypeInfo __Pyx_TypeInfo_float = { "float", NULL, sizeof(float), { 0 }, 0, 'R', 0, 0 };
-#define __Pyx_MODULE_NAME "monotonic_align.core"
-extern int __pyx_module_is_main_monotonic_align__core;
-int __pyx_module_is_main_monotonic_align__core = 0;
-
-/* Implementation of 'monotonic_align.core' */
-static PyObject *__pyx_builtin_range;
-static PyObject *__pyx_builtin_ValueError;
-static PyObject *__pyx_builtin_MemoryError;
-static PyObject *__pyx_builtin_enumerate;
-static PyObject *__pyx_builtin_TypeError;
-static PyObject *__pyx_builtin_Ellipsis;
-static PyObject *__pyx_builtin_id;
-static PyObject *__pyx_builtin_IndexError;
-static const char __pyx_k_O[] = "O";
-static const char __pyx_k_c[] = "c";
-static const char __pyx_k_id[] = "id";
-static const char __pyx_k_new[] = "__new__";
-static const char __pyx_k_obj[] = "obj";
-static const char __pyx_k_base[] = "base";
-static const char __pyx_k_dict[] = "__dict__";
-static const char __pyx_k_main[] = "__main__";
-static const char __pyx_k_mode[] = "mode";
-static const char __pyx_k_name[] = "name";
-static const char __pyx_k_ndim[] = "ndim";
-static const char __pyx_k_pack[] = "pack";
-static const char __pyx_k_size[] = "size";
-static const char __pyx_k_step[] = "step";
-static const char __pyx_k_stop[] = "stop";
-static const char __pyx_k_t_xs[] = "t_xs";
-static const char __pyx_k_t_ys[] = "t_ys";
-static const char __pyx_k_test[] = "__test__";
-static const char __pyx_k_ASCII[] = "ASCII";
-static const char __pyx_k_class[] = "__class__";
-static const char __pyx_k_error[] = "error";
-static const char __pyx_k_flags[] = "flags";
-static const char __pyx_k_paths[] = "paths";
-static const char __pyx_k_range[] = "range";
-static const char __pyx_k_shape[] = "shape";
-static const char __pyx_k_start[] = "start";
-static const char __pyx_k_encode[] = "encode";
-static const char __pyx_k_format[] = "format";
-static const char __pyx_k_import[] = "__import__";
-static const char __pyx_k_name_2[] = "__name__";
-static const char __pyx_k_pickle[] = "pickle";
-static const char __pyx_k_reduce[] = "__reduce__";
-static const char __pyx_k_struct[] = "struct";
-static const char __pyx_k_unpack[] = "unpack";
-static const char __pyx_k_update[] = "update";
-static const char __pyx_k_values[] = "values";
-static const char __pyx_k_fortran[] = "fortran";
-static const char __pyx_k_memview[] = "memview";
-static const char __pyx_k_Ellipsis[] = "Ellipsis";
-static const char __pyx_k_getstate[] = "__getstate__";
-static const char __pyx_k_itemsize[] = "itemsize";
-static const char __pyx_k_pyx_type[] = "__pyx_type";
-static const char __pyx_k_setstate[] = "__setstate__";
-static const char __pyx_k_TypeError[] = "TypeError";
-static const char __pyx_k_enumerate[] = "enumerate";
-static const char __pyx_k_pyx_state[] = "__pyx_state";
-static const char __pyx_k_reduce_ex[] = "__reduce_ex__";
-static const char __pyx_k_IndexError[] = "IndexError";
-static const char __pyx_k_ValueError[] = "ValueError";
-static const char __pyx_k_pyx_result[] = "__pyx_result";
-static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
-static const char __pyx_k_MemoryError[] = "MemoryError";
-static const char __pyx_k_PickleError[] = "PickleError";
-static const char __pyx_k_pyx_checksum[] = "__pyx_checksum";
-static const char __pyx_k_stringsource[] = "stringsource";
-static const char __pyx_k_pyx_getbuffer[] = "__pyx_getbuffer";
-static const char __pyx_k_reduce_cython[] = "__reduce_cython__";
-static const char __pyx_k_View_MemoryView[] = "View.MemoryView";
-static const char __pyx_k_allocate_buffer[] = "allocate_buffer";
-static const char __pyx_k_dtype_is_object[] = "dtype_is_object";
-static const char __pyx_k_pyx_PickleError[] = "__pyx_PickleError";
-static const char __pyx_k_setstate_cython[] = "__setstate_cython__";
-static const char __pyx_k_pyx_unpickle_Enum[] = "__pyx_unpickle_Enum";
-static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
-static const char __pyx_k_strided_and_direct[] = "";
-static const char __pyx_k_strided_and_indirect[] = "";
-static const char __pyx_k_contiguous_and_direct[] = "";
-static const char __pyx_k_MemoryView_of_r_object[] = "";
-static const char __pyx_k_MemoryView_of_r_at_0x_x[] = "";
-static const char __pyx_k_contiguous_and_indirect[] = "";
-static const char __pyx_k_Cannot_index_with_type_s[] = "Cannot index with type '%s'";
-static const char __pyx_k_Invalid_shape_in_axis_d_d[] = "Invalid shape in axis %d: %d.";
-static const char __pyx_k_itemsize_0_for_cython_array[] = "itemsize <= 0 for cython.array";
-static const char __pyx_k_unable_to_allocate_array_data[] = "unable to allocate array data.";
-static const char __pyx_k_strided_and_direct_or_indirect[] = "";
-static const char __pyx_k_Buffer_view_does_not_expose_stri[] = "Buffer view does not expose strides";
-static const char __pyx_k_Can_only_create_a_buffer_that_is[] = "Can only create a buffer that is contiguous in memory.";
-static const char __pyx_k_Cannot_assign_to_read_only_memor[] = "Cannot assign to read-only memoryview";
-static const char __pyx_k_Cannot_create_writable_memory_vi[] = "Cannot create writable memory view from read-only memoryview";
-static const char __pyx_k_Empty_shape_tuple_for_cython_arr[] = "Empty shape tuple for cython.array";
-static const char __pyx_k_Incompatible_checksums_s_vs_0xb0[] = "Incompatible checksums (%s vs 0xb068931 = (name))";
-static const char __pyx_k_Indirect_dimensions_not_supporte[] = "Indirect dimensions not supported";
-static const char __pyx_k_Invalid_mode_expected_c_or_fortr[] = "Invalid mode, expected 'c' or 'fortran', got %s";
-static const char __pyx_k_Out_of_bounds_on_buffer_access_a[] = "Out of bounds on buffer access (axis %d)";
-static const char __pyx_k_Unable_to_convert_item_to_object[] = "Unable to convert item to object";
-static const char __pyx_k_got_differing_extents_in_dimensi[] = "got differing extents in dimension %d (got %d and %d)";
-static const char __pyx_k_no_default___reduce___due_to_non[] = "no default __reduce__ due to non-trivial __cinit__";
-static const char __pyx_k_unable_to_allocate_shape_and_str[] = "unable to allocate shape and strides.";
-static PyObject *__pyx_n_s_ASCII;
-static PyObject *__pyx_kp_s_Buffer_view_does_not_expose_stri;
-static PyObject *__pyx_kp_s_Can_only_create_a_buffer_that_is;
-static PyObject *__pyx_kp_s_Cannot_assign_to_read_only_memor;
-static PyObject *__pyx_kp_s_Cannot_create_writable_memory_vi;
-static PyObject *__pyx_kp_s_Cannot_index_with_type_s;
-static PyObject *__pyx_n_s_Ellipsis;
-static PyObject *__pyx_kp_s_Empty_shape_tuple_for_cython_arr;
-static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0xb0;
-static PyObject *__pyx_n_s_IndexError;
-static PyObject *__pyx_kp_s_Indirect_dimensions_not_supporte;
-static PyObject *__pyx_kp_s_Invalid_mode_expected_c_or_fortr;
-static PyObject *__pyx_kp_s_Invalid_shape_in_axis_d_d;
-static PyObject *__pyx_n_s_MemoryError;
-static PyObject *__pyx_kp_s_MemoryView_of_r_at_0x_x;
-static PyObject *__pyx_kp_s_MemoryView_of_r_object;
-static PyObject *__pyx_n_b_O;
-static PyObject *__pyx_kp_s_Out_of_bounds_on_buffer_access_a;
-static PyObject *__pyx_n_s_PickleError;
-static PyObject *__pyx_n_s_TypeError;
-static PyObject *__pyx_kp_s_Unable_to_convert_item_to_object;
-static PyObject *__pyx_n_s_ValueError;
-static PyObject *__pyx_n_s_View_MemoryView;
-static PyObject *__pyx_n_s_allocate_buffer;
-static PyObject *__pyx_n_s_base;
-static PyObject *__pyx_n_s_c;
-static PyObject *__pyx_n_u_c;
-static PyObject *__pyx_n_s_class;
-static PyObject *__pyx_n_s_cline_in_traceback;
-static PyObject *__pyx_kp_s_contiguous_and_direct;
-static PyObject *__pyx_kp_s_contiguous_and_indirect;
-static PyObject *__pyx_n_s_dict;
-static PyObject *__pyx_n_s_dtype_is_object;
-static PyObject *__pyx_n_s_encode;
-static PyObject *__pyx_n_s_enumerate;
-static PyObject *__pyx_n_s_error;
-static PyObject *__pyx_n_s_flags;
-static PyObject *__pyx_n_s_format;
-static PyObject *__pyx_n_s_fortran;
-static PyObject *__pyx_n_u_fortran;
-static PyObject *__pyx_n_s_getstate;
-static PyObject *__pyx_kp_s_got_differing_extents_in_dimensi;
-static PyObject *__pyx_n_s_id;
-static PyObject *__pyx_n_s_import;
-static PyObject *__pyx_n_s_itemsize;
-static PyObject *__pyx_kp_s_itemsize_0_for_cython_array;
-static PyObject *__pyx_n_s_main;
-static PyObject *__pyx_n_s_memview;
-static PyObject *__pyx_n_s_mode;
-static PyObject *__pyx_n_s_name;
-static PyObject *__pyx_n_s_name_2;
-static PyObject *__pyx_n_s_ndim;
-static PyObject *__pyx_n_s_new;
-static PyObject *__pyx_kp_s_no_default___reduce___due_to_non;
-static PyObject *__pyx_n_s_obj;
-static PyObject *__pyx_n_s_pack;
-static PyObject *__pyx_n_s_paths;
-static PyObject *__pyx_n_s_pickle;
-static PyObject *__pyx_n_s_pyx_PickleError;
-static PyObject *__pyx_n_s_pyx_checksum;
-static PyObject *__pyx_n_s_pyx_getbuffer;
-static PyObject *__pyx_n_s_pyx_result;
-static PyObject *__pyx_n_s_pyx_state;
-static PyObject *__pyx_n_s_pyx_type;
-static PyObject *__pyx_n_s_pyx_unpickle_Enum;
-static PyObject *__pyx_n_s_pyx_vtable;
-static PyObject *__pyx_n_s_range;
-static PyObject *__pyx_n_s_reduce;
-static PyObject *__pyx_n_s_reduce_cython;
-static PyObject *__pyx_n_s_reduce_ex;
-static PyObject *__pyx_n_s_setstate;
-static PyObject *__pyx_n_s_setstate_cython;
-static PyObject *__pyx_n_s_shape;
-static PyObject *__pyx_n_s_size;
-static PyObject *__pyx_n_s_start;
-static PyObject *__pyx_n_s_step;
-static PyObject *__pyx_n_s_stop;
-static PyObject *__pyx_kp_s_strided_and_direct;
-static PyObject *__pyx_kp_s_strided_and_direct_or_indirect;
-static PyObject *__pyx_kp_s_strided_and_indirect;
-static PyObject *__pyx_kp_s_stringsource;
-static PyObject *__pyx_n_s_struct;
-static PyObject *__pyx_n_s_t_xs;
-static PyObject *__pyx_n_s_t_ys;
-static PyObject *__pyx_n_s_test;
-static PyObject *__pyx_kp_s_unable_to_allocate_array_data;
-static PyObject *__pyx_kp_s_unable_to_allocate_shape_and_str;
-static PyObject *__pyx_n_s_unpack;
-static PyObject *__pyx_n_s_update;
-static PyObject *__pyx_n_s_values;
-static PyObject *__pyx_pf_15monotonic_align_4core_maximum_path_c(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_paths, __Pyx_memviewslice __pyx_v_values, __Pyx_memviewslice __pyx_v_t_ys, __Pyx_memviewslice __pyx_v_t_xs); /* proto */
-static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_shape, Py_ssize_t __pyx_v_itemsize, PyObject *__pyx_v_format, PyObject *__pyx_v_mode, int __pyx_v_allocate_buffer); /* proto */
-static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array_2__getbuffer__(struct __pyx_array_obj *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */
-static void __pyx_array___pyx_pf_15View_dot_MemoryView_5array_4__dealloc__(struct __pyx_array_obj *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_15View_dot_MemoryView_5array_7memview___get__(struct __pyx_array_obj *__pyx_v_self); /* proto */
-static Py_ssize_t __pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__len__(struct __pyx_array_obj *__pyx_v_self); /* proto */
-static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getattr__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_attr); /* proto */
-static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__getitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item); /* proto */
-static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array_12__setitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value); /* proto */
-static PyObject *__pyx_pf___pyx_array___reduce_cython__(CYTHON_UNUSED struct __pyx_array_obj *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf___pyx_array_2__setstate_cython__(CYTHON_UNUSED struct __pyx_array_obj *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
-static int __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v_name); /* proto */
-static PyObject *__pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr__(struct __pyx_MemviewEnum_obj *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf___pyx_MemviewEnum___reduce_cython__(struct __pyx_MemviewEnum_obj *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf___pyx_MemviewEnum_2__setstate_cython__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
-static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview___cinit__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj, int __pyx_v_flags, int __pyx_v_dtype_is_object); /* proto */
-static void __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
-static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4__getitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index); /* proto */
-static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_6__setitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value); /* proto */
-static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_8__getbuffer__(struct __pyx_memoryview_obj *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */
-static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_1T___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4base___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_5shape___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4ndim___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_8itemsize___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_6nbytes___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
-static Py_ssize_t __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_10__len__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
-static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_12__repr__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
-static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_14__str__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
-static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_16is_c_contig(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
-static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_18is_f_contig(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
-static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_20copy(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
-static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22copy_fortran(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf___pyx_memoryview___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryview_obj *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf___pyx_memoryview_2__setstate_cython__(CYTHON_UNUSED struct __pyx_memoryview_obj *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
-static void __pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__(struct __pyx_memoryviewslice_obj *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__(struct __pyx_memoryviewslice_obj *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf___pyx_memoryviewslice___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryviewslice_obj *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf___pyx_memoryviewslice_2__setstate_cython__(CYTHON_UNUSED struct __pyx_memoryviewslice_obj *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
-static PyObject *__pyx_pf_15View_dot_MemoryView___pyx_unpickle_Enum(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
-static PyObject *__pyx_tp_new_array(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tp_new_Enum(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tp_new_memoryview(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_tp_new__memoryviewslice(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
-static PyObject *__pyx_int_0;
-static PyObject *__pyx_int_1;
-static PyObject *__pyx_int_184977713;
-static PyObject *__pyx_int_neg_1;
-static float __pyx_k_;
-static PyObject *__pyx_tuple__2;
-static PyObject *__pyx_tuple__3;
-static PyObject *__pyx_tuple__4;
-static PyObject *__pyx_tuple__5;
-static PyObject *__pyx_tuple__6;
-static PyObject *__pyx_tuple__7;
-static PyObject *__pyx_tuple__8;
-static PyObject *__pyx_tuple__9;
-static PyObject *__pyx_slice__16;
-static PyObject *__pyx_tuple__10;
-static PyObject *__pyx_tuple__11;
-static PyObject *__pyx_tuple__12;
-static PyObject *__pyx_tuple__13;
-static PyObject *__pyx_tuple__14;
-static PyObject *__pyx_tuple__15;
-static PyObject *__pyx_tuple__17;
-static PyObject *__pyx_tuple__18;
-static PyObject *__pyx_tuple__19;
-static PyObject *__pyx_tuple__20;
-static PyObject *__pyx_tuple__21;
-static PyObject *__pyx_tuple__22;
-static PyObject *__pyx_tuple__23;
-static PyObject *__pyx_tuple__24;
-static PyObject *__pyx_tuple__25;
-static PyObject *__pyx_codeobj__26;
-/* Late includes */
-
-/* "monotonic_align/core.pyx":7
- * @cython.boundscheck(False)
- * @cython.wraparound(False)
- * cdef void maximum_path_each(int[:,::1] path, float[:,::1] value, int t_y, int t_x, float max_neg_val=-1e9) nogil: # <<<<<<<<<<<<<<
- * cdef int x
- * cdef int y
- */
-
-static void __pyx_f_15monotonic_align_4core_maximum_path_each(__Pyx_memviewslice __pyx_v_path, __Pyx_memviewslice __pyx_v_value, int __pyx_v_t_y, int __pyx_v_t_x, struct __pyx_opt_args_15monotonic_align_4core_maximum_path_each *__pyx_optional_args) {
- float __pyx_v_max_neg_val = __pyx_k_;
- int __pyx_v_x;
- int __pyx_v_y;
- float __pyx_v_v_prev;
- float __pyx_v_v_cur;
- int __pyx_v_index;
- int __pyx_t_1;
- int __pyx_t_2;
- int __pyx_t_3;
- long __pyx_t_4;
- int __pyx_t_5;
- long __pyx_t_6;
- long __pyx_t_7;
- int __pyx_t_8;
- Py_ssize_t __pyx_t_9;
- Py_ssize_t __pyx_t_10;
- float __pyx_t_11;
- float __pyx_t_12;
- float __pyx_t_13;
- int __pyx_t_14;
- Py_ssize_t __pyx_t_15;
- Py_ssize_t __pyx_t_16;
- if (__pyx_optional_args) {
- if (__pyx_optional_args->__pyx_n > 0) {
- __pyx_v_max_neg_val = __pyx_optional_args->max_neg_val;
- }
- }
-
- /* "monotonic_align/core.pyx":13
- * cdef float v_cur
- * cdef float tmp
- * cdef int index = t_x - 1 # <<<<<<<<<<<<<<
- *
- * for y in range(t_y):
- */
- __pyx_v_index = (__pyx_v_t_x - 1);
-
- /* "monotonic_align/core.pyx":15
- * cdef int index = t_x - 1
- *
- * for y in range(t_y): # <<<<<<<<<<<<<<
- * for x in range(max(0, t_x + y - t_y), min(t_x, y + 1)):
- * if x == y:
- */
- __pyx_t_1 = __pyx_v_t_y;
- __pyx_t_2 = __pyx_t_1;
- for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
- __pyx_v_y = __pyx_t_3;
-
- /* "monotonic_align/core.pyx":16
- *
- * for y in range(t_y):
- * for x in range(max(0, t_x + y - t_y), min(t_x, y + 1)): # <<<<<<<<<<<<<<
- * if x == y:
- * v_cur = max_neg_val
- */
- __pyx_t_4 = (__pyx_v_y + 1);
- __pyx_t_5 = __pyx_v_t_x;
- if (((__pyx_t_4 < __pyx_t_5) != 0)) {
- __pyx_t_6 = __pyx_t_4;
- } else {
- __pyx_t_6 = __pyx_t_5;
- }
- __pyx_t_4 = __pyx_t_6;
- __pyx_t_5 = ((__pyx_v_t_x + __pyx_v_y) - __pyx_v_t_y);
- __pyx_t_6 = 0;
- if (((__pyx_t_5 > __pyx_t_6) != 0)) {
- __pyx_t_7 = __pyx_t_5;
- } else {
- __pyx_t_7 = __pyx_t_6;
- }
- __pyx_t_6 = __pyx_t_4;
- for (__pyx_t_5 = __pyx_t_7; __pyx_t_5 < __pyx_t_6; __pyx_t_5+=1) {
- __pyx_v_x = __pyx_t_5;
-
- /* "monotonic_align/core.pyx":17
- * for y in range(t_y):
- * for x in range(max(0, t_x + y - t_y), min(t_x, y + 1)):
- * if x == y: # <<<<<<<<<<<<<<
- * v_cur = max_neg_val
- * else:
- */
- __pyx_t_8 = ((__pyx_v_x == __pyx_v_y) != 0);
- if (__pyx_t_8) {
-
- /* "monotonic_align/core.pyx":18
- * for x in range(max(0, t_x + y - t_y), min(t_x, y + 1)):
- * if x == y:
- * v_cur = max_neg_val # <<<<<<<<<<<<<<
- * else:
- * v_cur = value[y-1, x]
- */
- __pyx_v_v_cur = __pyx_v_max_neg_val;
-
- /* "monotonic_align/core.pyx":17
- * for y in range(t_y):
- * for x in range(max(0, t_x + y - t_y), min(t_x, y + 1)):
- * if x == y: # <<<<<<<<<<<<<<
- * v_cur = max_neg_val
- * else:
- */
- goto __pyx_L7;
- }
-
- /* "monotonic_align/core.pyx":20
- * v_cur = max_neg_val
- * else:
- * v_cur = value[y-1, x] # <<<<<<<<<<<<<<
- * if x == 0:
- * if y == 0:
- */
- /*else*/ {
- __pyx_t_9 = (__pyx_v_y - 1);
- __pyx_t_10 = __pyx_v_x;
- __pyx_v_v_cur = (*((float *) ( /* dim=1 */ ((char *) (((float *) ( /* dim=0 */ (__pyx_v_value.data + __pyx_t_9 * __pyx_v_value.strides[0]) )) + __pyx_t_10)) )));
- }
- __pyx_L7:;
-
- /* "monotonic_align/core.pyx":21
- * else:
- * v_cur = value[y-1, x]
- * if x == 0: # <<<<<<<<<<<<<<
- * if y == 0:
- * v_prev = 0.
- */
- __pyx_t_8 = ((__pyx_v_x == 0) != 0);
- if (__pyx_t_8) {
-
- /* "monotonic_align/core.pyx":22
- * v_cur = value[y-1, x]
- * if x == 0:
- * if y == 0: # <<<<<<<<<<<<<<
- * v_prev = 0.
- * else:
- */
- __pyx_t_8 = ((__pyx_v_y == 0) != 0);
- if (__pyx_t_8) {
-
- /* "monotonic_align/core.pyx":23
- * if x == 0:
- * if y == 0:
- * v_prev = 0. # <<<<<<<<<<<<<<
- * else:
- * v_prev = max_neg_val
- */
- __pyx_v_v_prev = 0.;
-
- /* "monotonic_align/core.pyx":22
- * v_cur = value[y-1, x]
- * if x == 0:
- * if y == 0: # <<<<<<<<<<<<<<
- * v_prev = 0.
- * else:
- */
- goto __pyx_L9;
- }
-
- /* "monotonic_align/core.pyx":25
- * v_prev = 0.
- * else:
- * v_prev = max_neg_val # <<<<<<<<<<<<<<
- * else:
- * v_prev = value[y-1, x-1]
- */
- /*else*/ {
- __pyx_v_v_prev = __pyx_v_max_neg_val;
- }
- __pyx_L9:;
-
- /* "monotonic_align/core.pyx":21
- * else:
- * v_cur = value[y-1, x]
- * if x == 0: # <<<<<<<<<<<<<<
- * if y == 0:
- * v_prev = 0.
- */
- goto __pyx_L8;
- }
-
- /* "monotonic_align/core.pyx":27
- * v_prev = max_neg_val
- * else:
- * v_prev = value[y-1, x-1] # <<<<<<<<<<<<<<
- * value[y, x] += max(v_prev, v_cur)
- *
- */
- /*else*/ {
- __pyx_t_10 = (__pyx_v_y - 1);
- __pyx_t_9 = (__pyx_v_x - 1);
- __pyx_v_v_prev = (*((float *) ( /* dim=1 */ ((char *) (((float *) ( /* dim=0 */ (__pyx_v_value.data + __pyx_t_10 * __pyx_v_value.strides[0]) )) + __pyx_t_9)) )));
- }
- __pyx_L8:;
-
- /* "monotonic_align/core.pyx":28
- * else:
- * v_prev = value[y-1, x-1]
- * value[y, x] += max(v_prev, v_cur) # <<<<<<<<<<<<<<
- *
- * for y in range(t_y - 1, -1, -1):
- */
- __pyx_t_11 = __pyx_v_v_cur;
- __pyx_t_12 = __pyx_v_v_prev;
- if (((__pyx_t_11 > __pyx_t_12) != 0)) {
- __pyx_t_13 = __pyx_t_11;
- } else {
- __pyx_t_13 = __pyx_t_12;
- }
- __pyx_t_9 = __pyx_v_y;
- __pyx_t_10 = __pyx_v_x;
- *((float *) ( /* dim=1 */ ((char *) (((float *) ( /* dim=0 */ (__pyx_v_value.data + __pyx_t_9 * __pyx_v_value.strides[0]) )) + __pyx_t_10)) )) += __pyx_t_13;
- }
- }
-
- /* "monotonic_align/core.pyx":30
- * value[y, x] += max(v_prev, v_cur)
- *
- * for y in range(t_y - 1, -1, -1): # <<<<<<<<<<<<<<
- * path[y, index] = 1
- * if index != 0 and (index == y or value[y-1, index] < value[y-1, index-1]):
- */
- for (__pyx_t_1 = (__pyx_v_t_y - 1); __pyx_t_1 > -1; __pyx_t_1-=1) {
- __pyx_v_y = __pyx_t_1;
-
- /* "monotonic_align/core.pyx":31
- *
- * for y in range(t_y - 1, -1, -1):
- * path[y, index] = 1 # <<<<<<<<<<<<<<
- * if index != 0 and (index == y or value[y-1, index] < value[y-1, index-1]):
- * index = index - 1
- */
- __pyx_t_10 = __pyx_v_y;
- __pyx_t_9 = __pyx_v_index;
- *((int *) ( /* dim=1 */ ((char *) (((int *) ( /* dim=0 */ (__pyx_v_path.data + __pyx_t_10 * __pyx_v_path.strides[0]) )) + __pyx_t_9)) )) = 1;
-
- /* "monotonic_align/core.pyx":32
- * for y in range(t_y - 1, -1, -1):
- * path[y, index] = 1
- * if index != 0 and (index == y or value[y-1, index] < value[y-1, index-1]): # <<<<<<<<<<<<<<
- * index = index - 1
- *
- */
- __pyx_t_14 = ((__pyx_v_index != 0) != 0);
- if (__pyx_t_14) {
- } else {
- __pyx_t_8 = __pyx_t_14;
- goto __pyx_L13_bool_binop_done;
- }
- __pyx_t_14 = ((__pyx_v_index == __pyx_v_y) != 0);
- if (!__pyx_t_14) {
- } else {
- __pyx_t_8 = __pyx_t_14;
- goto __pyx_L13_bool_binop_done;
- }
- __pyx_t_9 = (__pyx_v_y - 1);
- __pyx_t_10 = __pyx_v_index;
- __pyx_t_15 = (__pyx_v_y - 1);
- __pyx_t_16 = (__pyx_v_index - 1);
- __pyx_t_14 = (((*((float *) ( /* dim=1 */ ((char *) (((float *) ( /* dim=0 */ (__pyx_v_value.data + __pyx_t_9 * __pyx_v_value.strides[0]) )) + __pyx_t_10)) ))) < (*((float *) ( /* dim=1 */ ((char *) (((float *) ( /* dim=0 */ (__pyx_v_value.data + __pyx_t_15 * __pyx_v_value.strides[0]) )) + __pyx_t_16)) )))) != 0);
- __pyx_t_8 = __pyx_t_14;
- __pyx_L13_bool_binop_done:;
- if (__pyx_t_8) {
-
- /* "monotonic_align/core.pyx":33
- * path[y, index] = 1
- * if index != 0 and (index == y or value[y-1, index] < value[y-1, index-1]):
- * index = index - 1 # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_v_index = (__pyx_v_index - 1);
-
- /* "monotonic_align/core.pyx":32
- * for y in range(t_y - 1, -1, -1):
- * path[y, index] = 1
- * if index != 0 and (index == y or value[y-1, index] < value[y-1, index-1]): # <<<<<<<<<<<<<<
- * index = index - 1
- *
- */
- }
- }
-
- /* "monotonic_align/core.pyx":7
- * @cython.boundscheck(False)
- * @cython.wraparound(False)
- * cdef void maximum_path_each(int[:,::1] path, float[:,::1] value, int t_y, int t_x, float max_neg_val=-1e9) nogil: # <<<<<<<<<<<<<<
- * cdef int x
- * cdef int y
- */
-
- /* function exit code */
-}
-
-/* "monotonic_align/core.pyx":38
- * @cython.boundscheck(False)
- * @cython.wraparound(False)
- * cpdef void maximum_path_c(int[:,:,::1] paths, float[:,:,::1] values, int[::1] t_ys, int[::1] t_xs) nogil: # <<<<<<<<<<<<<<
- * cdef int b = paths.shape[0]
- * cdef int i
- */
-
-static PyObject *__pyx_pw_15monotonic_align_4core_1maximum_path_c(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static void __pyx_f_15monotonic_align_4core_maximum_path_c(__Pyx_memviewslice __pyx_v_paths, __Pyx_memviewslice __pyx_v_values, __Pyx_memviewslice __pyx_v_t_ys, __Pyx_memviewslice __pyx_v_t_xs, CYTHON_UNUSED int __pyx_skip_dispatch) {
- CYTHON_UNUSED int __pyx_v_b;
- int __pyx_v_i;
- int __pyx_t_1;
- int __pyx_t_2;
- int __pyx_t_3;
- __Pyx_memviewslice __pyx_t_4 = { 0, 0, { 0 }, { 0 }, { 0 } };
- __Pyx_memviewslice __pyx_t_5 = { 0, 0, { 0 }, { 0 }, { 0 } };
- Py_ssize_t __pyx_t_6;
- Py_ssize_t __pyx_t_7;
-
- /* "monotonic_align/core.pyx":39
- * @cython.wraparound(False)
- * cpdef void maximum_path_c(int[:,:,::1] paths, float[:,:,::1] values, int[::1] t_ys, int[::1] t_xs) nogil:
- * cdef int b = paths.shape[0] # <<<<<<<<<<<<<<
- * cdef int i
- * for i in prange(b, nogil=True):
- */
- __pyx_v_b = (__pyx_v_paths.shape[0]);
-
- /* "monotonic_align/core.pyx":41
- * cdef int b = paths.shape[0]
- * cdef int i
- * for i in prange(b, nogil=True): # <<<<<<<<<<<<<<
- * maximum_path_each(paths[i], values[i], t_ys[i], t_xs[i])
- */
- {
- #ifdef WITH_THREAD
- PyThreadState *_save;
- Py_UNBLOCK_THREADS
- __Pyx_FastGIL_Remember();
- #endif
- /*try:*/ {
- __pyx_t_1 = __pyx_v_b;
- if ((1 == 0)) abort();
- {
- #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))))
- #undef likely
- #undef unlikely
- #define likely(x) (x)
- #define unlikely(x) (x)
- #endif
- __pyx_t_3 = (__pyx_t_1 - 0 + 1 - 1/abs(1)) / 1;
- if (__pyx_t_3 > 0)
- {
- #ifdef _OPENMP
- #pragma omp parallel private(__pyx_t_6, __pyx_t_7) firstprivate(__pyx_t_4, __pyx_t_5)
- #endif /* _OPENMP */
- {
- #ifdef _OPENMP
- #pragma omp for firstprivate(__pyx_v_i) lastprivate(__pyx_v_i)
- #endif /* _OPENMP */
- for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_3; __pyx_t_2++){
- {
- __pyx_v_i = (int)(0 + 1 * __pyx_t_2);
-
- /* "monotonic_align/core.pyx":42
- * cdef int i
- * for i in prange(b, nogil=True):
- * maximum_path_each(paths[i], values[i], t_ys[i], t_xs[i]) # <<<<<<<<<<<<<<
- */
- __pyx_t_4.data = __pyx_v_paths.data;
- __pyx_t_4.memview = __pyx_v_paths.memview;
- __PYX_INC_MEMVIEW(&__pyx_t_4, 0);
- {
- Py_ssize_t __pyx_tmp_idx = __pyx_v_i;
- Py_ssize_t __pyx_tmp_stride = __pyx_v_paths.strides[0];
- __pyx_t_4.data += __pyx_tmp_idx * __pyx_tmp_stride;
-}
-
-__pyx_t_4.shape[0] = __pyx_v_paths.shape[1];
-__pyx_t_4.strides[0] = __pyx_v_paths.strides[1];
- __pyx_t_4.suboffsets[0] = -1;
-
-__pyx_t_4.shape[1] = __pyx_v_paths.shape[2];
-__pyx_t_4.strides[1] = __pyx_v_paths.strides[2];
- __pyx_t_4.suboffsets[1] = -1;
-
-__pyx_t_5.data = __pyx_v_values.data;
- __pyx_t_5.memview = __pyx_v_values.memview;
- __PYX_INC_MEMVIEW(&__pyx_t_5, 0);
- {
- Py_ssize_t __pyx_tmp_idx = __pyx_v_i;
- Py_ssize_t __pyx_tmp_stride = __pyx_v_values.strides[0];
- __pyx_t_5.data += __pyx_tmp_idx * __pyx_tmp_stride;
-}
-
-__pyx_t_5.shape[0] = __pyx_v_values.shape[1];
-__pyx_t_5.strides[0] = __pyx_v_values.strides[1];
- __pyx_t_5.suboffsets[0] = -1;
-
-__pyx_t_5.shape[1] = __pyx_v_values.shape[2];
-__pyx_t_5.strides[1] = __pyx_v_values.strides[2];
- __pyx_t_5.suboffsets[1] = -1;
-
-__pyx_t_6 = __pyx_v_i;
- __pyx_t_7 = __pyx_v_i;
- __pyx_f_15monotonic_align_4core_maximum_path_each(__pyx_t_4, __pyx_t_5, (*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_t_ys.data) + __pyx_t_6)) ))), (*((int *) ( /* dim=0 */ ((char *) (((int *) __pyx_v_t_xs.data) + __pyx_t_7)) ))), NULL);
- __PYX_XDEC_MEMVIEW(&__pyx_t_4, 0);
- __pyx_t_4.memview = NULL;
- __pyx_t_4.data = NULL;
- __PYX_XDEC_MEMVIEW(&__pyx_t_5, 0);
- __pyx_t_5.memview = NULL;
- __pyx_t_5.data = NULL;
- }
- }
- }
- }
- }
- #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))))
- #undef likely
- #undef unlikely
- #define likely(x) __builtin_expect(!!(x), 1)
- #define unlikely(x) __builtin_expect(!!(x), 0)
- #endif
- }
-
- /* "monotonic_align/core.pyx":41
- * cdef int b = paths.shape[0]
- * cdef int i
- * for i in prange(b, nogil=True): # <<<<<<<<<<<<<<
- * maximum_path_each(paths[i], values[i], t_ys[i], t_xs[i])
- */
- /*finally:*/ {
- /*normal exit:*/{
- #ifdef WITH_THREAD
- __Pyx_FastGIL_Forget();
- Py_BLOCK_THREADS
- #endif
- goto __pyx_L5;
- }
- __pyx_L5:;
- }
- }
-
- /* "monotonic_align/core.pyx":38
- * @cython.boundscheck(False)
- * @cython.wraparound(False)
- * cpdef void maximum_path_c(int[:,:,::1] paths, float[:,:,::1] values, int[::1] t_ys, int[::1] t_xs) nogil: # <<<<<<<<<<<<<<
- * cdef int b = paths.shape[0]
- * cdef int i
- */
-
- /* function exit code */
-}
-
-/* Python wrapper */
-static PyObject *__pyx_pw_15monotonic_align_4core_1maximum_path_c(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyObject *__pyx_pw_15monotonic_align_4core_1maximum_path_c(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- __Pyx_memviewslice __pyx_v_paths = { 0, 0, { 0 }, { 0 }, { 0 } };
- __Pyx_memviewslice __pyx_v_values = { 0, 0, { 0 }, { 0 }, { 0 } };
- __Pyx_memviewslice __pyx_v_t_ys = { 0, 0, { 0 }, { 0 }, { 0 } };
- __Pyx_memviewslice __pyx_v_t_xs = { 0, 0, { 0 }, { 0 }, { 0 } };
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("maximum_path_c (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_paths,&__pyx_n_s_values,&__pyx_n_s_t_ys,&__pyx_n_s_t_xs,0};
- PyObject* values[4] = {0,0,0,0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- CYTHON_FALLTHROUGH;
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_paths)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_values)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("maximum_path_c", 1, 4, 4, 1); __PYX_ERR(0, 38, __pyx_L3_error)
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_t_ys)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("maximum_path_c", 1, 4, 4, 2); __PYX_ERR(0, 38, __pyx_L3_error)
- }
- CYTHON_FALLTHROUGH;
- case 3:
- if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_t_xs)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("maximum_path_c", 1, 4, 4, 3); __PYX_ERR(0, 38, __pyx_L3_error)
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "maximum_path_c") < 0)) __PYX_ERR(0, 38, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- }
- __pyx_v_paths = __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_int(values[0], PyBUF_WRITABLE); if (unlikely(!__pyx_v_paths.memview)) __PYX_ERR(0, 38, __pyx_L3_error)
- __pyx_v_values = __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_float(values[1], PyBUF_WRITABLE); if (unlikely(!__pyx_v_values.memview)) __PYX_ERR(0, 38, __pyx_L3_error)
- __pyx_v_t_ys = __Pyx_PyObject_to_MemoryviewSlice_dc_int(values[2], PyBUF_WRITABLE); if (unlikely(!__pyx_v_t_ys.memview)) __PYX_ERR(0, 38, __pyx_L3_error)
- __pyx_v_t_xs = __Pyx_PyObject_to_MemoryviewSlice_dc_int(values[3], PyBUF_WRITABLE); if (unlikely(!__pyx_v_t_xs.memview)) __PYX_ERR(0, 38, __pyx_L3_error)
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("maximum_path_c", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 38, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("monotonic_align.core.maximum_path_c", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_15monotonic_align_4core_maximum_path_c(__pyx_self, __pyx_v_paths, __pyx_v_values, __pyx_v_t_ys, __pyx_v_t_xs);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_15monotonic_align_4core_maximum_path_c(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_paths, __Pyx_memviewslice __pyx_v_values, __Pyx_memviewslice __pyx_v_t_ys, __Pyx_memviewslice __pyx_v_t_xs) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("maximum_path_c", 0);
- __Pyx_XDECREF(__pyx_r);
- if (unlikely(!__pyx_v_paths.memview)) { __Pyx_RaiseUnboundLocalError("paths"); __PYX_ERR(0, 38, __pyx_L1_error) }
- if (unlikely(!__pyx_v_values.memview)) { __Pyx_RaiseUnboundLocalError("values"); __PYX_ERR(0, 38, __pyx_L1_error) }
- if (unlikely(!__pyx_v_t_ys.memview)) { __Pyx_RaiseUnboundLocalError("t_ys"); __PYX_ERR(0, 38, __pyx_L1_error) }
- if (unlikely(!__pyx_v_t_xs.memview)) { __Pyx_RaiseUnboundLocalError("t_xs"); __PYX_ERR(0, 38, __pyx_L1_error) }
- __pyx_t_1 = __Pyx_void_to_None(__pyx_f_15monotonic_align_4core_maximum_path_c(__pyx_v_paths, __pyx_v_values, __pyx_v_t_ys, __pyx_v_t_xs, 0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 38, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("monotonic_align.core.maximum_path_c", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __PYX_XDEC_MEMVIEW(&__pyx_v_paths, 1);
- __PYX_XDEC_MEMVIEW(&__pyx_v_values, 1);
- __PYX_XDEC_MEMVIEW(&__pyx_v_t_ys, 1);
- __PYX_XDEC_MEMVIEW(&__pyx_v_t_xs, 1);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":122
- * cdef bint dtype_is_object
- *
- * def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None, # <<<<<<<<<<<<<<
- * mode="c", bint allocate_buffer=True):
- *
- */
-
-/* Python wrapper */
-static int __pyx_array___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_array___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_shape = 0;
- Py_ssize_t __pyx_v_itemsize;
- PyObject *__pyx_v_format = 0;
- PyObject *__pyx_v_mode = 0;
- int __pyx_v_allocate_buffer;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_shape,&__pyx_n_s_itemsize,&__pyx_n_s_format,&__pyx_n_s_mode,&__pyx_n_s_allocate_buffer,0};
- PyObject* values[5] = {0,0,0,0,0};
- values[3] = ((PyObject *)__pyx_n_s_c);
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
- CYTHON_FALLTHROUGH;
- case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- CYTHON_FALLTHROUGH;
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_shape)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_itemsize)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, 1); __PYX_ERR(1, 122, __pyx_L3_error)
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_format)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, 2); __PYX_ERR(1, 122, __pyx_L3_error)
- }
- CYTHON_FALLTHROUGH;
- case 3:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_mode);
- if (value) { values[3] = value; kw_args--; }
- }
- CYTHON_FALLTHROUGH;
- case 4:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_allocate_buffer);
- if (value) { values[4] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(1, 122, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
- CYTHON_FALLTHROUGH;
- case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
- CYTHON_FALLTHROUGH;
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_shape = ((PyObject*)values[0]);
- __pyx_v_itemsize = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_itemsize == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 122, __pyx_L3_error)
- __pyx_v_format = values[2];
- __pyx_v_mode = values[3];
- if (values[4]) {
- __pyx_v_allocate_buffer = __Pyx_PyObject_IsTrue(values[4]); if (unlikely((__pyx_v_allocate_buffer == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 123, __pyx_L3_error)
- } else {
-
- /* "View.MemoryView":123
- *
- * def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None,
- * mode="c", bint allocate_buffer=True): # <<<<<<<<<<<<<<
- *
- * cdef int idx
- */
- __pyx_v_allocate_buffer = ((int)1);
- }
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 122, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("View.MemoryView.array.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_shape), (&PyTuple_Type), 1, "shape", 1))) __PYX_ERR(1, 122, __pyx_L1_error)
- if (unlikely(((PyObject *)__pyx_v_format) == Py_None)) {
- PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "format"); __PYX_ERR(1, 122, __pyx_L1_error)
- }
- __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(((struct __pyx_array_obj *)__pyx_v_self), __pyx_v_shape, __pyx_v_itemsize, __pyx_v_format, __pyx_v_mode, __pyx_v_allocate_buffer);
-
- /* "View.MemoryView":122
- * cdef bint dtype_is_object
- *
- * def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None, # <<<<<<<<<<<<<<
- * mode="c", bint allocate_buffer=True):
- *
- */
-
- /* function exit code */
- goto __pyx_L0;
- __pyx_L1_error:;
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_shape, Py_ssize_t __pyx_v_itemsize, PyObject *__pyx_v_format, PyObject *__pyx_v_mode, int __pyx_v_allocate_buffer) {
- int __pyx_v_idx;
- Py_ssize_t __pyx_v_i;
- Py_ssize_t __pyx_v_dim;
- PyObject **__pyx_v_p;
- char __pyx_v_order;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- Py_ssize_t __pyx_t_1;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- int __pyx_t_4;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- char *__pyx_t_7;
- int __pyx_t_8;
- Py_ssize_t __pyx_t_9;
- PyObject *__pyx_t_10 = NULL;
- Py_ssize_t __pyx_t_11;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("__cinit__", 0);
- __Pyx_INCREF(__pyx_v_format);
-
- /* "View.MemoryView":129
- * cdef PyObject **p
- *
- * self.ndim = len(shape) # <<<<<<<<<<<<<<
- * self.itemsize = itemsize
- *
- */
- if (unlikely(__pyx_v_shape == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
- __PYX_ERR(1, 129, __pyx_L1_error)
- }
- __pyx_t_1 = PyTuple_GET_SIZE(__pyx_v_shape); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(1, 129, __pyx_L1_error)
- __pyx_v_self->ndim = ((int)__pyx_t_1);
-
- /* "View.MemoryView":130
- *
- * self.ndim = len(shape)
- * self.itemsize = itemsize # <<<<<<<<<<<<<<
- *
- * if not self.ndim:
- */
- __pyx_v_self->itemsize = __pyx_v_itemsize;
-
- /* "View.MemoryView":132
- * self.itemsize = itemsize
- *
- * if not self.ndim: # <<<<<<<<<<<<<<
- * raise ValueError("Empty shape tuple for cython.array")
- *
- */
- __pyx_t_2 = ((!(__pyx_v_self->ndim != 0)) != 0);
- if (unlikely(__pyx_t_2)) {
-
- /* "View.MemoryView":133
- *
- * if not self.ndim:
- * raise ValueError("Empty shape tuple for cython.array") # <<<<<<<<<<<<<<
- *
- * if itemsize <= 0:
- */
- __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 133, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_Raise(__pyx_t_3, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __PYX_ERR(1, 133, __pyx_L1_error)
-
- /* "View.MemoryView":132
- * self.itemsize = itemsize
- *
- * if not self.ndim: # <<<<<<<<<<<<<<
- * raise ValueError("Empty shape tuple for cython.array")
- *
- */
- }
-
- /* "View.MemoryView":135
- * raise ValueError("Empty shape tuple for cython.array")
- *
- * if itemsize <= 0: # <<<<<<<<<<<<<<
- * raise ValueError("itemsize <= 0 for cython.array")
- *
- */
- __pyx_t_2 = ((__pyx_v_itemsize <= 0) != 0);
- if (unlikely(__pyx_t_2)) {
-
- /* "View.MemoryView":136
- *
- * if itemsize <= 0:
- * raise ValueError("itemsize <= 0 for cython.array") # <<<<<<<<<<<<<<
- *
- * if not isinstance(format, bytes):
- */
- __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 136, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_Raise(__pyx_t_3, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __PYX_ERR(1, 136, __pyx_L1_error)
-
- /* "View.MemoryView":135
- * raise ValueError("Empty shape tuple for cython.array")
- *
- * if itemsize <= 0: # <<<<<<<<<<<<<<
- * raise ValueError("itemsize <= 0 for cython.array")
- *
- */
- }
-
- /* "View.MemoryView":138
- * raise ValueError("itemsize <= 0 for cython.array")
- *
- * if not isinstance(format, bytes): # <<<<<<<<<<<<<<
- * format = format.encode('ASCII')
- * self._format = format # keep a reference to the byte string
- */
- __pyx_t_2 = PyBytes_Check(__pyx_v_format);
- __pyx_t_4 = ((!(__pyx_t_2 != 0)) != 0);
- if (__pyx_t_4) {
-
- /* "View.MemoryView":139
- *
- * if not isinstance(format, bytes):
- * format = format.encode('ASCII') # <<<<<<<<<<<<<<
- * self._format = format # keep a reference to the byte string
- * self.format = self._format
- */
- __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_format, __pyx_n_s_encode); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 139, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __pyx_t_6 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
- __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
- if (likely(__pyx_t_6)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
- __Pyx_INCREF(__pyx_t_6);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_5, function);
- }
- }
- __pyx_t_3 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_n_s_ASCII) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_n_s_ASCII);
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 139, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_DECREF_SET(__pyx_v_format, __pyx_t_3);
- __pyx_t_3 = 0;
-
- /* "View.MemoryView":138
- * raise ValueError("itemsize <= 0 for cython.array")
- *
- * if not isinstance(format, bytes): # <<<<<<<<<<<<<<
- * format = format.encode('ASCII')
- * self._format = format # keep a reference to the byte string
- */
- }
-
- /* "View.MemoryView":140
- * if not isinstance(format, bytes):
- * format = format.encode('ASCII')
- * self._format = format # keep a reference to the byte string # <<<<<<<<<<<<<<
- * self.format = self._format
- *
- */
- if (!(likely(PyBytes_CheckExact(__pyx_v_format))||((__pyx_v_format) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_v_format)->tp_name), 0))) __PYX_ERR(1, 140, __pyx_L1_error)
- __pyx_t_3 = __pyx_v_format;
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_3);
- __Pyx_GOTREF(__pyx_v_self->_format);
- __Pyx_DECREF(__pyx_v_self->_format);
- __pyx_v_self->_format = ((PyObject*)__pyx_t_3);
- __pyx_t_3 = 0;
-
- /* "View.MemoryView":141
- * format = format.encode('ASCII')
- * self._format = format # keep a reference to the byte string
- * self.format = self._format # <<<<<<<<<<<<<<
- *
- *
- */
- if (unlikely(__pyx_v_self->_format == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
- __PYX_ERR(1, 141, __pyx_L1_error)
- }
- __pyx_t_7 = __Pyx_PyBytes_AsWritableString(__pyx_v_self->_format); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) __PYX_ERR(1, 141, __pyx_L1_error)
- __pyx_v_self->format = __pyx_t_7;
-
- /* "View.MemoryView":144
- *
- *
- * self._shape = PyObject_Malloc(sizeof(Py_ssize_t)*self.ndim*2) # <<<<<<<<<<<<<<
- * self._strides = self._shape + self.ndim
- *
- */
- __pyx_v_self->_shape = ((Py_ssize_t *)PyObject_Malloc((((sizeof(Py_ssize_t)) * __pyx_v_self->ndim) * 2)));
-
- /* "View.MemoryView":145
- *
- * self._shape = PyObject_Malloc(sizeof(Py_ssize_t)*self.ndim*2)
- * self._strides = self._shape + self.ndim # <<<<<<<<<<<<<<
- *
- * if not self._shape:
- */
- __pyx_v_self->_strides = (__pyx_v_self->_shape + __pyx_v_self->ndim);
-
- /* "View.MemoryView":147
- * self._strides = self._shape + self.ndim
- *
- * if not self._shape: # <<<<<<<<<<<<<<
- * raise MemoryError("unable to allocate shape and strides.")
- *
- */
- __pyx_t_4 = ((!(__pyx_v_self->_shape != 0)) != 0);
- if (unlikely(__pyx_t_4)) {
-
- /* "View.MemoryView":148
- *
- * if not self._shape:
- * raise MemoryError("unable to allocate shape and strides.") # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 148, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_Raise(__pyx_t_3, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __PYX_ERR(1, 148, __pyx_L1_error)
-
- /* "View.MemoryView":147
- * self._strides = self._shape + self.ndim
- *
- * if not self._shape: # <<<<<<<<<<<<<<
- * raise MemoryError("unable to allocate shape and strides.")
- *
- */
- }
-
- /* "View.MemoryView":151
- *
- *
- * for idx, dim in enumerate(shape): # <<<<<<<<<<<<<<
- * if dim <= 0:
- * raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
- */
- __pyx_t_8 = 0;
- __pyx_t_3 = __pyx_v_shape; __Pyx_INCREF(__pyx_t_3); __pyx_t_1 = 0;
- for (;;) {
- if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_5); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(1, 151, __pyx_L1_error)
- #else
- __pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 151, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- #endif
- __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_t_5); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 151, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __pyx_v_dim = __pyx_t_9;
- __pyx_v_idx = __pyx_t_8;
- __pyx_t_8 = (__pyx_t_8 + 1);
-
- /* "View.MemoryView":152
- *
- * for idx, dim in enumerate(shape):
- * if dim <= 0: # <<<<<<<<<<<<<<
- * raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
- * self._shape[idx] = dim
- */
- __pyx_t_4 = ((__pyx_v_dim <= 0) != 0);
- if (unlikely(__pyx_t_4)) {
-
- /* "View.MemoryView":153
- * for idx, dim in enumerate(shape):
- * if dim <= 0:
- * raise ValueError("Invalid shape in axis %d: %d." % (idx, dim)) # <<<<<<<<<<<<<<
- * self._shape[idx] = dim
- *
- */
- __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_idx); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 153, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 153, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 153, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_10);
- __Pyx_GIVEREF(__pyx_t_5);
- PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_5);
- __Pyx_GIVEREF(__pyx_t_6);
- PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_6);
- __pyx_t_5 = 0;
- __pyx_t_6 = 0;
- __pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_shape_in_axis_d_d, __pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 153, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
- __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_6); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 153, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_10);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_Raise(__pyx_t_10, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
- __PYX_ERR(1, 153, __pyx_L1_error)
-
- /* "View.MemoryView":152
- *
- * for idx, dim in enumerate(shape):
- * if dim <= 0: # <<<<<<<<<<<<<<
- * raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
- * self._shape[idx] = dim
- */
- }
-
- /* "View.MemoryView":154
- * if dim <= 0:
- * raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
- * self._shape[idx] = dim # <<<<<<<<<<<<<<
- *
- * cdef char order
- */
- (__pyx_v_self->_shape[__pyx_v_idx]) = __pyx_v_dim;
-
- /* "View.MemoryView":151
- *
- *
- * for idx, dim in enumerate(shape): # <<<<<<<<<<<<<<
- * if dim <= 0:
- * raise ValueError("Invalid shape in axis %d: %d." % (idx, dim))
- */
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "View.MemoryView":157
- *
- * cdef char order
- * if mode == 'fortran': # <<<<<<<<<<<<<<
- * order = b'F'
- * self.mode = u'fortran'
- */
- __pyx_t_4 = (__Pyx_PyString_Equals(__pyx_v_mode, __pyx_n_s_fortran, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(1, 157, __pyx_L1_error)
- if (__pyx_t_4) {
-
- /* "View.MemoryView":158
- * cdef char order
- * if mode == 'fortran':
- * order = b'F' # <<<<<<<<<<<<<<
- * self.mode = u'fortran'
- * elif mode == 'c':
- */
- __pyx_v_order = 'F';
-
- /* "View.MemoryView":159
- * if mode == 'fortran':
- * order = b'F'
- * self.mode = u'fortran' # <<<<<<<<<<<<<<
- * elif mode == 'c':
- * order = b'C'
- */
- __Pyx_INCREF(__pyx_n_u_fortran);
- __Pyx_GIVEREF(__pyx_n_u_fortran);
- __Pyx_GOTREF(__pyx_v_self->mode);
- __Pyx_DECREF(__pyx_v_self->mode);
- __pyx_v_self->mode = __pyx_n_u_fortran;
-
- /* "View.MemoryView":157
- *
- * cdef char order
- * if mode == 'fortran': # <<<<<<<<<<<<<<
- * order = b'F'
- * self.mode = u'fortran'
- */
- goto __pyx_L10;
- }
-
- /* "View.MemoryView":160
- * order = b'F'
- * self.mode = u'fortran'
- * elif mode == 'c': # <<<<<<<<<<<<<<
- * order = b'C'
- * self.mode = u'c'
- */
- __pyx_t_4 = (__Pyx_PyString_Equals(__pyx_v_mode, __pyx_n_s_c, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(1, 160, __pyx_L1_error)
- if (likely(__pyx_t_4)) {
-
- /* "View.MemoryView":161
- * self.mode = u'fortran'
- * elif mode == 'c':
- * order = b'C' # <<<<<<<<<<<<<<
- * self.mode = u'c'
- * else:
- */
- __pyx_v_order = 'C';
-
- /* "View.MemoryView":162
- * elif mode == 'c':
- * order = b'C'
- * self.mode = u'c' # <<<<<<<<<<<<<<
- * else:
- * raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode)
- */
- __Pyx_INCREF(__pyx_n_u_c);
- __Pyx_GIVEREF(__pyx_n_u_c);
- __Pyx_GOTREF(__pyx_v_self->mode);
- __Pyx_DECREF(__pyx_v_self->mode);
- __pyx_v_self->mode = __pyx_n_u_c;
-
- /* "View.MemoryView":160
- * order = b'F'
- * self.mode = u'fortran'
- * elif mode == 'c': # <<<<<<<<<<<<<<
- * order = b'C'
- * self.mode = u'c'
- */
- goto __pyx_L10;
- }
-
- /* "View.MemoryView":164
- * self.mode = u'c'
- * else:
- * raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode) # <<<<<<<<<<<<<<
- *
- * self.len = fill_contig_strides_array(self._shape, self._strides,
- */
- /*else*/ {
- __pyx_t_3 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Invalid_mode_expected_c_or_fortr, __pyx_v_mode); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 164, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 164, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_10);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_Raise(__pyx_t_10, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
- __PYX_ERR(1, 164, __pyx_L1_error)
- }
- __pyx_L10:;
-
- /* "View.MemoryView":166
- * raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode)
- *
- * self.len = fill_contig_strides_array(self._shape, self._strides, # <<<<<<<<<<<<<<
- * itemsize, self.ndim, order)
- *
- */
- __pyx_v_self->len = __pyx_fill_contig_strides_array(__pyx_v_self->_shape, __pyx_v_self->_strides, __pyx_v_itemsize, __pyx_v_self->ndim, __pyx_v_order);
-
- /* "View.MemoryView":169
- * itemsize, self.ndim, order)
- *
- * self.free_data = allocate_buffer # <<<<<<<<<<<<<<
- * self.dtype_is_object = format == b'O'
- * if allocate_buffer:
- */
- __pyx_v_self->free_data = __pyx_v_allocate_buffer;
-
- /* "View.MemoryView":170
- *
- * self.free_data = allocate_buffer
- * self.dtype_is_object = format == b'O' # <<<<<<<<<<<<<<
- * if allocate_buffer:
- *
- */
- __pyx_t_10 = PyObject_RichCompare(__pyx_v_format, __pyx_n_b_O, Py_EQ); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 170, __pyx_L1_error)
- __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 170, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
- __pyx_v_self->dtype_is_object = __pyx_t_4;
-
- /* "View.MemoryView":171
- * self.free_data = allocate_buffer
- * self.dtype_is_object = format == b'O'
- * if allocate_buffer: # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_4 = (__pyx_v_allocate_buffer != 0);
- if (__pyx_t_4) {
-
- /* "View.MemoryView":174
- *
- *
- * self.data = malloc(self.len) # <<<<<<<<<<<<<<
- * if not self.data:
- * raise MemoryError("unable to allocate array data.")
- */
- __pyx_v_self->data = ((char *)malloc(__pyx_v_self->len));
-
- /* "View.MemoryView":175
- *
- * self.data = malloc(self.len)
- * if not self.data: # <<<<<<<<<<<<<<
- * raise MemoryError("unable to allocate array data.")
- *
- */
- __pyx_t_4 = ((!(__pyx_v_self->data != 0)) != 0);
- if (unlikely(__pyx_t_4)) {
-
- /* "View.MemoryView":176
- * self.data = malloc(self.len)
- * if not self.data:
- * raise MemoryError("unable to allocate array data.") # <<<<<<<<<<<<<<
- *
- * if self.dtype_is_object:
- */
- __pyx_t_10 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 176, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_10);
- __Pyx_Raise(__pyx_t_10, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
- __PYX_ERR(1, 176, __pyx_L1_error)
-
- /* "View.MemoryView":175
- *
- * self.data = malloc(self.len)
- * if not self.data: # <<<<<<<<<<<<<<
- * raise MemoryError("unable to allocate array data.")
- *
- */
- }
-
- /* "View.MemoryView":178
- * raise MemoryError("unable to allocate array data.")
- *
- * if self.dtype_is_object: # <<<<<<<<<<<<<<
- * p = self.data
- * for i in range(self.len / itemsize):
- */
- __pyx_t_4 = (__pyx_v_self->dtype_is_object != 0);
- if (__pyx_t_4) {
-
- /* "View.MemoryView":179
- *
- * if self.dtype_is_object:
- * p = self.data # <<<<<<<<<<<<<<
- * for i in range(self.len / itemsize):
- * p[i] = Py_None
- */
- __pyx_v_p = ((PyObject **)__pyx_v_self->data);
-
- /* "View.MemoryView":180
- * if self.dtype_is_object:
- * p = self.data
- * for i in range(self.len / itemsize): # <<<<<<<<<<<<<<
- * p[i] = Py_None
- * Py_INCREF(Py_None)
- */
- if (unlikely(__pyx_v_itemsize == 0)) {
- PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
- __PYX_ERR(1, 180, __pyx_L1_error)
- }
- else if (sizeof(Py_ssize_t) == sizeof(long) && (!(((Py_ssize_t)-1) > 0)) && unlikely(__pyx_v_itemsize == (Py_ssize_t)-1) && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_v_self->len))) {
- PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
- __PYX_ERR(1, 180, __pyx_L1_error)
- }
- __pyx_t_1 = __Pyx_div_Py_ssize_t(__pyx_v_self->len, __pyx_v_itemsize);
- __pyx_t_9 = __pyx_t_1;
- for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_9; __pyx_t_11+=1) {
- __pyx_v_i = __pyx_t_11;
-
- /* "View.MemoryView":181
- * p = self.data
- * for i in range(self.len / itemsize):
- * p[i] = Py_None # <<<<<<<<<<<<<<
- * Py_INCREF(Py_None)
- *
- */
- (__pyx_v_p[__pyx_v_i]) = Py_None;
-
- /* "View.MemoryView":182
- * for i in range(self.len / itemsize):
- * p[i] = Py_None
- * Py_INCREF(Py_None) # <<<<<<<<<<<<<<
- *
- * @cname('getbuffer')
- */
- Py_INCREF(Py_None);
- }
-
- /* "View.MemoryView":178
- * raise MemoryError("unable to allocate array data.")
- *
- * if self.dtype_is_object: # <<<<<<<<<<<<<<
- * p = self.data
- * for i in range(self.len / itemsize):
- */
- }
-
- /* "View.MemoryView":171
- * self.free_data = allocate_buffer
- * self.dtype_is_object = format == b'O'
- * if allocate_buffer: # <<<<<<<<<<<<<<
- *
- *
- */
- }
-
- /* "View.MemoryView":122
- * cdef bint dtype_is_object
- *
- * def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None, # <<<<<<<<<<<<<<
- * mode="c", bint allocate_buffer=True):
- *
- */
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_10);
- __Pyx_AddTraceback("View.MemoryView.array.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_format);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":185
- *
- * @cname('getbuffer')
- * def __getbuffer__(self, Py_buffer *info, int flags): # <<<<<<<<<<<<<<
- * cdef int bufmode = -1
- * if self.mode == u"c":
- */
-
-/* Python wrapper */
-static CYTHON_UNUSED int __pyx_array_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
-static CYTHON_UNUSED int __pyx_array_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0);
- __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_2__getbuffer__(((struct __pyx_array_obj *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array_2__getbuffer__(struct __pyx_array_obj *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
- int __pyx_v_bufmode;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- char *__pyx_t_4;
- Py_ssize_t __pyx_t_5;
- int __pyx_t_6;
- Py_ssize_t *__pyx_t_7;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- if (__pyx_v_info == NULL) {
- PyErr_SetString(PyExc_BufferError, "PyObject_GetBuffer: view==NULL argument is obsolete");
- return -1;
- }
- __Pyx_RefNannySetupContext("__getbuffer__", 0);
- __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(__pyx_v_info->obj);
-
- /* "View.MemoryView":186
- * @cname('getbuffer')
- * def __getbuffer__(self, Py_buffer *info, int flags):
- * cdef int bufmode = -1 # <<<<<<<<<<<<<<
- * if self.mode == u"c":
- * bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
- */
- __pyx_v_bufmode = -1;
-
- /* "View.MemoryView":187
- * def __getbuffer__(self, Py_buffer *info, int flags):
- * cdef int bufmode = -1
- * if self.mode == u"c": # <<<<<<<<<<<<<<
- * bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
- * elif self.mode == u"fortran":
- */
- __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_v_self->mode, __pyx_n_u_c, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 187, __pyx_L1_error)
- __pyx_t_2 = (__pyx_t_1 != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":188
- * cdef int bufmode = -1
- * if self.mode == u"c":
- * bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS # <<<<<<<<<<<<<<
- * elif self.mode == u"fortran":
- * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
- */
- __pyx_v_bufmode = (PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS);
-
- /* "View.MemoryView":187
- * def __getbuffer__(self, Py_buffer *info, int flags):
- * cdef int bufmode = -1
- * if self.mode == u"c": # <<<<<<<<<<<<<<
- * bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
- * elif self.mode == u"fortran":
- */
- goto __pyx_L3;
- }
-
- /* "View.MemoryView":189
- * if self.mode == u"c":
- * bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
- * elif self.mode == u"fortran": # <<<<<<<<<<<<<<
- * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
- * if not (flags & bufmode):
- */
- __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_v_self->mode, __pyx_n_u_fortran, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 189, __pyx_L1_error)
- __pyx_t_1 = (__pyx_t_2 != 0);
- if (__pyx_t_1) {
-
- /* "View.MemoryView":190
- * bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
- * elif self.mode == u"fortran":
- * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS # <<<<<<<<<<<<<<
- * if not (flags & bufmode):
- * raise ValueError("Can only create a buffer that is contiguous in memory.")
- */
- __pyx_v_bufmode = (PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS);
-
- /* "View.MemoryView":189
- * if self.mode == u"c":
- * bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
- * elif self.mode == u"fortran": # <<<<<<<<<<<<<<
- * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
- * if not (flags & bufmode):
- */
- }
- __pyx_L3:;
-
- /* "View.MemoryView":191
- * elif self.mode == u"fortran":
- * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
- * if not (flags & bufmode): # <<<<<<<<<<<<<<
- * raise ValueError("Can only create a buffer that is contiguous in memory.")
- * info.buf = self.data
- */
- __pyx_t_1 = ((!((__pyx_v_flags & __pyx_v_bufmode) != 0)) != 0);
- if (unlikely(__pyx_t_1)) {
-
- /* "View.MemoryView":192
- * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
- * if not (flags & bufmode):
- * raise ValueError("Can only create a buffer that is contiguous in memory.") # <<<<<<<<<<<<<<
- * info.buf = self.data
- * info.len = self.len
- */
- __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 192, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_Raise(__pyx_t_3, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __PYX_ERR(1, 192, __pyx_L1_error)
-
- /* "View.MemoryView":191
- * elif self.mode == u"fortran":
- * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
- * if not (flags & bufmode): # <<<<<<<<<<<<<<
- * raise ValueError("Can only create a buffer that is contiguous in memory.")
- * info.buf = self.data
- */
- }
-
- /* "View.MemoryView":193
- * if not (flags & bufmode):
- * raise ValueError("Can only create a buffer that is contiguous in memory.")
- * info.buf = self.data # <<<<<<<<<<<<<<
- * info.len = self.len
- * info.ndim = self.ndim
- */
- __pyx_t_4 = __pyx_v_self->data;
- __pyx_v_info->buf = __pyx_t_4;
-
- /* "View.MemoryView":194
- * raise ValueError("Can only create a buffer that is contiguous in memory.")
- * info.buf = self.data
- * info.len = self.len # <<<<<<<<<<<<<<
- * info.ndim = self.ndim
- * info.shape = self._shape
- */
- __pyx_t_5 = __pyx_v_self->len;
- __pyx_v_info->len = __pyx_t_5;
-
- /* "View.MemoryView":195
- * info.buf = self.data
- * info.len = self.len
- * info.ndim = self.ndim # <<<<<<<<<<<<<<
- * info.shape = self._shape
- * info.strides = self._strides
- */
- __pyx_t_6 = __pyx_v_self->ndim;
- __pyx_v_info->ndim = __pyx_t_6;
-
- /* "View.MemoryView":196
- * info.len = self.len
- * info.ndim = self.ndim
- * info.shape = self._shape # <<<<<<<<<<<<<<
- * info.strides = self._strides
- * info.suboffsets = NULL
- */
- __pyx_t_7 = __pyx_v_self->_shape;
- __pyx_v_info->shape = __pyx_t_7;
-
- /* "View.MemoryView":197
- * info.ndim = self.ndim
- * info.shape = self._shape
- * info.strides = self._strides # <<<<<<<<<<<<<<
- * info.suboffsets = NULL
- * info.itemsize = self.itemsize
- */
- __pyx_t_7 = __pyx_v_self->_strides;
- __pyx_v_info->strides = __pyx_t_7;
-
- /* "View.MemoryView":198
- * info.shape = self._shape
- * info.strides = self._strides
- * info.suboffsets = NULL # <<<<<<<<<<<<<<
- * info.itemsize = self.itemsize
- * info.readonly = 0
- */
- __pyx_v_info->suboffsets = NULL;
-
- /* "View.MemoryView":199
- * info.strides = self._strides
- * info.suboffsets = NULL
- * info.itemsize = self.itemsize # <<<<<<<<<<<<<<
- * info.readonly = 0
- *
- */
- __pyx_t_5 = __pyx_v_self->itemsize;
- __pyx_v_info->itemsize = __pyx_t_5;
-
- /* "View.MemoryView":200
- * info.suboffsets = NULL
- * info.itemsize = self.itemsize
- * info.readonly = 0 # <<<<<<<<<<<<<<
- *
- * if flags & PyBUF_FORMAT:
- */
- __pyx_v_info->readonly = 0;
-
- /* "View.MemoryView":202
- * info.readonly = 0
- *
- * if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<<
- * info.format = self.format
- * else:
- */
- __pyx_t_1 = ((__pyx_v_flags & PyBUF_FORMAT) != 0);
- if (__pyx_t_1) {
-
- /* "View.MemoryView":203
- *
- * if flags & PyBUF_FORMAT:
- * info.format = self.format # <<<<<<<<<<<<<<
- * else:
- * info.format = NULL
- */
- __pyx_t_4 = __pyx_v_self->format;
- __pyx_v_info->format = __pyx_t_4;
-
- /* "View.MemoryView":202
- * info.readonly = 0
- *
- * if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<<
- * info.format = self.format
- * else:
- */
- goto __pyx_L5;
- }
-
- /* "View.MemoryView":205
- * info.format = self.format
- * else:
- * info.format = NULL # <<<<<<<<<<<<<<
- *
- * info.obj = self
- */
- /*else*/ {
- __pyx_v_info->format = NULL;
- }
- __pyx_L5:;
-
- /* "View.MemoryView":207
- * info.format = NULL
- *
- * info.obj = self # <<<<<<<<<<<<<<
- *
- * __pyx_getbuffer = capsule( &__pyx_array_getbuffer, "getbuffer(obj, view, flags)")
- */
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- __Pyx_GOTREF(__pyx_v_info->obj);
- __Pyx_DECREF(__pyx_v_info->obj);
- __pyx_v_info->obj = ((PyObject *)__pyx_v_self);
-
- /* "View.MemoryView":185
- *
- * @cname('getbuffer')
- * def __getbuffer__(self, Py_buffer *info, int flags): # <<<<<<<<<<<<<<
- * cdef int bufmode = -1
- * if self.mode == u"c":
- */
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("View.MemoryView.array.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- if (__pyx_v_info->obj != NULL) {
- __Pyx_GOTREF(__pyx_v_info->obj);
- __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0;
- }
- goto __pyx_L2;
- __pyx_L0:;
- if (__pyx_v_info->obj == Py_None) {
- __Pyx_GOTREF(__pyx_v_info->obj);
- __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0;
- }
- __pyx_L2:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":211
- * __pyx_getbuffer = capsule( &__pyx_array_getbuffer, "getbuffer(obj, view, flags)")
- *
- * def __dealloc__(array self): # <<<<<<<<<<<<<<
- * if self.callback_free_data != NULL:
- * self.callback_free_data(self.data)
- */
-
-/* Python wrapper */
-static void __pyx_array___dealloc__(PyObject *__pyx_v_self); /*proto*/
-static void __pyx_array___dealloc__(PyObject *__pyx_v_self) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
- __pyx_array___pyx_pf_15View_dot_MemoryView_5array_4__dealloc__(((struct __pyx_array_obj *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
-}
-
-static void __pyx_array___pyx_pf_15View_dot_MemoryView_5array_4__dealloc__(struct __pyx_array_obj *__pyx_v_self) {
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- __Pyx_RefNannySetupContext("__dealloc__", 0);
-
- /* "View.MemoryView":212
- *
- * def __dealloc__(array self):
- * if self.callback_free_data != NULL: # <<<<<<<<<<<<<<
- * self.callback_free_data(self.data)
- * elif self.free_data:
- */
- __pyx_t_1 = ((__pyx_v_self->callback_free_data != NULL) != 0);
- if (__pyx_t_1) {
-
- /* "View.MemoryView":213
- * def __dealloc__(array self):
- * if self.callback_free_data != NULL:
- * self.callback_free_data(self.data) # <<<<<<<<<<<<<<
- * elif self.free_data:
- * if self.dtype_is_object:
- */
- __pyx_v_self->callback_free_data(__pyx_v_self->data);
-
- /* "View.MemoryView":212
- *
- * def __dealloc__(array self):
- * if self.callback_free_data != NULL: # <<<<<<<<<<<<<<
- * self.callback_free_data(self.data)
- * elif self.free_data:
- */
- goto __pyx_L3;
- }
-
- /* "View.MemoryView":214
- * if self.callback_free_data != NULL:
- * self.callback_free_data(self.data)
- * elif self.free_data: # <<<<<<<<<<<<<<
- * if self.dtype_is_object:
- * refcount_objects_in_slice(self.data, self._shape,
- */
- __pyx_t_1 = (__pyx_v_self->free_data != 0);
- if (__pyx_t_1) {
-
- /* "View.MemoryView":215
- * self.callback_free_data(self.data)
- * elif self.free_data:
- * if self.dtype_is_object: # <<<<<<<<<<<<<<
- * refcount_objects_in_slice(self.data, self._shape,
- * self._strides, self.ndim, False)
- */
- __pyx_t_1 = (__pyx_v_self->dtype_is_object != 0);
- if (__pyx_t_1) {
-
- /* "View.MemoryView":216
- * elif self.free_data:
- * if self.dtype_is_object:
- * refcount_objects_in_slice(self.data, self._shape, # <<<<<<<<<<<<<<
- * self._strides, self.ndim, False)
- * free(self.data)
- */
- __pyx_memoryview_refcount_objects_in_slice(__pyx_v_self->data, __pyx_v_self->_shape, __pyx_v_self->_strides, __pyx_v_self->ndim, 0);
-
- /* "View.MemoryView":215
- * self.callback_free_data(self.data)
- * elif self.free_data:
- * if self.dtype_is_object: # <<<<<<<<<<<<<<
- * refcount_objects_in_slice(self.data, self._shape,
- * self._strides, self.ndim, False)
- */
- }
-
- /* "View.MemoryView":218
- * refcount_objects_in_slice(self.data, self._shape,
- * self._strides, self.ndim, False)
- * free(self.data) # <<<<<<<<<<<<<<
- * PyObject_Free(self._shape)
- *
- */
- free(__pyx_v_self->data);
-
- /* "View.MemoryView":214
- * if self.callback_free_data != NULL:
- * self.callback_free_data(self.data)
- * elif self.free_data: # <<<<<<<<<<<<<<
- * if self.dtype_is_object:
- * refcount_objects_in_slice(self.data, self._shape,
- */
- }
- __pyx_L3:;
-
- /* "View.MemoryView":219
- * self._strides, self.ndim, False)
- * free(self.data)
- * PyObject_Free(self._shape) # <<<<<<<<<<<<<<
- *
- * @property
- */
- PyObject_Free(__pyx_v_self->_shape);
-
- /* "View.MemoryView":211
- * __pyx_getbuffer = capsule( &__pyx_array_getbuffer, "getbuffer(obj, view, flags)")
- *
- * def __dealloc__(array self): # <<<<<<<<<<<<<<
- * if self.callback_free_data != NULL:
- * self.callback_free_data(self.data)
- */
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
-}
-
-/* "View.MemoryView":222
- *
- * @property
- * def memview(self): # <<<<<<<<<<<<<<
- * return self.get_memview()
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_15View_dot_MemoryView_5array_7memview_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_15View_dot_MemoryView_5array_7memview_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_15View_dot_MemoryView_5array_7memview___get__(((struct __pyx_array_obj *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_15View_dot_MemoryView_5array_7memview___get__(struct __pyx_array_obj *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("__get__", 0);
-
- /* "View.MemoryView":223
- * @property
- * def memview(self):
- * return self.get_memview() # <<<<<<<<<<<<<<
- *
- * @cname('get_memview')
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = ((struct __pyx_vtabstruct_array *)__pyx_v_self->__pyx_vtab)->get_memview(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 223, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "View.MemoryView":222
- *
- * @property
- * def memview(self): # <<<<<<<<<<<<<<
- * return self.get_memview()
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("View.MemoryView.array.memview.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":226
- *
- * @cname('get_memview')
- * cdef get_memview(self): # <<<<<<<<<<<<<<
- * flags = PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE
- * return memoryview(self, flags, self.dtype_is_object)
- */
-
-static PyObject *__pyx_array_get_memview(struct __pyx_array_obj *__pyx_v_self) {
- int __pyx_v_flags;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("get_memview", 0);
-
- /* "View.MemoryView":227
- * @cname('get_memview')
- * cdef get_memview(self):
- * flags = PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE # <<<<<<<<<<<<<<
- * return memoryview(self, flags, self.dtype_is_object)
- *
- */
- __pyx_v_flags = ((PyBUF_ANY_CONTIGUOUS | PyBUF_FORMAT) | PyBUF_WRITABLE);
-
- /* "View.MemoryView":228
- * cdef get_memview(self):
- * flags = PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE
- * return memoryview(self, flags, self.dtype_is_object) # <<<<<<<<<<<<<<
- *
- * def __len__(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 228, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_self->dtype_is_object); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 228, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 228, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2);
- __pyx_t_1 = 0;
- __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_memoryview_type), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 228, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
- /* "View.MemoryView":226
- *
- * @cname('get_memview')
- * cdef get_memview(self): # <<<<<<<<<<<<<<
- * flags = PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE
- * return memoryview(self, flags, self.dtype_is_object)
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("View.MemoryView.array.get_memview", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":230
- * return memoryview(self, flags, self.dtype_is_object)
- *
- * def __len__(self): # <<<<<<<<<<<<<<
- * return self._shape[0]
- *
- */
-
-/* Python wrapper */
-static Py_ssize_t __pyx_array___len__(PyObject *__pyx_v_self); /*proto*/
-static Py_ssize_t __pyx_array___len__(PyObject *__pyx_v_self) {
- Py_ssize_t __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
- __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__len__(((struct __pyx_array_obj *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static Py_ssize_t __pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__len__(struct __pyx_array_obj *__pyx_v_self) {
- Py_ssize_t __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__len__", 0);
-
- /* "View.MemoryView":231
- *
- * def __len__(self):
- * return self._shape[0] # <<<<<<<<<<<<<<
- *
- * def __getattr__(self, attr):
- */
- __pyx_r = (__pyx_v_self->_shape[0]);
- goto __pyx_L0;
-
- /* "View.MemoryView":230
- * return memoryview(self, flags, self.dtype_is_object)
- *
- * def __len__(self): # <<<<<<<<<<<<<<
- * return self._shape[0]
- *
- */
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":233
- * return self._shape[0]
- *
- * def __getattr__(self, attr): # <<<<<<<<<<<<<<
- * return getattr(self.memview, attr)
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_array___getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_attr); /*proto*/
-static PyObject *__pyx_array___getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_attr) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__getattr__ (wrapper)", 0);
- __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getattr__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v_attr));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getattr__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_attr) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("__getattr__", 0);
-
- /* "View.MemoryView":234
- *
- * def __getattr__(self, attr):
- * return getattr(self.memview, attr) # <<<<<<<<<<<<<<
- *
- * def __getitem__(self, item):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_memview); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 234, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_GetAttr(__pyx_t_1, __pyx_v_attr); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 234, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
- /* "View.MemoryView":233
- * return self._shape[0]
- *
- * def __getattr__(self, attr): # <<<<<<<<<<<<<<
- * return getattr(self.memview, attr)
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("View.MemoryView.array.__getattr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":236
- * return getattr(self.memview, attr)
- *
- * def __getitem__(self, item): # <<<<<<<<<<<<<<
- * return self.memview[item]
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_array___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item); /*proto*/
-static PyObject *__pyx_array___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
- __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__getitem__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v_item));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__getitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("__getitem__", 0);
-
- /* "View.MemoryView":237
- *
- * def __getitem__(self, item):
- * return self.memview[item] # <<<<<<<<<<<<<<
- *
- * def __setitem__(self, item, value):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_memview); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 237, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_v_item); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 237, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
- /* "View.MemoryView":236
- * return getattr(self.memview, attr)
- *
- * def __getitem__(self, item): # <<<<<<<<<<<<<<
- * return self.memview[item]
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("View.MemoryView.array.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":239
- * return self.memview[item]
- *
- * def __setitem__(self, item, value): # <<<<<<<<<<<<<<
- * self.memview[item] = value
- *
- */
-
-/* Python wrapper */
-static int __pyx_array___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value); /*proto*/
-static int __pyx_array___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0);
- __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_12__setitem__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v_item), ((PyObject *)__pyx_v_value));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array_12__setitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("__setitem__", 0);
-
- /* "View.MemoryView":240
- *
- * def __setitem__(self, item, value):
- * self.memview[item] = value # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_memview); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 240, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_v_item, __pyx_v_value) < 0)) __PYX_ERR(1, 240, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "View.MemoryView":239
- * return self.memview[item]
- *
- * def __setitem__(self, item, value): # <<<<<<<<<<<<<<
- * self.memview[item] = value
- *
- */
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("View.MemoryView.array.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "(tree fragment)":1
- * def __reduce_cython__(self): # <<<<<<<<<<<<<<
- * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
- * def __setstate_cython__(self, __pyx_state):
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw___pyx_array_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_pw___pyx_array_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
- __pyx_r = __pyx_pf___pyx_array___reduce_cython__(((struct __pyx_array_obj *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf___pyx_array___reduce_cython__(CYTHON_UNUSED struct __pyx_array_obj *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("__reduce_cython__", 0);
-
- /* "(tree fragment)":2
- * def __reduce_cython__(self):
- * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
- * def __setstate_cython__(self, __pyx_state):
- * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
- */
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_Raise(__pyx_t_1, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __PYX_ERR(1, 2, __pyx_L1_error)
-
- /* "(tree fragment)":1
- * def __reduce_cython__(self): # <<<<<<<<<<<<<<
- * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
- * def __setstate_cython__(self, __pyx_state):
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("View.MemoryView.array.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "(tree fragment)":3
- * def __reduce_cython__(self):
- * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
- * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
- * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw___pyx_array_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
-static PyObject *__pyx_pw___pyx_array_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
- __pyx_r = __pyx_pf___pyx_array_2__setstate_cython__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf___pyx_array_2__setstate_cython__(CYTHON_UNUSED struct __pyx_array_obj *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("__setstate_cython__", 0);
-
- /* "(tree fragment)":4
- * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
- * def __setstate_cython__(self, __pyx_state):
- * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
- */
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_Raise(__pyx_t_1, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __PYX_ERR(1, 4, __pyx_L1_error)
-
- /* "(tree fragment)":3
- * def __reduce_cython__(self):
- * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
- * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
- * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("View.MemoryView.array.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":244
- *
- * @cname("__pyx_array_new")
- * cdef array array_cwrapper(tuple shape, Py_ssize_t itemsize, char *format, # <<<<<<<<<<<<<<
- * char *mode, char *buf):
- * cdef array result
- */
-
-static struct __pyx_array_obj *__pyx_array_new(PyObject *__pyx_v_shape, Py_ssize_t __pyx_v_itemsize, char *__pyx_v_format, char *__pyx_v_mode, char *__pyx_v_buf) {
- struct __pyx_array_obj *__pyx_v_result = 0;
- struct __pyx_array_obj *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("array_cwrapper", 0);
-
- /* "View.MemoryView":248
- * cdef array result
- *
- * if buf == NULL: # <<<<<<<<<<<<<<
- * result = array(shape, itemsize, format, mode.decode('ASCII'))
- * else:
- */
- __pyx_t_1 = ((__pyx_v_buf == NULL) != 0);
- if (__pyx_t_1) {
-
- /* "View.MemoryView":249
- *
- * if buf == NULL:
- * result = array(shape, itemsize, format, mode.decode('ASCII')) # <<<<<<<<<<<<<<
- * else:
- * result = array(shape, itemsize, format, mode.decode('ASCII'),
- */
- __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_itemsize); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 249, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = __Pyx_PyBytes_FromString(__pyx_v_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 249, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = __Pyx_decode_c_string(__pyx_v_mode, 0, strlen(__pyx_v_mode), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 249, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 249, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_INCREF(__pyx_v_shape);
- __Pyx_GIVEREF(__pyx_v_shape);
- PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_shape);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_4);
- PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_4);
- __pyx_t_2 = 0;
- __pyx_t_3 = 0;
- __pyx_t_4 = 0;
- __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_array_type), __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 249, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __pyx_v_result = ((struct __pyx_array_obj *)__pyx_t_4);
- __pyx_t_4 = 0;
-
- /* "View.MemoryView":248
- * cdef array result
- *
- * if buf == NULL: # <<<<<<<<<<<<<<
- * result = array(shape, itemsize, format, mode.decode('ASCII'))
- * else:
- */
- goto __pyx_L3;
- }
-
- /* "View.MemoryView":251
- * result = array(shape, itemsize, format, mode.decode('ASCII'))
- * else:
- * result = array(shape, itemsize, format, mode.decode('ASCII'), # <<<<<<<<<<<<<<
- * allocate_buffer=False)
- * result.data = buf
- */
- /*else*/ {
- __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_itemsize); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 251, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = __Pyx_PyBytes_FromString(__pyx_v_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 251, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __pyx_t_3 = __Pyx_decode_c_string(__pyx_v_mode, 0, strlen(__pyx_v_mode), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 251, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 251, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_v_shape);
- __Pyx_GIVEREF(__pyx_v_shape);
- PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_shape);
- __Pyx_GIVEREF(__pyx_t_4);
- PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_5);
- PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_5);
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_3);
- __pyx_t_4 = 0;
- __pyx_t_5 = 0;
- __pyx_t_3 = 0;
-
- /* "View.MemoryView":252
- * else:
- * result = array(shape, itemsize, format, mode.decode('ASCII'),
- * allocate_buffer=False) # <<<<<<<<<<<<<<
- * result.data = buf
- *
- */
- __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 252, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_allocate_buffer, Py_False) < 0) __PYX_ERR(1, 252, __pyx_L1_error)
-
- /* "View.MemoryView":251
- * result = array(shape, itemsize, format, mode.decode('ASCII'))
- * else:
- * result = array(shape, itemsize, format, mode.decode('ASCII'), # <<<<<<<<<<<<<<
- * allocate_buffer=False)
- * result.data = buf
- */
- __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_array_type), __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 251, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_v_result = ((struct __pyx_array_obj *)__pyx_t_5);
- __pyx_t_5 = 0;
-
- /* "View.MemoryView":253
- * result = array(shape, itemsize, format, mode.decode('ASCII'),
- * allocate_buffer=False)
- * result.data = buf # <<<<<<<<<<<<<<
- *
- * return result
- */
- __pyx_v_result->data = __pyx_v_buf;
- }
- __pyx_L3:;
-
- /* "View.MemoryView":255
- * result.data = buf
- *
- * return result # <<<<<<<<<<<<<<
- *
- *
- */
- __Pyx_XDECREF(((PyObject *)__pyx_r));
- __Pyx_INCREF(((PyObject *)__pyx_v_result));
- __pyx_r = __pyx_v_result;
- goto __pyx_L0;
-
- /* "View.MemoryView":244
- *
- * @cname("__pyx_array_new")
- * cdef array array_cwrapper(tuple shape, Py_ssize_t itemsize, char *format, # <<<<<<<<<<<<<<
- * char *mode, char *buf):
- * cdef array result
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("View.MemoryView.array_cwrapper", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF((PyObject *)__pyx_v_result);
- __Pyx_XGIVEREF((PyObject *)__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":281
- * cdef class Enum(object):
- * cdef object name
- * def __init__(self, name): # <<<<<<<<<<<<<<
- * self.name = name
- * def __repr__(self):
- */
-
-/* Python wrapper */
-static int __pyx_MemviewEnum___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_MemviewEnum___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_name = 0;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_name,0};
- PyObject* values[1] = {0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_name)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(1, 281, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- }
- __pyx_v_name = values[0];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 281, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("View.MemoryView.Enum.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self), __pyx_v_name);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v_name) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__init__", 0);
-
- /* "View.MemoryView":282
- * cdef object name
- * def __init__(self, name):
- * self.name = name # <<<<<<<<<<<<<<
- * def __repr__(self):
- * return self.name
- */
- __Pyx_INCREF(__pyx_v_name);
- __Pyx_GIVEREF(__pyx_v_name);
- __Pyx_GOTREF(__pyx_v_self->name);
- __Pyx_DECREF(__pyx_v_self->name);
- __pyx_v_self->name = __pyx_v_name;
-
- /* "View.MemoryView":281
- * cdef class Enum(object):
- * cdef object name
- * def __init__(self, name): # <<<<<<<<<<<<<<
- * self.name = name
- * def __repr__(self):
- */
-
- /* function exit code */
- __pyx_r = 0;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":283
- * def __init__(self, name):
- * self.name = name
- * def __repr__(self): # <<<<<<<<<<<<<<
- * return self.name
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_MemviewEnum___repr__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_MemviewEnum___repr__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
- __pyx_r = __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr__(struct __pyx_MemviewEnum_obj *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__repr__", 0);
-
- /* "View.MemoryView":284
- * self.name = name
- * def __repr__(self):
- * return self.name # <<<<<<<<<<<<<<
- *
- * cdef generic = Enum("")
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_self->name);
- __pyx_r = __pyx_v_self->name;
- goto __pyx_L0;
-
- /* "View.MemoryView":283
- * def __init__(self, name):
- * self.name = name
- * def __repr__(self): # <<<<<<<<<<<<<<
- * return self.name
- *
- */
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "(tree fragment)":1
- * def __reduce_cython__(self): # <<<<<<<<<<<<<<
- * cdef tuple state
- * cdef object _dict
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw___pyx_MemviewEnum_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_pw___pyx_MemviewEnum_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
- __pyx_r = __pyx_pf___pyx_MemviewEnum___reduce_cython__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf___pyx_MemviewEnum___reduce_cython__(struct __pyx_MemviewEnum_obj *__pyx_v_self) {
- PyObject *__pyx_v_state = 0;
- PyObject *__pyx_v__dict = 0;
- int __pyx_v_use_setstate;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_t_2;
- int __pyx_t_3;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("__reduce_cython__", 0);
-
- /* "(tree fragment)":5
- * cdef object _dict
- * cdef bint use_setstate
- * state = (self.name,) # <<<<<<<<<<<<<<
- * _dict = getattr(self, '__dict__', None)
- * if _dict is not None:
- */
- __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_v_self->name);
- __Pyx_GIVEREF(__pyx_v_self->name);
- PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->name);
- __pyx_v_state = ((PyObject*)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "(tree fragment)":6
- * cdef bint use_setstate
- * state = (self.name,)
- * _dict = getattr(self, '__dict__', None) # <<<<<<<<<<<<<<
- * if _dict is not None:
- * state += (_dict,)
- */
- __pyx_t_1 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v__dict = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "(tree fragment)":7
- * state = (self.name,)
- * _dict = getattr(self, '__dict__', None)
- * if _dict is not None: # <<<<<<<<<<<<<<
- * state += (_dict,)
- * use_setstate = True
- */
- __pyx_t_2 = (__pyx_v__dict != Py_None);
- __pyx_t_3 = (__pyx_t_2 != 0);
- if (__pyx_t_3) {
-
- /* "(tree fragment)":8
- * _dict = getattr(self, '__dict__', None)
- * if _dict is not None:
- * state += (_dict,) # <<<<<<<<<<<<<<
- * use_setstate = True
- * else:
- */
- __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(__pyx_v__dict);
- __Pyx_GIVEREF(__pyx_v__dict);
- PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v__dict);
- __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 8, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_4));
- __pyx_t_4 = 0;
-
- /* "(tree fragment)":9
- * if _dict is not None:
- * state += (_dict,)
- * use_setstate = True # <<<<<<<<<<<<<<
- * else:
- * use_setstate = self.name is not None
- */
- __pyx_v_use_setstate = 1;
-
- /* "(tree fragment)":7
- * state = (self.name,)
- * _dict = getattr(self, '__dict__', None)
- * if _dict is not None: # <<<<<<<<<<<<<<
- * state += (_dict,)
- * use_setstate = True
- */
- goto __pyx_L3;
- }
-
- /* "(tree fragment)":11
- * use_setstate = True
- * else:
- * use_setstate = self.name is not None # <<<<<<<<<<<<<<
- * if use_setstate:
- * return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state
- */
- /*else*/ {
- __pyx_t_3 = (__pyx_v_self->name != Py_None);
- __pyx_v_use_setstate = __pyx_t_3;
- }
- __pyx_L3:;
-
- /* "(tree fragment)":12
- * else:
- * use_setstate = self.name is not None
- * if use_setstate: # <<<<<<<<<<<<<<
- * return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state
- * else:
- */
- __pyx_t_3 = (__pyx_v_use_setstate != 0);
- if (__pyx_t_3) {
-
- /* "(tree fragment)":13
- * use_setstate = self.name is not None
- * if use_setstate:
- * return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state # <<<<<<<<<<<<<<
- * else:
- * return __pyx_unpickle_Enum, (type(self), 0xb068931, state)
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pyx_unpickle_Enum); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 13, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 13, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
- __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
- PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
- __Pyx_INCREF(__pyx_int_184977713);
- __Pyx_GIVEREF(__pyx_int_184977713);
- PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_184977713);
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- PyTuple_SET_ITEM(__pyx_t_1, 2, Py_None);
- __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 13, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_GIVEREF(__pyx_t_4);
- PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
- __Pyx_INCREF(__pyx_v_state);
- __Pyx_GIVEREF(__pyx_v_state);
- PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_state);
- __pyx_t_4 = 0;
- __pyx_t_1 = 0;
- __pyx_r = __pyx_t_5;
- __pyx_t_5 = 0;
- goto __pyx_L0;
-
- /* "(tree fragment)":12
- * else:
- * use_setstate = self.name is not None
- * if use_setstate: # <<<<<<<<<<<<<<
- * return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state
- * else:
- */
- }
-
- /* "(tree fragment)":15
- * return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state
- * else:
- * return __pyx_unpickle_Enum, (type(self), 0xb068931, state) # <<<<<<<<<<<<<<
- * def __setstate_cython__(self, __pyx_state):
- * __pyx_unpickle_Enum__set_state(self, __pyx_state)
- */
- /*else*/ {
- __Pyx_XDECREF(__pyx_r);
- __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_pyx_unpickle_Enum); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 15, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 15, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
- __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
- PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
- __Pyx_INCREF(__pyx_int_184977713);
- __Pyx_GIVEREF(__pyx_int_184977713);
- PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_184977713);
- __Pyx_INCREF(__pyx_v_state);
- __Pyx_GIVEREF(__pyx_v_state);
- PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
- __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 15, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_5);
- PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
- __pyx_t_5 = 0;
- __pyx_t_1 = 0;
- __pyx_r = __pyx_t_4;
- __pyx_t_4 = 0;
- goto __pyx_L0;
- }
-
- /* "(tree fragment)":1
- * def __reduce_cython__(self): # <<<<<<<<<<<<<<
- * cdef tuple state
- * cdef object _dict
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("View.MemoryView.Enum.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_state);
- __Pyx_XDECREF(__pyx_v__dict);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "(tree fragment)":16
- * else:
- * return __pyx_unpickle_Enum, (type(self), 0xb068931, state)
- * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
- * __pyx_unpickle_Enum__set_state(self, __pyx_state)
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw___pyx_MemviewEnum_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
-static PyObject *__pyx_pw___pyx_MemviewEnum_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
- __pyx_r = __pyx_pf___pyx_MemviewEnum_2__setstate_cython__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf___pyx_MemviewEnum_2__setstate_cython__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("__setstate_cython__", 0);
-
- /* "(tree fragment)":17
- * return __pyx_unpickle_Enum, (type(self), 0xb068931, state)
- * def __setstate_cython__(self, __pyx_state):
- * __pyx_unpickle_Enum__set_state(self, __pyx_state) # <<<<<<<<<<<<<<
- */
- if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error)
- __pyx_t_1 = __pyx_unpickle_Enum__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "(tree fragment)":16
- * else:
- * return __pyx_unpickle_Enum, (type(self), 0xb068931, state)
- * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
- * __pyx_unpickle_Enum__set_state(self, __pyx_state)
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("View.MemoryView.Enum.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":298
- *
- * @cname('__pyx_align_pointer')
- * cdef void *align_pointer(void *memory, size_t alignment) nogil: # <<<<<<<<<<<<<<
- * "Align pointer memory on a given boundary"
- * cdef Py_intptr_t aligned_p = memory
- */
-
-static void *__pyx_align_pointer(void *__pyx_v_memory, size_t __pyx_v_alignment) {
- Py_intptr_t __pyx_v_aligned_p;
- size_t __pyx_v_offset;
- void *__pyx_r;
- int __pyx_t_1;
-
- /* "View.MemoryView":300
- * cdef void *align_pointer(void *memory, size_t alignment) nogil:
- * "Align pointer memory on a given boundary"
- * cdef Py_intptr_t aligned_p = memory # <<<<<<<<<<<<<<
- * cdef size_t offset
- *
- */
- __pyx_v_aligned_p = ((Py_intptr_t)__pyx_v_memory);
-
- /* "View.MemoryView":304
- *
- * with cython.cdivision(True):
- * offset = aligned_p % alignment # <<<<<<<<<<<<<<
- *
- * if offset > 0:
- */
- __pyx_v_offset = (__pyx_v_aligned_p % __pyx_v_alignment);
-
- /* "View.MemoryView":306
- * offset = aligned_p % alignment
- *
- * if offset > 0: # <<<<<<<<<<<<<<
- * aligned_p += alignment - offset
- *
- */
- __pyx_t_1 = ((__pyx_v_offset > 0) != 0);
- if (__pyx_t_1) {
-
- /* "View.MemoryView":307
- *
- * if offset > 0:
- * aligned_p += alignment - offset # <<<<<<<<<<<<<<
- *
- * return aligned_p
- */
- __pyx_v_aligned_p = (__pyx_v_aligned_p + (__pyx_v_alignment - __pyx_v_offset));
-
- /* "View.MemoryView":306
- * offset = aligned_p % alignment
- *
- * if offset > 0: # <<<<<<<<<<<<<<
- * aligned_p += alignment - offset
- *
- */
- }
-
- /* "View.MemoryView":309
- * aligned_p += alignment - offset
- *
- * return aligned_p # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_r = ((void *)__pyx_v_aligned_p);
- goto __pyx_L0;
-
- /* "View.MemoryView":298
- *
- * @cname('__pyx_align_pointer')
- * cdef void *align_pointer(void *memory, size_t alignment) nogil: # <<<<<<<<<<<<<<
- * "Align pointer memory on a given boundary"
- * cdef Py_intptr_t aligned_p = memory
- */
-
- /* function exit code */
- __pyx_L0:;
- return __pyx_r;
-}
-
-/* "View.MemoryView":345
- * cdef __Pyx_TypeInfo *typeinfo
- *
- * def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False): # <<<<<<<<<<<<<<
- * self.obj = obj
- * self.flags = flags
- */
-
-/* Python wrapper */
-static int __pyx_memoryview___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_memoryview___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v_obj = 0;
- int __pyx_v_flags;
- int __pyx_v_dtype_is_object;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_obj,&__pyx_n_s_flags,&__pyx_n_s_dtype_is_object,0};
- PyObject* values[3] = {0,0,0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_obj)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_flags)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, 1); __PYX_ERR(1, 345, __pyx_L3_error)
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (kw_args > 0) {
- PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dtype_is_object);
- if (value) { values[2] = value; kw_args--; }
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(1, 345, __pyx_L3_error)
- }
- } else {
- switch (PyTuple_GET_SIZE(__pyx_args)) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- break;
- default: goto __pyx_L5_argtuple_error;
- }
- }
- __pyx_v_obj = values[0];
- __pyx_v_flags = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 345, __pyx_L3_error)
- if (values[2]) {
- __pyx_v_dtype_is_object = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_dtype_is_object == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 345, __pyx_L3_error)
- } else {
- __pyx_v_dtype_is_object = ((int)0);
- }
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 345, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("View.MemoryView.memoryview.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return -1;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview___cinit__(((struct __pyx_memoryview_obj *)__pyx_v_self), __pyx_v_obj, __pyx_v_flags, __pyx_v_dtype_is_object);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview___cinit__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj, int __pyx_v_flags, int __pyx_v_dtype_is_object) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- int __pyx_t_3;
- int __pyx_t_4;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("__cinit__", 0);
-
- /* "View.MemoryView":346
- *
- * def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False):
- * self.obj = obj # <<<<<<<<<<<<<<
- * self.flags = flags
- * if type(self) is memoryview or obj is not None:
- */
- __Pyx_INCREF(__pyx_v_obj);
- __Pyx_GIVEREF(__pyx_v_obj);
- __Pyx_GOTREF(__pyx_v_self->obj);
- __Pyx_DECREF(__pyx_v_self->obj);
- __pyx_v_self->obj = __pyx_v_obj;
-
- /* "View.MemoryView":347
- * def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False):
- * self.obj = obj
- * self.flags = flags # <<<<<<<<<<<<<<
- * if type(self) is memoryview or obj is not None:
- * __Pyx_GetBuffer(obj, &self.view, flags)
- */
- __pyx_v_self->flags = __pyx_v_flags;
-
- /* "View.MemoryView":348
- * self.obj = obj
- * self.flags = flags
- * if type(self) is memoryview or obj is not None: # <<<<<<<<<<<<<<
- * __Pyx_GetBuffer(obj, &self.view, flags)
- * if self.view.obj == NULL:
- */
- __pyx_t_2 = (((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))) == ((PyObject *)__pyx_memoryview_type));
- __pyx_t_3 = (__pyx_t_2 != 0);
- if (!__pyx_t_3) {
- } else {
- __pyx_t_1 = __pyx_t_3;
- goto __pyx_L4_bool_binop_done;
- }
- __pyx_t_3 = (__pyx_v_obj != Py_None);
- __pyx_t_2 = (__pyx_t_3 != 0);
- __pyx_t_1 = __pyx_t_2;
- __pyx_L4_bool_binop_done:;
- if (__pyx_t_1) {
-
- /* "View.MemoryView":349
- * self.flags = flags
- * if type(self) is memoryview or obj is not None:
- * __Pyx_GetBuffer(obj, &self.view, flags) # <<<<<<<<<<<<<<
- * if self.view.obj == NULL:
- * (<__pyx_buffer *> &self.view).obj = Py_None
- */
- __pyx_t_4 = __Pyx_GetBuffer(__pyx_v_obj, (&__pyx_v_self->view), __pyx_v_flags); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 349, __pyx_L1_error)
-
- /* "View.MemoryView":350
- * if type(self) is memoryview or obj is not None:
- * __Pyx_GetBuffer(obj, &self.view, flags)
- * if self.view.obj == NULL: # <<<<<<<<<<<<<<
- * (<__pyx_buffer *> &self.view).obj = Py_None
- * Py_INCREF(Py_None)
- */
- __pyx_t_1 = ((((PyObject *)__pyx_v_self->view.obj) == NULL) != 0);
- if (__pyx_t_1) {
-
- /* "View.MemoryView":351
- * __Pyx_GetBuffer(obj, &self.view, flags)
- * if self.view.obj == NULL:
- * (<__pyx_buffer *> &self.view).obj = Py_None # <<<<<<<<<<<<<<
- * Py_INCREF(Py_None)
- *
- */
- ((Py_buffer *)(&__pyx_v_self->view))->obj = Py_None;
-
- /* "View.MemoryView":352
- * if self.view.obj == NULL:
- * (<__pyx_buffer *> &self.view).obj = Py_None
- * Py_INCREF(Py_None) # <<<<<<<<<<<<<<
- *
- * global __pyx_memoryview_thread_locks_used
- */
- Py_INCREF(Py_None);
-
- /* "View.MemoryView":350
- * if type(self) is memoryview or obj is not None:
- * __Pyx_GetBuffer(obj, &self.view, flags)
- * if self.view.obj == NULL: # <<<<<<<<<<<<<<
- * (<__pyx_buffer *> &self.view).obj = Py_None
- * Py_INCREF(Py_None)
- */
- }
-
- /* "View.MemoryView":348
- * self.obj = obj
- * self.flags = flags
- * if type(self) is memoryview or obj is not None: # <<<<<<<<<<<<<<
- * __Pyx_GetBuffer(obj, &self.view, flags)
- * if self.view.obj == NULL:
- */
- }
-
- /* "View.MemoryView":355
- *
- * global __pyx_memoryview_thread_locks_used
- * if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED: # <<<<<<<<<<<<<<
- * self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]
- * __pyx_memoryview_thread_locks_used += 1
- */
- __pyx_t_1 = ((__pyx_memoryview_thread_locks_used < 8) != 0);
- if (__pyx_t_1) {
-
- /* "View.MemoryView":356
- * global __pyx_memoryview_thread_locks_used
- * if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED:
- * self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] # <<<<<<<<<<<<<<
- * __pyx_memoryview_thread_locks_used += 1
- * if self.lock is NULL:
- */
- __pyx_v_self->lock = (__pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]);
-
- /* "View.MemoryView":357
- * if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED:
- * self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]
- * __pyx_memoryview_thread_locks_used += 1 # <<<<<<<<<<<<<<
- * if self.lock is NULL:
- * self.lock = PyThread_allocate_lock()
- */
- __pyx_memoryview_thread_locks_used = (__pyx_memoryview_thread_locks_used + 1);
-
- /* "View.MemoryView":355
- *
- * global __pyx_memoryview_thread_locks_used
- * if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED: # <<<<<<<<<<<<<<
- * self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]
- * __pyx_memoryview_thread_locks_used += 1
- */
- }
-
- /* "View.MemoryView":358
- * self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]
- * __pyx_memoryview_thread_locks_used += 1
- * if self.lock is NULL: # <<<<<<<<<<<<<<
- * self.lock = PyThread_allocate_lock()
- * if self.lock is NULL:
- */
- __pyx_t_1 = ((__pyx_v_self->lock == NULL) != 0);
- if (__pyx_t_1) {
-
- /* "View.MemoryView":359
- * __pyx_memoryview_thread_locks_used += 1
- * if self.lock is NULL:
- * self.lock = PyThread_allocate_lock() # <<<<<<<<<<<<<<
- * if self.lock is NULL:
- * raise MemoryError
- */
- __pyx_v_self->lock = PyThread_allocate_lock();
-
- /* "View.MemoryView":360
- * if self.lock is NULL:
- * self.lock = PyThread_allocate_lock()
- * if self.lock is NULL: # <<<<<<<<<<<<<<
- * raise MemoryError
- *
- */
- __pyx_t_1 = ((__pyx_v_self->lock == NULL) != 0);
- if (unlikely(__pyx_t_1)) {
-
- /* "View.MemoryView":361
- * self.lock = PyThread_allocate_lock()
- * if self.lock is NULL:
- * raise MemoryError # <<<<<<<<<<<<<<
- *
- * if flags & PyBUF_FORMAT:
- */
- PyErr_NoMemory(); __PYX_ERR(1, 361, __pyx_L1_error)
-
- /* "View.MemoryView":360
- * if self.lock is NULL:
- * self.lock = PyThread_allocate_lock()
- * if self.lock is NULL: # <<<<<<<<<<<<<<
- * raise MemoryError
- *
- */
- }
-
- /* "View.MemoryView":358
- * self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]
- * __pyx_memoryview_thread_locks_used += 1
- * if self.lock is NULL: # <<<<<<<<<<<<<<
- * self.lock = PyThread_allocate_lock()
- * if self.lock is NULL:
- */
- }
-
- /* "View.MemoryView":363
- * raise MemoryError
- *
- * if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<<
- * self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0')
- * else:
- */
- __pyx_t_1 = ((__pyx_v_flags & PyBUF_FORMAT) != 0);
- if (__pyx_t_1) {
-
- /* "View.MemoryView":364
- *
- * if flags & PyBUF_FORMAT:
- * self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0') # <<<<<<<<<<<<<<
- * else:
- * self.dtype_is_object = dtype_is_object
- */
- __pyx_t_2 = (((__pyx_v_self->view.format[0]) == 'O') != 0);
- if (__pyx_t_2) {
- } else {
- __pyx_t_1 = __pyx_t_2;
- goto __pyx_L11_bool_binop_done;
- }
- __pyx_t_2 = (((__pyx_v_self->view.format[1]) == '\x00') != 0);
- __pyx_t_1 = __pyx_t_2;
- __pyx_L11_bool_binop_done:;
- __pyx_v_self->dtype_is_object = __pyx_t_1;
-
- /* "View.MemoryView":363
- * raise MemoryError
- *
- * if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<<
- * self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0')
- * else:
- */
- goto __pyx_L10;
- }
-
- /* "View.MemoryView":366
- * self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0')
- * else:
- * self.dtype_is_object = dtype_is_object # <<<<<<<<<<<<<<
- *
- * self.acquisition_count_aligned_p = <__pyx_atomic_int *> align_pointer(
- */
- /*else*/ {
- __pyx_v_self->dtype_is_object = __pyx_v_dtype_is_object;
- }
- __pyx_L10:;
-
- /* "View.MemoryView":368
- * self.dtype_is_object = dtype_is_object
- *
- * self.acquisition_count_aligned_p = <__pyx_atomic_int *> align_pointer( # <<<<<<<<<<<<<<
- * &self.acquisition_count[0], sizeof(__pyx_atomic_int))
- * self.typeinfo = NULL
- */
- __pyx_v_self->acquisition_count_aligned_p = ((__pyx_atomic_int *)__pyx_align_pointer(((void *)(&(__pyx_v_self->acquisition_count[0]))), (sizeof(__pyx_atomic_int))));
-
- /* "View.MemoryView":370
- * self.acquisition_count_aligned_p = <__pyx_atomic_int *> align_pointer(
- * &self.acquisition_count[0], sizeof(__pyx_atomic_int))
- * self.typeinfo = NULL # <<<<<<<<<<<<<<
- *
- * def __dealloc__(memoryview self):
- */
- __pyx_v_self->typeinfo = NULL;
-
- /* "View.MemoryView":345
- * cdef __Pyx_TypeInfo *typeinfo
- *
- * def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False): # <<<<<<<<<<<<<<
- * self.obj = obj
- * self.flags = flags
- */
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_AddTraceback("View.MemoryView.memoryview.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":372
- * self.typeinfo = NULL
- *
- * def __dealloc__(memoryview self): # <<<<<<<<<<<<<<
- * if self.obj is not None:
- * __Pyx_ReleaseBuffer(&self.view)
- */
-
-/* Python wrapper */
-static void __pyx_memoryview___dealloc__(PyObject *__pyx_v_self); /*proto*/
-static void __pyx_memoryview___dealloc__(PyObject *__pyx_v_self) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
- __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__(((struct __pyx_memoryview_obj *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
-}
-
-static void __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__(struct __pyx_memoryview_obj *__pyx_v_self) {
- int __pyx_v_i;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- int __pyx_t_3;
- int __pyx_t_4;
- int __pyx_t_5;
- PyThread_type_lock __pyx_t_6;
- PyThread_type_lock __pyx_t_7;
- __Pyx_RefNannySetupContext("__dealloc__", 0);
-
- /* "View.MemoryView":373
- *
- * def __dealloc__(memoryview self):
- * if self.obj is not None: # <<<<<<<<<<<<<<
- * __Pyx_ReleaseBuffer(&self.view)
- * elif (<__pyx_buffer *> &self.view).obj == Py_None:
- */
- __pyx_t_1 = (__pyx_v_self->obj != Py_None);
- __pyx_t_2 = (__pyx_t_1 != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":374
- * def __dealloc__(memoryview self):
- * if self.obj is not None:
- * __Pyx_ReleaseBuffer(&self.view) # <<<<<<<<<<<<<<
- * elif (<__pyx_buffer *> &self.view).obj == Py_None:
- *
- */
- __Pyx_ReleaseBuffer((&__pyx_v_self->view));
-
- /* "View.MemoryView":373
- *
- * def __dealloc__(memoryview self):
- * if self.obj is not None: # <<<<<<<<<<<<<<
- * __Pyx_ReleaseBuffer(&self.view)
- * elif (<__pyx_buffer *> &self.view).obj == Py_None:
- */
- goto __pyx_L3;
- }
-
- /* "View.MemoryView":375
- * if self.obj is not None:
- * __Pyx_ReleaseBuffer(&self.view)
- * elif (<__pyx_buffer *> &self.view).obj == Py_None: # <<<<<<<<<<<<<<
- *
- * (<__pyx_buffer *> &self.view).obj = NULL
- */
- __pyx_t_2 = ((((Py_buffer *)(&__pyx_v_self->view))->obj == Py_None) != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":377
- * elif (<__pyx_buffer *> &self.view).obj == Py_None:
- *
- * (<__pyx_buffer *> &self.view).obj = NULL # <<<<<<<<<<<<<<
- * Py_DECREF(Py_None)
- *
- */
- ((Py_buffer *)(&__pyx_v_self->view))->obj = NULL;
-
- /* "View.MemoryView":378
- *
- * (<__pyx_buffer *> &self.view).obj = NULL
- * Py_DECREF(Py_None) # <<<<<<<<<<<<<<
- *
- * cdef int i
- */
- Py_DECREF(Py_None);
-
- /* "View.MemoryView":375
- * if self.obj is not None:
- * __Pyx_ReleaseBuffer(&self.view)
- * elif (<__pyx_buffer *> &self.view).obj == Py_None: # <<<<<<<<<<<<<<
- *
- * (<__pyx_buffer *> &self.view).obj = NULL
- */
- }
- __pyx_L3:;
-
- /* "View.MemoryView":382
- * cdef int i
- * global __pyx_memoryview_thread_locks_used
- * if self.lock != NULL: # <<<<<<<<<<<<<<
- * for i in range(__pyx_memoryview_thread_locks_used):
- * if __pyx_memoryview_thread_locks[i] is self.lock:
- */
- __pyx_t_2 = ((__pyx_v_self->lock != NULL) != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":383
- * global __pyx_memoryview_thread_locks_used
- * if self.lock != NULL:
- * for i in range(__pyx_memoryview_thread_locks_used): # <<<<<<<<<<<<<<
- * if __pyx_memoryview_thread_locks[i] is self.lock:
- * __pyx_memoryview_thread_locks_used -= 1
- */
- __pyx_t_3 = __pyx_memoryview_thread_locks_used;
- __pyx_t_4 = __pyx_t_3;
- for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
- __pyx_v_i = __pyx_t_5;
-
- /* "View.MemoryView":384
- * if self.lock != NULL:
- * for i in range(__pyx_memoryview_thread_locks_used):
- * if __pyx_memoryview_thread_locks[i] is self.lock: # <<<<<<<<<<<<<<
- * __pyx_memoryview_thread_locks_used -= 1
- * if i != __pyx_memoryview_thread_locks_used:
- */
- __pyx_t_2 = (((__pyx_memoryview_thread_locks[__pyx_v_i]) == __pyx_v_self->lock) != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":385
- * for i in range(__pyx_memoryview_thread_locks_used):
- * if __pyx_memoryview_thread_locks[i] is self.lock:
- * __pyx_memoryview_thread_locks_used -= 1 # <<<<<<<<<<<<<<
- * if i != __pyx_memoryview_thread_locks_used:
- * __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (
- */
- __pyx_memoryview_thread_locks_used = (__pyx_memoryview_thread_locks_used - 1);
-
- /* "View.MemoryView":386
- * if __pyx_memoryview_thread_locks[i] is self.lock:
- * __pyx_memoryview_thread_locks_used -= 1
- * if i != __pyx_memoryview_thread_locks_used: # <<<<<<<<<<<<<<
- * __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (
- * __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i])
- */
- __pyx_t_2 = ((__pyx_v_i != __pyx_memoryview_thread_locks_used) != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":388
- * if i != __pyx_memoryview_thread_locks_used:
- * __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (
- * __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i]) # <<<<<<<<<<<<<<
- * break
- * else:
- */
- __pyx_t_6 = (__pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]);
- __pyx_t_7 = (__pyx_memoryview_thread_locks[__pyx_v_i]);
-
- /* "View.MemoryView":387
- * __pyx_memoryview_thread_locks_used -= 1
- * if i != __pyx_memoryview_thread_locks_used:
- * __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = ( # <<<<<<<<<<<<<<
- * __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i])
- * break
- */
- (__pyx_memoryview_thread_locks[__pyx_v_i]) = __pyx_t_6;
- (__pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]) = __pyx_t_7;
-
- /* "View.MemoryView":386
- * if __pyx_memoryview_thread_locks[i] is self.lock:
- * __pyx_memoryview_thread_locks_used -= 1
- * if i != __pyx_memoryview_thread_locks_used: # <<<<<<<<<<<<<<
- * __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (
- * __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i])
- */
- }
-
- /* "View.MemoryView":389
- * __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = (
- * __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i])
- * break # <<<<<<<<<<<<<<
- * else:
- * PyThread_free_lock(self.lock)
- */
- goto __pyx_L6_break;
-
- /* "View.MemoryView":384
- * if self.lock != NULL:
- * for i in range(__pyx_memoryview_thread_locks_used):
- * if __pyx_memoryview_thread_locks[i] is self.lock: # <<<<<<<<<<<<<<
- * __pyx_memoryview_thread_locks_used -= 1
- * if i != __pyx_memoryview_thread_locks_used:
- */
- }
- }
- /*else*/ {
-
- /* "View.MemoryView":391
- * break
- * else:
- * PyThread_free_lock(self.lock) # <<<<<<<<<<<<<<
- *
- * cdef char *get_item_pointer(memoryview self, object index) except NULL:
- */
- PyThread_free_lock(__pyx_v_self->lock);
- }
- __pyx_L6_break:;
-
- /* "View.MemoryView":382
- * cdef int i
- * global __pyx_memoryview_thread_locks_used
- * if self.lock != NULL: # <<<<<<<<<<<<<<
- * for i in range(__pyx_memoryview_thread_locks_used):
- * if __pyx_memoryview_thread_locks[i] is self.lock:
- */
- }
-
- /* "View.MemoryView":372
- * self.typeinfo = NULL
- *
- * def __dealloc__(memoryview self): # <<<<<<<<<<<<<<
- * if self.obj is not None:
- * __Pyx_ReleaseBuffer(&self.view)
- */
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
-}
-
-/* "View.MemoryView":393
- * PyThread_free_lock(self.lock)
- *
- * cdef char *get_item_pointer(memoryview self, object index) except NULL: # <<<<<<<<<<<<<<
- * cdef Py_ssize_t dim
- * cdef char *itemp = self.view.buf
- */
-
-static char *__pyx_memoryview_get_item_pointer(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index) {
- Py_ssize_t __pyx_v_dim;
- char *__pyx_v_itemp;
- PyObject *__pyx_v_idx = NULL;
- char *__pyx_r;
- __Pyx_RefNannyDeclarations
- Py_ssize_t __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- Py_ssize_t __pyx_t_3;
- PyObject *(*__pyx_t_4)(PyObject *);
- PyObject *__pyx_t_5 = NULL;
- Py_ssize_t __pyx_t_6;
- char *__pyx_t_7;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("get_item_pointer", 0);
-
- /* "View.MemoryView":395
- * cdef char *get_item_pointer(memoryview self, object index) except NULL:
- * cdef Py_ssize_t dim
- * cdef char *itemp = self.view.buf # <<<<<<<<<<<<<<
- *
- * for dim, idx in enumerate(index):
- */
- __pyx_v_itemp = ((char *)__pyx_v_self->view.buf);
-
- /* "View.MemoryView":397
- * cdef char *itemp = self.view.buf
- *
- * for dim, idx in enumerate(index): # <<<<<<<<<<<<<<
- * itemp = pybuffer_index(&self.view, itemp, idx, dim)
- *
- */
- __pyx_t_1 = 0;
- if (likely(PyList_CheckExact(__pyx_v_index)) || PyTuple_CheckExact(__pyx_v_index)) {
- __pyx_t_2 = __pyx_v_index; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
- __pyx_t_4 = NULL;
- } else {
- __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 397, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 397, __pyx_L1_error)
- }
- for (;;) {
- if (likely(!__pyx_t_4)) {
- if (likely(PyList_CheckExact(__pyx_t_2))) {
- if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_5 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 397, __pyx_L1_error)
- #else
- __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 397, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- #endif
- } else {
- if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 397, __pyx_L1_error)
- #else
- __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 397, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- #endif
- }
- } else {
- __pyx_t_5 = __pyx_t_4(__pyx_t_2);
- if (unlikely(!__pyx_t_5)) {
- PyObject* exc_type = PyErr_Occurred();
- if (exc_type) {
- if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
- else __PYX_ERR(1, 397, __pyx_L1_error)
- }
- break;
- }
- __Pyx_GOTREF(__pyx_t_5);
- }
- __Pyx_XDECREF_SET(__pyx_v_idx, __pyx_t_5);
- __pyx_t_5 = 0;
- __pyx_v_dim = __pyx_t_1;
- __pyx_t_1 = (__pyx_t_1 + 1);
-
- /* "View.MemoryView":398
- *
- * for dim, idx in enumerate(index):
- * itemp = pybuffer_index(&self.view, itemp, idx, dim) # <<<<<<<<<<<<<<
- *
- * return itemp
- */
- __pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_v_idx); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 398, __pyx_L1_error)
- __pyx_t_7 = __pyx_pybuffer_index((&__pyx_v_self->view), __pyx_v_itemp, __pyx_t_6, __pyx_v_dim); if (unlikely(__pyx_t_7 == ((char *)NULL))) __PYX_ERR(1, 398, __pyx_L1_error)
- __pyx_v_itemp = __pyx_t_7;
-
- /* "View.MemoryView":397
- * cdef char *itemp = self.view.buf
- *
- * for dim, idx in enumerate(index): # <<<<<<<<<<<<<<
- * itemp = pybuffer_index(&self.view, itemp, idx, dim)
- *
- */
- }
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "View.MemoryView":400
- * itemp = pybuffer_index(&self.view, itemp, idx, dim)
- *
- * return itemp # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_r = __pyx_v_itemp;
- goto __pyx_L0;
-
- /* "View.MemoryView":393
- * PyThread_free_lock(self.lock)
- *
- * cdef char *get_item_pointer(memoryview self, object index) except NULL: # <<<<<<<<<<<<<<
- * cdef Py_ssize_t dim
- * cdef char *itemp = self.view.buf
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("View.MemoryView.memoryview.get_item_pointer", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_idx);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":403
- *
- *
- * def __getitem__(memoryview self, object index): # <<<<<<<<<<<<<<
- * if index is Ellipsis:
- * return self
- */
-
-/* Python wrapper */
-static PyObject *__pyx_memoryview___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index); /*proto*/
-static PyObject *__pyx_memoryview___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
- __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4__getitem__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((PyObject *)__pyx_v_index));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4__getitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index) {
- PyObject *__pyx_v_have_slices = NULL;
- PyObject *__pyx_v_indices = NULL;
- char *__pyx_v_itemp;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- char *__pyx_t_6;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("__getitem__", 0);
-
- /* "View.MemoryView":404
- *
- * def __getitem__(memoryview self, object index):
- * if index is Ellipsis: # <<<<<<<<<<<<<<
- * return self
- *
- */
- __pyx_t_1 = (__pyx_v_index == __pyx_builtin_Ellipsis);
- __pyx_t_2 = (__pyx_t_1 != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":405
- * def __getitem__(memoryview self, object index):
- * if index is Ellipsis:
- * return self # <<<<<<<<<<<<<<
- *
- * have_slices, indices = _unellipsify(index, self.view.ndim)
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __pyx_r = ((PyObject *)__pyx_v_self);
- goto __pyx_L0;
-
- /* "View.MemoryView":404
- *
- * def __getitem__(memoryview self, object index):
- * if index is Ellipsis: # <<<<<<<<<<<<<<
- * return self
- *
- */
- }
-
- /* "View.MemoryView":407
- * return self
- *
- * have_slices, indices = _unellipsify(index, self.view.ndim) # <<<<<<<<<<<<<<
- *
- * cdef char *itemp
- */
- __pyx_t_3 = _unellipsify(__pyx_v_index, __pyx_v_self->view.ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 407, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- if (likely(__pyx_t_3 != Py_None)) {
- PyObject* sequence = __pyx_t_3;
- Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
- if (unlikely(size != 2)) {
- if (size > 2) __Pyx_RaiseTooManyValuesError(2);
- else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
- __PYX_ERR(1, 407, __pyx_L1_error)
- }
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0);
- __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_5);
- #else
- __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 407, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 407, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- #endif
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- } else {
- __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(1, 407, __pyx_L1_error)
- }
- __pyx_v_have_slices = __pyx_t_4;
- __pyx_t_4 = 0;
- __pyx_v_indices = __pyx_t_5;
- __pyx_t_5 = 0;
-
- /* "View.MemoryView":410
- *
- * cdef char *itemp
- * if have_slices: # <<<<<<<<<<<<<<
- * return memview_slice(self, indices)
- * else:
- */
- __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_have_slices); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 410, __pyx_L1_error)
- if (__pyx_t_2) {
-
- /* "View.MemoryView":411
- * cdef char *itemp
- * if have_slices:
- * return memview_slice(self, indices) # <<<<<<<<<<<<<<
- * else:
- * itemp = self.get_item_pointer(indices)
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_3 = ((PyObject *)__pyx_memview_slice(__pyx_v_self, __pyx_v_indices)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 411, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_r = __pyx_t_3;
- __pyx_t_3 = 0;
- goto __pyx_L0;
-
- /* "View.MemoryView":410
- *
- * cdef char *itemp
- * if have_slices: # <<<<<<<<<<<<<<
- * return memview_slice(self, indices)
- * else:
- */
- }
-
- /* "View.MemoryView":413
- * return memview_slice(self, indices)
- * else:
- * itemp = self.get_item_pointer(indices) # <<<<<<<<<<<<<<
- * return self.convert_item_to_object(itemp)
- *
- */
- /*else*/ {
- __pyx_t_6 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->get_item_pointer(__pyx_v_self, __pyx_v_indices); if (unlikely(__pyx_t_6 == ((char *)NULL))) __PYX_ERR(1, 413, __pyx_L1_error)
- __pyx_v_itemp = __pyx_t_6;
-
- /* "View.MemoryView":414
- * else:
- * itemp = self.get_item_pointer(indices)
- * return self.convert_item_to_object(itemp) # <<<<<<<<<<<<<<
- *
- * def __setitem__(memoryview self, object index, object value):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_3 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->convert_item_to_object(__pyx_v_self, __pyx_v_itemp); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 414, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_r = __pyx_t_3;
- __pyx_t_3 = 0;
- goto __pyx_L0;
- }
-
- /* "View.MemoryView":403
- *
- *
- * def __getitem__(memoryview self, object index): # <<<<<<<<<<<<<<
- * if index is Ellipsis:
- * return self
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("View.MemoryView.memoryview.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_have_slices);
- __Pyx_XDECREF(__pyx_v_indices);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":416
- * return self.convert_item_to_object(itemp)
- *
- * def __setitem__(memoryview self, object index, object value): # <<<<<<<<<<<<<<
- * if self.view.readonly:
- * raise TypeError("Cannot assign to read-only memoryview")
- */
-
-/* Python wrapper */
-static int __pyx_memoryview___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value); /*proto*/
-static int __pyx_memoryview___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0);
- __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_6__setitem__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((PyObject *)__pyx_v_index), ((PyObject *)__pyx_v_value));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_6__setitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value) {
- PyObject *__pyx_v_have_slices = NULL;
- PyObject *__pyx_v_obj = NULL;
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("__setitem__", 0);
- __Pyx_INCREF(__pyx_v_index);
-
- /* "View.MemoryView":417
- *
- * def __setitem__(memoryview self, object index, object value):
- * if self.view.readonly: # <<<<<<<<<<<<<<
- * raise TypeError("Cannot assign to read-only memoryview")
- *
- */
- __pyx_t_1 = (__pyx_v_self->view.readonly != 0);
- if (unlikely(__pyx_t_1)) {
-
- /* "View.MemoryView":418
- * def __setitem__(memoryview self, object index, object value):
- * if self.view.readonly:
- * raise TypeError("Cannot assign to read-only memoryview") # <<<<<<<<<<<<<<
- *
- * have_slices, index = _unellipsify(index, self.view.ndim)
- */
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 418, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_Raise(__pyx_t_2, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __PYX_ERR(1, 418, __pyx_L1_error)
-
- /* "View.MemoryView":417
- *
- * def __setitem__(memoryview self, object index, object value):
- * if self.view.readonly: # <<<<<<<<<<<<<<
- * raise TypeError("Cannot assign to read-only memoryview")
- *
- */
- }
-
- /* "View.MemoryView":420
- * raise TypeError("Cannot assign to read-only memoryview")
- *
- * have_slices, index = _unellipsify(index, self.view.ndim) # <<<<<<<<<<<<<<
- *
- * if have_slices:
- */
- __pyx_t_2 = _unellipsify(__pyx_v_index, __pyx_v_self->view.ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 420, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (likely(__pyx_t_2 != Py_None)) {
- PyObject* sequence = __pyx_t_2;
- Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
- if (unlikely(size != 2)) {
- if (size > 2) __Pyx_RaiseTooManyValuesError(2);
- else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
- __PYX_ERR(1, 420, __pyx_L1_error)
- }
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0);
- __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1);
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_4);
- #else
- __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 420, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 420, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- #endif
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- } else {
- __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(1, 420, __pyx_L1_error)
- }
- __pyx_v_have_slices = __pyx_t_3;
- __pyx_t_3 = 0;
- __Pyx_DECREF_SET(__pyx_v_index, __pyx_t_4);
- __pyx_t_4 = 0;
-
- /* "View.MemoryView":422
- * have_slices, index = _unellipsify(index, self.view.ndim)
- *
- * if have_slices: # <<<<<<<<<<<<<<
- * obj = self.is_slice(value)
- * if obj:
- */
- __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_have_slices); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 422, __pyx_L1_error)
- if (__pyx_t_1) {
-
- /* "View.MemoryView":423
- *
- * if have_slices:
- * obj = self.is_slice(value) # <<<<<<<<<<<<<<
- * if obj:
- * self.setitem_slice_assignment(self[index], obj)
- */
- __pyx_t_2 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->is_slice(__pyx_v_self, __pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 423, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_v_obj = __pyx_t_2;
- __pyx_t_2 = 0;
-
- /* "View.MemoryView":424
- * if have_slices:
- * obj = self.is_slice(value)
- * if obj: # <<<<<<<<<<<<<<
- * self.setitem_slice_assignment(self[index], obj)
- * else:
- */
- __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_obj); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 424, __pyx_L1_error)
- if (__pyx_t_1) {
-
- /* "View.MemoryView":425
- * obj = self.is_slice(value)
- * if obj:
- * self.setitem_slice_assignment(self[index], obj) # <<<<<<<<<<<<<<
- * else:
- * self.setitem_slice_assign_scalar(self[index], value)
- */
- __pyx_t_2 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_v_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 425, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_4 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->setitem_slice_assignment(__pyx_v_self, __pyx_t_2, __pyx_v_obj); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 425, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-
- /* "View.MemoryView":424
- * if have_slices:
- * obj = self.is_slice(value)
- * if obj: # <<<<<<<<<<<<<<
- * self.setitem_slice_assignment(self[index], obj)
- * else:
- */
- goto __pyx_L5;
- }
-
- /* "View.MemoryView":427
- * self.setitem_slice_assignment(self[index], obj)
- * else:
- * self.setitem_slice_assign_scalar(self[index], value) # <<<<<<<<<<<<<<
- * else:
- * self.setitem_indexed(index, value)
- */
- /*else*/ {
- __pyx_t_4 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_v_index); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 427, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_memoryview_type))))) __PYX_ERR(1, 427, __pyx_L1_error)
- __pyx_t_2 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->setitem_slice_assign_scalar(__pyx_v_self, ((struct __pyx_memoryview_obj *)__pyx_t_4), __pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 427, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- }
- __pyx_L5:;
-
- /* "View.MemoryView":422
- * have_slices, index = _unellipsify(index, self.view.ndim)
- *
- * if have_slices: # <<<<<<<<<<<<<<
- * obj = self.is_slice(value)
- * if obj:
- */
- goto __pyx_L4;
- }
-
- /* "View.MemoryView":429
- * self.setitem_slice_assign_scalar(self[index], value)
- * else:
- * self.setitem_indexed(index, value) # <<<<<<<<<<<<<<
- *
- * cdef is_slice(self, obj):
- */
- /*else*/ {
- __pyx_t_2 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->setitem_indexed(__pyx_v_self, __pyx_v_index, __pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 429, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- }
- __pyx_L4:;
-
- /* "View.MemoryView":416
- * return self.convert_item_to_object(itemp)
- *
- * def __setitem__(memoryview self, object index, object value): # <<<<<<<<<<<<<<
- * if self.view.readonly:
- * raise TypeError("Cannot assign to read-only memoryview")
- */
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("View.MemoryView.memoryview.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_have_slices);
- __Pyx_XDECREF(__pyx_v_obj);
- __Pyx_XDECREF(__pyx_v_index);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":431
- * self.setitem_indexed(index, value)
- *
- * cdef is_slice(self, obj): # <<<<<<<<<<<<<<
- * if not isinstance(obj, memoryview):
- * try:
- */
-
-static PyObject *__pyx_memoryview_is_slice(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- PyObject *__pyx_t_8 = NULL;
- int __pyx_t_9;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("is_slice", 0);
- __Pyx_INCREF(__pyx_v_obj);
-
- /* "View.MemoryView":432
- *
- * cdef is_slice(self, obj):
- * if not isinstance(obj, memoryview): # <<<<<<<<<<<<<<
- * try:
- * obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
- */
- __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_obj, __pyx_memoryview_type);
- __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":433
- * cdef is_slice(self, obj):
- * if not isinstance(obj, memoryview):
- * try: # <<<<<<<<<<<<<<
- * obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
- * self.dtype_is_object)
- */
- {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
- __Pyx_XGOTREF(__pyx_t_3);
- __Pyx_XGOTREF(__pyx_t_4);
- __Pyx_XGOTREF(__pyx_t_5);
- /*try:*/ {
-
- /* "View.MemoryView":434
- * if not isinstance(obj, memoryview):
- * try:
- * obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS, # <<<<<<<<<<<<<<
- * self.dtype_is_object)
- * except TypeError:
- */
- __pyx_t_6 = __Pyx_PyInt_From_int(((__pyx_v_self->flags & (~PyBUF_WRITABLE)) | PyBUF_ANY_CONTIGUOUS)); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 434, __pyx_L4_error)
- __Pyx_GOTREF(__pyx_t_6);
-
- /* "View.MemoryView":435
- * try:
- * obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
- * self.dtype_is_object) # <<<<<<<<<<<<<<
- * except TypeError:
- * return None
- */
- __pyx_t_7 = __Pyx_PyBool_FromLong(__pyx_v_self->dtype_is_object); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 435, __pyx_L4_error)
- __Pyx_GOTREF(__pyx_t_7);
-
- /* "View.MemoryView":434
- * if not isinstance(obj, memoryview):
- * try:
- * obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS, # <<<<<<<<<<<<<<
- * self.dtype_is_object)
- * except TypeError:
- */
- __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 434, __pyx_L4_error)
- __Pyx_GOTREF(__pyx_t_8);
- __Pyx_INCREF(__pyx_v_obj);
- __Pyx_GIVEREF(__pyx_v_obj);
- PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_obj);
- __Pyx_GIVEREF(__pyx_t_6);
- PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_6);
- __Pyx_GIVEREF(__pyx_t_7);
- PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_7);
- __pyx_t_6 = 0;
- __pyx_t_7 = 0;
- __pyx_t_7 = __Pyx_PyObject_Call(((PyObject *)__pyx_memoryview_type), __pyx_t_8, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 434, __pyx_L4_error)
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_DECREF_SET(__pyx_v_obj, __pyx_t_7);
- __pyx_t_7 = 0;
-
- /* "View.MemoryView":433
- * cdef is_slice(self, obj):
- * if not isinstance(obj, memoryview):
- * try: # <<<<<<<<<<<<<<
- * obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
- * self.dtype_is_object)
- */
- }
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- goto __pyx_L9_try_end;
- __pyx_L4_error:;
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
-
- /* "View.MemoryView":436
- * obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
- * self.dtype_is_object)
- * except TypeError: # <<<<<<<<<<<<<<
- * return None
- *
- */
- __pyx_t_9 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError);
- if (__pyx_t_9) {
- __Pyx_AddTraceback("View.MemoryView.memoryview.is_slice", __pyx_clineno, __pyx_lineno, __pyx_filename);
- if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_8, &__pyx_t_6) < 0) __PYX_ERR(1, 436, __pyx_L6_except_error)
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_GOTREF(__pyx_t_8);
- __Pyx_GOTREF(__pyx_t_6);
-
- /* "View.MemoryView":437
- * self.dtype_is_object)
- * except TypeError:
- * return None # <<<<<<<<<<<<<<
- *
- * return obj
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- goto __pyx_L7_except_return;
- }
- goto __pyx_L6_except_error;
- __pyx_L6_except_error:;
-
- /* "View.MemoryView":433
- * cdef is_slice(self, obj):
- * if not isinstance(obj, memoryview):
- * try: # <<<<<<<<<<<<<<
- * obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
- * self.dtype_is_object)
- */
- __Pyx_XGIVEREF(__pyx_t_3);
- __Pyx_XGIVEREF(__pyx_t_4);
- __Pyx_XGIVEREF(__pyx_t_5);
- __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
- goto __pyx_L1_error;
- __pyx_L7_except_return:;
- __Pyx_XGIVEREF(__pyx_t_3);
- __Pyx_XGIVEREF(__pyx_t_4);
- __Pyx_XGIVEREF(__pyx_t_5);
- __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
- goto __pyx_L0;
- __pyx_L9_try_end:;
- }
-
- /* "View.MemoryView":432
- *
- * cdef is_slice(self, obj):
- * if not isinstance(obj, memoryview): # <<<<<<<<<<<<<<
- * try:
- * obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS,
- */
- }
-
- /* "View.MemoryView":439
- * return None
- *
- * return obj # <<<<<<<<<<<<<<
- *
- * cdef setitem_slice_assignment(self, dst, src):
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_obj);
- __pyx_r = __pyx_v_obj;
- goto __pyx_L0;
-
- /* "View.MemoryView":431
- * self.setitem_indexed(index, value)
- *
- * cdef is_slice(self, obj): # <<<<<<<<<<<<<<
- * if not isinstance(obj, memoryview):
- * try:
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_XDECREF(__pyx_t_8);
- __Pyx_AddTraceback("View.MemoryView.memoryview.is_slice", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_obj);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":441
- * return obj
- *
- * cdef setitem_slice_assignment(self, dst, src): # <<<<<<<<<<<<<<
- * cdef __Pyx_memviewslice dst_slice
- * cdef __Pyx_memviewslice src_slice
- */
-
-static PyObject *__pyx_memoryview_setitem_slice_assignment(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_dst, PyObject *__pyx_v_src) {
- __Pyx_memviewslice __pyx_v_dst_slice;
- __Pyx_memviewslice __pyx_v_src_slice;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_memviewslice *__pyx_t_1;
- __Pyx_memviewslice *__pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- int __pyx_t_4;
- int __pyx_t_5;
- int __pyx_t_6;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("setitem_slice_assignment", 0);
-
- /* "View.MemoryView":445
- * cdef __Pyx_memviewslice src_slice
- *
- * memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0], # <<<<<<<<<<<<<<
- * get_slice_from_memview(dst, &dst_slice)[0],
- * src.ndim, dst.ndim, self.dtype_is_object)
- */
- if (!(likely(((__pyx_v_src) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_src, __pyx_memoryview_type))))) __PYX_ERR(1, 445, __pyx_L1_error)
- __pyx_t_1 = __pyx_memoryview_get_slice_from_memoryview(((struct __pyx_memoryview_obj *)__pyx_v_src), (&__pyx_v_src_slice)); if (unlikely(__pyx_t_1 == ((__Pyx_memviewslice *)NULL))) __PYX_ERR(1, 445, __pyx_L1_error)
-
- /* "View.MemoryView":446
- *
- * memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0],
- * get_slice_from_memview(dst, &dst_slice)[0], # <<<<<<<<<<<<<<
- * src.ndim, dst.ndim, self.dtype_is_object)
- *
- */
- if (!(likely(((__pyx_v_dst) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_dst, __pyx_memoryview_type))))) __PYX_ERR(1, 446, __pyx_L1_error)
- __pyx_t_2 = __pyx_memoryview_get_slice_from_memoryview(((struct __pyx_memoryview_obj *)__pyx_v_dst), (&__pyx_v_dst_slice)); if (unlikely(__pyx_t_2 == ((__Pyx_memviewslice *)NULL))) __PYX_ERR(1, 446, __pyx_L1_error)
-
- /* "View.MemoryView":447
- * memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0],
- * get_slice_from_memview(dst, &dst_slice)[0],
- * src.ndim, dst.ndim, self.dtype_is_object) # <<<<<<<<<<<<<<
- *
- * cdef setitem_slice_assign_scalar(self, memoryview dst, value):
- */
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_src, __pyx_n_s_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 447, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 447, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_dst, __pyx_n_s_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 447, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 447, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "View.MemoryView":445
- * cdef __Pyx_memviewslice src_slice
- *
- * memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0], # <<<<<<<<<<<<<<
- * get_slice_from_memview(dst, &dst_slice)[0],
- * src.ndim, dst.ndim, self.dtype_is_object)
- */
- __pyx_t_6 = __pyx_memoryview_copy_contents((__pyx_t_1[0]), (__pyx_t_2[0]), __pyx_t_4, __pyx_t_5, __pyx_v_self->dtype_is_object); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(1, 445, __pyx_L1_error)
-
- /* "View.MemoryView":441
- * return obj
- *
- * cdef setitem_slice_assignment(self, dst, src): # <<<<<<<<<<<<<<
- * cdef __Pyx_memviewslice dst_slice
- * cdef __Pyx_memviewslice src_slice
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("View.MemoryView.memoryview.setitem_slice_assignment", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":449
- * src.ndim, dst.ndim, self.dtype_is_object)
- *
- * cdef setitem_slice_assign_scalar(self, memoryview dst, value): # <<<<<<<<<<<<<<
- * cdef int array[128]
- * cdef void *tmp = NULL
- */
-
-static PyObject *__pyx_memoryview_setitem_slice_assign_scalar(struct __pyx_memoryview_obj *__pyx_v_self, struct __pyx_memoryview_obj *__pyx_v_dst, PyObject *__pyx_v_value) {
- int __pyx_v_array[0x80];
- void *__pyx_v_tmp;
- void *__pyx_v_item;
- __Pyx_memviewslice *__pyx_v_dst_slice;
- __Pyx_memviewslice __pyx_v_tmp_slice;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_memviewslice *__pyx_t_1;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- int __pyx_t_4;
- int __pyx_t_5;
- char const *__pyx_t_6;
- PyObject *__pyx_t_7 = NULL;
- PyObject *__pyx_t_8 = NULL;
- PyObject *__pyx_t_9 = NULL;
- PyObject *__pyx_t_10 = NULL;
- PyObject *__pyx_t_11 = NULL;
- PyObject *__pyx_t_12 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("setitem_slice_assign_scalar", 0);
-
- /* "View.MemoryView":451
- * cdef setitem_slice_assign_scalar(self, memoryview dst, value):
- * cdef int array[128]
- * cdef void *tmp = NULL # <<<<<<<<<<<<<<
- * cdef void *item
- *
- */
- __pyx_v_tmp = NULL;
-
- /* "View.MemoryView":456
- * cdef __Pyx_memviewslice *dst_slice
- * cdef __Pyx_memviewslice tmp_slice
- * dst_slice = get_slice_from_memview(dst, &tmp_slice) # <<<<<<<<<<<<<<
- *
- * if self.view.itemsize > sizeof(array):
- */
- __pyx_t_1 = __pyx_memoryview_get_slice_from_memoryview(__pyx_v_dst, (&__pyx_v_tmp_slice)); if (unlikely(__pyx_t_1 == ((__Pyx_memviewslice *)NULL))) __PYX_ERR(1, 456, __pyx_L1_error)
- __pyx_v_dst_slice = __pyx_t_1;
-
- /* "View.MemoryView":458
- * dst_slice = get_slice_from_memview(dst, &tmp_slice)
- *
- * if self.view.itemsize > sizeof(array): # <<<<<<<<<<<<<<
- * tmp = PyMem_Malloc(self.view.itemsize)
- * if tmp == NULL:
- */
- __pyx_t_2 = ((((size_t)__pyx_v_self->view.itemsize) > (sizeof(__pyx_v_array))) != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":459
- *
- * if self.view.itemsize > sizeof(array):
- * tmp = PyMem_Malloc(self.view.itemsize) # <<<<<<<<<<<<<<
- * if tmp == NULL:
- * raise MemoryError
- */
- __pyx_v_tmp = PyMem_Malloc(__pyx_v_self->view.itemsize);
-
- /* "View.MemoryView":460
- * if self.view.itemsize > sizeof(array):
- * tmp = PyMem_Malloc(self.view.itemsize)
- * if tmp == NULL: # <<<<<<<<<<<<<<
- * raise MemoryError
- * item = tmp
- */
- __pyx_t_2 = ((__pyx_v_tmp == NULL) != 0);
- if (unlikely(__pyx_t_2)) {
-
- /* "View.MemoryView":461
- * tmp = PyMem_Malloc(self.view.itemsize)
- * if tmp == NULL:
- * raise MemoryError # <<<<<<<<<<<<<<
- * item = tmp
- * else:
- */
- PyErr_NoMemory(); __PYX_ERR(1, 461, __pyx_L1_error)
-
- /* "View.MemoryView":460
- * if self.view.itemsize > sizeof(array):
- * tmp = PyMem_Malloc(self.view.itemsize)
- * if tmp == NULL: # <<<<<<<<<<<<<<
- * raise MemoryError
- * item = tmp
- */
- }
-
- /* "View.MemoryView":462
- * if tmp == NULL:
- * raise MemoryError
- * item = tmp # <<<<<<<<<<<<<<
- * else:
- * item = array
- */
- __pyx_v_item = __pyx_v_tmp;
-
- /* "View.MemoryView":458
- * dst_slice = get_slice_from_memview(dst, &tmp_slice)
- *
- * if self.view.itemsize > sizeof(array): # <<<<<<<<<<<<<<
- * tmp = PyMem_Malloc(self.view.itemsize)
- * if tmp == NULL:
- */
- goto __pyx_L3;
- }
-
- /* "View.MemoryView":464
- * item = tmp
- * else:
- * item = array # <<<<<<<<<<<<<<
- *
- * try:
- */
- /*else*/ {
- __pyx_v_item = ((void *)__pyx_v_array);
- }
- __pyx_L3:;
-
- /* "View.MemoryView":466
- * item = array
- *
- * try: # <<<<<<<<<<<<<<
- * if self.dtype_is_object:
- * ( item)[0] = value
- */
- /*try:*/ {
-
- /* "View.MemoryView":467
- *
- * try:
- * if self.dtype_is_object: # <<<<<<<<<<<<<<
- * ( item)[0] = value
- * else:
- */
- __pyx_t_2 = (__pyx_v_self->dtype_is_object != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":468
- * try:
- * if self.dtype_is_object:
- * ( item)[0] = value # <<<<<<<<<<<<<<
- * else:
- * self.assign_item_from_object( item, value)
- */
- (((PyObject **)__pyx_v_item)[0]) = ((PyObject *)__pyx_v_value);
-
- /* "View.MemoryView":467
- *
- * try:
- * if self.dtype_is_object: # <<<<<<<<<<<<<<
- * ( item)[0] = value
- * else:
- */
- goto __pyx_L8;
- }
-
- /* "View.MemoryView":470
- * ( item)[0] = value
- * else:
- * self.assign_item_from_object( item, value) # <<<<<<<<<<<<<<
- *
- *
- */
- /*else*/ {
- __pyx_t_3 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->assign_item_from_object(__pyx_v_self, ((char *)__pyx_v_item), __pyx_v_value); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 470, __pyx_L6_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- }
- __pyx_L8:;
-
- /* "View.MemoryView":474
- *
- *
- * if self.view.suboffsets != NULL: # <<<<<<<<<<<<<<
- * assert_direct_dimensions(self.view.suboffsets, self.view.ndim)
- * slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize,
- */
- __pyx_t_2 = ((__pyx_v_self->view.suboffsets != NULL) != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":475
- *
- * if self.view.suboffsets != NULL:
- * assert_direct_dimensions(self.view.suboffsets, self.view.ndim) # <<<<<<<<<<<<<<
- * slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize,
- * item, self.dtype_is_object)
- */
- __pyx_t_3 = assert_direct_dimensions(__pyx_v_self->view.suboffsets, __pyx_v_self->view.ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 475, __pyx_L6_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "View.MemoryView":474
- *
- *
- * if self.view.suboffsets != NULL: # <<<<<<<<<<<<<<
- * assert_direct_dimensions(self.view.suboffsets, self.view.ndim)
- * slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize,
- */
- }
-
- /* "View.MemoryView":476
- * if self.view.suboffsets != NULL:
- * assert_direct_dimensions(self.view.suboffsets, self.view.ndim)
- * slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize, # <<<<<<<<<<<<<<
- * item, self.dtype_is_object)
- * finally:
- */
- __pyx_memoryview_slice_assign_scalar(__pyx_v_dst_slice, __pyx_v_dst->view.ndim, __pyx_v_self->view.itemsize, __pyx_v_item, __pyx_v_self->dtype_is_object);
- }
-
- /* "View.MemoryView":479
- * item, self.dtype_is_object)
- * finally:
- * PyMem_Free(tmp) # <<<<<<<<<<<<<<
- *
- * cdef setitem_indexed(self, index, value):
- */
- /*finally:*/ {
- /*normal exit:*/{
- PyMem_Free(__pyx_v_tmp);
- goto __pyx_L7;
- }
- __pyx_L6_error:;
- /*exception exit:*/{
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0;
- __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
- if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9) < 0)) __Pyx_ErrFetch(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
- __Pyx_XGOTREF(__pyx_t_7);
- __Pyx_XGOTREF(__pyx_t_8);
- __Pyx_XGOTREF(__pyx_t_9);
- __Pyx_XGOTREF(__pyx_t_10);
- __Pyx_XGOTREF(__pyx_t_11);
- __Pyx_XGOTREF(__pyx_t_12);
- __pyx_t_4 = __pyx_lineno; __pyx_t_5 = __pyx_clineno; __pyx_t_6 = __pyx_filename;
- {
- PyMem_Free(__pyx_v_tmp);
- }
- if (PY_MAJOR_VERSION >= 3) {
- __Pyx_XGIVEREF(__pyx_t_10);
- __Pyx_XGIVEREF(__pyx_t_11);
- __Pyx_XGIVEREF(__pyx_t_12);
- __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
- }
- __Pyx_XGIVEREF(__pyx_t_7);
- __Pyx_XGIVEREF(__pyx_t_8);
- __Pyx_XGIVEREF(__pyx_t_9);
- __Pyx_ErrRestore(__pyx_t_7, __pyx_t_8, __pyx_t_9);
- __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0;
- __pyx_lineno = __pyx_t_4; __pyx_clineno = __pyx_t_5; __pyx_filename = __pyx_t_6;
- goto __pyx_L1_error;
- }
- __pyx_L7:;
- }
-
- /* "View.MemoryView":449
- * src.ndim, dst.ndim, self.dtype_is_object)
- *
- * cdef setitem_slice_assign_scalar(self, memoryview dst, value): # <<<<<<<<<<<<<<
- * cdef int array[128]
- * cdef void *tmp = NULL
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("View.MemoryView.memoryview.setitem_slice_assign_scalar", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":481
- * PyMem_Free(tmp)
- *
- * cdef setitem_indexed(self, index, value): # <<<<<<<<<<<<<<
- * cdef char *itemp = self.get_item_pointer(index)
- * self.assign_item_from_object(itemp, value)
- */
-
-static PyObject *__pyx_memoryview_setitem_indexed(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value) {
- char *__pyx_v_itemp;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- char *__pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("setitem_indexed", 0);
-
- /* "View.MemoryView":482
- *
- * cdef setitem_indexed(self, index, value):
- * cdef char *itemp = self.get_item_pointer(index) # <<<<<<<<<<<<<<
- * self.assign_item_from_object(itemp, value)
- *
- */
- __pyx_t_1 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->get_item_pointer(__pyx_v_self, __pyx_v_index); if (unlikely(__pyx_t_1 == ((char *)NULL))) __PYX_ERR(1, 482, __pyx_L1_error)
- __pyx_v_itemp = __pyx_t_1;
-
- /* "View.MemoryView":483
- * cdef setitem_indexed(self, index, value):
- * cdef char *itemp = self.get_item_pointer(index)
- * self.assign_item_from_object(itemp, value) # <<<<<<<<<<<<<<
- *
- * cdef convert_item_to_object(self, char *itemp):
- */
- __pyx_t_2 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->assign_item_from_object(__pyx_v_self, __pyx_v_itemp, __pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 483, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "View.MemoryView":481
- * PyMem_Free(tmp)
- *
- * cdef setitem_indexed(self, index, value): # <<<<<<<<<<<<<<
- * cdef char *itemp = self.get_item_pointer(index)
- * self.assign_item_from_object(itemp, value)
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("View.MemoryView.memoryview.setitem_indexed", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":485
- * self.assign_item_from_object(itemp, value)
- *
- * cdef convert_item_to_object(self, char *itemp): # <<<<<<<<<<<<<<
- * """Only used if instantiated manually by the user, or if Cython doesn't
- * know how to convert the type"""
- */
-
-static PyObject *__pyx_memoryview_convert_item_to_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp) {
- PyObject *__pyx_v_struct = NULL;
- PyObject *__pyx_v_bytesitem = 0;
- PyObject *__pyx_v_result = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- int __pyx_t_8;
- PyObject *__pyx_t_9 = NULL;
- size_t __pyx_t_10;
- int __pyx_t_11;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("convert_item_to_object", 0);
-
- /* "View.MemoryView":488
- * """Only used if instantiated manually by the user, or if Cython doesn't
- * know how to convert the type"""
- * import struct # <<<<<<<<<<<<<<
- * cdef bytes bytesitem
- *
- */
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_struct, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 488, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_struct = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "View.MemoryView":491
- * cdef bytes bytesitem
- *
- * bytesitem = itemp[:self.view.itemsize] # <<<<<<<<<<<<<<
- * try:
- * result = struct.unpack(self.view.format, bytesitem)
- */
- __pyx_t_1 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_itemp + 0, __pyx_v_self->view.itemsize - 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 491, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_bytesitem = ((PyObject*)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "View.MemoryView":492
- *
- * bytesitem = itemp[:self.view.itemsize]
- * try: # <<<<<<<<<<<<<<
- * result = struct.unpack(self.view.format, bytesitem)
- * except struct.error:
- */
- {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ExceptionSave(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4);
- __Pyx_XGOTREF(__pyx_t_2);
- __Pyx_XGOTREF(__pyx_t_3);
- __Pyx_XGOTREF(__pyx_t_4);
- /*try:*/ {
-
- /* "View.MemoryView":493
- * bytesitem = itemp[:self.view.itemsize]
- * try:
- * result = struct.unpack(self.view.format, bytesitem) # <<<<<<<<<<<<<<
- * except struct.error:
- * raise ValueError("Unable to convert item to object")
- */
- __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_unpack); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 493, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_5);
- __pyx_t_6 = __Pyx_PyBytes_FromString(__pyx_v_self->view.format); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 493, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_6);
- __pyx_t_7 = NULL;
- __pyx_t_8 = 0;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
- __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
- if (likely(__pyx_t_7)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
- __Pyx_INCREF(__pyx_t_7);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_5, function);
- __pyx_t_8 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_5)) {
- PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_6, __pyx_v_bytesitem};
- __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 493, __pyx_L3_error)
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
- PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_6, __pyx_v_bytesitem};
- __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 493, __pyx_L3_error)
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- } else
- #endif
- {
- __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 493, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_9);
- if (__pyx_t_7) {
- __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
- }
- __Pyx_GIVEREF(__pyx_t_6);
- PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_6);
- __Pyx_INCREF(__pyx_v_bytesitem);
- __Pyx_GIVEREF(__pyx_v_bytesitem);
- PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_v_bytesitem);
- __pyx_t_6 = 0;
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 493, __pyx_L3_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- }
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __pyx_v_result = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "View.MemoryView":492
- *
- * bytesitem = itemp[:self.view.itemsize]
- * try: # <<<<<<<<<<<<<<
- * result = struct.unpack(self.view.format, bytesitem)
- * except struct.error:
- */
- }
-
- /* "View.MemoryView":497
- * raise ValueError("Unable to convert item to object")
- * else:
- * if len(self.view.format) == 1: # <<<<<<<<<<<<<<
- * return result[0]
- * return result
- */
- /*else:*/ {
- __pyx_t_10 = strlen(__pyx_v_self->view.format);
- __pyx_t_11 = ((__pyx_t_10 == 1) != 0);
- if (__pyx_t_11) {
-
- /* "View.MemoryView":498
- * else:
- * if len(self.view.format) == 1:
- * return result[0] # <<<<<<<<<<<<<<
- * return result
- *
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_result, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 498, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L6_except_return;
-
- /* "View.MemoryView":497
- * raise ValueError("Unable to convert item to object")
- * else:
- * if len(self.view.format) == 1: # <<<<<<<<<<<<<<
- * return result[0]
- * return result
- */
- }
-
- /* "View.MemoryView":499
- * if len(self.view.format) == 1:
- * return result[0]
- * return result # <<<<<<<<<<<<<<
- *
- * cdef assign_item_from_object(self, char *itemp, object value):
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_result);
- __pyx_r = __pyx_v_result;
- goto __pyx_L6_except_return;
- }
- __pyx_L3_error:;
- __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
-
- /* "View.MemoryView":494
- * try:
- * result = struct.unpack(self.view.format, bytesitem)
- * except struct.error: # <<<<<<<<<<<<<<
- * raise ValueError("Unable to convert item to object")
- * else:
- */
- __Pyx_ErrFetch(&__pyx_t_1, &__pyx_t_5, &__pyx_t_9);
- __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_error); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 494, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_6);
- __pyx_t_8 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_1, __pyx_t_6);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __Pyx_ErrRestore(__pyx_t_1, __pyx_t_5, __pyx_t_9);
- __pyx_t_1 = 0; __pyx_t_5 = 0; __pyx_t_9 = 0;
- if (__pyx_t_8) {
- __Pyx_AddTraceback("View.MemoryView.memoryview.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
- if (__Pyx_GetException(&__pyx_t_9, &__pyx_t_5, &__pyx_t_1) < 0) __PYX_ERR(1, 494, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_9);
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_GOTREF(__pyx_t_1);
-
- /* "View.MemoryView":495
- * result = struct.unpack(self.view.format, bytesitem)
- * except struct.error:
- * raise ValueError("Unable to convert item to object") # <<<<<<<<<<<<<<
- * else:
- * if len(self.view.format) == 1:
- */
- __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 495, __pyx_L5_except_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_Raise(__pyx_t_6, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __PYX_ERR(1, 495, __pyx_L5_except_error)
- }
- goto __pyx_L5_except_error;
- __pyx_L5_except_error:;
-
- /* "View.MemoryView":492
- *
- * bytesitem = itemp[:self.view.itemsize]
- * try: # <<<<<<<<<<<<<<
- * result = struct.unpack(self.view.format, bytesitem)
- * except struct.error:
- */
- __Pyx_XGIVEREF(__pyx_t_2);
- __Pyx_XGIVEREF(__pyx_t_3);
- __Pyx_XGIVEREF(__pyx_t_4);
- __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
- goto __pyx_L1_error;
- __pyx_L6_except_return:;
- __Pyx_XGIVEREF(__pyx_t_2);
- __Pyx_XGIVEREF(__pyx_t_3);
- __Pyx_XGIVEREF(__pyx_t_4);
- __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4);
- goto __pyx_L0;
- }
-
- /* "View.MemoryView":485
- * self.assign_item_from_object(itemp, value)
- *
- * cdef convert_item_to_object(self, char *itemp): # <<<<<<<<<<<<<<
- * """Only used if instantiated manually by the user, or if Cython doesn't
- * know how to convert the type"""
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_XDECREF(__pyx_t_9);
- __Pyx_AddTraceback("View.MemoryView.memoryview.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_struct);
- __Pyx_XDECREF(__pyx_v_bytesitem);
- __Pyx_XDECREF(__pyx_v_result);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":501
- * return result
- *
- * cdef assign_item_from_object(self, char *itemp, object value): # <<<<<<<<<<<<<<
- * """Only used if instantiated manually by the user, or if Cython doesn't
- * know how to convert the type"""
- */
-
-static PyObject *__pyx_memoryview_assign_item_from_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value) {
- PyObject *__pyx_v_struct = NULL;
- char __pyx_v_c;
- PyObject *__pyx_v_bytesvalue = 0;
- Py_ssize_t __pyx_v_i;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_t_2;
- int __pyx_t_3;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- PyObject *__pyx_t_6 = NULL;
- int __pyx_t_7;
- PyObject *__pyx_t_8 = NULL;
- Py_ssize_t __pyx_t_9;
- PyObject *__pyx_t_10 = NULL;
- char *__pyx_t_11;
- char *__pyx_t_12;
- char *__pyx_t_13;
- char *__pyx_t_14;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("assign_item_from_object", 0);
-
- /* "View.MemoryView":504
- * """Only used if instantiated manually by the user, or if Cython doesn't
- * know how to convert the type"""
- * import struct # <<<<<<<<<<<<<<
- * cdef char c
- * cdef bytes bytesvalue
- */
- __pyx_t_1 = __Pyx_Import(__pyx_n_s_struct, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 504, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_v_struct = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "View.MemoryView":509
- * cdef Py_ssize_t i
- *
- * if isinstance(value, tuple): # <<<<<<<<<<<<<<
- * bytesvalue = struct.pack(self.view.format, *value)
- * else:
- */
- __pyx_t_2 = PyTuple_Check(__pyx_v_value);
- __pyx_t_3 = (__pyx_t_2 != 0);
- if (__pyx_t_3) {
-
- /* "View.MemoryView":510
- *
- * if isinstance(value, tuple):
- * bytesvalue = struct.pack(self.view.format, *value) # <<<<<<<<<<<<<<
- * else:
- * bytesvalue = struct.pack(self.view.format, value)
- */
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_pack); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 510, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_4 = __Pyx_PyBytes_FromString(__pyx_v_self->view.format); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 510, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 510, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_GIVEREF(__pyx_t_4);
- PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
- __pyx_t_4 = 0;
- __pyx_t_4 = __Pyx_PySequence_Tuple(__pyx_v_value); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 510, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_6 = PyNumber_Add(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 510, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 510, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- if (!(likely(PyBytes_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(1, 510, __pyx_L1_error)
- __pyx_v_bytesvalue = ((PyObject*)__pyx_t_4);
- __pyx_t_4 = 0;
-
- /* "View.MemoryView":509
- * cdef Py_ssize_t i
- *
- * if isinstance(value, tuple): # <<<<<<<<<<<<<<
- * bytesvalue = struct.pack(self.view.format, *value)
- * else:
- */
- goto __pyx_L3;
- }
-
- /* "View.MemoryView":512
- * bytesvalue = struct.pack(self.view.format, *value)
- * else:
- * bytesvalue = struct.pack(self.view.format, value) # <<<<<<<<<<<<<<
- *
- * for i, c in enumerate(bytesvalue):
- */
- /*else*/ {
- __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_pack); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 512, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __pyx_t_1 = __Pyx_PyBytes_FromString(__pyx_v_self->view.format); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 512, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_5 = NULL;
- __pyx_t_7 = 0;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
- __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
- if (likely(__pyx_t_5)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_6, function);
- __pyx_t_7 = 1;
- }
- }
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(__pyx_t_6)) {
- PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_1, __pyx_v_value};
- __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 512, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- } else
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
- PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_1, __pyx_v_value};
- __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 512, __pyx_L1_error)
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- } else
- #endif
- {
- __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 512, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_8);
- if (__pyx_t_5) {
- __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); __pyx_t_5 = NULL;
- }
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_1);
- __Pyx_INCREF(__pyx_v_value);
- __Pyx_GIVEREF(__pyx_v_value);
- PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_value);
- __pyx_t_1 = 0;
- __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 512, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
- }
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- if (!(likely(PyBytes_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(1, 512, __pyx_L1_error)
- __pyx_v_bytesvalue = ((PyObject*)__pyx_t_4);
- __pyx_t_4 = 0;
- }
- __pyx_L3:;
-
- /* "View.MemoryView":514
- * bytesvalue = struct.pack(self.view.format, value)
- *
- * for i, c in enumerate(bytesvalue): # <<<<<<<<<<<<<<
- * itemp[i] = c
- *
- */
- __pyx_t_9 = 0;
- if (unlikely(__pyx_v_bytesvalue == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' is not iterable");
- __PYX_ERR(1, 514, __pyx_L1_error)
- }
- __Pyx_INCREF(__pyx_v_bytesvalue);
- __pyx_t_10 = __pyx_v_bytesvalue;
- __pyx_t_12 = PyBytes_AS_STRING(__pyx_t_10);
- __pyx_t_13 = (__pyx_t_12 + PyBytes_GET_SIZE(__pyx_t_10));
- for (__pyx_t_14 = __pyx_t_12; __pyx_t_14 < __pyx_t_13; __pyx_t_14++) {
- __pyx_t_11 = __pyx_t_14;
- __pyx_v_c = (__pyx_t_11[0]);
-
- /* "View.MemoryView":515
- *
- * for i, c in enumerate(bytesvalue):
- * itemp[i] = c # <<<<<<<<<<<<<<
- *
- * @cname('getbuffer')
- */
- __pyx_v_i = __pyx_t_9;
-
- /* "View.MemoryView":514
- * bytesvalue = struct.pack(self.view.format, value)
- *
- * for i, c in enumerate(bytesvalue): # <<<<<<<<<<<<<<
- * itemp[i] = c
- *
- */
- __pyx_t_9 = (__pyx_t_9 + 1);
-
- /* "View.MemoryView":515
- *
- * for i, c in enumerate(bytesvalue):
- * itemp[i] = c # <<<<<<<<<<<<<<
- *
- * @cname('getbuffer')
- */
- (__pyx_v_itemp[__pyx_v_i]) = __pyx_v_c;
- }
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
-
- /* "View.MemoryView":501
- * return result
- *
- * cdef assign_item_from_object(self, char *itemp, object value): # <<<<<<<<<<<<<<
- * """Only used if instantiated manually by the user, or if Cython doesn't
- * know how to convert the type"""
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_8);
- __Pyx_XDECREF(__pyx_t_10);
- __Pyx_AddTraceback("View.MemoryView.memoryview.assign_item_from_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_struct);
- __Pyx_XDECREF(__pyx_v_bytesvalue);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":518
- *
- * @cname('getbuffer')
- * def __getbuffer__(self, Py_buffer *info, int flags): # <<<<<<<<<<<<<<
- * if flags & PyBUF_WRITABLE and self.view.readonly:
- * raise ValueError("Cannot create writable memory view from read-only memoryview")
- */
-
-/* Python wrapper */
-static CYTHON_UNUSED int __pyx_memoryview_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/
-static CYTHON_UNUSED int __pyx_memoryview_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0);
- __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_8__getbuffer__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_8__getbuffer__(struct __pyx_memoryview_obj *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- Py_ssize_t *__pyx_t_4;
- char *__pyx_t_5;
- void *__pyx_t_6;
- int __pyx_t_7;
- Py_ssize_t __pyx_t_8;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- if (__pyx_v_info == NULL) {
- PyErr_SetString(PyExc_BufferError, "PyObject_GetBuffer: view==NULL argument is obsolete");
- return -1;
- }
- __Pyx_RefNannySetupContext("__getbuffer__", 0);
- __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(__pyx_v_info->obj);
-
- /* "View.MemoryView":519
- * @cname('getbuffer')
- * def __getbuffer__(self, Py_buffer *info, int flags):
- * if flags & PyBUF_WRITABLE and self.view.readonly: # <<<<<<<<<<<<<<
- * raise ValueError("Cannot create writable memory view from read-only memoryview")
- *
- */
- __pyx_t_2 = ((__pyx_v_flags & PyBUF_WRITABLE) != 0);
- if (__pyx_t_2) {
- } else {
- __pyx_t_1 = __pyx_t_2;
- goto __pyx_L4_bool_binop_done;
- }
- __pyx_t_2 = (__pyx_v_self->view.readonly != 0);
- __pyx_t_1 = __pyx_t_2;
- __pyx_L4_bool_binop_done:;
- if (unlikely(__pyx_t_1)) {
-
- /* "View.MemoryView":520
- * def __getbuffer__(self, Py_buffer *info, int flags):
- * if flags & PyBUF_WRITABLE and self.view.readonly:
- * raise ValueError("Cannot create writable memory view from read-only memoryview") # <<<<<<<<<<<<<<
- *
- * if flags & PyBUF_ND:
- */
- __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 520, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_Raise(__pyx_t_3, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __PYX_ERR(1, 520, __pyx_L1_error)
-
- /* "View.MemoryView":519
- * @cname('getbuffer')
- * def __getbuffer__(self, Py_buffer *info, int flags):
- * if flags & PyBUF_WRITABLE and self.view.readonly: # <<<<<<<<<<<<<<
- * raise ValueError("Cannot create writable memory view from read-only memoryview")
- *
- */
- }
-
- /* "View.MemoryView":522
- * raise ValueError("Cannot create writable memory view from read-only memoryview")
- *
- * if flags & PyBUF_ND: # <<<<<<<<<<<<<<
- * info.shape = self.view.shape
- * else:
- */
- __pyx_t_1 = ((__pyx_v_flags & PyBUF_ND) != 0);
- if (__pyx_t_1) {
-
- /* "View.MemoryView":523
- *
- * if flags & PyBUF_ND:
- * info.shape = self.view.shape # <<<<<<<<<<<<<<
- * else:
- * info.shape = NULL
- */
- __pyx_t_4 = __pyx_v_self->view.shape;
- __pyx_v_info->shape = __pyx_t_4;
-
- /* "View.MemoryView":522
- * raise ValueError("Cannot create writable memory view from read-only memoryview")
- *
- * if flags & PyBUF_ND: # <<<<<<<<<<<<<<
- * info.shape = self.view.shape
- * else:
- */
- goto __pyx_L6;
- }
-
- /* "View.MemoryView":525
- * info.shape = self.view.shape
- * else:
- * info.shape = NULL # <<<<<<<<<<<<<<
- *
- * if flags & PyBUF_STRIDES:
- */
- /*else*/ {
- __pyx_v_info->shape = NULL;
- }
- __pyx_L6:;
-
- /* "View.MemoryView":527
- * info.shape = NULL
- *
- * if flags & PyBUF_STRIDES: # <<<<<<<<<<<<<<
- * info.strides = self.view.strides
- * else:
- */
- __pyx_t_1 = ((__pyx_v_flags & PyBUF_STRIDES) != 0);
- if (__pyx_t_1) {
-
- /* "View.MemoryView":528
- *
- * if flags & PyBUF_STRIDES:
- * info.strides = self.view.strides # <<<<<<<<<<<<<<
- * else:
- * info.strides = NULL
- */
- __pyx_t_4 = __pyx_v_self->view.strides;
- __pyx_v_info->strides = __pyx_t_4;
-
- /* "View.MemoryView":527
- * info.shape = NULL
- *
- * if flags & PyBUF_STRIDES: # <<<<<<<<<<<<<<
- * info.strides = self.view.strides
- * else:
- */
- goto __pyx_L7;
- }
-
- /* "View.MemoryView":530
- * info.strides = self.view.strides
- * else:
- * info.strides = NULL # <<<<<<<<<<<<<<
- *
- * if flags & PyBUF_INDIRECT:
- */
- /*else*/ {
- __pyx_v_info->strides = NULL;
- }
- __pyx_L7:;
-
- /* "View.MemoryView":532
- * info.strides = NULL
- *
- * if flags & PyBUF_INDIRECT: # <<<<<<<<<<<<<<
- * info.suboffsets = self.view.suboffsets
- * else:
- */
- __pyx_t_1 = ((__pyx_v_flags & PyBUF_INDIRECT) != 0);
- if (__pyx_t_1) {
-
- /* "View.MemoryView":533
- *
- * if flags & PyBUF_INDIRECT:
- * info.suboffsets = self.view.suboffsets # <<<<<<<<<<<<<<
- * else:
- * info.suboffsets = NULL
- */
- __pyx_t_4 = __pyx_v_self->view.suboffsets;
- __pyx_v_info->suboffsets = __pyx_t_4;
-
- /* "View.MemoryView":532
- * info.strides = NULL
- *
- * if flags & PyBUF_INDIRECT: # <<<<<<<<<<<<<<
- * info.suboffsets = self.view.suboffsets
- * else:
- */
- goto __pyx_L8;
- }
-
- /* "View.MemoryView":535
- * info.suboffsets = self.view.suboffsets
- * else:
- * info.suboffsets = NULL # <<<<<<<<<<<<<<
- *
- * if flags & PyBUF_FORMAT:
- */
- /*else*/ {
- __pyx_v_info->suboffsets = NULL;
- }
- __pyx_L8:;
-
- /* "View.MemoryView":537
- * info.suboffsets = NULL
- *
- * if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<<
- * info.format = self.view.format
- * else:
- */
- __pyx_t_1 = ((__pyx_v_flags & PyBUF_FORMAT) != 0);
- if (__pyx_t_1) {
-
- /* "View.MemoryView":538
- *
- * if flags & PyBUF_FORMAT:
- * info.format = self.view.format # <<<<<<<<<<<<<<
- * else:
- * info.format = NULL
- */
- __pyx_t_5 = __pyx_v_self->view.format;
- __pyx_v_info->format = __pyx_t_5;
-
- /* "View.MemoryView":537
- * info.suboffsets = NULL
- *
- * if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<<
- * info.format = self.view.format
- * else:
- */
- goto __pyx_L9;
- }
-
- /* "View.MemoryView":540
- * info.format = self.view.format
- * else:
- * info.format = NULL # <<<<<<<<<<<<<<
- *
- * info.buf = self.view.buf
- */
- /*else*/ {
- __pyx_v_info->format = NULL;
- }
- __pyx_L9:;
-
- /* "View.MemoryView":542
- * info.format = NULL
- *
- * info.buf = self.view.buf # <<<<<<<<<<<<<<
- * info.ndim = self.view.ndim
- * info.itemsize = self.view.itemsize
- */
- __pyx_t_6 = __pyx_v_self->view.buf;
- __pyx_v_info->buf = __pyx_t_6;
-
- /* "View.MemoryView":543
- *
- * info.buf = self.view.buf
- * info.ndim = self.view.ndim # <<<<<<<<<<<<<<
- * info.itemsize = self.view.itemsize
- * info.len = self.view.len
- */
- __pyx_t_7 = __pyx_v_self->view.ndim;
- __pyx_v_info->ndim = __pyx_t_7;
-
- /* "View.MemoryView":544
- * info.buf = self.view.buf
- * info.ndim = self.view.ndim
- * info.itemsize = self.view.itemsize # <<<<<<<<<<<<<<
- * info.len = self.view.len
- * info.readonly = self.view.readonly
- */
- __pyx_t_8 = __pyx_v_self->view.itemsize;
- __pyx_v_info->itemsize = __pyx_t_8;
-
- /* "View.MemoryView":545
- * info.ndim = self.view.ndim
- * info.itemsize = self.view.itemsize
- * info.len = self.view.len # <<<<<<<<<<<<<<
- * info.readonly = self.view.readonly
- * info.obj = self
- */
- __pyx_t_8 = __pyx_v_self->view.len;
- __pyx_v_info->len = __pyx_t_8;
-
- /* "View.MemoryView":546
- * info.itemsize = self.view.itemsize
- * info.len = self.view.len
- * info.readonly = self.view.readonly # <<<<<<<<<<<<<<
- * info.obj = self
- *
- */
- __pyx_t_1 = __pyx_v_self->view.readonly;
- __pyx_v_info->readonly = __pyx_t_1;
-
- /* "View.MemoryView":547
- * info.len = self.view.len
- * info.readonly = self.view.readonly
- * info.obj = self # <<<<<<<<<<<<<<
- *
- * __pyx_getbuffer = capsule( &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)")
- */
- __Pyx_INCREF(((PyObject *)__pyx_v_self));
- __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
- __Pyx_GOTREF(__pyx_v_info->obj);
- __Pyx_DECREF(__pyx_v_info->obj);
- __pyx_v_info->obj = ((PyObject *)__pyx_v_self);
-
- /* "View.MemoryView":518
- *
- * @cname('getbuffer')
- * def __getbuffer__(self, Py_buffer *info, int flags): # <<<<<<<<<<<<<<
- * if flags & PyBUF_WRITABLE and self.view.readonly:
- * raise ValueError("Cannot create writable memory view from read-only memoryview")
- */
-
- /* function exit code */
- __pyx_r = 0;
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("View.MemoryView.memoryview.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- if (__pyx_v_info->obj != NULL) {
- __Pyx_GOTREF(__pyx_v_info->obj);
- __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0;
- }
- goto __pyx_L2;
- __pyx_L0:;
- if (__pyx_v_info->obj == Py_None) {
- __Pyx_GOTREF(__pyx_v_info->obj);
- __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0;
- }
- __pyx_L2:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":553
- *
- * @property
- * def T(self): # <<<<<<<<<<<<<<
- * cdef _memoryviewslice result = memoryview_copy(self)
- * transpose_memslice(&result.from_slice)
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_1T_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_1T_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_1T___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_1T___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
- struct __pyx_memoryviewslice_obj *__pyx_v_result = 0;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_t_2;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("__get__", 0);
-
- /* "View.MemoryView":554
- * @property
- * def T(self):
- * cdef _memoryviewslice result = memoryview_copy(self) # <<<<<<<<<<<<<<
- * transpose_memslice(&result.from_slice)
- * return result
- */
- __pyx_t_1 = __pyx_memoryview_copy_object(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 554, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_memoryviewslice_type))))) __PYX_ERR(1, 554, __pyx_L1_error)
- __pyx_v_result = ((struct __pyx_memoryviewslice_obj *)__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "View.MemoryView":555
- * def T(self):
- * cdef _memoryviewslice result = memoryview_copy(self)
- * transpose_memslice(&result.from_slice) # <<<<<<<<<<<<<<
- * return result
- *
- */
- __pyx_t_2 = __pyx_memslice_transpose((&__pyx_v_result->from_slice)); if (unlikely(__pyx_t_2 == ((int)0))) __PYX_ERR(1, 555, __pyx_L1_error)
-
- /* "View.MemoryView":556
- * cdef _memoryviewslice result = memoryview_copy(self)
- * transpose_memslice(&result.from_slice)
- * return result # <<<<<<<<<<<<<<
- *
- * @property
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(((PyObject *)__pyx_v_result));
- __pyx_r = ((PyObject *)__pyx_v_result);
- goto __pyx_L0;
-
- /* "View.MemoryView":553
- *
- * @property
- * def T(self): # <<<<<<<<<<<<<<
- * cdef _memoryviewslice result = memoryview_copy(self)
- * transpose_memslice(&result.from_slice)
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("View.MemoryView.memoryview.T.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF((PyObject *)__pyx_v_result);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":559
- *
- * @property
- * def base(self): # <<<<<<<<<<<<<<
- * return self.obj
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4base_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4base_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_4base___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4base___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__", 0);
-
- /* "View.MemoryView":560
- * @property
- * def base(self):
- * return self.obj # <<<<<<<<<<<<<<
- *
- * @property
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_self->obj);
- __pyx_r = __pyx_v_self->obj;
- goto __pyx_L0;
-
- /* "View.MemoryView":559
- *
- * @property
- * def base(self): # <<<<<<<<<<<<<<
- * return self.obj
- *
- */
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":563
- *
- * @property
- * def shape(self): # <<<<<<<<<<<<<<
- * return tuple([length for length in self.view.shape[:self.view.ndim]])
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_5shape_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_5shape_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_5shape___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_5shape___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
- Py_ssize_t __pyx_v_length;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- Py_ssize_t *__pyx_t_2;
- Py_ssize_t *__pyx_t_3;
- Py_ssize_t *__pyx_t_4;
- PyObject *__pyx_t_5 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("__get__", 0);
-
- /* "View.MemoryView":564
- * @property
- * def shape(self):
- * return tuple([length for length in self.view.shape[:self.view.ndim]]) # <<<<<<<<<<<<<<
- *
- * @property
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 564, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_3 = (__pyx_v_self->view.shape + __pyx_v_self->view.ndim);
- for (__pyx_t_4 = __pyx_v_self->view.shape; __pyx_t_4 < __pyx_t_3; __pyx_t_4++) {
- __pyx_t_2 = __pyx_t_4;
- __pyx_v_length = (__pyx_t_2[0]);
- __pyx_t_5 = PyInt_FromSsize_t(__pyx_v_length); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 564, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_5))) __PYX_ERR(1, 564, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- }
- __pyx_t_5 = PyList_AsTuple(((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 564, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_r = __pyx_t_5;
- __pyx_t_5 = 0;
- goto __pyx_L0;
-
- /* "View.MemoryView":563
- *
- * @property
- * def shape(self): # <<<<<<<<<<<<<<
- * return tuple([length for length in self.view.shape[:self.view.ndim]])
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("View.MemoryView.memoryview.shape.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":567
- *
- * @property
- * def strides(self): # <<<<<<<<<<<<<<
- * if self.view.strides == NULL:
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_7strides_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_7strides_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
- Py_ssize_t __pyx_v_stride;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- Py_ssize_t *__pyx_t_3;
- Py_ssize_t *__pyx_t_4;
- Py_ssize_t *__pyx_t_5;
- PyObject *__pyx_t_6 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("__get__", 0);
-
- /* "View.MemoryView":568
- * @property
- * def strides(self):
- * if self.view.strides == NULL: # <<<<<<<<<<<<<<
- *
- * raise ValueError("Buffer view does not expose strides")
- */
- __pyx_t_1 = ((__pyx_v_self->view.strides == NULL) != 0);
- if (unlikely(__pyx_t_1)) {
-
- /* "View.MemoryView":570
- * if self.view.strides == NULL:
- *
- * raise ValueError("Buffer view does not expose strides") # <<<<<<<<<<<<<<
- *
- * return tuple([stride for stride in self.view.strides[:self.view.ndim]])
- */
- __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 570, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_Raise(__pyx_t_2, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __PYX_ERR(1, 570, __pyx_L1_error)
-
- /* "View.MemoryView":568
- * @property
- * def strides(self):
- * if self.view.strides == NULL: # <<<<<<<<<<<<<<
- *
- * raise ValueError("Buffer view does not expose strides")
- */
- }
-
- /* "View.MemoryView":572
- * raise ValueError("Buffer view does not expose strides")
- *
- * return tuple([stride for stride in self.view.strides[:self.view.ndim]]) # <<<<<<<<<<<<<<
- *
- * @property
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 572, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_4 = (__pyx_v_self->view.strides + __pyx_v_self->view.ndim);
- for (__pyx_t_5 = __pyx_v_self->view.strides; __pyx_t_5 < __pyx_t_4; __pyx_t_5++) {
- __pyx_t_3 = __pyx_t_5;
- __pyx_v_stride = (__pyx_t_3[0]);
- __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_stride); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 572, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_6))) __PYX_ERR(1, 572, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- }
- __pyx_t_6 = PyList_AsTuple(((PyObject*)__pyx_t_2)); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 572, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_r = __pyx_t_6;
- __pyx_t_6 = 0;
- goto __pyx_L0;
-
- /* "View.MemoryView":567
- *
- * @property
- * def strides(self): # <<<<<<<<<<<<<<
- * if self.view.strides == NULL:
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_AddTraceback("View.MemoryView.memoryview.strides.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":575
- *
- * @property
- * def suboffsets(self): # <<<<<<<<<<<<<<
- * if self.view.suboffsets == NULL:
- * return (-1,) * self.view.ndim
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_10suboffsets_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_10suboffsets_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
- Py_ssize_t __pyx_v_suboffset;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- Py_ssize_t *__pyx_t_4;
- Py_ssize_t *__pyx_t_5;
- Py_ssize_t *__pyx_t_6;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("__get__", 0);
-
- /* "View.MemoryView":576
- * @property
- * def suboffsets(self):
- * if self.view.suboffsets == NULL: # <<<<<<<<<<<<<<
- * return (-1,) * self.view.ndim
- *
- */
- __pyx_t_1 = ((__pyx_v_self->view.suboffsets == NULL) != 0);
- if (__pyx_t_1) {
-
- /* "View.MemoryView":577
- * def suboffsets(self):
- * if self.view.suboffsets == NULL:
- * return (-1,) * self.view.ndim # <<<<<<<<<<<<<<
- *
- * return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]])
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->view.ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 577, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = PyNumber_Multiply(__pyx_tuple__13, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 577, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_r = __pyx_t_3;
- __pyx_t_3 = 0;
- goto __pyx_L0;
-
- /* "View.MemoryView":576
- * @property
- * def suboffsets(self):
- * if self.view.suboffsets == NULL: # <<<<<<<<<<<<<<
- * return (-1,) * self.view.ndim
- *
- */
- }
-
- /* "View.MemoryView":579
- * return (-1,) * self.view.ndim
- *
- * return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]]) # <<<<<<<<<<<<<<
- *
- * @property
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 579, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_5 = (__pyx_v_self->view.suboffsets + __pyx_v_self->view.ndim);
- for (__pyx_t_6 = __pyx_v_self->view.suboffsets; __pyx_t_6 < __pyx_t_5; __pyx_t_6++) {
- __pyx_t_4 = __pyx_t_6;
- __pyx_v_suboffset = (__pyx_t_4[0]);
- __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_suboffset); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 579, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_2))) __PYX_ERR(1, 579, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- }
- __pyx_t_2 = PyList_AsTuple(((PyObject*)__pyx_t_3)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 579, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
- /* "View.MemoryView":575
- *
- * @property
- * def suboffsets(self): # <<<<<<<<<<<<<<
- * if self.view.suboffsets == NULL:
- * return (-1,) * self.view.ndim
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("View.MemoryView.memoryview.suboffsets.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":582
- *
- * @property
- * def ndim(self): # <<<<<<<<<<<<<<
- * return self.view.ndim
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4ndim_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4ndim_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_4ndim___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4ndim___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("__get__", 0);
-
- /* "View.MemoryView":583
- * @property
- * def ndim(self):
- * return self.view.ndim # <<<<<<<<<<<<<<
- *
- * @property
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->view.ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 583, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "View.MemoryView":582
- *
- * @property
- * def ndim(self): # <<<<<<<<<<<<<<
- * return self.view.ndim
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("View.MemoryView.memoryview.ndim.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":586
- *
- * @property
- * def itemsize(self): # <<<<<<<<<<<<<<
- * return self.view.itemsize
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_8itemsize_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_8itemsize_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_8itemsize___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_8itemsize___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("__get__", 0);
-
- /* "View.MemoryView":587
- * @property
- * def itemsize(self):
- * return self.view.itemsize # <<<<<<<<<<<<<<
- *
- * @property
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->view.itemsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 587, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "View.MemoryView":586
- *
- * @property
- * def itemsize(self): # <<<<<<<<<<<<<<
- * return self.view.itemsize
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("View.MemoryView.memoryview.itemsize.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":590
- *
- * @property
- * def nbytes(self): # <<<<<<<<<<<<<<
- * return self.size * self.view.itemsize
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_6nbytes_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_6nbytes_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_6nbytes___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_6nbytes___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("__get__", 0);
-
- /* "View.MemoryView":591
- * @property
- * def nbytes(self):
- * return self.size * self.view.itemsize # <<<<<<<<<<<<<<
- *
- * @property
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 591, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_self->view.itemsize); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 591, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = PyNumber_Multiply(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 591, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_r = __pyx_t_3;
- __pyx_t_3 = 0;
- goto __pyx_L0;
-
- /* "View.MemoryView":590
- *
- * @property
- * def nbytes(self): # <<<<<<<<<<<<<<
- * return self.size * self.view.itemsize
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("View.MemoryView.memoryview.nbytes.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":594
- *
- * @property
- * def size(self): # <<<<<<<<<<<<<<
- * if self._size is None:
- * result = 1
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4size_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4size_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(((struct __pyx_memoryview_obj *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(struct __pyx_memoryview_obj *__pyx_v_self) {
- PyObject *__pyx_v_result = NULL;
- PyObject *__pyx_v_length = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- Py_ssize_t *__pyx_t_3;
- Py_ssize_t *__pyx_t_4;
- Py_ssize_t *__pyx_t_5;
- PyObject *__pyx_t_6 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("__get__", 0);
-
- /* "View.MemoryView":595
- * @property
- * def size(self):
- * if self._size is None: # <<<<<<<<<<<<<<
- * result = 1
- *
- */
- __pyx_t_1 = (__pyx_v_self->_size == Py_None);
- __pyx_t_2 = (__pyx_t_1 != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":596
- * def size(self):
- * if self._size is None:
- * result = 1 # <<<<<<<<<<<<<<
- *
- * for length in self.view.shape[:self.view.ndim]:
- */
- __Pyx_INCREF(__pyx_int_1);
- __pyx_v_result = __pyx_int_1;
-
- /* "View.MemoryView":598
- * result = 1
- *
- * for length in self.view.shape[:self.view.ndim]: # <<<<<<<<<<<<<<
- * result *= length
- *
- */
- __pyx_t_4 = (__pyx_v_self->view.shape + __pyx_v_self->view.ndim);
- for (__pyx_t_5 = __pyx_v_self->view.shape; __pyx_t_5 < __pyx_t_4; __pyx_t_5++) {
- __pyx_t_3 = __pyx_t_5;
- __pyx_t_6 = PyInt_FromSsize_t((__pyx_t_3[0])); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 598, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_XDECREF_SET(__pyx_v_length, __pyx_t_6);
- __pyx_t_6 = 0;
-
- /* "View.MemoryView":599
- *
- * for length in self.view.shape[:self.view.ndim]:
- * result *= length # <<<<<<<<<<<<<<
- *
- * self._size = result
- */
- __pyx_t_6 = PyNumber_InPlaceMultiply(__pyx_v_result, __pyx_v_length); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 599, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_6);
- __pyx_t_6 = 0;
- }
-
- /* "View.MemoryView":601
- * result *= length
- *
- * self._size = result # <<<<<<<<<<<<<<
- *
- * return self._size
- */
- __Pyx_INCREF(__pyx_v_result);
- __Pyx_GIVEREF(__pyx_v_result);
- __Pyx_GOTREF(__pyx_v_self->_size);
- __Pyx_DECREF(__pyx_v_self->_size);
- __pyx_v_self->_size = __pyx_v_result;
-
- /* "View.MemoryView":595
- * @property
- * def size(self):
- * if self._size is None: # <<<<<<<<<<<<<<
- * result = 1
- *
- */
- }
-
- /* "View.MemoryView":603
- * self._size = result
- *
- * return self._size # <<<<<<<<<<<<<<
- *
- * def __len__(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_self->_size);
- __pyx_r = __pyx_v_self->_size;
- goto __pyx_L0;
-
- /* "View.MemoryView":594
- *
- * @property
- * def size(self): # <<<<<<<<<<<<<<
- * if self._size is None:
- * result = 1
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_AddTraceback("View.MemoryView.memoryview.size.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_result);
- __Pyx_XDECREF(__pyx_v_length);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":605
- * return self._size
- *
- * def __len__(self): # <<<<<<<<<<<<<<
- * if self.view.ndim >= 1:
- * return self.view.shape[0]
- */
-
-/* Python wrapper */
-static Py_ssize_t __pyx_memoryview___len__(PyObject *__pyx_v_self); /*proto*/
-static Py_ssize_t __pyx_memoryview___len__(PyObject *__pyx_v_self) {
- Py_ssize_t __pyx_r;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
- __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_10__len__(((struct __pyx_memoryview_obj *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static Py_ssize_t __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_10__len__(struct __pyx_memoryview_obj *__pyx_v_self) {
- Py_ssize_t __pyx_r;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- __Pyx_RefNannySetupContext("__len__", 0);
-
- /* "View.MemoryView":606
- *
- * def __len__(self):
- * if self.view.ndim >= 1: # <<<<<<<<<<<<<<
- * return self.view.shape[0]
- *
- */
- __pyx_t_1 = ((__pyx_v_self->view.ndim >= 1) != 0);
- if (__pyx_t_1) {
-
- /* "View.MemoryView":607
- * def __len__(self):
- * if self.view.ndim >= 1:
- * return self.view.shape[0] # <<<<<<<<<<<<<<
- *
- * return 0
- */
- __pyx_r = (__pyx_v_self->view.shape[0]);
- goto __pyx_L0;
-
- /* "View.MemoryView":606
- *
- * def __len__(self):
- * if self.view.ndim >= 1: # <<<<<<<<<<<<<<
- * return self.view.shape[0]
- *
- */
- }
-
- /* "View.MemoryView":609
- * return self.view.shape[0]
- *
- * return 0 # <<<<<<<<<<<<<<
- *
- * def __repr__(self):
- */
- __pyx_r = 0;
- goto __pyx_L0;
-
- /* "View.MemoryView":605
- * return self._size
- *
- * def __len__(self): # <<<<<<<<<<<<<<
- * if self.view.ndim >= 1:
- * return self.view.shape[0]
- */
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":611
- * return 0
- *
- * def __repr__(self): # <<<<<<<<<<<<<<
- * return "" % (self.base.__class__.__name__,
- * id(self))
- */
-
-/* Python wrapper */
-static PyObject *__pyx_memoryview___repr__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_memoryview___repr__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
- __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_12__repr__(((struct __pyx_memoryview_obj *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_12__repr__(struct __pyx_memoryview_obj *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("__repr__", 0);
-
- /* "View.MemoryView":612
- *
- * def __repr__(self):
- * return "" % (self.base.__class__.__name__, # <<<<<<<<<<<<<<
- * id(self))
- *
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_base); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 612, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_class); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 612, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_name_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 612, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
- /* "View.MemoryView":613
- * def __repr__(self):
- * return "" % (self.base.__class__.__name__,
- * id(self)) # <<<<<<<<<<<<<<
- *
- * def __str__(self):
- */
- __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_id, ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 613, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
-
- /* "View.MemoryView":612
- *
- * def __repr__(self):
- * return "" % (self.base.__class__.__name__, # <<<<<<<<<<<<<<
- * id(self))
- *
- */
- __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 612, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
- __pyx_t_1 = 0;
- __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_MemoryView_of_r_at_0x_x, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 612, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
- /* "View.MemoryView":611
- * return 0
- *
- * def __repr__(self): # <<<<<<<<<<<<<<
- * return "" % (self.base.__class__.__name__,
- * id(self))
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("View.MemoryView.memoryview.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":615
- * id(self))
- *
- * def __str__(self): # <<<<<<<<<<<<<<
- * return "" % (self.base.__class__.__name__,)
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_memoryview___str__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_memoryview___str__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__str__ (wrapper)", 0);
- __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_14__str__(((struct __pyx_memoryview_obj *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_14__str__(struct __pyx_memoryview_obj *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("__str__", 0);
-
- /* "View.MemoryView":616
- *
- * def __str__(self):
- * return "" % (self.base.__class__.__name__,) # <<<<<<<<<<<<<<
- *
- *
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_base); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 616, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_class); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 616, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_name_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 616, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 616, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
- __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_MemoryView_of_r_object, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 616, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "View.MemoryView":615
- * id(self))
- *
- * def __str__(self): # <<<<<<<<<<<<<<
- * return "" % (self.base.__class__.__name__,)
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("View.MemoryView.memoryview.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":619
- *
- *
- * def is_c_contig(self): # <<<<<<<<<<<<<<
- * cdef __Pyx_memviewslice *mslice
- * cdef __Pyx_memviewslice tmp
- */
-
-/* Python wrapper */
-static PyObject *__pyx_memoryview_is_c_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_memoryview_is_c_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("is_c_contig (wrapper)", 0);
- __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_16is_c_contig(((struct __pyx_memoryview_obj *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_16is_c_contig(struct __pyx_memoryview_obj *__pyx_v_self) {
- __Pyx_memviewslice *__pyx_v_mslice;
- __Pyx_memviewslice __pyx_v_tmp;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_memviewslice *__pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("is_c_contig", 0);
-
- /* "View.MemoryView":622
- * cdef __Pyx_memviewslice *mslice
- * cdef __Pyx_memviewslice tmp
- * mslice = get_slice_from_memview(self, &tmp) # <<<<<<<<<<<<<<
- * return slice_is_contig(mslice[0], 'C', self.view.ndim)
- *
- */
- __pyx_t_1 = __pyx_memoryview_get_slice_from_memoryview(__pyx_v_self, (&__pyx_v_tmp)); if (unlikely(__pyx_t_1 == ((__Pyx_memviewslice *)NULL))) __PYX_ERR(1, 622, __pyx_L1_error)
- __pyx_v_mslice = __pyx_t_1;
-
- /* "View.MemoryView":623
- * cdef __Pyx_memviewslice tmp
- * mslice = get_slice_from_memview(self, &tmp)
- * return slice_is_contig(mslice[0], 'C', self.view.ndim) # <<<<<<<<<<<<<<
- *
- * def is_f_contig(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_memviewslice_is_contig((__pyx_v_mslice[0]), 'C', __pyx_v_self->view.ndim)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 623, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
- /* "View.MemoryView":619
- *
- *
- * def is_c_contig(self): # <<<<<<<<<<<<<<
- * cdef __Pyx_memviewslice *mslice
- * cdef __Pyx_memviewslice tmp
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("View.MemoryView.memoryview.is_c_contig", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":625
- * return slice_is_contig(mslice[0], 'C', self.view.ndim)
- *
- * def is_f_contig(self): # <<<<<<<<<<<<<<
- * cdef __Pyx_memviewslice *mslice
- * cdef __Pyx_memviewslice tmp
- */
-
-/* Python wrapper */
-static PyObject *__pyx_memoryview_is_f_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_memoryview_is_f_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("is_f_contig (wrapper)", 0);
- __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_18is_f_contig(((struct __pyx_memoryview_obj *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_18is_f_contig(struct __pyx_memoryview_obj *__pyx_v_self) {
- __Pyx_memviewslice *__pyx_v_mslice;
- __Pyx_memviewslice __pyx_v_tmp;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_memviewslice *__pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("is_f_contig", 0);
-
- /* "View.MemoryView":628
- * cdef __Pyx_memviewslice *mslice
- * cdef __Pyx_memviewslice tmp
- * mslice = get_slice_from_memview(self, &tmp) # <<<<<<<<<<<<<<
- * return slice_is_contig(mslice[0], 'F', self.view.ndim)
- *
- */
- __pyx_t_1 = __pyx_memoryview_get_slice_from_memoryview(__pyx_v_self, (&__pyx_v_tmp)); if (unlikely(__pyx_t_1 == ((__Pyx_memviewslice *)NULL))) __PYX_ERR(1, 628, __pyx_L1_error)
- __pyx_v_mslice = __pyx_t_1;
-
- /* "View.MemoryView":629
- * cdef __Pyx_memviewslice tmp
- * mslice = get_slice_from_memview(self, &tmp)
- * return slice_is_contig(mslice[0], 'F', self.view.ndim) # <<<<<<<<<<<<<<
- *
- * def copy(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_memviewslice_is_contig((__pyx_v_mslice[0]), 'F', __pyx_v_self->view.ndim)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 629, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
- /* "View.MemoryView":625
- * return slice_is_contig(mslice[0], 'C', self.view.ndim)
- *
- * def is_f_contig(self): # <<<<<<<<<<<<<<
- * cdef __Pyx_memviewslice *mslice
- * cdef __Pyx_memviewslice tmp
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("View.MemoryView.memoryview.is_f_contig", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":631
- * return slice_is_contig(mslice[0], 'F', self.view.ndim)
- *
- * def copy(self): # <<<<<<<<<<<<<<
- * cdef __Pyx_memviewslice mslice
- * cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS
- */
-
-/* Python wrapper */
-static PyObject *__pyx_memoryview_copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_memoryview_copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("copy (wrapper)", 0);
- __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_20copy(((struct __pyx_memoryview_obj *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_20copy(struct __pyx_memoryview_obj *__pyx_v_self) {
- __Pyx_memviewslice __pyx_v_mslice;
- int __pyx_v_flags;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_memviewslice __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("copy", 0);
-
- /* "View.MemoryView":633
- * def copy(self):
- * cdef __Pyx_memviewslice mslice
- * cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS # <<<<<<<<<<<<<<
- *
- * slice_copy(self, &mslice)
- */
- __pyx_v_flags = (__pyx_v_self->flags & (~PyBUF_F_CONTIGUOUS));
-
- /* "View.MemoryView":635
- * cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS
- *
- * slice_copy(self, &mslice) # <<<<<<<<<<<<<<
- * mslice = slice_copy_contig(&mslice, "c", self.view.ndim,
- * self.view.itemsize,
- */
- __pyx_memoryview_slice_copy(__pyx_v_self, (&__pyx_v_mslice));
-
- /* "View.MemoryView":636
- *
- * slice_copy(self, &mslice)
- * mslice = slice_copy_contig(&mslice, "c", self.view.ndim, # <<<<<<<<<<<<<<
- * self.view.itemsize,
- * flags|PyBUF_C_CONTIGUOUS,
- */
- __pyx_t_1 = __pyx_memoryview_copy_new_contig((&__pyx_v_mslice), ((char *)"c"), __pyx_v_self->view.ndim, __pyx_v_self->view.itemsize, (__pyx_v_flags | PyBUF_C_CONTIGUOUS), __pyx_v_self->dtype_is_object); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 636, __pyx_L1_error)
- __pyx_v_mslice = __pyx_t_1;
-
- /* "View.MemoryView":641
- * self.dtype_is_object)
- *
- * return memoryview_copy_from_slice(self, &mslice) # <<<<<<<<<<<<<<
- *
- * def copy_fortran(self):
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = __pyx_memoryview_copy_object_from_slice(__pyx_v_self, (&__pyx_v_mslice)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 641, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
- /* "View.MemoryView":631
- * return slice_is_contig(mslice[0], 'F', self.view.ndim)
- *
- * def copy(self): # <<<<<<<<<<<<<<
- * cdef __Pyx_memviewslice mslice
- * cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("View.MemoryView.memoryview.copy", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":643
- * return memoryview_copy_from_slice(self, &mslice)
- *
- * def copy_fortran(self): # <<<<<<<<<<<<<<
- * cdef __Pyx_memviewslice src, dst
- * cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS
- */
-
-/* Python wrapper */
-static PyObject *__pyx_memoryview_copy_fortran(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_memoryview_copy_fortran(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("copy_fortran (wrapper)", 0);
- __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22copy_fortran(((struct __pyx_memoryview_obj *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22copy_fortran(struct __pyx_memoryview_obj *__pyx_v_self) {
- __Pyx_memviewslice __pyx_v_src;
- __Pyx_memviewslice __pyx_v_dst;
- int __pyx_v_flags;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_memviewslice __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("copy_fortran", 0);
-
- /* "View.MemoryView":645
- * def copy_fortran(self):
- * cdef __Pyx_memviewslice src, dst
- * cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS # <<<<<<<<<<<<<<
- *
- * slice_copy(self, &src)
- */
- __pyx_v_flags = (__pyx_v_self->flags & (~PyBUF_C_CONTIGUOUS));
-
- /* "View.MemoryView":647
- * cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS
- *
- * slice_copy(self, &src) # <<<<<<<<<<<<<<
- * dst = slice_copy_contig(&src, "fortran", self.view.ndim,
- * self.view.itemsize,
- */
- __pyx_memoryview_slice_copy(__pyx_v_self, (&__pyx_v_src));
-
- /* "View.MemoryView":648
- *
- * slice_copy(self, &src)
- * dst = slice_copy_contig(&src, "fortran", self.view.ndim, # <<<<<<<<<<<<<<
- * self.view.itemsize,
- * flags|PyBUF_F_CONTIGUOUS,
- */
- __pyx_t_1 = __pyx_memoryview_copy_new_contig((&__pyx_v_src), ((char *)"fortran"), __pyx_v_self->view.ndim, __pyx_v_self->view.itemsize, (__pyx_v_flags | PyBUF_F_CONTIGUOUS), __pyx_v_self->dtype_is_object); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 648, __pyx_L1_error)
- __pyx_v_dst = __pyx_t_1;
-
- /* "View.MemoryView":653
- * self.dtype_is_object)
- *
- * return memoryview_copy_from_slice(self, &dst) # <<<<<<<<<<<<<<
- *
- *
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = __pyx_memoryview_copy_object_from_slice(__pyx_v_self, (&__pyx_v_dst)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 653, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
- /* "View.MemoryView":643
- * return memoryview_copy_from_slice(self, &mslice)
- *
- * def copy_fortran(self): # <<<<<<<<<<<<<<
- * cdef __Pyx_memviewslice src, dst
- * cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("View.MemoryView.memoryview.copy_fortran", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "(tree fragment)":1
- * def __reduce_cython__(self): # <<<<<<<<<<<<<<
- * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
- * def __setstate_cython__(self, __pyx_state):
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw___pyx_memoryview_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_pw___pyx_memoryview_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
- __pyx_r = __pyx_pf___pyx_memoryview___reduce_cython__(((struct __pyx_memoryview_obj *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf___pyx_memoryview___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryview_obj *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("__reduce_cython__", 0);
-
- /* "(tree fragment)":2
- * def __reduce_cython__(self):
- * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
- * def __setstate_cython__(self, __pyx_state):
- * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
- */
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_Raise(__pyx_t_1, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __PYX_ERR(1, 2, __pyx_L1_error)
-
- /* "(tree fragment)":1
- * def __reduce_cython__(self): # <<<<<<<<<<<<<<
- * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
- * def __setstate_cython__(self, __pyx_state):
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("View.MemoryView.memoryview.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "(tree fragment)":3
- * def __reduce_cython__(self):
- * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
- * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
- * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw___pyx_memoryview_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
-static PyObject *__pyx_pw___pyx_memoryview_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
- __pyx_r = __pyx_pf___pyx_memoryview_2__setstate_cython__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf___pyx_memoryview_2__setstate_cython__(CYTHON_UNUSED struct __pyx_memoryview_obj *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("__setstate_cython__", 0);
-
- /* "(tree fragment)":4
- * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
- * def __setstate_cython__(self, __pyx_state):
- * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
- */
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_Raise(__pyx_t_1, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __PYX_ERR(1, 4, __pyx_L1_error)
-
- /* "(tree fragment)":3
- * def __reduce_cython__(self):
- * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
- * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
- * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("View.MemoryView.memoryview.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":657
- *
- * @cname('__pyx_memoryview_new')
- * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo): # <<<<<<<<<<<<<<
- * cdef memoryview result = memoryview(o, flags, dtype_is_object)
- * result.typeinfo = typeinfo
- */
-
-static PyObject *__pyx_memoryview_new(PyObject *__pyx_v_o, int __pyx_v_flags, int __pyx_v_dtype_is_object, __Pyx_TypeInfo *__pyx_v_typeinfo) {
- struct __pyx_memoryview_obj *__pyx_v_result = 0;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("memoryview_cwrapper", 0);
-
- /* "View.MemoryView":658
- * @cname('__pyx_memoryview_new')
- * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo):
- * cdef memoryview result = memoryview(o, flags, dtype_is_object) # <<<<<<<<<<<<<<
- * result.typeinfo = typeinfo
- * return result
- */
- __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 658, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_dtype_is_object); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 658, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 658, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_INCREF(__pyx_v_o);
- __Pyx_GIVEREF(__pyx_v_o);
- PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_o);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2);
- __pyx_t_1 = 0;
- __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_memoryview_type), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 658, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_v_result = ((struct __pyx_memoryview_obj *)__pyx_t_2);
- __pyx_t_2 = 0;
-
- /* "View.MemoryView":659
- * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo):
- * cdef memoryview result = memoryview(o, flags, dtype_is_object)
- * result.typeinfo = typeinfo # <<<<<<<<<<<<<<
- * return result
- *
- */
- __pyx_v_result->typeinfo = __pyx_v_typeinfo;
-
- /* "View.MemoryView":660
- * cdef memoryview result = memoryview(o, flags, dtype_is_object)
- * result.typeinfo = typeinfo
- * return result # <<<<<<<<<<<<<<
- *
- * @cname('__pyx_memoryview_check')
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(((PyObject *)__pyx_v_result));
- __pyx_r = ((PyObject *)__pyx_v_result);
- goto __pyx_L0;
-
- /* "View.MemoryView":657
- *
- * @cname('__pyx_memoryview_new')
- * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo): # <<<<<<<<<<<<<<
- * cdef memoryview result = memoryview(o, flags, dtype_is_object)
- * result.typeinfo = typeinfo
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("View.MemoryView.memoryview_cwrapper", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF((PyObject *)__pyx_v_result);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":663
- *
- * @cname('__pyx_memoryview_check')
- * cdef inline bint memoryview_check(object o): # <<<<<<<<<<<<<<
- * return isinstance(o, memoryview)
- *
- */
-
-static CYTHON_INLINE int __pyx_memoryview_check(PyObject *__pyx_v_o) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- __Pyx_RefNannySetupContext("memoryview_check", 0);
-
- /* "View.MemoryView":664
- * @cname('__pyx_memoryview_check')
- * cdef inline bint memoryview_check(object o):
- * return isinstance(o, memoryview) # <<<<<<<<<<<<<<
- *
- * cdef tuple _unellipsify(object index, int ndim):
- */
- __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_o, __pyx_memoryview_type);
- __pyx_r = __pyx_t_1;
- goto __pyx_L0;
-
- /* "View.MemoryView":663
- *
- * @cname('__pyx_memoryview_check')
- * cdef inline bint memoryview_check(object o): # <<<<<<<<<<<<<<
- * return isinstance(o, memoryview)
- *
- */
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":666
- * return isinstance(o, memoryview)
- *
- * cdef tuple _unellipsify(object index, int ndim): # <<<<<<<<<<<<<<
- * """
- * Replace all ellipses with full slices and fill incomplete indices with
- */
-
-static PyObject *_unellipsify(PyObject *__pyx_v_index, int __pyx_v_ndim) {
- PyObject *__pyx_v_tup = NULL;
- PyObject *__pyx_v_result = NULL;
- int __pyx_v_have_slices;
- int __pyx_v_seen_ellipsis;
- CYTHON_UNUSED PyObject *__pyx_v_idx = NULL;
- PyObject *__pyx_v_item = NULL;
- Py_ssize_t __pyx_v_nslices;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- Py_ssize_t __pyx_t_5;
- PyObject *(*__pyx_t_6)(PyObject *);
- PyObject *__pyx_t_7 = NULL;
- Py_ssize_t __pyx_t_8;
- int __pyx_t_9;
- int __pyx_t_10;
- PyObject *__pyx_t_11 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("_unellipsify", 0);
-
- /* "View.MemoryView":671
- * full slices.
- * """
- * if not isinstance(index, tuple): # <<<<<<<<<<<<<<
- * tup = (index,)
- * else:
- */
- __pyx_t_1 = PyTuple_Check(__pyx_v_index);
- __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":672
- * """
- * if not isinstance(index, tuple):
- * tup = (index,) # <<<<<<<<<<<<<<
- * else:
- * tup = index
- */
- __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 672, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_INCREF(__pyx_v_index);
- __Pyx_GIVEREF(__pyx_v_index);
- PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_index);
- __pyx_v_tup = __pyx_t_3;
- __pyx_t_3 = 0;
-
- /* "View.MemoryView":671
- * full slices.
- * """
- * if not isinstance(index, tuple): # <<<<<<<<<<<<<<
- * tup = (index,)
- * else:
- */
- goto __pyx_L3;
- }
-
- /* "View.MemoryView":674
- * tup = (index,)
- * else:
- * tup = index # <<<<<<<<<<<<<<
- *
- * result = []
- */
- /*else*/ {
- __Pyx_INCREF(__pyx_v_index);
- __pyx_v_tup = __pyx_v_index;
- }
- __pyx_L3:;
-
- /* "View.MemoryView":676
- * tup = index
- *
- * result = [] # <<<<<<<<<<<<<<
- * have_slices = False
- * seen_ellipsis = False
- */
- __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 676, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_v_result = ((PyObject*)__pyx_t_3);
- __pyx_t_3 = 0;
-
- /* "View.MemoryView":677
- *
- * result = []
- * have_slices = False # <<<<<<<<<<<<<<
- * seen_ellipsis = False
- * for idx, item in enumerate(tup):
- */
- __pyx_v_have_slices = 0;
-
- /* "View.MemoryView":678
- * result = []
- * have_slices = False
- * seen_ellipsis = False # <<<<<<<<<<<<<<
- * for idx, item in enumerate(tup):
- * if item is Ellipsis:
- */
- __pyx_v_seen_ellipsis = 0;
-
- /* "View.MemoryView":679
- * have_slices = False
- * seen_ellipsis = False
- * for idx, item in enumerate(tup): # <<<<<<<<<<<<<<
- * if item is Ellipsis:
- * if not seen_ellipsis:
- */
- __Pyx_INCREF(__pyx_int_0);
- __pyx_t_3 = __pyx_int_0;
- if (likely(PyList_CheckExact(__pyx_v_tup)) || PyTuple_CheckExact(__pyx_v_tup)) {
- __pyx_t_4 = __pyx_v_tup; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
- __pyx_t_6 = NULL;
- } else {
- __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_tup); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 679, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 679, __pyx_L1_error)
- }
- for (;;) {
- if (likely(!__pyx_t_6)) {
- if (likely(PyList_CheckExact(__pyx_t_4))) {
- if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_7 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(1, 679, __pyx_L1_error)
- #else
- __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 679, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- #endif
- } else {
- if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(1, 679, __pyx_L1_error)
- #else
- __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 679, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- #endif
- }
- } else {
- __pyx_t_7 = __pyx_t_6(__pyx_t_4);
- if (unlikely(!__pyx_t_7)) {
- PyObject* exc_type = PyErr_Occurred();
- if (exc_type) {
- if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
- else __PYX_ERR(1, 679, __pyx_L1_error)
- }
- break;
- }
- __Pyx_GOTREF(__pyx_t_7);
- }
- __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_7);
- __pyx_t_7 = 0;
- __Pyx_INCREF(__pyx_t_3);
- __Pyx_XDECREF_SET(__pyx_v_idx, __pyx_t_3);
- __pyx_t_7 = __Pyx_PyInt_AddObjC(__pyx_t_3, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 679, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_DECREF(__pyx_t_3);
- __pyx_t_3 = __pyx_t_7;
- __pyx_t_7 = 0;
-
- /* "View.MemoryView":680
- * seen_ellipsis = False
- * for idx, item in enumerate(tup):
- * if item is Ellipsis: # <<<<<<<<<<<<<<
- * if not seen_ellipsis:
- * result.extend([slice(None)] * (ndim - len(tup) + 1))
- */
- __pyx_t_2 = (__pyx_v_item == __pyx_builtin_Ellipsis);
- __pyx_t_1 = (__pyx_t_2 != 0);
- if (__pyx_t_1) {
-
- /* "View.MemoryView":681
- * for idx, item in enumerate(tup):
- * if item is Ellipsis:
- * if not seen_ellipsis: # <<<<<<<<<<<<<<
- * result.extend([slice(None)] * (ndim - len(tup) + 1))
- * seen_ellipsis = True
- */
- __pyx_t_1 = ((!(__pyx_v_seen_ellipsis != 0)) != 0);
- if (__pyx_t_1) {
-
- /* "View.MemoryView":682
- * if item is Ellipsis:
- * if not seen_ellipsis:
- * result.extend([slice(None)] * (ndim - len(tup) + 1)) # <<<<<<<<<<<<<<
- * seen_ellipsis = True
- * else:
- */
- __pyx_t_8 = PyObject_Length(__pyx_v_tup); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(1, 682, __pyx_L1_error)
- __pyx_t_7 = PyList_New(1 * ((((__pyx_v_ndim - __pyx_t_8) + 1)<0) ? 0:((__pyx_v_ndim - __pyx_t_8) + 1))); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 682, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- { Py_ssize_t __pyx_temp;
- for (__pyx_temp=0; __pyx_temp < ((__pyx_v_ndim - __pyx_t_8) + 1); __pyx_temp++) {
- __Pyx_INCREF(__pyx_slice__16);
- __Pyx_GIVEREF(__pyx_slice__16);
- PyList_SET_ITEM(__pyx_t_7, __pyx_temp, __pyx_slice__16);
- }
- }
- __pyx_t_9 = __Pyx_PyList_Extend(__pyx_v_result, __pyx_t_7); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(1, 682, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-
- /* "View.MemoryView":683
- * if not seen_ellipsis:
- * result.extend([slice(None)] * (ndim - len(tup) + 1))
- * seen_ellipsis = True # <<<<<<<<<<<<<<
- * else:
- * result.append(slice(None))
- */
- __pyx_v_seen_ellipsis = 1;
-
- /* "View.MemoryView":681
- * for idx, item in enumerate(tup):
- * if item is Ellipsis:
- * if not seen_ellipsis: # <<<<<<<<<<<<<<
- * result.extend([slice(None)] * (ndim - len(tup) + 1))
- * seen_ellipsis = True
- */
- goto __pyx_L7;
- }
-
- /* "View.MemoryView":685
- * seen_ellipsis = True
- * else:
- * result.append(slice(None)) # <<<<<<<<<<<<<<
- * have_slices = True
- * else:
- */
- /*else*/ {
- __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_result, __pyx_slice__16); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(1, 685, __pyx_L1_error)
- }
- __pyx_L7:;
-
- /* "View.MemoryView":686
- * else:
- * result.append(slice(None))
- * have_slices = True # <<<<<<<<<<<<<<
- * else:
- * if not isinstance(item, slice) and not PyIndex_Check(item):
- */
- __pyx_v_have_slices = 1;
-
- /* "View.MemoryView":680
- * seen_ellipsis = False
- * for idx, item in enumerate(tup):
- * if item is Ellipsis: # <<<<<<<<<<<<<<
- * if not seen_ellipsis:
- * result.extend([slice(None)] * (ndim - len(tup) + 1))
- */
- goto __pyx_L6;
- }
-
- /* "View.MemoryView":688
- * have_slices = True
- * else:
- * if not isinstance(item, slice) and not PyIndex_Check(item): # <<<<<<<<<<<<<<
- * raise TypeError("Cannot index with type '%s'" % type(item))
- *
- */
- /*else*/ {
- __pyx_t_2 = PySlice_Check(__pyx_v_item);
- __pyx_t_10 = ((!(__pyx_t_2 != 0)) != 0);
- if (__pyx_t_10) {
- } else {
- __pyx_t_1 = __pyx_t_10;
- goto __pyx_L9_bool_binop_done;
- }
- __pyx_t_10 = ((!(PyIndex_Check(__pyx_v_item) != 0)) != 0);
- __pyx_t_1 = __pyx_t_10;
- __pyx_L9_bool_binop_done:;
- if (unlikely(__pyx_t_1)) {
-
- /* "View.MemoryView":689
- * else:
- * if not isinstance(item, slice) and not PyIndex_Check(item):
- * raise TypeError("Cannot index with type '%s'" % type(item)) # <<<<<<<<<<<<<<
- *
- * have_slices = have_slices or isinstance(item, slice)
- */
- __pyx_t_7 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Cannot_index_with_type_s, ((PyObject *)Py_TYPE(__pyx_v_item))); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 689, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_7); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 689, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_11);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_Raise(__pyx_t_11, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
- __PYX_ERR(1, 689, __pyx_L1_error)
-
- /* "View.MemoryView":688
- * have_slices = True
- * else:
- * if not isinstance(item, slice) and not PyIndex_Check(item): # <<<<<<<<<<<<<<
- * raise TypeError("Cannot index with type '%s'" % type(item))
- *
- */
- }
-
- /* "View.MemoryView":691
- * raise TypeError("Cannot index with type '%s'" % type(item))
- *
- * have_slices = have_slices or isinstance(item, slice) # <<<<<<<<<<<<<<
- * result.append(item)
- *
- */
- __pyx_t_10 = (__pyx_v_have_slices != 0);
- if (!__pyx_t_10) {
- } else {
- __pyx_t_1 = __pyx_t_10;
- goto __pyx_L11_bool_binop_done;
- }
- __pyx_t_10 = PySlice_Check(__pyx_v_item);
- __pyx_t_2 = (__pyx_t_10 != 0);
- __pyx_t_1 = __pyx_t_2;
- __pyx_L11_bool_binop_done:;
- __pyx_v_have_slices = __pyx_t_1;
-
- /* "View.MemoryView":692
- *
- * have_slices = have_slices or isinstance(item, slice)
- * result.append(item) # <<<<<<<<<<<<<<
- *
- * nslices = ndim - len(result)
- */
- __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_result, __pyx_v_item); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(1, 692, __pyx_L1_error)
- }
- __pyx_L6:;
-
- /* "View.MemoryView":679
- * have_slices = False
- * seen_ellipsis = False
- * for idx, item in enumerate(tup): # <<<<<<<<<<<<<<
- * if item is Ellipsis:
- * if not seen_ellipsis:
- */
- }
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "View.MemoryView":694
- * result.append(item)
- *
- * nslices = ndim - len(result) # <<<<<<<<<<<<<<
- * if nslices:
- * result.extend([slice(None)] * nslices)
- */
- __pyx_t_5 = PyList_GET_SIZE(__pyx_v_result); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(1, 694, __pyx_L1_error)
- __pyx_v_nslices = (__pyx_v_ndim - __pyx_t_5);
-
- /* "View.MemoryView":695
- *
- * nslices = ndim - len(result)
- * if nslices: # <<<<<<<<<<<<<<
- * result.extend([slice(None)] * nslices)
- *
- */
- __pyx_t_1 = (__pyx_v_nslices != 0);
- if (__pyx_t_1) {
-
- /* "View.MemoryView":696
- * nslices = ndim - len(result)
- * if nslices:
- * result.extend([slice(None)] * nslices) # <<<<<<<<<<<<<<
- *
- * return have_slices or nslices, tuple(result)
- */
- __pyx_t_3 = PyList_New(1 * ((__pyx_v_nslices<0) ? 0:__pyx_v_nslices)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 696, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- { Py_ssize_t __pyx_temp;
- for (__pyx_temp=0; __pyx_temp < __pyx_v_nslices; __pyx_temp++) {
- __Pyx_INCREF(__pyx_slice__16);
- __Pyx_GIVEREF(__pyx_slice__16);
- PyList_SET_ITEM(__pyx_t_3, __pyx_temp, __pyx_slice__16);
- }
- }
- __pyx_t_9 = __Pyx_PyList_Extend(__pyx_v_result, __pyx_t_3); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(1, 696, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "View.MemoryView":695
- *
- * nslices = ndim - len(result)
- * if nslices: # <<<<<<<<<<<<<<
- * result.extend([slice(None)] * nslices)
- *
- */
- }
-
- /* "View.MemoryView":698
- * result.extend([slice(None)] * nslices)
- *
- * return have_slices or nslices, tuple(result) # <<<<<<<<<<<<<<
- *
- * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):
- */
- __Pyx_XDECREF(__pyx_r);
- if (!__pyx_v_have_slices) {
- } else {
- __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_have_slices); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 698, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_3 = __pyx_t_4;
- __pyx_t_4 = 0;
- goto __pyx_L14_bool_binop_done;
- }
- __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_nslices); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 698, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_3 = __pyx_t_4;
- __pyx_t_4 = 0;
- __pyx_L14_bool_binop_done:;
- __pyx_t_4 = PyList_AsTuple(__pyx_v_result); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 698, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 698, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_11);
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_3);
- __Pyx_GIVEREF(__pyx_t_4);
- PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_4);
- __pyx_t_3 = 0;
- __pyx_t_4 = 0;
- __pyx_r = ((PyObject*)__pyx_t_11);
- __pyx_t_11 = 0;
- goto __pyx_L0;
-
- /* "View.MemoryView":666
- * return isinstance(o, memoryview)
- *
- * cdef tuple _unellipsify(object index, int ndim): # <<<<<<<<<<<<<<
- * """
- * Replace all ellipses with full slices and fill incomplete indices with
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_XDECREF(__pyx_t_11);
- __Pyx_AddTraceback("View.MemoryView._unellipsify", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v_tup);
- __Pyx_XDECREF(__pyx_v_result);
- __Pyx_XDECREF(__pyx_v_idx);
- __Pyx_XDECREF(__pyx_v_item);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":700
- * return have_slices or nslices, tuple(result)
- *
- * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim): # <<<<<<<<<<<<<<
- * for suboffset in suboffsets[:ndim]:
- * if suboffset >= 0:
- */
-
-static PyObject *assert_direct_dimensions(Py_ssize_t *__pyx_v_suboffsets, int __pyx_v_ndim) {
- Py_ssize_t __pyx_v_suboffset;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- Py_ssize_t *__pyx_t_1;
- Py_ssize_t *__pyx_t_2;
- Py_ssize_t *__pyx_t_3;
- int __pyx_t_4;
- PyObject *__pyx_t_5 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("assert_direct_dimensions", 0);
-
- /* "View.MemoryView":701
- *
- * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):
- * for suboffset in suboffsets[:ndim]: # <<<<<<<<<<<<<<
- * if suboffset >= 0:
- * raise ValueError("Indirect dimensions not supported")
- */
- __pyx_t_2 = (__pyx_v_suboffsets + __pyx_v_ndim);
- for (__pyx_t_3 = __pyx_v_suboffsets; __pyx_t_3 < __pyx_t_2; __pyx_t_3++) {
- __pyx_t_1 = __pyx_t_3;
- __pyx_v_suboffset = (__pyx_t_1[0]);
-
- /* "View.MemoryView":702
- * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):
- * for suboffset in suboffsets[:ndim]:
- * if suboffset >= 0: # <<<<<<<<<<<<<<
- * raise ValueError("Indirect dimensions not supported")
- *
- */
- __pyx_t_4 = ((__pyx_v_suboffset >= 0) != 0);
- if (unlikely(__pyx_t_4)) {
-
- /* "View.MemoryView":703
- * for suboffset in suboffsets[:ndim]:
- * if suboffset >= 0:
- * raise ValueError("Indirect dimensions not supported") # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__17, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 703, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __Pyx_Raise(__pyx_t_5, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- __PYX_ERR(1, 703, __pyx_L1_error)
-
- /* "View.MemoryView":702
- * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim):
- * for suboffset in suboffsets[:ndim]:
- * if suboffset >= 0: # <<<<<<<<<<<<<<
- * raise ValueError("Indirect dimensions not supported")
- *
- */
- }
- }
-
- /* "View.MemoryView":700
- * return have_slices or nslices, tuple(result)
- *
- * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim): # <<<<<<<<<<<<<<
- * for suboffset in suboffsets[:ndim]:
- * if suboffset >= 0:
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("View.MemoryView.assert_direct_dimensions", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":710
- *
- * @cname('__pyx_memview_slice')
- * cdef memoryview memview_slice(memoryview memview, object indices): # <<<<<<<<<<<<<<
- * cdef int new_ndim = 0, suboffset_dim = -1, dim
- * cdef bint negative_step
- */
-
-static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_obj *__pyx_v_memview, PyObject *__pyx_v_indices) {
- int __pyx_v_new_ndim;
- int __pyx_v_suboffset_dim;
- int __pyx_v_dim;
- __Pyx_memviewslice __pyx_v_src;
- __Pyx_memviewslice __pyx_v_dst;
- __Pyx_memviewslice *__pyx_v_p_src;
- struct __pyx_memoryviewslice_obj *__pyx_v_memviewsliceobj = 0;
- __Pyx_memviewslice *__pyx_v_p_dst;
- int *__pyx_v_p_suboffset_dim;
- Py_ssize_t __pyx_v_start;
- Py_ssize_t __pyx_v_stop;
- Py_ssize_t __pyx_v_step;
- int __pyx_v_have_start;
- int __pyx_v_have_stop;
- int __pyx_v_have_step;
- PyObject *__pyx_v_index = NULL;
- struct __pyx_memoryview_obj *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- struct __pyx_memoryview_obj *__pyx_t_4;
- char *__pyx_t_5;
- int __pyx_t_6;
- Py_ssize_t __pyx_t_7;
- PyObject *(*__pyx_t_8)(PyObject *);
- PyObject *__pyx_t_9 = NULL;
- Py_ssize_t __pyx_t_10;
- int __pyx_t_11;
- Py_ssize_t __pyx_t_12;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("memview_slice", 0);
-
- /* "View.MemoryView":711
- * @cname('__pyx_memview_slice')
- * cdef memoryview memview_slice(memoryview memview, object indices):
- * cdef int new_ndim = 0, suboffset_dim = -1, dim # <<<<<<<<<<<<<<
- * cdef bint negative_step
- * cdef __Pyx_memviewslice src, dst
- */
- __pyx_v_new_ndim = 0;
- __pyx_v_suboffset_dim = -1;
-
- /* "View.MemoryView":718
- *
- *
- * memset(&dst, 0, sizeof(dst)) # <<<<<<<<<<<<<<
- *
- * cdef _memoryviewslice memviewsliceobj
- */
- (void)(memset((&__pyx_v_dst), 0, (sizeof(__pyx_v_dst))));
-
- /* "View.MemoryView":722
- * cdef _memoryviewslice memviewsliceobj
- *
- * assert memview.view.ndim > 0 # <<<<<<<<<<<<<<
- *
- * if isinstance(memview, _memoryviewslice):
- */
- #ifndef CYTHON_WITHOUT_ASSERTIONS
- if (unlikely(!Py_OptimizeFlag)) {
- if (unlikely(!((__pyx_v_memview->view.ndim > 0) != 0))) {
- PyErr_SetNone(PyExc_AssertionError);
- __PYX_ERR(1, 722, __pyx_L1_error)
- }
- }
- #endif
-
- /* "View.MemoryView":724
- * assert memview.view.ndim > 0
- *
- * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<<
- * memviewsliceobj = memview
- * p_src = &memviewsliceobj.from_slice
- */
- __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type);
- __pyx_t_2 = (__pyx_t_1 != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":725
- *
- * if isinstance(memview, _memoryviewslice):
- * memviewsliceobj = memview # <<<<<<<<<<<<<<
- * p_src = &memviewsliceobj.from_slice
- * else:
- */
- if (!(likely(((((PyObject *)__pyx_v_memview)) == Py_None) || likely(__Pyx_TypeTest(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type))))) __PYX_ERR(1, 725, __pyx_L1_error)
- __pyx_t_3 = ((PyObject *)__pyx_v_memview);
- __Pyx_INCREF(__pyx_t_3);
- __pyx_v_memviewsliceobj = ((struct __pyx_memoryviewslice_obj *)__pyx_t_3);
- __pyx_t_3 = 0;
-
- /* "View.MemoryView":726
- * if isinstance(memview, _memoryviewslice):
- * memviewsliceobj = memview
- * p_src = &memviewsliceobj.from_slice # <<<<<<<<<<<<<<
- * else:
- * slice_copy(memview, &src)
- */
- __pyx_v_p_src = (&__pyx_v_memviewsliceobj->from_slice);
-
- /* "View.MemoryView":724
- * assert memview.view.ndim > 0
- *
- * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<<
- * memviewsliceobj = memview
- * p_src = &memviewsliceobj.from_slice
- */
- goto __pyx_L3;
- }
-
- /* "View.MemoryView":728
- * p_src = &memviewsliceobj.from_slice
- * else:
- * slice_copy(memview, &src) # <<<<<<<<<<<<<<
- * p_src = &src
- *
- */
- /*else*/ {
- __pyx_memoryview_slice_copy(__pyx_v_memview, (&__pyx_v_src));
-
- /* "View.MemoryView":729
- * else:
- * slice_copy(memview, &src)
- * p_src = &src # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_v_p_src = (&__pyx_v_src);
- }
- __pyx_L3:;
-
- /* "View.MemoryView":735
- *
- *
- * dst.memview = p_src.memview # <<<<<<<<<<<<<<
- * dst.data = p_src.data
- *
- */
- __pyx_t_4 = __pyx_v_p_src->memview;
- __pyx_v_dst.memview = __pyx_t_4;
-
- /* "View.MemoryView":736
- *
- * dst.memview = p_src.memview
- * dst.data = p_src.data # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_5 = __pyx_v_p_src->data;
- __pyx_v_dst.data = __pyx_t_5;
-
- /* "View.MemoryView":741
- *
- *
- * cdef __Pyx_memviewslice *p_dst = &dst # <<<<<<<<<<<<<<
- * cdef int *p_suboffset_dim = &suboffset_dim
- * cdef Py_ssize_t start, stop, step
- */
- __pyx_v_p_dst = (&__pyx_v_dst);
-
- /* "View.MemoryView":742
- *
- * cdef __Pyx_memviewslice *p_dst = &dst
- * cdef int *p_suboffset_dim = &suboffset_dim # <<<<<<<<<<<<<<
- * cdef Py_ssize_t start, stop, step
- * cdef bint have_start, have_stop, have_step
- */
- __pyx_v_p_suboffset_dim = (&__pyx_v_suboffset_dim);
-
- /* "View.MemoryView":746
- * cdef bint have_start, have_stop, have_step
- *
- * for dim, index in enumerate(indices): # <<<<<<<<<<<<<<
- * if PyIndex_Check(index):
- * slice_memviewslice(
- */
- __pyx_t_6 = 0;
- if (likely(PyList_CheckExact(__pyx_v_indices)) || PyTuple_CheckExact(__pyx_v_indices)) {
- __pyx_t_3 = __pyx_v_indices; __Pyx_INCREF(__pyx_t_3); __pyx_t_7 = 0;
- __pyx_t_8 = NULL;
- } else {
- __pyx_t_7 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_indices); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 746, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_8 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 746, __pyx_L1_error)
- }
- for (;;) {
- if (likely(!__pyx_t_8)) {
- if (likely(PyList_CheckExact(__pyx_t_3))) {
- if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_3)) break;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_9 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(1, 746, __pyx_L1_error)
- #else
- __pyx_t_9 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 746, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- #endif
- } else {
- if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
- #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(1, 746, __pyx_L1_error)
- #else
- __pyx_t_9 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 746, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- #endif
- }
- } else {
- __pyx_t_9 = __pyx_t_8(__pyx_t_3);
- if (unlikely(!__pyx_t_9)) {
- PyObject* exc_type = PyErr_Occurred();
- if (exc_type) {
- if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
- else __PYX_ERR(1, 746, __pyx_L1_error)
- }
- break;
- }
- __Pyx_GOTREF(__pyx_t_9);
- }
- __Pyx_XDECREF_SET(__pyx_v_index, __pyx_t_9);
- __pyx_t_9 = 0;
- __pyx_v_dim = __pyx_t_6;
- __pyx_t_6 = (__pyx_t_6 + 1);
-
- /* "View.MemoryView":747
- *
- * for dim, index in enumerate(indices):
- * if PyIndex_Check(index): # <<<<<<<<<<<<<<
- * slice_memviewslice(
- * p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
- */
- __pyx_t_2 = (PyIndex_Check(__pyx_v_index) != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":751
- * p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
- * dim, new_ndim, p_suboffset_dim,
- * index, 0, 0, # start, stop, step # <<<<<<<<<<<<<<
- * 0, 0, 0, # have_{start,stop,step}
- * False)
- */
- __pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_v_index); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 751, __pyx_L1_error)
-
- /* "View.MemoryView":748
- * for dim, index in enumerate(indices):
- * if PyIndex_Check(index):
- * slice_memviewslice( # <<<<<<<<<<<<<<
- * p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
- * dim, new_ndim, p_suboffset_dim,
- */
- __pyx_t_11 = __pyx_memoryview_slice_memviewslice(__pyx_v_p_dst, (__pyx_v_p_src->shape[__pyx_v_dim]), (__pyx_v_p_src->strides[__pyx_v_dim]), (__pyx_v_p_src->suboffsets[__pyx_v_dim]), __pyx_v_dim, __pyx_v_new_ndim, __pyx_v_p_suboffset_dim, __pyx_t_10, 0, 0, 0, 0, 0, 0); if (unlikely(__pyx_t_11 == ((int)-1))) __PYX_ERR(1, 748, __pyx_L1_error)
-
- /* "View.MemoryView":747
- *
- * for dim, index in enumerate(indices):
- * if PyIndex_Check(index): # <<<<<<<<<<<<<<
- * slice_memviewslice(
- * p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
- */
- goto __pyx_L6;
- }
-
- /* "View.MemoryView":754
- * 0, 0, 0, # have_{start,stop,step}
- * False)
- * elif index is None: # <<<<<<<<<<<<<<
- * p_dst.shape[new_ndim] = 1
- * p_dst.strides[new_ndim] = 0
- */
- __pyx_t_2 = (__pyx_v_index == Py_None);
- __pyx_t_1 = (__pyx_t_2 != 0);
- if (__pyx_t_1) {
-
- /* "View.MemoryView":755
- * False)
- * elif index is None:
- * p_dst.shape[new_ndim] = 1 # <<<<<<<<<<<<<<
- * p_dst.strides[new_ndim] = 0
- * p_dst.suboffsets[new_ndim] = -1
- */
- (__pyx_v_p_dst->shape[__pyx_v_new_ndim]) = 1;
-
- /* "View.MemoryView":756
- * elif index is None:
- * p_dst.shape[new_ndim] = 1
- * p_dst.strides[new_ndim] = 0 # <<<<<<<<<<<<<<
- * p_dst.suboffsets[new_ndim] = -1
- * new_ndim += 1
- */
- (__pyx_v_p_dst->strides[__pyx_v_new_ndim]) = 0;
-
- /* "View.MemoryView":757
- * p_dst.shape[new_ndim] = 1
- * p_dst.strides[new_ndim] = 0
- * p_dst.suboffsets[new_ndim] = -1 # <<<<<<<<<<<<<<
- * new_ndim += 1
- * else:
- */
- (__pyx_v_p_dst->suboffsets[__pyx_v_new_ndim]) = -1L;
-
- /* "View.MemoryView":758
- * p_dst.strides[new_ndim] = 0
- * p_dst.suboffsets[new_ndim] = -1
- * new_ndim += 1 # <<<<<<<<<<<<<<
- * else:
- * start = index.start or 0
- */
- __pyx_v_new_ndim = (__pyx_v_new_ndim + 1);
-
- /* "View.MemoryView":754
- * 0, 0, 0, # have_{start,stop,step}
- * False)
- * elif index is None: # <<<<<<<<<<<<<<
- * p_dst.shape[new_ndim] = 1
- * p_dst.strides[new_ndim] = 0
- */
- goto __pyx_L6;
- }
-
- /* "View.MemoryView":760
- * new_ndim += 1
- * else:
- * start = index.start or 0 # <<<<<<<<<<<<<<
- * stop = index.stop or 0
- * step = index.step or 0
- */
- /*else*/ {
- __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_start); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 760, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 760, __pyx_L1_error)
- if (!__pyx_t_1) {
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- } else {
- __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 760, __pyx_L1_error)
- __pyx_t_10 = __pyx_t_12;
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- goto __pyx_L7_bool_binop_done;
- }
- __pyx_t_10 = 0;
- __pyx_L7_bool_binop_done:;
- __pyx_v_start = __pyx_t_10;
-
- /* "View.MemoryView":761
- * else:
- * start = index.start or 0
- * stop = index.stop or 0 # <<<<<<<<<<<<<<
- * step = index.step or 0
- *
- */
- __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_stop); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 761, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 761, __pyx_L1_error)
- if (!__pyx_t_1) {
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- } else {
- __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 761, __pyx_L1_error)
- __pyx_t_10 = __pyx_t_12;
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- goto __pyx_L9_bool_binop_done;
- }
- __pyx_t_10 = 0;
- __pyx_L9_bool_binop_done:;
- __pyx_v_stop = __pyx_t_10;
-
- /* "View.MemoryView":762
- * start = index.start or 0
- * stop = index.stop or 0
- * step = index.step or 0 # <<<<<<<<<<<<<<
- *
- * have_start = index.start is not None
- */
- __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_step); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 762, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 762, __pyx_L1_error)
- if (!__pyx_t_1) {
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- } else {
- __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 762, __pyx_L1_error)
- __pyx_t_10 = __pyx_t_12;
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- goto __pyx_L11_bool_binop_done;
- }
- __pyx_t_10 = 0;
- __pyx_L11_bool_binop_done:;
- __pyx_v_step = __pyx_t_10;
-
- /* "View.MemoryView":764
- * step = index.step or 0
- *
- * have_start = index.start is not None # <<<<<<<<<<<<<<
- * have_stop = index.stop is not None
- * have_step = index.step is not None
- */
- __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_start); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 764, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- __pyx_t_1 = (__pyx_t_9 != Py_None);
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- __pyx_v_have_start = __pyx_t_1;
-
- /* "View.MemoryView":765
- *
- * have_start = index.start is not None
- * have_stop = index.stop is not None # <<<<<<<<<<<<<<
- * have_step = index.step is not None
- *
- */
- __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_stop); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 765, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- __pyx_t_1 = (__pyx_t_9 != Py_None);
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- __pyx_v_have_stop = __pyx_t_1;
-
- /* "View.MemoryView":766
- * have_start = index.start is not None
- * have_stop = index.stop is not None
- * have_step = index.step is not None # <<<<<<<<<<<<<<
- *
- * slice_memviewslice(
- */
- __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_step); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 766, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_9);
- __pyx_t_1 = (__pyx_t_9 != Py_None);
- __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
- __pyx_v_have_step = __pyx_t_1;
-
- /* "View.MemoryView":768
- * have_step = index.step is not None
- *
- * slice_memviewslice( # <<<<<<<<<<<<<<
- * p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim],
- * dim, new_ndim, p_suboffset_dim,
- */
- __pyx_t_11 = __pyx_memoryview_slice_memviewslice(__pyx_v_p_dst, (__pyx_v_p_src->shape[__pyx_v_dim]), (__pyx_v_p_src->strides[__pyx_v_dim]), (__pyx_v_p_src->suboffsets[__pyx_v_dim]), __pyx_v_dim, __pyx_v_new_ndim, __pyx_v_p_suboffset_dim, __pyx_v_start, __pyx_v_stop, __pyx_v_step, __pyx_v_have_start, __pyx_v_have_stop, __pyx_v_have_step, 1); if (unlikely(__pyx_t_11 == ((int)-1))) __PYX_ERR(1, 768, __pyx_L1_error)
-
- /* "View.MemoryView":774
- * have_start, have_stop, have_step,
- * True)
- * new_ndim += 1 # <<<<<<<<<<<<<<
- *
- * if isinstance(memview, _memoryviewslice):
- */
- __pyx_v_new_ndim = (__pyx_v_new_ndim + 1);
- }
- __pyx_L6:;
-
- /* "View.MemoryView":746
- * cdef bint have_start, have_stop, have_step
- *
- * for dim, index in enumerate(indices): # <<<<<<<<<<<<<<
- * if PyIndex_Check(index):
- * slice_memviewslice(
- */
- }
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "View.MemoryView":776
- * new_ndim += 1
- *
- * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<<
- * return memoryview_fromslice(dst, new_ndim,
- * memviewsliceobj.to_object_func,
- */
- __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type);
- __pyx_t_2 = (__pyx_t_1 != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":777
- *
- * if isinstance(memview, _memoryviewslice):
- * return memoryview_fromslice(dst, new_ndim, # <<<<<<<<<<<<<<
- * memviewsliceobj.to_object_func,
- * memviewsliceobj.to_dtype_func,
- */
- __Pyx_XDECREF(((PyObject *)__pyx_r));
-
- /* "View.MemoryView":778
- * if isinstance(memview, _memoryviewslice):
- * return memoryview_fromslice(dst, new_ndim,
- * memviewsliceobj.to_object_func, # <<<<<<<<<<<<<<
- * memviewsliceobj.to_dtype_func,
- * memview.dtype_is_object)
- */
- if (unlikely(!__pyx_v_memviewsliceobj)) { __Pyx_RaiseUnboundLocalError("memviewsliceobj"); __PYX_ERR(1, 778, __pyx_L1_error) }
-
- /* "View.MemoryView":779
- * return memoryview_fromslice(dst, new_ndim,
- * memviewsliceobj.to_object_func,
- * memviewsliceobj.to_dtype_func, # <<<<<<<<<<<<<<
- * memview.dtype_is_object)
- * else:
- */
- if (unlikely(!__pyx_v_memviewsliceobj)) { __Pyx_RaiseUnboundLocalError("memviewsliceobj"); __PYX_ERR(1, 779, __pyx_L1_error) }
-
- /* "View.MemoryView":777
- *
- * if isinstance(memview, _memoryviewslice):
- * return memoryview_fromslice(dst, new_ndim, # <<<<<<<<<<<<<<
- * memviewsliceobj.to_object_func,
- * memviewsliceobj.to_dtype_func,
- */
- __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_dst, __pyx_v_new_ndim, __pyx_v_memviewsliceobj->to_object_func, __pyx_v_memviewsliceobj->to_dtype_func, __pyx_v_memview->dtype_is_object); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 777, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_memoryview_type))))) __PYX_ERR(1, 777, __pyx_L1_error)
- __pyx_r = ((struct __pyx_memoryview_obj *)__pyx_t_3);
- __pyx_t_3 = 0;
- goto __pyx_L0;
-
- /* "View.MemoryView":776
- * new_ndim += 1
- *
- * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<<
- * return memoryview_fromslice(dst, new_ndim,
- * memviewsliceobj.to_object_func,
- */
- }
-
- /* "View.MemoryView":782
- * memview.dtype_is_object)
- * else:
- * return memoryview_fromslice(dst, new_ndim, NULL, NULL, # <<<<<<<<<<<<<<
- * memview.dtype_is_object)
- *
- */
- /*else*/ {
- __Pyx_XDECREF(((PyObject *)__pyx_r));
-
- /* "View.MemoryView":783
- * else:
- * return memoryview_fromslice(dst, new_ndim, NULL, NULL,
- * memview.dtype_is_object) # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_dst, __pyx_v_new_ndim, NULL, NULL, __pyx_v_memview->dtype_is_object); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 782, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
-
- /* "View.MemoryView":782
- * memview.dtype_is_object)
- * else:
- * return memoryview_fromslice(dst, new_ndim, NULL, NULL, # <<<<<<<<<<<<<<
- * memview.dtype_is_object)
- *
- */
- if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_memoryview_type))))) __PYX_ERR(1, 782, __pyx_L1_error)
- __pyx_r = ((struct __pyx_memoryview_obj *)__pyx_t_3);
- __pyx_t_3 = 0;
- goto __pyx_L0;
- }
-
- /* "View.MemoryView":710
- *
- * @cname('__pyx_memview_slice')
- * cdef memoryview memview_slice(memoryview memview, object indices): # <<<<<<<<<<<<<<
- * cdef int new_ndim = 0, suboffset_dim = -1, dim
- * cdef bint negative_step
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_9);
- __Pyx_AddTraceback("View.MemoryView.memview_slice", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF((PyObject *)__pyx_v_memviewsliceobj);
- __Pyx_XDECREF(__pyx_v_index);
- __Pyx_XGIVEREF((PyObject *)__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":807
- *
- * @cname('__pyx_memoryview_slice_memviewslice')
- * cdef int slice_memviewslice( # <<<<<<<<<<<<<<
- * __Pyx_memviewslice *dst,
- * Py_ssize_t shape, Py_ssize_t stride, Py_ssize_t suboffset,
- */
-
-static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, Py_ssize_t __pyx_v_shape, Py_ssize_t __pyx_v_stride, Py_ssize_t __pyx_v_suboffset, int __pyx_v_dim, int __pyx_v_new_ndim, int *__pyx_v_suboffset_dim, Py_ssize_t __pyx_v_start, Py_ssize_t __pyx_v_stop, Py_ssize_t __pyx_v_step, int __pyx_v_have_start, int __pyx_v_have_stop, int __pyx_v_have_step, int __pyx_v_is_slice) {
- Py_ssize_t __pyx_v_new_shape;
- int __pyx_v_negative_step;
- int __pyx_r;
- int __pyx_t_1;
- int __pyx_t_2;
- int __pyx_t_3;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
-
- /* "View.MemoryView":827
- * cdef bint negative_step
- *
- * if not is_slice: # <<<<<<<<<<<<<<
- *
- * if start < 0:
- */
- __pyx_t_1 = ((!(__pyx_v_is_slice != 0)) != 0);
- if (__pyx_t_1) {
-
- /* "View.MemoryView":829
- * if not is_slice:
- *
- * if start < 0: # <<<<<<<<<<<<<<
- * start += shape
- * if not 0 <= start < shape:
- */
- __pyx_t_1 = ((__pyx_v_start < 0) != 0);
- if (__pyx_t_1) {
-
- /* "View.MemoryView":830
- *
- * if start < 0:
- * start += shape # <<<<<<<<<<<<<<
- * if not 0 <= start < shape:
- * _err_dim(IndexError, "Index out of bounds (axis %d)", dim)
- */
- __pyx_v_start = (__pyx_v_start + __pyx_v_shape);
-
- /* "View.MemoryView":829
- * if not is_slice:
- *
- * if start < 0: # <<<<<<<<<<<<<<
- * start += shape
- * if not 0 <= start < shape:
- */
- }
-
- /* "View.MemoryView":831
- * if start < 0:
- * start += shape
- * if not 0 <= start < shape: # <<<<<<<<<<<<<<
- * _err_dim(IndexError, "Index out of bounds (axis %d)", dim)
- * else:
- */
- __pyx_t_1 = (0 <= __pyx_v_start);
- if (__pyx_t_1) {
- __pyx_t_1 = (__pyx_v_start < __pyx_v_shape);
- }
- __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":832
- * start += shape
- * if not 0 <= start < shape:
- * _err_dim(IndexError, "Index out of bounds (axis %d)", dim) # <<<<<<<<<<<<<<
- * else:
- *
- */
- __pyx_t_3 = __pyx_memoryview_err_dim(__pyx_builtin_IndexError, ((char *)"Index out of bounds (axis %d)"), __pyx_v_dim); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 832, __pyx_L1_error)
-
- /* "View.MemoryView":831
- * if start < 0:
- * start += shape
- * if not 0 <= start < shape: # <<<<<<<<<<<<<<
- * _err_dim(IndexError, "Index out of bounds (axis %d)", dim)
- * else:
- */
- }
-
- /* "View.MemoryView":827
- * cdef bint negative_step
- *
- * if not is_slice: # <<<<<<<<<<<<<<
- *
- * if start < 0:
- */
- goto __pyx_L3;
- }
-
- /* "View.MemoryView":835
- * else:
- *
- * negative_step = have_step != 0 and step < 0 # <<<<<<<<<<<<<<
- *
- * if have_step and step == 0:
- */
- /*else*/ {
- __pyx_t_1 = ((__pyx_v_have_step != 0) != 0);
- if (__pyx_t_1) {
- } else {
- __pyx_t_2 = __pyx_t_1;
- goto __pyx_L6_bool_binop_done;
- }
- __pyx_t_1 = ((__pyx_v_step < 0) != 0);
- __pyx_t_2 = __pyx_t_1;
- __pyx_L6_bool_binop_done:;
- __pyx_v_negative_step = __pyx_t_2;
-
- /* "View.MemoryView":837
- * negative_step = have_step != 0 and step < 0
- *
- * if have_step and step == 0: # <<<<<<<<<<<<<<
- * _err_dim(ValueError, "Step may not be zero (axis %d)", dim)
- *
- */
- __pyx_t_1 = (__pyx_v_have_step != 0);
- if (__pyx_t_1) {
- } else {
- __pyx_t_2 = __pyx_t_1;
- goto __pyx_L9_bool_binop_done;
- }
- __pyx_t_1 = ((__pyx_v_step == 0) != 0);
- __pyx_t_2 = __pyx_t_1;
- __pyx_L9_bool_binop_done:;
- if (__pyx_t_2) {
-
- /* "View.MemoryView":838
- *
- * if have_step and step == 0:
- * _err_dim(ValueError, "Step may not be zero (axis %d)", dim) # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_3 = __pyx_memoryview_err_dim(__pyx_builtin_ValueError, ((char *)"Step may not be zero (axis %d)"), __pyx_v_dim); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 838, __pyx_L1_error)
-
- /* "View.MemoryView":837
- * negative_step = have_step != 0 and step < 0
- *
- * if have_step and step == 0: # <<<<<<<<<<<<<<
- * _err_dim(ValueError, "Step may not be zero (axis %d)", dim)
- *
- */
- }
-
- /* "View.MemoryView":841
- *
- *
- * if have_start: # <<<<<<<<<<<<<<
- * if start < 0:
- * start += shape
- */
- __pyx_t_2 = (__pyx_v_have_start != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":842
- *
- * if have_start:
- * if start < 0: # <<<<<<<<<<<<<<
- * start += shape
- * if start < 0:
- */
- __pyx_t_2 = ((__pyx_v_start < 0) != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":843
- * if have_start:
- * if start < 0:
- * start += shape # <<<<<<<<<<<<<<
- * if start < 0:
- * start = 0
- */
- __pyx_v_start = (__pyx_v_start + __pyx_v_shape);
-
- /* "View.MemoryView":844
- * if start < 0:
- * start += shape
- * if start < 0: # <<<<<<<<<<<<<<
- * start = 0
- * elif start >= shape:
- */
- __pyx_t_2 = ((__pyx_v_start < 0) != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":845
- * start += shape
- * if start < 0:
- * start = 0 # <<<<<<<<<<<<<<
- * elif start >= shape:
- * if negative_step:
- */
- __pyx_v_start = 0;
-
- /* "View.MemoryView":844
- * if start < 0:
- * start += shape
- * if start < 0: # <<<<<<<<<<<<<<
- * start = 0
- * elif start >= shape:
- */
- }
-
- /* "View.MemoryView":842
- *
- * if have_start:
- * if start < 0: # <<<<<<<<<<<<<<
- * start += shape
- * if start < 0:
- */
- goto __pyx_L12;
- }
-
- /* "View.MemoryView":846
- * if start < 0:
- * start = 0
- * elif start >= shape: # <<<<<<<<<<<<<<
- * if negative_step:
- * start = shape - 1
- */
- __pyx_t_2 = ((__pyx_v_start >= __pyx_v_shape) != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":847
- * start = 0
- * elif start >= shape:
- * if negative_step: # <<<<<<<<<<<<<<
- * start = shape - 1
- * else:
- */
- __pyx_t_2 = (__pyx_v_negative_step != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":848
- * elif start >= shape:
- * if negative_step:
- * start = shape - 1 # <<<<<<<<<<<<<<
- * else:
- * start = shape
- */
- __pyx_v_start = (__pyx_v_shape - 1);
-
- /* "View.MemoryView":847
- * start = 0
- * elif start >= shape:
- * if negative_step: # <<<<<<<<<<<<<<
- * start = shape - 1
- * else:
- */
- goto __pyx_L14;
- }
-
- /* "View.MemoryView":850
- * start = shape - 1
- * else:
- * start = shape # <<<<<<<<<<<<<<
- * else:
- * if negative_step:
- */
- /*else*/ {
- __pyx_v_start = __pyx_v_shape;
- }
- __pyx_L14:;
-
- /* "View.MemoryView":846
- * if start < 0:
- * start = 0
- * elif start >= shape: # <<<<<<<<<<<<<<
- * if negative_step:
- * start = shape - 1
- */
- }
- __pyx_L12:;
-
- /* "View.MemoryView":841
- *
- *
- * if have_start: # <<<<<<<<<<<<<<
- * if start < 0:
- * start += shape
- */
- goto __pyx_L11;
- }
-
- /* "View.MemoryView":852
- * start = shape
- * else:
- * if negative_step: # <<<<<<<<<<<<<<
- * start = shape - 1
- * else:
- */
- /*else*/ {
- __pyx_t_2 = (__pyx_v_negative_step != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":853
- * else:
- * if negative_step:
- * start = shape - 1 # <<<<<<<<<<<<<<
- * else:
- * start = 0
- */
- __pyx_v_start = (__pyx_v_shape - 1);
-
- /* "View.MemoryView":852
- * start = shape
- * else:
- * if negative_step: # <<<<<<<<<<<<<<
- * start = shape - 1
- * else:
- */
- goto __pyx_L15;
- }
-
- /* "View.MemoryView":855
- * start = shape - 1
- * else:
- * start = 0 # <<<<<<<<<<<<<<
- *
- * if have_stop:
- */
- /*else*/ {
- __pyx_v_start = 0;
- }
- __pyx_L15:;
- }
- __pyx_L11:;
-
- /* "View.MemoryView":857
- * start = 0
- *
- * if have_stop: # <<<<<<<<<<<<<<
- * if stop < 0:
- * stop += shape
- */
- __pyx_t_2 = (__pyx_v_have_stop != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":858
- *
- * if have_stop:
- * if stop < 0: # <<<<<<<<<<<<<<
- * stop += shape
- * if stop < 0:
- */
- __pyx_t_2 = ((__pyx_v_stop < 0) != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":859
- * if have_stop:
- * if stop < 0:
- * stop += shape # <<<<<<<<<<<<<<
- * if stop < 0:
- * stop = 0
- */
- __pyx_v_stop = (__pyx_v_stop + __pyx_v_shape);
-
- /* "View.MemoryView":860
- * if stop < 0:
- * stop += shape
- * if stop < 0: # <<<<<<<<<<<<<<
- * stop = 0
- * elif stop > shape:
- */
- __pyx_t_2 = ((__pyx_v_stop < 0) != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":861
- * stop += shape
- * if stop < 0:
- * stop = 0 # <<<<<<<<<<<<<<
- * elif stop > shape:
- * stop = shape
- */
- __pyx_v_stop = 0;
-
- /* "View.MemoryView":860
- * if stop < 0:
- * stop += shape
- * if stop < 0: # <<<<<<<<<<<<<<
- * stop = 0
- * elif stop > shape:
- */
- }
-
- /* "View.MemoryView":858
- *
- * if have_stop:
- * if stop < 0: # <<<<<<<<<<<<<<
- * stop += shape
- * if stop < 0:
- */
- goto __pyx_L17;
- }
-
- /* "View.MemoryView":862
- * if stop < 0:
- * stop = 0
- * elif stop > shape: # <<<<<<<<<<<<<<
- * stop = shape
- * else:
- */
- __pyx_t_2 = ((__pyx_v_stop > __pyx_v_shape) != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":863
- * stop = 0
- * elif stop > shape:
- * stop = shape # <<<<<<<<<<<<<<
- * else:
- * if negative_step:
- */
- __pyx_v_stop = __pyx_v_shape;
-
- /* "View.MemoryView":862
- * if stop < 0:
- * stop = 0
- * elif stop > shape: # <<<<<<<<<<<<<<
- * stop = shape
- * else:
- */
- }
- __pyx_L17:;
-
- /* "View.MemoryView":857
- * start = 0
- *
- * if have_stop: # <<<<<<<<<<<<<<
- * if stop < 0:
- * stop += shape
- */
- goto __pyx_L16;
- }
-
- /* "View.MemoryView":865
- * stop = shape
- * else:
- * if negative_step: # <<<<<<<<<<<<<<
- * stop = -1
- * else:
- */
- /*else*/ {
- __pyx_t_2 = (__pyx_v_negative_step != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":866
- * else:
- * if negative_step:
- * stop = -1 # <<<<<<<<<<<<<<
- * else:
- * stop = shape
- */
- __pyx_v_stop = -1L;
-
- /* "View.MemoryView":865
- * stop = shape
- * else:
- * if negative_step: # <<<<<<<<<<<<<<
- * stop = -1
- * else:
- */
- goto __pyx_L19;
- }
-
- /* "View.MemoryView":868
- * stop = -1
- * else:
- * stop = shape # <<<<<<<<<<<<<<
- *
- * if not have_step:
- */
- /*else*/ {
- __pyx_v_stop = __pyx_v_shape;
- }
- __pyx_L19:;
- }
- __pyx_L16:;
-
- /* "View.MemoryView":870
- * stop = shape
- *
- * if not have_step: # <<<<<<<<<<<<<<
- * step = 1
- *
- */
- __pyx_t_2 = ((!(__pyx_v_have_step != 0)) != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":871
- *
- * if not have_step:
- * step = 1 # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_v_step = 1;
-
- /* "View.MemoryView":870
- * stop = shape
- *
- * if not have_step: # <<<<<<<<<<<<<<
- * step = 1
- *
- */
- }
-
- /* "View.MemoryView":875
- *
- * with cython.cdivision(True):
- * new_shape = (stop - start) // step # <<<<<<<<<<<<<<
- *
- * if (stop - start) - step * new_shape:
- */
- __pyx_v_new_shape = ((__pyx_v_stop - __pyx_v_start) / __pyx_v_step);
-
- /* "View.MemoryView":877
- * new_shape = (stop - start) // step
- *
- * if (stop - start) - step * new_shape: # <<<<<<<<<<<<<<
- * new_shape += 1
- *
- */
- __pyx_t_2 = (((__pyx_v_stop - __pyx_v_start) - (__pyx_v_step * __pyx_v_new_shape)) != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":878
- *
- * if (stop - start) - step * new_shape:
- * new_shape += 1 # <<<<<<<<<<<<<<
- *
- * if new_shape < 0:
- */
- __pyx_v_new_shape = (__pyx_v_new_shape + 1);
-
- /* "View.MemoryView":877
- * new_shape = (stop - start) // step
- *
- * if (stop - start) - step * new_shape: # <<<<<<<<<<<<<<
- * new_shape += 1
- *
- */
- }
-
- /* "View.MemoryView":880
- * new_shape += 1
- *
- * if new_shape < 0: # <<<<<<<<<<<<<<
- * new_shape = 0
- *
- */
- __pyx_t_2 = ((__pyx_v_new_shape < 0) != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":881
- *
- * if new_shape < 0:
- * new_shape = 0 # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_v_new_shape = 0;
-
- /* "View.MemoryView":880
- * new_shape += 1
- *
- * if new_shape < 0: # <<<<<<<<<<<<<<
- * new_shape = 0
- *
- */
- }
-
- /* "View.MemoryView":884
- *
- *
- * dst.strides[new_ndim] = stride * step # <<<<<<<<<<<<<<
- * dst.shape[new_ndim] = new_shape
- * dst.suboffsets[new_ndim] = suboffset
- */
- (__pyx_v_dst->strides[__pyx_v_new_ndim]) = (__pyx_v_stride * __pyx_v_step);
-
- /* "View.MemoryView":885
- *
- * dst.strides[new_ndim] = stride * step
- * dst.shape[new_ndim] = new_shape # <<<<<<<<<<<<<<
- * dst.suboffsets[new_ndim] = suboffset
- *
- */
- (__pyx_v_dst->shape[__pyx_v_new_ndim]) = __pyx_v_new_shape;
-
- /* "View.MemoryView":886
- * dst.strides[new_ndim] = stride * step
- * dst.shape[new_ndim] = new_shape
- * dst.suboffsets[new_ndim] = suboffset # <<<<<<<<<<<<<<
- *
- *
- */
- (__pyx_v_dst->suboffsets[__pyx_v_new_ndim]) = __pyx_v_suboffset;
- }
- __pyx_L3:;
-
- /* "View.MemoryView":889
- *
- *
- * if suboffset_dim[0] < 0: # <<<<<<<<<<<<<<
- * dst.data += start * stride
- * else:
- */
- __pyx_t_2 = (((__pyx_v_suboffset_dim[0]) < 0) != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":890
- *
- * if suboffset_dim[0] < 0:
- * dst.data += start * stride # <<<<<<<<<<<<<<
- * else:
- * dst.suboffsets[suboffset_dim[0]] += start * stride
- */
- __pyx_v_dst->data = (__pyx_v_dst->data + (__pyx_v_start * __pyx_v_stride));
-
- /* "View.MemoryView":889
- *
- *
- * if suboffset_dim[0] < 0: # <<<<<<<<<<<<<<
- * dst.data += start * stride
- * else:
- */
- goto __pyx_L23;
- }
-
- /* "View.MemoryView":892
- * dst.data += start * stride
- * else:
- * dst.suboffsets[suboffset_dim[0]] += start * stride # <<<<<<<<<<<<<<
- *
- * if suboffset >= 0:
- */
- /*else*/ {
- __pyx_t_3 = (__pyx_v_suboffset_dim[0]);
- (__pyx_v_dst->suboffsets[__pyx_t_3]) = ((__pyx_v_dst->suboffsets[__pyx_t_3]) + (__pyx_v_start * __pyx_v_stride));
- }
- __pyx_L23:;
-
- /* "View.MemoryView":894
- * dst.suboffsets[suboffset_dim[0]] += start * stride
- *
- * if suboffset >= 0: # <<<<<<<<<<<<<<
- * if not is_slice:
- * if new_ndim == 0:
- */
- __pyx_t_2 = ((__pyx_v_suboffset >= 0) != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":895
- *
- * if suboffset >= 0:
- * if not is_slice: # <<<<<<<<<<<<<<
- * if new_ndim == 0:
- * dst.data = ( dst.data)[0] + suboffset
- */
- __pyx_t_2 = ((!(__pyx_v_is_slice != 0)) != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":896
- * if suboffset >= 0:
- * if not is_slice:
- * if new_ndim == 0: # <<<<<<<<<<<<<<
- * dst.data = ( dst.data)[0] + suboffset
- * else:
- */
- __pyx_t_2 = ((__pyx_v_new_ndim == 0) != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":897
- * if not is_slice:
- * if new_ndim == 0:
- * dst.data = ( dst.data)[0] + suboffset # <<<<<<<<<<<<<<
- * else:
- * _err_dim(IndexError, "All dimensions preceding dimension %d "
- */
- __pyx_v_dst->data = ((((char **)__pyx_v_dst->data)[0]) + __pyx_v_suboffset);
-
- /* "View.MemoryView":896
- * if suboffset >= 0:
- * if not is_slice:
- * if new_ndim == 0: # <<<<<<<<<<<<<<
- * dst.data = ( dst.data)[0] + suboffset
- * else:
- */
- goto __pyx_L26;
- }
-
- /* "View.MemoryView":899
- * dst.data = ( dst.data)[0] + suboffset
- * else:
- * _err_dim(IndexError, "All dimensions preceding dimension %d " # <<<<<<<<<<<<<<
- * "must be indexed and not sliced", dim)
- * else:
- */
- /*else*/ {
-
- /* "View.MemoryView":900
- * else:
- * _err_dim(IndexError, "All dimensions preceding dimension %d "
- * "must be indexed and not sliced", dim) # <<<<<<<<<<<<<<
- * else:
- * suboffset_dim[0] = new_ndim
- */
- __pyx_t_3 = __pyx_memoryview_err_dim(__pyx_builtin_IndexError, ((char *)"All dimensions preceding dimension %d must be indexed and not sliced"), __pyx_v_dim); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 899, __pyx_L1_error)
- }
- __pyx_L26:;
-
- /* "View.MemoryView":895
- *
- * if suboffset >= 0:
- * if not is_slice: # <<<<<<<<<<<<<<
- * if new_ndim == 0:
- * dst.data = ( dst.data)[0] + suboffset
- */
- goto __pyx_L25;
- }
-
- /* "View.MemoryView":902
- * "must be indexed and not sliced", dim)
- * else:
- * suboffset_dim[0] = new_ndim # <<<<<<<<<<<<<<
- *
- * return 0
- */
- /*else*/ {
- (__pyx_v_suboffset_dim[0]) = __pyx_v_new_ndim;
- }
- __pyx_L25:;
-
- /* "View.MemoryView":894
- * dst.suboffsets[suboffset_dim[0]] += start * stride
- *
- * if suboffset >= 0: # <<<<<<<<<<<<<<
- * if not is_slice:
- * if new_ndim == 0:
- */
- }
-
- /* "View.MemoryView":904
- * suboffset_dim[0] = new_ndim
- *
- * return 0 # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_r = 0;
- goto __pyx_L0;
-
- /* "View.MemoryView":807
- *
- * @cname('__pyx_memoryview_slice_memviewslice')
- * cdef int slice_memviewslice( # <<<<<<<<<<<<<<
- * __Pyx_memviewslice *dst,
- * Py_ssize_t shape, Py_ssize_t stride, Py_ssize_t suboffset,
- */
-
- /* function exit code */
- __pyx_L1_error:;
- {
- #ifdef WITH_THREAD
- PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
- #endif
- __Pyx_AddTraceback("View.MemoryView.slice_memviewslice", __pyx_clineno, __pyx_lineno, __pyx_filename);
- #ifdef WITH_THREAD
- __Pyx_PyGILState_Release(__pyx_gilstate_save);
- #endif
- }
- __pyx_r = -1;
- __pyx_L0:;
- return __pyx_r;
-}
-
-/* "View.MemoryView":910
- *
- * @cname('__pyx_pybuffer_index')
- * cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index, # <<<<<<<<<<<<<<
- * Py_ssize_t dim) except NULL:
- * cdef Py_ssize_t shape, stride, suboffset = -1
- */
-
-static char *__pyx_pybuffer_index(Py_buffer *__pyx_v_view, char *__pyx_v_bufp, Py_ssize_t __pyx_v_index, Py_ssize_t __pyx_v_dim) {
- Py_ssize_t __pyx_v_shape;
- Py_ssize_t __pyx_v_stride;
- Py_ssize_t __pyx_v_suboffset;
- Py_ssize_t __pyx_v_itemsize;
- char *__pyx_v_resultp;
- char *__pyx_r;
- __Pyx_RefNannyDeclarations
- Py_ssize_t __pyx_t_1;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("pybuffer_index", 0);
-
- /* "View.MemoryView":912
- * cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index,
- * Py_ssize_t dim) except NULL:
- * cdef Py_ssize_t shape, stride, suboffset = -1 # <<<<<<<<<<<<<<
- * cdef Py_ssize_t itemsize = view.itemsize
- * cdef char *resultp
- */
- __pyx_v_suboffset = -1L;
-
- /* "View.MemoryView":913
- * Py_ssize_t dim) except NULL:
- * cdef Py_ssize_t shape, stride, suboffset = -1
- * cdef Py_ssize_t itemsize = view.itemsize # <<<<<<<<<<<<<<
- * cdef char *resultp
- *
- */
- __pyx_t_1 = __pyx_v_view->itemsize;
- __pyx_v_itemsize = __pyx_t_1;
-
- /* "View.MemoryView":916
- * cdef char *resultp
- *
- * if view.ndim == 0: # <<<<<<<<<<<<<<
- * shape = view.len / itemsize
- * stride = itemsize
- */
- __pyx_t_2 = ((__pyx_v_view->ndim == 0) != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":917
- *
- * if view.ndim == 0:
- * shape = view.len / itemsize # <<<<<<<<<<<<<<
- * stride = itemsize
- * else:
- */
- if (unlikely(__pyx_v_itemsize == 0)) {
- PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
- __PYX_ERR(1, 917, __pyx_L1_error)
- }
- else if (sizeof(Py_ssize_t) == sizeof(long) && (!(((Py_ssize_t)-1) > 0)) && unlikely(__pyx_v_itemsize == (Py_ssize_t)-1) && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_v_view->len))) {
- PyErr_SetString(PyExc_OverflowError, "value too large to perform division");
- __PYX_ERR(1, 917, __pyx_L1_error)
- }
- __pyx_v_shape = __Pyx_div_Py_ssize_t(__pyx_v_view->len, __pyx_v_itemsize);
-
- /* "View.MemoryView":918
- * if view.ndim == 0:
- * shape = view.len / itemsize
- * stride = itemsize # <<<<<<<<<<<<<<
- * else:
- * shape = view.shape[dim]
- */
- __pyx_v_stride = __pyx_v_itemsize;
-
- /* "View.MemoryView":916
- * cdef char *resultp
- *
- * if view.ndim == 0: # <<<<<<<<<<<<<<
- * shape = view.len / itemsize
- * stride = itemsize
- */
- goto __pyx_L3;
- }
-
- /* "View.MemoryView":920
- * stride = itemsize
- * else:
- * shape = view.shape[dim] # <<<<<<<<<<<<<<
- * stride = view.strides[dim]
- * if view.suboffsets != NULL:
- */
- /*else*/ {
- __pyx_v_shape = (__pyx_v_view->shape[__pyx_v_dim]);
-
- /* "View.MemoryView":921
- * else:
- * shape = view.shape[dim]
- * stride = view.strides[dim] # <<<<<<<<<<<<<<
- * if view.suboffsets != NULL:
- * suboffset = view.suboffsets[dim]
- */
- __pyx_v_stride = (__pyx_v_view->strides[__pyx_v_dim]);
-
- /* "View.MemoryView":922
- * shape = view.shape[dim]
- * stride = view.strides[dim]
- * if view.suboffsets != NULL: # <<<<<<<<<<<<<<
- * suboffset = view.suboffsets[dim]
- *
- */
- __pyx_t_2 = ((__pyx_v_view->suboffsets != NULL) != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":923
- * stride = view.strides[dim]
- * if view.suboffsets != NULL:
- * suboffset = view.suboffsets[dim] # <<<<<<<<<<<<<<
- *
- * if index < 0:
- */
- __pyx_v_suboffset = (__pyx_v_view->suboffsets[__pyx_v_dim]);
-
- /* "View.MemoryView":922
- * shape = view.shape[dim]
- * stride = view.strides[dim]
- * if view.suboffsets != NULL: # <<<<<<<<<<<<<<
- * suboffset = view.suboffsets[dim]
- *
- */
- }
- }
- __pyx_L3:;
-
- /* "View.MemoryView":925
- * suboffset = view.suboffsets[dim]
- *
- * if index < 0: # <<<<<<<<<<<<<<
- * index += view.shape[dim]
- * if index < 0:
- */
- __pyx_t_2 = ((__pyx_v_index < 0) != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":926
- *
- * if index < 0:
- * index += view.shape[dim] # <<<<<<<<<<<<<<
- * if index < 0:
- * raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
- */
- __pyx_v_index = (__pyx_v_index + (__pyx_v_view->shape[__pyx_v_dim]));
-
- /* "View.MemoryView":927
- * if index < 0:
- * index += view.shape[dim]
- * if index < 0: # <<<<<<<<<<<<<<
- * raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
- *
- */
- __pyx_t_2 = ((__pyx_v_index < 0) != 0);
- if (unlikely(__pyx_t_2)) {
-
- /* "View.MemoryView":928
- * index += view.shape[dim]
- * if index < 0:
- * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) # <<<<<<<<<<<<<<
- *
- * if index >= shape:
- */
- __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 928, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Out_of_bounds_on_buffer_access_a, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 928, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_IndexError, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 928, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_Raise(__pyx_t_3, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __PYX_ERR(1, 928, __pyx_L1_error)
-
- /* "View.MemoryView":927
- * if index < 0:
- * index += view.shape[dim]
- * if index < 0: # <<<<<<<<<<<<<<
- * raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
- *
- */
- }
-
- /* "View.MemoryView":925
- * suboffset = view.suboffsets[dim]
- *
- * if index < 0: # <<<<<<<<<<<<<<
- * index += view.shape[dim]
- * if index < 0:
- */
- }
-
- /* "View.MemoryView":930
- * raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
- *
- * if index >= shape: # <<<<<<<<<<<<<<
- * raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
- *
- */
- __pyx_t_2 = ((__pyx_v_index >= __pyx_v_shape) != 0);
- if (unlikely(__pyx_t_2)) {
-
- /* "View.MemoryView":931
- *
- * if index >= shape:
- * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) # <<<<<<<<<<<<<<
- *
- * resultp = bufp + index * stride
- */
- __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 931, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Out_of_bounds_on_buffer_access_a, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 931, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_IndexError, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 931, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_Raise(__pyx_t_3, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __PYX_ERR(1, 931, __pyx_L1_error)
-
- /* "View.MemoryView":930
- * raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
- *
- * if index >= shape: # <<<<<<<<<<<<<<
- * raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
- *
- */
- }
-
- /* "View.MemoryView":933
- * raise IndexError("Out of bounds on buffer access (axis %d)" % dim)
- *
- * resultp = bufp + index * stride # <<<<<<<<<<<<<<
- * if suboffset >= 0:
- * resultp = ( resultp)[0] + suboffset
- */
- __pyx_v_resultp = (__pyx_v_bufp + (__pyx_v_index * __pyx_v_stride));
-
- /* "View.MemoryView":934
- *
- * resultp = bufp + index * stride
- * if suboffset >= 0: # <<<<<<<<<<<<<<
- * resultp = ( resultp)[0] + suboffset
- *
- */
- __pyx_t_2 = ((__pyx_v_suboffset >= 0) != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":935
- * resultp = bufp + index * stride
- * if suboffset >= 0:
- * resultp = ( resultp)[0] + suboffset # <<<<<<<<<<<<<<
- *
- * return resultp
- */
- __pyx_v_resultp = ((((char **)__pyx_v_resultp)[0]) + __pyx_v_suboffset);
-
- /* "View.MemoryView":934
- *
- * resultp = bufp + index * stride
- * if suboffset >= 0: # <<<<<<<<<<<<<<
- * resultp = ( resultp)[0] + suboffset
- *
- */
- }
-
- /* "View.MemoryView":937
- * resultp = ( resultp)[0] + suboffset
- *
- * return resultp # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_r = __pyx_v_resultp;
- goto __pyx_L0;
-
- /* "View.MemoryView":910
- *
- * @cname('__pyx_pybuffer_index')
- * cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index, # <<<<<<<<<<<<<<
- * Py_ssize_t dim) except NULL:
- * cdef Py_ssize_t shape, stride, suboffset = -1
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("View.MemoryView.pybuffer_index", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":943
- *
- * @cname('__pyx_memslice_transpose')
- * cdef int transpose_memslice(__Pyx_memviewslice *memslice) nogil except 0: # <<<<<<<<<<<<<<
- * cdef int ndim = memslice.memview.view.ndim
- *
- */
-
-static int __pyx_memslice_transpose(__Pyx_memviewslice *__pyx_v_memslice) {
- int __pyx_v_ndim;
- Py_ssize_t *__pyx_v_shape;
- Py_ssize_t *__pyx_v_strides;
- int __pyx_v_i;
- int __pyx_v_j;
- int __pyx_r;
- int __pyx_t_1;
- Py_ssize_t *__pyx_t_2;
- long __pyx_t_3;
- long __pyx_t_4;
- Py_ssize_t __pyx_t_5;
- Py_ssize_t __pyx_t_6;
- int __pyx_t_7;
- int __pyx_t_8;
- int __pyx_t_9;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
-
- /* "View.MemoryView":944
- * @cname('__pyx_memslice_transpose')
- * cdef int transpose_memslice(__Pyx_memviewslice *memslice) nogil except 0:
- * cdef int ndim = memslice.memview.view.ndim # <<<<<<<<<<<<<<
- *
- * cdef Py_ssize_t *shape = memslice.shape
- */
- __pyx_t_1 = __pyx_v_memslice->memview->view.ndim;
- __pyx_v_ndim = __pyx_t_1;
-
- /* "View.MemoryView":946
- * cdef int ndim = memslice.memview.view.ndim
- *
- * cdef Py_ssize_t *shape = memslice.shape # <<<<<<<<<<<<<<
- * cdef Py_ssize_t *strides = memslice.strides
- *
- */
- __pyx_t_2 = __pyx_v_memslice->shape;
- __pyx_v_shape = __pyx_t_2;
-
- /* "View.MemoryView":947
- *
- * cdef Py_ssize_t *shape = memslice.shape
- * cdef Py_ssize_t *strides = memslice.strides # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_2 = __pyx_v_memslice->strides;
- __pyx_v_strides = __pyx_t_2;
-
- /* "View.MemoryView":951
- *
- * cdef int i, j
- * for i in range(ndim / 2): # <<<<<<<<<<<<<<
- * j = ndim - 1 - i
- * strides[i], strides[j] = strides[j], strides[i]
- */
- __pyx_t_3 = __Pyx_div_long(__pyx_v_ndim, 2);
- __pyx_t_4 = __pyx_t_3;
- for (__pyx_t_1 = 0; __pyx_t_1 < __pyx_t_4; __pyx_t_1+=1) {
- __pyx_v_i = __pyx_t_1;
-
- /* "View.MemoryView":952
- * cdef int i, j
- * for i in range(ndim / 2):
- * j = ndim - 1 - i # <<<<<<<<<<<<<<
- * strides[i], strides[j] = strides[j], strides[i]
- * shape[i], shape[j] = shape[j], shape[i]
- */
- __pyx_v_j = ((__pyx_v_ndim - 1) - __pyx_v_i);
-
- /* "View.MemoryView":953
- * for i in range(ndim / 2):
- * j = ndim - 1 - i
- * strides[i], strides[j] = strides[j], strides[i] # <<<<<<<<<<<<<<
- * shape[i], shape[j] = shape[j], shape[i]
- *
- */
- __pyx_t_5 = (__pyx_v_strides[__pyx_v_j]);
- __pyx_t_6 = (__pyx_v_strides[__pyx_v_i]);
- (__pyx_v_strides[__pyx_v_i]) = __pyx_t_5;
- (__pyx_v_strides[__pyx_v_j]) = __pyx_t_6;
-
- /* "View.MemoryView":954
- * j = ndim - 1 - i
- * strides[i], strides[j] = strides[j], strides[i]
- * shape[i], shape[j] = shape[j], shape[i] # <<<<<<<<<<<<<<
- *
- * if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0:
- */
- __pyx_t_6 = (__pyx_v_shape[__pyx_v_j]);
- __pyx_t_5 = (__pyx_v_shape[__pyx_v_i]);
- (__pyx_v_shape[__pyx_v_i]) = __pyx_t_6;
- (__pyx_v_shape[__pyx_v_j]) = __pyx_t_5;
-
- /* "View.MemoryView":956
- * shape[i], shape[j] = shape[j], shape[i]
- *
- * if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0: # <<<<<<<<<<<<<<
- * _err(ValueError, "Cannot transpose memoryview with indirect dimensions")
- *
- */
- __pyx_t_8 = (((__pyx_v_memslice->suboffsets[__pyx_v_i]) >= 0) != 0);
- if (!__pyx_t_8) {
- } else {
- __pyx_t_7 = __pyx_t_8;
- goto __pyx_L6_bool_binop_done;
- }
- __pyx_t_8 = (((__pyx_v_memslice->suboffsets[__pyx_v_j]) >= 0) != 0);
- __pyx_t_7 = __pyx_t_8;
- __pyx_L6_bool_binop_done:;
- if (__pyx_t_7) {
-
- /* "View.MemoryView":957
- *
- * if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0:
- * _err(ValueError, "Cannot transpose memoryview with indirect dimensions") # <<<<<<<<<<<<<<
- *
- * return 1
- */
- __pyx_t_9 = __pyx_memoryview_err(__pyx_builtin_ValueError, ((char *)"Cannot transpose memoryview with indirect dimensions")); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(1, 957, __pyx_L1_error)
-
- /* "View.MemoryView":956
- * shape[i], shape[j] = shape[j], shape[i]
- *
- * if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0: # <<<<<<<<<<<<<<
- * _err(ValueError, "Cannot transpose memoryview with indirect dimensions")
- *
- */
- }
- }
-
- /* "View.MemoryView":959
- * _err(ValueError, "Cannot transpose memoryview with indirect dimensions")
- *
- * return 1 # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_r = 1;
- goto __pyx_L0;
-
- /* "View.MemoryView":943
- *
- * @cname('__pyx_memslice_transpose')
- * cdef int transpose_memslice(__Pyx_memviewslice *memslice) nogil except 0: # <<<<<<<<<<<<<<
- * cdef int ndim = memslice.memview.view.ndim
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- {
- #ifdef WITH_THREAD
- PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
- #endif
- __Pyx_AddTraceback("View.MemoryView.transpose_memslice", __pyx_clineno, __pyx_lineno, __pyx_filename);
- #ifdef WITH_THREAD
- __Pyx_PyGILState_Release(__pyx_gilstate_save);
- #endif
- }
- __pyx_r = 0;
- __pyx_L0:;
- return __pyx_r;
-}
-
-/* "View.MemoryView":976
- * cdef int (*to_dtype_func)(char *, object) except 0
- *
- * def __dealloc__(self): # <<<<<<<<<<<<<<
- * __PYX_XDEC_MEMVIEW(&self.from_slice, 1)
- *
- */
-
-/* Python wrapper */
-static void __pyx_memoryviewslice___dealloc__(PyObject *__pyx_v_self); /*proto*/
-static void __pyx_memoryviewslice___dealloc__(PyObject *__pyx_v_self) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
- __pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
-}
-
-static void __pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__(struct __pyx_memoryviewslice_obj *__pyx_v_self) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__dealloc__", 0);
-
- /* "View.MemoryView":977
- *
- * def __dealloc__(self):
- * __PYX_XDEC_MEMVIEW(&self.from_slice, 1) # <<<<<<<<<<<<<<
- *
- * cdef convert_item_to_object(self, char *itemp):
- */
- __PYX_XDEC_MEMVIEW((&__pyx_v_self->from_slice), 1);
-
- /* "View.MemoryView":976
- * cdef int (*to_dtype_func)(char *, object) except 0
- *
- * def __dealloc__(self): # <<<<<<<<<<<<<<
- * __PYX_XDEC_MEMVIEW(&self.from_slice, 1)
- *
- */
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
-}
-
-/* "View.MemoryView":979
- * __PYX_XDEC_MEMVIEW(&self.from_slice, 1)
- *
- * cdef convert_item_to_object(self, char *itemp): # <<<<<<<<<<<<<<
- * if self.to_object_func != NULL:
- * return self.to_object_func(itemp)
- */
-
-static PyObject *__pyx_memoryviewslice_convert_item_to_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("convert_item_to_object", 0);
-
- /* "View.MemoryView":980
- *
- * cdef convert_item_to_object(self, char *itemp):
- * if self.to_object_func != NULL: # <<<<<<<<<<<<<<
- * return self.to_object_func(itemp)
- * else:
- */
- __pyx_t_1 = ((__pyx_v_self->to_object_func != NULL) != 0);
- if (__pyx_t_1) {
-
- /* "View.MemoryView":981
- * cdef convert_item_to_object(self, char *itemp):
- * if self.to_object_func != NULL:
- * return self.to_object_func(itemp) # <<<<<<<<<<<<<<
- * else:
- * return memoryview.convert_item_to_object(self, itemp)
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = __pyx_v_self->to_object_func(__pyx_v_itemp); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 981, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
-
- /* "View.MemoryView":980
- *
- * cdef convert_item_to_object(self, char *itemp):
- * if self.to_object_func != NULL: # <<<<<<<<<<<<<<
- * return self.to_object_func(itemp)
- * else:
- */
- }
-
- /* "View.MemoryView":983
- * return self.to_object_func(itemp)
- * else:
- * return memoryview.convert_item_to_object(self, itemp) # <<<<<<<<<<<<<<
- *
- * cdef assign_item_from_object(self, char *itemp, object value):
- */
- /*else*/ {
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = __pyx_memoryview_convert_item_to_object(((struct __pyx_memoryview_obj *)__pyx_v_self), __pyx_v_itemp); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 983, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_r = __pyx_t_2;
- __pyx_t_2 = 0;
- goto __pyx_L0;
- }
-
- /* "View.MemoryView":979
- * __PYX_XDEC_MEMVIEW(&self.from_slice, 1)
- *
- * cdef convert_item_to_object(self, char *itemp): # <<<<<<<<<<<<<<
- * if self.to_object_func != NULL:
- * return self.to_object_func(itemp)
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_AddTraceback("View.MemoryView._memoryviewslice.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":985
- * return memoryview.convert_item_to_object(self, itemp)
- *
- * cdef assign_item_from_object(self, char *itemp, object value): # <<<<<<<<<<<<<<
- * if self.to_dtype_func != NULL:
- * self.to_dtype_func(itemp, value)
- */
-
-static PyObject *__pyx_memoryviewslice_assign_item_from_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("assign_item_from_object", 0);
-
- /* "View.MemoryView":986
- *
- * cdef assign_item_from_object(self, char *itemp, object value):
- * if self.to_dtype_func != NULL: # <<<<<<<<<<<<<<
- * self.to_dtype_func(itemp, value)
- * else:
- */
- __pyx_t_1 = ((__pyx_v_self->to_dtype_func != NULL) != 0);
- if (__pyx_t_1) {
-
- /* "View.MemoryView":987
- * cdef assign_item_from_object(self, char *itemp, object value):
- * if self.to_dtype_func != NULL:
- * self.to_dtype_func(itemp, value) # <<<<<<<<<<<<<<
- * else:
- * memoryview.assign_item_from_object(self, itemp, value)
- */
- __pyx_t_2 = __pyx_v_self->to_dtype_func(__pyx_v_itemp, __pyx_v_value); if (unlikely(__pyx_t_2 == ((int)0))) __PYX_ERR(1, 987, __pyx_L1_error)
-
- /* "View.MemoryView":986
- *
- * cdef assign_item_from_object(self, char *itemp, object value):
- * if self.to_dtype_func != NULL: # <<<<<<<<<<<<<<
- * self.to_dtype_func(itemp, value)
- * else:
- */
- goto __pyx_L3;
- }
-
- /* "View.MemoryView":989
- * self.to_dtype_func(itemp, value)
- * else:
- * memoryview.assign_item_from_object(self, itemp, value) # <<<<<<<<<<<<<<
- *
- * @property
- */
- /*else*/ {
- __pyx_t_3 = __pyx_memoryview_assign_item_from_object(((struct __pyx_memoryview_obj *)__pyx_v_self), __pyx_v_itemp, __pyx_v_value); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 989, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- }
- __pyx_L3:;
-
- /* "View.MemoryView":985
- * return memoryview.convert_item_to_object(self, itemp)
- *
- * cdef assign_item_from_object(self, char *itemp, object value): # <<<<<<<<<<<<<<
- * if self.to_dtype_func != NULL:
- * self.to_dtype_func(itemp, value)
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("View.MemoryView._memoryviewslice.assign_item_from_object", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":992
- *
- * @property
- * def base(self): # <<<<<<<<<<<<<<
- * return self.from_object
- *
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_15View_dot_MemoryView_16_memoryviewslice_4base_1__get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pw_15View_dot_MemoryView_16_memoryviewslice_4base_1__get__(PyObject *__pyx_v_self) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
- __pyx_r = __pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__(struct __pyx_memoryviewslice_obj *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__get__", 0);
-
- /* "View.MemoryView":993
- * @property
- * def base(self):
- * return self.from_object # <<<<<<<<<<<<<<
- *
- * __pyx_getbuffer = capsule( &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)")
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v_self->from_object);
- __pyx_r = __pyx_v_self->from_object;
- goto __pyx_L0;
-
- /* "View.MemoryView":992
- *
- * @property
- * def base(self): # <<<<<<<<<<<<<<
- * return self.from_object
- *
- */
-
- /* function exit code */
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "(tree fragment)":1
- * def __reduce_cython__(self): # <<<<<<<<<<<<<<
- * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
- * def __setstate_cython__(self, __pyx_state):
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw___pyx_memoryviewslice_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_pw___pyx_memoryviewslice_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
- __pyx_r = __pyx_pf___pyx_memoryviewslice___reduce_cython__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf___pyx_memoryviewslice___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryviewslice_obj *__pyx_v_self) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("__reduce_cython__", 0);
-
- /* "(tree fragment)":2
- * def __reduce_cython__(self):
- * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
- * def __setstate_cython__(self, __pyx_state):
- * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
- */
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__18, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_Raise(__pyx_t_1, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __PYX_ERR(1, 2, __pyx_L1_error)
-
- /* "(tree fragment)":1
- * def __reduce_cython__(self): # <<<<<<<<<<<<<<
- * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
- * def __setstate_cython__(self, __pyx_state):
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("View.MemoryView._memoryviewslice.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "(tree fragment)":3
- * def __reduce_cython__(self):
- * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
- * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
- * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw___pyx_memoryviewslice_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
-static PyObject *__pyx_pw___pyx_memoryviewslice_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
- __pyx_r = __pyx_pf___pyx_memoryviewslice_2__setstate_cython__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf___pyx_memoryviewslice_2__setstate_cython__(CYTHON_UNUSED struct __pyx_memoryviewslice_obj *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("__setstate_cython__", 0);
-
- /* "(tree fragment)":4
- * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
- * def __setstate_cython__(self, __pyx_state):
- * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
- */
- __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__19, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_Raise(__pyx_t_1, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __PYX_ERR(1, 4, __pyx_L1_error)
-
- /* "(tree fragment)":3
- * def __reduce_cython__(self):
- * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
- * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
- * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("View.MemoryView._memoryviewslice.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":999
- *
- * @cname('__pyx_memoryview_fromslice')
- * cdef memoryview_fromslice(__Pyx_memviewslice memviewslice, # <<<<<<<<<<<<<<
- * int ndim,
- * object (*to_object_func)(char *),
- */
-
-static PyObject *__pyx_memoryview_fromslice(__Pyx_memviewslice __pyx_v_memviewslice, int __pyx_v_ndim, PyObject *(*__pyx_v_to_object_func)(char *), int (*__pyx_v_to_dtype_func)(char *, PyObject *), int __pyx_v_dtype_is_object) {
- struct __pyx_memoryviewslice_obj *__pyx_v_result = 0;
- Py_ssize_t __pyx_v_suboffset;
- PyObject *__pyx_v_length = NULL;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- __Pyx_TypeInfo *__pyx_t_4;
- Py_buffer __pyx_t_5;
- Py_ssize_t *__pyx_t_6;
- Py_ssize_t *__pyx_t_7;
- Py_ssize_t *__pyx_t_8;
- Py_ssize_t __pyx_t_9;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("memoryview_fromslice", 0);
-
- /* "View.MemoryView":1007
- * cdef _memoryviewslice result
- *
- * if memviewslice.memview == Py_None: # <<<<<<<<<<<<<<
- * return None
- *
- */
- __pyx_t_1 = ((((PyObject *)__pyx_v_memviewslice.memview) == Py_None) != 0);
- if (__pyx_t_1) {
-
- /* "View.MemoryView":1008
- *
- * if memviewslice.memview == Py_None:
- * return None # <<<<<<<<<<<<<<
- *
- *
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
-
- /* "View.MemoryView":1007
- * cdef _memoryviewslice result
- *
- * if memviewslice.memview == Py_None: # <<<<<<<<<<<<<<
- * return None
- *
- */
- }
-
- /* "View.MemoryView":1013
- *
- *
- * result = _memoryviewslice(None, 0, dtype_is_object) # <<<<<<<<<<<<<<
- *
- * result.from_slice = memviewslice
- */
- __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_dtype_is_object); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1013, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1013, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_INCREF(Py_None);
- __Pyx_GIVEREF(Py_None);
- PyTuple_SET_ITEM(__pyx_t_3, 0, Py_None);
- __Pyx_INCREF(__pyx_int_0);
- __Pyx_GIVEREF(__pyx_int_0);
- PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_0);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2);
- __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_memoryviewslice_type), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1013, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_v_result = ((struct __pyx_memoryviewslice_obj *)__pyx_t_2);
- __pyx_t_2 = 0;
-
- /* "View.MemoryView":1015
- * result = _memoryviewslice(None, 0, dtype_is_object)
- *
- * result.from_slice = memviewslice # <<<<<<<<<<<<<<
- * __PYX_INC_MEMVIEW(&memviewslice, 1)
- *
- */
- __pyx_v_result->from_slice = __pyx_v_memviewslice;
-
- /* "View.MemoryView":1016
- *
- * result.from_slice = memviewslice
- * __PYX_INC_MEMVIEW(&memviewslice, 1) # <<<<<<<<<<<<<<
- *
- * result.from_object = ( memviewslice.memview).base
- */
- __PYX_INC_MEMVIEW((&__pyx_v_memviewslice), 1);
-
- /* "View.MemoryView":1018
- * __PYX_INC_MEMVIEW(&memviewslice, 1)
- *
- * result.from_object = ( memviewslice.memview).base # <<<<<<<<<<<<<<
- * result.typeinfo = memviewslice.memview.typeinfo
- *
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_memviewslice.memview), __pyx_n_s_base); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1018, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_2);
- __Pyx_GOTREF(__pyx_v_result->from_object);
- __Pyx_DECREF(__pyx_v_result->from_object);
- __pyx_v_result->from_object = __pyx_t_2;
- __pyx_t_2 = 0;
-
- /* "View.MemoryView":1019
- *
- * result.from_object = ( memviewslice.memview).base
- * result.typeinfo = memviewslice.memview.typeinfo # <<<<<<<<<<<<<<
- *
- * result.view = memviewslice.memview.view
- */
- __pyx_t_4 = __pyx_v_memviewslice.memview->typeinfo;
- __pyx_v_result->__pyx_base.typeinfo = __pyx_t_4;
-
- /* "View.MemoryView":1021
- * result.typeinfo = memviewslice.memview.typeinfo
- *
- * result.view = memviewslice.memview.view # <<<<<<<<<<<<<<
- * result.view.buf = memviewslice.data
- * result.view.ndim = ndim
- */
- __pyx_t_5 = __pyx_v_memviewslice.memview->view;
- __pyx_v_result->__pyx_base.view = __pyx_t_5;
-
- /* "View.MemoryView":1022
- *
- * result.view = memviewslice.memview.view
- * result.view.buf = memviewslice.data # <<<<<<<<<<<<<<
- * result.view.ndim = ndim
- * (<__pyx_buffer *> &result.view).obj = Py_None
- */
- __pyx_v_result->__pyx_base.view.buf = ((void *)__pyx_v_memviewslice.data);
-
- /* "View.MemoryView":1023
- * result.view = memviewslice.memview.view
- * result.view.buf = memviewslice.data
- * result.view.ndim = ndim # <<<<<<<<<<<<<<
- * (<__pyx_buffer *> &result.view).obj = Py_None
- * Py_INCREF(Py_None)
- */
- __pyx_v_result->__pyx_base.view.ndim = __pyx_v_ndim;
-
- /* "View.MemoryView":1024
- * result.view.buf = memviewslice.data
- * result.view.ndim = ndim
- * (<__pyx_buffer *> &result.view).obj = Py_None # <<<<<<<<<<<<<<
- * Py_INCREF(Py_None)
- *
- */
- ((Py_buffer *)(&__pyx_v_result->__pyx_base.view))->obj = Py_None;
-
- /* "View.MemoryView":1025
- * result.view.ndim = ndim
- * (<__pyx_buffer *> &result.view).obj = Py_None
- * Py_INCREF(Py_None) # <<<<<<<<<<<<<<
- *
- * if (memviewslice.memview).flags & PyBUF_WRITABLE:
- */
- Py_INCREF(Py_None);
-
- /* "View.MemoryView":1027
- * Py_INCREF(Py_None)
- *
- * if (memviewslice.memview).flags & PyBUF_WRITABLE: # <<<<<<<<<<<<<<
- * result.flags = PyBUF_RECORDS
- * else:
- */
- __pyx_t_1 = ((((struct __pyx_memoryview_obj *)__pyx_v_memviewslice.memview)->flags & PyBUF_WRITABLE) != 0);
- if (__pyx_t_1) {
-
- /* "View.MemoryView":1028
- *
- * if (memviewslice.memview).flags & PyBUF_WRITABLE:
- * result.flags = PyBUF_RECORDS # <<<<<<<<<<<<<<
- * else:
- * result.flags = PyBUF_RECORDS_RO
- */
- __pyx_v_result->__pyx_base.flags = PyBUF_RECORDS;
-
- /* "View.MemoryView":1027
- * Py_INCREF(Py_None)
- *
- * if (memviewslice.memview).flags & PyBUF_WRITABLE: # <<<<<<<<<<<<<<
- * result.flags = PyBUF_RECORDS
- * else:
- */
- goto __pyx_L4;
- }
-
- /* "View.MemoryView":1030
- * result.flags = PyBUF_RECORDS
- * else:
- * result.flags = PyBUF_RECORDS_RO # <<<<<<<<<<<<<<
- *
- * result.view.shape = result.from_slice.shape
- */
- /*else*/ {
- __pyx_v_result->__pyx_base.flags = PyBUF_RECORDS_RO;
- }
- __pyx_L4:;
-
- /* "View.MemoryView":1032
- * result.flags = PyBUF_RECORDS_RO
- *
- * result.view.shape = result.from_slice.shape # <<<<<<<<<<<<<<
- * result.view.strides = result.from_slice.strides
- *
- */
- __pyx_v_result->__pyx_base.view.shape = ((Py_ssize_t *)__pyx_v_result->from_slice.shape);
-
- /* "View.MemoryView":1033
- *
- * result.view.shape = result.from_slice.shape
- * result.view.strides = result.from_slice.strides # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_v_result->__pyx_base.view.strides = ((Py_ssize_t *)__pyx_v_result->from_slice.strides);
-
- /* "View.MemoryView":1036
- *
- *
- * result.view.suboffsets = NULL # <<<<<<<<<<<<<<
- * for suboffset in result.from_slice.suboffsets[:ndim]:
- * if suboffset >= 0:
- */
- __pyx_v_result->__pyx_base.view.suboffsets = NULL;
-
- /* "View.MemoryView":1037
- *
- * result.view.suboffsets = NULL
- * for suboffset in result.from_slice.suboffsets[:ndim]: # <<<<<<<<<<<<<<
- * if suboffset >= 0:
- * result.view.suboffsets = result.from_slice.suboffsets
- */
- __pyx_t_7 = (__pyx_v_result->from_slice.suboffsets + __pyx_v_ndim);
- for (__pyx_t_8 = __pyx_v_result->from_slice.suboffsets; __pyx_t_8 < __pyx_t_7; __pyx_t_8++) {
- __pyx_t_6 = __pyx_t_8;
- __pyx_v_suboffset = (__pyx_t_6[0]);
-
- /* "View.MemoryView":1038
- * result.view.suboffsets = NULL
- * for suboffset in result.from_slice.suboffsets[:ndim]:
- * if suboffset >= 0: # <<<<<<<<<<<<<<
- * result.view.suboffsets = result.from_slice.suboffsets
- * break
- */
- __pyx_t_1 = ((__pyx_v_suboffset >= 0) != 0);
- if (__pyx_t_1) {
-
- /* "View.MemoryView":1039
- * for suboffset in result.from_slice.suboffsets[:ndim]:
- * if suboffset >= 0:
- * result.view.suboffsets = result.from_slice.suboffsets # <<<<<<<<<<<<<<
- * break
- *
- */
- __pyx_v_result->__pyx_base.view.suboffsets = ((Py_ssize_t *)__pyx_v_result->from_slice.suboffsets);
-
- /* "View.MemoryView":1040
- * if suboffset >= 0:
- * result.view.suboffsets = result.from_slice.suboffsets
- * break # <<<<<<<<<<<<<<
- *
- * result.view.len = result.view.itemsize
- */
- goto __pyx_L6_break;
-
- /* "View.MemoryView":1038
- * result.view.suboffsets = NULL
- * for suboffset in result.from_slice.suboffsets[:ndim]:
- * if suboffset >= 0: # <<<<<<<<<<<<<<
- * result.view.suboffsets = result.from_slice.suboffsets
- * break
- */
- }
- }
- __pyx_L6_break:;
-
- /* "View.MemoryView":1042
- * break
- *
- * result.view.len = result.view.itemsize # <<<<<<<<<<<<<<
- * for length in result.view.shape[:ndim]:
- * result.view.len *= length
- */
- __pyx_t_9 = __pyx_v_result->__pyx_base.view.itemsize;
- __pyx_v_result->__pyx_base.view.len = __pyx_t_9;
-
- /* "View.MemoryView":1043
- *
- * result.view.len = result.view.itemsize
- * for length in result.view.shape[:ndim]: # <<<<<<<<<<<<<<
- * result.view.len *= length
- *
- */
- __pyx_t_7 = (__pyx_v_result->__pyx_base.view.shape + __pyx_v_ndim);
- for (__pyx_t_8 = __pyx_v_result->__pyx_base.view.shape; __pyx_t_8 < __pyx_t_7; __pyx_t_8++) {
- __pyx_t_6 = __pyx_t_8;
- __pyx_t_2 = PyInt_FromSsize_t((__pyx_t_6[0])); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1043, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_XDECREF_SET(__pyx_v_length, __pyx_t_2);
- __pyx_t_2 = 0;
-
- /* "View.MemoryView":1044
- * result.view.len = result.view.itemsize
- * for length in result.view.shape[:ndim]:
- * result.view.len *= length # <<<<<<<<<<<<<<
- *
- * result.to_object_func = to_object_func
- */
- __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_result->__pyx_base.view.len); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1044, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = PyNumber_InPlaceMultiply(__pyx_t_2, __pyx_v_length); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1044, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 1044, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_v_result->__pyx_base.view.len = __pyx_t_9;
- }
-
- /* "View.MemoryView":1046
- * result.view.len *= length
- *
- * result.to_object_func = to_object_func # <<<<<<<<<<<<<<
- * result.to_dtype_func = to_dtype_func
- *
- */
- __pyx_v_result->to_object_func = __pyx_v_to_object_func;
-
- /* "View.MemoryView":1047
- *
- * result.to_object_func = to_object_func
- * result.to_dtype_func = to_dtype_func # <<<<<<<<<<<<<<
- *
- * return result
- */
- __pyx_v_result->to_dtype_func = __pyx_v_to_dtype_func;
-
- /* "View.MemoryView":1049
- * result.to_dtype_func = to_dtype_func
- *
- * return result # <<<<<<<<<<<<<<
- *
- * @cname('__pyx_memoryview_get_slice_from_memoryview')
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(((PyObject *)__pyx_v_result));
- __pyx_r = ((PyObject *)__pyx_v_result);
- goto __pyx_L0;
-
- /* "View.MemoryView":999
- *
- * @cname('__pyx_memoryview_fromslice')
- * cdef memoryview_fromslice(__Pyx_memviewslice memviewslice, # <<<<<<<<<<<<<<
- * int ndim,
- * object (*to_object_func)(char *),
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("View.MemoryView.memoryview_fromslice", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XDECREF((PyObject *)__pyx_v_result);
- __Pyx_XDECREF(__pyx_v_length);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":1052
- *
- * @cname('__pyx_memoryview_get_slice_from_memoryview')
- * cdef __Pyx_memviewslice *get_slice_from_memview(memoryview memview, # <<<<<<<<<<<<<<
- * __Pyx_memviewslice *mslice) except NULL:
- * cdef _memoryviewslice obj
- */
-
-static __Pyx_memviewslice *__pyx_memoryview_get_slice_from_memoryview(struct __pyx_memoryview_obj *__pyx_v_memview, __Pyx_memviewslice *__pyx_v_mslice) {
- struct __pyx_memoryviewslice_obj *__pyx_v_obj = 0;
- __Pyx_memviewslice *__pyx_r;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- PyObject *__pyx_t_3 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("get_slice_from_memview", 0);
-
- /* "View.MemoryView":1055
- * __Pyx_memviewslice *mslice) except NULL:
- * cdef _memoryviewslice obj
- * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<<
- * obj = memview
- * return &obj.from_slice
- */
- __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type);
- __pyx_t_2 = (__pyx_t_1 != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":1056
- * cdef _memoryviewslice obj
- * if isinstance(memview, _memoryviewslice):
- * obj = memview # <<<<<<<<<<<<<<
- * return &obj.from_slice
- * else:
- */
- if (!(likely(((((PyObject *)__pyx_v_memview)) == Py_None) || likely(__Pyx_TypeTest(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type))))) __PYX_ERR(1, 1056, __pyx_L1_error)
- __pyx_t_3 = ((PyObject *)__pyx_v_memview);
- __Pyx_INCREF(__pyx_t_3);
- __pyx_v_obj = ((struct __pyx_memoryviewslice_obj *)__pyx_t_3);
- __pyx_t_3 = 0;
-
- /* "View.MemoryView":1057
- * if isinstance(memview, _memoryviewslice):
- * obj = memview
- * return &obj.from_slice # <<<<<<<<<<<<<<
- * else:
- * slice_copy(memview, mslice)
- */
- __pyx_r = (&__pyx_v_obj->from_slice);
- goto __pyx_L0;
-
- /* "View.MemoryView":1055
- * __Pyx_memviewslice *mslice) except NULL:
- * cdef _memoryviewslice obj
- * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<<
- * obj = memview
- * return &obj.from_slice
- */
- }
-
- /* "View.MemoryView":1059
- * return &obj.from_slice
- * else:
- * slice_copy(memview, mslice) # <<<<<<<<<<<<<<
- * return mslice
- *
- */
- /*else*/ {
- __pyx_memoryview_slice_copy(__pyx_v_memview, __pyx_v_mslice);
-
- /* "View.MemoryView":1060
- * else:
- * slice_copy(memview, mslice)
- * return mslice # <<<<<<<<<<<<<<
- *
- * @cname('__pyx_memoryview_slice_copy')
- */
- __pyx_r = __pyx_v_mslice;
- goto __pyx_L0;
- }
-
- /* "View.MemoryView":1052
- *
- * @cname('__pyx_memoryview_get_slice_from_memoryview')
- * cdef __Pyx_memviewslice *get_slice_from_memview(memoryview memview, # <<<<<<<<<<<<<<
- * __Pyx_memviewslice *mslice) except NULL:
- * cdef _memoryviewslice obj
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_AddTraceback("View.MemoryView.get_slice_from_memview", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF((PyObject *)__pyx_v_obj);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":1063
- *
- * @cname('__pyx_memoryview_slice_copy')
- * cdef void slice_copy(memoryview memview, __Pyx_memviewslice *dst): # <<<<<<<<<<<<<<
- * cdef int dim
- * cdef (Py_ssize_t*) shape, strides, suboffsets
- */
-
-static void __pyx_memoryview_slice_copy(struct __pyx_memoryview_obj *__pyx_v_memview, __Pyx_memviewslice *__pyx_v_dst) {
- int __pyx_v_dim;
- Py_ssize_t *__pyx_v_shape;
- Py_ssize_t *__pyx_v_strides;
- Py_ssize_t *__pyx_v_suboffsets;
- __Pyx_RefNannyDeclarations
- Py_ssize_t *__pyx_t_1;
- int __pyx_t_2;
- int __pyx_t_3;
- int __pyx_t_4;
- Py_ssize_t __pyx_t_5;
- __Pyx_RefNannySetupContext("slice_copy", 0);
-
- /* "View.MemoryView":1067
- * cdef (Py_ssize_t*) shape, strides, suboffsets
- *
- * shape = memview.view.shape # <<<<<<<<<<<<<<
- * strides = memview.view.strides
- * suboffsets = memview.view.suboffsets
- */
- __pyx_t_1 = __pyx_v_memview->view.shape;
- __pyx_v_shape = __pyx_t_1;
-
- /* "View.MemoryView":1068
- *
- * shape = memview.view.shape
- * strides = memview.view.strides # <<<<<<<<<<<<<<
- * suboffsets = memview.view.suboffsets
- *
- */
- __pyx_t_1 = __pyx_v_memview->view.strides;
- __pyx_v_strides = __pyx_t_1;
-
- /* "View.MemoryView":1069
- * shape = memview.view.shape
- * strides = memview.view.strides
- * suboffsets = memview.view.suboffsets # <<<<<<<<<<<<<<
- *
- * dst.memview = <__pyx_memoryview *> memview
- */
- __pyx_t_1 = __pyx_v_memview->view.suboffsets;
- __pyx_v_suboffsets = __pyx_t_1;
-
- /* "View.MemoryView":1071
- * suboffsets = memview.view.suboffsets
- *
- * dst.memview = <__pyx_memoryview *> memview # <<<<<<<<<<<<<<
- * dst.data = memview.view.buf
- *
- */
- __pyx_v_dst->memview = ((struct __pyx_memoryview_obj *)__pyx_v_memview);
-
- /* "View.MemoryView":1072
- *
- * dst.memview = <__pyx_memoryview *> memview
- * dst.data = memview.view.buf # <<<<<<<<<<<<<<
- *
- * for dim in range(memview.view.ndim):
- */
- __pyx_v_dst->data = ((char *)__pyx_v_memview->view.buf);
-
- /* "View.MemoryView":1074
- * dst.data = memview.view.buf
- *
- * for dim in range(memview.view.ndim): # <<<<<<<<<<<<<<
- * dst.shape[dim] = shape[dim]
- * dst.strides[dim] = strides[dim]
- */
- __pyx_t_2 = __pyx_v_memview->view.ndim;
- __pyx_t_3 = __pyx_t_2;
- for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
- __pyx_v_dim = __pyx_t_4;
-
- /* "View.MemoryView":1075
- *
- * for dim in range(memview.view.ndim):
- * dst.shape[dim] = shape[dim] # <<<<<<<<<<<<<<
- * dst.strides[dim] = strides[dim]
- * dst.suboffsets[dim] = suboffsets[dim] if suboffsets else -1
- */
- (__pyx_v_dst->shape[__pyx_v_dim]) = (__pyx_v_shape[__pyx_v_dim]);
-
- /* "View.MemoryView":1076
- * for dim in range(memview.view.ndim):
- * dst.shape[dim] = shape[dim]
- * dst.strides[dim] = strides[dim] # <<<<<<<<<<<<<<
- * dst.suboffsets[dim] = suboffsets[dim] if suboffsets else -1
- *
- */
- (__pyx_v_dst->strides[__pyx_v_dim]) = (__pyx_v_strides[__pyx_v_dim]);
-
- /* "View.MemoryView":1077
- * dst.shape[dim] = shape[dim]
- * dst.strides[dim] = strides[dim]
- * dst.suboffsets[dim] = suboffsets[dim] if suboffsets else -1 # <<<<<<<<<<<<<<
- *
- * @cname('__pyx_memoryview_copy_object')
- */
- if ((__pyx_v_suboffsets != 0)) {
- __pyx_t_5 = (__pyx_v_suboffsets[__pyx_v_dim]);
- } else {
- __pyx_t_5 = -1L;
- }
- (__pyx_v_dst->suboffsets[__pyx_v_dim]) = __pyx_t_5;
- }
-
- /* "View.MemoryView":1063
- *
- * @cname('__pyx_memoryview_slice_copy')
- * cdef void slice_copy(memoryview memview, __Pyx_memviewslice *dst): # <<<<<<<<<<<<<<
- * cdef int dim
- * cdef (Py_ssize_t*) shape, strides, suboffsets
- */
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
-}
-
-/* "View.MemoryView":1080
- *
- * @cname('__pyx_memoryview_copy_object')
- * cdef memoryview_copy(memoryview memview): # <<<<<<<<<<<<<<
- * "Create a new memoryview object"
- * cdef __Pyx_memviewslice memviewslice
- */
-
-static PyObject *__pyx_memoryview_copy_object(struct __pyx_memoryview_obj *__pyx_v_memview) {
- __Pyx_memviewslice __pyx_v_memviewslice;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("memoryview_copy", 0);
-
- /* "View.MemoryView":1083
- * "Create a new memoryview object"
- * cdef __Pyx_memviewslice memviewslice
- * slice_copy(memview, &memviewslice) # <<<<<<<<<<<<<<
- * return memoryview_copy_from_slice(memview, &memviewslice)
- *
- */
- __pyx_memoryview_slice_copy(__pyx_v_memview, (&__pyx_v_memviewslice));
-
- /* "View.MemoryView":1084
- * cdef __Pyx_memviewslice memviewslice
- * slice_copy(memview, &memviewslice)
- * return memoryview_copy_from_slice(memview, &memviewslice) # <<<<<<<<<<<<<<
- *
- * @cname('__pyx_memoryview_copy_object_from_slice')
- */
- __Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __pyx_memoryview_copy_object_from_slice(__pyx_v_memview, (&__pyx_v_memviewslice)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1084, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_r = __pyx_t_1;
- __pyx_t_1 = 0;
- goto __pyx_L0;
-
- /* "View.MemoryView":1080
- *
- * @cname('__pyx_memoryview_copy_object')
- * cdef memoryview_copy(memoryview memview): # <<<<<<<<<<<<<<
- * "Create a new memoryview object"
- * cdef __Pyx_memviewslice memviewslice
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_AddTraceback("View.MemoryView.memoryview_copy", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":1087
- *
- * @cname('__pyx_memoryview_copy_object_from_slice')
- * cdef memoryview_copy_from_slice(memoryview memview, __Pyx_memviewslice *memviewslice): # <<<<<<<<<<<<<<
- * """
- * Create a new memoryview object from a given memoryview object and slice.
- */
-
-static PyObject *__pyx_memoryview_copy_object_from_slice(struct __pyx_memoryview_obj *__pyx_v_memview, __Pyx_memviewslice *__pyx_v_memviewslice) {
- PyObject *(*__pyx_v_to_object_func)(char *);
- int (*__pyx_v_to_dtype_func)(char *, PyObject *);
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- int __pyx_t_2;
- PyObject *(*__pyx_t_3)(char *);
- int (*__pyx_t_4)(char *, PyObject *);
- PyObject *__pyx_t_5 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("memoryview_copy_from_slice", 0);
-
- /* "View.MemoryView":1094
- * cdef int (*to_dtype_func)(char *, object) except 0
- *
- * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<<
- * to_object_func = (<_memoryviewslice> memview).to_object_func
- * to_dtype_func = (<_memoryviewslice> memview).to_dtype_func
- */
- __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type);
- __pyx_t_2 = (__pyx_t_1 != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":1095
- *
- * if isinstance(memview, _memoryviewslice):
- * to_object_func = (<_memoryviewslice> memview).to_object_func # <<<<<<<<<<<<<<
- * to_dtype_func = (<_memoryviewslice> memview).to_dtype_func
- * else:
- */
- __pyx_t_3 = ((struct __pyx_memoryviewslice_obj *)__pyx_v_memview)->to_object_func;
- __pyx_v_to_object_func = __pyx_t_3;
-
- /* "View.MemoryView":1096
- * if isinstance(memview, _memoryviewslice):
- * to_object_func = (<_memoryviewslice> memview).to_object_func
- * to_dtype_func = (<_memoryviewslice> memview).to_dtype_func # <<<<<<<<<<<<<<
- * else:
- * to_object_func = NULL
- */
- __pyx_t_4 = ((struct __pyx_memoryviewslice_obj *)__pyx_v_memview)->to_dtype_func;
- __pyx_v_to_dtype_func = __pyx_t_4;
-
- /* "View.MemoryView":1094
- * cdef int (*to_dtype_func)(char *, object) except 0
- *
- * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<<
- * to_object_func = (<_memoryviewslice> memview).to_object_func
- * to_dtype_func = (<_memoryviewslice> memview).to_dtype_func
- */
- goto __pyx_L3;
- }
-
- /* "View.MemoryView":1098
- * to_dtype_func = (<_memoryviewslice> memview).to_dtype_func
- * else:
- * to_object_func = NULL # <<<<<<<<<<<<<<
- * to_dtype_func = NULL
- *
- */
- /*else*/ {
- __pyx_v_to_object_func = NULL;
-
- /* "View.MemoryView":1099
- * else:
- * to_object_func = NULL
- * to_dtype_func = NULL # <<<<<<<<<<<<<<
- *
- * return memoryview_fromslice(memviewslice[0], memview.view.ndim,
- */
- __pyx_v_to_dtype_func = NULL;
- }
- __pyx_L3:;
-
- /* "View.MemoryView":1101
- * to_dtype_func = NULL
- *
- * return memoryview_fromslice(memviewslice[0], memview.view.ndim, # <<<<<<<<<<<<<<
- * to_object_func, to_dtype_func,
- * memview.dtype_is_object)
- */
- __Pyx_XDECREF(__pyx_r);
-
- /* "View.MemoryView":1103
- * return memoryview_fromslice(memviewslice[0], memview.view.ndim,
- * to_object_func, to_dtype_func,
- * memview.dtype_is_object) # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_5 = __pyx_memoryview_fromslice((__pyx_v_memviewslice[0]), __pyx_v_memview->view.ndim, __pyx_v_to_object_func, __pyx_v_to_dtype_func, __pyx_v_memview->dtype_is_object); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 1101, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_5);
- __pyx_r = __pyx_t_5;
- __pyx_t_5 = 0;
- goto __pyx_L0;
-
- /* "View.MemoryView":1087
- *
- * @cname('__pyx_memoryview_copy_object_from_slice')
- * cdef memoryview_copy_from_slice(memoryview memview, __Pyx_memviewslice *memviewslice): # <<<<<<<<<<<<<<
- * """
- * Create a new memoryview object from a given memoryview object and slice.
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("View.MemoryView.memoryview_copy_from_slice", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "View.MemoryView":1109
- *
- *
- * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil: # <<<<<<<<<<<<<<
- * if arg < 0:
- * return -arg
- */
-
-static Py_ssize_t abs_py_ssize_t(Py_ssize_t __pyx_v_arg) {
- Py_ssize_t __pyx_r;
- int __pyx_t_1;
-
- /* "View.MemoryView":1110
- *
- * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil:
- * if arg < 0: # <<<<<<<<<<<<<<
- * return -arg
- * else:
- */
- __pyx_t_1 = ((__pyx_v_arg < 0) != 0);
- if (__pyx_t_1) {
-
- /* "View.MemoryView":1111
- * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil:
- * if arg < 0:
- * return -arg # <<<<<<<<<<<<<<
- * else:
- * return arg
- */
- __pyx_r = (-__pyx_v_arg);
- goto __pyx_L0;
-
- /* "View.MemoryView":1110
- *
- * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil:
- * if arg < 0: # <<<<<<<<<<<<<<
- * return -arg
- * else:
- */
- }
-
- /* "View.MemoryView":1113
- * return -arg
- * else:
- * return arg # <<<<<<<<<<<<<<
- *
- * @cname('__pyx_get_best_slice_order')
- */
- /*else*/ {
- __pyx_r = __pyx_v_arg;
- goto __pyx_L0;
- }
-
- /* "View.MemoryView":1109
- *
- *
- * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil: # <<<<<<<<<<<<<<
- * if arg < 0:
- * return -arg
- */
-
- /* function exit code */
- __pyx_L0:;
- return __pyx_r;
-}
-
-/* "View.MemoryView":1116
- *
- * @cname('__pyx_get_best_slice_order')
- * cdef char get_best_order(__Pyx_memviewslice *mslice, int ndim) nogil: # <<<<<<<<<<<<<<
- * """
- * Figure out the best memory access order for a given slice.
- */
-
-static char __pyx_get_best_slice_order(__Pyx_memviewslice *__pyx_v_mslice, int __pyx_v_ndim) {
- int __pyx_v_i;
- Py_ssize_t __pyx_v_c_stride;
- Py_ssize_t __pyx_v_f_stride;
- char __pyx_r;
- int __pyx_t_1;
- int __pyx_t_2;
- int __pyx_t_3;
- int __pyx_t_4;
-
- /* "View.MemoryView":1121
- * """
- * cdef int i
- * cdef Py_ssize_t c_stride = 0 # <<<<<<<<<<<<<<
- * cdef Py_ssize_t f_stride = 0
- *
- */
- __pyx_v_c_stride = 0;
-
- /* "View.MemoryView":1122
- * cdef int i
- * cdef Py_ssize_t c_stride = 0
- * cdef Py_ssize_t f_stride = 0 # <<<<<<<<<<<<<<
- *
- * for i in range(ndim - 1, -1, -1):
- */
- __pyx_v_f_stride = 0;
-
- /* "View.MemoryView":1124
- * cdef Py_ssize_t f_stride = 0
- *
- * for i in range(ndim - 1, -1, -1): # <<<<<<<<<<<<<<
- * if mslice.shape[i] > 1:
- * c_stride = mslice.strides[i]
- */
- for (__pyx_t_1 = (__pyx_v_ndim - 1); __pyx_t_1 > -1; __pyx_t_1-=1) {
- __pyx_v_i = __pyx_t_1;
-
- /* "View.MemoryView":1125
- *
- * for i in range(ndim - 1, -1, -1):
- * if mslice.shape[i] > 1: # <<<<<<<<<<<<<<
- * c_stride = mslice.strides[i]
- * break
- */
- __pyx_t_2 = (((__pyx_v_mslice->shape[__pyx_v_i]) > 1) != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":1126
- * for i in range(ndim - 1, -1, -1):
- * if mslice.shape[i] > 1:
- * c_stride = mslice.strides[i] # <<<<<<<<<<<<<<
- * break
- *
- */
- __pyx_v_c_stride = (__pyx_v_mslice->strides[__pyx_v_i]);
-
- /* "View.MemoryView":1127
- * if mslice.shape[i] > 1:
- * c_stride = mslice.strides[i]
- * break # <<<<<<<<<<<<<<
- *
- * for i in range(ndim):
- */
- goto __pyx_L4_break;
-
- /* "View.MemoryView":1125
- *
- * for i in range(ndim - 1, -1, -1):
- * if mslice.shape[i] > 1: # <<<<<<<<<<<<<<
- * c_stride = mslice.strides[i]
- * break
- */
- }
- }
- __pyx_L4_break:;
-
- /* "View.MemoryView":1129
- * break
- *
- * for i in range(ndim): # <<<<<<<<<<<<<<
- * if mslice.shape[i] > 1:
- * f_stride = mslice.strides[i]
- */
- __pyx_t_1 = __pyx_v_ndim;
- __pyx_t_3 = __pyx_t_1;
- for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
- __pyx_v_i = __pyx_t_4;
-
- /* "View.MemoryView":1130
- *
- * for i in range(ndim):
- * if mslice.shape[i] > 1: # <<<<<<<<<<<<<<
- * f_stride = mslice.strides[i]
- * break
- */
- __pyx_t_2 = (((__pyx_v_mslice->shape[__pyx_v_i]) > 1) != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":1131
- * for i in range(ndim):
- * if mslice.shape[i] > 1:
- * f_stride = mslice.strides[i] # <<<<<<<<<<<<<<
- * break
- *
- */
- __pyx_v_f_stride = (__pyx_v_mslice->strides[__pyx_v_i]);
-
- /* "View.MemoryView":1132
- * if mslice.shape[i] > 1:
- * f_stride = mslice.strides[i]
- * break # <<<<<<<<<<<<<<
- *
- * if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride):
- */
- goto __pyx_L7_break;
-
- /* "View.MemoryView":1130
- *
- * for i in range(ndim):
- * if mslice.shape[i] > 1: # <<<<<<<<<<<<<<
- * f_stride = mslice.strides[i]
- * break
- */
- }
- }
- __pyx_L7_break:;
-
- /* "View.MemoryView":1134
- * break
- *
- * if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride): # <<<<<<<<<<<<<<
- * return 'C'
- * else:
- */
- __pyx_t_2 = ((abs_py_ssize_t(__pyx_v_c_stride) <= abs_py_ssize_t(__pyx_v_f_stride)) != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":1135
- *
- * if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride):
- * return 'C' # <<<<<<<<<<<<<<
- * else:
- * return 'F'
- */
- __pyx_r = 'C';
- goto __pyx_L0;
-
- /* "View.MemoryView":1134
- * break
- *
- * if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride): # <<<<<<<<<<<<<<
- * return 'C'
- * else:
- */
- }
-
- /* "View.MemoryView":1137
- * return 'C'
- * else:
- * return 'F' # <<<<<<<<<<<<<<
- *
- * @cython.cdivision(True)
- */
- /*else*/ {
- __pyx_r = 'F';
- goto __pyx_L0;
- }
-
- /* "View.MemoryView":1116
- *
- * @cname('__pyx_get_best_slice_order')
- * cdef char get_best_order(__Pyx_memviewslice *mslice, int ndim) nogil: # <<<<<<<<<<<<<<
- * """
- * Figure out the best memory access order for a given slice.
- */
-
- /* function exit code */
- __pyx_L0:;
- return __pyx_r;
-}
-
-/* "View.MemoryView":1140
- *
- * @cython.cdivision(True)
- * cdef void _copy_strided_to_strided(char *src_data, Py_ssize_t *src_strides, # <<<<<<<<<<<<<<
- * char *dst_data, Py_ssize_t *dst_strides,
- * Py_ssize_t *src_shape, Py_ssize_t *dst_shape,
- */
-
-static void _copy_strided_to_strided(char *__pyx_v_src_data, Py_ssize_t *__pyx_v_src_strides, char *__pyx_v_dst_data, Py_ssize_t *__pyx_v_dst_strides, Py_ssize_t *__pyx_v_src_shape, Py_ssize_t *__pyx_v_dst_shape, int __pyx_v_ndim, size_t __pyx_v_itemsize) {
- CYTHON_UNUSED Py_ssize_t __pyx_v_i;
- CYTHON_UNUSED Py_ssize_t __pyx_v_src_extent;
- Py_ssize_t __pyx_v_dst_extent;
- Py_ssize_t __pyx_v_src_stride;
- Py_ssize_t __pyx_v_dst_stride;
- int __pyx_t_1;
- int __pyx_t_2;
- int __pyx_t_3;
- Py_ssize_t __pyx_t_4;
- Py_ssize_t __pyx_t_5;
- Py_ssize_t __pyx_t_6;
-
- /* "View.MemoryView":1147
- *
- * cdef Py_ssize_t i
- * cdef Py_ssize_t src_extent = src_shape[0] # <<<<<<<<<<<<<<
- * cdef Py_ssize_t dst_extent = dst_shape[0]
- * cdef Py_ssize_t src_stride = src_strides[0]
- */
- __pyx_v_src_extent = (__pyx_v_src_shape[0]);
-
- /* "View.MemoryView":1148
- * cdef Py_ssize_t i
- * cdef Py_ssize_t src_extent = src_shape[0]
- * cdef Py_ssize_t dst_extent = dst_shape[0] # <<<<<<<<<<<<<<
- * cdef Py_ssize_t src_stride = src_strides[0]
- * cdef Py_ssize_t dst_stride = dst_strides[0]
- */
- __pyx_v_dst_extent = (__pyx_v_dst_shape[0]);
-
- /* "View.MemoryView":1149
- * cdef Py_ssize_t src_extent = src_shape[0]
- * cdef Py_ssize_t dst_extent = dst_shape[0]
- * cdef Py_ssize_t src_stride = src_strides[0] # <<<<<<<<<<<<<<
- * cdef Py_ssize_t dst_stride = dst_strides[0]
- *
- */
- __pyx_v_src_stride = (__pyx_v_src_strides[0]);
-
- /* "View.MemoryView":1150
- * cdef Py_ssize_t dst_extent = dst_shape[0]
- * cdef Py_ssize_t src_stride = src_strides[0]
- * cdef Py_ssize_t dst_stride = dst_strides[0] # <<<<<<<<<<<<<<
- *
- * if ndim == 1:
- */
- __pyx_v_dst_stride = (__pyx_v_dst_strides[0]);
-
- /* "View.MemoryView":1152
- * cdef Py_ssize_t dst_stride = dst_strides[0]
- *
- * if ndim == 1: # <<<<<<<<<<<<<<
- * if (src_stride > 0 and dst_stride > 0 and
- * src_stride == itemsize == dst_stride):
- */
- __pyx_t_1 = ((__pyx_v_ndim == 1) != 0);
- if (__pyx_t_1) {
-
- /* "View.MemoryView":1153
- *
- * if ndim == 1:
- * if (src_stride > 0 and dst_stride > 0 and # <<<<<<<<<<<<<<
- * src_stride == itemsize == dst_stride):
- * memcpy(dst_data, src_data, itemsize * dst_extent)
- */
- __pyx_t_2 = ((__pyx_v_src_stride > 0) != 0);
- if (__pyx_t_2) {
- } else {
- __pyx_t_1 = __pyx_t_2;
- goto __pyx_L5_bool_binop_done;
- }
- __pyx_t_2 = ((__pyx_v_dst_stride > 0) != 0);
- if (__pyx_t_2) {
- } else {
- __pyx_t_1 = __pyx_t_2;
- goto __pyx_L5_bool_binop_done;
- }
-
- /* "View.MemoryView":1154
- * if ndim == 1:
- * if (src_stride > 0 and dst_stride > 0 and
- * src_stride == itemsize == dst_stride): # <<<<<<<<<<<<<<
- * memcpy(dst_data, src_data, itemsize * dst_extent)
- * else:
- */
- __pyx_t_2 = (((size_t)__pyx_v_src_stride) == __pyx_v_itemsize);
- if (__pyx_t_2) {
- __pyx_t_2 = (__pyx_v_itemsize == ((size_t)__pyx_v_dst_stride));
- }
- __pyx_t_3 = (__pyx_t_2 != 0);
- __pyx_t_1 = __pyx_t_3;
- __pyx_L5_bool_binop_done:;
-
- /* "View.MemoryView":1153
- *
- * if ndim == 1:
- * if (src_stride > 0 and dst_stride > 0 and # <<<<<<<<<<<<<<
- * src_stride == itemsize == dst_stride):
- * memcpy(dst_data, src_data, itemsize * dst_extent)
- */
- if (__pyx_t_1) {
-
- /* "View.MemoryView":1155
- * if (src_stride > 0 and dst_stride > 0 and
- * src_stride == itemsize == dst_stride):
- * memcpy(dst_data, src_data, itemsize * dst_extent) # <<<<<<<<<<<<<<
- * else:
- * for i in range(dst_extent):
- */
- (void)(memcpy(__pyx_v_dst_data, __pyx_v_src_data, (__pyx_v_itemsize * __pyx_v_dst_extent)));
-
- /* "View.MemoryView":1153
- *
- * if ndim == 1:
- * if (src_stride > 0 and dst_stride > 0 and # <<<<<<<<<<<<<<
- * src_stride == itemsize == dst_stride):
- * memcpy(dst_data, src_data, itemsize * dst_extent)
- */
- goto __pyx_L4;
- }
-
- /* "View.MemoryView":1157
- * memcpy(dst_data, src_data, itemsize * dst_extent)
- * else:
- * for i in range(dst_extent): # <<<<<<<<<<<<<<
- * memcpy(dst_data, src_data, itemsize)
- * src_data += src_stride
- */
- /*else*/ {
- __pyx_t_4 = __pyx_v_dst_extent;
- __pyx_t_5 = __pyx_t_4;
- for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
- __pyx_v_i = __pyx_t_6;
-
- /* "View.MemoryView":1158
- * else:
- * for i in range(dst_extent):
- * memcpy(dst_data, src_data, itemsize) # <<<<<<<<<<<<<<
- * src_data += src_stride
- * dst_data += dst_stride
- */
- (void)(memcpy(__pyx_v_dst_data, __pyx_v_src_data, __pyx_v_itemsize));
-
- /* "View.MemoryView":1159
- * for i in range(dst_extent):
- * memcpy(dst_data, src_data, itemsize)
- * src_data += src_stride # <<<<<<<<<<<<<<
- * dst_data += dst_stride
- * else:
- */
- __pyx_v_src_data = (__pyx_v_src_data + __pyx_v_src_stride);
-
- /* "View.MemoryView":1160
- * memcpy(dst_data, src_data, itemsize)
- * src_data += src_stride
- * dst_data += dst_stride # <<<<<<<<<<<<<<
- * else:
- * for i in range(dst_extent):
- */
- __pyx_v_dst_data = (__pyx_v_dst_data + __pyx_v_dst_stride);
- }
- }
- __pyx_L4:;
-
- /* "View.MemoryView":1152
- * cdef Py_ssize_t dst_stride = dst_strides[0]
- *
- * if ndim == 1: # <<<<<<<<<<<<<<
- * if (src_stride > 0 and dst_stride > 0 and
- * src_stride == itemsize == dst_stride):
- */
- goto __pyx_L3;
- }
-
- /* "View.MemoryView":1162
- * dst_data += dst_stride
- * else:
- * for i in range(dst_extent): # <<<<<<<<<<<<<<
- * _copy_strided_to_strided(src_data, src_strides + 1,
- * dst_data, dst_strides + 1,
- */
- /*else*/ {
- __pyx_t_4 = __pyx_v_dst_extent;
- __pyx_t_5 = __pyx_t_4;
- for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
- __pyx_v_i = __pyx_t_6;
-
- /* "View.MemoryView":1163
- * else:
- * for i in range(dst_extent):
- * _copy_strided_to_strided(src_data, src_strides + 1, # <<<<<<<<<<<<<<
- * dst_data, dst_strides + 1,
- * src_shape + 1, dst_shape + 1,
- */
- _copy_strided_to_strided(__pyx_v_src_data, (__pyx_v_src_strides + 1), __pyx_v_dst_data, (__pyx_v_dst_strides + 1), (__pyx_v_src_shape + 1), (__pyx_v_dst_shape + 1), (__pyx_v_ndim - 1), __pyx_v_itemsize);
-
- /* "View.MemoryView":1167
- * src_shape + 1, dst_shape + 1,
- * ndim - 1, itemsize)
- * src_data += src_stride # <<<<<<<<<<<<<<
- * dst_data += dst_stride
- *
- */
- __pyx_v_src_data = (__pyx_v_src_data + __pyx_v_src_stride);
-
- /* "View.MemoryView":1168
- * ndim - 1, itemsize)
- * src_data += src_stride
- * dst_data += dst_stride # <<<<<<<<<<<<<<
- *
- * cdef void copy_strided_to_strided(__Pyx_memviewslice *src,
- */
- __pyx_v_dst_data = (__pyx_v_dst_data + __pyx_v_dst_stride);
- }
- }
- __pyx_L3:;
-
- /* "View.MemoryView":1140
- *
- * @cython.cdivision(True)
- * cdef void _copy_strided_to_strided(char *src_data, Py_ssize_t *src_strides, # <<<<<<<<<<<<<<
- * char *dst_data, Py_ssize_t *dst_strides,
- * Py_ssize_t *src_shape, Py_ssize_t *dst_shape,
- */
-
- /* function exit code */
-}
-
-/* "View.MemoryView":1170
- * dst_data += dst_stride
- *
- * cdef void copy_strided_to_strided(__Pyx_memviewslice *src, # <<<<<<<<<<<<<<
- * __Pyx_memviewslice *dst,
- * int ndim, size_t itemsize) nogil:
- */
-
-static void copy_strided_to_strided(__Pyx_memviewslice *__pyx_v_src, __Pyx_memviewslice *__pyx_v_dst, int __pyx_v_ndim, size_t __pyx_v_itemsize) {
-
- /* "View.MemoryView":1173
- * __Pyx_memviewslice *dst,
- * int ndim, size_t itemsize) nogil:
- * _copy_strided_to_strided(src.data, src.strides, dst.data, dst.strides, # <<<<<<<<<<<<<<
- * src.shape, dst.shape, ndim, itemsize)
- *
- */
- _copy_strided_to_strided(__pyx_v_src->data, __pyx_v_src->strides, __pyx_v_dst->data, __pyx_v_dst->strides, __pyx_v_src->shape, __pyx_v_dst->shape, __pyx_v_ndim, __pyx_v_itemsize);
-
- /* "View.MemoryView":1170
- * dst_data += dst_stride
- *
- * cdef void copy_strided_to_strided(__Pyx_memviewslice *src, # <<<<<<<<<<<<<<
- * __Pyx_memviewslice *dst,
- * int ndim, size_t itemsize) nogil:
- */
-
- /* function exit code */
-}
-
-/* "View.MemoryView":1177
- *
- * @cname('__pyx_memoryview_slice_get_size')
- * cdef Py_ssize_t slice_get_size(__Pyx_memviewslice *src, int ndim) nogil: # <<<<<<<<<<<<<<
- * "Return the size of the memory occupied by the slice in number of bytes"
- * cdef Py_ssize_t shape, size = src.memview.view.itemsize
- */
-
-static Py_ssize_t __pyx_memoryview_slice_get_size(__Pyx_memviewslice *__pyx_v_src, int __pyx_v_ndim) {
- Py_ssize_t __pyx_v_shape;
- Py_ssize_t __pyx_v_size;
- Py_ssize_t __pyx_r;
- Py_ssize_t __pyx_t_1;
- Py_ssize_t *__pyx_t_2;
- Py_ssize_t *__pyx_t_3;
- Py_ssize_t *__pyx_t_4;
-
- /* "View.MemoryView":1179
- * cdef Py_ssize_t slice_get_size(__Pyx_memviewslice *src, int ndim) nogil:
- * "Return the size of the memory occupied by the slice in number of bytes"
- * cdef Py_ssize_t shape, size = src.memview.view.itemsize # <<<<<<<<<<<<<<
- *
- * for shape in src.shape[:ndim]:
- */
- __pyx_t_1 = __pyx_v_src->memview->view.itemsize;
- __pyx_v_size = __pyx_t_1;
-
- /* "View.MemoryView":1181
- * cdef Py_ssize_t shape, size = src.memview.view.itemsize
- *
- * for shape in src.shape[:ndim]: # <<<<<<<<<<<<<<
- * size *= shape
- *
- */
- __pyx_t_3 = (__pyx_v_src->shape + __pyx_v_ndim);
- for (__pyx_t_4 = __pyx_v_src->shape; __pyx_t_4 < __pyx_t_3; __pyx_t_4++) {
- __pyx_t_2 = __pyx_t_4;
- __pyx_v_shape = (__pyx_t_2[0]);
-
- /* "View.MemoryView":1182
- *
- * for shape in src.shape[:ndim]:
- * size *= shape # <<<<<<<<<<<<<<
- *
- * return size
- */
- __pyx_v_size = (__pyx_v_size * __pyx_v_shape);
- }
-
- /* "View.MemoryView":1184
- * size *= shape
- *
- * return size # <<<<<<<<<<<<<<
- *
- * @cname('__pyx_fill_contig_strides_array')
- */
- __pyx_r = __pyx_v_size;
- goto __pyx_L0;
-
- /* "View.MemoryView":1177
- *
- * @cname('__pyx_memoryview_slice_get_size')
- * cdef Py_ssize_t slice_get_size(__Pyx_memviewslice *src, int ndim) nogil: # <<<<<<<<<<<<<<
- * "Return the size of the memory occupied by the slice in number of bytes"
- * cdef Py_ssize_t shape, size = src.memview.view.itemsize
- */
-
- /* function exit code */
- __pyx_L0:;
- return __pyx_r;
-}
-
-/* "View.MemoryView":1187
- *
- * @cname('__pyx_fill_contig_strides_array')
- * cdef Py_ssize_t fill_contig_strides_array( # <<<<<<<<<<<<<<
- * Py_ssize_t *shape, Py_ssize_t *strides, Py_ssize_t stride,
- * int ndim, char order) nogil:
- */
-
-static Py_ssize_t __pyx_fill_contig_strides_array(Py_ssize_t *__pyx_v_shape, Py_ssize_t *__pyx_v_strides, Py_ssize_t __pyx_v_stride, int __pyx_v_ndim, char __pyx_v_order) {
- int __pyx_v_idx;
- Py_ssize_t __pyx_r;
- int __pyx_t_1;
- int __pyx_t_2;
- int __pyx_t_3;
- int __pyx_t_4;
-
- /* "View.MemoryView":1196
- * cdef int idx
- *
- * if order == 'F': # <<<<<<<<<<<<<<
- * for idx in range(ndim):
- * strides[idx] = stride
- */
- __pyx_t_1 = ((__pyx_v_order == 'F') != 0);
- if (__pyx_t_1) {
-
- /* "View.MemoryView":1197
- *
- * if order == 'F':
- * for idx in range(ndim): # <<<<<<<<<<<<<<
- * strides[idx] = stride
- * stride *= shape[idx]
- */
- __pyx_t_2 = __pyx_v_ndim;
- __pyx_t_3 = __pyx_t_2;
- for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
- __pyx_v_idx = __pyx_t_4;
-
- /* "View.MemoryView":1198
- * if order == 'F':
- * for idx in range(ndim):
- * strides[idx] = stride # <<<<<<<<<<<<<<
- * stride *= shape[idx]
- * else:
- */
- (__pyx_v_strides[__pyx_v_idx]) = __pyx_v_stride;
-
- /* "View.MemoryView":1199
- * for idx in range(ndim):
- * strides[idx] = stride
- * stride *= shape[idx] # <<<<<<<<<<<<<<
- * else:
- * for idx in range(ndim - 1, -1, -1):
- */
- __pyx_v_stride = (__pyx_v_stride * (__pyx_v_shape[__pyx_v_idx]));
- }
-
- /* "View.MemoryView":1196
- * cdef int idx
- *
- * if order == 'F': # <<<<<<<<<<<<<<
- * for idx in range(ndim):
- * strides[idx] = stride
- */
- goto __pyx_L3;
- }
-
- /* "View.MemoryView":1201
- * stride *= shape[idx]
- * else:
- * for idx in range(ndim - 1, -1, -1): # <<<<<<<<<<<<<<
- * strides[idx] = stride
- * stride *= shape[idx]
- */
- /*else*/ {
- for (__pyx_t_2 = (__pyx_v_ndim - 1); __pyx_t_2 > -1; __pyx_t_2-=1) {
- __pyx_v_idx = __pyx_t_2;
-
- /* "View.MemoryView":1202
- * else:
- * for idx in range(ndim - 1, -1, -1):
- * strides[idx] = stride # <<<<<<<<<<<<<<
- * stride *= shape[idx]
- *
- */
- (__pyx_v_strides[__pyx_v_idx]) = __pyx_v_stride;
-
- /* "View.MemoryView":1203
- * for idx in range(ndim - 1, -1, -1):
- * strides[idx] = stride
- * stride *= shape[idx] # <<<<<<<<<<<<<<
- *
- * return stride
- */
- __pyx_v_stride = (__pyx_v_stride * (__pyx_v_shape[__pyx_v_idx]));
- }
- }
- __pyx_L3:;
-
- /* "View.MemoryView":1205
- * stride *= shape[idx]
- *
- * return stride # <<<<<<<<<<<<<<
- *
- * @cname('__pyx_memoryview_copy_data_to_temp')
- */
- __pyx_r = __pyx_v_stride;
- goto __pyx_L0;
-
- /* "View.MemoryView":1187
- *
- * @cname('__pyx_fill_contig_strides_array')
- * cdef Py_ssize_t fill_contig_strides_array( # <<<<<<<<<<<<<<
- * Py_ssize_t *shape, Py_ssize_t *strides, Py_ssize_t stride,
- * int ndim, char order) nogil:
- */
-
- /* function exit code */
- __pyx_L0:;
- return __pyx_r;
-}
-
-/* "View.MemoryView":1208
- *
- * @cname('__pyx_memoryview_copy_data_to_temp')
- * cdef void *copy_data_to_temp(__Pyx_memviewslice *src, # <<<<<<<<<<<<<<
- * __Pyx_memviewslice *tmpslice,
- * char order,
- */
-
-static void *__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice *__pyx_v_src, __Pyx_memviewslice *__pyx_v_tmpslice, char __pyx_v_order, int __pyx_v_ndim) {
- int __pyx_v_i;
- void *__pyx_v_result;
- size_t __pyx_v_itemsize;
- size_t __pyx_v_size;
- void *__pyx_r;
- Py_ssize_t __pyx_t_1;
- int __pyx_t_2;
- int __pyx_t_3;
- struct __pyx_memoryview_obj *__pyx_t_4;
- int __pyx_t_5;
- int __pyx_t_6;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
-
- /* "View.MemoryView":1219
- * cdef void *result
- *
- * cdef size_t itemsize = src.memview.view.itemsize # <<<<<<<<<<<<<<
- * cdef size_t size = slice_get_size(src, ndim)
- *
- */
- __pyx_t_1 = __pyx_v_src->memview->view.itemsize;
- __pyx_v_itemsize = __pyx_t_1;
-
- /* "View.MemoryView":1220
- *
- * cdef size_t itemsize = src.memview.view.itemsize
- * cdef size_t size = slice_get_size(src, ndim) # <<<<<<<<<<<<<<
- *
- * result = malloc(size)
- */
- __pyx_v_size = __pyx_memoryview_slice_get_size(__pyx_v_src, __pyx_v_ndim);
-
- /* "View.MemoryView":1222
- * cdef size_t size = slice_get_size(src, ndim)
- *
- * result = malloc(size) # <<<<<<<<<<<<<<
- * if not result:
- * _err(MemoryError, NULL)
- */
- __pyx_v_result = malloc(__pyx_v_size);
-
- /* "View.MemoryView":1223
- *
- * result = malloc(size)
- * if not result: # <<<<<<<<<<<<<<
- * _err(MemoryError, NULL)
- *
- */
- __pyx_t_2 = ((!(__pyx_v_result != 0)) != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":1224
- * result = malloc(size)
- * if not result:
- * _err(MemoryError, NULL) # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_3 = __pyx_memoryview_err(__pyx_builtin_MemoryError, NULL); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 1224, __pyx_L1_error)
-
- /* "View.MemoryView":1223
- *
- * result = malloc(size)
- * if not result: # <<<<<<<<<<<<<<
- * _err(MemoryError, NULL)
- *
- */
- }
-
- /* "View.MemoryView":1227
- *
- *
- * tmpslice.data = result # <<<<<<<<<<<<<<
- * tmpslice.memview = src.memview
- * for i in range(ndim):
- */
- __pyx_v_tmpslice->data = ((char *)__pyx_v_result);
-
- /* "View.MemoryView":1228
- *
- * tmpslice.data = result
- * tmpslice.memview = src.memview # <<<<<<<<<<<<<<
- * for i in range(ndim):
- * tmpslice.shape[i] = src.shape[i]
- */
- __pyx_t_4 = __pyx_v_src->memview;
- __pyx_v_tmpslice->memview = __pyx_t_4;
-
- /* "View.MemoryView":1229
- * tmpslice.data = result
- * tmpslice.memview = src.memview
- * for i in range(ndim): # <<<<<<<<<<<<<<
- * tmpslice.shape[i] = src.shape[i]
- * tmpslice.suboffsets[i] = -1
- */
- __pyx_t_3 = __pyx_v_ndim;
- __pyx_t_5 = __pyx_t_3;
- for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
- __pyx_v_i = __pyx_t_6;
-
- /* "View.MemoryView":1230
- * tmpslice.memview = src.memview
- * for i in range(ndim):
- * tmpslice.shape[i] = src.shape[i] # <<<<<<<<<<<<<<
- * tmpslice.suboffsets[i] = -1
- *
- */
- (__pyx_v_tmpslice->shape[__pyx_v_i]) = (__pyx_v_src->shape[__pyx_v_i]);
-
- /* "View.MemoryView":1231
- * for i in range(ndim):
- * tmpslice.shape[i] = src.shape[i]
- * tmpslice.suboffsets[i] = -1 # <<<<<<<<<<<<<<
- *
- * fill_contig_strides_array(&tmpslice.shape[0], &tmpslice.strides[0], itemsize,
- */
- (__pyx_v_tmpslice->suboffsets[__pyx_v_i]) = -1L;
- }
-
- /* "View.MemoryView":1233
- * tmpslice.suboffsets[i] = -1
- *
- * fill_contig_strides_array(&tmpslice.shape[0], &tmpslice.strides[0], itemsize, # <<<<<<<<<<<<<<
- * ndim, order)
- *
- */
- (void)(__pyx_fill_contig_strides_array((&(__pyx_v_tmpslice->shape[0])), (&(__pyx_v_tmpslice->strides[0])), __pyx_v_itemsize, __pyx_v_ndim, __pyx_v_order));
-
- /* "View.MemoryView":1237
- *
- *
- * for i in range(ndim): # <<<<<<<<<<<<<<
- * if tmpslice.shape[i] == 1:
- * tmpslice.strides[i] = 0
- */
- __pyx_t_3 = __pyx_v_ndim;
- __pyx_t_5 = __pyx_t_3;
- for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
- __pyx_v_i = __pyx_t_6;
-
- /* "View.MemoryView":1238
- *
- * for i in range(ndim):
- * if tmpslice.shape[i] == 1: # <<<<<<<<<<<<<<
- * tmpslice.strides[i] = 0
- *
- */
- __pyx_t_2 = (((__pyx_v_tmpslice->shape[__pyx_v_i]) == 1) != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":1239
- * for i in range(ndim):
- * if tmpslice.shape[i] == 1:
- * tmpslice.strides[i] = 0 # <<<<<<<<<<<<<<
- *
- * if slice_is_contig(src[0], order, ndim):
- */
- (__pyx_v_tmpslice->strides[__pyx_v_i]) = 0;
-
- /* "View.MemoryView":1238
- *
- * for i in range(ndim):
- * if tmpslice.shape[i] == 1: # <<<<<<<<<<<<<<
- * tmpslice.strides[i] = 0
- *
- */
- }
- }
-
- /* "View.MemoryView":1241
- * tmpslice.strides[i] = 0
- *
- * if slice_is_contig(src[0], order, ndim): # <<<<<<<<<<<<<<
- * memcpy(result, src.data, size)
- * else:
- */
- __pyx_t_2 = (__pyx_memviewslice_is_contig((__pyx_v_src[0]), __pyx_v_order, __pyx_v_ndim) != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":1242
- *
- * if slice_is_contig(src[0], order, ndim):
- * memcpy(result, src.data, size) # <<<<<<<<<<<<<<
- * else:
- * copy_strided_to_strided(src, tmpslice, ndim, itemsize)
- */
- (void)(memcpy(__pyx_v_result, __pyx_v_src->data, __pyx_v_size));
-
- /* "View.MemoryView":1241
- * tmpslice.strides[i] = 0
- *
- * if slice_is_contig(src[0], order, ndim): # <<<<<<<<<<<<<<
- * memcpy(result, src.data, size)
- * else:
- */
- goto __pyx_L9;
- }
-
- /* "View.MemoryView":1244
- * memcpy(result, src.data, size)
- * else:
- * copy_strided_to_strided(src, tmpslice, ndim, itemsize) # <<<<<<<<<<<<<<
- *
- * return result
- */
- /*else*/ {
- copy_strided_to_strided(__pyx_v_src, __pyx_v_tmpslice, __pyx_v_ndim, __pyx_v_itemsize);
- }
- __pyx_L9:;
-
- /* "View.MemoryView":1246
- * copy_strided_to_strided(src, tmpslice, ndim, itemsize)
- *
- * return result # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_r = __pyx_v_result;
- goto __pyx_L0;
-
- /* "View.MemoryView":1208
- *
- * @cname('__pyx_memoryview_copy_data_to_temp')
- * cdef void *copy_data_to_temp(__Pyx_memviewslice *src, # <<<<<<<<<<<<<<
- * __Pyx_memviewslice *tmpslice,
- * char order,
- */
-
- /* function exit code */
- __pyx_L1_error:;
- {
- #ifdef WITH_THREAD
- PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
- #endif
- __Pyx_AddTraceback("View.MemoryView.copy_data_to_temp", __pyx_clineno, __pyx_lineno, __pyx_filename);
- #ifdef WITH_THREAD
- __Pyx_PyGILState_Release(__pyx_gilstate_save);
- #endif
- }
- __pyx_r = NULL;
- __pyx_L0:;
- return __pyx_r;
-}
-
-/* "View.MemoryView":1251
- *
- * @cname('__pyx_memoryview_err_extents')
- * cdef int _err_extents(int i, Py_ssize_t extent1, # <<<<<<<<<<<<<<
- * Py_ssize_t extent2) except -1 with gil:
- * raise ValueError("got differing extents in dimension %d (got %d and %d)" %
- */
-
-static int __pyx_memoryview_err_extents(int __pyx_v_i, Py_ssize_t __pyx_v_extent1, Py_ssize_t __pyx_v_extent2) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- #ifdef WITH_THREAD
- PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
- #endif
- __Pyx_RefNannySetupContext("_err_extents", 0);
-
- /* "View.MemoryView":1254
- * Py_ssize_t extent2) except -1 with gil:
- * raise ValueError("got differing extents in dimension %d (got %d and %d)" %
- * (i, extent1, extent2)) # <<<<<<<<<<<<<<
- *
- * @cname('__pyx_memoryview_err_dim')
- */
- __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1254, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_extent1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1254, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_extent2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1254, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1254, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_GIVEREF(__pyx_t_1);
- PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_2);
- PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
- __Pyx_GIVEREF(__pyx_t_3);
- PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_3);
- __pyx_t_1 = 0;
- __pyx_t_2 = 0;
- __pyx_t_3 = 0;
-
- /* "View.MemoryView":1253
- * cdef int _err_extents(int i, Py_ssize_t extent1,
- * Py_ssize_t extent2) except -1 with gil:
- * raise ValueError("got differing extents in dimension %d (got %d and %d)" % # <<<<<<<<<<<<<<
- * (i, extent1, extent2))
- *
- */
- __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_got_differing_extents_in_dimensi, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1253, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1253, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_Raise(__pyx_t_4, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __PYX_ERR(1, 1253, __pyx_L1_error)
-
- /* "View.MemoryView":1251
- *
- * @cname('__pyx_memoryview_err_extents')
- * cdef int _err_extents(int i, Py_ssize_t extent1, # <<<<<<<<<<<<<<
- * Py_ssize_t extent2) except -1 with gil:
- * raise ValueError("got differing extents in dimension %d (got %d and %d)" %
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("View.MemoryView._err_extents", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __Pyx_RefNannyFinishContext();
- #ifdef WITH_THREAD
- __Pyx_PyGILState_Release(__pyx_gilstate_save);
- #endif
- return __pyx_r;
-}
-
-/* "View.MemoryView":1257
- *
- * @cname('__pyx_memoryview_err_dim')
- * cdef int _err_dim(object error, char *msg, int dim) except -1 with gil: # <<<<<<<<<<<<<<
- * raise error(msg.decode('ascii') % dim)
- *
- */
-
-static int __pyx_memoryview_err_dim(PyObject *__pyx_v_error, char *__pyx_v_msg, int __pyx_v_dim) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- #ifdef WITH_THREAD
- PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
- #endif
- __Pyx_RefNannySetupContext("_err_dim", 0);
- __Pyx_INCREF(__pyx_v_error);
-
- /* "View.MemoryView":1258
- * @cname('__pyx_memoryview_err_dim')
- * cdef int _err_dim(object error, char *msg, int dim) except -1 with gil:
- * raise error(msg.decode('ascii') % dim) # <<<<<<<<<<<<<<
- *
- * @cname('__pyx_memoryview_err')
- */
- __pyx_t_2 = __Pyx_decode_c_string(__pyx_v_msg, 0, strlen(__pyx_v_msg), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1258, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_dim); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1258, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = PyUnicode_Format(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1258, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_INCREF(__pyx_v_error);
- __pyx_t_3 = __pyx_v_error; __pyx_t_2 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
- __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
- if (likely(__pyx_t_2)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
- __Pyx_INCREF(__pyx_t_2);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_3, function);
- }
- }
- __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4);
- __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1258, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __Pyx_Raise(__pyx_t_1, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __PYX_ERR(1, 1258, __pyx_L1_error)
-
- /* "View.MemoryView":1257
- *
- * @cname('__pyx_memoryview_err_dim')
- * cdef int _err_dim(object error, char *msg, int dim) except -1 with gil: # <<<<<<<<<<<<<<
- * raise error(msg.decode('ascii') % dim)
- *
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_AddTraceback("View.MemoryView._err_dim", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __Pyx_XDECREF(__pyx_v_error);
- __Pyx_RefNannyFinishContext();
- #ifdef WITH_THREAD
- __Pyx_PyGILState_Release(__pyx_gilstate_save);
- #endif
- return __pyx_r;
-}
-
-/* "View.MemoryView":1261
- *
- * @cname('__pyx_memoryview_err')
- * cdef int _err(object error, char *msg) except -1 with gil: # <<<<<<<<<<<<<<
- * if msg != NULL:
- * raise error(msg.decode('ascii'))
- */
-
-static int __pyx_memoryview_err(PyObject *__pyx_v_error, char *__pyx_v_msg) {
- int __pyx_r;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- #ifdef WITH_THREAD
- PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
- #endif
- __Pyx_RefNannySetupContext("_err", 0);
- __Pyx_INCREF(__pyx_v_error);
-
- /* "View.MemoryView":1262
- * @cname('__pyx_memoryview_err')
- * cdef int _err(object error, char *msg) except -1 with gil:
- * if msg != NULL: # <<<<<<<<<<<<<<
- * raise error(msg.decode('ascii'))
- * else:
- */
- __pyx_t_1 = ((__pyx_v_msg != NULL) != 0);
- if (unlikely(__pyx_t_1)) {
-
- /* "View.MemoryView":1263
- * cdef int _err(object error, char *msg) except -1 with gil:
- * if msg != NULL:
- * raise error(msg.decode('ascii')) # <<<<<<<<<<<<<<
- * else:
- * raise error
- */
- __pyx_t_3 = __Pyx_decode_c_string(__pyx_v_msg, 0, strlen(__pyx_v_msg), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1263, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_INCREF(__pyx_v_error);
- __pyx_t_4 = __pyx_v_error; __pyx_t_5 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
- __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
- if (likely(__pyx_t_5)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_4, function);
- }
- }
- __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3);
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1263, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __Pyx_Raise(__pyx_t_2, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __PYX_ERR(1, 1263, __pyx_L1_error)
-
- /* "View.MemoryView":1262
- * @cname('__pyx_memoryview_err')
- * cdef int _err(object error, char *msg) except -1 with gil:
- * if msg != NULL: # <<<<<<<<<<<<<<
- * raise error(msg.decode('ascii'))
- * else:
- */
- }
-
- /* "View.MemoryView":1265
- * raise error(msg.decode('ascii'))
- * else:
- * raise error # <<<<<<<<<<<<<<
- *
- * @cname('__pyx_memoryview_copy_contents')
- */
- /*else*/ {
- __Pyx_Raise(__pyx_v_error, 0, 0, 0);
- __PYX_ERR(1, 1265, __pyx_L1_error)
- }
-
- /* "View.MemoryView":1261
- *
- * @cname('__pyx_memoryview_err')
- * cdef int _err(object error, char *msg) except -1 with gil: # <<<<<<<<<<<<<<
- * if msg != NULL:
- * raise error(msg.decode('ascii'))
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("View.MemoryView._err", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = -1;
- __Pyx_XDECREF(__pyx_v_error);
- __Pyx_RefNannyFinishContext();
- #ifdef WITH_THREAD
- __Pyx_PyGILState_Release(__pyx_gilstate_save);
- #endif
- return __pyx_r;
-}
-
-/* "View.MemoryView":1268
- *
- * @cname('__pyx_memoryview_copy_contents')
- * cdef int memoryview_copy_contents(__Pyx_memviewslice src, # <<<<<<<<<<<<<<
- * __Pyx_memviewslice dst,
- * int src_ndim, int dst_ndim,
- */
-
-static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_memviewslice __pyx_v_dst, int __pyx_v_src_ndim, int __pyx_v_dst_ndim, int __pyx_v_dtype_is_object) {
- void *__pyx_v_tmpdata;
- size_t __pyx_v_itemsize;
- int __pyx_v_i;
- char __pyx_v_order;
- int __pyx_v_broadcasting;
- int __pyx_v_direct_copy;
- __Pyx_memviewslice __pyx_v_tmp;
- int __pyx_v_ndim;
- int __pyx_r;
- Py_ssize_t __pyx_t_1;
- int __pyx_t_2;
- int __pyx_t_3;
- int __pyx_t_4;
- int __pyx_t_5;
- int __pyx_t_6;
- void *__pyx_t_7;
- int __pyx_t_8;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
-
- /* "View.MemoryView":1276
- * Check for overlapping memory and verify the shapes.
- * """
- * cdef void *tmpdata = NULL # <<<<<<<<<<<<<<
- * cdef size_t itemsize = src.memview.view.itemsize
- * cdef int i
- */
- __pyx_v_tmpdata = NULL;
-
- /* "View.MemoryView":1277
- * """
- * cdef void *tmpdata = NULL
- * cdef size_t itemsize = src.memview.view.itemsize # <<<<<<<<<<<<<<
- * cdef int i
- * cdef char order = get_best_order(&src, src_ndim)
- */
- __pyx_t_1 = __pyx_v_src.memview->view.itemsize;
- __pyx_v_itemsize = __pyx_t_1;
-
- /* "View.MemoryView":1279
- * cdef size_t itemsize = src.memview.view.itemsize
- * cdef int i
- * cdef char order = get_best_order(&src, src_ndim) # <<<<<<<<<<<<<<
- * cdef bint broadcasting = False
- * cdef bint direct_copy = False
- */
- __pyx_v_order = __pyx_get_best_slice_order((&__pyx_v_src), __pyx_v_src_ndim);
-
- /* "View.MemoryView":1280
- * cdef int i
- * cdef char order = get_best_order(&src, src_ndim)
- * cdef bint broadcasting = False # <<<<<<<<<<<<<<
- * cdef bint direct_copy = False
- * cdef __Pyx_memviewslice tmp
- */
- __pyx_v_broadcasting = 0;
-
- /* "View.MemoryView":1281
- * cdef char order = get_best_order(&src, src_ndim)
- * cdef bint broadcasting = False
- * cdef bint direct_copy = False # <<<<<<<<<<<<<<
- * cdef __Pyx_memviewslice tmp
- *
- */
- __pyx_v_direct_copy = 0;
-
- /* "View.MemoryView":1284
- * cdef __Pyx_memviewslice tmp
- *
- * if src_ndim < dst_ndim: # <<<<<<<<<<<<<<
- * broadcast_leading(&src, src_ndim, dst_ndim)
- * elif dst_ndim < src_ndim:
- */
- __pyx_t_2 = ((__pyx_v_src_ndim < __pyx_v_dst_ndim) != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":1285
- *
- * if src_ndim < dst_ndim:
- * broadcast_leading(&src, src_ndim, dst_ndim) # <<<<<<<<<<<<<<
- * elif dst_ndim < src_ndim:
- * broadcast_leading(&dst, dst_ndim, src_ndim)
- */
- __pyx_memoryview_broadcast_leading((&__pyx_v_src), __pyx_v_src_ndim, __pyx_v_dst_ndim);
-
- /* "View.MemoryView":1284
- * cdef __Pyx_memviewslice tmp
- *
- * if src_ndim < dst_ndim: # <<<<<<<<<<<<<<
- * broadcast_leading(&src, src_ndim, dst_ndim)
- * elif dst_ndim < src_ndim:
- */
- goto __pyx_L3;
- }
-
- /* "View.MemoryView":1286
- * if src_ndim < dst_ndim:
- * broadcast_leading(&src, src_ndim, dst_ndim)
- * elif dst_ndim < src_ndim: # <<<<<<<<<<<<<<
- * broadcast_leading(&dst, dst_ndim, src_ndim)
- *
- */
- __pyx_t_2 = ((__pyx_v_dst_ndim < __pyx_v_src_ndim) != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":1287
- * broadcast_leading(&src, src_ndim, dst_ndim)
- * elif dst_ndim < src_ndim:
- * broadcast_leading(&dst, dst_ndim, src_ndim) # <<<<<<<<<<<<<<
- *
- * cdef int ndim = max(src_ndim, dst_ndim)
- */
- __pyx_memoryview_broadcast_leading((&__pyx_v_dst), __pyx_v_dst_ndim, __pyx_v_src_ndim);
-
- /* "View.MemoryView":1286
- * if src_ndim < dst_ndim:
- * broadcast_leading(&src, src_ndim, dst_ndim)
- * elif dst_ndim < src_ndim: # <<<<<<<<<<<<<<
- * broadcast_leading(&dst, dst_ndim, src_ndim)
- *
- */
- }
- __pyx_L3:;
-
- /* "View.MemoryView":1289
- * broadcast_leading(&dst, dst_ndim, src_ndim)
- *
- * cdef int ndim = max(src_ndim, dst_ndim) # <<<<<<<<<<<<<<
- *
- * for i in range(ndim):
- */
- __pyx_t_3 = __pyx_v_dst_ndim;
- __pyx_t_4 = __pyx_v_src_ndim;
- if (((__pyx_t_3 > __pyx_t_4) != 0)) {
- __pyx_t_5 = __pyx_t_3;
- } else {
- __pyx_t_5 = __pyx_t_4;
- }
- __pyx_v_ndim = __pyx_t_5;
-
- /* "View.MemoryView":1291
- * cdef int ndim = max(src_ndim, dst_ndim)
- *
- * for i in range(ndim): # <<<<<<<<<<<<<<
- * if src.shape[i] != dst.shape[i]:
- * if src.shape[i] == 1:
- */
- __pyx_t_5 = __pyx_v_ndim;
- __pyx_t_3 = __pyx_t_5;
- for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
- __pyx_v_i = __pyx_t_4;
-
- /* "View.MemoryView":1292
- *
- * for i in range(ndim):
- * if src.shape[i] != dst.shape[i]: # <<<<<<<<<<<<<<
- * if src.shape[i] == 1:
- * broadcasting = True
- */
- __pyx_t_2 = (((__pyx_v_src.shape[__pyx_v_i]) != (__pyx_v_dst.shape[__pyx_v_i])) != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":1293
- * for i in range(ndim):
- * if src.shape[i] != dst.shape[i]:
- * if src.shape[i] == 1: # <<<<<<<<<<<<<<
- * broadcasting = True
- * src.strides[i] = 0
- */
- __pyx_t_2 = (((__pyx_v_src.shape[__pyx_v_i]) == 1) != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":1294
- * if src.shape[i] != dst.shape[i]:
- * if src.shape[i] == 1:
- * broadcasting = True # <<<<<<<<<<<<<<
- * src.strides[i] = 0
- * else:
- */
- __pyx_v_broadcasting = 1;
-
- /* "View.MemoryView":1295
- * if src.shape[i] == 1:
- * broadcasting = True
- * src.strides[i] = 0 # <<<<<<<<<<<<<<
- * else:
- * _err_extents(i, dst.shape[i], src.shape[i])
- */
- (__pyx_v_src.strides[__pyx_v_i]) = 0;
-
- /* "View.MemoryView":1293
- * for i in range(ndim):
- * if src.shape[i] != dst.shape[i]:
- * if src.shape[i] == 1: # <<<<<<<<<<<<<<
- * broadcasting = True
- * src.strides[i] = 0
- */
- goto __pyx_L7;
- }
-
- /* "View.MemoryView":1297
- * src.strides[i] = 0
- * else:
- * _err_extents(i, dst.shape[i], src.shape[i]) # <<<<<<<<<<<<<<
- *
- * if src.suboffsets[i] >= 0:
- */
- /*else*/ {
- __pyx_t_6 = __pyx_memoryview_err_extents(__pyx_v_i, (__pyx_v_dst.shape[__pyx_v_i]), (__pyx_v_src.shape[__pyx_v_i])); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(1, 1297, __pyx_L1_error)
- }
- __pyx_L7:;
-
- /* "View.MemoryView":1292
- *
- * for i in range(ndim):
- * if src.shape[i] != dst.shape[i]: # <<<<<<<<<<<<<<
- * if src.shape[i] == 1:
- * broadcasting = True
- */
- }
-
- /* "View.MemoryView":1299
- * _err_extents(i, dst.shape[i], src.shape[i])
- *
- * if src.suboffsets[i] >= 0: # <<<<<<<<<<<<<<
- * _err_dim(ValueError, "Dimension %d is not direct", i)
- *
- */
- __pyx_t_2 = (((__pyx_v_src.suboffsets[__pyx_v_i]) >= 0) != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":1300
- *
- * if src.suboffsets[i] >= 0:
- * _err_dim(ValueError, "Dimension %d is not direct", i) # <<<<<<<<<<<<<<
- *
- * if slices_overlap(&src, &dst, ndim, itemsize):
- */
- __pyx_t_6 = __pyx_memoryview_err_dim(__pyx_builtin_ValueError, ((char *)"Dimension %d is not direct"), __pyx_v_i); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(1, 1300, __pyx_L1_error)
-
- /* "View.MemoryView":1299
- * _err_extents(i, dst.shape[i], src.shape[i])
- *
- * if src.suboffsets[i] >= 0: # <<<<<<<<<<<<<<
- * _err_dim(ValueError, "Dimension %d is not direct", i)
- *
- */
- }
- }
-
- /* "View.MemoryView":1302
- * _err_dim(ValueError, "Dimension %d is not direct", i)
- *
- * if slices_overlap(&src, &dst, ndim, itemsize): # <<<<<<<<<<<<<<
- *
- * if not slice_is_contig(src, order, ndim):
- */
- __pyx_t_2 = (__pyx_slices_overlap((&__pyx_v_src), (&__pyx_v_dst), __pyx_v_ndim, __pyx_v_itemsize) != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":1304
- * if slices_overlap(&src, &dst, ndim, itemsize):
- *
- * if not slice_is_contig(src, order, ndim): # <<<<<<<<<<<<<<
- * order = get_best_order(&dst, ndim)
- *
- */
- __pyx_t_2 = ((!(__pyx_memviewslice_is_contig(__pyx_v_src, __pyx_v_order, __pyx_v_ndim) != 0)) != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":1305
- *
- * if not slice_is_contig(src, order, ndim):
- * order = get_best_order(&dst, ndim) # <<<<<<<<<<<<<<
- *
- * tmpdata = copy_data_to_temp(&src, &tmp, order, ndim)
- */
- __pyx_v_order = __pyx_get_best_slice_order((&__pyx_v_dst), __pyx_v_ndim);
-
- /* "View.MemoryView":1304
- * if slices_overlap(&src, &dst, ndim, itemsize):
- *
- * if not slice_is_contig(src, order, ndim): # <<<<<<<<<<<<<<
- * order = get_best_order(&dst, ndim)
- *
- */
- }
-
- /* "View.MemoryView":1307
- * order = get_best_order(&dst, ndim)
- *
- * tmpdata = copy_data_to_temp(&src, &tmp, order, ndim) # <<<<<<<<<<<<<<
- * src = tmp
- *
- */
- __pyx_t_7 = __pyx_memoryview_copy_data_to_temp((&__pyx_v_src), (&__pyx_v_tmp), __pyx_v_order, __pyx_v_ndim); if (unlikely(__pyx_t_7 == ((void *)NULL))) __PYX_ERR(1, 1307, __pyx_L1_error)
- __pyx_v_tmpdata = __pyx_t_7;
-
- /* "View.MemoryView":1308
- *
- * tmpdata = copy_data_to_temp(&src, &tmp, order, ndim)
- * src = tmp # <<<<<<<<<<<<<<
- *
- * if not broadcasting:
- */
- __pyx_v_src = __pyx_v_tmp;
-
- /* "View.MemoryView":1302
- * _err_dim(ValueError, "Dimension %d is not direct", i)
- *
- * if slices_overlap(&src, &dst, ndim, itemsize): # <<<<<<<<<<<<<<
- *
- * if not slice_is_contig(src, order, ndim):
- */
- }
-
- /* "View.MemoryView":1310
- * src = tmp
- *
- * if not broadcasting: # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_2 = ((!(__pyx_v_broadcasting != 0)) != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":1313
- *
- *
- * if slice_is_contig(src, 'C', ndim): # <<<<<<<<<<<<<<
- * direct_copy = slice_is_contig(dst, 'C', ndim)
- * elif slice_is_contig(src, 'F', ndim):
- */
- __pyx_t_2 = (__pyx_memviewslice_is_contig(__pyx_v_src, 'C', __pyx_v_ndim) != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":1314
- *
- * if slice_is_contig(src, 'C', ndim):
- * direct_copy = slice_is_contig(dst, 'C', ndim) # <<<<<<<<<<<<<<
- * elif slice_is_contig(src, 'F', ndim):
- * direct_copy = slice_is_contig(dst, 'F', ndim)
- */
- __pyx_v_direct_copy = __pyx_memviewslice_is_contig(__pyx_v_dst, 'C', __pyx_v_ndim);
-
- /* "View.MemoryView":1313
- *
- *
- * if slice_is_contig(src, 'C', ndim): # <<<<<<<<<<<<<<
- * direct_copy = slice_is_contig(dst, 'C', ndim)
- * elif slice_is_contig(src, 'F', ndim):
- */
- goto __pyx_L12;
- }
-
- /* "View.MemoryView":1315
- * if slice_is_contig(src, 'C', ndim):
- * direct_copy = slice_is_contig(dst, 'C', ndim)
- * elif slice_is_contig(src, 'F', ndim): # <<<<<<<<<<<<<<
- * direct_copy = slice_is_contig(dst, 'F', ndim)
- *
- */
- __pyx_t_2 = (__pyx_memviewslice_is_contig(__pyx_v_src, 'F', __pyx_v_ndim) != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":1316
- * direct_copy = slice_is_contig(dst, 'C', ndim)
- * elif slice_is_contig(src, 'F', ndim):
- * direct_copy = slice_is_contig(dst, 'F', ndim) # <<<<<<<<<<<<<<
- *
- * if direct_copy:
- */
- __pyx_v_direct_copy = __pyx_memviewslice_is_contig(__pyx_v_dst, 'F', __pyx_v_ndim);
-
- /* "View.MemoryView":1315
- * if slice_is_contig(src, 'C', ndim):
- * direct_copy = slice_is_contig(dst, 'C', ndim)
- * elif slice_is_contig(src, 'F', ndim): # <<<<<<<<<<<<<<
- * direct_copy = slice_is_contig(dst, 'F', ndim)
- *
- */
- }
- __pyx_L12:;
-
- /* "View.MemoryView":1318
- * direct_copy = slice_is_contig(dst, 'F', ndim)
- *
- * if direct_copy: # <<<<<<<<<<<<<<
- *
- * refcount_copying(&dst, dtype_is_object, ndim, False)
- */
- __pyx_t_2 = (__pyx_v_direct_copy != 0);
- if (__pyx_t_2) {
-
- /* "View.MemoryView":1320
- * if direct_copy:
- *
- * refcount_copying(&dst, dtype_is_object, ndim, False) # <<<<<<<<<<<<<<
- * memcpy(dst.data, src.data, slice_get_size(&src, ndim))
- * refcount_copying(&dst, dtype_is_object, ndim, True)
- */
- __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 0);
-
- /* "View.MemoryView":1321
- *
- * refcount_copying(&dst, dtype_is_object, ndim, False)
- * memcpy(dst.data, src.data, slice_get_size(&src, ndim)) # <<<<<<<<<<<<<<
- * refcount_copying(&dst, dtype_is_object, ndim, True)
- * free(tmpdata)
- */
- (void)(memcpy(__pyx_v_dst.data, __pyx_v_src.data, __pyx_memoryview_slice_get_size((&__pyx_v_src), __pyx_v_ndim)));
-
- /* "View.MemoryView":1322
- * refcount_copying(&dst, dtype_is_object, ndim, False)
- * memcpy(dst.data, src.data, slice_get_size(&src, ndim))
- * refcount_copying(&dst, dtype_is_object, ndim, True) # <<<<<<<<<<<<<<
- * free(tmpdata)
- * return 0
- */
- __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 1);
-
- /* "View.MemoryView":1323
- * memcpy(dst.data, src.data, slice_get_size(&src, ndim))
- * refcount_copying(&dst, dtype_is_object, ndim, True)
- * free(tmpdata) # <<<<<<<<<<<<<<
- * return 0
- *
- */
- free(__pyx_v_tmpdata);
-
- /* "View.MemoryView":1324
- * refcount_copying(&dst, dtype_is_object, ndim, True)
- * free(tmpdata)
- * return 0 # <<<<<<<<<<<<<<
- *
- * if order == 'F' == get_best_order(&dst, ndim):
- */
- __pyx_r = 0;
- goto __pyx_L0;
-
- /* "View.MemoryView":1318
- * direct_copy = slice_is_contig(dst, 'F', ndim)
- *
- * if direct_copy: # <<<<<<<<<<<<<<
- *
- * refcount_copying(&dst, dtype_is_object, ndim, False)
- */
- }
-
- /* "View.MemoryView":1310
- * src = tmp
- *
- * if not broadcasting: # <<<<<<<<<<<<<<
- *
- *
- */
- }
-
- /* "View.MemoryView":1326
- * return 0
- *
- * if order == 'F' == get_best_order(&dst, ndim): # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_2 = (__pyx_v_order == 'F');
- if (__pyx_t_2) {
- __pyx_t_2 = ('F' == __pyx_get_best_slice_order((&__pyx_v_dst), __pyx_v_ndim));
- }
- __pyx_t_8 = (__pyx_t_2 != 0);
- if (__pyx_t_8) {
-
- /* "View.MemoryView":1329
- *
- *
- * transpose_memslice(&src) # <<<<<<<<<<<<<<
- * transpose_memslice(&dst)
- *
- */
- __pyx_t_5 = __pyx_memslice_transpose((&__pyx_v_src)); if (unlikely(__pyx_t_5 == ((int)0))) __PYX_ERR(1, 1329, __pyx_L1_error)
-
- /* "View.MemoryView":1330
- *
- * transpose_memslice(&src)
- * transpose_memslice(&dst) # <<<<<<<<<<<<<<
- *
- * refcount_copying(&dst, dtype_is_object, ndim, False)
- */
- __pyx_t_5 = __pyx_memslice_transpose((&__pyx_v_dst)); if (unlikely(__pyx_t_5 == ((int)0))) __PYX_ERR(1, 1330, __pyx_L1_error)
-
- /* "View.MemoryView":1326
- * return 0
- *
- * if order == 'F' == get_best_order(&dst, ndim): # <<<<<<<<<<<<<<
- *
- *
- */
- }
-
- /* "View.MemoryView":1332
- * transpose_memslice(&dst)
- *
- * refcount_copying(&dst, dtype_is_object, ndim, False) # <<<<<<<<<<<<<<
- * copy_strided_to_strided(&src, &dst, ndim, itemsize)
- * refcount_copying(&dst, dtype_is_object, ndim, True)
- */
- __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 0);
-
- /* "View.MemoryView":1333
- *
- * refcount_copying(&dst, dtype_is_object, ndim, False)
- * copy_strided_to_strided(&src, &dst, ndim, itemsize) # <<<<<<<<<<<<<<
- * refcount_copying(&dst, dtype_is_object, ndim, True)
- *
- */
- copy_strided_to_strided((&__pyx_v_src), (&__pyx_v_dst), __pyx_v_ndim, __pyx_v_itemsize);
-
- /* "View.MemoryView":1334
- * refcount_copying(&dst, dtype_is_object, ndim, False)
- * copy_strided_to_strided(&src, &dst, ndim, itemsize)
- * refcount_copying(&dst, dtype_is_object, ndim, True) # <<<<<<<<<<<<<<
- *
- * free(tmpdata)
- */
- __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 1);
-
- /* "View.MemoryView":1336
- * refcount_copying(&dst, dtype_is_object, ndim, True)
- *
- * free(tmpdata) # <<<<<<<<<<<<<<
- * return 0
- *
- */
- free(__pyx_v_tmpdata);
-
- /* "View.MemoryView":1337
- *
- * free(tmpdata)
- * return 0 # <<<<<<<<<<<<<<
- *
- * @cname('__pyx_memoryview_broadcast_leading')
- */
- __pyx_r = 0;
- goto __pyx_L0;
-
- /* "View.MemoryView":1268
- *
- * @cname('__pyx_memoryview_copy_contents')
- * cdef int memoryview_copy_contents(__Pyx_memviewslice src, # <<<<<<<<<<<<<<
- * __Pyx_memviewslice dst,
- * int src_ndim, int dst_ndim,
- */
-
- /* function exit code */
- __pyx_L1_error:;
- {
- #ifdef WITH_THREAD
- PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
- #endif
- __Pyx_AddTraceback("View.MemoryView.memoryview_copy_contents", __pyx_clineno, __pyx_lineno, __pyx_filename);
- #ifdef WITH_THREAD
- __Pyx_PyGILState_Release(__pyx_gilstate_save);
- #endif
- }
- __pyx_r = -1;
- __pyx_L0:;
- return __pyx_r;
-}
-
-/* "View.MemoryView":1340
- *
- * @cname('__pyx_memoryview_broadcast_leading')
- * cdef void broadcast_leading(__Pyx_memviewslice *mslice, # <<<<<<<<<<<<<<
- * int ndim,
- * int ndim_other) nogil:
- */
-
-static void __pyx_memoryview_broadcast_leading(__Pyx_memviewslice *__pyx_v_mslice, int __pyx_v_ndim, int __pyx_v_ndim_other) {
- int __pyx_v_i;
- int __pyx_v_offset;
- int __pyx_t_1;
- int __pyx_t_2;
- int __pyx_t_3;
-
- /* "View.MemoryView":1344
- * int ndim_other) nogil:
- * cdef int i
- * cdef int offset = ndim_other - ndim # <<<<<<<<<<<<<<
- *
- * for i in range(ndim - 1, -1, -1):
- */
- __pyx_v_offset = (__pyx_v_ndim_other - __pyx_v_ndim);
-
- /* "View.MemoryView":1346
- * cdef int offset = ndim_other - ndim
- *
- * for i in range(ndim - 1, -1, -1): # <<<<<<<<<<<<<<
- * mslice.shape[i + offset] = mslice.shape[i]
- * mslice.strides[i + offset] = mslice.strides[i]
- */
- for (__pyx_t_1 = (__pyx_v_ndim - 1); __pyx_t_1 > -1; __pyx_t_1-=1) {
- __pyx_v_i = __pyx_t_1;
-
- /* "View.MemoryView":1347
- *
- * for i in range(ndim - 1, -1, -1):
- * mslice.shape[i + offset] = mslice.shape[i] # <<<<<<<<<<<<<<
- * mslice.strides[i + offset] = mslice.strides[i]
- * mslice.suboffsets[i + offset] = mslice.suboffsets[i]
- */
- (__pyx_v_mslice->shape[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_mslice->shape[__pyx_v_i]);
-
- /* "View.MemoryView":1348
- * for i in range(ndim - 1, -1, -1):
- * mslice.shape[i + offset] = mslice.shape[i]
- * mslice.strides[i + offset] = mslice.strides[i] # <<<<<<<<<<<<<<
- * mslice.suboffsets[i + offset] = mslice.suboffsets[i]
- *
- */
- (__pyx_v_mslice->strides[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_mslice->strides[__pyx_v_i]);
-
- /* "View.MemoryView":1349
- * mslice.shape[i + offset] = mslice.shape[i]
- * mslice.strides[i + offset] = mslice.strides[i]
- * mslice.suboffsets[i + offset] = mslice.suboffsets[i] # <<<<<<<<<<<<<<
- *
- * for i in range(offset):
- */
- (__pyx_v_mslice->suboffsets[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_mslice->suboffsets[__pyx_v_i]);
- }
-
- /* "View.MemoryView":1351
- * mslice.suboffsets[i + offset] = mslice.suboffsets[i]
- *
- * for i in range(offset): # <<<<<<<<<<<<<<
- * mslice.shape[i] = 1
- * mslice.strides[i] = mslice.strides[0]
- */
- __pyx_t_1 = __pyx_v_offset;
- __pyx_t_2 = __pyx_t_1;
- for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
- __pyx_v_i = __pyx_t_3;
-
- /* "View.MemoryView":1352
- *
- * for i in range(offset):
- * mslice.shape[i] = 1 # <<<<<<<<<<<<<<
- * mslice.strides[i] = mslice.strides[0]
- * mslice.suboffsets[i] = -1
- */
- (__pyx_v_mslice->shape[__pyx_v_i]) = 1;
-
- /* "View.MemoryView":1353
- * for i in range(offset):
- * mslice.shape[i] = 1
- * mslice.strides[i] = mslice.strides[0] # <<<<<<<<<<<<<<
- * mslice.suboffsets[i] = -1
- *
- */
- (__pyx_v_mslice->strides[__pyx_v_i]) = (__pyx_v_mslice->strides[0]);
-
- /* "View.MemoryView":1354
- * mslice.shape[i] = 1
- * mslice.strides[i] = mslice.strides[0]
- * mslice.suboffsets[i] = -1 # <<<<<<<<<<<<<<
- *
- *
- */
- (__pyx_v_mslice->suboffsets[__pyx_v_i]) = -1L;
- }
-
- /* "View.MemoryView":1340
- *
- * @cname('__pyx_memoryview_broadcast_leading')
- * cdef void broadcast_leading(__Pyx_memviewslice *mslice, # <<<<<<<<<<<<<<
- * int ndim,
- * int ndim_other) nogil:
- */
-
- /* function exit code */
-}
-
-/* "View.MemoryView":1362
- *
- * @cname('__pyx_memoryview_refcount_copying')
- * cdef void refcount_copying(__Pyx_memviewslice *dst, bint dtype_is_object, # <<<<<<<<<<<<<<
- * int ndim, bint inc) nogil:
- *
- */
-
-static void __pyx_memoryview_refcount_copying(__Pyx_memviewslice *__pyx_v_dst, int __pyx_v_dtype_is_object, int __pyx_v_ndim, int __pyx_v_inc) {
- int __pyx_t_1;
-
- /* "View.MemoryView":1366
- *
- *
- * if dtype_is_object: # <<<<<<<<<<<<<<
- * refcount_objects_in_slice_with_gil(dst.data, dst.shape,
- * dst.strides, ndim, inc)
- */
- __pyx_t_1 = (__pyx_v_dtype_is_object != 0);
- if (__pyx_t_1) {
-
- /* "View.MemoryView":1367
- *
- * if dtype_is_object:
- * refcount_objects_in_slice_with_gil(dst.data, dst.shape, # <<<<<<<<<<<<<<
- * dst.strides, ndim, inc)
- *
- */
- __pyx_memoryview_refcount_objects_in_slice_with_gil(__pyx_v_dst->data, __pyx_v_dst->shape, __pyx_v_dst->strides, __pyx_v_ndim, __pyx_v_inc);
-
- /* "View.MemoryView":1366
- *
- *
- * if dtype_is_object: # <<<<<<<<<<<<<<
- * refcount_objects_in_slice_with_gil(dst.data, dst.shape,
- * dst.strides, ndim, inc)
- */
- }
-
- /* "View.MemoryView":1362
- *
- * @cname('__pyx_memoryview_refcount_copying')
- * cdef void refcount_copying(__Pyx_memviewslice *dst, bint dtype_is_object, # <<<<<<<<<<<<<<
- * int ndim, bint inc) nogil:
- *
- */
-
- /* function exit code */
-}
-
-/* "View.MemoryView":1371
- *
- * @cname('__pyx_memoryview_refcount_objects_in_slice_with_gil')
- * cdef void refcount_objects_in_slice_with_gil(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<<
- * Py_ssize_t *strides, int ndim,
- * bint inc) with gil:
- */
-
-static void __pyx_memoryview_refcount_objects_in_slice_with_gil(char *__pyx_v_data, Py_ssize_t *__pyx_v_shape, Py_ssize_t *__pyx_v_strides, int __pyx_v_ndim, int __pyx_v_inc) {
- __Pyx_RefNannyDeclarations
- #ifdef WITH_THREAD
- PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure();
- #endif
- __Pyx_RefNannySetupContext("refcount_objects_in_slice_with_gil", 0);
-
- /* "View.MemoryView":1374
- * Py_ssize_t *strides, int ndim,
- * bint inc) with gil:
- * refcount_objects_in_slice(data, shape, strides, ndim, inc) # <<<<<<<<<<<<<<
- *
- * @cname('__pyx_memoryview_refcount_objects_in_slice')
- */
- __pyx_memoryview_refcount_objects_in_slice(__pyx_v_data, __pyx_v_shape, __pyx_v_strides, __pyx_v_ndim, __pyx_v_inc);
-
- /* "View.MemoryView":1371
- *
- * @cname('__pyx_memoryview_refcount_objects_in_slice_with_gil')
- * cdef void refcount_objects_in_slice_with_gil(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<<
- * Py_ssize_t *strides, int ndim,
- * bint inc) with gil:
- */
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- #ifdef WITH_THREAD
- __Pyx_PyGILState_Release(__pyx_gilstate_save);
- #endif
-}
-
-/* "View.MemoryView":1377
- *
- * @cname('__pyx_memoryview_refcount_objects_in_slice')
- * cdef void refcount_objects_in_slice(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<<
- * Py_ssize_t *strides, int ndim, bint inc):
- * cdef Py_ssize_t i
- */
-
-static void __pyx_memoryview_refcount_objects_in_slice(char *__pyx_v_data, Py_ssize_t *__pyx_v_shape, Py_ssize_t *__pyx_v_strides, int __pyx_v_ndim, int __pyx_v_inc) {
- CYTHON_UNUSED Py_ssize_t __pyx_v_i;
- __Pyx_RefNannyDeclarations
- Py_ssize_t __pyx_t_1;
- Py_ssize_t __pyx_t_2;
- Py_ssize_t __pyx_t_3;
- int __pyx_t_4;
- __Pyx_RefNannySetupContext("refcount_objects_in_slice", 0);
-
- /* "View.MemoryView":1381
- * cdef Py_ssize_t i
- *
- * for i in range(shape[0]): # <<<<<<<<<<<<<<
- * if ndim == 1:
- * if inc:
- */
- __pyx_t_1 = (__pyx_v_shape[0]);
- __pyx_t_2 = __pyx_t_1;
- for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
- __pyx_v_i = __pyx_t_3;
-
- /* "View.MemoryView":1382
- *
- * for i in range(shape[0]):
- * if ndim == 1: # <<<<<<<<<<<<<<
- * if inc:
- * Py_INCREF(( data)[0])
- */
- __pyx_t_4 = ((__pyx_v_ndim == 1) != 0);
- if (__pyx_t_4) {
-
- /* "View.MemoryView":1383
- * for i in range(shape[0]):
- * if ndim == 1:
- * if inc: # <<<<<<<<<<<<<<
- * Py_INCREF(( data)[0])
- * else:
- */
- __pyx_t_4 = (__pyx_v_inc != 0);
- if (__pyx_t_4) {
-
- /* "View.MemoryView":1384
- * if ndim == 1:
- * if inc:
- * Py_INCREF(( data)[0]) # <<<<<<<<<<<<<<
- * else:
- * Py_DECREF(( data)[0])
- */
- Py_INCREF((((PyObject **)__pyx_v_data)[0]));
-
- /* "View.MemoryView":1383
- * for i in range(shape[0]):
- * if ndim == 1:
- * if inc: # <<<<<<<<<<<<<<
- * Py_INCREF(( data)[0])
- * else:
- */
- goto __pyx_L6;
- }
-
- /* "View.MemoryView":1386
- * Py_INCREF(( data)[0])
- * else:
- * Py_DECREF(( data)[0]) # <<<<<<<<<<<<<<
- * else:
- * refcount_objects_in_slice(data, shape + 1, strides + 1,
- */
- /*else*/ {
- Py_DECREF((((PyObject **)__pyx_v_data)[0]));
- }
- __pyx_L6:;
-
- /* "View.MemoryView":1382
- *
- * for i in range(shape[0]):
- * if ndim == 1: # <<<<<<<<<<<<<<
- * if inc:
- * Py_INCREF(( data)[0])
- */
- goto __pyx_L5;
- }
-
- /* "View.MemoryView":1388
- * Py_DECREF(( data)[0])
- * else:
- * refcount_objects_in_slice(data, shape + 1, strides + 1, # <<<<<<<<<<<<<<
- * ndim - 1, inc)
- *
- */
- /*else*/ {
-
- /* "View.MemoryView":1389
- * else:
- * refcount_objects_in_slice(data, shape + 1, strides + 1,
- * ndim - 1, inc) # <<<<<<<<<<<<<<
- *
- * data += strides[0]
- */
- __pyx_memoryview_refcount_objects_in_slice(__pyx_v_data, (__pyx_v_shape + 1), (__pyx_v_strides + 1), (__pyx_v_ndim - 1), __pyx_v_inc);
- }
- __pyx_L5:;
-
- /* "View.MemoryView":1391
- * ndim - 1, inc)
- *
- * data += strides[0] # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_v_data = (__pyx_v_data + (__pyx_v_strides[0]));
- }
-
- /* "View.MemoryView":1377
- *
- * @cname('__pyx_memoryview_refcount_objects_in_slice')
- * cdef void refcount_objects_in_slice(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<<
- * Py_ssize_t *strides, int ndim, bint inc):
- * cdef Py_ssize_t i
- */
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
-}
-
-/* "View.MemoryView":1397
- *
- * @cname('__pyx_memoryview_slice_assign_scalar')
- * cdef void slice_assign_scalar(__Pyx_memviewslice *dst, int ndim, # <<<<<<<<<<<<<<
- * size_t itemsize, void *item,
- * bint dtype_is_object) nogil:
- */
-
-static void __pyx_memoryview_slice_assign_scalar(__Pyx_memviewslice *__pyx_v_dst, int __pyx_v_ndim, size_t __pyx_v_itemsize, void *__pyx_v_item, int __pyx_v_dtype_is_object) {
-
- /* "View.MemoryView":1400
- * size_t itemsize, void *item,
- * bint dtype_is_object) nogil:
- * refcount_copying(dst, dtype_is_object, ndim, False) # <<<<<<<<<<<<<<
- * _slice_assign_scalar(dst.data, dst.shape, dst.strides, ndim,
- * itemsize, item)
- */
- __pyx_memoryview_refcount_copying(__pyx_v_dst, __pyx_v_dtype_is_object, __pyx_v_ndim, 0);
-
- /* "View.MemoryView":1401
- * bint dtype_is_object) nogil:
- * refcount_copying(dst, dtype_is_object, ndim, False)
- * _slice_assign_scalar(dst.data, dst.shape, dst.strides, ndim, # <<<<<<<<<<<<<<
- * itemsize, item)
- * refcount_copying(dst, dtype_is_object, ndim, True)
- */
- __pyx_memoryview__slice_assign_scalar(__pyx_v_dst->data, __pyx_v_dst->shape, __pyx_v_dst->strides, __pyx_v_ndim, __pyx_v_itemsize, __pyx_v_item);
-
- /* "View.MemoryView":1403
- * _slice_assign_scalar(dst.data, dst.shape, dst.strides, ndim,
- * itemsize, item)
- * refcount_copying(dst, dtype_is_object, ndim, True) # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_memoryview_refcount_copying(__pyx_v_dst, __pyx_v_dtype_is_object, __pyx_v_ndim, 1);
-
- /* "View.MemoryView":1397
- *
- * @cname('__pyx_memoryview_slice_assign_scalar')
- * cdef void slice_assign_scalar(__Pyx_memviewslice *dst, int ndim, # <<<<<<<<<<<<<<
- * size_t itemsize, void *item,
- * bint dtype_is_object) nogil:
- */
-
- /* function exit code */
-}
-
-/* "View.MemoryView":1407
- *
- * @cname('__pyx_memoryview__slice_assign_scalar')
- * cdef void _slice_assign_scalar(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<<
- * Py_ssize_t *strides, int ndim,
- * size_t itemsize, void *item) nogil:
- */
-
-static void __pyx_memoryview__slice_assign_scalar(char *__pyx_v_data, Py_ssize_t *__pyx_v_shape, Py_ssize_t *__pyx_v_strides, int __pyx_v_ndim, size_t __pyx_v_itemsize, void *__pyx_v_item) {
- CYTHON_UNUSED Py_ssize_t __pyx_v_i;
- Py_ssize_t __pyx_v_stride;
- Py_ssize_t __pyx_v_extent;
- int __pyx_t_1;
- Py_ssize_t __pyx_t_2;
- Py_ssize_t __pyx_t_3;
- Py_ssize_t __pyx_t_4;
-
- /* "View.MemoryView":1411
- * size_t itemsize, void *item) nogil:
- * cdef Py_ssize_t i
- * cdef Py_ssize_t stride = strides[0] # <<<<<<<<<<<<<<
- * cdef Py_ssize_t extent = shape[0]
- *
- */
- __pyx_v_stride = (__pyx_v_strides[0]);
-
- /* "View.MemoryView":1412
- * cdef Py_ssize_t i
- * cdef Py_ssize_t stride = strides[0]
- * cdef Py_ssize_t extent = shape[0] # <<<<<<<<<<<<<<
- *
- * if ndim == 1:
- */
- __pyx_v_extent = (__pyx_v_shape[0]);
-
- /* "View.MemoryView":1414
- * cdef Py_ssize_t extent = shape[0]
- *
- * if ndim == 1: # <<<<<<<<<<<<<<
- * for i in range(extent):
- * memcpy(data, item, itemsize)
- */
- __pyx_t_1 = ((__pyx_v_ndim == 1) != 0);
- if (__pyx_t_1) {
-
- /* "View.MemoryView":1415
- *
- * if ndim == 1:
- * for i in range(extent): # <<<<<<<<<<<<<<
- * memcpy(data, item, itemsize)
- * data += stride
- */
- __pyx_t_2 = __pyx_v_extent;
- __pyx_t_3 = __pyx_t_2;
- for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
- __pyx_v_i = __pyx_t_4;
-
- /* "View.MemoryView":1416
- * if ndim == 1:
- * for i in range(extent):
- * memcpy(data, item, itemsize) # <<<<<<<<<<<<<<
- * data += stride
- * else:
- */
- (void)(memcpy(__pyx_v_data, __pyx_v_item, __pyx_v_itemsize));
-
- /* "View.MemoryView":1417
- * for i in range(extent):
- * memcpy(data, item, itemsize)
- * data += stride # <<<<<<<<<<<<<<
- * else:
- * for i in range(extent):
- */
- __pyx_v_data = (__pyx_v_data + __pyx_v_stride);
- }
-
- /* "View.MemoryView":1414
- * cdef Py_ssize_t extent = shape[0]
- *
- * if ndim == 1: # <<<<<<<<<<<<<<
- * for i in range(extent):
- * memcpy(data, item, itemsize)
- */
- goto __pyx_L3;
- }
-
- /* "View.MemoryView":1419
- * data += stride
- * else:
- * for i in range(extent): # <<<<<<<<<<<<<<
- * _slice_assign_scalar(data, shape + 1, strides + 1,
- * ndim - 1, itemsize, item)
- */
- /*else*/ {
- __pyx_t_2 = __pyx_v_extent;
- __pyx_t_3 = __pyx_t_2;
- for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
- __pyx_v_i = __pyx_t_4;
-
- /* "View.MemoryView":1420
- * else:
- * for i in range(extent):
- * _slice_assign_scalar(data, shape + 1, strides + 1, # <<<<<<<<<<<<<<
- * ndim - 1, itemsize, item)
- * data += stride
- */
- __pyx_memoryview__slice_assign_scalar(__pyx_v_data, (__pyx_v_shape + 1), (__pyx_v_strides + 1), (__pyx_v_ndim - 1), __pyx_v_itemsize, __pyx_v_item);
-
- /* "View.MemoryView":1422
- * _slice_assign_scalar(data, shape + 1, strides + 1,
- * ndim - 1, itemsize, item)
- * data += stride # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_v_data = (__pyx_v_data + __pyx_v_stride);
- }
- }
- __pyx_L3:;
-
- /* "View.MemoryView":1407
- *
- * @cname('__pyx_memoryview__slice_assign_scalar')
- * cdef void _slice_assign_scalar(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<<
- * Py_ssize_t *strides, int ndim,
- * size_t itemsize, void *item) nogil:
- */
-
- /* function exit code */
-}
-
-/* "(tree fragment)":1
- * def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<<
- * cdef object __pyx_PickleError
- * cdef object __pyx_result
- */
-
-/* Python wrapper */
-static PyObject *__pyx_pw_15View_dot_MemoryView_1__pyx_unpickle_Enum(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static PyMethodDef __pyx_mdef_15View_dot_MemoryView_1__pyx_unpickle_Enum = {"__pyx_unpickle_Enum", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_15View_dot_MemoryView_1__pyx_unpickle_Enum, METH_VARARGS|METH_KEYWORDS, 0};
-static PyObject *__pyx_pw_15View_dot_MemoryView_1__pyx_unpickle_Enum(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
- PyObject *__pyx_v___pyx_type = 0;
- long __pyx_v___pyx_checksum;
- PyObject *__pyx_v___pyx_state = 0;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- PyObject *__pyx_r = 0;
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__pyx_unpickle_Enum (wrapper)", 0);
- {
- static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0};
- PyObject* values[3] = {0,0,0};
- if (unlikely(__pyx_kwds)) {
- Py_ssize_t kw_args;
- const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
- switch (pos_args) {
- case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- CYTHON_FALLTHROUGH;
- case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- CYTHON_FALLTHROUGH;
- case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- CYTHON_FALLTHROUGH;
- case 0: break;
- default: goto __pyx_L5_argtuple_error;
- }
- kw_args = PyDict_Size(__pyx_kwds);
- switch (pos_args) {
- case 0:
- if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
- else goto __pyx_L5_argtuple_error;
- CYTHON_FALLTHROUGH;
- case 1:
- if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Enum", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error)
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
- else {
- __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Enum", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error)
- }
- }
- if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_Enum") < 0)) __PYX_ERR(1, 1, __pyx_L3_error)
- }
- } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
- goto __pyx_L5_argtuple_error;
- } else {
- values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
- values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
- values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
- }
- __pyx_v___pyx_type = values[0];
- __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error)
- __pyx_v___pyx_state = values[2];
- }
- goto __pyx_L4_argument_unpacking_done;
- __pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Enum", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error)
- __pyx_L3_error:;
- __Pyx_AddTraceback("View.MemoryView.__pyx_unpickle_Enum", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __Pyx_RefNannyFinishContext();
- return NULL;
- __pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_15View_dot_MemoryView___pyx_unpickle_Enum(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);
-
- /* function exit code */
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-static PyObject *__pyx_pf_15View_dot_MemoryView___pyx_unpickle_Enum(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
- PyObject *__pyx_v___pyx_PickleError = 0;
- PyObject *__pyx_v___pyx_result = 0;
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- int __pyx_t_1;
- PyObject *__pyx_t_2 = NULL;
- PyObject *__pyx_t_3 = NULL;
- PyObject *__pyx_t_4 = NULL;
- PyObject *__pyx_t_5 = NULL;
- int __pyx_t_6;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("__pyx_unpickle_Enum", 0);
-
- /* "(tree fragment)":4
- * cdef object __pyx_PickleError
- * cdef object __pyx_result
- * if __pyx_checksum != 0xb068931: # <<<<<<<<<<<<<<
- * from pickle import PickleError as __pyx_PickleError
- * raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
- */
- __pyx_t_1 = ((__pyx_v___pyx_checksum != 0xb068931) != 0);
- if (__pyx_t_1) {
-
- /* "(tree fragment)":5
- * cdef object __pyx_result
- * if __pyx_checksum != 0xb068931:
- * from pickle import PickleError as __pyx_PickleError # <<<<<<<<<<<<<<
- * raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
- * __pyx_result = Enum.__new__(__pyx_type)
- */
- __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_n_s_PickleError);
- __Pyx_GIVEREF(__pyx_n_s_PickleError);
- PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
- __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_2);
- __pyx_v___pyx_PickleError = __pyx_t_2;
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "(tree fragment)":6
- * if __pyx_checksum != 0xb068931:
- * from pickle import PickleError as __pyx_PickleError
- * raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum) # <<<<<<<<<<<<<<
- * __pyx_result = Enum.__new__(__pyx_type)
- * if __pyx_state is not None:
- */
- __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0xb0, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_4);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_INCREF(__pyx_v___pyx_PickleError);
- __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
- if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_5)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_5);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __Pyx_Raise(__pyx_t_3, 0, 0, 0);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __PYX_ERR(1, 6, __pyx_L1_error)
-
- /* "(tree fragment)":4
- * cdef object __pyx_PickleError
- * cdef object __pyx_result
- * if __pyx_checksum != 0xb068931: # <<<<<<<<<<<<<<
- * from pickle import PickleError as __pyx_PickleError
- * raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
- */
- }
-
- /* "(tree fragment)":7
- * from pickle import PickleError as __pyx_PickleError
- * raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
- * __pyx_result = Enum.__new__(__pyx_type) # <<<<<<<<<<<<<<
- * if __pyx_state is not None:
- * __pyx_unpickle_Enum__set_state( __pyx_result, __pyx_state)
- */
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_MemviewEnum_type), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_2);
- __pyx_t_4 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
- __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
- if (likely(__pyx_t_4)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
- __Pyx_INCREF(__pyx_t_4);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_2, function);
- }
- }
- __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type);
- __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 7, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_v___pyx_result = __pyx_t_3;
- __pyx_t_3 = 0;
-
- /* "(tree fragment)":8
- * raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
- * __pyx_result = Enum.__new__(__pyx_type)
- * if __pyx_state is not None: # <<<<<<<<<<<<<<
- * __pyx_unpickle_Enum__set_state( __pyx_result, __pyx_state)
- * return __pyx_result
- */
- __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
- __pyx_t_6 = (__pyx_t_1 != 0);
- if (__pyx_t_6) {
-
- /* "(tree fragment)":9
- * __pyx_result = Enum.__new__(__pyx_type)
- * if __pyx_state is not None:
- * __pyx_unpickle_Enum__set_state( __pyx_result, __pyx_state) # <<<<<<<<<<<<<<
- * return __pyx_result
- * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):
- */
- if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error)
- __pyx_t_3 = __pyx_unpickle_Enum__set_state(((struct __pyx_MemviewEnum_obj *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 9, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_3);
- __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
- /* "(tree fragment)":8
- * raise __pyx_PickleError("Incompatible checksums (%s vs 0xb068931 = (name))" % __pyx_checksum)
- * __pyx_result = Enum.__new__(__pyx_type)
- * if __pyx_state is not None: # <<<<<<<<<<<<<<
- * __pyx_unpickle_Enum__set_state( __pyx_result, __pyx_state)
- * return __pyx_result
- */
- }
-
- /* "(tree fragment)":10
- * if __pyx_state is not None:
- * __pyx_unpickle_Enum__set_state( __pyx_result, __pyx_state)
- * return __pyx_result # <<<<<<<<<<<<<<
- * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):
- * __pyx_result.name = __pyx_state[0]
- */
- __Pyx_XDECREF(__pyx_r);
- __Pyx_INCREF(__pyx_v___pyx_result);
- __pyx_r = __pyx_v___pyx_result;
- goto __pyx_L0;
-
- /* "(tree fragment)":1
- * def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<<
- * cdef object __pyx_PickleError
- * cdef object __pyx_result
- */
-
- /* function exit code */
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_2);
- __Pyx_XDECREF(__pyx_t_3);
- __Pyx_XDECREF(__pyx_t_4);
- __Pyx_XDECREF(__pyx_t_5);
- __Pyx_AddTraceback("View.MemoryView.__pyx_unpickle_Enum", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = NULL;
- __pyx_L0:;
- __Pyx_XDECREF(__pyx_v___pyx_PickleError);
- __Pyx_XDECREF(__pyx_v___pyx_result);
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-
-/* "(tree fragment)":11
- * __pyx_unpickle_Enum__set_state( __pyx_result, __pyx_state)
- * return __pyx_result
- * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state): # <<<<<<<<<<<<<<
- * __pyx_result.name = __pyx_state[0]
- * if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
- */
-
-static PyObject *__pyx_unpickle_Enum__set_state(struct __pyx_MemviewEnum_obj *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
- PyObject *__pyx_r = NULL;
- __Pyx_RefNannyDeclarations
- PyObject *__pyx_t_1 = NULL;
- int __pyx_t_2;
- Py_ssize_t __pyx_t_3;
- int __pyx_t_4;
- int __pyx_t_5;
- PyObject *__pyx_t_6 = NULL;
- PyObject *__pyx_t_7 = NULL;
- PyObject *__pyx_t_8 = NULL;
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("__pyx_unpickle_Enum__set_state", 0);
-
- /* "(tree fragment)":12
- * return __pyx_result
- * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):
- * __pyx_result.name = __pyx_state[0] # <<<<<<<<<<<<<<
- * if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
- * __pyx_result.__dict__.update(__pyx_state[1])
- */
- if (unlikely(__pyx_v___pyx_state == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
- __PYX_ERR(1, 12, __pyx_L1_error)
- }
- __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __Pyx_GOTREF(__pyx_v___pyx_result->name);
- __Pyx_DECREF(__pyx_v___pyx_result->name);
- __pyx_v___pyx_result->name = __pyx_t_1;
- __pyx_t_1 = 0;
-
- /* "(tree fragment)":13
- * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):
- * __pyx_result.name = __pyx_state[0]
- * if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'): # <<<<<<<<<<<<<<
- * __pyx_result.__dict__.update(__pyx_state[1])
- */
- if (unlikely(__pyx_v___pyx_state == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
- __PYX_ERR(1, 13, __pyx_L1_error)
- }
- __pyx_t_3 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
- __pyx_t_4 = ((__pyx_t_3 > 1) != 0);
- if (__pyx_t_4) {
- } else {
- __pyx_t_2 = __pyx_t_4;
- goto __pyx_L4_bool_binop_done;
- }
- __pyx_t_4 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
- __pyx_t_5 = (__pyx_t_4 != 0);
- __pyx_t_2 = __pyx_t_5;
- __pyx_L4_bool_binop_done:;
- if (__pyx_t_2) {
-
- /* "(tree fragment)":14
- * __pyx_result.name = __pyx_state[0]
- * if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
- * __pyx_result.__dict__.update(__pyx_state[1]) # <<<<<<<<<<<<<<
- */
- __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_7);
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- if (unlikely(__pyx_v___pyx_state == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
- __PYX_ERR(1, 14, __pyx_L1_error)
- }
- __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_6);
- __pyx_t_8 = NULL;
- if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
- __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
- if (likely(__pyx_t_8)) {
- PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
- __Pyx_INCREF(__pyx_t_8);
- __Pyx_INCREF(function);
- __Pyx_DECREF_SET(__pyx_t_7, function);
- }
- }
- __pyx_t_1 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6);
- __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
- __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "(tree fragment)":13
- * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state):
- * __pyx_result.name = __pyx_state[0]
- * if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'): # <<<<<<<<<<<<<<
- * __pyx_result.__dict__.update(__pyx_state[1])
- */
- }
-
- /* "(tree fragment)":11
- * __pyx_unpickle_Enum__set_state( __pyx_result, __pyx_state)
- * return __pyx_result
- * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state): # <<<<<<<<<<<<<<
- * __pyx_result.name = __pyx_state[0]
- * if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
- */
-
- /* function exit code */
- __pyx_r = Py_None; __Pyx_INCREF(Py_None);
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- __Pyx_XDECREF(__pyx_t_6);
- __Pyx_XDECREF(__pyx_t_7);
- __Pyx_XDECREF(__pyx_t_8);
- __Pyx_AddTraceback("View.MemoryView.__pyx_unpickle_Enum__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
- __pyx_r = 0;
- __pyx_L0:;
- __Pyx_XGIVEREF(__pyx_r);
- __Pyx_RefNannyFinishContext();
- return __pyx_r;
-}
-static struct __pyx_vtabstruct_array __pyx_vtable_array;
-
-static PyObject *__pyx_tp_new_array(PyTypeObject *t, PyObject *a, PyObject *k) {
- struct __pyx_array_obj *p;
- PyObject *o;
- if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
- o = (*t->tp_alloc)(t, 0);
- } else {
- o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
- }
- if (unlikely(!o)) return 0;
- p = ((struct __pyx_array_obj *)o);
- p->__pyx_vtab = __pyx_vtabptr_array;
- p->mode = ((PyObject*)Py_None); Py_INCREF(Py_None);
- p->_format = ((PyObject*)Py_None); Py_INCREF(Py_None);
- if (unlikely(__pyx_array___cinit__(o, a, k) < 0)) goto bad;
- return o;
- bad:
- Py_DECREF(o); o = 0;
- return NULL;
-}
-
-static void __pyx_tp_dealloc_array(PyObject *o) {
- struct __pyx_array_obj *p = (struct __pyx_array_obj *)o;
- #if CYTHON_USE_TP_FINALIZE
- if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) {
- if (PyObject_CallFinalizerFromDealloc(o)) return;
- }
- #endif
- {
- PyObject *etype, *eval, *etb;
- PyErr_Fetch(&etype, &eval, &etb);
- __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1);
- __pyx_array___dealloc__(o);
- __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1);
- PyErr_Restore(etype, eval, etb);
- }
- Py_CLEAR(p->mode);
- Py_CLEAR(p->_format);
- (*Py_TYPE(o)->tp_free)(o);
-}
-static PyObject *__pyx_sq_item_array(PyObject *o, Py_ssize_t i) {
- PyObject *r;
- PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
- r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
- Py_DECREF(x);
- return r;
-}
-
-static int __pyx_mp_ass_subscript_array(PyObject *o, PyObject *i, PyObject *v) {
- if (v) {
- return __pyx_array___setitem__(o, i, v);
- }
- else {
- PyErr_Format(PyExc_NotImplementedError,
- "Subscript deletion not supported by %.200s", Py_TYPE(o)->tp_name);
- return -1;
- }
-}
-
-static PyObject *__pyx_tp_getattro_array(PyObject *o, PyObject *n) {
- PyObject *v = __Pyx_PyObject_GenericGetAttr(o, n);
- if (!v && PyErr_ExceptionMatches(PyExc_AttributeError)) {
- PyErr_Clear();
- v = __pyx_array___getattr__(o, n);
- }
- return v;
-}
-
-static PyObject *__pyx_getprop___pyx_array_memview(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_15View_dot_MemoryView_5array_7memview_1__get__(o);
-}
-
-static PyMethodDef __pyx_methods_array[] = {
- {"__getattr__", (PyCFunction)__pyx_array___getattr__, METH_O|METH_COEXIST, 0},
- {"__reduce_cython__", (PyCFunction)__pyx_pw___pyx_array_1__reduce_cython__, METH_NOARGS, 0},
- {"__setstate_cython__", (PyCFunction)__pyx_pw___pyx_array_3__setstate_cython__, METH_O, 0},
- {0, 0, 0, 0}
-};
-
-static struct PyGetSetDef __pyx_getsets_array[] = {
- {(char *)"memview", __pyx_getprop___pyx_array_memview, 0, (char *)0, 0},
- {0, 0, 0, 0, 0}
-};
-
-static PySequenceMethods __pyx_tp_as_sequence_array = {
- __pyx_array___len__, /*sq_length*/
- 0, /*sq_concat*/
- 0, /*sq_repeat*/
- __pyx_sq_item_array, /*sq_item*/
- 0, /*sq_slice*/
- 0, /*sq_ass_item*/
- 0, /*sq_ass_slice*/
- 0, /*sq_contains*/
- 0, /*sq_inplace_concat*/
- 0, /*sq_inplace_repeat*/
-};
-
-static PyMappingMethods __pyx_tp_as_mapping_array = {
- __pyx_array___len__, /*mp_length*/
- __pyx_array___getitem__, /*mp_subscript*/
- __pyx_mp_ass_subscript_array, /*mp_ass_subscript*/
-};
-
-static PyBufferProcs __pyx_tp_as_buffer_array = {
- #if PY_MAJOR_VERSION < 3
- 0, /*bf_getreadbuffer*/
- #endif
- #if PY_MAJOR_VERSION < 3
- 0, /*bf_getwritebuffer*/
- #endif
- #if PY_MAJOR_VERSION < 3
- 0, /*bf_getsegcount*/
- #endif
- #if PY_MAJOR_VERSION < 3
- 0, /*bf_getcharbuffer*/
- #endif
- __pyx_array_getbuffer, /*bf_getbuffer*/
- 0, /*bf_releasebuffer*/
-};
-
-static PyTypeObject __pyx_type___pyx_array = {
- PyVarObject_HEAD_INIT(0, 0)
- "monotonic_align.core.array", /*tp_name*/
- sizeof(struct __pyx_array_obj), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_array, /*tp_dealloc*/
- #if PY_VERSION_HEX < 0x030800b4
- 0, /*tp_print*/
- #endif
- #if PY_VERSION_HEX >= 0x030800b4
- 0, /*tp_vectorcall_offset*/
- #endif
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- &__pyx_tp_as_sequence_array, /*tp_as_sequence*/
- &__pyx_tp_as_mapping_array, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- __pyx_tp_getattro_array, /*tp_getattro*/
- 0, /*tp_setattro*/
- &__pyx_tp_as_buffer_array, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
- 0, /*tp_doc*/
- 0, /*tp_traverse*/
- 0, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- __pyx_methods_array, /*tp_methods*/
- 0, /*tp_members*/
- __pyx_getsets_array, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- 0, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new_array, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
- #if PY_VERSION_HEX >= 0x030800b1
- 0, /*tp_vectorcall*/
- #endif
- #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
- 0, /*tp_print*/
- #endif
-};
-
-static PyObject *__pyx_tp_new_Enum(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
- struct __pyx_MemviewEnum_obj *p;
- PyObject *o;
- if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
- o = (*t->tp_alloc)(t, 0);
- } else {
- o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
- }
- if (unlikely(!o)) return 0;
- p = ((struct __pyx_MemviewEnum_obj *)o);
- p->name = Py_None; Py_INCREF(Py_None);
- return o;
-}
-
-static void __pyx_tp_dealloc_Enum(PyObject *o) {
- struct __pyx_MemviewEnum_obj *p = (struct __pyx_MemviewEnum_obj *)o;
- #if CYTHON_USE_TP_FINALIZE
- if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
- if (PyObject_CallFinalizerFromDealloc(o)) return;
- }
- #endif
- PyObject_GC_UnTrack(o);
- Py_CLEAR(p->name);
- (*Py_TYPE(o)->tp_free)(o);
-}
-
-static int __pyx_tp_traverse_Enum(PyObject *o, visitproc v, void *a) {
- int e;
- struct __pyx_MemviewEnum_obj *p = (struct __pyx_MemviewEnum_obj *)o;
- if (p->name) {
- e = (*v)(p->name, a); if (e) return e;
- }
- return 0;
-}
-
-static int __pyx_tp_clear_Enum(PyObject *o) {
- PyObject* tmp;
- struct __pyx_MemviewEnum_obj *p = (struct __pyx_MemviewEnum_obj *)o;
- tmp = ((PyObject*)p->name);
- p->name = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- return 0;
-}
-
-static PyMethodDef __pyx_methods_Enum[] = {
- {"__reduce_cython__", (PyCFunction)__pyx_pw___pyx_MemviewEnum_1__reduce_cython__, METH_NOARGS, 0},
- {"__setstate_cython__", (PyCFunction)__pyx_pw___pyx_MemviewEnum_3__setstate_cython__, METH_O, 0},
- {0, 0, 0, 0}
-};
-
-static PyTypeObject __pyx_type___pyx_MemviewEnum = {
- PyVarObject_HEAD_INIT(0, 0)
- "monotonic_align.core.Enum", /*tp_name*/
- sizeof(struct __pyx_MemviewEnum_obj), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_Enum, /*tp_dealloc*/
- #if PY_VERSION_HEX < 0x030800b4
- 0, /*tp_print*/
- #endif
- #if PY_VERSION_HEX >= 0x030800b4
- 0, /*tp_vectorcall_offset*/
- #endif
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- __pyx_MemviewEnum___repr__, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- 0, /*tp_doc*/
- __pyx_tp_traverse_Enum, /*tp_traverse*/
- __pyx_tp_clear_Enum, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- __pyx_methods_Enum, /*tp_methods*/
- 0, /*tp_members*/
- 0, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- __pyx_MemviewEnum___init__, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new_Enum, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
- #if PY_VERSION_HEX >= 0x030800b1
- 0, /*tp_vectorcall*/
- #endif
- #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
- 0, /*tp_print*/
- #endif
-};
-static struct __pyx_vtabstruct_memoryview __pyx_vtable_memoryview;
-
-static PyObject *__pyx_tp_new_memoryview(PyTypeObject *t, PyObject *a, PyObject *k) {
- struct __pyx_memoryview_obj *p;
- PyObject *o;
- if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
- o = (*t->tp_alloc)(t, 0);
- } else {
- o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
- }
- if (unlikely(!o)) return 0;
- p = ((struct __pyx_memoryview_obj *)o);
- p->__pyx_vtab = __pyx_vtabptr_memoryview;
- p->obj = Py_None; Py_INCREF(Py_None);
- p->_size = Py_None; Py_INCREF(Py_None);
- p->_array_interface = Py_None; Py_INCREF(Py_None);
- p->view.obj = NULL;
- if (unlikely(__pyx_memoryview___cinit__(o, a, k) < 0)) goto bad;
- return o;
- bad:
- Py_DECREF(o); o = 0;
- return NULL;
-}
-
-static void __pyx_tp_dealloc_memoryview(PyObject *o) {
- struct __pyx_memoryview_obj *p = (struct __pyx_memoryview_obj *)o;
- #if CYTHON_USE_TP_FINALIZE
- if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
- if (PyObject_CallFinalizerFromDealloc(o)) return;
- }
- #endif
- PyObject_GC_UnTrack(o);
- {
- PyObject *etype, *eval, *etb;
- PyErr_Fetch(&etype, &eval, &etb);
- __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1);
- __pyx_memoryview___dealloc__(o);
- __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1);
- PyErr_Restore(etype, eval, etb);
- }
- Py_CLEAR(p->obj);
- Py_CLEAR(p->_size);
- Py_CLEAR(p->_array_interface);
- (*Py_TYPE(o)->tp_free)(o);
-}
-
-static int __pyx_tp_traverse_memoryview(PyObject *o, visitproc v, void *a) {
- int e;
- struct __pyx_memoryview_obj *p = (struct __pyx_memoryview_obj *)o;
- if (p->obj) {
- e = (*v)(p->obj, a); if (e) return e;
- }
- if (p->_size) {
- e = (*v)(p->_size, a); if (e) return e;
- }
- if (p->_array_interface) {
- e = (*v)(p->_array_interface, a); if (e) return e;
- }
- if (p->view.obj) {
- e = (*v)(p->view.obj, a); if (e) return e;
- }
- return 0;
-}
-
-static int __pyx_tp_clear_memoryview(PyObject *o) {
- PyObject* tmp;
- struct __pyx_memoryview_obj *p = (struct __pyx_memoryview_obj *)o;
- tmp = ((PyObject*)p->obj);
- p->obj = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->_size);
- p->_size = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- tmp = ((PyObject*)p->_array_interface);
- p->_array_interface = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- Py_CLEAR(p->view.obj);
- return 0;
-}
-static PyObject *__pyx_sq_item_memoryview(PyObject *o, Py_ssize_t i) {
- PyObject *r;
- PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
- r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
- Py_DECREF(x);
- return r;
-}
-
-static int __pyx_mp_ass_subscript_memoryview(PyObject *o, PyObject *i, PyObject *v) {
- if (v) {
- return __pyx_memoryview___setitem__(o, i, v);
- }
- else {
- PyErr_Format(PyExc_NotImplementedError,
- "Subscript deletion not supported by %.200s", Py_TYPE(o)->tp_name);
- return -1;
- }
-}
-
-static PyObject *__pyx_getprop___pyx_memoryview_T(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_15View_dot_MemoryView_10memoryview_1T_1__get__(o);
-}
-
-static PyObject *__pyx_getprop___pyx_memoryview_base(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_15View_dot_MemoryView_10memoryview_4base_1__get__(o);
-}
-
-static PyObject *__pyx_getprop___pyx_memoryview_shape(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_15View_dot_MemoryView_10memoryview_5shape_1__get__(o);
-}
-
-static PyObject *__pyx_getprop___pyx_memoryview_strides(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_15View_dot_MemoryView_10memoryview_7strides_1__get__(o);
-}
-
-static PyObject *__pyx_getprop___pyx_memoryview_suboffsets(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_15View_dot_MemoryView_10memoryview_10suboffsets_1__get__(o);
-}
-
-static PyObject *__pyx_getprop___pyx_memoryview_ndim(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_15View_dot_MemoryView_10memoryview_4ndim_1__get__(o);
-}
-
-static PyObject *__pyx_getprop___pyx_memoryview_itemsize(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_15View_dot_MemoryView_10memoryview_8itemsize_1__get__(o);
-}
-
-static PyObject *__pyx_getprop___pyx_memoryview_nbytes(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_15View_dot_MemoryView_10memoryview_6nbytes_1__get__(o);
-}
-
-static PyObject *__pyx_getprop___pyx_memoryview_size(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_15View_dot_MemoryView_10memoryview_4size_1__get__(o);
-}
-
-static PyMethodDef __pyx_methods_memoryview[] = {
- {"is_c_contig", (PyCFunction)__pyx_memoryview_is_c_contig, METH_NOARGS, 0},
- {"is_f_contig", (PyCFunction)__pyx_memoryview_is_f_contig, METH_NOARGS, 0},
- {"copy", (PyCFunction)__pyx_memoryview_copy, METH_NOARGS, 0},
- {"copy_fortran", (PyCFunction)__pyx_memoryview_copy_fortran, METH_NOARGS, 0},
- {"__reduce_cython__", (PyCFunction)__pyx_pw___pyx_memoryview_1__reduce_cython__, METH_NOARGS, 0},
- {"__setstate_cython__", (PyCFunction)__pyx_pw___pyx_memoryview_3__setstate_cython__, METH_O, 0},
- {0, 0, 0, 0}
-};
-
-static struct PyGetSetDef __pyx_getsets_memoryview[] = {
- {(char *)"T", __pyx_getprop___pyx_memoryview_T, 0, (char *)0, 0},
- {(char *)"base", __pyx_getprop___pyx_memoryview_base, 0, (char *)0, 0},
- {(char *)"shape", __pyx_getprop___pyx_memoryview_shape, 0, (char *)0, 0},
- {(char *)"strides", __pyx_getprop___pyx_memoryview_strides, 0, (char *)0, 0},
- {(char *)"suboffsets", __pyx_getprop___pyx_memoryview_suboffsets, 0, (char *)0, 0},
- {(char *)"ndim", __pyx_getprop___pyx_memoryview_ndim, 0, (char *)0, 0},
- {(char *)"itemsize", __pyx_getprop___pyx_memoryview_itemsize, 0, (char *)0, 0},
- {(char *)"nbytes", __pyx_getprop___pyx_memoryview_nbytes, 0, (char *)0, 0},
- {(char *)"size", __pyx_getprop___pyx_memoryview_size, 0, (char *)0, 0},
- {0, 0, 0, 0, 0}
-};
-
-static PySequenceMethods __pyx_tp_as_sequence_memoryview = {
- __pyx_memoryview___len__, /*sq_length*/
- 0, /*sq_concat*/
- 0, /*sq_repeat*/
- __pyx_sq_item_memoryview, /*sq_item*/
- 0, /*sq_slice*/
- 0, /*sq_ass_item*/
- 0, /*sq_ass_slice*/
- 0, /*sq_contains*/
- 0, /*sq_inplace_concat*/
- 0, /*sq_inplace_repeat*/
-};
-
-static PyMappingMethods __pyx_tp_as_mapping_memoryview = {
- __pyx_memoryview___len__, /*mp_length*/
- __pyx_memoryview___getitem__, /*mp_subscript*/
- __pyx_mp_ass_subscript_memoryview, /*mp_ass_subscript*/
-};
-
-static PyBufferProcs __pyx_tp_as_buffer_memoryview = {
- #if PY_MAJOR_VERSION < 3
- 0, /*bf_getreadbuffer*/
- #endif
- #if PY_MAJOR_VERSION < 3
- 0, /*bf_getwritebuffer*/
- #endif
- #if PY_MAJOR_VERSION < 3
- 0, /*bf_getsegcount*/
- #endif
- #if PY_MAJOR_VERSION < 3
- 0, /*bf_getcharbuffer*/
- #endif
- __pyx_memoryview_getbuffer, /*bf_getbuffer*/
- 0, /*bf_releasebuffer*/
-};
-
-static PyTypeObject __pyx_type___pyx_memoryview = {
- PyVarObject_HEAD_INIT(0, 0)
- "monotonic_align.core.memoryview", /*tp_name*/
- sizeof(struct __pyx_memoryview_obj), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc_memoryview, /*tp_dealloc*/
- #if PY_VERSION_HEX < 0x030800b4
- 0, /*tp_print*/
- #endif
- #if PY_VERSION_HEX >= 0x030800b4
- 0, /*tp_vectorcall_offset*/
- #endif
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- __pyx_memoryview___repr__, /*tp_repr*/
- 0, /*tp_as_number*/
- &__pyx_tp_as_sequence_memoryview, /*tp_as_sequence*/
- &__pyx_tp_as_mapping_memoryview, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- __pyx_memoryview___str__, /*tp_str*/
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- &__pyx_tp_as_buffer_memoryview, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- 0, /*tp_doc*/
- __pyx_tp_traverse_memoryview, /*tp_traverse*/
- __pyx_tp_clear_memoryview, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- __pyx_methods_memoryview, /*tp_methods*/
- 0, /*tp_members*/
- __pyx_getsets_memoryview, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- 0, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new_memoryview, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
- #if PY_VERSION_HEX >= 0x030800b1
- 0, /*tp_vectorcall*/
- #endif
- #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
- 0, /*tp_print*/
- #endif
-};
-static struct __pyx_vtabstruct__memoryviewslice __pyx_vtable__memoryviewslice;
-
-static PyObject *__pyx_tp_new__memoryviewslice(PyTypeObject *t, PyObject *a, PyObject *k) {
- struct __pyx_memoryviewslice_obj *p;
- PyObject *o = __pyx_tp_new_memoryview(t, a, k);
- if (unlikely(!o)) return 0;
- p = ((struct __pyx_memoryviewslice_obj *)o);
- p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_memoryview*)__pyx_vtabptr__memoryviewslice;
- p->from_object = Py_None; Py_INCREF(Py_None);
- p->from_slice.memview = NULL;
- return o;
-}
-
-static void __pyx_tp_dealloc__memoryviewslice(PyObject *o) {
- struct __pyx_memoryviewslice_obj *p = (struct __pyx_memoryviewslice_obj *)o;
- #if CYTHON_USE_TP_FINALIZE
- if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
- if (PyObject_CallFinalizerFromDealloc(o)) return;
- }
- #endif
- PyObject_GC_UnTrack(o);
- {
- PyObject *etype, *eval, *etb;
- PyErr_Fetch(&etype, &eval, &etb);
- __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1);
- __pyx_memoryviewslice___dealloc__(o);
- __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1);
- PyErr_Restore(etype, eval, etb);
- }
- Py_CLEAR(p->from_object);
- PyObject_GC_Track(o);
- __pyx_tp_dealloc_memoryview(o);
-}
-
-static int __pyx_tp_traverse__memoryviewslice(PyObject *o, visitproc v, void *a) {
- int e;
- struct __pyx_memoryviewslice_obj *p = (struct __pyx_memoryviewslice_obj *)o;
- e = __pyx_tp_traverse_memoryview(o, v, a); if (e) return e;
- if (p->from_object) {
- e = (*v)(p->from_object, a); if (e) return e;
- }
- return 0;
-}
-
-static int __pyx_tp_clear__memoryviewslice(PyObject *o) {
- PyObject* tmp;
- struct __pyx_memoryviewslice_obj *p = (struct __pyx_memoryviewslice_obj *)o;
- __pyx_tp_clear_memoryview(o);
- tmp = ((PyObject*)p->from_object);
- p->from_object = Py_None; Py_INCREF(Py_None);
- Py_XDECREF(tmp);
- __PYX_XDEC_MEMVIEW(&p->from_slice, 1);
- return 0;
-}
-
-static PyObject *__pyx_getprop___pyx_memoryviewslice_base(PyObject *o, CYTHON_UNUSED void *x) {
- return __pyx_pw_15View_dot_MemoryView_16_memoryviewslice_4base_1__get__(o);
-}
-
-static PyMethodDef __pyx_methods__memoryviewslice[] = {
- {"__reduce_cython__", (PyCFunction)__pyx_pw___pyx_memoryviewslice_1__reduce_cython__, METH_NOARGS, 0},
- {"__setstate_cython__", (PyCFunction)__pyx_pw___pyx_memoryviewslice_3__setstate_cython__, METH_O, 0},
- {0, 0, 0, 0}
-};
-
-static struct PyGetSetDef __pyx_getsets__memoryviewslice[] = {
- {(char *)"base", __pyx_getprop___pyx_memoryviewslice_base, 0, (char *)0, 0},
- {0, 0, 0, 0, 0}
-};
-
-static PyTypeObject __pyx_type___pyx_memoryviewslice = {
- PyVarObject_HEAD_INIT(0, 0)
- "monotonic_align.core._memoryviewslice", /*tp_name*/
- sizeof(struct __pyx_memoryviewslice_obj), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- __pyx_tp_dealloc__memoryviewslice, /*tp_dealloc*/
- #if PY_VERSION_HEX < 0x030800b4
- 0, /*tp_print*/
- #endif
- #if PY_VERSION_HEX >= 0x030800b4
- 0, /*tp_vectorcall_offset*/
- #endif
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- #if PY_MAJOR_VERSION < 3
- 0, /*tp_compare*/
- #endif
- #if PY_MAJOR_VERSION >= 3
- 0, /*tp_as_async*/
- #endif
- #if CYTHON_COMPILING_IN_PYPY
- __pyx_memoryview___repr__, /*tp_repr*/
- #else
- 0, /*tp_repr*/
- #endif
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- #if CYTHON_COMPILING_IN_PYPY
- __pyx_memoryview___str__, /*tp_str*/
- #else
- 0, /*tp_str*/
- #endif
- 0, /*tp_getattro*/
- 0, /*tp_setattro*/
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
- "Internal class for passing memoryview slices to Python", /*tp_doc*/
- __pyx_tp_traverse__memoryviewslice, /*tp_traverse*/
- __pyx_tp_clear__memoryviewslice, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- __pyx_methods__memoryviewslice, /*tp_methods*/
- 0, /*tp_members*/
- __pyx_getsets__memoryviewslice, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- 0, /*tp_init*/
- 0, /*tp_alloc*/
- __pyx_tp_new__memoryviewslice, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
- 0, /*tp_bases*/
- 0, /*tp_mro*/
- 0, /*tp_cache*/
- 0, /*tp_subclasses*/
- 0, /*tp_weaklist*/
- 0, /*tp_del*/
- 0, /*tp_version_tag*/
- #if PY_VERSION_HEX >= 0x030400a1
- 0, /*tp_finalize*/
- #endif
- #if PY_VERSION_HEX >= 0x030800b1
- 0, /*tp_vectorcall*/
- #endif
- #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
- 0, /*tp_print*/
- #endif
-};
-
-static PyMethodDef __pyx_methods[] = {
- {"maximum_path_c", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_15monotonic_align_4core_1maximum_path_c, METH_VARARGS|METH_KEYWORDS, 0},
- {0, 0, 0, 0}
-};
-
-#if PY_MAJOR_VERSION >= 3
-#if CYTHON_PEP489_MULTI_PHASE_INIT
-static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
-static int __pyx_pymod_exec_core(PyObject* module); /*proto*/
-static PyModuleDef_Slot __pyx_moduledef_slots[] = {
- {Py_mod_create, (void*)__pyx_pymod_create},
- {Py_mod_exec, (void*)__pyx_pymod_exec_core},
- {0, NULL}
-};
-#endif
-
-static struct PyModuleDef __pyx_moduledef = {
- PyModuleDef_HEAD_INIT,
- "core",
- 0, /* m_doc */
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- 0, /* m_size */
- #else
- -1, /* m_size */
- #endif
- __pyx_methods /* m_methods */,
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- __pyx_moduledef_slots, /* m_slots */
- #else
- NULL, /* m_reload */
- #endif
- NULL, /* m_traverse */
- NULL, /* m_clear */
- NULL /* m_free */
-};
-#endif
-#ifndef CYTHON_SMALL_CODE
-#if defined(__clang__)
- #define CYTHON_SMALL_CODE
-#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
- #define CYTHON_SMALL_CODE __attribute__((cold))
-#else
- #define CYTHON_SMALL_CODE
-#endif
-#endif
-
-static __Pyx_StringTabEntry __pyx_string_tab[] = {
- {&__pyx_n_s_ASCII, __pyx_k_ASCII, sizeof(__pyx_k_ASCII), 0, 0, 1, 1},
- {&__pyx_kp_s_Buffer_view_does_not_expose_stri, __pyx_k_Buffer_view_does_not_expose_stri, sizeof(__pyx_k_Buffer_view_does_not_expose_stri), 0, 0, 1, 0},
- {&__pyx_kp_s_Can_only_create_a_buffer_that_is, __pyx_k_Can_only_create_a_buffer_that_is, sizeof(__pyx_k_Can_only_create_a_buffer_that_is), 0, 0, 1, 0},
- {&__pyx_kp_s_Cannot_assign_to_read_only_memor, __pyx_k_Cannot_assign_to_read_only_memor, sizeof(__pyx_k_Cannot_assign_to_read_only_memor), 0, 0, 1, 0},
- {&__pyx_kp_s_Cannot_create_writable_memory_vi, __pyx_k_Cannot_create_writable_memory_vi, sizeof(__pyx_k_Cannot_create_writable_memory_vi), 0, 0, 1, 0},
- {&__pyx_kp_s_Cannot_index_with_type_s, __pyx_k_Cannot_index_with_type_s, sizeof(__pyx_k_Cannot_index_with_type_s), 0, 0, 1, 0},
- {&__pyx_n_s_Ellipsis, __pyx_k_Ellipsis, sizeof(__pyx_k_Ellipsis), 0, 0, 1, 1},
- {&__pyx_kp_s_Empty_shape_tuple_for_cython_arr, __pyx_k_Empty_shape_tuple_for_cython_arr, sizeof(__pyx_k_Empty_shape_tuple_for_cython_arr), 0, 0, 1, 0},
- {&__pyx_kp_s_Incompatible_checksums_s_vs_0xb0, __pyx_k_Incompatible_checksums_s_vs_0xb0, sizeof(__pyx_k_Incompatible_checksums_s_vs_0xb0), 0, 0, 1, 0},
- {&__pyx_n_s_IndexError, __pyx_k_IndexError, sizeof(__pyx_k_IndexError), 0, 0, 1, 1},
- {&__pyx_kp_s_Indirect_dimensions_not_supporte, __pyx_k_Indirect_dimensions_not_supporte, sizeof(__pyx_k_Indirect_dimensions_not_supporte), 0, 0, 1, 0},
- {&__pyx_kp_s_Invalid_mode_expected_c_or_fortr, __pyx_k_Invalid_mode_expected_c_or_fortr, sizeof(__pyx_k_Invalid_mode_expected_c_or_fortr), 0, 0, 1, 0},
- {&__pyx_kp_s_Invalid_shape_in_axis_d_d, __pyx_k_Invalid_shape_in_axis_d_d, sizeof(__pyx_k_Invalid_shape_in_axis_d_d), 0, 0, 1, 0},
- {&__pyx_n_s_MemoryError, __pyx_k_MemoryError, sizeof(__pyx_k_MemoryError), 0, 0, 1, 1},
- {&__pyx_kp_s_MemoryView_of_r_at_0x_x, __pyx_k_MemoryView_of_r_at_0x_x, sizeof(__pyx_k_MemoryView_of_r_at_0x_x), 0, 0, 1, 0},
- {&__pyx_kp_s_MemoryView_of_r_object, __pyx_k_MemoryView_of_r_object, sizeof(__pyx_k_MemoryView_of_r_object), 0, 0, 1, 0},
- {&__pyx_n_b_O, __pyx_k_O, sizeof(__pyx_k_O), 0, 0, 0, 1},
- {&__pyx_kp_s_Out_of_bounds_on_buffer_access_a, __pyx_k_Out_of_bounds_on_buffer_access_a, sizeof(__pyx_k_Out_of_bounds_on_buffer_access_a), 0, 0, 1, 0},
- {&__pyx_n_s_PickleError, __pyx_k_PickleError, sizeof(__pyx_k_PickleError), 0, 0, 1, 1},
- {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
- {&__pyx_kp_s_Unable_to_convert_item_to_object, __pyx_k_Unable_to_convert_item_to_object, sizeof(__pyx_k_Unable_to_convert_item_to_object), 0, 0, 1, 0},
- {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
- {&__pyx_n_s_View_MemoryView, __pyx_k_View_MemoryView, sizeof(__pyx_k_View_MemoryView), 0, 0, 1, 1},
- {&__pyx_n_s_allocate_buffer, __pyx_k_allocate_buffer, sizeof(__pyx_k_allocate_buffer), 0, 0, 1, 1},
- {&__pyx_n_s_base, __pyx_k_base, sizeof(__pyx_k_base), 0, 0, 1, 1},
- {&__pyx_n_s_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 0, 1, 1},
- {&__pyx_n_u_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 1, 0, 1},
- {&__pyx_n_s_class, __pyx_k_class, sizeof(__pyx_k_class), 0, 0, 1, 1},
- {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
- {&__pyx_kp_s_contiguous_and_direct, __pyx_k_contiguous_and_direct, sizeof(__pyx_k_contiguous_and_direct), 0, 0, 1, 0},
- {&__pyx_kp_s_contiguous_and_indirect, __pyx_k_contiguous_and_indirect, sizeof(__pyx_k_contiguous_and_indirect), 0, 0, 1, 0},
- {&__pyx_n_s_dict, __pyx_k_dict, sizeof(__pyx_k_dict), 0, 0, 1, 1},
- {&__pyx_n_s_dtype_is_object, __pyx_k_dtype_is_object, sizeof(__pyx_k_dtype_is_object), 0, 0, 1, 1},
- {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1},
- {&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1},
- {&__pyx_n_s_error, __pyx_k_error, sizeof(__pyx_k_error), 0, 0, 1, 1},
- {&__pyx_n_s_flags, __pyx_k_flags, sizeof(__pyx_k_flags), 0, 0, 1, 1},
- {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1},
- {&__pyx_n_s_fortran, __pyx_k_fortran, sizeof(__pyx_k_fortran), 0, 0, 1, 1},
- {&__pyx_n_u_fortran, __pyx_k_fortran, sizeof(__pyx_k_fortran), 0, 1, 0, 1},
- {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1},
- {&__pyx_kp_s_got_differing_extents_in_dimensi, __pyx_k_got_differing_extents_in_dimensi, sizeof(__pyx_k_got_differing_extents_in_dimensi), 0, 0, 1, 0},
- {&__pyx_n_s_id, __pyx_k_id, sizeof(__pyx_k_id), 0, 0, 1, 1},
- {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
- {&__pyx_n_s_itemsize, __pyx_k_itemsize, sizeof(__pyx_k_itemsize), 0, 0, 1, 1},
- {&__pyx_kp_s_itemsize_0_for_cython_array, __pyx_k_itemsize_0_for_cython_array, sizeof(__pyx_k_itemsize_0_for_cython_array), 0, 0, 1, 0},
- {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
- {&__pyx_n_s_memview, __pyx_k_memview, sizeof(__pyx_k_memview), 0, 0, 1, 1},
- {&__pyx_n_s_mode, __pyx_k_mode, sizeof(__pyx_k_mode), 0, 0, 1, 1},
- {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
- {&__pyx_n_s_name_2, __pyx_k_name_2, sizeof(__pyx_k_name_2), 0, 0, 1, 1},
- {&__pyx_n_s_ndim, __pyx_k_ndim, sizeof(__pyx_k_ndim), 0, 0, 1, 1},
- {&__pyx_n_s_new, __pyx_k_new, sizeof(__pyx_k_new), 0, 0, 1, 1},
- {&__pyx_kp_s_no_default___reduce___due_to_non, __pyx_k_no_default___reduce___due_to_non, sizeof(__pyx_k_no_default___reduce___due_to_non), 0, 0, 1, 0},
- {&__pyx_n_s_obj, __pyx_k_obj, sizeof(__pyx_k_obj), 0, 0, 1, 1},
- {&__pyx_n_s_pack, __pyx_k_pack, sizeof(__pyx_k_pack), 0, 0, 1, 1},
- {&__pyx_n_s_paths, __pyx_k_paths, sizeof(__pyx_k_paths), 0, 0, 1, 1},
- {&__pyx_n_s_pickle, __pyx_k_pickle, sizeof(__pyx_k_pickle), 0, 0, 1, 1},
- {&__pyx_n_s_pyx_PickleError, __pyx_k_pyx_PickleError, sizeof(__pyx_k_pyx_PickleError), 0, 0, 1, 1},
- {&__pyx_n_s_pyx_checksum, __pyx_k_pyx_checksum, sizeof(__pyx_k_pyx_checksum), 0, 0, 1, 1},
- {&__pyx_n_s_pyx_getbuffer, __pyx_k_pyx_getbuffer, sizeof(__pyx_k_pyx_getbuffer), 0, 0, 1, 1},
- {&__pyx_n_s_pyx_result, __pyx_k_pyx_result, sizeof(__pyx_k_pyx_result), 0, 0, 1, 1},
- {&__pyx_n_s_pyx_state, __pyx_k_pyx_state, sizeof(__pyx_k_pyx_state), 0, 0, 1, 1},
- {&__pyx_n_s_pyx_type, __pyx_k_pyx_type, sizeof(__pyx_k_pyx_type), 0, 0, 1, 1},
- {&__pyx_n_s_pyx_unpickle_Enum, __pyx_k_pyx_unpickle_Enum, sizeof(__pyx_k_pyx_unpickle_Enum), 0, 0, 1, 1},
- {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
- {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
- {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1},
- {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1},
- {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1},
- {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1},
- {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1},
- {&__pyx_n_s_shape, __pyx_k_shape, sizeof(__pyx_k_shape), 0, 0, 1, 1},
- {&__pyx_n_s_size, __pyx_k_size, sizeof(__pyx_k_size), 0, 0, 1, 1},
- {&__pyx_n_s_start, __pyx_k_start, sizeof(__pyx_k_start), 0, 0, 1, 1},
- {&__pyx_n_s_step, __pyx_k_step, sizeof(__pyx_k_step), 0, 0, 1, 1},
- {&__pyx_n_s_stop, __pyx_k_stop, sizeof(__pyx_k_stop), 0, 0, 1, 1},
- {&__pyx_kp_s_strided_and_direct, __pyx_k_strided_and_direct, sizeof(__pyx_k_strided_and_direct), 0, 0, 1, 0},
- {&__pyx_kp_s_strided_and_direct_or_indirect, __pyx_k_strided_and_direct_or_indirect, sizeof(__pyx_k_strided_and_direct_or_indirect), 0, 0, 1, 0},
- {&__pyx_kp_s_strided_and_indirect, __pyx_k_strided_and_indirect, sizeof(__pyx_k_strided_and_indirect), 0, 0, 1, 0},
- {&__pyx_kp_s_stringsource, __pyx_k_stringsource, sizeof(__pyx_k_stringsource), 0, 0, 1, 0},
- {&__pyx_n_s_struct, __pyx_k_struct, sizeof(__pyx_k_struct), 0, 0, 1, 1},
- {&__pyx_n_s_t_xs, __pyx_k_t_xs, sizeof(__pyx_k_t_xs), 0, 0, 1, 1},
- {&__pyx_n_s_t_ys, __pyx_k_t_ys, sizeof(__pyx_k_t_ys), 0, 0, 1, 1},
- {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
- {&__pyx_kp_s_unable_to_allocate_array_data, __pyx_k_unable_to_allocate_array_data, sizeof(__pyx_k_unable_to_allocate_array_data), 0, 0, 1, 0},
- {&__pyx_kp_s_unable_to_allocate_shape_and_str, __pyx_k_unable_to_allocate_shape_and_str, sizeof(__pyx_k_unable_to_allocate_shape_and_str), 0, 0, 1, 0},
- {&__pyx_n_s_unpack, __pyx_k_unpack, sizeof(__pyx_k_unpack), 0, 0, 1, 1},
- {&__pyx_n_s_update, __pyx_k_update, sizeof(__pyx_k_update), 0, 0, 1, 1},
- {&__pyx_n_s_values, __pyx_k_values, sizeof(__pyx_k_values), 0, 0, 1, 1},
- {0, 0, 0, 0, 0, 0, 0}
-};
-static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
- __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 15, __pyx_L1_error)
- __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(1, 133, __pyx_L1_error)
- __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(1, 148, __pyx_L1_error)
- __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(1, 151, __pyx_L1_error)
- __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(1, 2, __pyx_L1_error)
- __pyx_builtin_Ellipsis = __Pyx_GetBuiltinName(__pyx_n_s_Ellipsis); if (!__pyx_builtin_Ellipsis) __PYX_ERR(1, 404, __pyx_L1_error)
- __pyx_builtin_id = __Pyx_GetBuiltinName(__pyx_n_s_id); if (!__pyx_builtin_id) __PYX_ERR(1, 613, __pyx_L1_error)
- __pyx_builtin_IndexError = __Pyx_GetBuiltinName(__pyx_n_s_IndexError); if (!__pyx_builtin_IndexError) __PYX_ERR(1, 832, __pyx_L1_error)
- return 0;
- __pyx_L1_error:;
- return -1;
-}
-
-static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
-
- /* "View.MemoryView":133
- *
- * if not self.ndim:
- * raise ValueError("Empty shape tuple for cython.array") # <<<<<<<<<<<<<<
- *
- * if itemsize <= 0:
- */
- __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_Empty_shape_tuple_for_cython_arr); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(1, 133, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__2);
- __Pyx_GIVEREF(__pyx_tuple__2);
-
- /* "View.MemoryView":136
- *
- * if itemsize <= 0:
- * raise ValueError("itemsize <= 0 for cython.array") # <<<<<<<<<<<<<<
- *
- * if not isinstance(format, bytes):
- */
- __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_s_itemsize_0_for_cython_array); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(1, 136, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__3);
- __Pyx_GIVEREF(__pyx_tuple__3);
-
- /* "View.MemoryView":148
- *
- * if not self._shape:
- * raise MemoryError("unable to allocate shape and strides.") # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_shape_and_str); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(1, 148, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__4);
- __Pyx_GIVEREF(__pyx_tuple__4);
-
- /* "View.MemoryView":176
- * self.data = malloc(self.len)
- * if not self.data:
- * raise MemoryError("unable to allocate array data.") # <<<<<<<<<<<<<<
- *
- * if self.dtype_is_object:
- */
- __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_array_data); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(1, 176, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__5);
- __Pyx_GIVEREF(__pyx_tuple__5);
-
- /* "View.MemoryView":192
- * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS
- * if not (flags & bufmode):
- * raise ValueError("Can only create a buffer that is contiguous in memory.") # <<<<<<<<<<<<<<
- * info.buf = self.data
- * info.len = self.len
- */
- __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_s_Can_only_create_a_buffer_that_is); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(1, 192, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__6);
- __Pyx_GIVEREF(__pyx_tuple__6);
-
- /* "(tree fragment)":2
- * def __reduce_cython__(self):
- * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
- * def __setstate_cython__(self, __pyx_state):
- * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
- */
- __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(1, 2, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__7);
- __Pyx_GIVEREF(__pyx_tuple__7);
-
- /* "(tree fragment)":4
- * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
- * def __setstate_cython__(self, __pyx_state):
- * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
- */
- __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(1, 4, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__8);
- __Pyx_GIVEREF(__pyx_tuple__8);
-
- /* "View.MemoryView":418
- * def __setitem__(memoryview self, object index, object value):
- * if self.view.readonly:
- * raise TypeError("Cannot assign to read-only memoryview") # <<<<<<<<<<<<<<
- *
- * have_slices, index = _unellipsify(index, self.view.ndim)
- */
- __pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_s_Cannot_assign_to_read_only_memor); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(1, 418, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__9);
- __Pyx_GIVEREF(__pyx_tuple__9);
-
- /* "View.MemoryView":495
- * result = struct.unpack(self.view.format, bytesitem)
- * except struct.error:
- * raise ValueError("Unable to convert item to object") # <<<<<<<<<<<<<<
- * else:
- * if len(self.view.format) == 1:
- */
- __pyx_tuple__10 = PyTuple_Pack(1, __pyx_kp_s_Unable_to_convert_item_to_object); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(1, 495, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__10);
- __Pyx_GIVEREF(__pyx_tuple__10);
-
- /* "View.MemoryView":520
- * def __getbuffer__(self, Py_buffer *info, int flags):
- * if flags & PyBUF_WRITABLE and self.view.readonly:
- * raise ValueError("Cannot create writable memory view from read-only memoryview") # <<<<<<<<<<<<<<
- *
- * if flags & PyBUF_ND:
- */
- __pyx_tuple__11 = PyTuple_Pack(1, __pyx_kp_s_Cannot_create_writable_memory_vi); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(1, 520, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__11);
- __Pyx_GIVEREF(__pyx_tuple__11);
-
- /* "View.MemoryView":570
- * if self.view.strides == NULL:
- *
- * raise ValueError("Buffer view does not expose strides") # <<<<<<<<<<<<<<
- *
- * return tuple([stride for stride in self.view.strides[:self.view.ndim]])
- */
- __pyx_tuple__12 = PyTuple_Pack(1, __pyx_kp_s_Buffer_view_does_not_expose_stri); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(1, 570, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__12);
- __Pyx_GIVEREF(__pyx_tuple__12);
-
- /* "View.MemoryView":577
- * def suboffsets(self):
- * if self.view.suboffsets == NULL:
- * return (-1,) * self.view.ndim # <<<<<<<<<<<<<<
- *
- * return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]])
- */
- __pyx_tuple__13 = PyTuple_New(1); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(1, 577, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__13);
- __Pyx_INCREF(__pyx_int_neg_1);
- __Pyx_GIVEREF(__pyx_int_neg_1);
- PyTuple_SET_ITEM(__pyx_tuple__13, 0, __pyx_int_neg_1);
- __Pyx_GIVEREF(__pyx_tuple__13);
-
- /* "(tree fragment)":2
- * def __reduce_cython__(self):
- * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
- * def __setstate_cython__(self, __pyx_state):
- * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
- */
- __pyx_tuple__14 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(1, 2, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__14);
- __Pyx_GIVEREF(__pyx_tuple__14);
-
- /* "(tree fragment)":4
- * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
- * def __setstate_cython__(self, __pyx_state):
- * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
- */
- __pyx_tuple__15 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(1, 4, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__15);
- __Pyx_GIVEREF(__pyx_tuple__15);
-
- /* "View.MemoryView":682
- * if item is Ellipsis:
- * if not seen_ellipsis:
- * result.extend([slice(None)] * (ndim - len(tup) + 1)) # <<<<<<<<<<<<<<
- * seen_ellipsis = True
- * else:
- */
- __pyx_slice__16 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__16)) __PYX_ERR(1, 682, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_slice__16);
- __Pyx_GIVEREF(__pyx_slice__16);
-
- /* "View.MemoryView":703
- * for suboffset in suboffsets[:ndim]:
- * if suboffset >= 0:
- * raise ValueError("Indirect dimensions not supported") # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_tuple__17 = PyTuple_Pack(1, __pyx_kp_s_Indirect_dimensions_not_supporte); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(1, 703, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__17);
- __Pyx_GIVEREF(__pyx_tuple__17);
-
- /* "(tree fragment)":2
- * def __reduce_cython__(self):
- * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
- * def __setstate_cython__(self, __pyx_state):
- * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
- */
- __pyx_tuple__18 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(1, 2, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__18);
- __Pyx_GIVEREF(__pyx_tuple__18);
-
- /* "(tree fragment)":4
- * raise TypeError("no default __reduce__ due to non-trivial __cinit__")
- * def __setstate_cython__(self, __pyx_state):
- * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<<
- */
- __pyx_tuple__19 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(1, 4, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__19);
- __Pyx_GIVEREF(__pyx_tuple__19);
-
- /* "View.MemoryView":286
- * return self.name
- *
- * cdef generic = Enum("") # <<<<<<<<<<<<<<
- * cdef strided = Enum("") # default
- * cdef indirect = Enum("")
- */
- __pyx_tuple__20 = PyTuple_Pack(1, __pyx_kp_s_strided_and_direct_or_indirect); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(1, 286, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__20);
- __Pyx_GIVEREF(__pyx_tuple__20);
-
- /* "View.MemoryView":287
- *
- * cdef generic = Enum("")
- * cdef strided = Enum("") # default # <<<<<<<<<<<<<<
- * cdef indirect = Enum("")
- *
- */
- __pyx_tuple__21 = PyTuple_Pack(1, __pyx_kp_s_strided_and_direct); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(1, 287, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__21);
- __Pyx_GIVEREF(__pyx_tuple__21);
-
- /* "View.MemoryView":288
- * cdef generic = Enum("")
- * cdef strided = Enum("") # default
- * cdef indirect = Enum("") # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_tuple__22 = PyTuple_Pack(1, __pyx_kp_s_strided_and_indirect); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(1, 288, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__22);
- __Pyx_GIVEREF(__pyx_tuple__22);
-
- /* "View.MemoryView":291
- *
- *
- * cdef contiguous = Enum("") # <<<<<<<<<<<<<<
- * cdef indirect_contiguous = Enum("")
- *
- */
- __pyx_tuple__23 = PyTuple_Pack(1, __pyx_kp_s_contiguous_and_direct); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(1, 291, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__23);
- __Pyx_GIVEREF(__pyx_tuple__23);
-
- /* "View.MemoryView":292
- *
- * cdef contiguous = Enum("")
- * cdef indirect_contiguous = Enum("") # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_tuple__24 = PyTuple_Pack(1, __pyx_kp_s_contiguous_and_indirect); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(1, 292, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__24);
- __Pyx_GIVEREF(__pyx_tuple__24);
-
- /* "(tree fragment)":1
- * def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<<
- * cdef object __pyx_PickleError
- * cdef object __pyx_result
- */
- __pyx_tuple__25 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(1, 1, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_tuple__25);
- __Pyx_GIVEREF(__pyx_tuple__25);
- __pyx_codeobj__26 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__25, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_Enum, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__26)) __PYX_ERR(1, 1, __pyx_L1_error)
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
- /* InitThreads.init */
- #ifdef WITH_THREAD
-PyEval_InitThreads();
-#endif
-
-if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error)
-
- if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
- __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_int_184977713 = PyInt_FromLong(184977713L); if (unlikely(!__pyx_int_184977713)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) __PYX_ERR(0, 1, __pyx_L1_error)
- return 0;
- __pyx_L1_error:;
- return -1;
-}
-
-static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
-static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
-static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
-static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
-static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
-static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
-static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/
-
-static int __Pyx_modinit_global_init_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
- /*--- Global init code ---*/
- generic = Py_None; Py_INCREF(Py_None);
- strided = Py_None; Py_INCREF(Py_None);
- indirect = Py_None; Py_INCREF(Py_None);
- contiguous = Py_None; Py_INCREF(Py_None);
- indirect_contiguous = Py_None; Py_INCREF(Py_None);
- __Pyx_RefNannyFinishContext();
- return 0;
-}
-
-static int __Pyx_modinit_variable_export_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
- /*--- Variable export code ---*/
- __Pyx_RefNannyFinishContext();
- return 0;
-}
-
-static int __Pyx_modinit_function_export_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
- /*--- Function export code ---*/
- __Pyx_RefNannyFinishContext();
- return 0;
-}
-
-static int __Pyx_modinit_type_init_code(void) {
- __Pyx_RefNannyDeclarations
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
- /*--- Type init code ---*/
- __pyx_vtabptr_array = &__pyx_vtable_array;
- __pyx_vtable_array.get_memview = (PyObject *(*)(struct __pyx_array_obj *))__pyx_array_get_memview;
- if (PyType_Ready(&__pyx_type___pyx_array) < 0) __PYX_ERR(1, 105, __pyx_L1_error)
- #if PY_VERSION_HEX < 0x030800B1
- __pyx_type___pyx_array.tp_print = 0;
- #endif
- if (__Pyx_SetVtable(__pyx_type___pyx_array.tp_dict, __pyx_vtabptr_array) < 0) __PYX_ERR(1, 105, __pyx_L1_error)
- if (__Pyx_setup_reduce((PyObject*)&__pyx_type___pyx_array) < 0) __PYX_ERR(1, 105, __pyx_L1_error)
- __pyx_array_type = &__pyx_type___pyx_array;
- if (PyType_Ready(&__pyx_type___pyx_MemviewEnum) < 0) __PYX_ERR(1, 279, __pyx_L1_error)
- #if PY_VERSION_HEX < 0x030800B1
- __pyx_type___pyx_MemviewEnum.tp_print = 0;
- #endif
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type___pyx_MemviewEnum.tp_dictoffset && __pyx_type___pyx_MemviewEnum.tp_getattro == PyObject_GenericGetAttr)) {
- __pyx_type___pyx_MemviewEnum.tp_getattro = __Pyx_PyObject_GenericGetAttr;
- }
- if (__Pyx_setup_reduce((PyObject*)&__pyx_type___pyx_MemviewEnum) < 0) __PYX_ERR(1, 279, __pyx_L1_error)
- __pyx_MemviewEnum_type = &__pyx_type___pyx_MemviewEnum;
- __pyx_vtabptr_memoryview = &__pyx_vtable_memoryview;
- __pyx_vtable_memoryview.get_item_pointer = (char *(*)(struct __pyx_memoryview_obj *, PyObject *))__pyx_memoryview_get_item_pointer;
- __pyx_vtable_memoryview.is_slice = (PyObject *(*)(struct __pyx_memoryview_obj *, PyObject *))__pyx_memoryview_is_slice;
- __pyx_vtable_memoryview.setitem_slice_assignment = (PyObject *(*)(struct __pyx_memoryview_obj *, PyObject *, PyObject *))__pyx_memoryview_setitem_slice_assignment;
- __pyx_vtable_memoryview.setitem_slice_assign_scalar = (PyObject *(*)(struct __pyx_memoryview_obj *, struct __pyx_memoryview_obj *, PyObject *))__pyx_memoryview_setitem_slice_assign_scalar;
- __pyx_vtable_memoryview.setitem_indexed = (PyObject *(*)(struct __pyx_memoryview_obj *, PyObject *, PyObject *))__pyx_memoryview_setitem_indexed;
- __pyx_vtable_memoryview.convert_item_to_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *))__pyx_memoryview_convert_item_to_object;
- __pyx_vtable_memoryview.assign_item_from_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *, PyObject *))__pyx_memoryview_assign_item_from_object;
- if (PyType_Ready(&__pyx_type___pyx_memoryview) < 0) __PYX_ERR(1, 330, __pyx_L1_error)
- #if PY_VERSION_HEX < 0x030800B1
- __pyx_type___pyx_memoryview.tp_print = 0;
- #endif
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type___pyx_memoryview.tp_dictoffset && __pyx_type___pyx_memoryview.tp_getattro == PyObject_GenericGetAttr)) {
- __pyx_type___pyx_memoryview.tp_getattro = __Pyx_PyObject_GenericGetAttr;
- }
- if (__Pyx_SetVtable(__pyx_type___pyx_memoryview.tp_dict, __pyx_vtabptr_memoryview) < 0) __PYX_ERR(1, 330, __pyx_L1_error)
- if (__Pyx_setup_reduce((PyObject*)&__pyx_type___pyx_memoryview) < 0) __PYX_ERR(1, 330, __pyx_L1_error)
- __pyx_memoryview_type = &__pyx_type___pyx_memoryview;
- __pyx_vtabptr__memoryviewslice = &__pyx_vtable__memoryviewslice;
- __pyx_vtable__memoryviewslice.__pyx_base = *__pyx_vtabptr_memoryview;
- __pyx_vtable__memoryviewslice.__pyx_base.convert_item_to_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *))__pyx_memoryviewslice_convert_item_to_object;
- __pyx_vtable__memoryviewslice.__pyx_base.assign_item_from_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *, PyObject *))__pyx_memoryviewslice_assign_item_from_object;
- __pyx_type___pyx_memoryviewslice.tp_base = __pyx_memoryview_type;
- if (PyType_Ready(&__pyx_type___pyx_memoryviewslice) < 0) __PYX_ERR(1, 965, __pyx_L1_error)
- #if PY_VERSION_HEX < 0x030800B1
- __pyx_type___pyx_memoryviewslice.tp_print = 0;
- #endif
- if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type___pyx_memoryviewslice.tp_dictoffset && __pyx_type___pyx_memoryviewslice.tp_getattro == PyObject_GenericGetAttr)) {
- __pyx_type___pyx_memoryviewslice.tp_getattro = __Pyx_PyObject_GenericGetAttr;
- }
- if (__Pyx_SetVtable(__pyx_type___pyx_memoryviewslice.tp_dict, __pyx_vtabptr__memoryviewslice) < 0) __PYX_ERR(1, 965, __pyx_L1_error)
- if (__Pyx_setup_reduce((PyObject*)&__pyx_type___pyx_memoryviewslice) < 0) __PYX_ERR(1, 965, __pyx_L1_error)
- __pyx_memoryviewslice_type = &__pyx_type___pyx_memoryviewslice;
- __Pyx_RefNannyFinishContext();
- return 0;
- __pyx_L1_error:;
- __Pyx_RefNannyFinishContext();
- return -1;
-}
-
-static int __Pyx_modinit_type_import_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
- /*--- Type import code ---*/
- __Pyx_RefNannyFinishContext();
- return 0;
-}
-
-static int __Pyx_modinit_variable_import_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
- /*--- Variable import code ---*/
- __Pyx_RefNannyFinishContext();
- return 0;
-}
-
-static int __Pyx_modinit_function_import_code(void) {
- __Pyx_RefNannyDeclarations
- __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
- /*--- Function import code ---*/
- __Pyx_RefNannyFinishContext();
- return 0;
-}
-
-
-#ifndef CYTHON_NO_PYINIT_EXPORT
-#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
-#elif PY_MAJOR_VERSION < 3
-#ifdef __cplusplus
-#define __Pyx_PyMODINIT_FUNC extern "C" void
-#else
-#define __Pyx_PyMODINIT_FUNC void
-#endif
-#else
-#ifdef __cplusplus
-#define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
-#else
-#define __Pyx_PyMODINIT_FUNC PyObject *
-#endif
-#endif
-
-
-#if PY_MAJOR_VERSION < 3
-__Pyx_PyMODINIT_FUNC initcore(void) CYTHON_SMALL_CODE; /*proto*/
-__Pyx_PyMODINIT_FUNC initcore(void)
-#else
-__Pyx_PyMODINIT_FUNC PyInit_core(void) CYTHON_SMALL_CODE; /*proto*/
-__Pyx_PyMODINIT_FUNC PyInit_core(void)
-#if CYTHON_PEP489_MULTI_PHASE_INIT
-{
- return PyModuleDef_Init(&__pyx_moduledef);
-}
-static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
- #if PY_VERSION_HEX >= 0x030700A1
- static PY_INT64_T main_interpreter_id = -1;
- PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
- if (main_interpreter_id == -1) {
- main_interpreter_id = current_id;
- return (unlikely(current_id == -1)) ? -1 : 0;
- } else if (unlikely(main_interpreter_id != current_id))
- #else
- static PyInterpreterState *main_interpreter = NULL;
- PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
- if (!main_interpreter) {
- main_interpreter = current_interpreter;
- } else if (unlikely(main_interpreter != current_interpreter))
- #endif
- {
- PyErr_SetString(
- PyExc_ImportError,
- "Interpreter change detected - this module can only be loaded into one interpreter per process.");
- return -1;
- }
- return 0;
-}
-static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) {
- PyObject *value = PyObject_GetAttrString(spec, from_name);
- int result = 0;
- if (likely(value)) {
- if (allow_none || value != Py_None) {
- result = PyDict_SetItemString(moddict, to_name, value);
- }
- Py_DECREF(value);
- } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
- PyErr_Clear();
- } else {
- result = -1;
- }
- return result;
-}
-static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
- PyObject *module = NULL, *moddict, *modname;
- if (__Pyx_check_single_interpreter())
- return NULL;
- if (__pyx_m)
- return __Pyx_NewRef(__pyx_m);
- modname = PyObject_GetAttrString(spec, "name");
- if (unlikely(!modname)) goto bad;
- module = PyModule_NewObject(modname);
- Py_DECREF(modname);
- if (unlikely(!module)) goto bad;
- moddict = PyModule_GetDict(module);
- if (unlikely(!moddict)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
- if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
- return module;
-bad:
- Py_XDECREF(module);
- return NULL;
-}
-
-
-static CYTHON_SMALL_CODE int __pyx_pymod_exec_core(PyObject *__pyx_pyinit_module)
-#endif
-#endif
-{
- PyObject *__pyx_t_1 = NULL;
- static PyThread_type_lock __pyx_t_2[8];
- int __pyx_lineno = 0;
- const char *__pyx_filename = NULL;
- int __pyx_clineno = 0;
- __Pyx_RefNannyDeclarations
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- if (__pyx_m) {
- if (__pyx_m == __pyx_pyinit_module) return 0;
- PyErr_SetString(PyExc_RuntimeError, "Module 'core' has already been imported. Re-initialisation is not supported.");
- return -1;
- }
- #elif PY_MAJOR_VERSION >= 3
- if (__pyx_m) return __Pyx_NewRef(__pyx_m);
- #endif
- #if CYTHON_REFNANNY
-__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
-if (!__Pyx_RefNanny) {
- PyErr_Clear();
- __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
- if (!__Pyx_RefNanny)
- Py_FatalError("failed to import 'refnanny' module");
-}
-#endif
- __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_core(void)", 0);
- if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #ifdef __Pxy_PyFrame_Initialize_Offsets
- __Pxy_PyFrame_Initialize_Offsets();
- #endif
- __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
- __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
- #ifdef __Pyx_CyFunction_USED
- if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_FusedFunction_USED
- if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_Coroutine_USED
- if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_Generator_USED
- if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_AsyncGen_USED
- if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- #ifdef __Pyx_StopAsyncIteration_USED
- if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- /*--- Library function declarations ---*/
- /*--- Threads initialization code ---*/
- #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
- #ifdef WITH_THREAD /* Python build with threading support? */
- PyEval_InitThreads();
- #endif
- #endif
- /*--- Module creation code ---*/
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- __pyx_m = __pyx_pyinit_module;
- Py_INCREF(__pyx_m);
- #else
- #if PY_MAJOR_VERSION < 3
- __pyx_m = Py_InitModule4("core", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
- #else
- __pyx_m = PyModule_Create(&__pyx_moduledef);
- #endif
- if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_INCREF(__pyx_d);
- __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_INCREF(__pyx_b);
- __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
- Py_INCREF(__pyx_cython_runtime);
- if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
- /*--- Initialize various global constants etc. ---*/
- if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
- if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
- if (__pyx_module_is_main_monotonic_align__core) {
- if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name_2, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- }
- #if PY_MAJOR_VERSION >= 3
- {
- PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
- if (!PyDict_GetItemString(modules, "monotonic_align.core")) {
- if (unlikely(PyDict_SetItemString(modules, "monotonic_align.core", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
- }
- }
- #endif
- /*--- Builtin init code ---*/
- if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- /*--- Constants init code ---*/
- if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- /*--- Global type/function init code ---*/
- (void)__Pyx_modinit_global_init_code();
- (void)__Pyx_modinit_variable_export_code();
- (void)__Pyx_modinit_function_export_code();
- if (unlikely(__Pyx_modinit_type_init_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
- (void)__Pyx_modinit_type_import_code();
- (void)__Pyx_modinit_variable_import_code();
- (void)__Pyx_modinit_function_import_code();
- /*--- Execution code ---*/
- #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
- if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- #endif
-
- /* "monotonic_align/core.pyx":7
- * @cython.boundscheck(False)
- * @cython.wraparound(False)
- * cdef void maximum_path_each(int[:,::1] path, float[:,::1] value, int t_y, int t_x, float max_neg_val=-1e9) nogil: # <<<<<<<<<<<<<<
- * cdef int x
- * cdef int y
- */
- __pyx_k_ = (-1e9);
-
- /* "monotonic_align/core.pyx":1
- * cimport cython # <<<<<<<<<<<<<<
- * from cython.parallel import prange
- *
- */
- __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "View.MemoryView":209
- * info.obj = self
- *
- * __pyx_getbuffer = capsule( &__pyx_array_getbuffer, "getbuffer(obj, view, flags)") # <<<<<<<<<<<<<<
- *
- * def __dealloc__(array self):
- */
- __pyx_t_1 = __pyx_capsule_create(((void *)(&__pyx_array_getbuffer)), ((char *)"getbuffer(obj, view, flags)")); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 209, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem((PyObject *)__pyx_array_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_1) < 0) __PYX_ERR(1, 209, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- PyType_Modified(__pyx_array_type);
-
- /* "View.MemoryView":286
- * return self.name
- *
- * cdef generic = Enum("") # <<<<<<<<<<<<<<
- * cdef strided = Enum("") # default
- * cdef indirect = Enum("")
- */
- __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__20, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 286, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_XGOTREF(generic);
- __Pyx_DECREF_SET(generic, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "View.MemoryView":287
- *
- * cdef generic = Enum("")
- * cdef strided = Enum("") # default # <<<<<<<<<<<<<<
- * cdef indirect = Enum("")
- *
- */
- __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__21, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 287, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_XGOTREF(strided);
- __Pyx_DECREF_SET(strided, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "View.MemoryView":288
- * cdef generic = Enum("")
- * cdef strided = Enum("") # default
- * cdef indirect = Enum("") # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__22, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 288, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_XGOTREF(indirect);
- __Pyx_DECREF_SET(indirect, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "View.MemoryView":291
- *
- *
- * cdef contiguous = Enum("") # <<<<<<<<<<<<<<
- * cdef indirect_contiguous = Enum("")
- *
- */
- __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__23, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 291, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_XGOTREF(contiguous);
- __Pyx_DECREF_SET(contiguous, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "View.MemoryView":292
- *
- * cdef contiguous = Enum("")
- * cdef indirect_contiguous = Enum("") # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__24, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 292, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- __Pyx_XGOTREF(indirect_contiguous);
- __Pyx_DECREF_SET(indirect_contiguous, __pyx_t_1);
- __Pyx_GIVEREF(__pyx_t_1);
- __pyx_t_1 = 0;
-
- /* "View.MemoryView":316
- *
- * DEF THREAD_LOCKS_PREALLOCATED = 8
- * cdef int __pyx_memoryview_thread_locks_used = 0 # <<<<<<<<<<<<<<
- * cdef PyThread_type_lock[THREAD_LOCKS_PREALLOCATED] __pyx_memoryview_thread_locks = [
- * PyThread_allocate_lock(),
- */
- __pyx_memoryview_thread_locks_used = 0;
-
- /* "View.MemoryView":317
- * DEF THREAD_LOCKS_PREALLOCATED = 8
- * cdef int __pyx_memoryview_thread_locks_used = 0
- * cdef PyThread_type_lock[THREAD_LOCKS_PREALLOCATED] __pyx_memoryview_thread_locks = [ # <<<<<<<<<<<<<<
- * PyThread_allocate_lock(),
- * PyThread_allocate_lock(),
- */
- __pyx_t_2[0] = PyThread_allocate_lock();
- __pyx_t_2[1] = PyThread_allocate_lock();
- __pyx_t_2[2] = PyThread_allocate_lock();
- __pyx_t_2[3] = PyThread_allocate_lock();
- __pyx_t_2[4] = PyThread_allocate_lock();
- __pyx_t_2[5] = PyThread_allocate_lock();
- __pyx_t_2[6] = PyThread_allocate_lock();
- __pyx_t_2[7] = PyThread_allocate_lock();
- memcpy(&(__pyx_memoryview_thread_locks[0]), __pyx_t_2, sizeof(__pyx_memoryview_thread_locks[0]) * (8));
-
- /* "View.MemoryView":549
- * info.obj = self
- *
- * __pyx_getbuffer = capsule( &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)") # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_1 = __pyx_capsule_create(((void *)(&__pyx_memoryview_getbuffer)), ((char *)"getbuffer(obj, view, flags)")); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 549, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem((PyObject *)__pyx_memoryview_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_1) < 0) __PYX_ERR(1, 549, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- PyType_Modified(__pyx_memoryview_type);
-
- /* "View.MemoryView":995
- * return self.from_object
- *
- * __pyx_getbuffer = capsule( &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)") # <<<<<<<<<<<<<<
- *
- *
- */
- __pyx_t_1 = __pyx_capsule_create(((void *)(&__pyx_memoryview_getbuffer)), ((char *)"getbuffer(obj, view, flags)")); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 995, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem((PyObject *)__pyx_memoryviewslice_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_1) < 0) __PYX_ERR(1, 995, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- PyType_Modified(__pyx_memoryviewslice_type);
-
- /* "(tree fragment)":1
- * def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<<
- * cdef object __pyx_PickleError
- * cdef object __pyx_result
- */
- __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_15View_dot_MemoryView_1__pyx_unpickle_Enum, NULL, __pyx_n_s_View_MemoryView); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error)
- __Pyx_GOTREF(__pyx_t_1);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_Enum, __pyx_t_1) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
- __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
- /* "(tree fragment)":11
- * __pyx_unpickle_Enum__set_state( __pyx_result, __pyx_state)
- * return __pyx_result
- * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state): # <<<<<<<<<<<<<<
- * __pyx_result.name = __pyx_state[0]
- * if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'):
- */
-
- /*--- Wrapped vars code ---*/
-
- goto __pyx_L0;
- __pyx_L1_error:;
- __Pyx_XDECREF(__pyx_t_1);
- if (__pyx_m) {
- if (__pyx_d) {
- __Pyx_AddTraceback("init monotonic_align.core", __pyx_clineno, __pyx_lineno, __pyx_filename);
- }
- Py_CLEAR(__pyx_m);
- } else if (!PyErr_Occurred()) {
- PyErr_SetString(PyExc_ImportError, "init monotonic_align.core");
- }
- __pyx_L0:;
- __Pyx_RefNannyFinishContext();
- #if CYTHON_PEP489_MULTI_PHASE_INIT
- return (__pyx_m != NULL) ? 0 : -1;
- #elif PY_MAJOR_VERSION >= 3
- return __pyx_m;
- #else
- return;
- #endif
-}
-
-/* --- Runtime support code --- */
-/* Refnanny */
-#if CYTHON_REFNANNY
-static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
- PyObject *m = NULL, *p = NULL;
- void *r = NULL;
- m = PyImport_ImportModule(modname);
- if (!m) goto end;
- p = PyObject_GetAttrString(m, "RefNannyAPI");
- if (!p) goto end;
- r = PyLong_AsVoidPtr(p);
-end:
- Py_XDECREF(p);
- Py_XDECREF(m);
- return (__Pyx_RefNannyAPIStruct *)r;
-}
-#endif
-
-/* PyObjectGetAttrStr */
-#if CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
- PyTypeObject* tp = Py_TYPE(obj);
- if (likely(tp->tp_getattro))
- return tp->tp_getattro(obj, attr_name);
-#if PY_MAJOR_VERSION < 3
- if (likely(tp->tp_getattr))
- return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
-#endif
- return PyObject_GetAttr(obj, attr_name);
-}
-#endif
-
-/* GetBuiltinName */
-static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
- PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
- if (unlikely(!result)) {
- PyErr_Format(PyExc_NameError,
-#if PY_MAJOR_VERSION >= 3
- "name '%U' is not defined", name);
-#else
- "name '%.200s' is not defined", PyString_AS_STRING(name));
-#endif
- }
- return result;
-}
-
-/* MemviewSliceInit */
-static int
-__Pyx_init_memviewslice(struct __pyx_memoryview_obj *memview,
- int ndim,
- __Pyx_memviewslice *memviewslice,
- int memview_is_new_reference)
-{
- __Pyx_RefNannyDeclarations
- int i, retval=-1;
- Py_buffer *buf = &memview->view;
- __Pyx_RefNannySetupContext("init_memviewslice", 0);
- if (unlikely(memviewslice->memview || memviewslice->data)) {
- PyErr_SetString(PyExc_ValueError,
- "memviewslice is already initialized!");
- goto fail;
- }
- if (buf->strides) {
- for (i = 0; i < ndim; i++) {
- memviewslice->strides[i] = buf->strides[i];
- }
- } else {
- Py_ssize_t stride = buf->itemsize;
- for (i = ndim - 1; i >= 0; i--) {
- memviewslice->strides[i] = stride;
- stride *= buf->shape[i];
- }
- }
- for (i = 0; i < ndim; i++) {
- memviewslice->shape[i] = buf->shape[i];
- if (buf->suboffsets) {
- memviewslice->suboffsets[i] = buf->suboffsets[i];
- } else {
- memviewslice->suboffsets[i] = -1;
- }
- }
- memviewslice->memview = memview;
- memviewslice->data = (char *)buf->buf;
- if (__pyx_add_acquisition_count(memview) == 0 && !memview_is_new_reference) {
- Py_INCREF(memview);
- }
- retval = 0;
- goto no_fail;
-fail:
- memviewslice->memview = 0;
- memviewslice->data = 0;
- retval = -1;
-no_fail:
- __Pyx_RefNannyFinishContext();
- return retval;
-}
-#ifndef Py_NO_RETURN
-#define Py_NO_RETURN
-#endif
-static void __pyx_fatalerror(const char *fmt, ...) Py_NO_RETURN {
- va_list vargs;
- char msg[200];
-#ifdef HAVE_STDARG_PROTOTYPES
- va_start(vargs, fmt);
-#else
- va_start(vargs);
-#endif
- vsnprintf(msg, 200, fmt, vargs);
- va_end(vargs);
- Py_FatalError(msg);
-}
-static CYTHON_INLINE int
-__pyx_add_acquisition_count_locked(__pyx_atomic_int *acquisition_count,
- PyThread_type_lock lock)
-{
- int result;
- PyThread_acquire_lock(lock, 1);
- result = (*acquisition_count)++;
- PyThread_release_lock(lock);
- return result;
-}
-static CYTHON_INLINE int
-__pyx_sub_acquisition_count_locked(__pyx_atomic_int *acquisition_count,
- PyThread_type_lock lock)
-{
- int result;
- PyThread_acquire_lock(lock, 1);
- result = (*acquisition_count)--;
- PyThread_release_lock(lock);
- return result;
-}
-static CYTHON_INLINE void
-__Pyx_INC_MEMVIEW(__Pyx_memviewslice *memslice, int have_gil, int lineno)
-{
- int first_time;
- struct __pyx_memoryview_obj *memview = memslice->memview;
- if (unlikely(!memview || (PyObject *) memview == Py_None))
- return;
- if (unlikely(__pyx_get_slice_count(memview) < 0))
- __pyx_fatalerror("Acquisition count is %d (line %d)",
- __pyx_get_slice_count(memview), lineno);
- first_time = __pyx_add_acquisition_count(memview) == 0;
- if (unlikely(first_time)) {
- if (have_gil) {
- Py_INCREF((PyObject *) memview);
- } else {
- PyGILState_STATE _gilstate = PyGILState_Ensure();
- Py_INCREF((PyObject *) memview);
- PyGILState_Release(_gilstate);
- }
- }
-}
-static CYTHON_INLINE void __Pyx_XDEC_MEMVIEW(__Pyx_memviewslice *memslice,
- int have_gil, int lineno) {
- int last_time;
- struct __pyx_memoryview_obj *memview = memslice->memview;
- if (unlikely(!memview || (PyObject *) memview == Py_None)) {
- memslice->memview = NULL;
- return;
- }
- if (unlikely(__pyx_get_slice_count(memview) <= 0))
- __pyx_fatalerror("Acquisition count is %d (line %d)",
- __pyx_get_slice_count(memview), lineno);
- last_time = __pyx_sub_acquisition_count(memview) == 1;
- memslice->data = NULL;
- if (unlikely(last_time)) {
- if (have_gil) {
- Py_CLEAR(memslice->memview);
- } else {
- PyGILState_STATE _gilstate = PyGILState_Ensure();
- Py_CLEAR(memslice->memview);
- PyGILState_Release(_gilstate);
- }
- } else {
- memslice->memview = NULL;
- }
-}
-
-/* RaiseArgTupleInvalid */
-static void __Pyx_RaiseArgtupleInvalid(
- const char* func_name,
- int exact,
- Py_ssize_t num_min,
- Py_ssize_t num_max,
- Py_ssize_t num_found)
-{
- Py_ssize_t num_expected;
- const char *more_or_less;
- if (num_found < num_min) {
- num_expected = num_min;
- more_or_less = "at least";
- } else {
- num_expected = num_max;
- more_or_less = "at most";
- }
- if (exact) {
- more_or_less = "exactly";
- }
- PyErr_Format(PyExc_TypeError,
- "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
- func_name, more_or_less, num_expected,
- (num_expected == 1) ? "" : "s", num_found);
-}
-
-/* RaiseDoubleKeywords */
-static void __Pyx_RaiseDoubleKeywordsError(
- const char* func_name,
- PyObject* kw_name)
-{
- PyErr_Format(PyExc_TypeError,
- #if PY_MAJOR_VERSION >= 3
- "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
- #else
- "%s() got multiple values for keyword argument '%s'", func_name,
- PyString_AsString(kw_name));
- #endif
-}
-
-/* ParseKeywords */
-static int __Pyx_ParseOptionalKeywords(
- PyObject *kwds,
- PyObject **argnames[],
- PyObject *kwds2,
- PyObject *values[],
- Py_ssize_t num_pos_args,
- const char* function_name)
-{
- PyObject *key = 0, *value = 0;
- Py_ssize_t pos = 0;
- PyObject*** name;
- PyObject*** first_kw_arg = argnames + num_pos_args;
- while (PyDict_Next(kwds, &pos, &key, &value)) {
- name = first_kw_arg;
- while (*name && (**name != key)) name++;
- if (*name) {
- values[name-argnames] = value;
- continue;
- }
- name = first_kw_arg;
- #if PY_MAJOR_VERSION < 3
- if (likely(PyString_Check(key))) {
- while (*name) {
- if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
- && _PyString_Eq(**name, key)) {
- values[name-argnames] = value;
- break;
- }
- name++;
- }
- if (*name) continue;
- else {
- PyObject*** argname = argnames;
- while (argname != first_kw_arg) {
- if ((**argname == key) || (
- (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
- && _PyString_Eq(**argname, key))) {
- goto arg_passed_twice;
- }
- argname++;
- }
- }
- } else
- #endif
- if (likely(PyUnicode_Check(key))) {
- while (*name) {
- int cmp = (**name == key) ? 0 :
- #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
- (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
- #endif
- PyUnicode_Compare(**name, key);
- if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
- if (cmp == 0) {
- values[name-argnames] = value;
- break;
- }
- name++;
- }
- if (*name) continue;
- else {
- PyObject*** argname = argnames;
- while (argname != first_kw_arg) {
- int cmp = (**argname == key) ? 0 :
- #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
- (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
- #endif
- PyUnicode_Compare(**argname, key);
- if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
- if (cmp == 0) goto arg_passed_twice;
- argname++;
- }
- }
- } else
- goto invalid_keyword_type;
- if (kwds2) {
- if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
- } else {
- goto invalid_keyword;
- }
- }
- return 0;
-arg_passed_twice:
- __Pyx_RaiseDoubleKeywordsError(function_name, key);
- goto bad;
-invalid_keyword_type:
- PyErr_Format(PyExc_TypeError,
- "%.200s() keywords must be strings", function_name);
- goto bad;
-invalid_keyword:
- PyErr_Format(PyExc_TypeError,
- #if PY_MAJOR_VERSION < 3
- "%.200s() got an unexpected keyword argument '%.200s'",
- function_name, PyString_AsString(key));
- #else
- "%s() got an unexpected keyword argument '%U'",
- function_name, key);
- #endif
-bad:
- return -1;
-}
-
-/* None */
-static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) {
- PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname);
-}
-
-/* ArgTypeTest */
-static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact)
-{
- if (unlikely(!type)) {
- PyErr_SetString(PyExc_SystemError, "Missing type object");
- return 0;
- }
- else if (exact) {
- #if PY_MAJOR_VERSION == 2
- if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
- #endif
- }
- else {
- if (likely(__Pyx_TypeCheck(obj, type))) return 1;
- }
- PyErr_Format(PyExc_TypeError,
- "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
- name, type->tp_name, Py_TYPE(obj)->tp_name);
- return 0;
-}
-
-/* PyObjectCall */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
- PyObject *result;
- ternaryfunc call = func->ob_type->tp_call;
- if (unlikely(!call))
- return PyObject_Call(func, arg, kw);
- if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
- return NULL;
- result = (*call)(func, arg, kw);
- Py_LeaveRecursiveCall();
- if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
- PyErr_SetString(
- PyExc_SystemError,
- "NULL result without error in PyObject_Call");
- }
- return result;
-}
-#endif
-
-/* PyErrFetchRestore */
-#if CYTHON_FAST_THREAD_STATE
-static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- tmp_type = tstate->curexc_type;
- tmp_value = tstate->curexc_value;
- tmp_tb = tstate->curexc_traceback;
- tstate->curexc_type = type;
- tstate->curexc_value = value;
- tstate->curexc_traceback = tb;
- Py_XDECREF(tmp_type);
- Py_XDECREF(tmp_value);
- Py_XDECREF(tmp_tb);
-}
-static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
- *type = tstate->curexc_type;
- *value = tstate->curexc_value;
- *tb = tstate->curexc_traceback;
- tstate->curexc_type = 0;
- tstate->curexc_value = 0;
- tstate->curexc_traceback = 0;
-}
-#endif
-
-/* RaiseException */
-#if PY_MAJOR_VERSION < 3
-static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
- CYTHON_UNUSED PyObject *cause) {
- __Pyx_PyThreadState_declare
- Py_XINCREF(type);
- if (!value || value == Py_None)
- value = NULL;
- else
- Py_INCREF(value);
- if (!tb || tb == Py_None)
- tb = NULL;
- else {
- Py_INCREF(tb);
- if (!PyTraceBack_Check(tb)) {
- PyErr_SetString(PyExc_TypeError,
- "raise: arg 3 must be a traceback or None");
- goto raise_error;
- }
- }
- if (PyType_Check(type)) {
-#if CYTHON_COMPILING_IN_PYPY
- if (!value) {
- Py_INCREF(Py_None);
- value = Py_None;
- }
-#endif
- PyErr_NormalizeException(&type, &value, &tb);
- } else {
- if (value) {
- PyErr_SetString(PyExc_TypeError,
- "instance exception may not have a separate value");
- goto raise_error;
- }
- value = type;
- type = (PyObject*) Py_TYPE(type);
- Py_INCREF(type);
- if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
- PyErr_SetString(PyExc_TypeError,
- "raise: exception class must be a subclass of BaseException");
- goto raise_error;
- }
- }
- __Pyx_PyThreadState_assign
- __Pyx_ErrRestore(type, value, tb);
- return;
-raise_error:
- Py_XDECREF(value);
- Py_XDECREF(type);
- Py_XDECREF(tb);
- return;
-}
-#else
-static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
- PyObject* owned_instance = NULL;
- if (tb == Py_None) {
- tb = 0;
- } else if (tb && !PyTraceBack_Check(tb)) {
- PyErr_SetString(PyExc_TypeError,
- "raise: arg 3 must be a traceback or None");
- goto bad;
- }
- if (value == Py_None)
- value = 0;
- if (PyExceptionInstance_Check(type)) {
- if (value) {
- PyErr_SetString(PyExc_TypeError,
- "instance exception may not have a separate value");
- goto bad;
- }
- value = type;
- type = (PyObject*) Py_TYPE(value);
- } else if (PyExceptionClass_Check(type)) {
- PyObject *instance_class = NULL;
- if (value && PyExceptionInstance_Check(value)) {
- instance_class = (PyObject*) Py_TYPE(value);
- if (instance_class != type) {
- int is_subclass = PyObject_IsSubclass(instance_class, type);
- if (!is_subclass) {
- instance_class = NULL;
- } else if (unlikely(is_subclass == -1)) {
- goto bad;
- } else {
- type = instance_class;
- }
- }
- }
- if (!instance_class) {
- PyObject *args;
- if (!value)
- args = PyTuple_New(0);
- else if (PyTuple_Check(value)) {
- Py_INCREF(value);
- args = value;
- } else
- args = PyTuple_Pack(1, value);
- if (!args)
- goto bad;
- owned_instance = PyObject_Call(type, args, NULL);
- Py_DECREF(args);
- if (!owned_instance)
- goto bad;
- value = owned_instance;
- if (!PyExceptionInstance_Check(value)) {
- PyErr_Format(PyExc_TypeError,
- "calling %R should have returned an instance of "
- "BaseException, not %R",
- type, Py_TYPE(value));
- goto bad;
- }
- }
- } else {
- PyErr_SetString(PyExc_TypeError,
- "raise: exception class must be a subclass of BaseException");
- goto bad;
- }
- if (cause) {
- PyObject *fixed_cause;
- if (cause == Py_None) {
- fixed_cause = NULL;
- } else if (PyExceptionClass_Check(cause)) {
- fixed_cause = PyObject_CallObject(cause, NULL);
- if (fixed_cause == NULL)
- goto bad;
- } else if (PyExceptionInstance_Check(cause)) {
- fixed_cause = cause;
- Py_INCREF(fixed_cause);
- } else {
- PyErr_SetString(PyExc_TypeError,
- "exception causes must derive from "
- "BaseException");
- goto bad;
- }
- PyException_SetCause(value, fixed_cause);
- }
- PyErr_SetObject(type, value);
- if (tb) {
-#if CYTHON_COMPILING_IN_PYPY
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
- Py_INCREF(tb);
- PyErr_Restore(tmp_type, tmp_value, tb);
- Py_XDECREF(tmp_tb);
-#else
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- PyObject* tmp_tb = tstate->curexc_traceback;
- if (tb != tmp_tb) {
- Py_INCREF(tb);
- tstate->curexc_traceback = tb;
- Py_XDECREF(tmp_tb);
- }
-#endif
- }
-bad:
- Py_XDECREF(owned_instance);
- return;
-}
-#endif
-
-/* PyCFunctionFastCall */
-#if CYTHON_FAST_PYCCALL
-static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
- PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
- PyCFunction meth = PyCFunction_GET_FUNCTION(func);
- PyObject *self = PyCFunction_GET_SELF(func);
- int flags = PyCFunction_GET_FLAGS(func);
- assert(PyCFunction_Check(func));
- assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)));
- assert(nargs >= 0);
- assert(nargs == 0 || args != NULL);
- /* _PyCFunction_FastCallDict() must not be called with an exception set,
- because it may clear it (directly or indirectly) and so the
- caller loses its exception */
- assert(!PyErr_Occurred());
- if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
- return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL);
- } else {
- return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs);
- }
-}
-#endif
-
-/* PyFunctionFastCall */
-#if CYTHON_FAST_PYCALL
-static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
- PyObject *globals) {
- PyFrameObject *f;
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- PyObject **fastlocals;
- Py_ssize_t i;
- PyObject *result;
- assert(globals != NULL);
- /* XXX Perhaps we should create a specialized
- PyFrame_New() that doesn't take locals, but does
- take builtins without sanity checking them.
- */
- assert(tstate != NULL);
- f = PyFrame_New(tstate, co, globals, NULL);
- if (f == NULL) {
- return NULL;
- }
- fastlocals = __Pyx_PyFrame_GetLocalsplus(f);
- for (i = 0; i < na; i++) {
- Py_INCREF(*args);
- fastlocals[i] = *args++;
- }
- result = PyEval_EvalFrameEx(f,0);
- ++tstate->recursion_depth;
- Py_DECREF(f);
- --tstate->recursion_depth;
- return result;
-}
-#if 1 || PY_VERSION_HEX < 0x030600B1
-static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) {
- PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
- PyObject *globals = PyFunction_GET_GLOBALS(func);
- PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
- PyObject *closure;
-#if PY_MAJOR_VERSION >= 3
- PyObject *kwdefs;
-#endif
- PyObject *kwtuple, **k;
- PyObject **d;
- Py_ssize_t nd;
- Py_ssize_t nk;
- PyObject *result;
- assert(kwargs == NULL || PyDict_Check(kwargs));
- nk = kwargs ? PyDict_Size(kwargs) : 0;
- if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
- return NULL;
- }
- if (
-#if PY_MAJOR_VERSION >= 3
- co->co_kwonlyargcount == 0 &&
-#endif
- likely(kwargs == NULL || nk == 0) &&
- co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
- if (argdefs == NULL && co->co_argcount == nargs) {
- result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
- goto done;
- }
- else if (nargs == 0 && argdefs != NULL
- && co->co_argcount == Py_SIZE(argdefs)) {
- /* function called with no arguments, but all parameters have
- a default value: use default values as arguments .*/
- args = &PyTuple_GET_ITEM(argdefs, 0);
- result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
- goto done;
- }
- }
- if (kwargs != NULL) {
- Py_ssize_t pos, i;
- kwtuple = PyTuple_New(2 * nk);
- if (kwtuple == NULL) {
- result = NULL;
- goto done;
- }
- k = &PyTuple_GET_ITEM(kwtuple, 0);
- pos = i = 0;
- while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
- Py_INCREF(k[i]);
- Py_INCREF(k[i+1]);
- i += 2;
- }
- nk = i / 2;
- }
- else {
- kwtuple = NULL;
- k = NULL;
- }
- closure = PyFunction_GET_CLOSURE(func);
-#if PY_MAJOR_VERSION >= 3
- kwdefs = PyFunction_GET_KW_DEFAULTS(func);
-#endif
- if (argdefs != NULL) {
- d = &PyTuple_GET_ITEM(argdefs, 0);
- nd = Py_SIZE(argdefs);
- }
- else {
- d = NULL;
- nd = 0;
- }
-#if PY_MAJOR_VERSION >= 3
- result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
- args, (int)nargs,
- k, (int)nk,
- d, (int)nd, kwdefs, closure);
-#else
- result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
- args, (int)nargs,
- k, (int)nk,
- d, (int)nd, closure);
-#endif
- Py_XDECREF(kwtuple);
-done:
- Py_LeaveRecursiveCall();
- return result;
-}
-#endif
-#endif
-
-/* PyObjectCall2Args */
-static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) {
- PyObject *args, *result = NULL;
- #if CYTHON_FAST_PYCALL
- if (PyFunction_Check(function)) {
- PyObject *args[2] = {arg1, arg2};
- return __Pyx_PyFunction_FastCall(function, args, 2);
- }
- #endif
- #if CYTHON_FAST_PYCCALL
- if (__Pyx_PyFastCFunction_Check(function)) {
- PyObject *args[2] = {arg1, arg2};
- return __Pyx_PyCFunction_FastCall(function, args, 2);
- }
- #endif
- args = PyTuple_New(2);
- if (unlikely(!args)) goto done;
- Py_INCREF(arg1);
- PyTuple_SET_ITEM(args, 0, arg1);
- Py_INCREF(arg2);
- PyTuple_SET_ITEM(args, 1, arg2);
- Py_INCREF(function);
- result = __Pyx_PyObject_Call(function, args, NULL);
- Py_DECREF(args);
- Py_DECREF(function);
-done:
- return result;
-}
-
-/* PyObjectCallMethO */
-#if CYTHON_COMPILING_IN_CPYTHON
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
- PyObject *self, *result;
- PyCFunction cfunc;
- cfunc = PyCFunction_GET_FUNCTION(func);
- self = PyCFunction_GET_SELF(func);
- if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
- return NULL;
- result = cfunc(self, arg);
- Py_LeaveRecursiveCall();
- if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
- PyErr_SetString(
- PyExc_SystemError,
- "NULL result without error in PyObject_Call");
- }
- return result;
-}
-#endif
-
-/* PyObjectCallOneArg */
-#if CYTHON_COMPILING_IN_CPYTHON
-static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
- PyObject *result;
- PyObject *args = PyTuple_New(1);
- if (unlikely(!args)) return NULL;
- Py_INCREF(arg);
- PyTuple_SET_ITEM(args, 0, arg);
- result = __Pyx_PyObject_Call(func, args, NULL);
- Py_DECREF(args);
- return result;
-}
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
-#if CYTHON_FAST_PYCALL
- if (PyFunction_Check(func)) {
- return __Pyx_PyFunction_FastCall(func, &arg, 1);
- }
-#endif
- if (likely(PyCFunction_Check(func))) {
- if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
- return __Pyx_PyObject_CallMethO(func, arg);
-#if CYTHON_FAST_PYCCALL
- } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
- return __Pyx_PyCFunction_FastCall(func, &arg, 1);
-#endif
- }
- }
- return __Pyx__PyObject_CallOneArg(func, arg);
-}
-#else
-static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
- PyObject *result;
- PyObject *args = PyTuple_Pack(1, arg);
- if (unlikely(!args)) return NULL;
- result = __Pyx_PyObject_Call(func, args, NULL);
- Py_DECREF(args);
- return result;
-}
-#endif
-
-/* BytesEquals */
-static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
-#if CYTHON_COMPILING_IN_PYPY
- return PyObject_RichCompareBool(s1, s2, equals);
-#else
- if (s1 == s2) {
- return (equals == Py_EQ);
- } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
- const char *ps1, *ps2;
- Py_ssize_t length = PyBytes_GET_SIZE(s1);
- if (length != PyBytes_GET_SIZE(s2))
- return (equals == Py_NE);
- ps1 = PyBytes_AS_STRING(s1);
- ps2 = PyBytes_AS_STRING(s2);
- if (ps1[0] != ps2[0]) {
- return (equals == Py_NE);
- } else if (length == 1) {
- return (equals == Py_EQ);
- } else {
- int result;
-#if CYTHON_USE_UNICODE_INTERNALS
- Py_hash_t hash1, hash2;
- hash1 = ((PyBytesObject*)s1)->ob_shash;
- hash2 = ((PyBytesObject*)s2)->ob_shash;
- if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
- return (equals == Py_NE);
- }
-#endif
- result = memcmp(ps1, ps2, (size_t)length);
- return (equals == Py_EQ) ? (result == 0) : (result != 0);
- }
- } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
- return (equals == Py_NE);
- } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
- return (equals == Py_NE);
- } else {
- int result;
- PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
- if (!py_result)
- return -1;
- result = __Pyx_PyObject_IsTrue(py_result);
- Py_DECREF(py_result);
- return result;
- }
-#endif
-}
-
-/* UnicodeEquals */
-static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
-#if CYTHON_COMPILING_IN_PYPY
- return PyObject_RichCompareBool(s1, s2, equals);
-#else
-#if PY_MAJOR_VERSION < 3
- PyObject* owned_ref = NULL;
-#endif
- int s1_is_unicode, s2_is_unicode;
- if (s1 == s2) {
- goto return_eq;
- }
- s1_is_unicode = PyUnicode_CheckExact(s1);
- s2_is_unicode = PyUnicode_CheckExact(s2);
-#if PY_MAJOR_VERSION < 3
- if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) {
- owned_ref = PyUnicode_FromObject(s2);
- if (unlikely(!owned_ref))
- return -1;
- s2 = owned_ref;
- s2_is_unicode = 1;
- } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) {
- owned_ref = PyUnicode_FromObject(s1);
- if (unlikely(!owned_ref))
- return -1;
- s1 = owned_ref;
- s1_is_unicode = 1;
- } else if (((!s2_is_unicode) & (!s1_is_unicode))) {
- return __Pyx_PyBytes_Equals(s1, s2, equals);
- }
-#endif
- if (s1_is_unicode & s2_is_unicode) {
- Py_ssize_t length;
- int kind;
- void *data1, *data2;
- if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0))
- return -1;
- length = __Pyx_PyUnicode_GET_LENGTH(s1);
- if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) {
- goto return_ne;
- }
-#if CYTHON_USE_UNICODE_INTERNALS
- {
- Py_hash_t hash1, hash2;
- #if CYTHON_PEP393_ENABLED
- hash1 = ((PyASCIIObject*)s1)->hash;
- hash2 = ((PyASCIIObject*)s2)->hash;
- #else
- hash1 = ((PyUnicodeObject*)s1)->hash;
- hash2 = ((PyUnicodeObject*)s2)->hash;
- #endif
- if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
- goto return_ne;
- }
- }
-#endif
- kind = __Pyx_PyUnicode_KIND(s1);
- if (kind != __Pyx_PyUnicode_KIND(s2)) {
- goto return_ne;
- }
- data1 = __Pyx_PyUnicode_DATA(s1);
- data2 = __Pyx_PyUnicode_DATA(s2);
- if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
- goto return_ne;
- } else if (length == 1) {
- goto return_eq;
- } else {
- int result = memcmp(data1, data2, (size_t)(length * kind));
- #if PY_MAJOR_VERSION < 3
- Py_XDECREF(owned_ref);
- #endif
- return (equals == Py_EQ) ? (result == 0) : (result != 0);
- }
- } else if ((s1 == Py_None) & s2_is_unicode) {
- goto return_ne;
- } else if ((s2 == Py_None) & s1_is_unicode) {
- goto return_ne;
- } else {
- int result;
- PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
- #if PY_MAJOR_VERSION < 3
- Py_XDECREF(owned_ref);
- #endif
- if (!py_result)
- return -1;
- result = __Pyx_PyObject_IsTrue(py_result);
- Py_DECREF(py_result);
- return result;
- }
-return_eq:
- #if PY_MAJOR_VERSION < 3
- Py_XDECREF(owned_ref);
- #endif
- return (equals == Py_EQ);
-return_ne:
- #if PY_MAJOR_VERSION < 3
- Py_XDECREF(owned_ref);
- #endif
- return (equals == Py_NE);
-#endif
-}
-
-/* None */
-static CYTHON_INLINE Py_ssize_t __Pyx_div_Py_ssize_t(Py_ssize_t a, Py_ssize_t b) {
- Py_ssize_t q = a / b;
- Py_ssize_t r = a - q*b;
- q -= ((r != 0) & ((r ^ b) < 0));
- return q;
-}
-
-/* GetAttr */
-static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
-#if CYTHON_USE_TYPE_SLOTS
-#if PY_MAJOR_VERSION >= 3
- if (likely(PyUnicode_Check(n)))
-#else
- if (likely(PyString_Check(n)))
-#endif
- return __Pyx_PyObject_GetAttrStr(o, n);
-#endif
- return PyObject_GetAttr(o, n);
-}
-
-/* GetItemInt */
-static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
- PyObject *r;
- if (!j) return NULL;
- r = PyObject_GetItem(o, j);
- Py_DECREF(j);
- return r;
-}
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
- CYTHON_NCP_UNUSED int wraparound,
- CYTHON_NCP_UNUSED int boundscheck) {
-#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- Py_ssize_t wrapped_i = i;
- if (wraparound & unlikely(i < 0)) {
- wrapped_i += PyList_GET_SIZE(o);
- }
- if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) {
- PyObject *r = PyList_GET_ITEM(o, wrapped_i);
- Py_INCREF(r);
- return r;
- }
- return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
-#else
- return PySequence_GetItem(o, i);
-#endif
-}
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
- CYTHON_NCP_UNUSED int wraparound,
- CYTHON_NCP_UNUSED int boundscheck) {
-#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- Py_ssize_t wrapped_i = i;
- if (wraparound & unlikely(i < 0)) {
- wrapped_i += PyTuple_GET_SIZE(o);
- }
- if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) {
- PyObject *r = PyTuple_GET_ITEM(o, wrapped_i);
- Py_INCREF(r);
- return r;
- }
- return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
-#else
- return PySequence_GetItem(o, i);
-#endif
-}
-static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
- CYTHON_NCP_UNUSED int wraparound,
- CYTHON_NCP_UNUSED int boundscheck) {
-#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
- if (is_list || PyList_CheckExact(o)) {
- Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
- if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) {
- PyObject *r = PyList_GET_ITEM(o, n);
- Py_INCREF(r);
- return r;
- }
- }
- else if (PyTuple_CheckExact(o)) {
- Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
- if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) {
- PyObject *r = PyTuple_GET_ITEM(o, n);
- Py_INCREF(r);
- return r;
- }
- } else {
- PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
- if (likely(m && m->sq_item)) {
- if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
- Py_ssize_t l = m->sq_length(o);
- if (likely(l >= 0)) {
- i += l;
- } else {
- if (!PyErr_ExceptionMatches(PyExc_OverflowError))
- return NULL;
- PyErr_Clear();
- }
- }
- return m->sq_item(o, i);
- }
- }
-#else
- if (is_list || PySequence_Check(o)) {
- return PySequence_GetItem(o, i);
- }
-#endif
- return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
-}
-
-/* ObjectGetItem */
-#if CYTHON_USE_TYPE_SLOTS
-static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject* index) {
- PyObject *runerr;
- Py_ssize_t key_value;
- PySequenceMethods *m = Py_TYPE(obj)->tp_as_sequence;
- if (unlikely(!(m && m->sq_item))) {
- PyErr_Format(PyExc_TypeError, "'%.200s' object is not subscriptable", Py_TYPE(obj)->tp_name);
- return NULL;
- }
- key_value = __Pyx_PyIndex_AsSsize_t(index);
- if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) {
- return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1);
- }
- if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) {
- PyErr_Clear();
- PyErr_Format(PyExc_IndexError, "cannot fit '%.200s' into an index-sized integer", Py_TYPE(index)->tp_name);
- }
- return NULL;
-}
-static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key) {
- PyMappingMethods *m = Py_TYPE(obj)->tp_as_mapping;
- if (likely(m && m->mp_subscript)) {
- return m->mp_subscript(obj, key);
- }
- return __Pyx_PyObject_GetIndex(obj, key);
-}
-#endif
-
-/* decode_c_string */
-static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
- const char* cstring, Py_ssize_t start, Py_ssize_t stop,
- const char* encoding, const char* errors,
- PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) {
- Py_ssize_t length;
- if (unlikely((start < 0) | (stop < 0))) {
- size_t slen = strlen(cstring);
- if (unlikely(slen > (size_t) PY_SSIZE_T_MAX)) {
- PyErr_SetString(PyExc_OverflowError,
- "c-string too long to convert to Python");
- return NULL;
- }
- length = (Py_ssize_t) slen;
- if (start < 0) {
- start += length;
- if (start < 0)
- start = 0;
- }
- if (stop < 0)
- stop += length;
- }
- if (unlikely(stop <= start))
- return __Pyx_NewRef(__pyx_empty_unicode);
- length = stop - start;
- cstring += start;
- if (decode_func) {
- return decode_func(cstring, length, errors);
- } else {
- return PyUnicode_Decode(cstring, length, encoding, errors);
- }
-}
-
-/* PyErrExceptionMatches */
-#if CYTHON_FAST_THREAD_STATE
-static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
- Py_ssize_t i, n;
- n = PyTuple_GET_SIZE(tuple);
-#if PY_MAJOR_VERSION >= 3
- for (i=0; icurexc_type;
- if (exc_type == err) return 1;
- if (unlikely(!exc_type)) return 0;
- if (unlikely(PyTuple_Check(err)))
- return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
- return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
-}
-#endif
-
-/* GetAttr3 */
-static PyObject *__Pyx_GetAttr3Default(PyObject *d) {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
- return NULL;
- __Pyx_PyErr_Clear();
- Py_INCREF(d);
- return d;
-}
-static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) {
- PyObject *r = __Pyx_GetAttr(o, n);
- return (likely(r)) ? r : __Pyx_GetAttr3Default(d);
-}
-
-/* PyDictVersioning */
-#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
-static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
- PyObject *dict = Py_TYPE(obj)->tp_dict;
- return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
-}
-static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
- PyObject **dictptr = NULL;
- Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
- if (offset) {
-#if CYTHON_COMPILING_IN_CPYTHON
- dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
-#else
- dictptr = _PyObject_GetDictPtr(obj);
-#endif
- }
- return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
-}
-static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
- PyObject *dict = Py_TYPE(obj)->tp_dict;
- if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
- return 0;
- return obj_dict_version == __Pyx_get_object_dict_version(obj);
-}
-#endif
-
-/* GetModuleGlobalName */
-#if CYTHON_USE_DICT_VERSIONS
-static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
-#else
-static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
-#endif
-{
- PyObject *result;
-#if !CYTHON_AVOID_BORROWED_REFS
-#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
- result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
- __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
- if (likely(result)) {
- return __Pyx_NewRef(result);
- } else if (unlikely(PyErr_Occurred())) {
- return NULL;
- }
-#else
- result = PyDict_GetItem(__pyx_d, name);
- __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
- if (likely(result)) {
- return __Pyx_NewRef(result);
- }
-#endif
-#else
- result = PyObject_GetItem(__pyx_d, name);
- __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
- if (likely(result)) {
- return __Pyx_NewRef(result);
- }
- PyErr_Clear();
-#endif
- return __Pyx_GetBuiltinName(name);
-}
-
-/* RaiseTooManyValuesToUnpack */
-static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
- PyErr_Format(PyExc_ValueError,
- "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
-}
-
-/* RaiseNeedMoreValuesToUnpack */
-static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
- PyErr_Format(PyExc_ValueError,
- "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
- index, (index == 1) ? "" : "s");
-}
-
-/* RaiseNoneIterError */
-static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
-}
-
-/* ExtTypeTest */
-static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
- if (unlikely(!type)) {
- PyErr_SetString(PyExc_SystemError, "Missing type object");
- return 0;
- }
- if (likely(__Pyx_TypeCheck(obj, type)))
- return 1;
- PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
- Py_TYPE(obj)->tp_name, type->tp_name);
- return 0;
-}
-
-/* GetTopmostException */
-#if CYTHON_USE_EXC_INFO_STACK
-static _PyErr_StackItem *
-__Pyx_PyErr_GetTopmostException(PyThreadState *tstate)
-{
- _PyErr_StackItem *exc_info = tstate->exc_info;
- while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) &&
- exc_info->previous_item != NULL)
- {
- exc_info = exc_info->previous_item;
- }
- return exc_info;
-}
-#endif
-
-/* SaveResetException */
-#if CYTHON_FAST_THREAD_STATE
-static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
- #if CYTHON_USE_EXC_INFO_STACK
- _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
- *type = exc_info->exc_type;
- *value = exc_info->exc_value;
- *tb = exc_info->exc_traceback;
- #else
- *type = tstate->exc_type;
- *value = tstate->exc_value;
- *tb = tstate->exc_traceback;
- #endif
- Py_XINCREF(*type);
- Py_XINCREF(*value);
- Py_XINCREF(*tb);
-}
-static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- #if CYTHON_USE_EXC_INFO_STACK
- _PyErr_StackItem *exc_info = tstate->exc_info;
- tmp_type = exc_info->exc_type;
- tmp_value = exc_info->exc_value;
- tmp_tb = exc_info->exc_traceback;
- exc_info->exc_type = type;
- exc_info->exc_value = value;
- exc_info->exc_traceback = tb;
- #else
- tmp_type = tstate->exc_type;
- tmp_value = tstate->exc_value;
- tmp_tb = tstate->exc_traceback;
- tstate->exc_type = type;
- tstate->exc_value = value;
- tstate->exc_traceback = tb;
- #endif
- Py_XDECREF(tmp_type);
- Py_XDECREF(tmp_value);
- Py_XDECREF(tmp_tb);
-}
-#endif
-
-/* GetException */
-#if CYTHON_FAST_THREAD_STATE
-static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb)
-#else
-static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
-#endif
-{
- PyObject *local_type, *local_value, *local_tb;
-#if CYTHON_FAST_THREAD_STATE
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- local_type = tstate->curexc_type;
- local_value = tstate->curexc_value;
- local_tb = tstate->curexc_traceback;
- tstate->curexc_type = 0;
- tstate->curexc_value = 0;
- tstate->curexc_traceback = 0;
-#else
- PyErr_Fetch(&local_type, &local_value, &local_tb);
-#endif
- PyErr_NormalizeException(&local_type, &local_value, &local_tb);
-#if CYTHON_FAST_THREAD_STATE
- if (unlikely(tstate->curexc_type))
-#else
- if (unlikely(PyErr_Occurred()))
-#endif
- goto bad;
- #if PY_MAJOR_VERSION >= 3
- if (local_tb) {
- if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
- goto bad;
- }
- #endif
- Py_XINCREF(local_tb);
- Py_XINCREF(local_type);
- Py_XINCREF(local_value);
- *type = local_type;
- *value = local_value;
- *tb = local_tb;
-#if CYTHON_FAST_THREAD_STATE
- #if CYTHON_USE_EXC_INFO_STACK
- {
- _PyErr_StackItem *exc_info = tstate->exc_info;
- tmp_type = exc_info->exc_type;
- tmp_value = exc_info->exc_value;
- tmp_tb = exc_info->exc_traceback;
- exc_info->exc_type = local_type;
- exc_info->exc_value = local_value;
- exc_info->exc_traceback = local_tb;
- }
- #else
- tmp_type = tstate->exc_type;
- tmp_value = tstate->exc_value;
- tmp_tb = tstate->exc_traceback;
- tstate->exc_type = local_type;
- tstate->exc_value = local_value;
- tstate->exc_traceback = local_tb;
- #endif
- Py_XDECREF(tmp_type);
- Py_XDECREF(tmp_value);
- Py_XDECREF(tmp_tb);
-#else
- PyErr_SetExcInfo(local_type, local_value, local_tb);
-#endif
- return 0;
-bad:
- *type = 0;
- *value = 0;
- *tb = 0;
- Py_XDECREF(local_type);
- Py_XDECREF(local_value);
- Py_XDECREF(local_tb);
- return -1;
-}
-
-/* SwapException */
-#if CYTHON_FAST_THREAD_STATE
-static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- #if CYTHON_USE_EXC_INFO_STACK
- _PyErr_StackItem *exc_info = tstate->exc_info;
- tmp_type = exc_info->exc_type;
- tmp_value = exc_info->exc_value;
- tmp_tb = exc_info->exc_traceback;
- exc_info->exc_type = *type;
- exc_info->exc_value = *value;
- exc_info->exc_traceback = *tb;
- #else
- tmp_type = tstate->exc_type;
- tmp_value = tstate->exc_value;
- tmp_tb = tstate->exc_traceback;
- tstate->exc_type = *type;
- tstate->exc_value = *value;
- tstate->exc_traceback = *tb;
- #endif
- *type = tmp_type;
- *value = tmp_value;
- *tb = tmp_tb;
-}
-#else
-static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
- PyObject *tmp_type, *tmp_value, *tmp_tb;
- PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
- PyErr_SetExcInfo(*type, *value, *tb);
- *type = tmp_type;
- *value = tmp_value;
- *tb = tmp_tb;
-}
-#endif
-
-/* Import */
-static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
- PyObject *empty_list = 0;
- PyObject *module = 0;
- PyObject *global_dict = 0;
- PyObject *empty_dict = 0;
- PyObject *list;
- #if PY_MAJOR_VERSION < 3
- PyObject *py_import;
- py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
- if (!py_import)
- goto bad;
- #endif
- if (from_list)
- list = from_list;
- else {
- empty_list = PyList_New(0);
- if (!empty_list)
- goto bad;
- list = empty_list;
- }
- global_dict = PyModule_GetDict(__pyx_m);
- if (!global_dict)
- goto bad;
- empty_dict = PyDict_New();
- if (!empty_dict)
- goto bad;
- {
- #if PY_MAJOR_VERSION >= 3
- if (level == -1) {
- if ((1) && (strchr(__Pyx_MODULE_NAME, '.'))) {
- module = PyImport_ImportModuleLevelObject(
- name, global_dict, empty_dict, list, 1);
- if (!module) {
- if (!PyErr_ExceptionMatches(PyExc_ImportError))
- goto bad;
- PyErr_Clear();
- }
- }
- level = 0;
- }
- #endif
- if (!module) {
- #if PY_MAJOR_VERSION < 3
- PyObject *py_level = PyInt_FromLong(level);
- if (!py_level)
- goto bad;
- module = PyObject_CallFunctionObjArgs(py_import,
- name, global_dict, empty_dict, list, py_level, (PyObject *)NULL);
- Py_DECREF(py_level);
- #else
- module = PyImport_ImportModuleLevelObject(
- name, global_dict, empty_dict, list, level);
- #endif
- }
- }
-bad:
- #if PY_MAJOR_VERSION < 3
- Py_XDECREF(py_import);
- #endif
- Py_XDECREF(empty_list);
- Py_XDECREF(empty_dict);
- return module;
-}
-
-/* FastTypeChecks */
-#if CYTHON_COMPILING_IN_CPYTHON
-static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
- while (a) {
- a = a->tp_base;
- if (a == b)
- return 1;
- }
- return b == &PyBaseObject_Type;
-}
-static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
- PyObject *mro;
- if (a == b) return 1;
- mro = a->tp_mro;
- if (likely(mro)) {
- Py_ssize_t i, n;
- n = PyTuple_GET_SIZE(mro);
- for (i = 0; i < n; i++) {
- if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
- return 1;
- }
- return 0;
- }
- return __Pyx_InBases(a, b);
-}
-#if PY_MAJOR_VERSION == 2
-static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
- PyObject *exception, *value, *tb;
- int res;
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- __Pyx_ErrFetch(&exception, &value, &tb);
- res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
- if (unlikely(res == -1)) {
- PyErr_WriteUnraisable(err);
- res = 0;
- }
- if (!res) {
- res = PyObject_IsSubclass(err, exc_type2);
- if (unlikely(res == -1)) {
- PyErr_WriteUnraisable(err);
- res = 0;
- }
- }
- __Pyx_ErrRestore(exception, value, tb);
- return res;
-}
-#else
-static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
- int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
- if (!res) {
- res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
- }
- return res;
-}
-#endif
-static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
- Py_ssize_t i, n;
- assert(PyExceptionClass_Check(exc_type));
- n = PyTuple_GET_SIZE(tuple);
-#if PY_MAJOR_VERSION >= 3
- for (i=0; i= 0 || (x^b) >= 0))
- return PyInt_FromLong(x);
- return PyLong_Type.tp_as_number->nb_add(op1, op2);
- }
- #endif
- #if CYTHON_USE_PYLONG_INTERNALS
- if (likely(PyLong_CheckExact(op1))) {
- const long b = intval;
- long a, x;
-#ifdef HAVE_LONG_LONG
- const PY_LONG_LONG llb = intval;
- PY_LONG_LONG lla, llx;
-#endif
- const digit* digits = ((PyLongObject*)op1)->ob_digit;
- const Py_ssize_t size = Py_SIZE(op1);
- if (likely(__Pyx_sst_abs(size) <= 1)) {
- a = likely(size) ? digits[0] : 0;
- if (size == -1) a = -a;
- } else {
- switch (size) {
- case -2:
- if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
- break;
-#ifdef HAVE_LONG_LONG
- } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
- lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
- goto long_long;
-#endif
- }
- CYTHON_FALLTHROUGH;
- case 2:
- if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
- break;
-#ifdef HAVE_LONG_LONG
- } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
- lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
- goto long_long;
-#endif
- }
- CYTHON_FALLTHROUGH;
- case -3:
- if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
- break;
-#ifdef HAVE_LONG_LONG
- } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
- lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
- goto long_long;
-#endif
- }
- CYTHON_FALLTHROUGH;
- case 3:
- if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
- break;
-#ifdef HAVE_LONG_LONG
- } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
- lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
- goto long_long;
-#endif
- }
- CYTHON_FALLTHROUGH;
- case -4:
- if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
- a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
- break;
-#ifdef HAVE_LONG_LONG
- } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
- lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
- goto long_long;
-#endif
- }
- CYTHON_FALLTHROUGH;
- case 4:
- if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
- a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
- break;
-#ifdef HAVE_LONG_LONG
- } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
- lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
- goto long_long;
-#endif
- }
- CYTHON_FALLTHROUGH;
- default: return PyLong_Type.tp_as_number->nb_add(op1, op2);
- }
- }
- x = a + b;
- return PyLong_FromLong(x);
-#ifdef HAVE_LONG_LONG
- long_long:
- llx = lla + llb;
- return PyLong_FromLongLong(llx);
-#endif
-
-
- }
- #endif
- if (PyFloat_CheckExact(op1)) {
- const long b = intval;
- double a = PyFloat_AS_DOUBLE(op1);
- double result;
- PyFPE_START_PROTECT("add", return NULL)
- result = ((double)a) + (double)b;
- PyFPE_END_PROTECT(result)
- return PyFloat_FromDouble(result);
- }
- return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2);
-}
-#endif
-
-/* None */
-static CYTHON_INLINE long __Pyx_div_long(long a, long b) {
- long q = a / b;
- long r = a - q*b;
- q -= ((r != 0) & ((r ^ b) < 0));
- return q;
-}
-
-/* ImportFrom */
-static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
- PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
- if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
- PyErr_Format(PyExc_ImportError,
- #if PY_MAJOR_VERSION < 3
- "cannot import name %.230s", PyString_AS_STRING(name));
- #else
- "cannot import name %S", name);
- #endif
- }
- return value;
-}
-
-/* HasAttr */
-static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) {
- PyObject *r;
- if (unlikely(!__Pyx_PyBaseString_Check(n))) {
- PyErr_SetString(PyExc_TypeError,
- "hasattr(): attribute name must be string");
- return -1;
- }
- r = __Pyx_GetAttr(o, n);
- if (unlikely(!r)) {
- PyErr_Clear();
- return 0;
- } else {
- Py_DECREF(r);
- return 1;
- }
-}
-
-/* PyObject_GenericGetAttrNoDict */
-#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
- PyErr_Format(PyExc_AttributeError,
-#if PY_MAJOR_VERSION >= 3
- "'%.50s' object has no attribute '%U'",
- tp->tp_name, attr_name);
-#else
- "'%.50s' object has no attribute '%.400s'",
- tp->tp_name, PyString_AS_STRING(attr_name));
-#endif
- return NULL;
-}
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
- PyObject *descr;
- PyTypeObject *tp = Py_TYPE(obj);
- if (unlikely(!PyString_Check(attr_name))) {
- return PyObject_GenericGetAttr(obj, attr_name);
- }
- assert(!tp->tp_dictoffset);
- descr = _PyType_Lookup(tp, attr_name);
- if (unlikely(!descr)) {
- return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
- }
- Py_INCREF(descr);
- #if PY_MAJOR_VERSION < 3
- if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
- #endif
- {
- descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
- if (unlikely(f)) {
- PyObject *res = f(descr, obj, (PyObject *)tp);
- Py_DECREF(descr);
- return res;
- }
- }
- return descr;
-}
-#endif
-
-/* PyObject_GenericGetAttr */
-#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
-static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
- if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
- return PyObject_GenericGetAttr(obj, attr_name);
- }
- return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
-}
-#endif
-
-/* SetVTable */
-static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
-#if PY_VERSION_HEX >= 0x02070000
- PyObject *ob = PyCapsule_New(vtable, 0, 0);
-#else
- PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
-#endif
- if (!ob)
- goto bad;
- if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0)
- goto bad;
- Py_DECREF(ob);
- return 0;
-bad:
- Py_XDECREF(ob);
- return -1;
-}
-
-/* PyObjectGetAttrStrNoError */
-static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) {
- __Pyx_PyThreadState_declare
- __Pyx_PyThreadState_assign
- if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
- __Pyx_PyErr_Clear();
-}
-static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) {
- PyObject *result;
-#if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS && PY_VERSION_HEX >= 0x030700B1
- PyTypeObject* tp = Py_TYPE(obj);
- if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) {
- return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1);
- }
-#endif
- result = __Pyx_PyObject_GetAttrStr(obj, attr_name);
- if (unlikely(!result)) {
- __Pyx_PyObject_GetAttrStr_ClearAttributeError();
- }
- return result;
-}
-
-/* SetupReduce */
-static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) {
- int ret;
- PyObject *name_attr;
- name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name_2);
- if (likely(name_attr)) {
- ret = PyObject_RichCompareBool(name_attr, name, Py_EQ);
- } else {
- ret = -1;
- }
- if (unlikely(ret < 0)) {
- PyErr_Clear();
- ret = 0;
- }
- Py_XDECREF(name_attr);
- return ret;
-}
-static int __Pyx_setup_reduce(PyObject* type_obj) {
- int ret = 0;
- PyObject *object_reduce = NULL;
- PyObject *object_reduce_ex = NULL;
- PyObject *reduce = NULL;
- PyObject *reduce_ex = NULL;
- PyObject *reduce_cython = NULL;
- PyObject *setstate = NULL;
- PyObject *setstate_cython = NULL;
-#if CYTHON_USE_PYTYPE_LOOKUP
- if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
-#else
- if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
-#endif
-#if CYTHON_USE_PYTYPE_LOOKUP
- object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
-#else
- object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
-#endif
- reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto __PYX_BAD;
- if (reduce_ex == object_reduce_ex) {
-#if CYTHON_USE_PYTYPE_LOOKUP
- object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
-#else
- object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
-#endif
- reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto __PYX_BAD;
- if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) {
- reduce_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_reduce_cython);
- if (likely(reduce_cython)) {
- ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
- ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
- } else if (reduce == object_reduce || PyErr_Occurred()) {
- goto __PYX_BAD;
- }
- setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate);
- if (!setstate) PyErr_Clear();
- if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) {
- setstate_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_setstate_cython);
- if (likely(setstate_cython)) {
- ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
- ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
- } else if (!setstate || PyErr_Occurred()) {
- goto __PYX_BAD;
- }
- }
- PyType_Modified((PyTypeObject*)type_obj);
- }
- }
- goto __PYX_GOOD;
-__PYX_BAD:
- if (!PyErr_Occurred())
- PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name);
- ret = -1;
-__PYX_GOOD:
-#if !CYTHON_USE_PYTYPE_LOOKUP
- Py_XDECREF(object_reduce);
- Py_XDECREF(object_reduce_ex);
-#endif
- Py_XDECREF(reduce);
- Py_XDECREF(reduce_ex);
- Py_XDECREF(reduce_cython);
- Py_XDECREF(setstate);
- Py_XDECREF(setstate_cython);
- return ret;
-}
-
-/* CLineInTraceback */
-#ifndef CYTHON_CLINE_IN_TRACEBACK
-static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) {
- PyObject *use_cline;
- PyObject *ptype, *pvalue, *ptraceback;
-#if CYTHON_COMPILING_IN_CPYTHON
- PyObject **cython_runtime_dict;
-#endif
- if (unlikely(!__pyx_cython_runtime)) {
- return c_line;
- }
- __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
-#if CYTHON_COMPILING_IN_CPYTHON
- cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
- if (likely(cython_runtime_dict)) {
- __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
- use_cline, *cython_runtime_dict,
- __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
- } else
-#endif
- {
- PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
- if (use_cline_obj) {
- use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
- Py_DECREF(use_cline_obj);
- } else {
- PyErr_Clear();
- use_cline = NULL;
- }
- }
- if (!use_cline) {
- c_line = 0;
- PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
- }
- else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
- c_line = 0;
- }
- __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
- return c_line;
-}
-#endif
-
-/* CodeObjectCache */
-static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
- int start = 0, mid = 0, end = count - 1;
- if (end >= 0 && code_line > entries[end].code_line) {
- return count;
- }
- while (start < end) {
- mid = start + (end - start) / 2;
- if (code_line < entries[mid].code_line) {
- end = mid;
- } else if (code_line > entries[mid].code_line) {
- start = mid + 1;
- } else {
- return mid;
- }
- }
- if (code_line <= entries[mid].code_line) {
- return mid;
- } else {
- return mid + 1;
- }
-}
-static PyCodeObject *__pyx_find_code_object(int code_line) {
- PyCodeObject* code_object;
- int pos;
- if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
- return NULL;
- }
- pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
- if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
- return NULL;
- }
- code_object = __pyx_code_cache.entries[pos].code_object;
- Py_INCREF(code_object);
- return code_object;
-}
-static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
- int pos, i;
- __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
- if (unlikely(!code_line)) {
- return;
- }
- if (unlikely(!entries)) {
- entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
- if (likely(entries)) {
- __pyx_code_cache.entries = entries;
- __pyx_code_cache.max_count = 64;
- __pyx_code_cache.count = 1;
- entries[0].code_line = code_line;
- entries[0].code_object = code_object;
- Py_INCREF(code_object);
- }
- return;
- }
- pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
- if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
- PyCodeObject* tmp = entries[pos].code_object;
- entries[pos].code_object = code_object;
- Py_DECREF(tmp);
- return;
- }
- if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
- int new_max = __pyx_code_cache.max_count + 64;
- entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
- __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
- if (unlikely(!entries)) {
- return;
- }
- __pyx_code_cache.entries = entries;
- __pyx_code_cache.max_count = new_max;
- }
- for (i=__pyx_code_cache.count; i>pos; i--) {
- entries[i] = entries[i-1];
- }
- entries[pos].code_line = code_line;
- entries[pos].code_object = code_object;
- __pyx_code_cache.count++;
- Py_INCREF(code_object);
-}
-
-/* AddTraceback */
-#include "compile.h"
-#include "frameobject.h"
-#include "traceback.h"
-static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
- const char *funcname, int c_line,
- int py_line, const char *filename) {
- PyCodeObject *py_code = 0;
- PyObject *py_srcfile = 0;
- PyObject *py_funcname = 0;
- #if PY_MAJOR_VERSION < 3
- py_srcfile = PyString_FromString(filename);
- #else
- py_srcfile = PyUnicode_FromString(filename);
- #endif
- if (!py_srcfile) goto bad;
- if (c_line) {
- #if PY_MAJOR_VERSION < 3
- py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
- #else
- py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
- #endif
- }
- else {
- #if PY_MAJOR_VERSION < 3
- py_funcname = PyString_FromString(funcname);
- #else
- py_funcname = PyUnicode_FromString(funcname);
- #endif
- }
- if (!py_funcname) goto bad;
- py_code = __Pyx_PyCode_New(
- 0,
- 0,
- 0,
- 0,
- 0,
- __pyx_empty_bytes, /*PyObject *code,*/
- __pyx_empty_tuple, /*PyObject *consts,*/
- __pyx_empty_tuple, /*PyObject *names,*/
- __pyx_empty_tuple, /*PyObject *varnames,*/
- __pyx_empty_tuple, /*PyObject *freevars,*/
- __pyx_empty_tuple, /*PyObject *cellvars,*/
- py_srcfile, /*PyObject *filename,*/
- py_funcname, /*PyObject *name,*/
- py_line,
- __pyx_empty_bytes /*PyObject *lnotab*/
- );
- Py_DECREF(py_srcfile);
- Py_DECREF(py_funcname);
- return py_code;
-bad:
- Py_XDECREF(py_srcfile);
- Py_XDECREF(py_funcname);
- return NULL;
-}
-static void __Pyx_AddTraceback(const char *funcname, int c_line,
- int py_line, const char *filename) {
- PyCodeObject *py_code = 0;
- PyFrameObject *py_frame = 0;
- PyThreadState *tstate = __Pyx_PyThreadState_Current;
- if (c_line) {
- c_line = __Pyx_CLineForTraceback(tstate, c_line);
- }
- py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
- if (!py_code) {
- py_code = __Pyx_CreateCodeObjectForTraceback(
- funcname, c_line, py_line, filename);
- if (!py_code) goto bad;
- __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
- }
- py_frame = PyFrame_New(
- tstate, /*PyThreadState *tstate,*/
- py_code, /*PyCodeObject *code,*/
- __pyx_d, /*PyObject *globals,*/
- 0 /*PyObject *locals*/
- );
- if (!py_frame) goto bad;
- __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
- PyTraceBack_Here(py_frame);
-bad:
- Py_XDECREF(py_code);
- Py_XDECREF(py_frame);
-}
-
-#if PY_MAJOR_VERSION < 3
-static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) {
- if (PyObject_CheckBuffer(obj)) return PyObject_GetBuffer(obj, view, flags);
- if (__Pyx_TypeCheck(obj, __pyx_array_type)) return __pyx_array_getbuffer(obj, view, flags);
- if (__Pyx_TypeCheck(obj, __pyx_memoryview_type)) return __pyx_memoryview_getbuffer(obj, view, flags);
- PyErr_Format(PyExc_TypeError, "'%.200s' does not have the buffer interface", Py_TYPE(obj)->tp_name);
- return -1;
-}
-static void __Pyx_ReleaseBuffer(Py_buffer *view) {
- PyObject *obj = view->obj;
- if (!obj) return;
- if (PyObject_CheckBuffer(obj)) {
- PyBuffer_Release(view);
- return;
- }
- if ((0)) {}
- view->obj = NULL;
- Py_DECREF(obj);
-}
-#endif
-
-
-/* MemviewSliceIsContig */
-static int
-__pyx_memviewslice_is_contig(const __Pyx_memviewslice mvs, char order, int ndim)
-{
- int i, index, step, start;
- Py_ssize_t itemsize = mvs.memview->view.itemsize;
- if (order == 'F') {
- step = 1;
- start = 0;
- } else {
- step = -1;
- start = ndim - 1;
- }
- for (i = 0; i < ndim; i++) {
- index = start + step * i;
- if (mvs.suboffsets[index] >= 0 || mvs.strides[index] != itemsize)
- return 0;
- itemsize *= mvs.shape[index];
- }
- return 1;
-}
-
-/* OverlappingSlices */
-static void
-__pyx_get_array_memory_extents(__Pyx_memviewslice *slice,
- void **out_start, void **out_end,
- int ndim, size_t itemsize)
-{
- char *start, *end;
- int i;
- start = end = slice->data;
- for (i = 0; i < ndim; i++) {
- Py_ssize_t stride = slice->strides[i];
- Py_ssize_t extent = slice->shape[i];
- if (extent == 0) {
- *out_start = *out_end = start;
- return;
- } else {
- if (stride > 0)
- end += stride * (extent - 1);
- else
- start += stride * (extent - 1);
- }
- }
- *out_start = start;
- *out_end = end + itemsize;
-}
-static int
-__pyx_slices_overlap(__Pyx_memviewslice *slice1,
- __Pyx_memviewslice *slice2,
- int ndim, size_t itemsize)
-{
- void *start1, *end1, *start2, *end2;
- __pyx_get_array_memory_extents(slice1, &start1, &end1, ndim, itemsize);
- __pyx_get_array_memory_extents(slice2, &start2, &end2, ndim, itemsize);
- return (start1 < end2) && (start2 < end1);
-}
-
-/* Capsule */
-static CYTHON_INLINE PyObject *
-__pyx_capsule_create(void *p, CYTHON_UNUSED const char *sig)
-{
- PyObject *cobj;
-#if PY_VERSION_HEX >= 0x02070000
- cobj = PyCapsule_New(p, sig, NULL);
-#else
- cobj = PyCObject_FromVoidPtr(p, NULL);
-#endif
- return cobj;
-}
-
-/* IsLittleEndian */
-static CYTHON_INLINE int __Pyx_Is_Little_Endian(void)
-{
- union {
- uint32_t u32;
- uint8_t u8[4];
- } S;
- S.u32 = 0x01020304;
- return S.u8[0] == 4;
-}
-
-/* BufferFormatCheck */
-static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx,
- __Pyx_BufFmt_StackElem* stack,
- __Pyx_TypeInfo* type) {
- stack[0].field = &ctx->root;
- stack[0].parent_offset = 0;
- ctx->root.type = type;
- ctx->root.name = "buffer dtype";
- ctx->root.offset = 0;
- ctx->head = stack;
- ctx->head->field = &ctx->root;
- ctx->fmt_offset = 0;
- ctx->head->parent_offset = 0;
- ctx->new_packmode = '@';
- ctx->enc_packmode = '@';
- ctx->new_count = 1;
- ctx->enc_count = 0;
- ctx->enc_type = 0;
- ctx->is_complex = 0;
- ctx->is_valid_array = 0;
- ctx->struct_alignment = 0;
- while (type->typegroup == 'S') {
- ++ctx->head;
- ctx->head->field = type->fields;
- ctx->head->parent_offset = 0;
- type = type->fields->type;
- }
-}
-static int __Pyx_BufFmt_ParseNumber(const char** ts) {
- int count;
- const char* t = *ts;
- if (*t < '0' || *t > '9') {
- return -1;
- } else {
- count = *t++ - '0';
- while (*t >= '0' && *t <= '9') {
- count *= 10;
- count += *t++ - '0';
- }
- }
- *ts = t;
- return count;
-}
-static int __Pyx_BufFmt_ExpectNumber(const char **ts) {
- int number = __Pyx_BufFmt_ParseNumber(ts);
- if (number == -1)
- PyErr_Format(PyExc_ValueError,\
- "Does not understand character buffer dtype format string ('%c')", **ts);
- return number;
-}
-static void __Pyx_BufFmt_RaiseUnexpectedChar(char ch) {
- PyErr_Format(PyExc_ValueError,
- "Unexpected format string character: '%c'", ch);
-}
-static const char* __Pyx_BufFmt_DescribeTypeChar(char ch, int is_complex) {
- switch (ch) {
- case '?': return "'bool'";
- case 'c': return "'char'";
- case 'b': return "'signed char'";
- case 'B': return "'unsigned char'";
- case 'h': return "'short'";
- case 'H': return "'unsigned short'";
- case 'i': return "'int'";
- case 'I': return "'unsigned int'";
- case 'l': return "'long'";
- case 'L': return "'unsigned long'";
- case 'q': return "'long long'";
- case 'Q': return "'unsigned long long'";
- case 'f': return (is_complex ? "'complex float'" : "'float'");
- case 'd': return (is_complex ? "'complex double'" : "'double'");
- case 'g': return (is_complex ? "'complex long double'" : "'long double'");
- case 'T': return "a struct";
- case 'O': return "Python object";
- case 'P': return "a pointer";
- case 's': case 'p': return "a string";
- case 0: return "end";
- default: return "unparseable format string";
- }
-}
-static size_t __Pyx_BufFmt_TypeCharToStandardSize(char ch, int is_complex) {
- switch (ch) {
- case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
- case 'h': case 'H': return 2;
- case 'i': case 'I': case 'l': case 'L': return 4;
- case 'q': case 'Q': return 8;
- case 'f': return (is_complex ? 8 : 4);
- case 'd': return (is_complex ? 16 : 8);
- case 'g': {
- PyErr_SetString(PyExc_ValueError, "Python does not define a standard format string size for long double ('g')..");
- return 0;
- }
- case 'O': case 'P': return sizeof(void*);
- default:
- __Pyx_BufFmt_RaiseUnexpectedChar(ch);
- return 0;
- }
-}
-static size_t __Pyx_BufFmt_TypeCharToNativeSize(char ch, int is_complex) {
- switch (ch) {
- case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
- case 'h': case 'H': return sizeof(short);
- case 'i': case 'I': return sizeof(int);
- case 'l': case 'L': return sizeof(long);
- #ifdef HAVE_LONG_LONG
- case 'q': case 'Q': return sizeof(PY_LONG_LONG);
- #endif
- case 'f': return sizeof(float) * (is_complex ? 2 : 1);
- case 'd': return sizeof(double) * (is_complex ? 2 : 1);
- case 'g': return sizeof(long double) * (is_complex ? 2 : 1);
- case 'O': case 'P': return sizeof(void*);
- default: {
- __Pyx_BufFmt_RaiseUnexpectedChar(ch);
- return 0;
- }
- }
-}
-typedef struct { char c; short x; } __Pyx_st_short;
-typedef struct { char c; int x; } __Pyx_st_int;
-typedef struct { char c; long x; } __Pyx_st_long;
-typedef struct { char c; float x; } __Pyx_st_float;
-typedef struct { char c; double x; } __Pyx_st_double;
-typedef struct { char c; long double x; } __Pyx_st_longdouble;
-typedef struct { char c; void *x; } __Pyx_st_void_p;
-#ifdef HAVE_LONG_LONG
-typedef struct { char c; PY_LONG_LONG x; } __Pyx_st_longlong;
-#endif
-static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, CYTHON_UNUSED int is_complex) {
- switch (ch) {
- case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
- case 'h': case 'H': return sizeof(__Pyx_st_short) - sizeof(short);
- case 'i': case 'I': return sizeof(__Pyx_st_int) - sizeof(int);
- case 'l': case 'L': return sizeof(__Pyx_st_long) - sizeof(long);
-#ifdef HAVE_LONG_LONG
- case 'q': case 'Q': return sizeof(__Pyx_st_longlong) - sizeof(PY_LONG_LONG);
-#endif
- case 'f': return sizeof(__Pyx_st_float) - sizeof(float);
- case 'd': return sizeof(__Pyx_st_double) - sizeof(double);
- case 'g': return sizeof(__Pyx_st_longdouble) - sizeof(long double);
- case 'P': case 'O': return sizeof(__Pyx_st_void_p) - sizeof(void*);
- default:
- __Pyx_BufFmt_RaiseUnexpectedChar(ch);
- return 0;
- }
-}
-/* These are for computing the padding at the end of the struct to align
- on the first member of the struct. This will probably the same as above,
- but we don't have any guarantees.
- */
-typedef struct { short x; char c; } __Pyx_pad_short;
-typedef struct { int x; char c; } __Pyx_pad_int;
-typedef struct { long x; char c; } __Pyx_pad_long;
-typedef struct { float x; char c; } __Pyx_pad_float;
-typedef struct { double x; char c; } __Pyx_pad_double;
-typedef struct { long double x; char c; } __Pyx_pad_longdouble;
-typedef struct { void *x; char c; } __Pyx_pad_void_p;
-#ifdef HAVE_LONG_LONG
-typedef struct { PY_LONG_LONG x; char c; } __Pyx_pad_longlong;
-#endif
-static size_t __Pyx_BufFmt_TypeCharToPadding(char ch, CYTHON_UNUSED int is_complex) {
- switch (ch) {
- case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1;
- case 'h': case 'H': return sizeof(__Pyx_pad_short) - sizeof(short);
- case 'i': case 'I': return sizeof(__Pyx_pad_int) - sizeof(int);
- case 'l': case 'L': return sizeof(__Pyx_pad_long) - sizeof(long);
-#ifdef HAVE_LONG_LONG
- case 'q': case 'Q': return sizeof(__Pyx_pad_longlong) - sizeof(PY_LONG_LONG);
-#endif
- case 'f': return sizeof(__Pyx_pad_float) - sizeof(float);
- case 'd': return sizeof(__Pyx_pad_double) - sizeof(double);
- case 'g': return sizeof(__Pyx_pad_longdouble) - sizeof(long double);
- case 'P': case 'O': return sizeof(__Pyx_pad_void_p) - sizeof(void*);
- default:
- __Pyx_BufFmt_RaiseUnexpectedChar(ch);
- return 0;
- }
-}
-static char __Pyx_BufFmt_TypeCharToGroup(char ch, int is_complex) {
- switch (ch) {
- case 'c':
- return 'H';
- case 'b': case 'h': case 'i':
- case 'l': case 'q': case 's': case 'p':
- return 'I';
- case '?': case 'B': case 'H': case 'I': case 'L': case 'Q':
- return 'U';
- case 'f': case 'd': case 'g':
- return (is_complex ? 'C' : 'R');
- case 'O':
- return 'O';
- case 'P':
- return 'P';
- default: {
- __Pyx_BufFmt_RaiseUnexpectedChar(ch);
- return 0;
- }
- }
-}
-static void __Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context* ctx) {
- if (ctx->head == NULL || ctx->head->field == &ctx->root) {
- const char* expected;
- const char* quote;
- if (ctx->head == NULL) {
- expected = "end";
- quote = "";
- } else {
- expected = ctx->head->field->type->name;
- quote = "'";
- }
- PyErr_Format(PyExc_ValueError,
- "Buffer dtype mismatch, expected %s%s%s but got %s",
- quote, expected, quote,
- __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex));
- } else {
- __Pyx_StructField* field = ctx->head->field;
- __Pyx_StructField* parent = (ctx->head - 1)->field;
- PyErr_Format(PyExc_ValueError,
- "Buffer dtype mismatch, expected '%s' but got %s in '%s.%s'",
- field->type->name, __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex),
- parent->type->name, field->name);
- }
-}
-static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) {
- char group;
- size_t size, offset, arraysize = 1;
- if (ctx->enc_type == 0) return 0;
- if (ctx->head->field->type->arraysize[0]) {
- int i, ndim = 0;
- if (ctx->enc_type == 's' || ctx->enc_type == 'p') {
- ctx->is_valid_array = ctx->head->field->type->ndim == 1;
- ndim = 1;
- if (ctx->enc_count != ctx->head->field->type->arraysize[0]) {
- PyErr_Format(PyExc_ValueError,
- "Expected a dimension of size %zu, got %zu",
- ctx->head->field->type->arraysize[0], ctx->enc_count);
- return -1;
- }
- }
- if (!ctx->is_valid_array) {
- PyErr_Format(PyExc_ValueError, "Expected %d dimensions, got %d",
- ctx->head->field->type->ndim, ndim);
- return -1;
- }
- for (i = 0; i < ctx->head->field->type->ndim; i++) {
- arraysize *= ctx->head->field->type->arraysize[i];
- }
- ctx->is_valid_array = 0;
- ctx->enc_count = 1;
- }
- group = __Pyx_BufFmt_TypeCharToGroup(ctx->enc_type, ctx->is_complex);
- do {
- __Pyx_StructField* field = ctx->head->field;
- __Pyx_TypeInfo* type = field->type;
- if (ctx->enc_packmode == '@' || ctx->enc_packmode == '^') {
- size = __Pyx_BufFmt_TypeCharToNativeSize(ctx->enc_type, ctx->is_complex);
- } else {
- size = __Pyx_BufFmt_TypeCharToStandardSize(ctx->enc_type, ctx->is_complex);
- }
- if (ctx->enc_packmode == '@') {
- size_t align_at = __Pyx_BufFmt_TypeCharToAlignment(ctx->enc_type, ctx->is_complex);
- size_t align_mod_offset;
- if (align_at == 0) return -1;
- align_mod_offset = ctx->fmt_offset % align_at;
- if (align_mod_offset > 0) ctx->fmt_offset += align_at - align_mod_offset;
- if (ctx->struct_alignment == 0)
- ctx->struct_alignment = __Pyx_BufFmt_TypeCharToPadding(ctx->enc_type,
- ctx->is_complex);
- }
- if (type->size != size || type->typegroup != group) {
- if (type->typegroup == 'C' && type->fields != NULL) {
- size_t parent_offset = ctx->head->parent_offset + field->offset;
- ++ctx->head;
- ctx->head->field = type->fields;
- ctx->head->parent_offset = parent_offset;
- continue;
- }
- if ((type->typegroup == 'H' || group == 'H') && type->size == size) {
- } else {
- __Pyx_BufFmt_RaiseExpected(ctx);
- return -1;
- }
- }
- offset = ctx->head->parent_offset + field->offset;
- if (ctx->fmt_offset != offset) {
- PyErr_Format(PyExc_ValueError,
- "Buffer dtype mismatch; next field is at offset %" CYTHON_FORMAT_SSIZE_T "d but %" CYTHON_FORMAT_SSIZE_T "d expected",
- (Py_ssize_t)ctx->fmt_offset, (Py_ssize_t)offset);
- return -1;
- }
- ctx->fmt_offset += size;
- if (arraysize)
- ctx->fmt_offset += (arraysize - 1) * size;
- --ctx->enc_count;
- while (1) {
- if (field == &ctx->root) {
- ctx->head = NULL;
- if (ctx->enc_count != 0) {
- __Pyx_BufFmt_RaiseExpected(ctx);
- return -1;
- }
- break;
- }
- ctx->head->field = ++field;
- if (field->type == NULL) {
- --ctx->head;
- field = ctx->head->field;
- continue;
- } else if (field->type->typegroup == 'S') {
- size_t parent_offset = ctx->head->parent_offset + field->offset;
- if (field->type->fields->type == NULL) continue;
- field = field->type->fields;
- ++ctx->head;
- ctx->head->field = field;
- ctx->head->parent_offset = parent_offset;
- break;
- } else {
- break;
- }
- }
- } while (ctx->enc_count);
- ctx->enc_type = 0;
- ctx->is_complex = 0;
- return 0;
-}
-static PyObject *
-__pyx_buffmt_parse_array(__Pyx_BufFmt_Context* ctx, const char** tsp)
-{
- const char *ts = *tsp;
- int i = 0, number, ndim;
- ++ts;
- if (ctx->new_count != 1) {
- PyErr_SetString(PyExc_ValueError,
- "Cannot handle repeated arrays in format string");
- return NULL;
- }
- if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
- ndim = ctx->head->field->type->ndim;
- while (*ts && *ts != ')') {
- switch (*ts) {
- case ' ': case '\f': case '\r': case '\n': case '\t': case '\v': continue;
- default: break;
- }
- number = __Pyx_BufFmt_ExpectNumber(&ts);
- if (number == -1) return NULL;
- if (i < ndim && (size_t) number != ctx->head->field->type->arraysize[i])
- return PyErr_Format(PyExc_ValueError,
- "Expected a dimension of size %zu, got %d",
- ctx->head->field->type->arraysize[i], number);
- if (*ts != ',' && *ts != ')')
- return PyErr_Format(PyExc_ValueError,
- "Expected a comma in format string, got '%c'", *ts);
- if (*ts == ',') ts++;
- i++;
- }
- if (i != ndim)
- return PyErr_Format(PyExc_ValueError, "Expected %d dimension(s), got %d",
- ctx->head->field->type->ndim, i);
- if (!*ts) {
- PyErr_SetString(PyExc_ValueError,
- "Unexpected end of format string, expected ')'");
- return NULL;
- }
- ctx->is_valid_array = 1;
- ctx->new_count = 1;
- *tsp = ++ts;
- return Py_None;
-}
-static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts) {
- int got_Z = 0;
- while (1) {
- switch(*ts) {
- case 0:
- if (ctx->enc_type != 0 && ctx->head == NULL) {
- __Pyx_BufFmt_RaiseExpected(ctx);
- return NULL;
- }
- if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
- if (ctx->head != NULL) {
- __Pyx_BufFmt_RaiseExpected(ctx);
- return NULL;
- }
- return ts;
- case ' ':
- case '\r':
- case '\n':
- ++ts;
- break;
- case '<':
- if (!__Pyx_Is_Little_Endian()) {
- PyErr_SetString(PyExc_ValueError, "Little-endian buffer not supported on big-endian compiler");
- return NULL;
- }
- ctx->new_packmode = '=';
- ++ts;
- break;
- case '>':
- case '!':
- if (__Pyx_Is_Little_Endian()) {
- PyErr_SetString(PyExc_ValueError, "Big-endian buffer not supported on little-endian compiler");
- return NULL;
- }
- ctx->new_packmode = '=';
- ++ts;
- break;
- case '=':
- case '@':
- case '^':
- ctx->new_packmode = *ts++;
- break;
- case 'T':
- {
- const char* ts_after_sub;
- size_t i, struct_count = ctx->new_count;
- size_t struct_alignment = ctx->struct_alignment;
- ctx->new_count = 1;
- ++ts;
- if (*ts != '{') {
- PyErr_SetString(PyExc_ValueError, "Buffer acquisition: Expected '{' after 'T'");
- return NULL;
- }
- if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
- ctx->enc_type = 0;
- ctx->enc_count = 0;
- ctx->struct_alignment = 0;
- ++ts;
- ts_after_sub = ts;
- for (i = 0; i != struct_count; ++i) {
- ts_after_sub = __Pyx_BufFmt_CheckString(ctx, ts);
- if (!ts_after_sub) return NULL;
- }
- ts = ts_after_sub;
- if (struct_alignment) ctx->struct_alignment = struct_alignment;
- }
- break;
- case '}':
- {
- size_t alignment = ctx->struct_alignment;
- ++ts;
- if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
- ctx->enc_type = 0;
- if (alignment && ctx->fmt_offset % alignment) {
- ctx->fmt_offset += alignment - (ctx->fmt_offset % alignment);
- }
- }
- return ts;
- case 'x':
- if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
- ctx->fmt_offset += ctx->new_count;
- ctx->new_count = 1;
- ctx->enc_count = 0;
- ctx->enc_type = 0;
- ctx->enc_packmode = ctx->new_packmode;
- ++ts;
- break;
- case 'Z':
- got_Z = 1;
- ++ts;
- if (*ts != 'f' && *ts != 'd' && *ts != 'g') {
- __Pyx_BufFmt_RaiseUnexpectedChar('Z');
- return NULL;
- }
- CYTHON_FALLTHROUGH;
- case '?': case 'c': case 'b': case 'B': case 'h': case 'H': case 'i': case 'I':
- case 'l': case 'L': case 'q': case 'Q':
- case 'f': case 'd': case 'g':
- case 'O': case 'p':
- if ((ctx->enc_type == *ts) && (got_Z == ctx->is_complex) &&
- (ctx->enc_packmode == ctx->new_packmode) && (!ctx->is_valid_array)) {
- ctx->enc_count += ctx->new_count;
- ctx->new_count = 1;
- got_Z = 0;
- ++ts;
- break;
- }
- CYTHON_FALLTHROUGH;
- case 's':
- if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL;
- ctx->enc_count = ctx->new_count;
- ctx->enc_packmode = ctx->new_packmode;
- ctx->enc_type = *ts;
- ctx->is_complex = got_Z;
- ++ts;
- ctx->new_count = 1;
- got_Z = 0;
- break;
- case ':':
- ++ts;
- while(*ts != ':') ++ts;
- ++ts;
- break;
- case '(':
- if (!__pyx_buffmt_parse_array(ctx, &ts)) return NULL;
- break;
- default:
- {
- int number = __Pyx_BufFmt_ExpectNumber(&ts);
- if (number == -1) return NULL;
- ctx->new_count = (size_t)number;
- }
- }
- }
-}
-
-/* TypeInfoCompare */
- static int
-__pyx_typeinfo_cmp(__Pyx_TypeInfo *a, __Pyx_TypeInfo *b)
-{
- int i;
- if (!a || !b)
- return 0;
- if (a == b)
- return 1;
- if (a->size != b->size || a->typegroup != b->typegroup ||
- a->is_unsigned != b->is_unsigned || a->ndim != b->ndim) {
- if (a->typegroup == 'H' || b->typegroup == 'H') {
- return a->size == b->size;
- } else {
- return 0;
- }
- }
- if (a->ndim) {
- for (i = 0; i < a->ndim; i++)
- if (a->arraysize[i] != b->arraysize[i])
- return 0;
- }
- if (a->typegroup == 'S') {
- if (a->flags != b->flags)
- return 0;
- if (a->fields || b->fields) {
- if (!(a->fields && b->fields))
- return 0;
- for (i = 0; a->fields[i].type && b->fields[i].type; i++) {
- __Pyx_StructField *field_a = a->fields + i;
- __Pyx_StructField *field_b = b->fields + i;
- if (field_a->offset != field_b->offset ||
- !__pyx_typeinfo_cmp(field_a->type, field_b->type))
- return 0;
- }
- return !a->fields[i].type && !b->fields[i].type;
- }
- }
- return 1;
-}
-
-/* MemviewSliceValidateAndInit */
- static int
-__pyx_check_strides(Py_buffer *buf, int dim, int ndim, int spec)
-{
- if (buf->shape[dim] <= 1)
- return 1;
- if (buf->strides) {
- if (spec & __Pyx_MEMVIEW_CONTIG) {
- if (spec & (__Pyx_MEMVIEW_PTR|__Pyx_MEMVIEW_FULL)) {
- if (unlikely(buf->strides[dim] != sizeof(void *))) {
- PyErr_Format(PyExc_ValueError,
- "Buffer is not indirectly contiguous "
- "in dimension %d.", dim);
- goto fail;
- }
- } else if (unlikely(buf->strides[dim] != buf->itemsize)) {
- PyErr_SetString(PyExc_ValueError,
- "Buffer and memoryview are not contiguous "
- "in the same dimension.");
- goto fail;
- }
- }
- if (spec & __Pyx_MEMVIEW_FOLLOW) {
- Py_ssize_t stride = buf->strides[dim];
- if (stride < 0)
- stride = -stride;
- if (unlikely(stride < buf->itemsize)) {
- PyErr_SetString(PyExc_ValueError,
- "Buffer and memoryview are not contiguous "
- "in the same dimension.");
- goto fail;
- }
- }
- } else {
- if (unlikely(spec & __Pyx_MEMVIEW_CONTIG && dim != ndim - 1)) {
- PyErr_Format(PyExc_ValueError,
- "C-contiguous buffer is not contiguous in "
- "dimension %d", dim);
- goto fail;
- } else if (unlikely(spec & (__Pyx_MEMVIEW_PTR))) {
- PyErr_Format(PyExc_ValueError,
- "C-contiguous buffer is not indirect in "
- "dimension %d", dim);
- goto fail;
- } else if (unlikely(buf->suboffsets)) {
- PyErr_SetString(PyExc_ValueError,
- "Buffer exposes suboffsets but no strides");
- goto fail;
- }
- }
- return 1;
-fail:
- return 0;
-}
-static int
-__pyx_check_suboffsets(Py_buffer *buf, int dim, CYTHON_UNUSED int ndim, int spec)
-{
- if (spec & __Pyx_MEMVIEW_DIRECT) {
- if (unlikely(buf->suboffsets && buf->suboffsets[dim] >= 0)) {
- PyErr_Format(PyExc_ValueError,
- "Buffer not compatible with direct access "
- "in dimension %d.", dim);
- goto fail;
- }
- }
- if (spec & __Pyx_MEMVIEW_PTR) {
- if (unlikely(!buf->suboffsets || (buf->suboffsets[dim] < 0))) {
- PyErr_Format(PyExc_ValueError,
- "Buffer is not indirectly accessible "
- "in dimension %d.", dim);
- goto fail;
- }
- }
- return 1;
-fail:
- return 0;
-}
-static int
-__pyx_verify_contig(Py_buffer *buf, int ndim, int c_or_f_flag)
-{
- int i;
- if (c_or_f_flag & __Pyx_IS_F_CONTIG) {
- Py_ssize_t stride = 1;
- for (i = 0; i < ndim; i++) {
- if (unlikely(stride * buf->itemsize != buf->strides[i] && buf->shape[i] > 1)) {
- PyErr_SetString(PyExc_ValueError,
- "Buffer not fortran contiguous.");
- goto fail;
- }
- stride = stride * buf->shape[i];
- }
- } else if (c_or_f_flag & __Pyx_IS_C_CONTIG) {
- Py_ssize_t stride = 1;
- for (i = ndim - 1; i >- 1; i--) {
- if (unlikely(stride * buf->itemsize != buf->strides[i] && buf->shape[i] > 1)) {
- PyErr_SetString(PyExc_ValueError,
- "Buffer not C contiguous.");
- goto fail;
- }
- stride = stride * buf->shape[i];
- }
- }
- return 1;
-fail:
- return 0;
-}
-static int __Pyx_ValidateAndInit_memviewslice(
- int *axes_specs,
- int c_or_f_flag,
- int buf_flags,
- int ndim,
- __Pyx_TypeInfo *dtype,
- __Pyx_BufFmt_StackElem stack[],
- __Pyx_memviewslice *memviewslice,
- PyObject *original_obj)
-{
- struct __pyx_memoryview_obj *memview, *new_memview;
- __Pyx_RefNannyDeclarations
- Py_buffer *buf;
- int i, spec = 0, retval = -1;
- __Pyx_BufFmt_Context ctx;
- int from_memoryview = __pyx_memoryview_check(original_obj);
- __Pyx_RefNannySetupContext("ValidateAndInit_memviewslice", 0);
- if (from_memoryview && __pyx_typeinfo_cmp(dtype, ((struct __pyx_memoryview_obj *)
- original_obj)->typeinfo)) {
- memview = (struct __pyx_memoryview_obj *) original_obj;
- new_memview = NULL;
- } else {
- memview = (struct __pyx_memoryview_obj *) __pyx_memoryview_new(
- original_obj, buf_flags, 0, dtype);
- new_memview = memview;
- if (unlikely(!memview))
- goto fail;
- }
- buf = &memview->view;
- if (unlikely(buf->ndim != ndim)) {
- PyErr_Format(PyExc_ValueError,
- "Buffer has wrong number of dimensions (expected %d, got %d)",
- ndim, buf->ndim);
- goto fail;
- }
- if (new_memview) {
- __Pyx_BufFmt_Init(&ctx, stack, dtype);
- if (unlikely(!__Pyx_BufFmt_CheckString(&ctx, buf->format))) goto fail;
- }
- if (unlikely((unsigned) buf->itemsize != dtype->size)) {
- PyErr_Format(PyExc_ValueError,
- "Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "u byte%s) "
- "does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "u byte%s)",
- buf->itemsize,
- (buf->itemsize > 1) ? "s" : "",
- dtype->name,
- dtype->size,
- (dtype->size > 1) ? "s" : "");
- goto fail;
- }
- if (buf->len > 0) {
- for (i = 0; i < ndim; i++) {
- spec = axes_specs[i];
- if (unlikely(!__pyx_check_strides(buf, i, ndim, spec)))
- goto fail;
- if (unlikely(!__pyx_check_suboffsets(buf, i, ndim, spec)))
- goto fail;
- }
- if (unlikely(buf->strides && !__pyx_verify_contig(buf, ndim, c_or_f_flag)))
- goto fail;
- }
- if (unlikely(__Pyx_init_memviewslice(memview, ndim, memviewslice,
- new_memview != NULL) == -1)) {
- goto fail;
- }
- retval = 0;
- goto no_fail;
-fail:
- Py_XDECREF(new_memview);
- retval = -1;
-no_fail:
- __Pyx_RefNannyFinishContext();
- return retval;
-}
-
-/* ObjectToMemviewSlice */
- static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_int(PyObject *obj, int writable_flag) {
- __Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
- __Pyx_BufFmt_StackElem stack[1];
- int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_FOLLOW), (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_FOLLOW), (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_CONTIG) };
- int retcode;
- if (obj == Py_None) {
- result.memview = (struct __pyx_memoryview_obj *) Py_None;
- return result;
- }
- retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, __Pyx_IS_C_CONTIG,
- (PyBUF_C_CONTIGUOUS | PyBUF_FORMAT) | writable_flag, 3,
- &__Pyx_TypeInfo_int, stack,
- &result, obj);
- if (unlikely(retcode == -1))
- goto __pyx_fail;
- return result;
-__pyx_fail:
- result.memview = NULL;
- result.data = NULL;
- return result;
-}
-
-/* ObjectToMemviewSlice */
- static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_d_d_dc_float(PyObject *obj, int writable_flag) {
- __Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
- __Pyx_BufFmt_StackElem stack[1];
- int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_FOLLOW), (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_FOLLOW), (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_CONTIG) };
- int retcode;
- if (obj == Py_None) {
- result.memview = (struct __pyx_memoryview_obj *) Py_None;
- return result;
- }
- retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, __Pyx_IS_C_CONTIG,
- (PyBUF_C_CONTIGUOUS | PyBUF_FORMAT) | writable_flag, 3,
- &__Pyx_TypeInfo_float, stack,
- &result, obj);
- if (unlikely(retcode == -1))
- goto __pyx_fail;
- return result;
-__pyx_fail:
- result.memview = NULL;
- result.data = NULL;
- return result;
-}
-
-/* ObjectToMemviewSlice */
- static CYTHON_INLINE __Pyx_memviewslice __Pyx_PyObject_to_MemoryviewSlice_dc_int(PyObject *obj, int writable_flag) {
- __Pyx_memviewslice result = { 0, 0, { 0 }, { 0 }, { 0 } };
- __Pyx_BufFmt_StackElem stack[1];
- int axes_specs[] = { (__Pyx_MEMVIEW_DIRECT | __Pyx_MEMVIEW_CONTIG) };
- int retcode;
- if (obj == Py_None) {
- result.memview = (struct __pyx_memoryview_obj *) Py_None;
- return result;
- }
- retcode = __Pyx_ValidateAndInit_memviewslice(axes_specs, __Pyx_IS_C_CONTIG,
- (PyBUF_C_CONTIGUOUS | PyBUF_FORMAT) | writable_flag, 1,
- &__Pyx_TypeInfo_int, stack,
- &result, obj);
- if (unlikely(retcode == -1))
- goto __pyx_fail;
- return result;
-__pyx_fail:
- result.memview = NULL;
- result.data = NULL;
- return result;
-}
-
-/* CIntToPy */
- static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
- const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 0;
- const int is_unsigned = neg_one > const_zero;
- if (is_unsigned) {
- if (sizeof(int) < sizeof(long)) {
- return PyInt_FromLong((long) value);
- } else if (sizeof(int) <= sizeof(unsigned long)) {
- return PyLong_FromUnsignedLong((unsigned long) value);
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
- return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
-#endif
- }
- } else {
- if (sizeof(int) <= sizeof(long)) {
- return PyInt_FromLong((long) value);
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
- return PyLong_FromLongLong((PY_LONG_LONG) value);
-#endif
- }
- }
- {
- int one = 1; int little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&value;
- return _PyLong_FromByteArray(bytes, sizeof(int),
- little, !is_unsigned);
- }
-}
-
-/* CIntFromPyVerify */
- #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
- __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
-#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
- __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
-#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
- {\
- func_type value = func_value;\
- if (sizeof(target_type) < sizeof(func_type)) {\
- if (unlikely(value != (func_type) (target_type) value)) {\
- func_type zero = 0;\
- if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
- return (target_type) -1;\
- if (is_unsigned && unlikely(value < zero))\
- goto raise_neg_overflow;\
- else\
- goto raise_overflow;\
- }\
- }\
- return (target_type) value;\
- }
-
-/* CIntToPy */
- static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
- const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0;
- const int is_unsigned = neg_one > const_zero;
- if (is_unsigned) {
- if (sizeof(long) < sizeof(long)) {
- return PyInt_FromLong((long) value);
- } else if (sizeof(long) <= sizeof(unsigned long)) {
- return PyLong_FromUnsignedLong((unsigned long) value);
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
- return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
-#endif
- }
- } else {
- if (sizeof(long) <= sizeof(long)) {
- return PyInt_FromLong((long) value);
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
- return PyLong_FromLongLong((PY_LONG_LONG) value);
-#endif
- }
- }
- {
- int one = 1; int little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&value;
- return _PyLong_FromByteArray(bytes, sizeof(long),
- little, !is_unsigned);
- }
-}
-
-/* MemviewSliceCopyTemplate */
- static __Pyx_memviewslice
-__pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs,
- const char *mode, int ndim,
- size_t sizeof_dtype, int contig_flag,
- int dtype_is_object)
-{
- __Pyx_RefNannyDeclarations
- int i;
- __Pyx_memviewslice new_mvs = { 0, 0, { 0 }, { 0 }, { 0 } };
- struct __pyx_memoryview_obj *from_memview = from_mvs->memview;
- Py_buffer *buf = &from_memview->view;
- PyObject *shape_tuple = NULL;
- PyObject *temp_int = NULL;
- struct __pyx_array_obj *array_obj = NULL;
- struct __pyx_memoryview_obj *memview_obj = NULL;
- __Pyx_RefNannySetupContext("__pyx_memoryview_copy_new_contig", 0);
- for (i = 0; i < ndim; i++) {
- if (unlikely(from_mvs->suboffsets[i] >= 0)) {
- PyErr_Format(PyExc_ValueError, "Cannot copy memoryview slice with "
- "indirect dimensions (axis %d)", i);
- goto fail;
- }
- }
- shape_tuple = PyTuple_New(ndim);
- if (unlikely(!shape_tuple)) {
- goto fail;
- }
- __Pyx_GOTREF(shape_tuple);
- for(i = 0; i < ndim; i++) {
- temp_int = PyInt_FromSsize_t(from_mvs->shape[i]);
- if(unlikely(!temp_int)) {
- goto fail;
- } else {
- PyTuple_SET_ITEM(shape_tuple, i, temp_int);
- temp_int = NULL;
- }
- }
- array_obj = __pyx_array_new(shape_tuple, sizeof_dtype, buf->format, (char *) mode, NULL);
- if (unlikely(!array_obj)) {
- goto fail;
- }
- __Pyx_GOTREF(array_obj);
- memview_obj = (struct __pyx_memoryview_obj *) __pyx_memoryview_new(
- (PyObject *) array_obj, contig_flag,
- dtype_is_object,
- from_mvs->memview->typeinfo);
- if (unlikely(!memview_obj))
- goto fail;
- if (unlikely(__Pyx_init_memviewslice(memview_obj, ndim, &new_mvs, 1) < 0))
- goto fail;
- if (unlikely(__pyx_memoryview_copy_contents(*from_mvs, new_mvs, ndim, ndim,
- dtype_is_object) < 0))
- goto fail;
- goto no_fail;
-fail:
- __Pyx_XDECREF(new_mvs.memview);
- new_mvs.memview = NULL;
- new_mvs.data = NULL;
-no_fail:
- __Pyx_XDECREF(shape_tuple);
- __Pyx_XDECREF(temp_int);
- __Pyx_XDECREF(array_obj);
- __Pyx_RefNannyFinishContext();
- return new_mvs;
-}
-
-/* CIntFromPy */
- static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
- const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 0;
- const int is_unsigned = neg_one > const_zero;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_Check(x))) {
- if (sizeof(int) < sizeof(long)) {
- __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
- } else {
- long val = PyInt_AS_LONG(x);
- if (is_unsigned && unlikely(val < 0)) {
- goto raise_neg_overflow;
- }
- return (int) val;
- }
- } else
-#endif
- if (likely(PyLong_Check(x))) {
- if (is_unsigned) {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (int) 0;
- case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
- case 2:
- if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
- return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
- }
- }
- break;
- case 3:
- if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
- return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
- }
- }
- break;
- case 4:
- if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
- return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
- }
- }
- break;
- }
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON
- if (unlikely(Py_SIZE(x) < 0)) {
- goto raise_neg_overflow;
- }
-#else
- {
- int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
- if (unlikely(result < 0))
- return (int) -1;
- if (unlikely(result == 1))
- goto raise_neg_overflow;
- }
-#endif
- if (sizeof(int) <= sizeof(unsigned long)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
-#endif
- }
- } else {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (int) 0;
- case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
- case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
- case -2:
- if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
- return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case 2:
- if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
- return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case -3:
- if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
- return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case 3:
- if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
- return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case -4:
- if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
- return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- case 4:
- if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
- return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
- }
- }
- break;
- }
-#endif
- if (sizeof(int) <= sizeof(long)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
-#endif
- }
- }
- {
-#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
- PyErr_SetString(PyExc_RuntimeError,
- "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
-#else
- int val;
- PyObject *v = __Pyx_PyNumber_IntOrLong(x);
- #if PY_MAJOR_VERSION < 3
- if (likely(v) && !PyLong_Check(v)) {
- PyObject *tmp = v;
- v = PyNumber_Long(tmp);
- Py_DECREF(tmp);
- }
- #endif
- if (likely(v)) {
- int one = 1; int is_little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&val;
- int ret = _PyLong_AsByteArray((PyLongObject *)v,
- bytes, sizeof(val),
- is_little, !is_unsigned);
- Py_DECREF(v);
- if (likely(!ret))
- return val;
- }
-#endif
- return (int) -1;
- }
- } else {
- int val;
- PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
- if (!tmp) return (int) -1;
- val = __Pyx_PyInt_As_int(tmp);
- Py_DECREF(tmp);
- return val;
- }
-raise_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "value too large to convert to int");
- return (int) -1;
-raise_neg_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "can't convert negative value to int");
- return (int) -1;
-}
-
-/* CIntFromPy */
- static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
- const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0;
- const int is_unsigned = neg_one > const_zero;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_Check(x))) {
- if (sizeof(long) < sizeof(long)) {
- __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
- } else {
- long val = PyInt_AS_LONG(x);
- if (is_unsigned && unlikely(val < 0)) {
- goto raise_neg_overflow;
- }
- return (long) val;
- }
- } else
-#endif
- if (likely(PyLong_Check(x))) {
- if (is_unsigned) {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (long) 0;
- case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
- case 2:
- if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
- return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
- }
- }
- break;
- case 3:
- if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
- return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
- }
- }
- break;
- case 4:
- if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
- return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
- }
- }
- break;
- }
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON
- if (unlikely(Py_SIZE(x) < 0)) {
- goto raise_neg_overflow;
- }
-#else
- {
- int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
- if (unlikely(result < 0))
- return (long) -1;
- if (unlikely(result == 1))
- goto raise_neg_overflow;
- }
-#endif
- if (sizeof(long) <= sizeof(unsigned long)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
-#endif
- }
- } else {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (long) 0;
- case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
- case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
- case -2:
- if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case 2:
- if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case -3:
- if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case 3:
- if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case -4:
- if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
- return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- case 4:
- if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
- return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
- }
- }
- break;
- }
-#endif
- if (sizeof(long) <= sizeof(long)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
-#endif
- }
- }
- {
-#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
- PyErr_SetString(PyExc_RuntimeError,
- "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
-#else
- long val;
- PyObject *v = __Pyx_PyNumber_IntOrLong(x);
- #if PY_MAJOR_VERSION < 3
- if (likely(v) && !PyLong_Check(v)) {
- PyObject *tmp = v;
- v = PyNumber_Long(tmp);
- Py_DECREF(tmp);
- }
- #endif
- if (likely(v)) {
- int one = 1; int is_little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&val;
- int ret = _PyLong_AsByteArray((PyLongObject *)v,
- bytes, sizeof(val),
- is_little, !is_unsigned);
- Py_DECREF(v);
- if (likely(!ret))
- return val;
- }
-#endif
- return (long) -1;
- }
- } else {
- long val;
- PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
- if (!tmp) return (long) -1;
- val = __Pyx_PyInt_As_long(tmp);
- Py_DECREF(tmp);
- return val;
- }
-raise_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "value too large to convert to long");
- return (long) -1;
-raise_neg_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "can't convert negative value to long");
- return (long) -1;
-}
-
-/* CIntFromPy */
- static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *x) {
- const char neg_one = (char) ((char) 0 - (char) 1), const_zero = (char) 0;
- const int is_unsigned = neg_one > const_zero;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_Check(x))) {
- if (sizeof(char) < sizeof(long)) {
- __PYX_VERIFY_RETURN_INT(char, long, PyInt_AS_LONG(x))
- } else {
- long val = PyInt_AS_LONG(x);
- if (is_unsigned && unlikely(val < 0)) {
- goto raise_neg_overflow;
- }
- return (char) val;
- }
- } else
-#endif
- if (likely(PyLong_Check(x))) {
- if (is_unsigned) {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (char) 0;
- case 1: __PYX_VERIFY_RETURN_INT(char, digit, digits[0])
- case 2:
- if (8 * sizeof(char) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(char) >= 2 * PyLong_SHIFT) {
- return (char) (((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0]));
- }
- }
- break;
- case 3:
- if (8 * sizeof(char) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(char) >= 3 * PyLong_SHIFT) {
- return (char) (((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]));
- }
- }
- break;
- case 4:
- if (8 * sizeof(char) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(char) >= 4 * PyLong_SHIFT) {
- return (char) (((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]));
- }
- }
- break;
- }
-#endif
-#if CYTHON_COMPILING_IN_CPYTHON
- if (unlikely(Py_SIZE(x) < 0)) {
- goto raise_neg_overflow;
- }
-#else
- {
- int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
- if (unlikely(result < 0))
- return (char) -1;
- if (unlikely(result == 1))
- goto raise_neg_overflow;
- }
-#endif
- if (sizeof(char) <= sizeof(unsigned long)) {
- __PYX_VERIFY_RETURN_INT_EXC(char, unsigned long, PyLong_AsUnsignedLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(char) <= sizeof(unsigned PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(char, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
-#endif
- }
- } else {
-#if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)x)->ob_digit;
- switch (Py_SIZE(x)) {
- case 0: return (char) 0;
- case -1: __PYX_VERIFY_RETURN_INT(char, sdigit, (sdigit) (-(sdigit)digits[0]))
- case 1: __PYX_VERIFY_RETURN_INT(char, digit, +digits[0])
- case -2:
- if (8 * sizeof(char) - 1 > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) {
- return (char) (((char)-1)*(((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
- }
- }
- break;
- case 2:
- if (8 * sizeof(char) > 1 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) {
- return (char) ((((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
- }
- }
- break;
- case -3:
- if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) {
- return (char) (((char)-1)*(((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
- }
- }
- break;
- case 3:
- if (8 * sizeof(char) > 2 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) {
- return (char) ((((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
- }
- }
- break;
- case -4:
- if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(char) - 1 > 4 * PyLong_SHIFT) {
- return (char) (((char)-1)*(((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
- }
- }
- break;
- case 4:
- if (8 * sizeof(char) > 3 * PyLong_SHIFT) {
- if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
- __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
- } else if (8 * sizeof(char) - 1 > 4 * PyLong_SHIFT) {
- return (char) ((((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])));
- }
- }
- break;
- }
-#endif
- if (sizeof(char) <= sizeof(long)) {
- __PYX_VERIFY_RETURN_INT_EXC(char, long, PyLong_AsLong(x))
-#ifdef HAVE_LONG_LONG
- } else if (sizeof(char) <= sizeof(PY_LONG_LONG)) {
- __PYX_VERIFY_RETURN_INT_EXC(char, PY_LONG_LONG, PyLong_AsLongLong(x))
-#endif
- }
- }
- {
-#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
- PyErr_SetString(PyExc_RuntimeError,
- "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
-#else
- char val;
- PyObject *v = __Pyx_PyNumber_IntOrLong(x);
- #if PY_MAJOR_VERSION < 3
- if (likely(v) && !PyLong_Check(v)) {
- PyObject *tmp = v;
- v = PyNumber_Long(tmp);
- Py_DECREF(tmp);
- }
- #endif
- if (likely(v)) {
- int one = 1; int is_little = (int)*(unsigned char *)&one;
- unsigned char *bytes = (unsigned char *)&val;
- int ret = _PyLong_AsByteArray((PyLongObject *)v,
- bytes, sizeof(val),
- is_little, !is_unsigned);
- Py_DECREF(v);
- if (likely(!ret))
- return val;
- }
-#endif
- return (char) -1;
- }
- } else {
- char val;
- PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
- if (!tmp) return (char) -1;
- val = __Pyx_PyInt_As_char(tmp);
- Py_DECREF(tmp);
- return val;
- }
-raise_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "value too large to convert to char");
- return (char) -1;
-raise_neg_overflow:
- PyErr_SetString(PyExc_OverflowError,
- "can't convert negative value to char");
- return (char) -1;
-}
-
-/* CheckBinaryVersion */
- static int __Pyx_check_binary_version(void) {
- char ctversion[4], rtversion[4];
- PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
- PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
- if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
- char message[200];
- PyOS_snprintf(message, sizeof(message),
- "compiletime version %s of module '%.100s' "
- "does not match runtime version %s",
- ctversion, __Pyx_MODULE_NAME, rtversion);
- return PyErr_WarnEx(NULL, message, 1);
- }
- return 0;
-}
-
-/* InitStrings */
- static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
- while (t->p) {
- #if PY_MAJOR_VERSION < 3
- if (t->is_unicode) {
- *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
- } else if (t->intern) {
- *t->p = PyString_InternFromString(t->s);
- } else {
- *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
- }
- #else
- if (t->is_unicode | t->is_str) {
- if (t->intern) {
- *t->p = PyUnicode_InternFromString(t->s);
- } else if (t->encoding) {
- *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
- } else {
- *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
- }
- } else {
- *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
- }
- #endif
- if (!*t->p)
- return -1;
- if (PyObject_Hash(*t->p) == -1)
- return -1;
- ++t;
- }
- return 0;
-}
-
-static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
- return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
-}
-static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
- Py_ssize_t ignore;
- return __Pyx_PyObject_AsStringAndSize(o, &ignore);
-}
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
-#if !CYTHON_PEP393_ENABLED
-static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
- char* defenc_c;
- PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
- if (!defenc) return NULL;
- defenc_c = PyBytes_AS_STRING(defenc);
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
- {
- char* end = defenc_c + PyBytes_GET_SIZE(defenc);
- char* c;
- for (c = defenc_c; c < end; c++) {
- if ((unsigned char) (*c) >= 128) {
- PyUnicode_AsASCIIString(o);
- return NULL;
- }
- }
- }
-#endif
- *length = PyBytes_GET_SIZE(defenc);
- return defenc_c;
-}
-#else
-static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
- if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
- if (likely(PyUnicode_IS_ASCII(o))) {
- *length = PyUnicode_GET_LENGTH(o);
- return PyUnicode_AsUTF8(o);
- } else {
- PyUnicode_AsASCIIString(o);
- return NULL;
- }
-#else
- return PyUnicode_AsUTF8AndSize(o, length);
-#endif
-}
-#endif
-#endif
-static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
-#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
- if (
-#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
- __Pyx_sys_getdefaultencoding_not_ascii &&
-#endif
- PyUnicode_Check(o)) {
- return __Pyx_PyUnicode_AsStringAndSize(o, length);
- } else
-#endif
-#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
- if (PyByteArray_Check(o)) {
- *length = PyByteArray_GET_SIZE(o);
- return PyByteArray_AS_STRING(o);
- } else
-#endif
- {
- char* result;
- int r = PyBytes_AsStringAndSize(o, &result, length);
- if (unlikely(r < 0)) {
- return NULL;
- } else {
- return result;
- }
- }
-}
-static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
- int is_true = x == Py_True;
- if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
- else return PyObject_IsTrue(x);
-}
-static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
- int retval;
- if (unlikely(!x)) return -1;
- retval = __Pyx_PyObject_IsTrue(x);
- Py_DECREF(x);
- return retval;
-}
-static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
-#if PY_MAJOR_VERSION >= 3
- if (PyLong_Check(result)) {
- if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
- "__int__ returned non-int (type %.200s). "
- "The ability to return an instance of a strict subclass of int "
- "is deprecated, and may be removed in a future version of Python.",
- Py_TYPE(result)->tp_name)) {
- Py_DECREF(result);
- return NULL;
- }
- return result;
- }
-#endif
- PyErr_Format(PyExc_TypeError,
- "__%.4s__ returned non-%.4s (type %.200s)",
- type_name, type_name, Py_TYPE(result)->tp_name);
- Py_DECREF(result);
- return NULL;
-}
-static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
-#if CYTHON_USE_TYPE_SLOTS
- PyNumberMethods *m;
-#endif
- const char *name = NULL;
- PyObject *res = NULL;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_Check(x) || PyLong_Check(x)))
-#else
- if (likely(PyLong_Check(x)))
-#endif
- return __Pyx_NewRef(x);
-#if CYTHON_USE_TYPE_SLOTS
- m = Py_TYPE(x)->tp_as_number;
- #if PY_MAJOR_VERSION < 3
- if (m && m->nb_int) {
- name = "int";
- res = m->nb_int(x);
- }
- else if (m && m->nb_long) {
- name = "long";
- res = m->nb_long(x);
- }
- #else
- if (likely(m && m->nb_int)) {
- name = "int";
- res = m->nb_int(x);
- }
- #endif
-#else
- if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
- res = PyNumber_Int(x);
- }
-#endif
- if (likely(res)) {
-#if PY_MAJOR_VERSION < 3
- if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
-#else
- if (unlikely(!PyLong_CheckExact(res))) {
-#endif
- return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
- }
- }
- else if (!PyErr_Occurred()) {
- PyErr_SetString(PyExc_TypeError,
- "an integer is required");
- }
- return res;
-}
-static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
- Py_ssize_t ival;
- PyObject *x;
-#if PY_MAJOR_VERSION < 3
- if (likely(PyInt_CheckExact(b))) {
- if (sizeof(Py_ssize_t) >= sizeof(long))
- return PyInt_AS_LONG(b);
- else
- return PyInt_AsSsize_t(b);
- }
-#endif
- if (likely(PyLong_CheckExact(b))) {
- #if CYTHON_USE_PYLONG_INTERNALS
- const digit* digits = ((PyLongObject*)b)->ob_digit;
- const Py_ssize_t size = Py_SIZE(b);
- if (likely(__Pyx_sst_abs(size) <= 1)) {
- ival = likely(size) ? digits[0] : 0;
- if (size == -1) ival = -ival;
- return ival;
- } else {
- switch (size) {
- case 2:
- if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
- return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case -2:
- if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
- return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case 3:
- if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
- return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case -3:
- if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
- return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case 4:
- if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
- return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- case -4:
- if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
- return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
- }
- break;
- }
- }
- #endif
- return PyLong_AsSsize_t(b);
- }
- x = PyNumber_Index(b);
- if (!x) return -1;
- ival = PyInt_AsSsize_t(x);
- Py_DECREF(x);
- return ival;
-}
-static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
- return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
-}
-static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
- return PyInt_FromSize_t(ival);
-}
-
-
-#endif /* Py_PYTHON_H */
diff --git a/spaces/PrabhuKiranKonda/fastapi-postgres-todo-api/schemas.py b/spaces/PrabhuKiranKonda/fastapi-postgres-todo-api/schemas.py
deleted file mode 100644
index 6eaf9bda1961f0858a15056cce1f8e26232e5811..0000000000000000000000000000000000000000
--- a/spaces/PrabhuKiranKonda/fastapi-postgres-todo-api/schemas.py
+++ /dev/null
@@ -1,54 +0,0 @@
-# why schemas? it is a way to define the structure of the data sent to the server and the data received from the server
-from pydantic import BaseModel, Field
-import datetime as dt
-
-# template for user data. this is used to validate the data sent to the server
-
-
-class userBase(BaseModel):
- first_name: str = Field(...)
- last_name: str = Field(...)
- email: str = Field(...,)
-
-
-class userCreate(userBase):
- password: str = Field(...) # hashed password
-
- class Config:
- orm_mode = True # to tell pydantic to read the data even if it is not a dict but an ORM model
- schema_extra = {
- "example": {
- "first_name": "John",
- "last_name": "Doe",
- "email": "qpmzj@example.com",
- "password": "password",
- }
- }
-
-
-class User(userBase):
- user_id: int
-
- class Config:
- orm_mode = True
-
-
-class TodoBase(BaseModel):
- task_name: str
- task_description: str
- priority: int
- category: str
- due_date: dt.date
- status: bool = False
-
-
-class TodoCreate(TodoBase):
- pass
-
-
-class Todo(TodoBase):
- todo_id: int
- user_id: int
-
- class Config:
- orm_mode = True
diff --git a/spaces/QianFeng/White-box-Cartoonization2308/wbc/network.py b/spaces/QianFeng/White-box-Cartoonization2308/wbc/network.py
deleted file mode 100644
index 6f16cee1aa1994d0a78c524f459764de5164e637..0000000000000000000000000000000000000000
--- a/spaces/QianFeng/White-box-Cartoonization2308/wbc/network.py
+++ /dev/null
@@ -1,62 +0,0 @@
-import tensorflow as tf
-import numpy as np
-import tensorflow.contrib.slim as slim
-
-
-
-def resblock(inputs, out_channel=32, name='resblock'):
-
- with tf.variable_scope(name):
-
- x = slim.convolution2d(inputs, out_channel, [3, 3],
- activation_fn=None, scope='conv1')
- x = tf.nn.leaky_relu(x)
- x = slim.convolution2d(x, out_channel, [3, 3],
- activation_fn=None, scope='conv2')
-
- return x + inputs
-
-
-
-
-def unet_generator(inputs, channel=32, num_blocks=4, name='generator', reuse=False):
- with tf.variable_scope(name, reuse=reuse):
-
- x0 = slim.convolution2d(inputs, channel, [7, 7], activation_fn=None)
- x0 = tf.nn.leaky_relu(x0)
-
- x1 = slim.convolution2d(x0, channel, [3, 3], stride=2, activation_fn=None)
- x1 = tf.nn.leaky_relu(x1)
- x1 = slim.convolution2d(x1, channel*2, [3, 3], activation_fn=None)
- x1 = tf.nn.leaky_relu(x1)
-
- x2 = slim.convolution2d(x1, channel*2, [3, 3], stride=2, activation_fn=None)
- x2 = tf.nn.leaky_relu(x2)
- x2 = slim.convolution2d(x2, channel*4, [3, 3], activation_fn=None)
- x2 = tf.nn.leaky_relu(x2)
-
- for idx in range(num_blocks):
- x2 = resblock(x2, out_channel=channel*4, name='block_{}'.format(idx))
-
- x2 = slim.convolution2d(x2, channel*2, [3, 3], activation_fn=None)
- x2 = tf.nn.leaky_relu(x2)
-
- h1, w1 = tf.shape(x2)[1], tf.shape(x2)[2]
- x3 = tf.image.resize_bilinear(x2, (h1*2, w1*2))
- x3 = slim.convolution2d(x3+x1, channel*2, [3, 3], activation_fn=None)
- x3 = tf.nn.leaky_relu(x3)
- x3 = slim.convolution2d(x3, channel, [3, 3], activation_fn=None)
- x3 = tf.nn.leaky_relu(x3)
-
- h2, w2 = tf.shape(x3)[1], tf.shape(x3)[2]
- x4 = tf.image.resize_bilinear(x3, (h2*2, w2*2))
- x4 = slim.convolution2d(x4+x0, channel, [3, 3], activation_fn=None)
- x4 = tf.nn.leaky_relu(x4)
- x4 = slim.convolution2d(x4, 3, [7, 7], activation_fn=None)
-
- return x4
-
-if __name__ == '__main__':
-
-
- pass
\ No newline at end of file
diff --git a/spaces/Qrstud/ChatGPT-prompt-generator/README.md b/spaces/Qrstud/ChatGPT-prompt-generator/README.md
deleted file mode 100644
index 9765db2c80dd4c4b938060743922163b1718e003..0000000000000000000000000000000000000000
--- a/spaces/Qrstud/ChatGPT-prompt-generator/README.md
+++ /dev/null
@@ -1,14 +0,0 @@
----
-title: ChatGPT Prompt Generator
-emoji: 👨🏻🎤
-colorFrom: purple
-colorTo: pink
-sdk: gradio
-sdk_version: 3.16.2
-app_file: app.py
-pinned: false
-license: apache-2.0
-duplicated_from: merve/ChatGPT-prompt-generator
----
-
-Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
diff --git a/spaces/RamziRebai/hf_sum/app.py b/spaces/RamziRebai/hf_sum/app.py
deleted file mode 100644
index d4e0bf9b38a2ffa21e4fcc878e791f406122c3b3..0000000000000000000000000000000000000000
--- a/spaces/RamziRebai/hf_sum/app.py
+++ /dev/null
@@ -1,15 +0,0 @@
-from transformers import pipeline
-import gradio as gr
-
-summarizer= pipeline("summarization", model="facebook/bart-large-cnn", framework="tf", truncation=True)
-
-def summarize(text):
- result= summarizer(text, truncation=True, min_length=30, max_length=130)
- return result[0]["summary_text"]
-
-iface= gr.Interface(
- fn= summarize,
- inputs= gr.inputs.Textbox(lines=10, placeholder="please put your text here"),
- outputs="text"
-)
-iface.launch()
\ No newline at end of file
diff --git a/spaces/Raspberry-ai/main/.env/lib/python3.11/site-packages/pip/_vendor/cachecontrol/__init__.py b/spaces/Raspberry-ai/main/.env/lib/python3.11/site-packages/pip/_vendor/cachecontrol/__init__.py
deleted file mode 100644
index f631ae6df4747b808cac7c03b38e3e1d48bea00b..0000000000000000000000000000000000000000
--- a/spaces/Raspberry-ai/main/.env/lib/python3.11/site-packages/pip/_vendor/cachecontrol/__init__.py
+++ /dev/null
@@ -1,18 +0,0 @@
-# SPDX-FileCopyrightText: 2015 Eric Larson
-#
-# SPDX-License-Identifier: Apache-2.0
-
-"""CacheControl import Interface.
-
-Make it easy to import from cachecontrol without long namespaces.
-"""
-__author__ = "Eric Larson"
-__email__ = "eric@ionrock.org"
-__version__ = "0.12.11"
-
-from .wrapper import CacheControl
-from .adapter import CacheControlAdapter
-from .controller import CacheController
-
-import logging
-logging.getLogger(__name__).addHandler(logging.NullHandler())
diff --git a/spaces/Raspberry-ai/main/.env/lib/python3.11/site-packages/pip/_vendor/pygments/formatter.py b/spaces/Raspberry-ai/main/.env/lib/python3.11/site-packages/pip/_vendor/pygments/formatter.py
deleted file mode 100644
index a2349ef8652c659388ba69477c01989f2e4ce17d..0000000000000000000000000000000000000000
--- a/spaces/Raspberry-ai/main/.env/lib/python3.11/site-packages/pip/_vendor/pygments/formatter.py
+++ /dev/null
@@ -1,94 +0,0 @@
-"""
- pygments.formatter
- ~~~~~~~~~~~~~~~~~~
-
- Base formatter class.
-
- :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS.
- :license: BSD, see LICENSE for details.
-"""
-
-import codecs
-
-from pip._vendor.pygments.util import get_bool_opt
-from pip._vendor.pygments.styles import get_style_by_name
-
-__all__ = ['Formatter']
-
-
-def _lookup_style(style):
- if isinstance(style, str):
- return get_style_by_name(style)
- return style
-
-
-class Formatter:
- """
- Converts a token stream to text.
-
- Options accepted:
-
- ``style``
- The style to use, can be a string or a Style subclass
- (default: "default"). Not used by e.g. the
- TerminalFormatter.
- ``full``
- Tells the formatter to output a "full" document, i.e.
- a complete self-contained document. This doesn't have
- any effect for some formatters (default: false).
- ``title``
- If ``full`` is true, the title that should be used to
- caption the document (default: '').
- ``encoding``
- If given, must be an encoding name. This will be used to
- convert the Unicode token strings to byte strings in the
- output. If it is "" or None, Unicode strings will be written
- to the output file, which most file-like objects do not
- support (default: None).
- ``outencoding``
- Overrides ``encoding`` if given.
- """
-
- #: Name of the formatter
- name = None
-
- #: Shortcuts for the formatter
- aliases = []
-
- #: fn match rules
- filenames = []
-
- #: If True, this formatter outputs Unicode strings when no encoding
- #: option is given.
- unicodeoutput = True
-
- def __init__(self, **options):
- self.style = _lookup_style(options.get('style', 'default'))
- self.full = get_bool_opt(options, 'full', False)
- self.title = options.get('title', '')
- self.encoding = options.get('encoding', None) or None
- if self.encoding in ('guess', 'chardet'):
- # can happen for e.g. pygmentize -O encoding=guess
- self.encoding = 'utf-8'
- self.encoding = options.get('outencoding') or self.encoding
- self.options = options
-
- def get_style_defs(self, arg=''):
- """
- Return the style definitions for the current style as a string.
-
- ``arg`` is an additional argument whose meaning depends on the
- formatter used. Note that ``arg`` can also be a list or tuple
- for some formatters like the html formatter.
- """
- return ''
-
- def format(self, tokensource, outfile):
- """
- Format ``tokensource``, an iterable of ``(tokentype, tokenstring)``
- tuples and write it into ``outfile``.
- """
- if self.encoding:
- # wrap the outfile in a StreamWriter
- outfile = codecs.lookup(self.encoding)[3](outfile)
- return self.format_unencoded(tokensource, outfile)
diff --git a/spaces/Raspberry-ai/main/.env/lib/python3.11/site-packages/setuptools/_distutils/command/bdist_dumb.py b/spaces/Raspberry-ai/main/.env/lib/python3.11/site-packages/setuptools/_distutils/command/bdist_dumb.py
deleted file mode 100644
index 0f52330f67728e5f02d1673dc9683e95f6f9d294..0000000000000000000000000000000000000000
--- a/spaces/Raspberry-ai/main/.env/lib/python3.11/site-packages/setuptools/_distutils/command/bdist_dumb.py
+++ /dev/null
@@ -1,144 +0,0 @@
-"""distutils.command.bdist_dumb
-
-Implements the Distutils 'bdist_dumb' command (create a "dumb" built
-distribution -- i.e., just an archive to be unpacked under $prefix or
-$exec_prefix)."""
-
-import os
-from distutils.core import Command
-from distutils.util import get_platform
-from distutils.dir_util import remove_tree, ensure_relative
-from distutils.errors import DistutilsPlatformError
-from distutils.sysconfig import get_python_version
-from distutils import log
-
-
-class bdist_dumb(Command):
-
- description = "create a \"dumb\" built distribution"
-
- user_options = [
- ('bdist-dir=', 'd', "temporary directory for creating the distribution"),
- (
- 'plat-name=',
- 'p',
- "platform name to embed in generated filenames "
- "(default: %s)" % get_platform(),
- ),
- (
- 'format=',
- 'f',
- "archive format to create (tar, gztar, bztar, xztar, " "ztar, zip)",
- ),
- (
- 'keep-temp',
- 'k',
- "keep the pseudo-installation tree around after "
- + "creating the distribution archive",
- ),
- ('dist-dir=', 'd', "directory to put final built distributions in"),
- ('skip-build', None, "skip rebuilding everything (for testing/debugging)"),
- (
- 'relative',
- None,
- "build the archive using relative paths " "(default: false)",
- ),
- (
- 'owner=',
- 'u',
- "Owner name used when creating a tar file" " [default: current user]",
- ),
- (
- 'group=',
- 'g',
- "Group name used when creating a tar file" " [default: current group]",
- ),
- ]
-
- boolean_options = ['keep-temp', 'skip-build', 'relative']
-
- default_format = {'posix': 'gztar', 'nt': 'zip'}
-
- def initialize_options(self):
- self.bdist_dir = None
- self.plat_name = None
- self.format = None
- self.keep_temp = 0
- self.dist_dir = None
- self.skip_build = None
- self.relative = 0
- self.owner = None
- self.group = None
-
- def finalize_options(self):
- if self.bdist_dir is None:
- bdist_base = self.get_finalized_command('bdist').bdist_base
- self.bdist_dir = os.path.join(bdist_base, 'dumb')
-
- if self.format is None:
- try:
- self.format = self.default_format[os.name]
- except KeyError:
- raise DistutilsPlatformError(
- "don't know how to create dumb built distributions "
- "on platform %s" % os.name
- )
-
- self.set_undefined_options(
- 'bdist',
- ('dist_dir', 'dist_dir'),
- ('plat_name', 'plat_name'),
- ('skip_build', 'skip_build'),
- )
-
- def run(self):
- if not self.skip_build:
- self.run_command('build')
-
- install = self.reinitialize_command('install', reinit_subcommands=1)
- install.root = self.bdist_dir
- install.skip_build = self.skip_build
- install.warn_dir = 0
-
- log.info("installing to %s", self.bdist_dir)
- self.run_command('install')
-
- # And make an archive relative to the root of the
- # pseudo-installation tree.
- archive_basename = "{}.{}".format(
- self.distribution.get_fullname(), self.plat_name
- )
-
- pseudoinstall_root = os.path.join(self.dist_dir, archive_basename)
- if not self.relative:
- archive_root = self.bdist_dir
- else:
- if self.distribution.has_ext_modules() and (
- install.install_base != install.install_platbase
- ):
- raise DistutilsPlatformError(
- "can't make a dumb built distribution where "
- "base and platbase are different (%s, %s)"
- % (repr(install.install_base), repr(install.install_platbase))
- )
- else:
- archive_root = os.path.join(
- self.bdist_dir, ensure_relative(install.install_base)
- )
-
- # Make the archive
- filename = self.make_archive(
- pseudoinstall_root,
- self.format,
- root_dir=archive_root,
- owner=self.owner,
- group=self.group,
- )
- if self.distribution.has_ext_modules():
- pyversion = get_python_version()
- else:
- pyversion = 'any'
- self.distribution.dist_files.append(('bdist_dumb', pyversion, filename))
-
- if not self.keep_temp:
- remove_tree(self.bdist_dir, dry_run=self.dry_run)
diff --git a/spaces/Realcat/image-matching-webui/third_party/SOLD2/sold2/config/__init__.py b/spaces/Realcat/image-matching-webui/third_party/SOLD2/sold2/config/__init__.py
deleted file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000
diff --git a/spaces/Robert001/UniControl-Demo/annotator/uniformer/mmcv/runner/hooks/__init__.py b/spaces/Robert001/UniControl-Demo/annotator/uniformer/mmcv/runner/hooks/__init__.py
deleted file mode 100644
index 915af28cefab14a14c1188ed861161080fd138a3..0000000000000000000000000000000000000000
--- a/spaces/Robert001/UniControl-Demo/annotator/uniformer/mmcv/runner/hooks/__init__.py
+++ /dev/null
@@ -1,29 +0,0 @@
-# Copyright (c) OpenMMLab. All rights reserved.
-from .checkpoint import CheckpointHook
-from .closure import ClosureHook
-from .ema import EMAHook
-from .evaluation import DistEvalHook, EvalHook
-from .hook import HOOKS, Hook
-from .iter_timer import IterTimerHook
-from .logger import (DvcliveLoggerHook, LoggerHook, MlflowLoggerHook,
- NeptuneLoggerHook, PaviLoggerHook, TensorboardLoggerHook,
- TextLoggerHook, WandbLoggerHook)
-from .lr_updater import LrUpdaterHook
-from .memory import EmptyCacheHook
-from .momentum_updater import MomentumUpdaterHook
-from .optimizer import (Fp16OptimizerHook, GradientCumulativeFp16OptimizerHook,
- GradientCumulativeOptimizerHook, OptimizerHook)
-from .profiler import ProfilerHook
-from .sampler_seed import DistSamplerSeedHook
-from .sync_buffer import SyncBuffersHook
-
-__all__ = [
- 'HOOKS', 'Hook', 'CheckpointHook', 'ClosureHook', 'LrUpdaterHook',
- 'OptimizerHook', 'Fp16OptimizerHook', 'IterTimerHook',
- 'DistSamplerSeedHook', 'EmptyCacheHook', 'LoggerHook', 'MlflowLoggerHook',
- 'PaviLoggerHook', 'TextLoggerHook', 'TensorboardLoggerHook',
- 'NeptuneLoggerHook', 'WandbLoggerHook', 'DvcliveLoggerHook',
- 'MomentumUpdaterHook', 'SyncBuffersHook', 'EMAHook', 'EvalHook',
- 'DistEvalHook', 'ProfilerHook', 'GradientCumulativeOptimizerHook',
- 'GradientCumulativeFp16OptimizerHook'
-]
diff --git a/spaces/Robert001/UniControl-Demo/annotator/uniformer/mmdet_null/core/bbox/samplers/__init__.py b/spaces/Robert001/UniControl-Demo/annotator/uniformer/mmdet_null/core/bbox/samplers/__init__.py
deleted file mode 100644
index 0b06303fe1000e11c5486c40c70606a34a5208e3..0000000000000000000000000000000000000000
--- a/spaces/Robert001/UniControl-Demo/annotator/uniformer/mmdet_null/core/bbox/samplers/__init__.py
+++ /dev/null
@@ -1,15 +0,0 @@
-from .base_sampler import BaseSampler
-from .combined_sampler import CombinedSampler
-from .instance_balanced_pos_sampler import InstanceBalancedPosSampler
-from .iou_balanced_neg_sampler import IoUBalancedNegSampler
-from .ohem_sampler import OHEMSampler
-from .pseudo_sampler import PseudoSampler
-from .random_sampler import RandomSampler
-from .sampling_result import SamplingResult
-from .score_hlr_sampler import ScoreHLRSampler
-
-__all__ = [
- 'BaseSampler', 'PseudoSampler', 'RandomSampler',
- 'InstanceBalancedPosSampler', 'IoUBalancedNegSampler', 'CombinedSampler',
- 'OHEMSampler', 'SamplingResult', 'ScoreHLRSampler'
-]
diff --git a/spaces/Rongjiehuang/ProDiff/modules/parallel_wavegan/layers/upsample.py b/spaces/Rongjiehuang/ProDiff/modules/parallel_wavegan/layers/upsample.py
deleted file mode 100644
index 18c6397c420a81fadc5320e3a48f3249534decd8..0000000000000000000000000000000000000000
--- a/spaces/Rongjiehuang/ProDiff/modules/parallel_wavegan/layers/upsample.py
+++ /dev/null
@@ -1,183 +0,0 @@
-# -*- coding: utf-8 -*-
-
-"""Upsampling module.
-
-This code is modified from https://github.com/r9y9/wavenet_vocoder.
-
-"""
-
-import numpy as np
-import torch
-import torch.nn.functional as F
-
-from . import Conv1d
-
-
-class Stretch2d(torch.nn.Module):
- """Stretch2d module."""
-
- def __init__(self, x_scale, y_scale, mode="nearest"):
- """Initialize Stretch2d module.
-
- Args:
- x_scale (int): X scaling factor (Time axis in spectrogram).
- y_scale (int): Y scaling factor (Frequency axis in spectrogram).
- mode (str): Interpolation mode.
-
- """
- super(Stretch2d, self).__init__()
- self.x_scale = x_scale
- self.y_scale = y_scale
- self.mode = mode
-
- def forward(self, x):
- """Calculate forward propagation.
-
- Args:
- x (Tensor): Input tensor (B, C, F, T).
-
- Returns:
- Tensor: Interpolated tensor (B, C, F * y_scale, T * x_scale),
-
- """
- return F.interpolate(
- x, scale_factor=(self.y_scale, self.x_scale), mode=self.mode)
-
-
-class Conv2d(torch.nn.Conv2d):
- """Conv2d module with customized initialization."""
-
- def __init__(self, *args, **kwargs):
- """Initialize Conv2d module."""
- super(Conv2d, self).__init__(*args, **kwargs)
-
- def reset_parameters(self):
- """Reset parameters."""
- self.weight.data.fill_(1. / np.prod(self.kernel_size))
- if self.bias is not None:
- torch.nn.init.constant_(self.bias, 0.0)
-
-
-class UpsampleNetwork(torch.nn.Module):
- """Upsampling network module."""
-
- def __init__(self,
- upsample_scales,
- nonlinear_activation=None,
- nonlinear_activation_params={},
- interpolate_mode="nearest",
- freq_axis_kernel_size=1,
- use_causal_conv=False,
- ):
- """Initialize upsampling network module.
-
- Args:
- upsample_scales (list): List of upsampling scales.
- nonlinear_activation (str): Activation function name.
- nonlinear_activation_params (dict): Arguments for specified activation function.
- interpolate_mode (str): Interpolation mode.
- freq_axis_kernel_size (int): Kernel size in the direction of frequency axis.
-
- """
- super(UpsampleNetwork, self).__init__()
- self.use_causal_conv = use_causal_conv
- self.up_layers = torch.nn.ModuleList()
- for scale in upsample_scales:
- # interpolation layer
- stretch = Stretch2d(scale, 1, interpolate_mode)
- self.up_layers += [stretch]
-
- # conv layer
- assert (freq_axis_kernel_size - 1) % 2 == 0, "Not support even number freq axis kernel size."
- freq_axis_padding = (freq_axis_kernel_size - 1) // 2
- kernel_size = (freq_axis_kernel_size, scale * 2 + 1)
- if use_causal_conv:
- padding = (freq_axis_padding, scale * 2)
- else:
- padding = (freq_axis_padding, scale)
- conv = Conv2d(1, 1, kernel_size=kernel_size, padding=padding, bias=False)
- self.up_layers += [conv]
-
- # nonlinear
- if nonlinear_activation is not None:
- nonlinear = getattr(torch.nn, nonlinear_activation)(**nonlinear_activation_params)
- self.up_layers += [nonlinear]
-
- def forward(self, c):
- """Calculate forward propagation.
-
- Args:
- c : Input tensor (B, C, T).
-
- Returns:
- Tensor: Upsampled tensor (B, C, T'), where T' = T * prod(upsample_scales).
-
- """
- c = c.unsqueeze(1) # (B, 1, C, T)
- for f in self.up_layers:
- if self.use_causal_conv and isinstance(f, Conv2d):
- c = f(c)[..., :c.size(-1)]
- else:
- c = f(c)
- return c.squeeze(1) # (B, C, T')
-
-
-class ConvInUpsampleNetwork(torch.nn.Module):
- """Convolution + upsampling network module."""
-
- def __init__(self,
- upsample_scales,
- nonlinear_activation=None,
- nonlinear_activation_params={},
- interpolate_mode="nearest",
- freq_axis_kernel_size=1,
- aux_channels=80,
- aux_context_window=0,
- use_causal_conv=False
- ):
- """Initialize convolution + upsampling network module.
-
- Args:
- upsample_scales (list): List of upsampling scales.
- nonlinear_activation (str): Activation function name.
- nonlinear_activation_params (dict): Arguments for specified activation function.
- mode (str): Interpolation mode.
- freq_axis_kernel_size (int): Kernel size in the direction of frequency axis.
- aux_channels (int): Number of channels of pre-convolutional layer.
- aux_context_window (int): Context window size of the pre-convolutional layer.
- use_causal_conv (bool): Whether to use causal structure.
-
- """
- super(ConvInUpsampleNetwork, self).__init__()
- self.aux_context_window = aux_context_window
- self.use_causal_conv = use_causal_conv and aux_context_window > 0
- # To capture wide-context information in conditional features
- kernel_size = aux_context_window + 1 if use_causal_conv else 2 * aux_context_window + 1
- # NOTE(kan-bayashi): Here do not use padding because the input is already padded
- self.conv_in = Conv1d(aux_channels, aux_channels, kernel_size=kernel_size, bias=False)
- self.upsample = UpsampleNetwork(
- upsample_scales=upsample_scales,
- nonlinear_activation=nonlinear_activation,
- nonlinear_activation_params=nonlinear_activation_params,
- interpolate_mode=interpolate_mode,
- freq_axis_kernel_size=freq_axis_kernel_size,
- use_causal_conv=use_causal_conv,
- )
-
- def forward(self, c):
- """Calculate forward propagation.
-
- Args:
- c : Input tensor (B, C, T').
-
- Returns:
- Tensor: Upsampled tensor (B, C, T),
- where T = (T' - aux_context_window * 2) * prod(upsample_scales).
-
- Note:
- The length of inputs considers the context window size.
-
- """
- c_ = self.conv_in(c)
- c = c_[:, :, :-self.aux_context_window] if self.use_causal_conv else c_
- return self.upsample(c)
diff --git a/spaces/Rongjiehuang/ProDiff/modules/parallel_wavegan/optimizers/__init__.py b/spaces/Rongjiehuang/ProDiff/modules/parallel_wavegan/optimizers/__init__.py
deleted file mode 100644
index a0e0c5932838281e912079e5784d84d43444a61a..0000000000000000000000000000000000000000
--- a/spaces/Rongjiehuang/ProDiff/modules/parallel_wavegan/optimizers/__init__.py
+++ /dev/null
@@ -1,2 +0,0 @@
-from torch.optim import * # NOQA
-from .radam import * # NOQA
diff --git a/spaces/Sarst/VITS-Umamusume-voice-synthesizer2/attentions.py b/spaces/Sarst/VITS-Umamusume-voice-synthesizer2/attentions.py
deleted file mode 100644
index 86bc73b5fe98cc7b443e9078553920346c996707..0000000000000000000000000000000000000000
--- a/spaces/Sarst/VITS-Umamusume-voice-synthesizer2/attentions.py
+++ /dev/null
@@ -1,300 +0,0 @@
-import math
-import torch
-from torch import nn
-from torch.nn import functional as F
-
-import commons
-from modules import LayerNorm
-
-
-class Encoder(nn.Module):
- def __init__(self, hidden_channels, filter_channels, n_heads, n_layers, kernel_size=1, p_dropout=0., window_size=4, **kwargs):
- super().__init__()
- self.hidden_channels = hidden_channels
- self.filter_channels = filter_channels
- self.n_heads = n_heads
- self.n_layers = n_layers
- self.kernel_size = kernel_size
- self.p_dropout = p_dropout
- self.window_size = window_size
-
- self.drop = nn.Dropout(p_dropout)
- self.attn_layers = nn.ModuleList()
- self.norm_layers_1 = nn.ModuleList()
- self.ffn_layers = nn.ModuleList()
- self.norm_layers_2 = nn.ModuleList()
- for i in range(self.n_layers):
- self.attn_layers.append(MultiHeadAttention(hidden_channels, hidden_channels, n_heads, p_dropout=p_dropout, window_size=window_size))
- self.norm_layers_1.append(LayerNorm(hidden_channels))
- self.ffn_layers.append(FFN(hidden_channels, hidden_channels, filter_channels, kernel_size, p_dropout=p_dropout))
- self.norm_layers_2.append(LayerNorm(hidden_channels))
-
- def forward(self, x, x_mask):
- attn_mask = x_mask.unsqueeze(2) * x_mask.unsqueeze(-1)
- x = x * x_mask
- for i in range(self.n_layers):
- y = self.attn_layers[i](x, x, attn_mask)
- y = self.drop(y)
- x = self.norm_layers_1[i](x + y)
-
- y = self.ffn_layers[i](x, x_mask)
- y = self.drop(y)
- x = self.norm_layers_2[i](x + y)
- x = x * x_mask
- return x
-
-
-class Decoder(nn.Module):
- def __init__(self, hidden_channels, filter_channels, n_heads, n_layers, kernel_size=1, p_dropout=0., proximal_bias=False, proximal_init=True, **kwargs):
- super().__init__()
- self.hidden_channels = hidden_channels
- self.filter_channels = filter_channels
- self.n_heads = n_heads
- self.n_layers = n_layers
- self.kernel_size = kernel_size
- self.p_dropout = p_dropout
- self.proximal_bias = proximal_bias
- self.proximal_init = proximal_init
-
- self.drop = nn.Dropout(p_dropout)
- self.self_attn_layers = nn.ModuleList()
- self.norm_layers_0 = nn.ModuleList()
- self.encdec_attn_layers = nn.ModuleList()
- self.norm_layers_1 = nn.ModuleList()
- self.ffn_layers = nn.ModuleList()
- self.norm_layers_2 = nn.ModuleList()
- for i in range(self.n_layers):
- self.self_attn_layers.append(MultiHeadAttention(hidden_channels, hidden_channels, n_heads, p_dropout=p_dropout, proximal_bias=proximal_bias, proximal_init=proximal_init))
- self.norm_layers_0.append(LayerNorm(hidden_channels))
- self.encdec_attn_layers.append(MultiHeadAttention(hidden_channels, hidden_channels, n_heads, p_dropout=p_dropout))
- self.norm_layers_1.append(LayerNorm(hidden_channels))
- self.ffn_layers.append(FFN(hidden_channels, hidden_channels, filter_channels, kernel_size, p_dropout=p_dropout, causal=True))
- self.norm_layers_2.append(LayerNorm(hidden_channels))
-
- def forward(self, x, x_mask, h, h_mask):
- """
- x: decoder input
- h: encoder output
- """
- self_attn_mask = commons.subsequent_mask(x_mask.size(2)).to(device=x.device, dtype=x.dtype)
- encdec_attn_mask = h_mask.unsqueeze(2) * x_mask.unsqueeze(-1)
- x = x * x_mask
- for i in range(self.n_layers):
- y = self.self_attn_layers[i](x, x, self_attn_mask)
- y = self.drop(y)
- x = self.norm_layers_0[i](x + y)
-
- y = self.encdec_attn_layers[i](x, h, encdec_attn_mask)
- y = self.drop(y)
- x = self.norm_layers_1[i](x + y)
-
- y = self.ffn_layers[i](x, x_mask)
- y = self.drop(y)
- x = self.norm_layers_2[i](x + y)
- x = x * x_mask
- return x
-
-
-class MultiHeadAttention(nn.Module):
- def __init__(self, channels, out_channels, n_heads, p_dropout=0., window_size=None, heads_share=True, block_length=None, proximal_bias=False, proximal_init=False):
- super().__init__()
- assert channels % n_heads == 0
-
- self.channels = channels
- self.out_channels = out_channels
- self.n_heads = n_heads
- self.p_dropout = p_dropout
- self.window_size = window_size
- self.heads_share = heads_share
- self.block_length = block_length
- self.proximal_bias = proximal_bias
- self.proximal_init = proximal_init
- self.attn = None
-
- self.k_channels = channels // n_heads
- self.conv_q = nn.Conv1d(channels, channels, 1)
- self.conv_k = nn.Conv1d(channels, channels, 1)
- self.conv_v = nn.Conv1d(channels, channels, 1)
- self.conv_o = nn.Conv1d(channels, out_channels, 1)
- self.drop = nn.Dropout(p_dropout)
-
- if window_size is not None:
- n_heads_rel = 1 if heads_share else n_heads
- rel_stddev = self.k_channels**-0.5
- self.emb_rel_k = nn.Parameter(torch.randn(n_heads_rel, window_size * 2 + 1, self.k_channels) * rel_stddev)
- self.emb_rel_v = nn.Parameter(torch.randn(n_heads_rel, window_size * 2 + 1, self.k_channels) * rel_stddev)
-
- nn.init.xavier_uniform_(self.conv_q.weight)
- nn.init.xavier_uniform_(self.conv_k.weight)
- nn.init.xavier_uniform_(self.conv_v.weight)
- if proximal_init:
- with torch.no_grad():
- self.conv_k.weight.copy_(self.conv_q.weight)
- self.conv_k.bias.copy_(self.conv_q.bias)
-
- def forward(self, x, c, attn_mask=None):
- q = self.conv_q(x)
- k = self.conv_k(c)
- v = self.conv_v(c)
-
- x, self.attn = self.attention(q, k, v, mask=attn_mask)
-
- x = self.conv_o(x)
- return x
-
- def attention(self, query, key, value, mask=None):
- # reshape [b, d, t] -> [b, n_h, t, d_k]
- b, d, t_s, t_t = (*key.size(), query.size(2))
- query = query.view(b, self.n_heads, self.k_channels, t_t).transpose(2, 3)
- key = key.view(b, self.n_heads, self.k_channels, t_s).transpose(2, 3)
- value = value.view(b, self.n_heads, self.k_channels, t_s).transpose(2, 3)
-
- scores = torch.matmul(query / math.sqrt(self.k_channels), key.transpose(-2, -1))
- if self.window_size is not None:
- assert t_s == t_t, "Relative attention is only available for self-attention."
- key_relative_embeddings = self._get_relative_embeddings(self.emb_rel_k, t_s)
- rel_logits = self._matmul_with_relative_keys(query /math.sqrt(self.k_channels), key_relative_embeddings)
- scores_local = self._relative_position_to_absolute_position(rel_logits)
- scores = scores + scores_local
- if self.proximal_bias:
- assert t_s == t_t, "Proximal bias is only available for self-attention."
- scores = scores + self._attention_bias_proximal(t_s).to(device=scores.device, dtype=scores.dtype)
- if mask is not None:
- scores = scores.masked_fill(mask == 0, -1e4)
- if self.block_length is not None:
- assert t_s == t_t, "Local attention is only available for self-attention."
- block_mask = torch.ones_like(scores).triu(-self.block_length).tril(self.block_length)
- scores = scores.masked_fill(block_mask == 0, -1e4)
- p_attn = F.softmax(scores, dim=-1) # [b, n_h, t_t, t_s]
- p_attn = self.drop(p_attn)
- output = torch.matmul(p_attn, value)
- if self.window_size is not None:
- relative_weights = self._absolute_position_to_relative_position(p_attn)
- value_relative_embeddings = self._get_relative_embeddings(self.emb_rel_v, t_s)
- output = output + self._matmul_with_relative_values(relative_weights, value_relative_embeddings)
- output = output.transpose(2, 3).contiguous().view(b, d, t_t) # [b, n_h, t_t, d_k] -> [b, d, t_t]
- return output, p_attn
-
- def _matmul_with_relative_values(self, x, y):
- """
- x: [b, h, l, m]
- y: [h or 1, m, d]
- ret: [b, h, l, d]
- """
- ret = torch.matmul(x, y.unsqueeze(0))
- return ret
-
- def _matmul_with_relative_keys(self, x, y):
- """
- x: [b, h, l, d]
- y: [h or 1, m, d]
- ret: [b, h, l, m]
- """
- ret = torch.matmul(x, y.unsqueeze(0).transpose(-2, -1))
- return ret
-
- def _get_relative_embeddings(self, relative_embeddings, length):
- max_relative_position = 2 * self.window_size + 1
- # Pad first before slice to avoid using cond ops.
- pad_length = max(length - (self.window_size + 1), 0)
- slice_start_position = max((self.window_size + 1) - length, 0)
- slice_end_position = slice_start_position + 2 * length - 1
- if pad_length > 0:
- padded_relative_embeddings = F.pad(
- relative_embeddings,
- commons.convert_pad_shape([[0, 0], [pad_length, pad_length], [0, 0]]))
- else:
- padded_relative_embeddings = relative_embeddings
- used_relative_embeddings = padded_relative_embeddings[:,slice_start_position:slice_end_position]
- return used_relative_embeddings
-
- def _relative_position_to_absolute_position(self, x):
- """
- x: [b, h, l, 2*l-1]
- ret: [b, h, l, l]
- """
- batch, heads, length, _ = x.size()
- # Concat columns of pad to shift from relative to absolute indexing.
- x = F.pad(x, commons.convert_pad_shape([[0,0],[0,0],[0,0],[0,1]]))
-
- # Concat extra elements so to add up to shape (len+1, 2*len-1).
- x_flat = x.view([batch, heads, length * 2 * length])
- x_flat = F.pad(x_flat, commons.convert_pad_shape([[0,0],[0,0],[0,length-1]]))
-
- # Reshape and slice out the padded elements.
- x_final = x_flat.view([batch, heads, length+1, 2*length-1])[:, :, :length, length-1:]
- return x_final
-
- def _absolute_position_to_relative_position(self, x):
- """
- x: [b, h, l, l]
- ret: [b, h, l, 2*l-1]
- """
- batch, heads, length, _ = x.size()
- # padd along column
- x = F.pad(x, commons.convert_pad_shape([[0, 0], [0, 0], [0, 0], [0, length-1]]))
- x_flat = x.view([batch, heads, length**2 + length*(length -1)])
- # add 0's in the beginning that will skew the elements after reshape
- x_flat = F.pad(x_flat, commons.convert_pad_shape([[0, 0], [0, 0], [length, 0]]))
- x_final = x_flat.view([batch, heads, length, 2*length])[:,:,:,1:]
- return x_final
-
- def _attention_bias_proximal(self, length):
- """Bias for self-attention to encourage attention to close positions.
- Args:
- length: an integer scalar.
- Returns:
- a Tensor with shape [1, 1, length, length]
- """
- r = torch.arange(length, dtype=torch.float32)
- diff = torch.unsqueeze(r, 0) - torch.unsqueeze(r, 1)
- return torch.unsqueeze(torch.unsqueeze(-torch.log1p(torch.abs(diff)), 0), 0)
-
-
-class FFN(nn.Module):
- def __init__(self, in_channels, out_channels, filter_channels, kernel_size, p_dropout=0., activation=None, causal=False):
- super().__init__()
- self.in_channels = in_channels
- self.out_channels = out_channels
- self.filter_channels = filter_channels
- self.kernel_size = kernel_size
- self.p_dropout = p_dropout
- self.activation = activation
- self.causal = causal
-
- if causal:
- self.padding = self._causal_padding
- else:
- self.padding = self._same_padding
-
- self.conv_1 = nn.Conv1d(in_channels, filter_channels, kernel_size)
- self.conv_2 = nn.Conv1d(filter_channels, out_channels, kernel_size)
- self.drop = nn.Dropout(p_dropout)
-
- def forward(self, x, x_mask):
- x = self.conv_1(self.padding(x * x_mask))
- if self.activation == "gelu":
- x = x * torch.sigmoid(1.702 * x)
- else:
- x = torch.relu(x)
- x = self.drop(x)
- x = self.conv_2(self.padding(x * x_mask))
- return x * x_mask
-
- def _causal_padding(self, x):
- if self.kernel_size == 1:
- return x
- pad_l = self.kernel_size - 1
- pad_r = 0
- padding = [[0, 0], [0, 0], [pad_l, pad_r]]
- x = F.pad(x, commons.convert_pad_shape(padding))
- return x
-
- def _same_padding(self, x):
- if self.kernel_size == 1:
- return x
- pad_l = (self.kernel_size - 1) // 2
- pad_r = self.kernel_size // 2
- padding = [[0, 0], [0, 0], [pad_l, pad_r]]
- x = F.pad(x, commons.convert_pad_shape(padding))
- return x
diff --git a/spaces/Shad0ws/Information_Extraction_with_ChatGPT/README.md b/spaces/Shad0ws/Information_Extraction_with_ChatGPT/README.md
deleted file mode 100644
index b7e203a277b7a79eb5b9eea5b4107c1ff08e88f1..0000000000000000000000000000000000000000
--- a/spaces/Shad0ws/Information_Extraction_with_ChatGPT/README.md
+++ /dev/null
@@ -1,13 +0,0 @@
----
-title: Information Extraction With ChatGPT
-emoji: 📉
-colorFrom: indigo
-colorTo: red
-sdk: gradio
-sdk_version: 3.16.2
-app_file: app.py
-pinned: false
-license: mit
----
-
-Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
diff --git a/spaces/Shakeb100/GroomingGenie_AI/clipseg/setup.py b/spaces/Shakeb100/GroomingGenie_AI/clipseg/setup.py
deleted file mode 100644
index 2bf28ffe269cba3033af263db5f98313772818f0..0000000000000000000000000000000000000000
--- a/spaces/Shakeb100/GroomingGenie_AI/clipseg/setup.py
+++ /dev/null
@@ -1,30 +0,0 @@
-from setuptools import setup
-
-with open("README.md", "r", encoding="utf-8") as readme_file:
- readme = readme_file.read()
-
-requirements = [
- "numpy",
- "scipy",
- "matplotlib",
- "torch",
- "torchvision",
- "opencv-python",
- "CLIP @ git+https://github.com/openai/CLIP.git"
-]
-
-setup(
- name='clipseg',
- packages=['clipseg'],
- package_dir={'clipseg': 'models'},
- package_data={'clipseg': [
- "../weights/*.pth",
- ]},
- version='0.0.1',
- url='https://github.com/timojl/clipseg',
- python_requires='>=3.9',
- install_requires=requirements,
- description='This repository contains the code used in the paper "Image Segmentation Using Text and Image Prompts".',
- long_description=readme,
- long_description_content_type="text/markdown",
-)
diff --git a/spaces/SilenWang/ReviewGPT/utils/pubmed.py b/spaces/SilenWang/ReviewGPT/utils/pubmed.py
deleted file mode 100644
index 77ed4caeec8cc2e3406c167c1e3a7b49760ab0e9..0000000000000000000000000000000000000000
--- a/spaces/SilenWang/ReviewGPT/utils/pubmed.py
+++ /dev/null
@@ -1,44 +0,0 @@
-from Bio import Entrez
-
-try:
- from utils.config import EMAIL
-except ImportError:
- from utils.config_sample import EMAIL
-
-
-class PubMedFetcher:
- def __init__(self, email=None, pmids=None):
- self.email = email if email else EMAIL
- self.pmids = pmids
-
-
- def fetch_abstract(self):
- # 设置email和搜索关键词
- Entrez.email = self.email
-
- # 使用文章ID批量获取文章的题录和摘要信息
- handle = Entrez.efetch(db="pubmed", id=self.pmids, rettype="abstract", retmode="xml")
- fetch_record = Entrez.read(handle)
-
- # print(self.pmids)
-
- articles = []
- for idx, rec in enumerate(fetch_record["PubmedArticle"]):
- articles.append({
- 'PMID': self.pmids[idx],
- 'Title': rec["MedlineCitation"]["Article"]["ArticleTitle"],
- 'Abstract': rec["MedlineCitation"]["Article"]["Abstract"]["AbstractText"][0] if "Abstract" in rec["MedlineCitation"]["Article"] else ""
- })
-
- return articles
-
-
-if __name__ == '__main__':
-
- # 设置邮箱地址,提供给NCBI用于联系
-
- id_list = [26502953, 19016404, 25837277, 34209617, 35602107]
-
- fetcher = PubMedFetcher(email=EMAIL, pmids=id_list)
-
- print(fetcher.fetch_abstract())
diff --git a/spaces/Sonnt/Fracture_Webapp/ui/UIConfigs.py b/spaces/Sonnt/Fracture_Webapp/ui/UIConfigs.py
deleted file mode 100644
index d893162a3dea24503c6efe974240dae24d3c9842..0000000000000000000000000000000000000000
--- a/spaces/Sonnt/Fracture_Webapp/ui/UIConfigs.py
+++ /dev/null
@@ -1,41 +0,0 @@
-import streamlit as st
-from PIL import Image
-
-def hide_menu_button():
- st.markdown(""" """, unsafe_allow_html=True
- )
-
-def condense_layout():
- padding = 0
- st.markdown(f""" """, unsafe_allow_html=True
- )
-
-def set_page_config(page:str='home', logo_size:str=200, pagetile:str=None):
- img = Image.open("/home/user/app/LogoVPI.png")
- st.set_page_config(# Alternate names: setup_page, page, layout
- layout="wide", # Can be "centered" or "wide". In the future also "dashboard", etc.
- initial_sidebar_state="auto", # Can be "auto", "expanded", "collapsed"
- page_title="VPI-MLogs", # String or None. Strings get appended with "• Streamlit".
- page_icon=img, # String, anything supported by st.image, or None.
- )
- if page == 'home':
- col_1, col_2, col_3, col_4, col_5, = st.columns(5)
- with col_3:
- st.image("https://i.ibb.co/Yd42K98/LogoVPI.png", width=logo_size)
- elif page == 'sub':
- logo, info = st.columns([3, 7])
- with logo:
- st.image("https://i.ibb.co/Yd42K98/LogoVPI.png", width=logo_size)
- with info:
- st.markdown(pagetile, unsafe_allow_html=True)
-
-
\ No newline at end of file
diff --git a/spaces/SungBeom/chatwine-korean/.venv/Lib/site-packages/IPython/utils/py3compat.py b/spaces/SungBeom/chatwine-korean/.venv/Lib/site-packages/IPython/utils/py3compat.py
deleted file mode 100644
index 34af4c58f42bad6de0e9562b2029089f41d813a2..0000000000000000000000000000000000000000
--- a/spaces/SungBeom/chatwine-korean/.venv/Lib/site-packages/IPython/utils/py3compat.py
+++ /dev/null
@@ -1,67 +0,0 @@
-# coding: utf-8
-"""Compatibility tricks for Python 3. Mainly to do with unicode.
-
-This file is deprecated and will be removed in a future version.
-"""
-import platform
-import builtins as builtin_mod
-
-from .encoding import DEFAULT_ENCODING
-
-
-def decode(s, encoding=None):
- encoding = encoding or DEFAULT_ENCODING
- return s.decode(encoding, "replace")
-
-
-def encode(u, encoding=None):
- encoding = encoding or DEFAULT_ENCODING
- return u.encode(encoding, "replace")
-
-
-def cast_unicode(s, encoding=None):
- if isinstance(s, bytes):
- return decode(s, encoding)
- return s
-
-
-def safe_unicode(e):
- """unicode(e) with various fallbacks. Used for exceptions, which may not be
- safe to call unicode() on.
- """
- try:
- return str(e)
- except UnicodeError:
- pass
-
- try:
- return repr(e)
- except UnicodeError:
- pass
-
- return "Unrecoverably corrupt evalue"
-
-
-# keep reference to builtin_mod because the kernel overrides that value
-# to forward requests to a frontend.
-def input(prompt=""):
- return builtin_mod.input(prompt)
-
-
-def execfile(fname, glob, loc=None, compiler=None):
- loc = loc if (loc is not None) else glob
- with open(fname, "rb") as f:
- compiler = compiler or compile
- exec(compiler(f.read(), fname, "exec"), glob, loc)
-
-
-PYPY = platform.python_implementation() == "PyPy"
-
-# Cython still rely on that as a Dec 28 2019
-# See https://github.com/cython/cython/pull/3291 and
-# https://github.com/ipython/ipython/issues/12068
-def no_code(x, encoding=None):
- return x
-
-
-unicode_to_str = cast_bytes_py2 = no_code
diff --git a/spaces/SungBeom/chatwine-korean/.venv/Lib/site-packages/PIL/MpoImagePlugin.py b/spaces/SungBeom/chatwine-korean/.venv/Lib/site-packages/PIL/MpoImagePlugin.py
deleted file mode 100644
index f9261c77d6862d7def90c6136dff6449241b0690..0000000000000000000000000000000000000000
--- a/spaces/SungBeom/chatwine-korean/.venv/Lib/site-packages/PIL/MpoImagePlugin.py
+++ /dev/null
@@ -1,197 +0,0 @@
-#
-# The Python Imaging Library.
-# $Id$
-#
-# MPO file handling
-#
-# See "Multi-Picture Format" (CIPA DC-007-Translation 2009, Standard of the
-# Camera & Imaging Products Association)
-#
-# The multi-picture object combines multiple JPEG images (with a modified EXIF
-# data format) into a single file. While it can theoretically be used much like
-# a GIF animation, it is commonly used to represent 3D photographs and is (as
-# of this writing) the most commonly used format by 3D cameras.
-#
-# History:
-# 2014-03-13 Feneric Created
-#
-# See the README file for information on usage and redistribution.
-#
-
-import itertools
-import os
-import struct
-
-from . import (
- ExifTags,
- Image,
- ImageFile,
- ImageSequence,
- JpegImagePlugin,
- TiffImagePlugin,
-)
-from ._binary import i16be as i16
-from ._binary import o32le
-
-# def _accept(prefix):
-# return JpegImagePlugin._accept(prefix)
-
-
-def _save(im, fp, filename):
- JpegImagePlugin._save(im, fp, filename)
-
-
-def _save_all(im, fp, filename):
- append_images = im.encoderinfo.get("append_images", [])
- if not append_images:
- try:
- animated = im.is_animated
- except AttributeError:
- animated = False
- if not animated:
- _save(im, fp, filename)
- return
-
- mpf_offset = 28
- offsets = []
- for imSequence in itertools.chain([im], append_images):
- for im_frame in ImageSequence.Iterator(imSequence):
- if not offsets:
- # APP2 marker
- im_frame.encoderinfo["extra"] = (
- b"\xFF\xE2" + struct.pack(">H", 6 + 82) + b"MPF\0" + b" " * 82
- )
- exif = im_frame.encoderinfo.get("exif")
- if isinstance(exif, Image.Exif):
- exif = exif.tobytes()
- im_frame.encoderinfo["exif"] = exif
- if exif:
- mpf_offset += 4 + len(exif)
-
- JpegImagePlugin._save(im_frame, fp, filename)
- offsets.append(fp.tell())
- else:
- im_frame.save(fp, "JPEG")
- offsets.append(fp.tell() - offsets[-1])
-
- ifd = TiffImagePlugin.ImageFileDirectory_v2()
- ifd[0xB000] = b"0100"
- ifd[0xB001] = len(offsets)
-
- mpentries = b""
- data_offset = 0
- for i, size in enumerate(offsets):
- if i == 0:
- mptype = 0x030000 # Baseline MP Primary Image
- else:
- mptype = 0x000000 # Undefined
- mpentries += struct.pack(" 1
- self._fp = self.fp # FIXME: hack
- self._fp.seek(self.__mpoffsets[0]) # get ready to read first frame
- self.__frame = 0
- self.offset = 0
- # for now we can only handle reading and individual frame extraction
- self.readonly = 1
-
- def load_seek(self, pos):
- self._fp.seek(pos)
-
- def seek(self, frame):
- if not self._seek_check(frame):
- return
- self.fp = self._fp
- self.offset = self.__mpoffsets[frame]
-
- self.fp.seek(self.offset + 2) # skip SOI marker
- segment = self.fp.read(2)
- if not segment:
- msg = "No data found for frame"
- raise ValueError(msg)
- self._size = self._initial_size
- if i16(segment) == 0xFFE1: # APP1
- n = i16(self.fp.read(2)) - 2
- self.info["exif"] = ImageFile._safe_read(self.fp, n)
- self._reload_exif()
-
- mptype = self.mpinfo[0xB002][frame]["Attribute"]["MPType"]
- if mptype.startswith("Large Thumbnail"):
- exif = self.getexif().get_ifd(ExifTags.IFD.Exif)
- if 40962 in exif and 40963 in exif:
- self._size = (exif[40962], exif[40963])
- elif "exif" in self.info:
- del self.info["exif"]
- self._reload_exif()
-
- self.tile = [("jpeg", (0, 0) + self.size, self.offset, (self.mode, ""))]
- self.__frame = frame
-
- def tell(self):
- return self.__frame
-
- @staticmethod
- def adopt(jpeg_instance, mpheader=None):
- """
- Transform the instance of JpegImageFile into
- an instance of MpoImageFile.
- After the call, the JpegImageFile is extended
- to be an MpoImageFile.
-
- This is essentially useful when opening a JPEG
- file that reveals itself as an MPO, to avoid
- double call to _open.
- """
- jpeg_instance.__class__ = MpoImageFile
- jpeg_instance._after_jpeg_open(mpheader)
- return jpeg_instance
-
-
-# ---------------------------------------------------------------------
-# Registry stuff
-
-# Note that since MPO shares a factory with JPEG, we do not need to do a
-# separate registration for it here.
-# Image.register_open(MpoImageFile.format,
-# JpegImagePlugin.jpeg_factory, _accept)
-Image.register_save(MpoImageFile.format, _save)
-Image.register_save_all(MpoImageFile.format, _save_all)
-
-Image.register_extension(MpoImageFile.format, ".mpo")
-
-Image.register_mime(MpoImageFile.format, "image/mpo")
diff --git a/spaces/SungBeom/chatwine-korean/.venv/Lib/site-packages/adodbapi/adodbapi.py b/spaces/SungBeom/chatwine-korean/.venv/Lib/site-packages/adodbapi/adodbapi.py
deleted file mode 100644
index 8f7c045ea7531fc6ea91405252aaaf20c5eb6e9a..0000000000000000000000000000000000000000
--- a/spaces/SungBeom/chatwine-korean/.venv/Lib/site-packages/adodbapi/adodbapi.py
+++ /dev/null
@@ -1,1223 +0,0 @@
-"""adodbapi - A python DB API 2.0 (PEP 249) interface to Microsoft ADO
-
-Copyright (C) 2002 Henrik Ekelund, versions 2.1 and later by Vernon Cole
-* http://sourceforge.net/projects/pywin32
-* https://github.com/mhammond/pywin32
-* http://sourceforge.net/projects/adodbapi
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- django adaptations and refactoring by Adam Vandenberg
-
-DB-API 2.0 specification: http://www.python.org/dev/peps/pep-0249/
-
-This module source should run correctly in CPython versions 2.7 and later,
-or IronPython version 2.7 and later,
-or, after running through 2to3.py, CPython 3.4 or later.
-"""
-
-__version__ = "2.6.2.0"
-version = "adodbapi v" + __version__
-
-import copy
-import decimal
-import os
-import sys
-import weakref
-
-from . import ado_consts as adc, apibase as api, process_connect_string
-
-try:
- verbose = int(os.environ["ADODBAPI_VERBOSE"])
-except:
- verbose = False
-if verbose:
- print(version)
-
-# --- define objects to smooth out IronPython <-> CPython differences
-onWin32 = False # assume the worst
-if api.onIronPython:
- from clr import Reference
- from System import (
- Activator,
- Array,
- Byte,
- DateTime,
- DBNull,
- Decimal as SystemDecimal,
- Type,
- )
-
- def Dispatch(dispatch):
- type = Type.GetTypeFromProgID(dispatch)
- return Activator.CreateInstance(type)
-
- def getIndexedValue(obj, index):
- return obj.Item[index]
-
-else: # try pywin32
- try:
- import pythoncom
- import pywintypes
- import win32com.client
-
- onWin32 = True
-
- def Dispatch(dispatch):
- return win32com.client.Dispatch(dispatch)
-
- except ImportError:
- import warnings
-
- warnings.warn(
- "pywin32 package (or IronPython) required for adodbapi.", ImportWarning
- )
-
- def getIndexedValue(obj, index):
- return obj(index)
-
-
-from collections.abc import Mapping
-
-# --- define objects to smooth out Python3000 <-> Python 2.x differences
-unicodeType = str
-longType = int
-StringTypes = str
-maxint = sys.maxsize
-
-
-# ----------------- The .connect method -----------------
-def make_COM_connecter():
- try:
- if onWin32:
- pythoncom.CoInitialize() # v2.1 Paj
- c = Dispatch("ADODB.Connection") # connect _after_ CoIninialize v2.1.1 adamvan
- except:
- raise api.InterfaceError(
- "Windows COM Error: Dispatch('ADODB.Connection') failed."
- )
- return c
-
-
-def connect(*args, **kwargs): # --> a db-api connection object
- """Connect to a database.
-
- call using:
- :connection_string -- An ADODB formatted connection string, see:
- * http://www.connectionstrings.com
- * http://www.asp101.com/articles/john/connstring/default.asp
- :timeout -- A command timeout value, in seconds (default 30 seconds)
- """
- co = Connection() # make an empty connection object
-
- kwargs = process_connect_string.process(args, kwargs, True)
-
- try: # connect to the database, using the connection information in kwargs
- co.connect(kwargs)
- return co
- except Exception as e:
- message = 'Error opening connection to "%s"' % co.connection_string
- raise api.OperationalError(e, message)
-
-
-# so you could use something like:
-# myConnection.paramstyle = 'named'
-# The programmer may also change the default.
-# For example, if I were using django, I would say:
-# import adodbapi as Database
-# Database.adodbapi.paramstyle = 'format'
-
-# ------- other module level defaults --------
-defaultIsolationLevel = adc.adXactReadCommitted
-# Set defaultIsolationLevel on module level before creating the connection.
-# For example:
-# import adodbapi, ado_consts
-# adodbapi.adodbapi.defaultIsolationLevel=ado_consts.adXactBrowse"
-#
-# Set defaultCursorLocation on module level before creating the connection.
-# It may be one of the "adUse..." consts.
-defaultCursorLocation = adc.adUseClient # changed from adUseServer as of v 2.3.0
-
-dateconverter = api.pythonDateTimeConverter() # default
-
-
-def format_parameters(ADOparameters, show_value=False):
- """Format a collection of ADO Command Parameters.
-
- Used by error reporting in _execute_command.
- """
- try:
- if show_value:
- desc = [
- 'Name: %s, Dir.: %s, Type: %s, Size: %s, Value: "%s", Precision: %s, NumericScale: %s'
- % (
- p.Name,
- adc.directions[p.Direction],
- adc.adTypeNames.get(p.Type, str(p.Type) + " (unknown type)"),
- p.Size,
- p.Value,
- p.Precision,
- p.NumericScale,
- )
- for p in ADOparameters
- ]
- else:
- desc = [
- "Name: %s, Dir.: %s, Type: %s, Size: %s, Precision: %s, NumericScale: %s"
- % (
- p.Name,
- adc.directions[p.Direction],
- adc.adTypeNames.get(p.Type, str(p.Type) + " (unknown type)"),
- p.Size,
- p.Precision,
- p.NumericScale,
- )
- for p in ADOparameters
- ]
- return "[" + "\n".join(desc) + "]"
- except:
- return "[]"
-
-
-def _configure_parameter(p, value, adotype, settings_known):
- """Configure the given ADO Parameter 'p' with the Python 'value'."""
-
- if adotype in api.adoBinaryTypes:
- p.Size = len(value)
- p.AppendChunk(value)
-
- elif isinstance(value, StringTypes): # v2.1 Jevon
- L = len(value)
- if adotype in api.adoStringTypes: # v2.2.1 Cole
- if settings_known:
- L = min(L, p.Size) # v2.1 Cole limit data to defined size
- p.Value = value[:L] # v2.1 Jevon & v2.1 Cole
- else:
- p.Value = value # dont limit if db column is numeric
- if L > 0: # v2.1 Cole something does not like p.Size as Zero
- p.Size = L # v2.1 Jevon
-
- elif isinstance(value, decimal.Decimal):
- if api.onIronPython:
- s = str(value)
- p.Value = s
- p.Size = len(s)
- else:
- p.Value = value
- exponent = value.as_tuple()[2]
- digit_count = len(value.as_tuple()[1])
- p.Precision = digit_count
- if exponent == 0:
- p.NumericScale = 0
- elif exponent < 0:
- p.NumericScale = -exponent
- if p.Precision < p.NumericScale:
- p.Precision = p.NumericScale
- else: # exponent > 0:
- p.NumericScale = 0
- p.Precision = digit_count + exponent
-
- elif type(value) in dateconverter.types:
- if settings_known and adotype in api.adoDateTimeTypes:
- p.Value = dateconverter.COMDate(value)
- else: # probably a string
- # provide the date as a string in the format 'YYYY-MM-dd'
- s = dateconverter.DateObjectToIsoFormatString(value)
- p.Value = s
- p.Size = len(s)
-
- elif api.onIronPython and isinstance(value, longType): # Iron Python Long
- s = str(value) # feature workaround for IPy 2.0
- p.Value = s
-
- elif adotype == adc.adEmpty: # ADO will not let you specify a null column
- p.Type = (
- adc.adInteger
- ) # so we will fake it to be an integer (just to have something)
- p.Value = None # and pass in a Null *value*
-
- # For any other type, set the value and let pythoncom do the right thing.
- else:
- p.Value = value
-
-
-# # # # # ----- the Class that defines a connection ----- # # # # #
-class Connection(object):
- # include connection attributes as class attributes required by api definition.
- Warning = api.Warning
- Error = api.Error
- InterfaceError = api.InterfaceError
- DataError = api.DataError
- DatabaseError = api.DatabaseError
- OperationalError = api.OperationalError
- IntegrityError = api.IntegrityError
- InternalError = api.InternalError
- NotSupportedError = api.NotSupportedError
- ProgrammingError = api.ProgrammingError
- FetchFailedError = api.FetchFailedError # (special for django)
- # ...class attributes... (can be overridden by instance attributes)
- verbose = api.verbose
-
- @property
- def dbapi(self): # a proposed db-api version 3 extension.
- "Return a reference to the DBAPI module for this Connection."
- return api
-
- def __init__(self): # now define the instance attributes
- self.connector = None
- self.paramstyle = api.paramstyle
- self.supportsTransactions = False
- self.connection_string = ""
- self.cursors = weakref.WeakValueDictionary()
- self.dbms_name = ""
- self.dbms_version = ""
- self.errorhandler = None # use the standard error handler for this instance
- self.transaction_level = 0 # 0 == Not in a transaction, at the top level
- self._autocommit = False
-
- def connect(self, kwargs, connection_maker=make_COM_connecter):
- if verbose > 9:
- print("kwargs=", repr(kwargs))
- try:
- self.connection_string = (
- kwargs["connection_string"] % kwargs
- ) # insert keyword arguments
- except Exception as e:
- self._raiseConnectionError(
- KeyError, "Python string format error in connection string->"
- )
- self.timeout = kwargs.get("timeout", 30)
- self.mode = kwargs.get("mode", adc.adModeUnknown)
- self.kwargs = kwargs
- if verbose:
- print('%s attempting: "%s"' % (version, self.connection_string))
- self.connector = connection_maker()
- self.connector.ConnectionTimeout = self.timeout
- self.connector.ConnectionString = self.connection_string
- self.connector.Mode = self.mode
-
- try:
- self.connector.Open() # Open the ADO connection
- except api.Error:
- self._raiseConnectionError(
- api.DatabaseError,
- "ADO error trying to Open=%s" % self.connection_string,
- )
-
- try: # Stefan Fuchs; support WINCCOLEDBProvider
- if getIndexedValue(self.connector.Properties, "Transaction DDL").Value != 0:
- self.supportsTransactions = True
- except pywintypes.com_error:
- pass # Stefan Fuchs
- self.dbms_name = getIndexedValue(self.connector.Properties, "DBMS Name").Value
- try: # Stefan Fuchs
- self.dbms_version = getIndexedValue(
- self.connector.Properties, "DBMS Version"
- ).Value
- except pywintypes.com_error:
- pass # Stefan Fuchs
- self.connector.CursorLocation = defaultCursorLocation # v2.1 Rose
- if self.supportsTransactions:
- self.connector.IsolationLevel = defaultIsolationLevel
- self._autocommit = bool(kwargs.get("autocommit", False))
- if not self._autocommit:
- self.transaction_level = (
- self.connector.BeginTrans()
- ) # Disables autocommit & inits transaction_level
- else:
- self._autocommit = True
- if "paramstyle" in kwargs:
- self.paramstyle = kwargs["paramstyle"] # let setattr do the error checking
- self.messages = []
- if verbose:
- print("adodbapi New connection at %X" % id(self))
-
- def _raiseConnectionError(self, errorclass, errorvalue):
- eh = self.errorhandler
- if eh is None:
- eh = api.standardErrorHandler
- eh(self, None, errorclass, errorvalue)
-
- def _closeAdoConnection(self): # all v2.1 Rose
- """close the underlying ADO Connection object,
- rolling it back first if it supports transactions."""
- if self.connector is None:
- return
- if not self._autocommit:
- if self.transaction_level:
- try:
- self.connector.RollbackTrans()
- except:
- pass
- self.connector.Close()
- if verbose:
- print("adodbapi Closed connection at %X" % id(self))
-
- def close(self):
- """Close the connection now (rather than whenever __del__ is called).
-
- The connection will be unusable from this point forward;
- an Error (or subclass) exception will be raised if any operation is attempted with the connection.
- The same applies to all cursor objects trying to use the connection.
- """
- for crsr in list(self.cursors.values())[
- :
- ]: # copy the list, then close each one
- crsr.close(dont_tell_me=True) # close without back-link clearing
- self.messages = []
- try:
- self._closeAdoConnection() # v2.1 Rose
- except Exception as e:
- self._raiseConnectionError(sys.exc_info()[0], sys.exc_info()[1])
-
- self.connector = None # v2.4.2.2 fix subtle timeout bug
- # per M.Hammond: "I expect the benefits of uninitializing are probably fairly small,
- # so never uninitializing will probably not cause any problems."
-
- def commit(self):
- """Commit any pending transaction to the database.
-
- Note that if the database supports an auto-commit feature,
- this must be initially off. An interface method may be provided to turn it back on.
- Database modules that do not support transactions should implement this method with void functionality.
- """
- self.messages = []
- if not self.supportsTransactions:
- return
-
- try:
- self.transaction_level = self.connector.CommitTrans()
- if verbose > 1:
- print("commit done on connection at %X" % id(self))
- if not (
- self._autocommit
- or (self.connector.Attributes & adc.adXactAbortRetaining)
- ):
- # If attributes has adXactCommitRetaining it performs retaining commits that is,
- # calling CommitTrans automatically starts a new transaction. Not all providers support this.
- # If not, we will have to start a new transaction by this command:
- self.transaction_level = self.connector.BeginTrans()
- except Exception as e:
- self._raiseConnectionError(api.ProgrammingError, e)
-
- def _rollback(self):
- """In case a database does provide transactions this method causes the the database to roll back to
- the start of any pending transaction. Closing a connection without committing the changes first will
- cause an implicit rollback to be performed.
-
- If the database does not support the functionality required by the method, the interface should
- throw an exception in case the method is used.
- The preferred approach is to not implement the method and thus have Python generate
- an AttributeError in case the method is requested. This allows the programmer to check for database
- capabilities using the standard hasattr() function.
-
- For some dynamically configured interfaces it may not be appropriate to require dynamically making
- the method available. These interfaces should then raise a NotSupportedError to indicate the
- non-ability to perform the roll back when the method is invoked.
- """
- self.messages = []
- if (
- self.transaction_level
- ): # trying to roll back with no open transaction causes an error
- try:
- self.transaction_level = self.connector.RollbackTrans()
- if verbose > 1:
- print("rollback done on connection at %X" % id(self))
- if not self._autocommit and not (
- self.connector.Attributes & adc.adXactAbortRetaining
- ):
- # If attributes has adXactAbortRetaining it performs retaining aborts that is,
- # calling RollbackTrans automatically starts a new transaction. Not all providers support this.
- # If not, we will have to start a new transaction by this command:
- if (
- not self.transaction_level
- ): # if self.transaction_level == 0 or self.transaction_level is None:
- self.transaction_level = self.connector.BeginTrans()
- except Exception as e:
- self._raiseConnectionError(api.ProgrammingError, e)
-
- def __setattr__(self, name, value):
- if name == "autocommit": # extension: allow user to turn autocommit on or off
- if self.supportsTransactions:
- object.__setattr__(self, "_autocommit", bool(value))
- try:
- self._rollback() # must clear any outstanding transactions
- except:
- pass
- return
- elif name == "paramstyle":
- if value not in api.accepted_paramstyles:
- self._raiseConnectionError(
- api.NotSupportedError,
- 'paramstyle="%s" not in:%s'
- % (value, repr(api.accepted_paramstyles)),
- )
- elif name == "variantConversions":
- value = copy.copy(
- value
- ) # make a new copy -- no changes in the default, please
- object.__setattr__(self, name, value)
-
- def __getattr__(self, item):
- if (
- item == "rollback"
- ): # the rollback method only appears if the database supports transactions
- if self.supportsTransactions:
- return (
- self._rollback
- ) # return the rollback method so the caller can execute it.
- else:
- raise AttributeError("this data provider does not support Rollback")
- elif item == "autocommit":
- return self._autocommit
- else:
- raise AttributeError(
- 'no such attribute in ADO connection object as="%s"' % item
- )
-
- def cursor(self):
- "Return a new Cursor Object using the connection."
- self.messages = []
- c = Cursor(self)
- return c
-
- def _i_am_here(self, crsr):
- "message from a new cursor proclaiming its existence"
- oid = id(crsr)
- self.cursors[oid] = crsr
-
- def _i_am_closing(self, crsr):
- "message from a cursor giving connection a chance to clean up"
- try:
- del self.cursors[id(crsr)]
- except:
- pass
-
- def printADOerrors(self):
- j = self.connector.Errors.Count
- if j:
- print("ADO Errors:(%i)" % j)
- for e in self.connector.Errors:
- print("Description: %s" % e.Description)
- print("Error: %s %s " % (e.Number, adc.adoErrors.get(e.Number, "unknown")))
- if e.Number == adc.ado_error_TIMEOUT:
- print(
- "Timeout Error: Try using adodbpi.connect(constr,timeout=Nseconds)"
- )
- print("Source: %s" % e.Source)
- print("NativeError: %s" % e.NativeError)
- print("SQL State: %s" % e.SQLState)
-
- def _suggest_error_class(self):
- """Introspect the current ADO Errors and determine an appropriate error class.
-
- Error.SQLState is a SQL-defined error condition, per the SQL specification:
- http://www.contrib.andrew.cmu.edu/~shadow/sql/sql1992.txt
-
- The 23000 class of errors are integrity errors.
- Error 40002 is a transactional integrity error.
- """
- if self.connector is not None:
- for e in self.connector.Errors:
- state = str(e.SQLState)
- if state.startswith("23") or state == "40002":
- return api.IntegrityError
- return api.DatabaseError
-
- def __del__(self):
- try:
- self._closeAdoConnection() # v2.1 Rose
- except:
- pass
- self.connector = None
-
- def __enter__(self): # Connections are context managers
- return self
-
- def __exit__(self, exc_type, exc_val, exc_tb):
- if exc_type:
- self._rollback() # automatic rollback on errors
- else:
- self.commit()
-
- def get_table_names(self):
- schema = self.connector.OpenSchema(20) # constant = adSchemaTables
-
- tables = []
- while not schema.EOF:
- name = getIndexedValue(schema.Fields, "TABLE_NAME").Value
- tables.append(name)
- schema.MoveNext()
- del schema
- return tables
-
-
-# # # # # ----- the Class that defines a cursor ----- # # # # #
-class Cursor(object):
- ## ** api required attributes:
- ## description...
- ## This read-only attribute is a sequence of 7-item sequences.
- ## Each of these sequences contains information describing one result column:
- ## (name, type_code, display_size, internal_size, precision, scale, null_ok).
- ## This attribute will be None for operations that do not return rows or if the
- ## cursor has not had an operation invoked via the executeXXX() method yet.
- ## The type_code can be interpreted by comparing it to the Type Objects specified in the section below.
- ## rowcount...
- ## This read-only attribute specifies the number of rows that the last executeXXX() produced
- ## (for DQL statements like select) or affected (for DML statements like update or insert).
- ## The attribute is -1 in case no executeXXX() has been performed on the cursor or
- ## the rowcount of the last operation is not determinable by the interface.[7]
- ## arraysize...
- ## This read/write attribute specifies the number of rows to fetch at a time with fetchmany().
- ## It defaults to 1 meaning to fetch a single row at a time.
- ## Implementations must observe this value with respect to the fetchmany() method,
- ## but are free to interact with the database a single row at a time.
- ## It may also be used in the implementation of executemany().
- ## ** extension attributes:
- ## paramstyle...
- ## allows the programmer to override the connection's default paramstyle
- ## errorhandler...
- ## allows the programmer to override the connection's default error handler
-
- def __init__(self, connection):
- self.command = None
- self._ado_prepared = False
- self.messages = []
- self.connection = connection
- self.paramstyle = connection.paramstyle # used for overriding the paramstyle
- self._parameter_names = []
- self.recordset_is_remote = False
- self.rs = None # the ADO recordset for this cursor
- self.converters = [] # conversion function for each column
- self.columnNames = {} # names of columns {lowercase name : number,...}
- self.numberOfColumns = 0
- self._description = None
- self.rowcount = -1
- self.errorhandler = connection.errorhandler
- self.arraysize = 1
- connection._i_am_here(self)
- if verbose:
- print(
- "%s New cursor at %X on conn %X"
- % (version, id(self), id(self.connection))
- )
-
- def __iter__(self): # [2.1 Zamarev]
- return iter(self.fetchone, None) # [2.1 Zamarev]
-
- def prepare(self, operation):
- self.command = operation
- self._description = None
- self._ado_prepared = "setup"
-
- def __next__(self):
- r = self.fetchone()
- if r:
- return r
- raise StopIteration
-
- def __enter__(self):
- "Allow database cursors to be used with context managers."
- return self
-
- def __exit__(self, exc_type, exc_val, exc_tb):
- "Allow database cursors to be used with context managers."
- self.close()
-
- def _raiseCursorError(self, errorclass, errorvalue):
- eh = self.errorhandler
- if eh is None:
- eh = api.standardErrorHandler
- eh(self.connection, self, errorclass, errorvalue)
-
- def build_column_info(self, recordset):
- self.converters = [] # convertion function for each column
- self.columnNames = {} # names of columns {lowercase name : number,...}
- self._description = None
-
- # if EOF and BOF are true at the same time, there are no records in the recordset
- if (recordset is None) or (recordset.State == adc.adStateClosed):
- self.rs = None
- self.numberOfColumns = 0
- return
- self.rs = recordset # v2.1.1 bkline
- self.recordset_format = api.RS_ARRAY if api.onIronPython else api.RS_WIN_32
- self.numberOfColumns = recordset.Fields.Count
- try:
- varCon = self.connection.variantConversions
- except AttributeError:
- varCon = api.variantConversions
- for i in range(self.numberOfColumns):
- f = getIndexedValue(self.rs.Fields, i)
- try:
- self.converters.append(
- varCon[f.Type]
- ) # conversion function for this column
- except KeyError:
- self._raiseCursorError(
- api.InternalError, "Data column of Unknown ADO type=%s" % f.Type
- )
- self.columnNames[f.Name.lower()] = i # columnNames lookup
-
- def _makeDescriptionFromRS(self):
- # Abort if closed or no recordset.
- if self.rs is None:
- self._description = None
- return
- desc = []
- for i in range(self.numberOfColumns):
- f = getIndexedValue(self.rs.Fields, i)
- if self.rs.EOF or self.rs.BOF:
- display_size = None
- else:
- display_size = (
- f.ActualSize
- ) # TODO: Is this the correct defintion according to the DB API 2 Spec ?
- null_ok = bool(f.Attributes & adc.adFldMayBeNull) # v2.1 Cole
- desc.append(
- (
- f.Name,
- f.Type,
- display_size,
- f.DefinedSize,
- f.Precision,
- f.NumericScale,
- null_ok,
- )
- )
- self._description = desc
-
- def get_description(self):
- if not self._description:
- self._makeDescriptionFromRS()
- return self._description
-
- def __getattr__(self, item):
- if item == "description":
- return self.get_description()
- object.__getattribute__(
- self, item
- ) # may get here on Remote attribute calls for existing attributes
-
- def format_description(self, d):
- """Format db_api description tuple for printing."""
- if self.description is None:
- self._makeDescriptionFromRS()
- if isinstance(d, int):
- d = self.description[d]
- desc = (
- "Name= %s, Type= %s, DispSize= %s, IntSize= %s, Precision= %s, Scale= %s NullOK=%s"
- % (
- d[0],
- adc.adTypeNames.get(d[1], str(d[1]) + " (unknown type)"),
- d[2],
- d[3],
- d[4],
- d[5],
- d[6],
- )
- )
- return desc
-
- def close(self, dont_tell_me=False):
- """Close the cursor now (rather than whenever __del__ is called).
- The cursor will be unusable from this point forward; an Error (or subclass)
- exception will be raised if any operation is attempted with the cursor.
- """
- if self.connection is None:
- return
- self.messages = []
- if (
- self.rs and self.rs.State != adc.adStateClosed
- ): # rs exists and is open #v2.1 Rose
- self.rs.Close() # v2.1 Rose
- self.rs = None # let go of the recordset so ADO will let it be disposed #v2.1 Rose
- if not dont_tell_me:
- self.connection._i_am_closing(
- self
- ) # take me off the connection's cursors list
- self.connection = (
- None # this will make all future method calls on me throw an exception
- )
- if verbose:
- print("adodbapi Closed cursor at %X" % id(self))
-
- def __del__(self):
- try:
- self.close()
- except:
- pass
-
- def _new_command(self, command_type=adc.adCmdText):
- self.cmd = None
- self.messages = []
-
- if self.connection is None:
- self._raiseCursorError(api.InterfaceError, None)
- return
- try:
- self.cmd = Dispatch("ADODB.Command")
- self.cmd.ActiveConnection = self.connection.connector
- self.cmd.CommandTimeout = self.connection.timeout
- self.cmd.CommandType = command_type
- self.cmd.CommandText = self.commandText
- self.cmd.Prepared = bool(self._ado_prepared)
- except:
- self._raiseCursorError(
- api.DatabaseError,
- 'Error creating new ADODB.Command object for "%s"'
- % repr(self.commandText),
- )
-
- def _execute_command(self):
- # Stored procedures may have an integer return value
- self.return_value = None
- recordset = None
- count = -1 # default value
- if verbose:
- print('Executing command="%s"' % self.commandText)
- try:
- # ----- the actual SQL is executed here ---
- if api.onIronPython:
- ra = Reference[int]()
- recordset = self.cmd.Execute(ra)
- count = ra.Value
- else: # pywin32
- recordset, count = self.cmd.Execute()
- # ----- ------------------------------- ---
- except Exception as e:
- _message = ""
- if hasattr(e, "args"):
- _message += str(e.args) + "\n"
- _message += "Command:\n%s\nParameters:\n%s" % (
- self.commandText,
- format_parameters(self.cmd.Parameters, True),
- )
- klass = self.connection._suggest_error_class()
- self._raiseCursorError(klass, _message)
- try:
- self.rowcount = recordset.RecordCount
- except:
- self.rowcount = count
- self.build_column_info(recordset)
-
- # The ADO documentation hints that obtaining the recordcount may be timeconsuming
- # "If the Recordset object does not support approximate positioning, this property
- # may be a significant drain on resources # [ekelund]
- # Therefore, COM will not return rowcount for server-side cursors. [Cole]
- # Client-side cursors (the default since v2.8) will force a static
- # cursor, and rowcount will then be set accurately [Cole]
-
- def get_rowcount(self):
- return self.rowcount
-
- def get_returned_parameters(self):
- """with some providers, returned parameters and the .return_value are not available until
- after the last recordset has been read. In that case, you must coll nextset() until it
- returns None, then call this method to get your returned information."""
-
- retLst = (
- []
- ) # store procedures may return altered parameters, including an added "return value" item
- for p in tuple(self.cmd.Parameters):
- if verbose > 2:
- print(
- 'Returned=Name: %s, Dir.: %s, Type: %s, Size: %s, Value: "%s",'
- " Precision: %s, NumericScale: %s"
- % (
- p.Name,
- adc.directions[p.Direction],
- adc.adTypeNames.get(p.Type, str(p.Type) + " (unknown type)"),
- p.Size,
- p.Value,
- p.Precision,
- p.NumericScale,
- )
- )
- pyObject = api.convert_to_python(p.Value, api.variantConversions[p.Type])
- if p.Direction == adc.adParamReturnValue:
- self.returnValue = (
- pyObject # also load the undocumented attribute (Vernon's Error!)
- )
- self.return_value = pyObject
- else:
- retLst.append(pyObject)
- return retLst # return the parameter list to the caller
-
- def callproc(self, procname, parameters=None):
- """Call a stored database procedure with the given name.
- The sequence of parameters must contain one entry for each
- argument that the sproc expects. The result of the
- call is returned as modified copy of the input
- sequence. Input parameters are left untouched, output and
- input/output parameters replaced with possibly new values.
-
- The sproc may also provide a result set as output,
- which is available through the standard .fetch*() methods.
- Extension: A "return_value" property may be set on the
- cursor if the sproc defines an integer return value.
- """
- self._parameter_names = []
- self.commandText = procname
- self._new_command(command_type=adc.adCmdStoredProc)
- self._buildADOparameterList(parameters, sproc=True)
- if verbose > 2:
- print(
- "Calling Stored Proc with Params=",
- format_parameters(self.cmd.Parameters, True),
- )
- self._execute_command()
- return self.get_returned_parameters()
-
- def _reformat_operation(self, operation, parameters):
- if self.paramstyle in ("format", "pyformat"): # convert %s to ?
- operation, self._parameter_names = api.changeFormatToQmark(operation)
- elif self.paramstyle == "named" or (
- self.paramstyle == "dynamic" and isinstance(parameters, Mapping)
- ):
- operation, self._parameter_names = api.changeNamedToQmark(
- operation
- ) # convert :name to ?
- return operation
-
- def _buildADOparameterList(self, parameters, sproc=False):
- self.parameters = parameters
- if parameters is None:
- parameters = []
-
- # Note: ADO does not preserve the parameter list, even if "Prepared" is True, so we must build every time.
- parameters_known = False
- if sproc: # needed only if we are calling a stored procedure
- try: # attempt to use ADO's parameter list
- self.cmd.Parameters.Refresh()
- if verbose > 2:
- print(
- "ADO detected Params=",
- format_parameters(self.cmd.Parameters, True),
- )
- print("Program Parameters=", repr(parameters))
- parameters_known = True
- except api.Error:
- if verbose:
- print("ADO Parameter Refresh failed")
- pass
- else:
- if len(parameters) != self.cmd.Parameters.Count - 1:
- raise api.ProgrammingError(
- "You must supply %d parameters for this stored procedure"
- % (self.cmd.Parameters.Count - 1)
- )
- if sproc or parameters != []:
- i = 0
- if parameters_known: # use ado parameter list
- if self._parameter_names: # named parameters
- for i, pm_name in enumerate(self._parameter_names):
- p = getIndexedValue(self.cmd.Parameters, i)
- try:
- _configure_parameter(
- p, parameters[pm_name], p.Type, parameters_known
- )
- except Exception as e:
- _message = (
- "Error Converting Parameter %s: %s, %s <- %s\n"
- % (
- p.Name,
- adc.ado_type_name(p.Type),
- p.Value,
- repr(parameters[pm_name]),
- )
- )
- self._raiseCursorError(
- api.DataError, _message + "->" + repr(e.args)
- )
- else: # regular sequence of parameters
- for value in parameters:
- p = getIndexedValue(self.cmd.Parameters, i)
- if (
- p.Direction == adc.adParamReturnValue
- ): # this is an extra parameter added by ADO
- i += 1 # skip the extra
- p = getIndexedValue(self.cmd.Parameters, i)
- try:
- _configure_parameter(p, value, p.Type, parameters_known)
- except Exception as e:
- _message = (
- "Error Converting Parameter %s: %s, %s <- %s\n"
- % (
- p.Name,
- adc.ado_type_name(p.Type),
- p.Value,
- repr(value),
- )
- )
- self._raiseCursorError(
- api.DataError, _message + "->" + repr(e.args)
- )
- i += 1
- else: # -- build own parameter list
- if (
- self._parameter_names
- ): # we expect a dictionary of parameters, this is the list of expected names
- for parm_name in self._parameter_names:
- elem = parameters[parm_name]
- adotype = api.pyTypeToADOType(elem)
- p = self.cmd.CreateParameter(
- parm_name, adotype, adc.adParamInput
- )
- _configure_parameter(p, elem, adotype, parameters_known)
- try:
- self.cmd.Parameters.Append(p)
- except Exception as e:
- _message = "Error Building Parameter %s: %s, %s <- %s\n" % (
- p.Name,
- adc.ado_type_name(p.Type),
- p.Value,
- repr(elem),
- )
- self._raiseCursorError(
- api.DataError, _message + "->" + repr(e.args)
- )
- else: # expecting the usual sequence of parameters
- if sproc:
- p = self.cmd.CreateParameter(
- "@RETURN_VALUE", adc.adInteger, adc.adParamReturnValue
- )
- self.cmd.Parameters.Append(p)
-
- for elem in parameters:
- name = "p%i" % i
- adotype = api.pyTypeToADOType(elem)
- p = self.cmd.CreateParameter(
- name, adotype, adc.adParamInput
- ) # Name, Type, Direction, Size, Value
- _configure_parameter(p, elem, adotype, parameters_known)
- try:
- self.cmd.Parameters.Append(p)
- except Exception as e:
- _message = "Error Building Parameter %s: %s, %s <- %s\n" % (
- p.Name,
- adc.ado_type_name(p.Type),
- p.Value,
- repr(elem),
- )
- self._raiseCursorError(
- api.DataError, _message + "->" + repr(e.args)
- )
- i += 1
- if self._ado_prepared == "setup":
- self._ado_prepared = (
- True # parameters will be "known" by ADO next loop
- )
-
- def execute(self, operation, parameters=None):
- """Prepare and execute a database operation (query or command).
-
- Parameters may be provided as sequence or mapping and will be bound to variables in the operation.
- Variables are specified in a database-specific notation
- (see the module's paramstyle attribute for details). [5]
- A reference to the operation will be retained by the cursor.
- If the same operation object is passed in again, then the cursor
- can optimize its behavior. This is most effective for algorithms
- where the same operation is used, but different parameters are bound to it (many times).
-
- For maximum efficiency when reusing an operation, it is best to use
- the setinputsizes() method to specify the parameter types and sizes ahead of time.
- It is legal for a parameter to not match the predefined information;
- the implementation should compensate, possibly with a loss of efficiency.
-
- The parameters may also be specified as list of tuples to e.g. insert multiple rows in
- a single operation, but this kind of usage is depreciated: executemany() should be used instead.
-
- Return value is not defined.
-
- [5] The module will use the __getitem__ method of the parameters object to map either positions
- (integers) or names (strings) to parameter values. This allows for both sequences and mappings
- to be used as input.
- The term "bound" refers to the process of binding an input value to a database execution buffer.
- In practical terms, this means that the input value is directly used as a value in the operation.
- The client should not be required to "escape" the value so that it can be used -- the value
- should be equal to the actual database value."""
- if (
- self.command is not operation
- or self._ado_prepared == "setup"
- or not hasattr(self, "commandText")
- ):
- if self.command is not operation:
- self._ado_prepared = False
- self.command = operation
- self._parameter_names = []
- self.commandText = (
- operation
- if (self.paramstyle == "qmark" or not parameters)
- else self._reformat_operation(operation, parameters)
- )
- self._new_command()
- self._buildADOparameterList(parameters)
- if verbose > 3:
- print("Params=", format_parameters(self.cmd.Parameters, True))
- self._execute_command()
-
- def executemany(self, operation, seq_of_parameters):
- """Prepare a database operation (query or command)
- and then execute it against all parameter sequences or mappings found in the sequence seq_of_parameters.
-
- Return values are not defined.
- """
- self.messages = list()
- total_recordcount = 0
-
- self.prepare(operation)
- for params in seq_of_parameters:
- self.execute(self.command, params)
- if self.rowcount == -1:
- total_recordcount = -1
- if total_recordcount != -1:
- total_recordcount += self.rowcount
- self.rowcount = total_recordcount
-
- def _fetch(self, limit=None):
- """Fetch rows from the current recordset.
-
- limit -- Number of rows to fetch, or None (default) to fetch all rows.
- """
- if self.connection is None or self.rs is None:
- self._raiseCursorError(
- api.FetchFailedError, "fetch() on closed connection or empty query set"
- )
- return
-
- if self.rs.State == adc.adStateClosed or self.rs.BOF or self.rs.EOF:
- return list()
- if limit: # limit number of rows retrieved
- ado_results = self.rs.GetRows(limit)
- else: # get all rows
- ado_results = self.rs.GetRows()
- if (
- self.recordset_format == api.RS_ARRAY
- ): # result of GetRows is a two-dimension array
- length = (
- len(ado_results) // self.numberOfColumns
- ) # length of first dimension
- else: # pywin32
- length = len(ado_results[0]) # result of GetRows is tuples in a tuple
- fetchObject = api.SQLrows(
- ado_results, length, self
- ) # new object to hold the results of the fetch
- return fetchObject
-
- def fetchone(self):
- """Fetch the next row of a query result set, returning a single sequence,
- or None when no more data is available.
-
- An Error (or subclass) exception is raised if the previous call to executeXXX()
- did not produce any result set or no call was issued yet.
- """
- self.messages = []
- result = self._fetch(1)
- if result: # return record (not list of records)
- return result[0]
- return None
-
- def fetchmany(self, size=None):
- """Fetch the next set of rows of a query result, returning a list of tuples. An empty sequence is returned when no more rows are available.
-
- The number of rows to fetch per call is specified by the parameter.
- If it is not given, the cursor's arraysize determines the number of rows to be fetched.
- The method should try to fetch as many rows as indicated by the size parameter.
- If this is not possible due to the specified number of rows not being available,
- fewer rows may be returned.
-
- An Error (or subclass) exception is raised if the previous call to executeXXX()
- did not produce any result set or no call was issued yet.
-
- Note there are performance considerations involved with the size parameter.
- For optimal performance, it is usually best to use the arraysize attribute.
- If the size parameter is used, then it is best for it to retain the same value from
- one fetchmany() call to the next.
- """
- self.messages = []
- if size is None:
- size = self.arraysize
- return self._fetch(size)
-
- def fetchall(self):
- """Fetch all (remaining) rows of a query result, returning them as a sequence of sequences (e.g. a list of tuples).
-
- Note that the cursor's arraysize attribute
- can affect the performance of this operation.
- An Error (or subclass) exception is raised if the previous call to executeXXX()
- did not produce any result set or no call was issued yet.
- """
- self.messages = []
- return self._fetch()
-
- def nextset(self):
- """Skip to the next available recordset, discarding any remaining rows from the current recordset.
-
- If there are no more sets, the method returns None. Otherwise, it returns a true
- value and subsequent calls to the fetch methods will return rows from the next result set.
-
- An Error (or subclass) exception is raised if the previous call to executeXXX()
- did not produce any result set or no call was issued yet.
- """
- self.messages = []
- if self.connection is None or self.rs is None:
- self._raiseCursorError(
- api.OperationalError,
- ("nextset() on closed connection or empty query set"),
- )
- return None
-
- if api.onIronPython:
- try:
- recordset = self.rs.NextRecordset()
- except TypeError:
- recordset = None
- except api.Error as exc:
- self._raiseCursorError(api.NotSupportedError, exc.args)
- else: # pywin32
- try: # [begin 2.1 ekelund]
- rsTuple = self.rs.NextRecordset() #
- except pywintypes.com_error as exc: # return appropriate error
- self._raiseCursorError(
- api.NotSupportedError, exc.args
- ) # [end 2.1 ekelund]
- recordset = rsTuple[0]
- if recordset is None:
- return None
- self.build_column_info(recordset)
- return True
-
- def setinputsizes(self, sizes):
- pass
-
- def setoutputsize(self, size, column=None):
- pass
-
- def _last_query(self): # let the programmer see what query we actually used
- try:
- if self.parameters == None:
- ret = self.commandText
- else:
- ret = "%s,parameters=%s" % (self.commandText, repr(self.parameters))
- except:
- ret = None
- return ret
-
- query = property(_last_query, None, None, "returns the last query executed")
-
-
-if __name__ == "__main__":
- raise api.ProgrammingError(version + " cannot be run as a main program.")
diff --git a/spaces/SungBeom/chatwine-korean/.venv/Lib/site-packages/debugpy/_vendored/pydevd/pydevd_tracing.py b/spaces/SungBeom/chatwine-korean/.venv/Lib/site-packages/debugpy/_vendored/pydevd/pydevd_tracing.py
deleted file mode 100644
index d658b12483d89883d2d4954de5437d6e8c7703e5..0000000000000000000000000000000000000000
--- a/spaces/SungBeom/chatwine-korean/.venv/Lib/site-packages/debugpy/_vendored/pydevd/pydevd_tracing.py
+++ /dev/null
@@ -1,385 +0,0 @@
-from _pydevd_bundle.pydevd_constants import get_frame, IS_CPYTHON, IS_64BIT_PROCESS, IS_WINDOWS, \
- IS_LINUX, IS_MAC, DebugInfoHolder, LOAD_NATIVE_LIB_FLAG, \
- ENV_FALSE_LOWER_VALUES, ForkSafeLock
-from _pydev_bundle._pydev_saved_modules import thread, threading
-from _pydev_bundle import pydev_log, pydev_monkey
-import os.path
-import platform
-import ctypes
-from io import StringIO
-import sys
-import traceback
-
-_original_settrace = sys.settrace
-
-
-class TracingFunctionHolder:
- '''This class exists just to keep some variables (so that we don't keep them in the global namespace).
- '''
- _original_tracing = None
- _warn = True
- _traceback_limit = 1
- _warnings_shown = {}
-
-
-def get_exception_traceback_str():
- exc_info = sys.exc_info()
- s = StringIO()
- traceback.print_exception(exc_info[0], exc_info[1], exc_info[2], file=s)
- return s.getvalue()
-
-
-def _get_stack_str(frame):
-
- msg = '\nIf this is needed, please check: ' + \
- '\nhttp://pydev.blogspot.com/2007/06/why-cant-pydev-debugger-work-with.html' + \
- '\nto see how to restore the debug tracing back correctly.\n'
-
- if TracingFunctionHolder._traceback_limit:
- s = StringIO()
- s.write('Call Location:\n')
- traceback.print_stack(f=frame, limit=TracingFunctionHolder._traceback_limit, file=s)
- msg = msg + s.getvalue()
-
- return msg
-
-
-def _internal_set_trace(tracing_func):
- if TracingFunctionHolder._warn:
- frame = get_frame()
- if frame is not None and frame.f_back is not None:
- filename = os.path.splitext(frame.f_back.f_code.co_filename.lower())[0]
- if filename.endswith('threadpool') and 'gevent' in filename:
- if tracing_func is None:
- pydev_log.debug('Disabled internal sys.settrace from gevent threadpool.')
- return
-
- elif not filename.endswith(
- (
- 'threading',
- 'pydevd_tracing',
- )
- ):
-
- message = \
- '\nPYDEV DEBUGGER WARNING:' + \
- '\nsys.settrace() should not be used when the debugger is being used.' + \
- '\nThis may cause the debugger to stop working correctly.' + \
- '%s' % _get_stack_str(frame.f_back)
-
- if message not in TracingFunctionHolder._warnings_shown:
- # only warn about each message once...
- TracingFunctionHolder._warnings_shown[message] = 1
- sys.stderr.write('%s\n' % (message,))
- sys.stderr.flush()
-
- if TracingFunctionHolder._original_tracing:
- TracingFunctionHolder._original_tracing(tracing_func)
-
-
-_last_tracing_func_thread_local = threading.local()
-
-
-def SetTrace(tracing_func):
- _last_tracing_func_thread_local.tracing_func = tracing_func
-
- if tracing_func is not None:
- if set_trace_to_threads(tracing_func, thread_idents=[thread.get_ident()], create_dummy_thread=False) == 0:
- # If we can use our own tracer instead of the one from sys.settrace, do it (the reason
- # is that this is faster than the Python version because we don't call
- # PyFrame_FastToLocalsWithError and PyFrame_LocalsToFast at each event!
- # (the difference can be huge when checking line events on frames as the
- # time increases based on the number of local variables in the scope)
- # See: InternalCallTrampoline (on the C side) for details.
- return
-
- # If it didn't work (or if it was None), use the Python version.
- set_trace = TracingFunctionHolder._original_tracing or sys.settrace
- set_trace(tracing_func)
-
-
-def reapply_settrace():
- try:
- tracing_func = _last_tracing_func_thread_local.tracing_func
- except AttributeError:
- return
- else:
- SetTrace(tracing_func)
-
-
-def replace_sys_set_trace_func():
- if TracingFunctionHolder._original_tracing is None:
- TracingFunctionHolder._original_tracing = sys.settrace
- sys.settrace = _internal_set_trace
-
-
-def restore_sys_set_trace_func():
- if TracingFunctionHolder._original_tracing is not None:
- sys.settrace = TracingFunctionHolder._original_tracing
- TracingFunctionHolder._original_tracing = None
-
-
-_lock = ForkSafeLock()
-
-
-def _load_python_helper_lib():
- try:
- # If it's already loaded, just return it.
- return _load_python_helper_lib.__lib__
- except AttributeError:
- pass
- with _lock:
- try:
- return _load_python_helper_lib.__lib__
- except AttributeError:
- pass
-
- lib = _load_python_helper_lib_uncached()
- _load_python_helper_lib.__lib__ = lib
- return lib
-
-
-def get_python_helper_lib_filename():
- # Note: we have an independent (and similar -- but not equal) version of this method in
- # `add_code_to_python_process.py` which should be kept synchronized with this one (we do a copy
- # because the `pydevd_attach_to_process` is mostly independent and shouldn't be imported in the
- # debugger -- the only situation where it's imported is if the user actually does an attach to
- # process, through `attach_pydevd.py`, but this should usually be called from the IDE directly
- # and not from the debugger).
- libdir = os.path.join(os.path.dirname(__file__), 'pydevd_attach_to_process')
-
- arch = ''
- if IS_WINDOWS:
- # prefer not using platform.machine() when possible (it's a bit heavyweight as it may
- # spawn a subprocess).
- arch = os.environ.get("PROCESSOR_ARCHITEW6432", os.environ.get('PROCESSOR_ARCHITECTURE', ''))
-
- if not arch:
- arch = platform.machine()
- if not arch:
- pydev_log.info('platform.machine() did not return valid value.') # This shouldn't happen...
- return None
-
- if IS_WINDOWS:
- extension = '.dll'
- suffix_64 = 'amd64'
- suffix_32 = 'x86'
-
- elif IS_LINUX:
- extension = '.so'
- suffix_64 = 'amd64'
- suffix_32 = 'x86'
-
- elif IS_MAC:
- extension = '.dylib'
- suffix_64 = 'x86_64'
- suffix_32 = 'x86'
-
- else:
- pydev_log.info('Unable to set trace to all threads in platform: %s', sys.platform)
- return None
-
- if arch.lower() not in ('amd64', 'x86', 'x86_64', 'i386', 'x86'):
- # We don't support this processor by default. Still, let's support the case where the
- # user manually compiled it himself with some heuristics.
- #
- # Ideally the user would provide a library in the format: "attach_."
- # based on the way it's currently compiled -- see:
- # - windows/compile_windows.bat
- # - linux_and_mac/compile_linux.sh
- # - linux_and_mac/compile_mac.sh
-
- try:
- found = [name for name in os.listdir(libdir) if name.startswith('attach_') and name.endswith(extension)]
- except:
- if DebugInfoHolder.DEBUG_TRACE_LEVEL >= 1:
- # There is no need to show this unless debug tracing is enabled.
- pydev_log.exception('Error listing dir: %s', libdir)
- return None
-
- expected_name = 'attach_' + arch + extension
- expected_name_linux = 'attach_linux_' + arch + extension
-
- filename = None
- if expected_name in found: # Heuristic: user compiled with "attach_."
- filename = os.path.join(libdir, expected_name)
-
- elif IS_LINUX and expected_name_linux in found: # Heuristic: user compiled with "attach_linux_."
- filename = os.path.join(libdir, expected_name_linux)
-
- elif len(found) == 1: # Heuristic: user removed all libraries and just left his own lib.
- filename = os.path.join(libdir, found[0])
-
- else: # Heuristic: there's one additional library which doesn't seem to be our own. Find the odd one.
- filtered = [name for name in found if not name.endswith((suffix_64 + extension, suffix_32 + extension))]
- if len(filtered) == 1: # If more than one is available we can't be sure...
- filename = os.path.join(libdir, found[0])
-
- if filename is None:
- pydev_log.info(
- 'Unable to set trace to all threads in arch: %s (did not find a %s lib in %s).',
- arch, expected_name, libdir
-
- )
- return None
-
- pydev_log.info('Using %s lib in arch: %s.', filename, arch)
-
- else:
- # Happy path for which we have pre-compiled binaries.
- if IS_64BIT_PROCESS:
- suffix = suffix_64
- else:
- suffix = suffix_32
-
- if IS_WINDOWS or IS_MAC: # just the extension changes
- prefix = 'attach_'
- elif IS_LINUX: #
- prefix = 'attach_linux_' # historically it has a different name
- else:
- pydev_log.info('Unable to set trace to all threads in platform: %s', sys.platform)
- return None
-
- filename = os.path.join(libdir, '%s%s%s' % (prefix, suffix, extension))
-
- if not os.path.exists(filename):
- pydev_log.critical('Expected: %s to exist.', filename)
- return None
-
- return filename
-
-
-def _load_python_helper_lib_uncached():
- if (not IS_CPYTHON or sys.version_info[:2] > (3, 11)
- or hasattr(sys, 'gettotalrefcount') or LOAD_NATIVE_LIB_FLAG in ENV_FALSE_LOWER_VALUES):
- pydev_log.info('Helper lib to set tracing to all threads not loaded.')
- return None
-
- try:
- filename = get_python_helper_lib_filename()
- if filename is None:
- return None
- # Load as pydll so that we don't release the gil.
- lib = ctypes.pydll.LoadLibrary(filename)
- pydev_log.info('Successfully Loaded helper lib to set tracing to all threads.')
- return lib
- except:
- if DebugInfoHolder.DEBUG_TRACE_LEVEL >= 1:
- # Only show message if tracing is on (we don't have pre-compiled
- # binaries for all architectures -- i.e.: ARM).
- pydev_log.exception('Error loading: %s', filename)
- return None
-
-
-def set_trace_to_threads(tracing_func, thread_idents=None, create_dummy_thread=True):
- assert tracing_func is not None
-
- ret = 0
-
- # Note: use sys._current_frames() keys to get the thread ids because it'll return
- # thread ids created in C/C++ where there's user code running, unlike the APIs
- # from the threading module which see only threads created through it (unless
- # a call for threading.current_thread() was previously done in that thread,
- # in which case a dummy thread would've been created for it).
- if thread_idents is None:
- thread_idents = set(sys._current_frames().keys())
-
- for t in threading.enumerate():
- # PY-44778: ignore pydevd threads and also add any thread that wasn't found on
- # sys._current_frames() as some existing threads may not appear in
- # sys._current_frames() but may be available through the `threading` module.
- if getattr(t, 'pydev_do_not_trace', False):
- thread_idents.discard(t.ident)
- else:
- thread_idents.add(t.ident)
-
- curr_ident = thread.get_ident()
- curr_thread = threading._active.get(curr_ident)
-
- if curr_ident in thread_idents and len(thread_idents) != 1:
- # The current thread must be updated first (because we need to set
- # the reference to `curr_thread`).
- thread_idents = list(thread_idents)
- thread_idents.remove(curr_ident)
- thread_idents.insert(0, curr_ident)
-
- for thread_ident in thread_idents:
- # If that thread is not available in the threading module we also need to create a
- # dummy thread for it (otherwise it'll be invisible to the debugger).
- if create_dummy_thread:
- if thread_ident not in threading._active:
-
- class _DummyThread(threading._DummyThread):
-
- def _set_ident(self):
- # Note: Hack to set the thread ident that we want.
- self._ident = thread_ident
-
- t = _DummyThread()
- # Reset to the base class (don't expose our own version of the class).
- t.__class__ = threading._DummyThread
-
- if thread_ident == curr_ident:
- curr_thread = t
-
- with threading._active_limbo_lock:
- # On Py2 it'll put in active getting the current indent, not using the
- # ident that was set, so, we have to update it (should be harmless on Py3
- # so, do it always).
- threading._active[thread_ident] = t
- threading._active[curr_ident] = curr_thread
-
- if t.ident != thread_ident:
- # Check if it actually worked.
- pydev_log.critical('pydevd: creation of _DummyThread with fixed thread ident did not succeed.')
-
- # Some (ptvsd) tests failed because of this, so, leave it always disabled for now.
- # show_debug_info = 1 if DebugInfoHolder.DEBUG_TRACE_LEVEL >= 1 else 0
- show_debug_info = 0
-
- # Hack to increase _Py_TracingPossible.
- # See comments on py_custom_pyeval_settrace.hpp
- proceed = thread.allocate_lock()
- proceed.acquire()
-
- def dummy_trace(frame, event, arg):
- return dummy_trace
-
- def increase_tracing_count():
- set_trace = TracingFunctionHolder._original_tracing or sys.settrace
- set_trace(dummy_trace)
- proceed.release()
-
- start_new_thread = pydev_monkey.get_original_start_new_thread(thread)
- start_new_thread(increase_tracing_count, ())
- proceed.acquire() # Only proceed after the release() is done.
- proceed = None
-
- # Note: The set_trace_func is not really used anymore in the C side.
- set_trace_func = TracingFunctionHolder._original_tracing or sys.settrace
-
- lib = _load_python_helper_lib()
- if lib is None: # This is the case if it's not CPython.
- pydev_log.info('Unable to load helper lib to set tracing to all threads (unsupported python vm).')
- ret = -1
- else:
- try:
- result = lib.AttachDebuggerTracing(
- ctypes.c_int(show_debug_info),
- ctypes.py_object(set_trace_func),
- ctypes.py_object(tracing_func),
- ctypes.c_uint(thread_ident),
- ctypes.py_object(None),
- )
- except:
- if DebugInfoHolder.DEBUG_TRACE_LEVEL >= 1:
- # There is no need to show this unless debug tracing is enabled.
- pydev_log.exception('Error attaching debugger tracing')
- ret = -1
- else:
- if result != 0:
- pydev_log.info('Unable to set tracing for existing thread. Result: %s', result)
- ret = result
-
- return ret
-
diff --git a/spaces/SungBeom/chatwine-korean/.venv/Lib/site-packages/docarray/display/tensor_display.py b/spaces/SungBeom/chatwine-korean/.venv/Lib/site-packages/docarray/display/tensor_display.py
deleted file mode 100644
index 1bf884b518fc27f5781537705eb2687f00214094..0000000000000000000000000000000000000000
--- a/spaces/SungBeom/chatwine-korean/.venv/Lib/site-packages/docarray/display/tensor_display.py
+++ /dev/null
@@ -1,74 +0,0 @@
-from typing_extensions import TYPE_CHECKING
-
-if TYPE_CHECKING:
- from rich.console import Console, ConsoleOptions, RenderResult
- from rich.measure import Measurement
-
- from docarray.typing.tensor.abstract_tensor import AbstractTensor
-
-
-class TensorDisplay:
- """
- Rich representation of a tensor.
- """
-
- tensor_min_width: int = 30
-
- def __init__(self, tensor: 'AbstractTensor'):
- self.tensor = tensor
-
- def __rich_console__(
- self, console: 'Console', options: 'ConsoleOptions'
- ) -> 'RenderResult':
- comp_be = self.tensor.get_comp_backend()
- t_squeezed = comp_be.squeeze(comp_be.detach(self.tensor))
-
- if comp_be.n_dim(t_squeezed) == 1 and comp_be.shape(t_squeezed)[0] < 200:
- import colorsys
-
- from rich.color import Color
- from rich.segment import Segment
- from rich.style import Style
-
- tensor_normalized = comp_be.minmax_normalize(t_squeezed, (0, 5))
-
- hue = 0.75
- saturation = 1.0
- for idx, y in enumerate(tensor_normalized):
- luminance = 0.1 + ((y / 5) * 0.7)
- r, g, b = colorsys.hls_to_rgb(hue, luminance + 0.07, saturation)
- color = Color.from_rgb(r * 255, g * 255, b * 255)
- yield Segment('▄', Style(color=color, bgcolor=color))
- if idx != 0 and idx % options.max_width == 0:
- yield Segment.line()
- else:
- from rich.text import Text
-
- yield Text(
- f'{self.tensor.__class__.__name__} of '
- f'shape {comp_be.shape(self.tensor)}, '
- f'dtype: {str(comp_be.dtype(self.tensor))}'
- )
-
- def __rich_measure__(
- self, console: 'Console', options: 'ConsoleOptions'
- ) -> 'Measurement':
- from rich.measure import Measurement
-
- width = self._compute_table_width(max_width=options.max_width)
- return Measurement(1, width)
-
- def _compute_table_width(self, max_width: int) -> int:
- """
- Compute the width of the table. Depending on the length of the tensor, the width
- should be in the range of 30 (min) and a given `max_width`.
- :return: the width of the table
- """
- comp_be = self.tensor.get_comp_backend()
- t_squeezed = comp_be.squeeze(comp_be.detach(self.tensor))
- if comp_be.n_dim(t_squeezed) == 1 and comp_be.shape(t_squeezed)[0] < max_width:
- min_capped = max(comp_be.shape(t_squeezed)[0], self.tensor_min_width)
- min_max_capped = min(min_capped, max_width)
- return min_max_capped
- else:
- return max_width
diff --git a/spaces/SungBeom/chatwine-korean/.venv/Lib/site-packages/docarray/utils/_internal/__init__.py b/spaces/SungBeom/chatwine-korean/.venv/Lib/site-packages/docarray/utils/_internal/__init__.py
deleted file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000
diff --git a/spaces/TYH71/gradio-ml-skeleton/app.py b/spaces/TYH71/gradio-ml-skeleton/app.py
deleted file mode 100644
index d7eb1905cf09914bca2c9e30cae396dab14e36c1..0000000000000000000000000000000000000000
--- a/spaces/TYH71/gradio-ml-skeleton/app.py
+++ /dev/null
@@ -1,21 +0,0 @@
-'''
-main script for gradio application
-'''
-import argparse
-import gradio as gr
-from src.core.logger import logger
-from src.interface.yolov5 import yolov5_demo
-
-demo = gr.TabbedInterface(
- [yolov5_demo],
- ["YOLOv5 Demo"]
-)
-
-if __name__ == "__main__":
- parser = argparse.ArgumentParser()
- parser.add_argument("--host", default="0.0.0.0", type=str)
- parser.add_argument(
- "--port", help="will start gradio app on this port (if available)", default=7860, type=int)
- args_all = parser.parse_args()
- logger.info("Gradio Application live and running !")
- demo.queue().launch(share=False, server_name=args_all.host, server_port=args_all.port)
diff --git a/spaces/Tristan/static-rlhf-interface/Makefile b/spaces/Tristan/static-rlhf-interface/Makefile
deleted file mode 100644
index de6c7edf2325840ecd5daefa52b7dd6172ffaa37..0000000000000000000000000000000000000000
--- a/spaces/Tristan/static-rlhf-interface/Makefile
+++ /dev/null
@@ -1,10 +0,0 @@
-.PHONY: style quality
-
-style:
- python -m black --line-length 119 --target-version py38 .
- python -m isort .
-
-quality:
- python -m black --check --line-length 119 --target-version py38 .
- python -m isort --check-only .
- python -m flake8 --max-line-length 119 .
diff --git a/spaces/Tuana/find-the-animal/utils/haystack.py b/spaces/Tuana/find-the-animal/utils/haystack.py
deleted file mode 100644
index d53964669dd8501229055e29c0d198028619d28f..0000000000000000000000000000000000000000
--- a/spaces/Tuana/find-the-animal/utils/haystack.py
+++ /dev/null
@@ -1,80 +0,0 @@
-import shutil
-from haystack.document_stores import FAISSDocumentStore
-from haystack.nodes.retriever import EmbeddingRetriever, MultiModalRetriever
-from haystack.nodes.reader import FARMReader
-from haystack import Pipeline
-from utils.config import (INDEX_DIR)
-from typing import List
-from haystack import BaseComponent, Answer
-import streamlit as st
-
-
-
-class AnswerToQuery(BaseComponent):
-
- outgoing_edges = 1
-
- def run(self, query: str, answers: List[Answer]):
- return {"query": answers[0].answer}, "output_1"
-
- def run_batch(self):
- raise NotImplementedError()
-
-# cached to make index and models load only at start
-@st.cache(
- hash_funcs={"builtins.SwigPyObject": lambda _: None}, allow_output_mutation=True
-)
-def start_haystack():
- """
- load document store, retrievers for images and text, reader and create pipeline
- """
- shutil.copy(f"{INDEX_DIR}/text.db", ".")
- shutil.copy(f"{INDEX_DIR}/images.db", ".")
-
- document_store_text = FAISSDocumentStore(
- faiss_index_path=f"{INDEX_DIR}/text.faiss",
- faiss_config_path=f"{INDEX_DIR}/text.json",
- )
-
- document_store_images = FAISSDocumentStore(
- faiss_index_path=f"{INDEX_DIR}/images.faiss",
- faiss_config_path=f"{INDEX_DIR}/images.json",
- )
-
- retriever_text = EmbeddingRetriever(
- document_store=document_store_text,
- embedding_model="sentence-transformers/multi-qa-mpnet-base-dot-v1",
- model_format="sentence_transformers",
- )
-
- reader = FARMReader(model_name_or_path="deepset/deberta-v3-base-squad2", use_gpu=True)
-
-
- retriever_images = MultiModalRetriever(
- document_store=document_store_images,
- query_embedding_model = "sentence-transformers/clip-ViT-B-32",
- query_type="text",
- document_embedding_models = {
- "image": "sentence-transformers/clip-ViT-B-32"
- }
- )
-
- answer_to_query = AnswerToQuery()
-
- pipe = Pipeline()
-
- pipe.add_node(retriever_text, name="text_retriever", inputs=["Query"])
- pipe.add_node(reader, name="text_reader", inputs=["text_retriever"])
- pipe.add_node(answer_to_query, name="answer2query", inputs=["text_reader"])
- pipe.add_node(retriever_images, name="image_retriever", inputs=["answer2query"])
-
- return pipe
-
-pipe = start_haystack()
-
-@st.cache(allow_output_mutation=True)
-def query(statement: str, text_reader_top_k: int = 5):
- """Run query"""
- params = {"text_reader": {"top_k": text_reader_top_k},"image_retriever": {"top_k": 1},"text_retriever": {"top_k": 5} }
- results = pipe.run(statement, params=params)
- return results
\ No newline at end of file
diff --git a/spaces/Vasanthgx/demo_minima_vasanth/README.md b/spaces/Vasanthgx/demo_minima_vasanth/README.md
deleted file mode 100644
index 86e6c217a9ea4343ba474bda20e44e235cf7d99f..0000000000000000000000000000000000000000
--- a/spaces/Vasanthgx/demo_minima_vasanth/README.md
+++ /dev/null
@@ -1,13 +0,0 @@
----
-title: Demo Minima Vasanth
-emoji: ⚡
-colorFrom: blue
-colorTo: indigo
-sdk: gradio
-sdk_version: 3.27.0
-app_file: app.py
-pinned: false
-license: apache-2.0
----
-
-Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
diff --git a/spaces/VincentZB/Stable-Diffusion-ControlNet-WebUI/diffusion_webui/diffusion_models/stable_diffusion/__init__.py b/spaces/VincentZB/Stable-Diffusion-ControlNet-WebUI/diffusion_webui/diffusion_models/stable_diffusion/__init__.py
deleted file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000
diff --git a/spaces/WZUN666/vits-uma-genshin-honkai/text/symbols.py b/spaces/WZUN666/vits-uma-genshin-honkai/text/symbols.py
deleted file mode 100644
index edfbd24247be8c757275ce80b9ec27a0ffa808f3..0000000000000000000000000000000000000000
--- a/spaces/WZUN666/vits-uma-genshin-honkai/text/symbols.py
+++ /dev/null
@@ -1,39 +0,0 @@
-'''
-Defines the set of symbols used in text input to the model.
-'''
-
-'''# japanese_cleaners
-_pad = '_'
-_punctuation = ',.!?-'
-_letters = 'AEINOQUabdefghijkmnoprstuvwyzʃʧ↓↑ '
-'''
-
-'''# japanese_cleaners2
-_pad = '_'
-_punctuation = ',.!?-~…'
-_letters = 'AEINOQUabdefghijkmnoprstuvwyzʃʧʦ↓↑ '
-'''
-
-'''# korean_cleaners
-_pad = '_'
-_punctuation = ',.!?…~'
-_letters = 'ㄱㄴㄷㄹㅁㅂㅅㅇㅈㅊㅋㅌㅍㅎㄲㄸㅃㅆㅉㅏㅓㅗㅜㅡㅣㅐㅔ '
-'''
-
-'''# chinese_cleaners
-_pad = '_'
-_punctuation = ',。!?—…'
-_letters = 'ㄅㄆㄇㄈㄉㄊㄋㄌㄍㄎㄏㄐㄑㄒㄓㄔㄕㄖㄗㄘㄙㄚㄛㄜㄝㄞㄟㄠㄡㄢㄣㄤㄥㄦㄧㄨㄩˉˊˇˋ˙ '
-'''
-
-# zh_ja_mixture_cleaners
-_pad = '_'
-_punctuation = ',.!?-~…'
-_letters = 'AEINOQUabdefghijklmnoprstuvwyzʃʧʦɯɹəɥ⁼ʰ`→↓↑ '
-
-
-# Export all symbols:
-symbols = [_pad] + list(_punctuation) + list(_letters)
-
-# Special symbol ids
-SPACE_ID = symbols.index(" ")
\ No newline at end of file
diff --git a/spaces/Whatcoldwind/csgo_investment/app.py b/spaces/Whatcoldwind/csgo_investment/app.py
deleted file mode 100644
index a4c862b1c384d212cff6762579ac70d9d820a3ba..0000000000000000000000000000000000000000
--- a/spaces/Whatcoldwind/csgo_investment/app.py
+++ /dev/null
@@ -1,474 +0,0 @@
-import functools
-from pathlib import Path
-
-from api import Goods, Inventory, test_tokens
-import streamlit as st
-from st_aggrid import AgGrid
-from st_aggrid import DataReturnMode, GridUpdateMode
-from st_aggrid.shared import JsCode
-from st_aggrid.grid_options_builder import GridOptionsBuilder
-import pandas as pd
-from pyecharts.charts import Bar, Pie
-from pyecharts import options as opts
-from pyecharts.globals import ThemeType
-import streamlit_echarts
-import json
-
-
-
-def delete_goods(inventory, index):
- for i in index:
- inventory.delete(i['库存编号'])
-
-
-def sell_goods(inventory, index):
- for i in index:
- try:
- inventory()[i['库存编号']].sell(eval(i['卖出价格']))
- except:
- st.error("卖出价格输入错误,请检查输入")
-
-def lease_goods(inventory, index):
- for i in index:
- inventory()[i['库存编号']].lease()
-
-
-def back_goods(inventory, index):
- for i in index:
- inventory()[i['库存编号']].back()
-
-
-
-def open_inventory(path):
- if type(path) == str:
- st.session_state.inventory=Inventory(path)
- st.session_state.inventory.save()
- else:
- with st.spinner("加载库存中..."):
- st.session_state.inventory = Inventory(path.name)
- st.success("库存已打开 ✅")
- with open(st.session_state.inventory.path,'wb+') as file:
- file.write(path.getvalue())
- with st.spinner("更新饰品信息..."):
- progress_bar = st.progress(0)
- if len(st.session_state.inventory())<=0:
- rate=1
- else:
- rate = 1 / len(st.session_state.inventory())
- for p, i in enumerate(st.session_state.inventory):
- progress_bar.progress(rate * p)
- st.session_state.inventory()[i].refresh()
- progress_bar.empty()
-
-
-def save_inventory(path):
- with st.spinner("保存库存中..."):
- st.session_state.inventory.save()
- st.success("库存保存成功 ✅")
- with st.sidebar:
- with open(st.session_state.inventory.path, 'rb') as f:
- st.download_button('下载到本地', f, file_name=st.session_state.inventory.path)
-def update_token(token):
- if not test_tokens(token):
- st.error("Token无效,请重新登陆悠悠,按F12查找token,格式为 Bearer xxx")
- return
- USER_TOKEN=token
- if 'inventory' in st.session_state:
- for good in st.session_state.inventory():
- st.session_state.inventory()[good].token=USER_TOKEN
- st.success("Token更新成功,请及时保存!!✅")
-
-
-
-cellsytle_jscode = JsCode(
- """
-function (params) {
- if (params.value < 0) {
- return {
- 'color': 'white',
- 'backgroundColor': 'forestgreen'
- }
- } else {
- return {
- 'color': 'white',
- 'backgroundColor': 'crimson'
- }
- }
- };
- """
-)
-
-def import_from_file(path,token):
- if not "inventory" in st.session_state:
- st.error("请新建仓库在导入数据")
- return
- if not test_tokens(token):
- st.error("悠悠token不正确")
- return
- try:
- if path.name.endswith('.csv'):
- data=pd.read_csv(path.getvalue())
- elif path.name.endswith('.xlsx'):
- data=pd.read_excel(path.getvalue())
- else:
- st.error('%s 文件类型不支持'%path.name)
- return
- for i in range(data.shape[0]):
- tmp = Goods(str(data.iloc[i]['Buff id']), int(data.iloc[i]['购入花费(元)']),token=token)
- tmp.refresh()
- st.session_state.inventory.add(tmp)
- st.success(tmp.name + "已添加 ✅")
- except:
- st.error('检查%s中是否包含 <购入花费(元)>字段'%path)
-
-def main() -> None:
- global USER_TOKEN
- st.header("CSGO 饰品投资追踪 :moneybag: :dollar: :bar_chart:")
- st.caption("Made by Shevon & Lishuai, maintained by whatcoldwind")
- st.text("请在左侧打开库存文件")
- with st.sidebar:
- st.subheader("选择库存")
- path = st.file_uploader("上传本地库存文件")
- if path:
- launch = st.button('打开库存', on_click=open_inventory, args=(path,))
- new_name=st.text_input("输入新建库存的名称",value="xxxxx")
- if new_name:
- new_one = st.button('新建库存', on_click=open_inventory, args=(new_name+'.pkl',))
- save = st.button('保存库存更改', on_click=save_inventory, args=(path,))
- token_value = st.text_input("token值", value=USER_TOKEN)
- token = st.button('更新悠悠有品token', on_click=update_token, args=(token_value,))
-
- if 'inventory' in st.session_state:
- import_file_path = st.file_uploader("上传导出表格文件并导入到当前仓库 *.csv *.xlsx")
- if import_file_path:
- import_bt = st.button('导入', on_click=import_from_file, args=(import_file_path,USER_TOKEN))
- st.caption('目前已启动库存 ' + st.session_state.inventory.path)
- st.subheader("添加饰品")
- form_track = st.form(key="track")
- with form_track:
- code = st.text_input("请输入饰品buff代码")
- cost = eval(st.text_input("请输入购买价格,0表示仅观望", "0"))
- submitted = st.form_submit_button(label="添加")
- if submitted:
- with st.spinner("加载饰品信息..."):
- try:
- tmp = Goods(code, cost,token=USER_TOKEN)
- tmp.refresh()
- st.session_state.inventory.add(tmp)
- st.success(tmp.name + "已添加 ✅")
- except:
- st.error("饰品信息加载失败,请检查代码和token是否正确")
-
- if 'inventory' in st.session_state:
- for good in st.session_state.inventory():
- validation=test_tokens(st.session_state.inventory()[good].token)
- if validation :
- USER_TOKEN=st.session_state.inventory()[good].token
- st.success("✅ 你当前token有效:%s"%USER_TOKEN)
- break
- st.subheader("投资信息")
- if len(st.session_state.inventory()) > 0:
- col = st.columns(4)
- col2 = st.columns(4)
- col3 = st.columns(4)
- col[0].metric(
- "总投资额", value=f"{st.session_state.inventory.total_cost():.2f} 元",
- help="购买饰品总花费"
- )
- col[1].metric("追踪总量", value=f"{len(st.session_state.inventory())} 件",help="加入库存文件的饰品数量")
- col[2].metric(
- "库存价值(Buff计,含租出)",
- value=f"{st.session_state.inventory.calc_price():.2f} 元",
- help="库存饰品和已租出饰品总价值"
- )
- col[3].metric(
- "总套现", value=f"{st.session_state.inventory.sell_price():.2f} 元",
- help="卖出饰品总收入"
- )
- earn = (
- st.session_state.inventory.calc_price()
- + st.session_state.inventory.sell_price()
- - st.session_state.inventory.total_cost()
- )
- col2[0].metric("盈利(Buff计)", value=f"{earn:.2f} 元",
- help="总套现 + 库存价值 - 总投资额")
- col2[1].metric(
- "总收益率",
- value=f"{earn/st.session_state.inventory.total_cost()*100:.2f} %",
- help="盈利 / 总投资额 * 100"
- )
- yyyp_earn = (
- st.session_state.inventory.calc_yyyp_price()
- + st.session_state.inventory.sell_price()
- - st.session_state.inventory.total_cost()
- )
- col2[2].metric("盈利(悠悠有品计)", value=f"{yyyp_earn:.2f} 元")
- col2[3].metric(
- "总收益率",
- value=f"{yyyp_earn/st.session_state.inventory.total_cost()*100:.2f} %",
- help="盈利 / 总投资额 * 100"
- )
- col3[0].metric(
- "持有饰品收益(Buff计)",
- value=f"{st.session_state.inventory.calc_price() - st.session_state.inventory.total_cost_in_inventory():.2f} 元",
- help="库存价值 - 库存内和已租出饰品总花费"
- )
- col3[1].metric(
- "持有饰品收益率(Buff计)",
- value=f"{100 * (st.session_state.inventory.calc_price() - st.session_state.inventory.total_cost_in_inventory())/st.session_state.inventory.total_cost_in_inventory():.2f} %",
- help="( 持有饰品收益 - 库存内和已租出饰品总花费 ) * 100"
- )
- col3[2].metric(
- "持有饰品收益(悠悠有品计)",
- value=f"{st.session_state.inventory.calc_yyyp_price() - st.session_state.inventory.total_cost_in_inventory():.2f} 元",
- help="库存价值 - 库存内和已租出饰品总花费"
- )
- col3[3].metric(
- "持有饰品收益率(悠悠有品计)",
- value=f"{100 * (st.session_state.inventory.calc_yyyp_price() - st.session_state.inventory.total_cost_in_inventory())/st.session_state.inventory.total_cost_in_inventory():.2f} %",
- help="( 持有饰品收益 - 库存内和已租出饰品总花费 ) * 100"
- )
- st.subheader("目前资金组成")
- col4 = st.columns(2)
- with col4[0]:
- fig1 = Pie(init_opts=opts.InitOpts(theme=ThemeType.MACARONS)).add(
- "库存资金组成",
- [('出租',sum(
- [
- st.session_state.inventory()[good].price
- for good in st.session_state.inventory()
- if st.session_state.inventory()[good].status == 1
- ]
- )),
- ('在库',sum(
- [
- st.session_state.inventory()[good].price
- for good in st.session_state.inventory()
- if (
- st.session_state.inventory()[good].status == 0
- and st.session_state.inventory()[good].cost != 0
- )
- ]
- ))],
- radius=["30%", "75%"],
- )
- streamlit_echarts.st_pyecharts(fig1, height="400px", key="fig1")
- with col4[1]:
- fig2 = Pie(init_opts=opts.InitOpts(theme=ThemeType.MACARONS)).add(
- "盈利资金组成",
- [('库存增值',st.session_state.inventory.calc_price()
- - st.session_state.inventory.total_cost_in_inventory(),), ('卖出收益',st.session_state.inventory.sell_earn(),)],
- radius=["30%", "75%"],
- )
- streamlit_echarts.st_pyecharts(fig2, height="400px", key="fig2")
- else:
- st.caption("当前库存为空")
- # 追踪列表
- st.subheader("追踪列表")
- st.text("右键表格可以导出表格")
- if len(st.session_state.inventory()) > 0:
- data = pd.DataFrame(
- columns=['库存编号', 'Buff id', '名称', '状态', '购入花费(元)', '卖出价格']
- )
- for xx in st.session_state.inventory:
- xx = st.session_state.inventory()[xx]
- data.loc[len(data)] = [
- xx.index,
- xx.id,
- xx.name,
- xx.get_status(),
- xx.cost,
- xx.sell_price,
- ]
-
- gb = GridOptionsBuilder.from_dataframe(data)
-
- gb.configure_selection(
- selection_mode='multiple',
- use_checkbox=True,
- )
- gb.configure_side_bar()
- gb.configure_grid_options(domLayout='normal')
- gridOptions = gb.build()
- grid = AgGrid(
- data,
- gridOptions=gridOptions,
- allow_unsafe_jscode=True,
- return_mode_value=DataReturnMode.FILTERED,
- update_mode=GridUpdateMode.MODEL_CHANGED,
- enable_enterprise_modules=True,
- )
- selected = grid["selected_rows"]
- if selected != []:
- print(selected)
- st.button(
- '删除选中饰品',
- on_click=delete_goods,
- args=(st.session_state.inventory, selected),
- )
- st.button(
- '出售选中饰品',
- on_click=sell_goods,
- args=(st.session_state.inventory, selected),
- )
- st.button(
- '租出选中饰品',
- on_click=lease_goods,
- args=(st.session_state.inventory, selected),
- )
- st.button(
- '回仓选中饰品',
- on_click=back_goods,
- args=(st.session_state.inventory, selected),
- )
- else:
- st.caption("暂无饰品记录")
-
- goods = [st.session_state.inventory()[xx] for xx in st.session_state.inventory]
- # 已购列表
- st.subheader("已购列表")
- st.text("右键表格可以导出表格")
- track = [xx for xx in goods if xx.cost != 0]
- if len(track) > 0:
- data_track = pd.DataFrame([xx() for xx in track])
- data_track['Status'] = data_track['Status'].map(
- {0: '在库中', 1: '已租出', 2: '已卖出'}
- )
-
- data_track.columns = [
- 'Buff id',
- '有品 id',
- '名称',
- '购入花费(元)',
- 'Buff 价格',
- '有品价格',
- 'Steam 价格(元)',
- '状态',
- '有品在售',
- '有品在租',
- '短租价格(元)',
- '长租价格(元)',
- '押金(元)',
- '租售比',
- '理论目前收益(元)',
- '理论目前收益率(%)',
- '租金比例(%)',
- '押金比例(%)',
- '年化短租比例(%)',
- '年化长租比例(%)',
- '套现比例(%)',
- 'buff和有品价格比例',
- ]
- data_track = data_track.round(4)
- #del data_track['Buff id']
- #del data_track['有品 id']
- gb0 = GridOptionsBuilder.from_dataframe(data_track)
- gb0.configure_columns(["Buff id", "有品 id", "名称"], pinned=True)
- gb0.configure_columns(
- ['理论目前收益(元)', '理论目前收益率(%)'],
- cellStyle=cellsytle_jscode,
- )
- gb0.configure_side_bar()
- gb0.configure_grid_options(domLayout='normal')
-
- gridOptions = gb0.build()
- grid_track = AgGrid(
- data_track,
- gridOptions=gridOptions,
- allow_unsafe_jscode=True,
- enable_enterprise_modules=True,
- )
- st.subheader("理论收益分析")
- # Plot
- x = data_track.sort_values(
- by='理论目前收益率(%)',
- )['名称'].tolist()
- y1 = data_track.sort_values(
- by='理论目前收益率(%)',
- )['理论目前收益率(%)'].tolist()
- y2 = data_track.sort_values(
- by='理论目前收益率(%)',
- )['理论目前收益(元)'].tolist()
- fig0 = (
- Bar(init_opts=opts.InitOpts(theme=ThemeType.MACARONS))
- .add_xaxis(x)
- .add_yaxis("理论目前收益率(%)", y1)
- .add_yaxis("理论目前收益(元)", y2)
- .reversal_axis()
- .set_global_opts(
- # 设置操作图表缩放功能,orient="vertical" 为Y轴 滑动
- datazoom_opts=[
- opts.DataZoomOpts(),
- opts.DataZoomOpts(type_="inside", range_start=0, range_end=100),
- opts.DataZoomOpts(
- orient="vertical",
- range_start=0,
- range_end=100,
- ),
- ],
- )
- # .render("bar_datazoom_both.html")
- )
-
- streamlit_echarts.st_pyecharts(fig0, height="900px", key="fig0")
-
- else:
- st.caption("暂无已购饰品")
-
- # 观望列表
- st.subheader("观望列表")
- observe = [xx for xx in goods if xx.cost == 0]
- if len(observe) > 0:
- data_observe = pd.DataFrame([xx() for xx in observe])
- del data_observe['Cost']
- data_observe['Status'] = data_observe['Status'].map({0: '观望中'})
-
- data_observe.columns = [
- 'Buff id',
- '有品 id',
- '名称',
- 'Buff 价格(元)',
- '有品价格(元)',
- 'Steam 价格(元)',
- '状态',
- '有品在售',
- '有品在租',
- '短租价格(元)',
- '长租价格(元)',
- '押金',
- '租售比',
- '租金比例(%)',
- '押金比例(%)',
- '年化短租比例(%)',
- '年化长租比例(%)',
- '套现比例(%)',
- 'buff和有品价格比例',
- ]
- data_observe = data_observe.round(4)
- del data_observe['Buff id']
- del data_observe['有品 id']
- gb1 = GridOptionsBuilder.from_dataframe(data_observe)
- gb1.configure_columns(["Buff id", "有品 id", "名称"], pinned=True)
- gb1.configure_side_bar()
- gb1.configure_grid_options(domLayout='normal')
-
- gridOptions = gb1.build()
- grid_observe = AgGrid(
- data_observe,
- gridOptions=gridOptions,
- allow_unsafe_jscode=True,
- enable_enterprise_modules=True,
- )
-
- else:
- st.caption("暂无观望饰品")
-
-
-if __name__ == "__main__":
- st.set_page_config(
- "CSGO 饰品投资追踪",
- "💰",
- layout="wide",
- )
- USER_TOKEN="Bearer xxx"
- main()
diff --git a/spaces/XAI/CHM-Corr/common/logger.py b/spaces/XAI/CHM-Corr/common/logger.py
deleted file mode 100644
index 062895e2355eb83abe2f8be3ed0957ef9155d007..0000000000000000000000000000000000000000
--- a/spaces/XAI/CHM-Corr/common/logger.py
+++ /dev/null
@@ -1,117 +0,0 @@
-r""" Logging """
-
-import datetime
-import logging
-import os
-
-from tensorboardX import SummaryWriter
-import torch
-
-
-class Logger:
- r""" Writes results of training/testing """
- @classmethod
- def initialize(cls, args, training):
- logtime = datetime.datetime.now().__format__('_%m%d_%H%M%S')
- logpath = args.logpath if training else '_TEST_' + args.load.split('/')[-1].split('.')[0] + logtime
- if logpath == '': logpath = logtime
-
- cls.logpath = os.path.join('logs', logpath + '.log')
- cls.benchmark = args.benchmark
- os.makedirs(cls.logpath)
-
- logging.basicConfig(filemode='w',
- filename=os.path.join(cls.logpath, 'log.txt'),
- level=logging.INFO,
- format='%(message)s',
- datefmt='%m-%d %H:%M:%S')
-
- # Console log config
- console = logging.StreamHandler()
- console.setLevel(logging.INFO)
- formatter = logging.Formatter('%(message)s')
- console.setFormatter(formatter)
- logging.getLogger('').addHandler(console)
-
- # Tensorboard writer
- cls.tbd_writer = SummaryWriter(os.path.join(cls.logpath, 'tbd/runs'))
-
- # Log arguments
- if training:
- logging.info(':======== Convolutional Hough Matching Networks =========')
- for arg_key in args.__dict__:
- logging.info('| %20s: %-24s' % (arg_key, str(args.__dict__[arg_key])))
- logging.info(':========================================================\n')
-
- @classmethod
- def info(cls, msg):
- r""" Writes message to .txt """
- logging.info(msg)
-
- @classmethod
- def save_model(cls, model, epoch, val_pck):
- torch.save(model.state_dict(), os.path.join(cls.logpath, 'pck_best_model.pt'))
- cls.info('Model saved @%d w/ val. PCK: %5.2f.\n' % (epoch, val_pck))
-
-
-class AverageMeter:
- r""" Stores loss, evaluation results, selected layers """
- def __init__(self, benchamrk):
- r""" Constructor of AverageMeter """
- self.buffer_keys = ['pck']
- self.buffer = {}
- for key in self.buffer_keys:
- self.buffer[key] = []
-
- self.loss_buffer = []
-
- def update(self, eval_result, loss=None):
- for key in self.buffer_keys:
- self.buffer[key] += eval_result[key]
-
- if loss is not None:
- self.loss_buffer.append(loss)
-
- def write_result(self, split, epoch):
- msg = '\n*** %s ' % split
- msg += '[@Epoch %02d] ' % epoch
-
- if len(self.loss_buffer) > 0:
- msg += 'Loss: %5.2f ' % (sum(self.loss_buffer) / len(self.loss_buffer))
-
- for key in self.buffer_keys:
- msg += '%s: %6.2f ' % (key.upper(), sum(self.buffer[key]) / len(self.buffer[key]))
- msg += '***\n'
- Logger.info(msg)
-
- def write_process(self, batch_idx, datalen, epoch):
- msg = '[Epoch: %02d] ' % epoch
- msg += '[Batch: %04d/%04d] ' % (batch_idx+1, datalen)
- if len(self.loss_buffer) > 0:
- msg += 'Loss: %5.2f ' % self.loss_buffer[-1]
- msg += 'Avg Loss: %5.5f ' % (sum(self.loss_buffer) / len(self.loss_buffer))
-
- for key in self.buffer_keys:
- msg += 'Avg %s: %5.2f ' % (key.upper(), sum(self.buffer[key]) / len(self.buffer[key]) * 100)
- Logger.info(msg)
-
- def write_test_process(self, batch_idx, datalen):
- msg = '[Batch: %04d/%04d] ' % (batch_idx+1, datalen)
-
- for key in self.buffer_keys:
- if key == 'pck':
- pcks = torch.stack(self.buffer[key]).mean(dim=0) * 100
- val = ''
- for p in pcks:
- val += '%5.2f ' % p.item()
- msg += 'Avg %s: %s ' % (key.upper(), val)
- else:
- msg += 'Avg %s: %5.2f ' % (key.upper(), sum(self.buffer[key]) / len(self.buffer[key]))
- Logger.info(msg)
-
- def get_test_result(self):
- result = {}
- for key in self.buffer_keys:
- result[key] = torch.stack(self.buffer[key]).mean(dim=0) * 100
-
- return result
diff --git a/spaces/XS-1/BW_IMAGE_VIDEO_COLORIZER/fastai/vision/models/xresnet2.py b/spaces/XS-1/BW_IMAGE_VIDEO_COLORIZER/fastai/vision/models/xresnet2.py
deleted file mode 100644
index 58c1a94154062de89cfe6ee10f1526a0375819d0..0000000000000000000000000000000000000000
--- a/spaces/XS-1/BW_IMAGE_VIDEO_COLORIZER/fastai/vision/models/xresnet2.py
+++ /dev/null
@@ -1,202 +0,0 @@
-import torch.nn as nn
-import torch
-import math
-import torch.utils.model_zoo as model_zoo
-from ...torch_core import Module
-
-
-__all__ = ['XResNet', 'xresnet18', 'xresnet34_2', 'xresnet50_2', 'xresnet101', 'xresnet152']
-
-
-def conv3x3(in_planes, out_planes, stride=1):
- return nn.Conv2d(in_planes, out_planes, kernel_size=3, stride=stride, padding=1, bias=False)
-
-
-class BasicBlock(Module):
- expansion = 1
-
- def __init__(self, inplanes, planes, stride=1, downsample=None):
- super(BasicBlock, self).__init__()
- self.conv1 = conv3x3(inplanes, planes, stride)
- self.bn1 = nn.BatchNorm2d(planes)
- self.relu = nn.ReLU(inplace=True)
- self.conv2 = conv3x3(planes, planes)
- self.bn2 = nn.BatchNorm2d(planes)
- self.downsample = downsample
- self.stride = stride
-
- def forward(self, x):
- residual = x
-
- out = self.conv1(x)
- out = self.bn1(out)
- out = self.relu(out)
-
- out = self.conv2(out)
- out = self.bn2(out)
-
- if self.downsample is not None: residual = self.downsample(x)
-
- out += residual
- out = self.relu(out)
-
- return out
-
-
-class Bottleneck(Module):
- expansion = 4
-
- def __init__(self, inplanes, planes, stride=1, downsample=None):
- super(Bottleneck, self).__init__()
- self.conv1 = nn.Conv2d(inplanes, planes, kernel_size=1, bias=False)
- self.bn1 = nn.BatchNorm2d(planes)
- self.conv2 = nn.Conv2d(planes, planes, kernel_size=3, stride=stride,
- padding=1, bias=False)
- self.bn2 = nn.BatchNorm2d(planes)
- self.conv3 = nn.Conv2d(planes, planes * self.expansion, kernel_size=1, bias=False)
- self.bn3 = nn.BatchNorm2d(planes * self.expansion)
- self.relu = nn.ReLU(inplace=True)
- self.downsample = downsample
- self.stride = stride
-
- def forward(self, x):
- residual = x
-
- out = self.conv1(x)
- out = self.bn1(out)
- out = self.relu(out)
-
- out = self.conv2(out)
- out = self.bn2(out)
- out = self.relu(out)
-
- out = self.conv3(out)
- out = self.bn3(out)
-
- if self.downsample is not None: residual = self.downsample(x)
-
- out += residual
- out = self.relu(out)
-
- return out
-
-def conv2d(ni, nf, stride):
- return nn.Sequential(nn.Conv2d(ni, nf, kernel_size=3, stride=stride, padding=1, bias=False),
- nn.BatchNorm2d(nf), nn.ReLU(inplace=True))
-
-class XResNet(Module):
-
- def __init__(self, block, layers, c_out=1000):
- self.inplanes = 64
- super(XResNet, self).__init__()
- self.conv1 = conv2d(3, 32, 2)
- self.conv2 = conv2d(32, 32, 1)
- self.conv3 = conv2d(32, 64, 1)
- self.maxpool = nn.MaxPool2d(kernel_size=3, stride=2, padding=1)
- self.layer1 = self._make_layer(block, 64, layers[0])
- self.layer2 = self._make_layer(block, 128, layers[1], stride=2)
- self.layer3 = self._make_layer(block, 256, layers[2], stride=2)
- self.layer4 = self._make_layer(block, 512, layers[3], stride=2)
- self.avgpool = nn.AdaptiveAvgPool2d(1)
- self.fc = nn.Linear(512 * block.expansion, c_out)
-
- for m in self.modules():
- if isinstance(m, nn.Conv2d):
- nn.init.kaiming_normal_(m.weight, mode='fan_out', nonlinearity='relu')
- elif isinstance(m, nn.BatchNorm2d):
- nn.init.constant_(m.weight, 1)
- nn.init.constant_(m.bias, 0)
-
- for m in self.modules():
- if isinstance(m, BasicBlock): m.bn2.weight = nn.Parameter(torch.zeros_like(m.bn2.weight))
- if isinstance(m, Bottleneck): m.bn3.weight = nn.Parameter(torch.zeros_like(m.bn3.weight))
- if isinstance(m, nn.Linear): m.weight.data.normal_(0, 0.01)
-
- def _make_layer(self, block, planes, blocks, stride=1):
- downsample = None
- if stride != 1 or self.inplanes != planes * block.expansion:
- layers = []
- if stride==2: layers.append(nn.AvgPool2d(kernel_size=2, stride=2))
- layers += [
- nn.Conv2d(self.inplanes, planes * block.expansion, kernel_size=1, stride=1, bias=False),
- nn.BatchNorm2d(planes * block.expansion) ]
- downsample = nn.Sequential(*layers)
-
- layers = []
- layers.append(block(self.inplanes, planes, stride, downsample))
- self.inplanes = planes * block.expansion
- for i in range(1, blocks): layers.append(block(self.inplanes, planes))
- return nn.Sequential(*layers)
-
- def forward(self, x):
- x = self.conv1(x)
- x = self.conv2(x)
- x = self.conv3(x)
- x = self.maxpool(x)
-
- x = self.layer1(x)
- x = self.layer2(x)
- x = self.layer3(x)
- x = self.layer4(x)
-
- x = self.avgpool(x)
- x = x.view(x.size(0), -1)
- x = self.fc(x)
-
- return x
-
-
-def xresnet18(pretrained=False, **kwargs):
- """Constructs a XResNet-18 model.
-
- Args:
- pretrained (bool): If True, returns a model pre-trained on ImageNet
- """
- model = XResNet(BasicBlock, [2, 2, 2, 2], **kwargs)
- if pretrained: model.load_state_dict(model_zoo.load_url(model_urls['xresnet18']))
- return model
-
-
-def xresnet34_2(pretrained=False, **kwargs):
- """Constructs a XResNet-34 model.
-
- Args:
- pretrained (bool): If True, returns a model pre-trained on ImageNet
- """
- model = XResNet(BasicBlock, [3, 4, 6, 3], **kwargs)
- if pretrained: model.load_state_dict(model_zoo.load_url(model_urls['xresnet34']))
- return model
-
-
-def xresnet50_2(pretrained=False, **kwargs):
- """Constructs a XResNet-50 model.
-
- Args:
- pretrained (bool): If True, returns a model pre-trained on ImageNet
- """
- model = XResNet(Bottleneck, [3, 4, 6, 3], **kwargs)
- if pretrained: model.load_state_dict(model_zoo.load_url(model_urls['xresnet50']))
- return model
-
-
-def xresnet101(pretrained=False, **kwargs):
- """Constructs a XResNet-101 model.
-
- Args:
- pretrained (bool): If True, returns a model pre-trained on ImageNet
- """
- model = XResNet(Bottleneck, [3, 4, 23, 3], **kwargs)
- if pretrained: model.load_state_dict(model_zoo.load_url(model_urls['xresnet101']))
- return model
-
-
-def xresnet152(pretrained=False, **kwargs):
- """Constructs a XResNet-152 model.
-
- Args:
- pretrained (bool): If True, returns a model pre-trained on ImageNet
- """
- model = XResNet(Bottleneck, [3, 8, 36, 3], **kwargs)
- if pretrained: model.load_state_dict(model_zoo.load_url(model_urls['xresnet152']))
- return model
-
diff --git a/spaces/Xhaheen/ASR_Whisper_OpenAI/app.py b/spaces/Xhaheen/ASR_Whisper_OpenAI/app.py
deleted file mode 100644
index 37d969c71c639b9581642ea1948b0fc722ec0cde..0000000000000000000000000000000000000000
--- a/spaces/Xhaheen/ASR_Whisper_OpenAI/app.py
+++ /dev/null
@@ -1,177 +0,0 @@
-import gradio as gr
-import whisper
-
-model = whisper.load_model("base")
-
-
-
-def inference(audio):
- audio = whisper.load_audio(audio)
- audio = whisper.pad_or_trim(audio)
-
- mel = whisper.log_mel_spectrogram(audio).to(model.device)
-
- _, probs = model.detect_language(mel)
- lang = max(probs, key=probs.get)
-
- options = whisper.DecodingOptions(fp16 = False)
- result = whisper.decode(model, mel, options)
-
- return lang.upper(), result.text
-
-
-title="Open AI Whisper"
-
-description="Whisper is a general-purpose speech recognition model. It is trained on a large dataset of diverse audio and is also a multi-task model that can perform multilingual speech recognition as well as speech translation and language identification."
-
-css = """
- .gradio-container {
- font-family: 'IBM Plex Sans', sans-serif;
- }
- .gr-button {
- color: white;
- border-color: black;
- background: black;
- }
- input[type='range'] {
- accent-color: black;
- }
- .dark input[type='range'] {
- accent-color: #dfdfdf;
- }
- .container {
- max-width: 730px;
- margin: auto;
- padding-top: 1.5rem;
- }
-
- .details:hover {
- text-decoration: underline;
- }
- .gr-button {
- white-space: nowrap;
- }
- .gr-button:focus {
- border-color: rgb(147 197 253 / var(--tw-border-opacity));
- outline: none;
- box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);
- --tw-border-opacity: 1;
- --tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
- --tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(3px var(--tw-ring-offset-width)) var(--tw-ring-color);
- --tw-ring-color: rgb(191 219 254 / var(--tw-ring-opacity));
- --tw-ring-opacity: .5;
- }
- .footer {
- margin-bottom: 45px;
- margin-top: 35px;
- text-align: center;
- border-bottom: 1px solid #e5e5e5;
- }
- .footer>p {
- font-size: .8rem;
- display: inline-block;
- padding: 0 10px;
- transform: translateY(10px);
- background: white;
- }
- .dark .footer {
- border-color: #303030;
- }
- .dark .footer>p {
- background: #0b0f19;
- }
- .prompt h4{
- margin: 1.25em 0 .25em 0;
- font-weight: bold;
- font-size: 115%;
- }
-"""
-
-block = gr.Blocks(css=css)
-
-
-
-with block:
- gr.HTML(
- """
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- OpenAI Whisper
-
-
-
- Whisper is a general-purpose speech recognition model. It is trained on a large dataset of diverse audio and is also a multi-task model that can perform multilingual speech recognition as well as speech translation and language identification.
-
-
- """
- )
- with gr.Group():
- with gr.Box():
- with gr.Row().style(mobile_collapse=False, equal_height=True):
- audio = gr.Audio(
- label="Input Audio",
- show_label=False,
- source="microphone",
- type="filepath"
- )
-
- btn = gr.Button("Transcribe")
-
- lang_str = gr.Textbox(label="language")
-
- text = gr.Textbox(label="Transcription")
-
-
-
-
- btn.click(inference, inputs=[audio], outputs=[lang_str,text])
-
- gr.HTML('''
-
- ''')
-
-block.launch()
diff --git a/spaces/Xule/ChuanhuChatGPT/modules/presets.py b/spaces/Xule/ChuanhuChatGPT/modules/presets.py
deleted file mode 100644
index 969f122198a360f8c3eb126b156d056ab81d53e1..0000000000000000000000000000000000000000
--- a/spaces/Xule/ChuanhuChatGPT/modules/presets.py
+++ /dev/null
@@ -1,222 +0,0 @@
-# -*- coding:utf-8 -*-
-import os
-from pathlib import Path
-import gradio as gr
-from .webui_locale import I18nAuto
-
-i18n = I18nAuto() # internationalization
-
-CHATGLM_MODEL = None
-CHATGLM_TOKENIZER = None
-LLAMA_MODEL = None
-LLAMA_INFERENCER = None
-
-# ChatGPT 设置
-INITIAL_SYSTEM_PROMPT = "You are a helpful assistant."
-API_HOST = "api.openai.com"
-COMPLETION_URL = "https://api.openai.com/v1/chat/completions"
-BALANCE_API_URL="https://api.openai.com/dashboard/billing/credit_grants"
-USAGE_API_URL="https://api.openai.com/dashboard/billing/usage"
-HISTORY_DIR = Path("history")
-HISTORY_DIR = "history"
-TEMPLATES_DIR = "templates"
-
-# 错误信息
-STANDARD_ERROR_MSG = i18n("☹️发生了错误:") # 错误信息的标准前缀
-GENERAL_ERROR_MSG = i18n("获取对话时发生错误,请查看后台日志")
-ERROR_RETRIEVE_MSG = i18n("请检查网络连接,或者API-Key是否有效。")
-CONNECTION_TIMEOUT_MSG = i18n("连接超时,无法获取对话。") # 连接超时
-READ_TIMEOUT_MSG = i18n("读取超时,无法获取对话。") # 读取超时
-PROXY_ERROR_MSG = i18n("代理错误,无法获取对话。") # 代理错误
-SSL_ERROR_PROMPT = i18n("SSL错误,无法获取对话。") # SSL 错误
-NO_APIKEY_MSG = i18n("API key为空,请检查是否输入正确。") # API key 长度不足 51 位
-NO_INPUT_MSG = i18n("请输入对话内容。") # 未输入对话内容
-BILLING_NOT_APPLICABLE_MSG = i18n("账单信息不适用") # 本地运行的模型返回的账单信息
-
-TIMEOUT_STREAMING = 60 # 流式对话时的超时时间
-TIMEOUT_ALL = 200 # 非流式对话时的超时时间
-ENABLE_STREAMING_OPTION = True # 是否启用选择选择是否实时显示回答的勾选框
-HIDE_MY_KEY = False # 如果你想在UI中隐藏你的 API 密钥,将此值设置为 True
-CONCURRENT_COUNT = 100 # 允许同时使用的用户数量
-
-SIM_K = 5
-INDEX_QUERY_TEMPRATURE = 1.0
-
-CHUANHU_TITLE = i18n("川虎Chat 🚀")
-
-CHUANHU_DESCRIPTION = i18n("由Bilibili [土川虎虎虎](https://space.bilibili.com/29125536) 和 [明昭MZhao](https://space.bilibili.com/24807452)开发 访问川虎Chat的 [GitHub项目](https://github.com/GaiZhenbiao/ChuanhuChatGPT) 下载最新版脚本")
-
-FOOTER = """{versions}
"""
-
-APPEARANCE_SWITCHER = """
-
-
"""+ i18n("切换亮暗色主题") + """
-
-
-
-
-
-"""
-
-SUMMARIZE_PROMPT = "你是谁?我们刚才聊了什么?" # 总结对话时的 prompt
-
-ONLINE_MODELS = [
- "gpt-3.5-turbo",
- "gpt-3.5-turbo-0301",
- "gpt-4",
- "gpt-4-0314",
- "gpt-4-32k",
- "gpt-4-32k-0314",
- "xmchat",
-]
-
-LOCAL_MODELS = [
- "chatglm-6b",
- "chatglm-6b-int4",
- "chatglm-6b-int4-qe",
- "llama-7b-hf",
- "llama-13b-hf",
- "llama-30b-hf",
- "llama-65b-hf"
-]
-
-if os.environ.get('HIDE_LOCAL_MODELS', 'false') == 'true':
- MODELS = ONLINE_MODELS
-else:
- MODELS = ONLINE_MODELS + LOCAL_MODELS
-
-DEFAULT_MODEL = 0
-
-os.makedirs("models", exist_ok=True)
-os.makedirs("lora", exist_ok=True)
-os.makedirs("history", exist_ok=True)
-for dir_name in os.listdir("models"):
- if os.path.isdir(os.path.join("models", dir_name)):
- if dir_name not in MODELS:
- MODELS.append(dir_name)
-
-MODEL_TOKEN_LIMIT = {
- "gpt-3.5-turbo": 4096,
- "gpt-3.5-turbo-0301": 4096,
- "gpt-4": 8192,
- "gpt-4-0314": 8192,
- "gpt-4-32k": 32768,
- "gpt-4-32k-0314": 32768
-}
-
-TOKEN_OFFSET = 1000 # 模型的token上限减去这个值,得到软上限。到达软上限之后,自动尝试减少token占用。
-DEFAULT_TOKEN_LIMIT = 3000 # 默认的token上限
-REDUCE_TOKEN_FACTOR = 0.5 # 与模型token上限想乘,得到目标token数。减少token占用时,将token占用减少到目标token数以下。
-
-REPLY_LANGUAGES = [
- "简体中文",
- "繁體中文",
- "English",
- "日本語",
- "Español",
- "Français",
- "Deutsch",
- "跟随问题语言(不稳定)"
-]
-
-
-WEBSEARCH_PTOMPT_TEMPLATE = """\
-Web search results:
-
-{web_results}
-Current date: {current_date}
-
-Instructions: Using the provided web search results, write a comprehensive reply to the given query. Make sure to cite results using [[number](URL)] notation after the reference. If the provided search results refer to multiple subjects with the same name, write separate answers for each subject.
-Query: {query}
-Reply in {reply_language}
-"""
-
-PROMPT_TEMPLATE = """\
-Context information is below.
----------------------
-{context_str}
----------------------
-Current date: {current_date}.
-Using the provided context information, write a comprehensive reply to the given query.
-Make sure to cite results using [number] notation after the reference.
-If the provided context information refer to multiple subjects with the same name, write separate answers for each subject.
-Use prior knowledge only if the given context didn't provide enough information.
-Answer the question: {query_str}
-Reply in {reply_language}
-"""
-
-REFINE_TEMPLATE = """\
-The original question is as follows: {query_str}
-We have provided an existing answer: {existing_answer}
-We have the opportunity to refine the existing answer
-(only if needed) with some more context below.
-------------
-{context_msg}
-------------
-Given the new context, refine the original answer to better
-Reply in {reply_language}
-If the context isn't useful, return the original answer.
-"""
-
-ALREADY_CONVERTED_MARK = ""
-
-small_and_beautiful_theme = gr.themes.Soft(
- primary_hue=gr.themes.Color(
- c50="#02C160",
- c100="rgba(2, 193, 96, 0.2)",
- c200="#02C160",
- c300="rgba(2, 193, 96, 0.32)",
- c400="rgba(2, 193, 96, 0.32)",
- c500="rgba(2, 193, 96, 1.0)",
- c600="rgba(2, 193, 96, 1.0)",
- c700="rgba(2, 193, 96, 0.32)",
- c800="rgba(2, 193, 96, 0.32)",
- c900="#02C160",
- c950="#02C160",
- ),
- secondary_hue=gr.themes.Color(
- c50="#576b95",
- c100="#576b95",
- c200="#576b95",
- c300="#576b95",
- c400="#576b95",
- c500="#576b95",
- c600="#576b95",
- c700="#576b95",
- c800="#576b95",
- c900="#576b95",
- c950="#576b95",
- ),
- neutral_hue=gr.themes.Color(
- name="gray",
- c50="#f9fafb",
- c100="#f3f4f6",
- c200="#e5e7eb",
- c300="#d1d5db",
- c400="#B2B2B2",
- c500="#808080",
- c600="#636363",
- c700="#515151",
- c800="#393939",
- c900="#272727",
- c950="#171717",
- ),
- radius_size=gr.themes.sizes.radius_sm,
- ).set(
- button_primary_background_fill="#06AE56",
- button_primary_background_fill_dark="#06AE56",
- button_primary_background_fill_hover="#07C863",
- button_primary_border_color="#06AE56",
- button_primary_border_color_dark="#06AE56",
- button_primary_text_color="#FFFFFF",
- button_primary_text_color_dark="#FFFFFF",
- button_secondary_background_fill="#F2F2F2",
- button_secondary_background_fill_dark="#2B2B2B",
- button_secondary_text_color="#393939",
- button_secondary_text_color_dark="#FFFFFF",
- # background_fill_primary="#F7F7F7",
- # background_fill_primary_dark="#1F1F1F",
- block_title_text_color="*primary_500",
- block_title_background_fill="*primary_100",
- input_background_fill="#F6F6F6",
- )
diff --git a/spaces/XzJosh/Bekki-Bert-VITS2/preprocess_text.py b/spaces/XzJosh/Bekki-Bert-VITS2/preprocess_text.py
deleted file mode 100644
index 5eb0f3b9e929fcbe91dcbeb653391227a2518a15..0000000000000000000000000000000000000000
--- a/spaces/XzJosh/Bekki-Bert-VITS2/preprocess_text.py
+++ /dev/null
@@ -1,64 +0,0 @@
-import json
-from random import shuffle
-
-import tqdm
-from text.cleaner import clean_text
-from collections import defaultdict
-stage = [1,2,3]
-
-transcription_path = 'filelists/genshin.list'
-train_path = 'filelists/train.list'
-val_path = 'filelists/val.list'
-config_path = "configs/config.json"
-val_per_spk = 4
-max_val_total = 8
-
-if 1 in stage:
- with open( transcription_path+'.cleaned', 'w', encoding='utf-8') as f:
- for line in tqdm.tqdm(open(transcription_path, encoding='utf-8').readlines()):
- try:
- utt, spk, language, text = line.strip().split('|')
- norm_text, phones, tones, word2ph = clean_text(text, language)
- f.write('{}|{}|{}|{}|{}|{}|{}\n'.format(utt, spk, language, norm_text, ' '.join(phones),
- " ".join([str(i) for i in tones]),
- " ".join([str(i) for i in word2ph])))
- except Exception as error :
- print("err!", utt, error)
-
-if 2 in stage:
- spk_utt_map = defaultdict(list)
- spk_id_map = {}
- current_sid = 0
-
- with open( transcription_path+'.cleaned', encoding='utf-8') as f:
- for line in f.readlines():
- utt, spk, language, text, phones, tones, word2ph = line.strip().split('|')
- spk_utt_map[spk].append(line)
- if spk not in spk_id_map.keys():
- spk_id_map[spk] = current_sid
- current_sid += 1
- train_list = []
- val_list = []
-
- for spk, utts in spk_utt_map.items():
- shuffle(utts)
- val_list+=utts[:val_per_spk]
- train_list+=utts[val_per_spk:]
- if len(val_list) > max_val_total:
- train_list+=val_list[max_val_total:]
- val_list = val_list[:max_val_total]
-
- with open( train_path,"w", encoding='utf-8') as f:
- for line in train_list:
- f.write(line)
-
- with open(val_path, "w", encoding='utf-8') as f:
- for line in val_list:
- f.write(line)
-
-if 3 in stage:
- assert 2 in stage
- config = json.load(open(config_path, encoding='utf-8'))
- config["data"]['spk2id'] = spk_id_map
- with open(config_path, 'w', encoding='utf-8') as f:
- json.dump(config, f, indent=2, ensure_ascii=False)
diff --git a/spaces/XzJosh/Carol-Bert-VITS2/monotonic_align/core.py b/spaces/XzJosh/Carol-Bert-VITS2/monotonic_align/core.py
deleted file mode 100644
index dddc688d76172b880054e544b7a217acd013f14f..0000000000000000000000000000000000000000
--- a/spaces/XzJosh/Carol-Bert-VITS2/monotonic_align/core.py
+++ /dev/null
@@ -1,35 +0,0 @@
-import numba
-
-
-@numba.jit(numba.void(numba.int32[:,:,::1], numba.float32[:,:,::1], numba.int32[::1], numba.int32[::1]), nopython=True, nogil=True)
-def maximum_path_jit(paths, values, t_ys, t_xs):
- b = paths.shape[0]
- max_neg_val=-1e9
- for i in range(int(b)):
- path = paths[i]
- value = values[i]
- t_y = t_ys[i]
- t_x = t_xs[i]
-
- v_prev = v_cur = 0.0
- index = t_x - 1
-
- for y in range(t_y):
- for x in range(max(0, t_x + y - t_y), min(t_x, y + 1)):
- if x == y:
- v_cur = max_neg_val
- else:
- v_cur = value[y-1, x]
- if x == 0:
- if y == 0:
- v_prev = 0.
- else:
- v_prev = max_neg_val
- else:
- v_prev = value[y-1, x-1]
- value[y, x] += max(v_prev, v_cur)
-
- for y in range(t_y - 1, -1, -1):
- path[y, index] = 1
- if index != 0 and (index == y or value[y-1, index] < value[y-1, index-1]):
- index = index - 1
diff --git a/spaces/Yassine/Stego/app.py b/spaces/Yassine/Stego/app.py
deleted file mode 100644
index 77294271d07c3f975cea138541e3ac969fb04c98..0000000000000000000000000000000000000000
--- a/spaces/Yassine/Stego/app.py
+++ /dev/null
@@ -1,63 +0,0 @@
-import stc
-import cv2
-import random
-import numpy as np
-import gradio as gr
-from PIL import Image
-from scipy import signal
-
-
-title = "Steganography"
-description = '''Explore hiding messages in images using content adaptive steganography and STCs (Syndrome Trellis Codes).
- http://dde.binghamton.edu/download/syndrome/ .
- We use HILL https://ieeexplore.ieee.org/document/7025854 .
- Python implementation adapted from Daniel Lerch's https://github.com/daniellerch/pySTC .
- To encode:
- Drag and drop a PNG file, write a message and enter a key (remember the key), the generated image has the secret message encoded.
- To decode:
- Drag and drop the stego file that you just generated, enter the key.
- Note that this software is supplied "as is," without any services or security guaranties.
- '''
-
-def HILL(input_image, operation, message, key):
- tmp_name = str(random.randint(100,500))
- try:
- buffer = input_image
- I = cv2.imdecode(np.frombuffer(buffer, np.uint8), 1)
- I = cv2.cvtColor(I,cv2.COLOR_BGR2GRAY)
- cv2.imwrite('tmp/'+tmp_name+'.png',I)
- except Exception as e:
- print(e)
- raise ValueError('Unable to read image')
-
- if operation == 'decode':
- try:
- stc.extract('tmp/'+tmp_name+'.png', key, 'tmp/'+tmp_name+'.txt')
- return 'tmp/'+tmp_name+'.txt'
- except:
- raise ValueError('Unable to decode')
-
- else:
- H = np.array(
- [[-1, 2, -1],
- [ 2, -4, 2],
- [-1, 2, -1]])
- L1 = np.ones((3, 3)).astype('float32')/(3**2)
- L2 = np.ones((15, 15)).astype('float32')/(15**2)
- costs = signal.convolve2d(I, H, mode='same', boundary='symm')
- costs = abs(costs)
- costs = signal.convolve2d(costs, L1, mode='same', boundary='symm')
- costs = 1/costs
- costs = signal.convolve2d(costs, L2, mode='same', boundary='symm')
- costs[costs == np.inf] = 1
- stc.embed('tmp/'+tmp_name+'.png', costs, message, key, 'tmp/'+tmp_name+'.png')
- return 'tmp/'+tmp_name+'.png'
-
-iface = gr.Interface(fn=HILL,
- inputs=[gr.components.File(type='binary'), gr.components.Radio(['encode', 'decode']), gr.components.Textbox(), gr.components.Textbox()],
- outputs=gr.components.File(),
- examples=[['tmp/8825.png', 'encode', 'This is a secret message', 'secret-key'],
- ['tmp/9390.png', 'encode', 'This is another secret message', 'secret-key-2']],
- title=title,
- description=description)
-iface.launch()
\ No newline at end of file
diff --git a/spaces/Yntec/DreamAnything/app.py b/spaces/Yntec/DreamAnything/app.py
deleted file mode 100644
index c8d7249ad493dc95d4a294a20fe09b7809292c68..0000000000000000000000000000000000000000
--- a/spaces/Yntec/DreamAnything/app.py
+++ /dev/null
@@ -1,230 +0,0 @@
-import gradio as gr
-import os
-import sys
-from pathlib import Path
-import random
-import string
-import time
-from queue import Queue
-from threading import Thread
-import emoji
-
-text_gen=gr.Interface.load("spaces/phenomenon1981/MagicPrompt-Stable-Diffusion")
-def get_prompts(prompt_text):
- if prompt_text:
- return text_gen(prompt_text + " Dream")
- else:
- return text_gen("")
-proc1=gr.Interface.load("models/Yntec/DreamAnything")
-
-def restart_script_periodically():
- while True:
- random_time = random.randint(5400, 6000)
- time.sleep(random_time)
- os.execl(sys.executable, sys.executable, *sys.argv)
-
-
-restart_thread = Thread(target=restart_script_periodically, daemon=True)
-restart_thread.start()
-
-
-queue = Queue()
-queue_threshold = 100
-
-#Don't add noise to the first picture no matter what (the point of noise is to get varied outputs, the first one doesn't need to vary about anything)
-def noadd_random_noise(prompt, noise_level=0.00):
- if noise_level == 0:
- noise_level = 0.00
- percentage_noise = noise_level * 5
- num_noise_chars = int(len(prompt) * (percentage_noise/100))
- noise_indices = random.sample(range(len(prompt)), num_noise_chars)
- prompt_list = list(prompt)
- noise_chars = list(string.ascii_letters + string.punctuation + '' + string.digits)
- noise_chars.extend([''])
- for index in noise_indices:
- prompt_list[index] = random.choice(noise_chars)
- return "".join(prompt_list)
-
-#normal behavior
-def add_random_noise(prompt, noise_level=0.00):
- if noise_level == 0:
- noise_level = 0.00
- percentage_noise = noise_level * 5
- num_noise_chars = int(len(prompt) * (percentage_noise/100))
- noise_indices = random.sample(range(len(prompt)), num_noise_chars)
- prompt_list = list(prompt)
- noise_chars = list(string.ascii_letters + string.punctuation + ' ' + string.digits)
- noise_chars.extend(['😍', 'beautiful', '😂', '🤔', '😊', '🤗', '😭', '🙄', 'pretty', '🤯', '🤫', '🥴', 'sitting', '🤩', '🥳', '😔', '😩', '🤪', '😇', 'retro', '😈', '👹', 'masterpiece', '🤖', '👽', 'high quality', '🎃', '🎅', '🎄', '🎁', '🎂', '🎉', '🎈', '🎊', '🎮', '❤️', '💔', '💕', '💖', '💗', '🐶', '🐱', 'visible', '🐹', '🦊', '🐻', '🐨', '🐯', '🦁', '🐘', '🔥', '🌧️', '🌞', '🌈', '💥', '🌴', '🌊', '🌺', '🌻', '🌸', '🎨', '🌅', '🌌', '☁️', '⛈️', '❄️', '☀️', '🌤️', '⛅️', '🌥️', '🌦️', '🌧️', '🌩️', '🌨️', '🌫️', '☔️', '🌬️', '💨', '🌪️', 'cute', 'kawaii', 'little'])
- for index in noise_indices:
- prompt_list[index] = random.choice(noise_chars)
- return "".join(prompt_list)
-
-def send_it1(inputs, noise_level, proc1=proc1):
- prompt_with_noise = noadd_random_noise(inputs, noise_level)
- while queue.qsize() >= queue_threshold:
- time.sleep(2)
- queue.put(prompt_with_noise)
- output1 = proc1(prompt_with_noise)
- return output1
-
-def send_it2(inputs, noise_level, proc1=proc1):
- prompt_with_noise = add_random_noise(inputs, noise_level)
- while queue.qsize() >= queue_threshold:
- time.sleep(2)
- queue.put(prompt_with_noise)
- output2 = proc1(prompt_with_noise)
- return output2
-
-def send_itX(inputs, noise_level, proc1=proc1):
- prompt_with_noise = add_random_noise(inputs, noise_level)
- while queue.qsize() >= queue_threshold:
- time.sleep(2)
- queue.put(prompt_with_noise)
- outputX = proc1(prompt_with_noise)
- return outputX
-
-def send_it3(inputs, noise_level, proc1=proc1):
- prompt_with_noise = add_random_noise(inputs, noise_level)
- while queue.qsize() >= queue_threshold:
- time.sleep(2)
- queue.put(prompt_with_noise)
- output3 = proc1(prompt_with_noise)
- return output3
-
-def send_it4(inputs, noise_level, proc1=proc1):
- prompt_with_noise = add_random_noise(inputs, noise_level)
- while queue.qsize() >= queue_threshold:
- time.sleep(2)
- queue.put(prompt_with_noise)
- output4 = proc1(prompt_with_noise)
- return output4
-
-def send_it5(inputs, noise_level, proc1=proc1):
- prompt_with_noise = add_random_noise(inputs, noise_level)
- while queue.qsize() >= queue_threshold:
- time.sleep(2)
- queue.put(prompt_with_noise)
- output5 = proc1(prompt_with_noise)
- return output5
-
-#def send_it7(inputs, noise_level, proc1=proc1):
- #prompt_with_noise = add_random_noise(inputs, noise_level)
- #while queue.qsize() >= queue_threshold:
- # time.sleep(2)
- #queue.put(prompt_with_noise)
- #output5 = proc1(prompt_with_noise)
- #return output0
-
-
-with gr.Blocks(css='style.css') as demo:
- gr.HTML(
- """
-
-
-
-
-
DreamAnything
-
-
-
-
- If you have an idea, put it on the first box to expand it, if you have a full prompt, you can leave the first box empty and just put it on the second one and click generate images!
- Noise Level: Controls how much randomness is added to the input of the boxes after the first one before it is sent to the model, so you can get 6 unique 768x768 images. Higher noise level produces more diverse outputs, while lower noise level produces similar outputs,
- original space created by Phenomenon1981 .
-
-
- ❤️ Press the Like Button if you enjoy my space! ❤️
-
-
- """
- )
- with gr.Column(elem_id="col-container"):
- with gr.Row(variant="compact"):
- input_text = gr.Textbox(
- label="Short Prompt",
- show_label=False,
- max_lines=2,
- placeholder="Enter a basic idea and click 'Magic Prompt'. Got no ideas? No problem, Simply just hit the magic button!",
- ).style(
- container=False,min_width=1200
- )
- see_prompts = gr.Button("✨Magic✨ ✨Prompt✨").style(full_width=False)
-
-
- with gr.Row(variant="compact"):
- prompt = gr.Textbox(
- label="Enter your prompt",
- show_label=False,
- max_lines=2,
- placeholder="Full Prompt",
- ).style(
- container=False,
- )
- run = gr.Button("Generate Images").style(full_width=False)
-
- with gr.Row():
- with gr.Row():
- #Now that the first box generates a picture with noise=0 having the default at 0 makes no sense as it'd generate the same image 6 times.
- noise_level = gr.Slider(minimum=0.2, maximum=3, step=0.1, label="Noise Level (0.1 or less was generating the same pic 6 times! 🤣)")
- gr.HTML(
- """
-
-
-
-
Please allow up to 1 minute for each image to generate, for a total of 6 minutes max.
-
-
-
-
- """
- )
- with gr.Row():
- with gr.Row():
- output1=gr.Image(label="DreamAnything",show_label=False,min_width=640)
- output2=gr.Image(label="DreamAnything",show_label=False,min_width=640)
- with gr.Row():
- with gr.Row():
- output3=gr.Image(label="DreamAnything",show_label=False,min_width=640)
- output4=gr.Image(label="DreamAnything",show_label=False,min_width=640)
- with gr.Row():
- with gr.Row():
- output5=gr.Image(label="DreamAnything",show_label=False,min_width=640)
- outputX=gr.Image(label="DreamAnything",show_label=False,min_width=640)
- #with gr.Row():
- #with gr.Row():
- #output0=gr.Image(label="DreamAnything",show_label=False,min_width=640)
-
- see_prompts.click(get_prompts, inputs=[input_text], outputs=[prompt], queue=False)
- run.click(send_it1, inputs=[prompt, noise_level], outputs=[output1])
- #run.click(send_it7, inputs=[prompt, noise_level], outputs=[output0])
- run.click(send_it2, inputs=[prompt, noise_level], outputs=[output2])
- run.click(send_it3, inputs=[prompt, noise_level], outputs=[output3])
- run.click(send_it4, inputs=[prompt, noise_level], outputs=[output4])
- run.click(send_it5, inputs=[prompt, noise_level], outputs=[output5])
- run.click(send_itX, inputs=[prompt, noise_level], outputs=[outputX])
-
-
- with gr.Row():
- gr.HTML(
- """
-
-
-
Unleash your creative side and generate mesmerizing images with just a few clicks! Enter a spark of inspiration in the "Basic Idea" text box and click the "Magic Prompt" button to elevate it to a polished masterpiece. Make any final tweaks in the "Full Prompt" box and hit the "Generate Images" button to watch your vision come to life. Experiment with the "Noise Level" for a diverse range of outputs, from similar to wildly unique. Let the fun begin!
-
-
- """
-)
-
- demo.launch(enable_queue=True, inline=True)
- block.queue(concurrency_count=100)
diff --git a/spaces/Yuliang/ECON/lib/pixielib/models/FLAME.py b/spaces/Yuliang/ECON/lib/pixielib/models/FLAME.py
deleted file mode 100644
index fb9ca09c4890f17206905546f4373ab186a5e6d1..0000000000000000000000000000000000000000
--- a/spaces/Yuliang/ECON/lib/pixielib/models/FLAME.py
+++ /dev/null
@@ -1,107 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Max-Planck-Gesellschaft zur Förderung der Wissenschaften e.V. (MPG) is
-# holder of all proprietary rights on this computer program.
-# Using this computer program means that you agree to the terms
-# in the LICENSE file included with this software distribution.
-# Any use not explicitly granted by the LICENSE is prohibited.
-#
-# Copyright©2019 Max-Planck-Gesellschaft zur Förderung
-# der Wissenschaften e.V. (MPG). acting on behalf of its Max Planck Institute
-# for Intelligent Systems. All rights reserved.
-#
-# For comments or questions, please email us at pixie@tue.mpg.de
-# For commercial licensing contact, please contact ps-license@tuebingen.mpg.de
-
-import pickle
-
-import numpy as np
-import torch
-import torch.nn as nn
-import torch.nn.functional as F
-
-
-class FLAMETex(nn.Module):
- """
- FLAME texture:
- https://github.com/TimoBolkart/TF_FLAME/blob/ade0ab152300ec5f0e8555d6765411555c5ed43d/sample_texture.py#L64
- FLAME texture converted from BFM:
- https://github.com/TimoBolkart/BFM_to_FLAME
- """
- def __init__(self, config):
- super(FLAMETex, self).__init__()
- if config.tex_type == "BFM":
- mu_key = "MU"
- pc_key = "PC"
- n_pc = 199
- tex_path = config.tex_path
- tex_space = np.load(tex_path)
- texture_mean = tex_space[mu_key].reshape(1, -1)
- texture_basis = tex_space[pc_key].reshape(-1, n_pc)
-
- elif config.tex_type == "FLAME":
- mu_key = "mean"
- pc_key = "tex_dir"
- n_pc = 200
- tex_path = config.flame_tex_path
- tex_space = np.load(tex_path)
- texture_mean = tex_space[mu_key].reshape(1, -1) / 255.0
- texture_basis = tex_space[pc_key].reshape(-1, n_pc) / 255.0
- else:
- print("texture type ", config.tex_type, "not exist!")
- raise NotImplementedError
-
- n_tex = config.n_tex
- num_components = texture_basis.shape[1]
- texture_mean = torch.from_numpy(texture_mean).float()[None, ...]
- texture_basis = torch.from_numpy(texture_basis[:, :n_tex]).float()[None, ...]
- self.register_buffer("texture_mean", texture_mean)
- self.register_buffer("texture_basis", texture_basis)
-
- def forward(self, texcode=None):
- """
- texcode: [batchsize, n_tex]
- texture: [bz, 3, 256, 256], range: 0-1
- """
- texture = self.texture_mean + (self.texture_basis * texcode[:, None, :]).sum(-1)
- texture = texture.reshape(texcode.shape[0], 512, 512, 3).permute(0, 3, 1, 2)
- texture = F.interpolate(texture, [256, 256])
- texture = texture[:, [2, 1, 0], :, :]
- return texture
-
-
-def texture_flame2smplx(cached_data, flame_texture, smplx_texture):
- """Convert flame texture map (face-only) into smplx texture map (includes body texture)
- TODO: pytorch version ==> grid sample
- """
- if smplx_texture.shape[0] != smplx_texture.shape[1]:
- print("SMPL-X texture not squared (%d != %d)" % (smplx_texture[0], smplx_texture[1]))
- return
- if smplx_texture.shape[0] != cached_data["target_resolution"]:
- print(
- "SMPL-X texture size does not match cached image resolution (%d != %d)" %
- (smplx_texture.shape[0], cached_data["target_resolution"])
- )
- return
- x_coords = cached_data["x_coords"]
- y_coords = cached_data["y_coords"]
- target_pixel_ids = cached_data["target_pixel_ids"]
- source_uv_points = cached_data["source_uv_points"]
-
- source_tex_coords = np.zeros_like((source_uv_points)).astype(int)
- source_tex_coords[:, 0] = np.clip(
- flame_texture.shape[0] * (1.0 - source_uv_points[:, 1]),
- 0.0,
- flame_texture.shape[0],
- ).astype(int)
- source_tex_coords[:, 1] = np.clip(
- flame_texture.shape[1] * (source_uv_points[:, 0]), 0.0, flame_texture.shape[1]
- ).astype(int)
-
- smplx_texture[y_coords[target_pixel_ids].astype(int),
- x_coords[target_pixel_ids].astype(int), :, ] = flame_texture[source_tex_coords[:,
- 0],
- source_tex_coords[:,
- 1]]
-
- return smplx_texture
diff --git a/spaces/Zengwengen/nb/README.md b/spaces/Zengwengen/nb/README.md
deleted file mode 100644
index 7aa73b96193a8b426d961a1418e4a18a38e05b06..0000000000000000000000000000000000000000
--- a/spaces/Zengwengen/nb/README.md
+++ /dev/null
@@ -1,12 +0,0 @@
----
-title: Nb
-emoji: 📊
-colorFrom: yellow
-colorTo: purple
-sdk: docker
-pinned: false
-license: mit
-app_port: 8080
----
-
-Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
diff --git a/spaces/abdvl/datahub_qa_bot/docs/actions/guides/developing-an-action.md b/spaces/abdvl/datahub_qa_bot/docs/actions/guides/developing-an-action.md
deleted file mode 100644
index a8b47954a7876b976cbcefbcc8258cbc8a625f7c..0000000000000000000000000000000000000000
--- a/spaces/abdvl/datahub_qa_bot/docs/actions/guides/developing-an-action.md
+++ /dev/null
@@ -1,132 +0,0 @@
-# Developing an Action
-
-In this guide, we will outline each step to developing a Action for the DataHub Actions Framework.
-
-## Overview
-
-Developing a DataHub Action is a matter of extending the `Action` base class in Python, installing your
-Action to make it visible to the framework, and then configuring the framework to use the new Action.
-
-
-## Step 1: Defining an Action
-
-To implement an Action, we'll need to extend the `Action` base class and override the following functions:
-
-- `create()` - This function is invoked to instantiate the action, with a free-form configuration dictionary
- extracted from the Actions configuration file as input.
-- `act()` - This function is invoked when an Action is received. It should contain the core logic of the Action.
-- `close()` - This function is invoked when the framework has issued a shutdown of the pipeline. It should be used
- to cleanup any processes happening inside the Action.
-
-Let's start by defining a new implementation of Action called `CustomAction`. We'll keep it simple-- this Action will
-print the configuration that is provided when it is created, and print any Events that it receives.
-
-```python
-# custom_action.py
-from datahub_actions.action.action import Action
-from datahub_actions.event.event_envelope import EventEnvelope
-from datahub_actions.pipeline.pipeline_context import PipelineContext
-
-class CustomAction(Action):
- @classmethod
- def create(cls, config_dict: dict, ctx: PipelineContext) -> "Action":
- # Simply print the config_dict.
- print(config_dict)
- return cls(ctx)
-
- def __init__(self, ctx: PipelineContext):
- self.ctx = ctx
-
- def act(self, event: EventEnvelope) -> None:
- # Do something super important.
- # For now, just print. :)
- print(event)
-
- def close(self) -> None:
- pass
-```
-
-
-## Step 2: Installing the Action
-
-Now that we've defined the Action, we need to make it visible to the framework by making it
-available in the Python runtime environment.
-
-The easiest way to do this is to just place it in the same directory as your configuration file, in which case the module name is the same as the file
-name - in this case it will be `custom_action`.
-
-### Advanced: Installing as a Package
-
-Alternatively, create a `setup.py` file in the same directory as the new Action to convert it into a package that pip can understand.
-
-```
-from setuptools import find_packages, setup
-
-setup(
- name="custom_action_example",
- version="1.0",
- packages=find_packages(),
- # if you don't already have DataHub Actions installed, add it under install_requires
- # install_requires=["acryl-datahub-actions"]
-)
-```
-
-Next, install the package
-
-```shell
-pip install -e .
-```
-
-inside the module. (alt.`python setup.py`).
-
-Once we have done this, our class will be referencable via `custom_action_example.custom_action:CustomAction`.
-
-
-## Step 3: Running the Action
-
-Now that we've defined our Action, we can create an Action configuration file that refers to the new Action.
-We will need to provide the fully-qualified Python module & class name when doing so.
-
-*Example Configuration*
-
-```yaml
-# custom_action.yaml
-name: "custom_action_test"
-source:
- type: "kafka"
- config:
- connection:
- bootstrap: ${KAFKA_BOOTSTRAP_SERVER:-localhost:9092}
- schema_registry_url: ${SCHEMA_REGISTRY_URL:-http://localhost:8081}
-action:
- type: "custom_action_example.custom_action:CustomAction"
- config:
- # Some sample configuration which should be printed on create.
- config1: value1
-```
-
-Next, run the `datahub actions` command as usual:
-
-```shell
-datahub actions -c custom_action.yaml
-```
-
-If all is well, your Action should now be receiving & printing Events.
-
-
-## (Optional) Step 4: Contributing the Action
-
-If your Action is generally applicable, you can raise a PR to include it in the core Action library
-provided by DataHub. All Actions will live under the `datahub_actions/plugin/action` directory inside the
-[datahub-actions](https://github.com/acryldata/datahub-actions) repository.
-
-Once you've added your new Action there, make sure that you make it discoverable by updating the `entry_points` section
-of the `setup.py` file. This allows you to assign a globally unique name for you Action, so that people can use
-it without defining the full module path.
-
-### Prerequisites:
-
-Prerequisites to consideration for inclusion in the core Actions library include
-
-- **Testing** Define unit tests for your Action
-- **Deduplication** Confirm that no existing Action serves the same purpose, or can be easily extended to serve the same purpose
diff --git a/spaces/abdvl/datahub_qa_bot/docs/managed-datahub/datahub-api/graphql-api/getting-started.md b/spaces/abdvl/datahub_qa_bot/docs/managed-datahub/datahub-api/graphql-api/getting-started.md
deleted file mode 100644
index 3c57b0a21d96e43a4d3943246f50725885619356..0000000000000000000000000000000000000000
--- a/spaces/abdvl/datahub_qa_bot/docs/managed-datahub/datahub-api/graphql-api/getting-started.md
+++ /dev/null
@@ -1,42 +0,0 @@
----
-description: Getting started with the DataHub GraphQL API.
----
-
-# Getting Started
-
-The Acryl DataHub GraphQL API is an extension of the open source [DataHub GraphQL API.](docs/api/graphql/overview.md)
-
-For a full reference to the Queries & Mutations available for consumption, check out [Queries](graphql/queries.md) & [Mutations](graphql/mutations.md).
-
-### Connecting to the API
-
-.png)
-
-When you generate the token you will see an example of `curl` command which you can use to connect to the GraphQL API.
-
-Note that there is a single URL mentioned there but it can be any of these
-
-- https://`your-account`.acryl.io/api/graphql
-- https://`your-account`.acryl.io/api/gms/graphql
-
-If there is any example that requires you to connect to GMS then you can use the second URL and change the endpoints.
-
-e.g. to get configuration of your GMS server you can use
-
-```
-curl -X GET 'https://your-account.acryl.io/api/gms/config' --header
-```
-
-e.g. to connect to ingestion endpoint for doing ingestion programmatically you can use the below URL
-
-- https://your-account.acryl.io/api/gms/aspects?action=ingestProposal
-
-### Exploring the API
-
-The entire GraphQL API can be explored & [introspected](https://graphql.org/learn/introspection/) using GraphiQL, an interactive query tool which allows you to navigate the entire Acryl GraphQL schema as well as craft & issue using an intuitive UI.
-
-[GraphiQL](https://www.gatsbyjs.com/docs/how-to/querying-data/running-queries-with-graphiql/) is available for each Acryl DataHub deployment, locating at `https://your-account.acryl.io/api/graphiql`.
-
-### Querying the API
-
-Currently, we do not offer language-specific SDKs for accessing the DataHub GraphQL API. For querying the API, you can make use of a variety of per-language client libraries. For a full list, see [GraphQL Code Libraries, Tools, & Services](https://graphql.org/code/).
diff --git a/spaces/abhishek/sketch-to-image/annotator/uniformer/mmdet_null/models/necks/__init__.py b/spaces/abhishek/sketch-to-image/annotator/uniformer/mmdet_null/models/necks/__init__.py
deleted file mode 100644
index 02f833a8a0f538a8c06fef622d1cadc1a1b66ea2..0000000000000000000000000000000000000000
--- a/spaces/abhishek/sketch-to-image/annotator/uniformer/mmdet_null/models/necks/__init__.py
+++ /dev/null
@@ -1,16 +0,0 @@
-from .bfp import BFP
-from .channel_mapper import ChannelMapper
-from .fpg import FPG
-from .fpn import FPN
-from .fpn_carafe import FPN_CARAFE
-from .hrfpn import HRFPN
-from .nas_fpn import NASFPN
-from .nasfcos_fpn import NASFCOS_FPN
-from .pafpn import PAFPN
-from .rfp import RFP
-from .yolo_neck import YOLOV3Neck
-
-__all__ = [
- 'FPN', 'BFP', 'ChannelMapper', 'HRFPN', 'NASFPN', 'FPN_CARAFE', 'PAFPN',
- 'NASFCOS_FPN', 'RFP', 'YOLOV3Neck', 'FPG'
-]
diff --git a/spaces/abidlabs/streaming-asr/README.md b/spaces/abidlabs/streaming-asr/README.md
deleted file mode 100644
index 5d8fb4eb0033d3a11f759b8decfc62669adcc224..0000000000000000000000000000000000000000
--- a/spaces/abidlabs/streaming-asr/README.md
+++ /dev/null
@@ -1,12 +0,0 @@
----
-title: Streaming Asr
-emoji: 🐢
-colorFrom: pink
-colorTo: green
-sdk: gradio
-sdk_version: 3.21.0
-app_file: app.py
-pinned: false
----
-
-Check out the configuration reference at https://huggingface.co/docs/hub/spaces#reference
diff --git a/spaces/akashagarwal/ASRGenerateStory/README.md b/spaces/akashagarwal/ASRGenerateStory/README.md
deleted file mode 100644
index 4fac87b15d3c6a8f83581d798b385d0db99620e7..0000000000000000000000000000000000000000
--- a/spaces/akashagarwal/ASRGenerateStory/README.md
+++ /dev/null
@@ -1,13 +0,0 @@
----
-title: ASRGenerateStory
-emoji: 🐢
-colorFrom: red
-colorTo: gray
-sdk: gradio
-sdk_version: 3.0.24
-app_file: app.py
-pinned: false
----
-
-Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
-
diff --git a/spaces/akhaliq/deeplab2/model/layers/axial_block_groups_test.py b/spaces/akhaliq/deeplab2/model/layers/axial_block_groups_test.py
deleted file mode 100644
index b1283bc2f2623035e5b8374ade1974db6d474141..0000000000000000000000000000000000000000
--- a/spaces/akhaliq/deeplab2/model/layers/axial_block_groups_test.py
+++ /dev/null
@@ -1,182 +0,0 @@
-# coding=utf-8
-# Copyright 2021 The Deeplab2 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.
-
-"""Tests for axial_block_groups."""
-
-import numpy as np
-import tensorflow as tf
-
-from deeplab2.model import test_utils
-from deeplab2.model.layers import axial_block_groups
-
-
-class AxialBlockGroupsTest(tf.test.TestCase):
-
- def test_axial_attention_follows_bottleneck_block(self):
- layer = axial_block_groups.BlockGroup(
- filters=512,
- num_blocks=2,
- name='block_group',
- original_resnet_stride=2,
- original_resnet_input_stride=16,
- use_axial_beyond_stride=32,
- output_stride=16)
- _, pixel_output, memory_output = layer((tf.zeros([2, 65, 65, 1024]),
- tf.zeros([2, 128, 147])))
- self.assertListEqual(pixel_output.get_shape().as_list(),
- [2, 65, 65, 2048])
- self.assertListEqual(memory_output.get_shape().as_list(),
- [2, 128, 147])
-
- def test_global_attention_follows_basic_block(self):
- layer = axial_block_groups.BlockGroup(
- filters=256,
- num_blocks=2,
- name='block_group',
- backbone_type='wider_resnet',
- original_resnet_stride=2,
- original_resnet_input_stride=8,
- use_global_beyond_stride=16,
- positional_encoding_type='1D')
-
- _, pixel_output, memory_output = layer((tf.zeros([2, 65, 65, 32]),
- tf.zeros([2, 128, 147])))
- self.assertListEqual(pixel_output.get_shape().as_list(),
- [2, 33, 33, 1024])
- self.assertListEqual(memory_output.get_shape().as_list(),
- [2, 128, 147])
-
- def test_atrous_consistency_basic_block(self):
- tf.random.set_seed(0)
- pixel_inputs = test_utils.create_test_input(2, 11, 11, 3)
- # Dense feature extraction followed by subsampling.
- layer1 = axial_block_groups.BlockGroup(
- filters=2,
- num_blocks=2,
- name='stage3',
- backbone_type='wider_resnet',
- original_resnet_stride=2,
- original_resnet_input_stride=8,
- output_stride=8,
- use_axial_beyond_stride=0,
- use_global_beyond_stride=0,
- use_transformer_beyond_stride=0)
- # Create the weights
- layer1((pixel_inputs, None))
- weights = layer1.get_weights()
- # Set the batch norm gamma as non-zero so that the 3x3 convolution affects
- # the output.
- for index in range(len(weights)):
- if np.sum(weights[index]) == 0.0:
- weights[index] = weights[index] + 1
- layer1.set_weights(weights)
- _, pixel_outputs, _ = layer1((pixel_inputs, None))
- output = pixel_outputs[:, ::2, ::2, :]
- # Feature extraction at the nominal network rate.
- layer2 = axial_block_groups.BlockGroup(
- filters=2,
- num_blocks=2,
- name='stage3',
- backbone_type='wider_resnet',
- original_resnet_stride=2,
- original_resnet_input_stride=8,
- output_stride=16,
- use_axial_beyond_stride=0,
- use_global_beyond_stride=0,
- use_transformer_beyond_stride=0)
- # Create the weights
- layer2((pixel_inputs, None))
- # Make the two networks use the same weights.
- layer2.set_weights(layer1.get_weights())
- _, expected, _ = layer2((pixel_inputs, None))
- self.assertAllClose(output, expected, atol=1e-4, rtol=1e-4)
-
- def test_atrous_consistency_bottleneck_block(self):
- tf.random.set_seed(0)
- pixel_inputs = test_utils.create_test_input(2, 11, 11, 3)
- # Dense feature extraction followed by subsampling.
- layer1 = axial_block_groups.BlockGroup(
- filters=2,
- num_blocks=2,
- name='stage3',
- backbone_type='wider_resnet',
- original_resnet_stride=2,
- original_resnet_input_stride=16,
- output_stride=16,
- use_axial_beyond_stride=0,
- use_global_beyond_stride=0,
- use_transformer_beyond_stride=0)
- # Create the weights
- layer1((pixel_inputs, None))
- weights = layer1.get_weights()
- # Set the batch norm gamma as non-zero so that the 3x3 convolution affects
- # the output.
- for index in range(len(weights)):
- if np.sum(weights[index]) == 0.0:
- weights[index] = weights[index] + 1
- layer1.set_weights(weights)
- _, pixel_outputs, _ = layer1((pixel_inputs, None))
- output = pixel_outputs[:, ::2, ::2, :]
- # Feature extraction at the nominal network rate.
- layer2 = axial_block_groups.BlockGroup(
- filters=2,
- num_blocks=2,
- name='stage3',
- backbone_type='wider_resnet',
- original_resnet_stride=2,
- original_resnet_input_stride=16,
- output_stride=32,
- use_axial_beyond_stride=0,
- use_global_beyond_stride=0,
- use_transformer_beyond_stride=0)
- # Create the weights
- layer2((pixel_inputs, None))
- # Make the two networks use the same weights.
- layer2.set_weights(layer1.get_weights())
- _, expected, _ = layer2((pixel_inputs, None))
- self.assertAllClose(output, expected, atol=1e-4, rtol=1e-4)
-
- def test_use_se_sac_recompute_drop_path_schedule(self):
- _ = axial_block_groups.BlockGroup(
- filters=512,
- num_blocks=2,
- name='block_group',
- original_resnet_stride=2,
- original_resnet_input_stride=8,
- use_axial_beyond_stride=0,
- use_squeeze_and_excite=True, # True
- use_sac_beyond_stride=16, # True
- recompute_within_stride=16, # True
- drop_path_beyond_stride=16,
- drop_path_schedule='linear', # 1.0, 0.85
- output_stride=16)
-
- def test_nouse_se_sac_recompute_drop_path_schedule(self):
- _ = axial_block_groups.BlockGroup(
- filters=512,
- num_blocks=2,
- name='block_group',
- original_resnet_stride=2,
- original_resnet_input_stride=8,
- use_axial_beyond_stride=0,
- use_squeeze_and_excite=False, # False
- use_sac_beyond_stride=32, # False
- recompute_within_stride=8, # False
- drop_path_beyond_stride=32, # 1.0, 1.0
- drop_path_schedule='constant',
- output_stride=16)
-
-if __name__ == '__main__':
- tf.test.main()
diff --git a/spaces/alexrods/Smartcity-Traffic-Detection/centroidtracker.py b/spaces/alexrods/Smartcity-Traffic-Detection/centroidtracker.py
deleted file mode 100644
index 3b89b0a3627f8d71bfd0f7f5f1ef1c9b73142856..0000000000000000000000000000000000000000
--- a/spaces/alexrods/Smartcity-Traffic-Detection/centroidtracker.py
+++ /dev/null
@@ -1,163 +0,0 @@
-# import the necessary packages
-from scipy.spatial import distance as dist
-from collections import OrderedDict
-import numpy as np
-
-class CentroidTracker:
- def __init__(self, maxDisappeared=50, maxDistance=50):
- # initialize the next unique object ID along with two ordered
- # dictionaries used to keep track of mapping a given object
- # ID to its centroid and number of consecutive frames it has
- # been marked as "disappeared", respectively
- self.nextObjectID = 0
- self.objects = OrderedDict()
- self.disappeared = OrderedDict()
-
- # store the number of maximum consecutive frames a given
- # object is allowed to be marked as "disappeared" until we
- # need to deregister the object from tracking
- self.maxDisappeared = maxDisappeared
-
- # store the maximum distance between centroids to associate
- # an object -- if the distance is larger than this maximum
- # distance we'll start to mark the object as "disappeared"
- self.maxDistance = maxDistance
-
- def register(self, centroid):
- # when registering an object we use the next available object
- # ID to store the centroid
- self.objects[self.nextObjectID] = centroid
- self.disappeared[self.nextObjectID] = 0
- self.nextObjectID += 1
-
- def deregister(self, objectID):
- # to deregister an object ID we delete the object ID from
- # both of our respective dictionaries
- del self.objects[objectID]
- del self.disappeared[objectID]
-
- def update(self, rects):
- # check to see if the list of input bounding box rectangles
- # is empty
- if len(rects) == 0:
- # loop over any existing tracked objects and mark them
- # as disappeared
- for objectID in list(self.disappeared.keys()):
- self.disappeared[objectID] += 1
-
- # if we have reached a maximum number of consecutive
- # frames where a given object has been marked as
- # missing, deregister it
- if self.disappeared[objectID] > self.maxDisappeared:
- self.deregister(objectID)
-
- # return early as there are no centroids or tracking info
- # to update
- return self.objects
-
- # initialize an array of input centroids for the current frame
- inputCentroids = np.zeros((len(rects), 2), dtype="int")
-
- # loop over the bounding box rectangles
- for (i, (startX, startY, endX, endY)) in enumerate(rects):
- # use the bounding box coordinates to derive the centroid
- cX = int((startX + endX) / 2.0)
- cY = int((startY + endY) / 2.0)
- inputCentroids[i] = (cX, cY)
-
- # if we are currently not tracking any objects take the input
- # centroids and register each of them
- if len(self.objects) == 0:
- for i in range(0, len(inputCentroids)):
- self.register(inputCentroids[i])
-
- # otherwise, are are currently tracking objects so we need to
- # try to match the input centroids to existing object
- # centroids
- else:
- # grab the set of object IDs and corresponding centroids
- objectIDs = list(self.objects.keys())
- objectCentroids = list(self.objects.values())
-
- # compute the distance between each pair of object
- # centroids and input centroids, respectively -- our
- # goal will be to match an input centroid to an existing
- # object centroid
- D = dist.cdist(np.array(objectCentroids), inputCentroids)
-
- # in order to perform this matching we must (1) find the
- # smallest value in each row and then (2) sort the row
- # indexes based on their minimum values so that the row
- # with the smallest value as at the *front* of the index
- # list
- rows = D.min(axis=1).argsort()
-
- # next, we perform a similar process on the columns by
- # finding the smallest value in each column and then
- # sorting using the previously computed row index list
- cols = D.argmin(axis=1)[rows]
-
- # in order to determine if we need to update, register,
- # or deregister an object we need to keep track of which
- # of the rows and column indexes we have already examined
- usedRows = set()
- usedCols = set()
-
- # loop over the combination of the (row, column) index
- # tuples
- for (row, col) in zip(rows, cols):
- # if we have already examined either the row or
- # column value before, ignore it
- if row in usedRows or col in usedCols:
- continue
-
- # if the distance between centroids is greater than
- # the maximum distance, do not associate the two
- # centroids to the same object
- if D[row, col] > self.maxDistance:
- continue
-
- # otherwise, grab the object ID for the current row,
- # set its new centroid, and reset the disappeared
- # counter
- objectID = objectIDs[row]
- self.objects[objectID] = inputCentroids[col]
- self.disappeared[objectID] = 0
-
- # indicate that we have examined each of the row and
- # column indexes, respectively
- usedRows.add(row)
- usedCols.add(col)
-
- # compute both the row and column index we have NOT yet
- # examined
- unusedRows = set(range(0, D.shape[0])).difference(usedRows)
- unusedCols = set(range(0, D.shape[1])).difference(usedCols)
-
- # in the event that the number of object centroids is
- # equal or greater than the number of input centroids
- # we need to check and see if some of these objects have
- # potentially disappeared
- if D.shape[0] >= D.shape[1]:
- # loop over the unused row indexes
- for row in unusedRows:
- # grab the object ID for the corresponding row
- # index and increment the disappeared counter
- objectID = objectIDs[row]
- self.disappeared[objectID] += 1
-
- # check to see if the number of consecutive
- # frames the object has been marked "disappeared"
- # for warrants deregistering the object
- if self.disappeared[objectID] > self.maxDisappeared:
- self.deregister(objectID)
-
- # otherwise, if the number of input centroids is greater
- # than the number of existing object centroids we need to
- # register each new input centroid as a trackable object
- else:
- for col in unusedCols:
- self.register(inputCentroids[col])
-
- # return the set of trackable objects
- return self.objects
\ No newline at end of file
diff --git a/spaces/ali-ghamdan/deoldify/fastai/script.py b/spaces/ali-ghamdan/deoldify/fastai/script.py
deleted file mode 100644
index c66c6b9992cd0c2a5e20fd97819bc34f9e1435b8..0000000000000000000000000000000000000000
--- a/spaces/ali-ghamdan/deoldify/fastai/script.py
+++ /dev/null
@@ -1,51 +0,0 @@
-import os, sys, subprocess, inspect
-from dataclasses import dataclass
-from typing import Any
-from argparse import ArgumentParser
-
-
-@dataclass
-class Param():
- "A parameter in a function used in `anno_parser` or `call_parse`"
- help:str=None
- type:type=None
- opt:bool=True
- action:str=None
- nargs:str=None
- const:str=None
- choices:str=None
- required:bool=None
-
- @property
- def pre(self): return '--' if self.opt else ''
- @property
- def kwargs(self): return {k:v for k,v in self.__dict__.items()
- if v is not None and k!='opt'}
-
-def anno_parser(func):
- "Look at params (annotated with `Param`) in func and return an `ArgumentParser`"
- p = ArgumentParser(description=func.__doc__)
- for k,v in inspect.signature(func).parameters.items():
- param = func.__annotations__.get(k, Param())
- kwargs = param.kwargs
- if v.default != inspect.Parameter.empty: kwargs['default'] = v.default
- p.add_argument(f"{param.pre}{k}", **kwargs)
- return p
-
-def call_parse(func):
- "Decorator to create a simple CLI from `func` using `anno_parser`"
- name = inspect.currentframe().f_back.f_globals['__name__']
- if name == "__main__":
- args = anno_parser(func).parse_args()
- func(**args.__dict__)
- else: return func
-
-def call_plac(f):
- "Decorator to create a simple CLI from `func` using `plac`"
- name = inspect.currentframe().f_back.f_globals['__name__']
- if name == '__main__':
- import plac
- res = plac.call(f)
- if callable(res): res()
- else: return f
-
diff --git a/spaces/ali-ghamdan/deoldify/fastai/utils/show_install.py b/spaces/ali-ghamdan/deoldify/fastai/utils/show_install.py
deleted file mode 100644
index b9e6cc3be84ed684ec6984b1a7cfe7b673a72c8d..0000000000000000000000000000000000000000
--- a/spaces/ali-ghamdan/deoldify/fastai/utils/show_install.py
+++ /dev/null
@@ -1,8 +0,0 @@
-from ..script import *
-from .collect_env import *
-
-# Temporary POC for module-based script
-@call_parse
-def main(show_nvidia_smi:Param(opt=False, nargs='?', type=bool)=False):
- return show_install(show_nvidia_smi)
-
diff --git a/spaces/ali-ghamdan/realesrgan-models/tests/test_model.py b/spaces/ali-ghamdan/realesrgan-models/tests/test_model.py
deleted file mode 100644
index c20bb1d56ed20222e929e9c94026f6ea383c6026..0000000000000000000000000000000000000000
--- a/spaces/ali-ghamdan/realesrgan-models/tests/test_model.py
+++ /dev/null
@@ -1,126 +0,0 @@
-import torch
-import yaml
-from basicsr.archs.rrdbnet_arch import RRDBNet
-from basicsr.data.paired_image_dataset import PairedImageDataset
-from basicsr.losses.losses import GANLoss, L1Loss, PerceptualLoss
-
-from realesrgan.archs.discriminator_arch import UNetDiscriminatorSN
-from realesrgan.models.realesrgan_model import RealESRGANModel
-from realesrgan.models.realesrnet_model import RealESRNetModel
-
-
-def test_realesrnet_model():
- with open('tests/data/test_realesrnet_model.yml', mode='r') as f:
- opt = yaml.load(f, Loader=yaml.FullLoader)
-
- # build model
- model = RealESRNetModel(opt)
- # test attributes
- assert model.__class__.__name__ == 'RealESRNetModel'
- assert isinstance(model.net_g, RRDBNet)
- assert isinstance(model.cri_pix, L1Loss)
- assert isinstance(model.optimizers[0], torch.optim.Adam)
-
- # prepare data
- gt = torch.rand((1, 3, 32, 32), dtype=torch.float32)
- kernel1 = torch.rand((1, 5, 5), dtype=torch.float32)
- kernel2 = torch.rand((1, 5, 5), dtype=torch.float32)
- sinc_kernel = torch.rand((1, 5, 5), dtype=torch.float32)
- data = dict(gt=gt, kernel1=kernel1, kernel2=kernel2, sinc_kernel=sinc_kernel)
- model.feed_data(data)
- # check dequeue
- model.feed_data(data)
- # check data shape
- assert model.lq.shape == (1, 3, 8, 8)
- assert model.gt.shape == (1, 3, 32, 32)
-
- # change probability to test if-else
- model.opt['gaussian_noise_prob'] = 0
- model.opt['gray_noise_prob'] = 0
- model.opt['second_blur_prob'] = 0
- model.opt['gaussian_noise_prob2'] = 0
- model.opt['gray_noise_prob2'] = 0
- model.feed_data(data)
- # check data shape
- assert model.lq.shape == (1, 3, 8, 8)
- assert model.gt.shape == (1, 3, 32, 32)
-
- # ----------------- test nondist_validation -------------------- #
- # construct dataloader
- dataset_opt = dict(
- name='Demo',
- dataroot_gt='tests/data/gt',
- dataroot_lq='tests/data/lq',
- io_backend=dict(type='disk'),
- scale=4,
- phase='val')
- dataset = PairedImageDataset(dataset_opt)
- dataloader = torch.utils.data.DataLoader(dataset=dataset, batch_size=1, shuffle=False, num_workers=0)
- assert model.is_train is True
- model.nondist_validation(dataloader, 1, None, False)
- assert model.is_train is True
-
-
-def test_realesrgan_model():
- with open('tests/data/test_realesrgan_model.yml', mode='r') as f:
- opt = yaml.load(f, Loader=yaml.FullLoader)
-
- # build model
- model = RealESRGANModel(opt)
- # test attributes
- assert model.__class__.__name__ == 'RealESRGANModel'
- assert isinstance(model.net_g, RRDBNet) # generator
- assert isinstance(model.net_d, UNetDiscriminatorSN) # discriminator
- assert isinstance(model.cri_pix, L1Loss)
- assert isinstance(model.cri_perceptual, PerceptualLoss)
- assert isinstance(model.cri_gan, GANLoss)
- assert isinstance(model.optimizers[0], torch.optim.Adam)
- assert isinstance(model.optimizers[1], torch.optim.Adam)
-
- # prepare data
- gt = torch.rand((1, 3, 32, 32), dtype=torch.float32)
- kernel1 = torch.rand((1, 5, 5), dtype=torch.float32)
- kernel2 = torch.rand((1, 5, 5), dtype=torch.float32)
- sinc_kernel = torch.rand((1, 5, 5), dtype=torch.float32)
- data = dict(gt=gt, kernel1=kernel1, kernel2=kernel2, sinc_kernel=sinc_kernel)
- model.feed_data(data)
- # check dequeue
- model.feed_data(data)
- # check data shape
- assert model.lq.shape == (1, 3, 8, 8)
- assert model.gt.shape == (1, 3, 32, 32)
-
- # change probability to test if-else
- model.opt['gaussian_noise_prob'] = 0
- model.opt['gray_noise_prob'] = 0
- model.opt['second_blur_prob'] = 0
- model.opt['gaussian_noise_prob2'] = 0
- model.opt['gray_noise_prob2'] = 0
- model.feed_data(data)
- # check data shape
- assert model.lq.shape == (1, 3, 8, 8)
- assert model.gt.shape == (1, 3, 32, 32)
-
- # ----------------- test nondist_validation -------------------- #
- # construct dataloader
- dataset_opt = dict(
- name='Demo',
- dataroot_gt='tests/data/gt',
- dataroot_lq='tests/data/lq',
- io_backend=dict(type='disk'),
- scale=4,
- phase='val')
- dataset = PairedImageDataset(dataset_opt)
- dataloader = torch.utils.data.DataLoader(dataset=dataset, batch_size=1, shuffle=False, num_workers=0)
- assert model.is_train is True
- model.nondist_validation(dataloader, 1, None, False)
- assert model.is_train is True
-
- # ----------------- test optimize_parameters -------------------- #
- model.feed_data(data)
- model.optimize_parameters(1)
- assert model.output.shape == (1, 3, 32, 32)
- assert isinstance(model.log_dict, dict)
- # check returned keys
- expected_keys = ['l_g_pix', 'l_g_percep', 'l_g_gan', 'l_d_real', 'out_d_real', 'l_d_fake', 'out_d_fake']
- assert set(expected_keys).issubset(set(model.log_dict.keys()))
diff --git a/spaces/allknowingroger/Image-Models-Test131/README.md b/spaces/allknowingroger/Image-Models-Test131/README.md
deleted file mode 100644
index a77e6ec0a97abeffb4689a3fc6da9bfab7bcf6fb..0000000000000000000000000000000000000000
--- a/spaces/allknowingroger/Image-Models-Test131/README.md
+++ /dev/null
@@ -1,12 +0,0 @@
----
-title: More Image Models
-emoji: 😻
-colorFrom: red
-colorTo: gray
-sdk: gradio
-sdk_version: 3.23.0
-app_file: app.py
-duplicated_from: allknowingroger/Image-Models-Test130
----
-
-
\ No newline at end of file
diff --git a/spaces/amarchheda/ChordDuplicate/portaudio/cmake_support/FindJack.cmake b/spaces/amarchheda/ChordDuplicate/portaudio/cmake_support/FindJack.cmake
deleted file mode 100644
index 96e0b501b6c6c053a7a96f80b744ac3c1c8c68b2..0000000000000000000000000000000000000000
--- a/spaces/amarchheda/ChordDuplicate/portaudio/cmake_support/FindJack.cmake
+++ /dev/null
@@ -1,41 +0,0 @@
-# - Try to find jack
-# Once done this will define
-# JACK_FOUND - System has jack
-# JACK_INCLUDE_DIRS - The jack include directories
-# JACK_LIBRARIES - The libraries needed to use jack
-# JACK_DEFINITIONS - Compiler switches required for using jack
-
-if (JACK_LIBRARIES AND JACK_INCLUDE_DIRS)
-
- # in cache already
- set(JACK_FOUND TRUE)
-
-else (JACK_LIBRARIES AND JACK_INCLUDE_DIRS)
-
- set(JACK_DEFINITIONS "")
-
- # Look for pkg-config and use it (if available) to find package
- find_package(PkgConfig QUIET)
- if (PKG_CONFIG_FOUND)
- pkg_search_module(JACK QUIET jack)
- endif (PKG_CONFIG_FOUND)
-
- if (NOT JACK_FOUND)
-
- find_path(JACK_INCLUDE_DIR jack/jack.h HINTS ${JACK_INCLUDEDIR} ${JACK_INCLUDE_DIRS} PATH_SUFFIXES jack)
- find_library(JACK_LIBRARY NAMES jack HINTS ${JACK_LIBDIR} ${JACK_LIBRARY_DIRS})
-
- set(JACK_LIBRARIES ${JACK_LIBRARY})
- set(JACK_INCLUDE_DIRS ${JACK_INCLUDE_DIR})
-
- include(FindPackageHandleStandardArgs)
-
- # Set JACK_FOUND if the library and include paths were found
- find_package_handle_standard_args(jack DEFAULT_MSG JACK_LIBRARY JACK_INCLUDE_DIR)
-
- # Don't show include/library paths in cmake GUI
- mark_as_advanced(JACK_INCLUDE_DIR JACK_LIBRARY)
-
- endif (NOT JACK_FOUND)
-
-endif (JACK_LIBRARIES AND JACK_INCLUDE_DIRS)
diff --git a/spaces/anton-l/youtube-subs-wav2vec/app.py b/spaces/anton-l/youtube-subs-wav2vec/app.py
deleted file mode 100644
index 83cac746296c491fd6385912fbcd760ae13292a1..0000000000000000000000000000000000000000
--- a/spaces/anton-l/youtube-subs-wav2vec/app.py
+++ /dev/null
@@ -1,107 +0,0 @@
-from collections import deque
-
-import streamlit as st
-import torch
-from streamlit_player import st_player
-from transformers import AutoModelForCTC, Wav2Vec2Processor
-
-from streaming import ffmpeg_stream
-
-device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
-player_options = {
- "events": ["onProgress"],
- "progress_interval": 200,
- "volume": 1.0,
- "playing": True,
- "loop": False,
- "controls": False,
- "muted": False,
- "config": {"youtube": {"playerVars": {"start": 1}}},
-}
-
-# disable rapid fading in and out on `st.code` updates
-st.markdown("", unsafe_allow_html=True)
-
-@st.cache(hash_funcs={torch.nn.parameter.Parameter: lambda _: None})
-def load_model(model_path="facebook/wav2vec2-large-robust-ft-swbd-300h"):
- processor = Wav2Vec2Processor.from_pretrained(model_path)
- model = AutoModelForCTC.from_pretrained(model_path).to(device)
- return processor, model
-
-
-processor, model = load_model()
-
-
-def stream_text(url, chunk_duration_ms, pad_duration_ms):
- sampling_rate = processor.feature_extractor.sampling_rate
-
- # calculate the length of logits to cut from the sides of the output to account for input padding
- output_pad_len = model._get_feat_extract_output_lengths(int(sampling_rate * pad_duration_ms / 1000))
-
- # define the audio chunk generator
- stream = ffmpeg_stream(url, sampling_rate, chunk_duration_ms=chunk_duration_ms, pad_duration_ms=pad_duration_ms)
-
- leftover_text = ""
- for i, chunk in enumerate(stream):
- input_values = processor(chunk, sampling_rate=sampling_rate, return_tensors="pt").input_values
-
- with torch.no_grad():
- logits = model(input_values.to(device)).logits[0]
- if i > 0:
- logits = logits[output_pad_len : len(logits) - output_pad_len]
- else: # don't count padding at the start of the clip
- logits = logits[: len(logits) - output_pad_len]
-
- predicted_ids = torch.argmax(logits, dim=-1).cpu().tolist()
- if processor.decode(predicted_ids).strip():
- leftover_ids = processor.tokenizer.encode(leftover_text)
- # concat the last word (or its part) from the last frame with the current text
- text = processor.decode(leftover_ids + predicted_ids)
- # don't return the last word in case it's just partially recognized
- text, leftover_text = text.rsplit(" ", 1)
- yield text
- else:
- yield leftover_text
- leftover_text = ""
-
- yield leftover_text
-
-
-def main():
- state = st.session_state
- st.header("YouTube Streaming ASR with Robust Wav2Vec2")
-
- with st.form(key="inputs_form"):
- state.youtube_url = st.text_input("YouTube URL", "https://www.youtube.com/watch?v=yJmiZ1Mo1cQ")
- state.chunk_duration_ms = st.slider("Audio chunk duration (ms)", 2000, 10000, 3000, 100)
- state.pad_duration_ms = st.slider("Padding duration (ms)", 100, 5000, 1000, 100)
- submit_button = st.form_submit_button(label="Submit")
-
- if submit_button or "asr_stream" not in state:
- # a hack to update the video player on value changes
- state.youtube_url = (
- state.youtube_url.split("&hash=")[0]
- + f"&hash={state.chunk_duration_ms}-{state.pad_duration_ms}"
- )
- state.asr_stream = stream_text(
- state.youtube_url, state.chunk_duration_ms, state.pad_duration_ms
- )
- state.chunks_taken = 0
- state.lines = deque([], maxlen=5) # limit to the last 5 lines of subs
-
- player = st_player(state.youtube_url, **player_options, key="youtube_player")
-
- if "asr_stream" in state and player.data and player.data["played"] < 1.0:
- # check how many seconds were played, and if more than processed - write the next text chunk
- processed_seconds = state.chunks_taken * (state.chunk_duration_ms / 1000)
- if processed_seconds < player.data["playedSeconds"]:
- text = next(state.asr_stream)
- state.lines.append(text)
- state.chunks_taken += 1
- if "lines" in state:
- # print the last 3 lines of subs
- st.code("\n".join(state.lines))
-
-
-if __name__ == "__main__":
- main()
diff --git a/spaces/aodianyun/stable-diffusion-webui/javascript/imageParams.js b/spaces/aodianyun/stable-diffusion-webui/javascript/imageParams.js
deleted file mode 100644
index 67404a89ba6084a065ab5ac188e01ed29952113b..0000000000000000000000000000000000000000
--- a/spaces/aodianyun/stable-diffusion-webui/javascript/imageParams.js
+++ /dev/null
@@ -1,19 +0,0 @@
-window.onload = (function(){
- window.addEventListener('drop', e => {
- const target = e.composedPath()[0];
- const idx = selected_gallery_index();
- if (target.placeholder.indexOf("Prompt") == -1) return;
-
- let prompt_target = get_tab_index('tabs') == 1 ? "img2img_prompt_image" : "txt2img_prompt_image";
-
- e.stopPropagation();
- e.preventDefault();
- const imgParent = gradioApp().getElementById(prompt_target);
- const files = e.dataTransfer.files;
- const fileInput = imgParent.querySelector('input[type="file"]');
- if ( fileInput ) {
- fileInput.files = files;
- fileInput.dispatchEvent(new Event('change'));
- }
- });
-});
diff --git a/spaces/arseny-chebyshev/vox-diffusion/app.py b/spaces/arseny-chebyshev/vox-diffusion/app.py
deleted file mode 100644
index 0f6a28507b7f2ddb15b034c0143aa04365164752..0000000000000000000000000000000000000000
--- a/spaces/arseny-chebyshev/vox-diffusion/app.py
+++ /dev/null
@@ -1,3 +0,0 @@
-import gradio as gr
-
-gr.Interface.load("models/plasmo/vox2").launch()
\ No newline at end of file
diff --git a/spaces/artificialguybr/video-dubbing/TTS/TTS/tts/models/delightful_tts.py b/spaces/artificialguybr/video-dubbing/TTS/TTS/tts/models/delightful_tts.py
deleted file mode 100644
index b1cf886bea1f22a0ec1b0524f5a80ea8db0b55f8..0000000000000000000000000000000000000000
--- a/spaces/artificialguybr/video-dubbing/TTS/TTS/tts/models/delightful_tts.py
+++ /dev/null
@@ -1,1770 +0,0 @@
-import os
-from dataclasses import dataclass, field
-from itertools import chain
-from pathlib import Path
-from typing import Dict, List, Optional, Tuple, Union
-
-import numpy as np
-import torch
-import torch.distributed as dist
-import torchaudio
-from coqpit import Coqpit
-from librosa.filters import mel as librosa_mel_fn
-from torch import nn
-from torch.cuda.amp.autocast_mode import autocast
-from torch.nn import functional as F
-from torch.utils.data import DataLoader
-from torch.utils.data.sampler import WeightedRandomSampler
-from trainer.torch import DistributedSampler, DistributedSamplerWrapper
-from trainer.trainer_utils import get_optimizer, get_scheduler
-
-from TTS.tts.datasets.dataset import F0Dataset, TTSDataset, _parse_sample
-from TTS.tts.layers.delightful_tts.acoustic_model import AcousticModel
-from TTS.tts.layers.losses import ForwardSumLoss, VitsDiscriminatorLoss
-from TTS.tts.layers.vits.discriminator import VitsDiscriminator
-from TTS.tts.models.base_tts import BaseTTSE2E
-from TTS.tts.utils.helpers import average_over_durations, compute_attn_prior, rand_segments, segment, sequence_mask
-from TTS.tts.utils.speakers import SpeakerManager
-from TTS.tts.utils.text.tokenizer import TTSTokenizer
-from TTS.tts.utils.visual import plot_alignment, plot_avg_pitch, plot_pitch, plot_spectrogram
-from TTS.utils.audio.numpy_transforms import build_mel_basis, compute_f0
-from TTS.utils.audio.numpy_transforms import db_to_amp as db_to_amp_numpy
-from TTS.utils.audio.numpy_transforms import mel_to_wav as mel_to_wav_numpy
-from TTS.utils.audio.processor import AudioProcessor
-from TTS.utils.io import load_fsspec
-from TTS.vocoder.layers.losses import MultiScaleSTFTLoss
-from TTS.vocoder.models.hifigan_generator import HifiganGenerator
-from TTS.vocoder.utils.generic_utils import plot_results
-
-
-def id_to_torch(aux_id, cuda=False):
- if aux_id is not None:
- aux_id = np.asarray(aux_id)
- aux_id = torch.from_numpy(aux_id)
- if cuda:
- return aux_id.cuda()
- return aux_id
-
-
-def embedding_to_torch(d_vector, cuda=False):
- if d_vector is not None:
- d_vector = np.asarray(d_vector)
- d_vector = torch.from_numpy(d_vector).float()
- d_vector = d_vector.squeeze().unsqueeze(0)
- if cuda:
- return d_vector.cuda()
- return d_vector
-
-
-def numpy_to_torch(np_array, dtype, cuda=False):
- if np_array is None:
- return None
- tensor = torch.as_tensor(np_array, dtype=dtype)
- if cuda:
- return tensor.cuda()
- return tensor
-
-
-def get_mask_from_lengths(lengths: torch.Tensor) -> torch.Tensor:
- batch_size = lengths.shape[0]
- max_len = torch.max(lengths).item()
- ids = torch.arange(0, max_len, device=lengths.device).unsqueeze(0).expand(batch_size, -1)
- mask = ids >= lengths.unsqueeze(1).expand(-1, max_len)
- return mask
-
-
-def pad(input_ele: List[torch.Tensor], max_len: int) -> torch.Tensor:
- out_list = torch.jit.annotate(List[torch.Tensor], [])
- for batch in input_ele:
- if len(batch.shape) == 1:
- one_batch_padded = F.pad(batch, (0, max_len - batch.size(0)), "constant", 0.0)
- else:
- one_batch_padded = F.pad(batch, (0, 0, 0, max_len - batch.size(0)), "constant", 0.0)
- out_list.append(one_batch_padded)
- out_padded = torch.stack(out_list)
- return out_padded
-
-
-def init_weights(m: nn.Module, mean: float = 0.0, std: float = 0.01):
- classname = m.__class__.__name__
- if classname.find("Conv") != -1:
- m.weight.data.normal_(mean, std)
-
-
-def stride_lens(lens: torch.Tensor, stride: int = 2) -> torch.Tensor:
- return torch.ceil(lens / stride).int()
-
-
-def initialize_embeddings(shape: Tuple[int]) -> torch.Tensor:
- assert len(shape) == 2, "Can only initialize 2-D embedding matrices ..."
- return torch.randn(shape) * np.sqrt(2 / shape[1])
-
-
-# pylint: disable=redefined-outer-name
-def calc_same_padding(kernel_size: int) -> Tuple[int, int]:
- pad = kernel_size // 2
- return (pad, pad - (kernel_size + 1) % 2)
-
-
-hann_window = {}
-mel_basis = {}
-
-
-@torch.no_grad()
-def weights_reset(m: nn.Module):
- # check if the current module has reset_parameters and if it is reset the weight
- reset_parameters = getattr(m, "reset_parameters", None)
- if callable(reset_parameters):
- m.reset_parameters()
-
-
-def get_module_weights_sum(mdl: nn.Module):
- dict_sums = {}
- for name, w in mdl.named_parameters():
- if "weight" in name:
- value = w.data.sum().item()
- dict_sums[name] = value
- return dict_sums
-
-
-def load_audio(file_path: str):
- """Load the audio file normalized in [-1, 1]
-
- Return Shapes:
- - x: :math:`[1, T]`
- """
- x, sr = torchaudio.load(
- file_path,
- )
- assert (x > 1).sum() + (x < -1).sum() == 0
- return x, sr
-
-
-def _amp_to_db(x, C=1, clip_val=1e-5):
- return torch.log(torch.clamp(x, min=clip_val) * C)
-
-
-def _db_to_amp(x, C=1):
- return torch.exp(x) / C
-
-
-def amp_to_db(magnitudes):
- output = _amp_to_db(magnitudes)
- return output
-
-
-def db_to_amp(magnitudes):
- output = _db_to_amp(magnitudes)
- return output
-
-
-def _wav_to_spec(y, n_fft, hop_length, win_length, center=False):
- y = y.squeeze(1)
-
- if torch.min(y) < -1.0:
- print("min value is ", torch.min(y))
- if torch.max(y) > 1.0:
- print("max value is ", torch.max(y))
-
- global hann_window # pylint: disable=global-statement
- dtype_device = str(y.dtype) + "_" + str(y.device)
- wnsize_dtype_device = str(win_length) + "_" + dtype_device
- if wnsize_dtype_device not in hann_window:
- hann_window[wnsize_dtype_device] = torch.hann_window(win_length).to(dtype=y.dtype, device=y.device)
-
- y = torch.nn.functional.pad(
- y.unsqueeze(1),
- (int((n_fft - hop_length) / 2), int((n_fft - hop_length) / 2)),
- mode="reflect",
- )
- y = y.squeeze(1)
-
- spec = torch.stft(
- y,
- n_fft,
- hop_length=hop_length,
- win_length=win_length,
- window=hann_window[wnsize_dtype_device],
- center=center,
- pad_mode="reflect",
- normalized=False,
- onesided=True,
- return_complex=False,
- )
-
- return spec
-
-
-def wav_to_spec(y, n_fft, hop_length, win_length, center=False):
- """
- Args Shapes:
- - y : :math:`[B, 1, T]`
-
- Return Shapes:
- - spec : :math:`[B,C,T]`
- """
- spec = _wav_to_spec(y, n_fft, hop_length, win_length, center=center)
- spec = torch.sqrt(spec.pow(2).sum(-1) + 1e-6)
- return spec
-
-
-def wav_to_energy(y, n_fft, hop_length, win_length, center=False):
- spec = _wav_to_spec(y, n_fft, hop_length, win_length, center=center)
-
- spec = torch.sqrt(spec.pow(2).sum(-1) + 1e-6)
- return torch.norm(spec, dim=1, keepdim=True)
-
-
-def name_mel_basis(spec, n_fft, fmax):
- n_fft_len = f"{n_fft}_{fmax}_{spec.dtype}_{spec.device}"
- return n_fft_len
-
-
-def spec_to_mel(spec, n_fft, num_mels, sample_rate, fmin, fmax):
- """
- Args Shapes:
- - spec : :math:`[B,C,T]`
-
- Return Shapes:
- - mel : :math:`[B,C,T]`
- """
- global mel_basis # pylint: disable=global-statement
- mel_basis_key = name_mel_basis(spec, n_fft, fmax)
- # pylint: disable=too-many-function-args
- if mel_basis_key not in mel_basis:
- # pylint: disable=missing-kwoa
- mel = librosa_mel_fn(sample_rate, n_fft, num_mels, fmin, fmax)
- mel_basis[mel_basis_key] = torch.from_numpy(mel).to(dtype=spec.dtype, device=spec.device)
- mel = torch.matmul(mel_basis[mel_basis_key], spec)
- mel = amp_to_db(mel)
- return mel
-
-
-def wav_to_mel(y, n_fft, num_mels, sample_rate, hop_length, win_length, fmin, fmax, center=False):
- """
- Args Shapes:
- - y : :math:`[B, 1, T_y]`
-
- Return Shapes:
- - spec : :math:`[B,C,T_spec]`
- """
- y = y.squeeze(1)
-
- if torch.min(y) < -1.0:
- print("min value is ", torch.min(y))
- if torch.max(y) > 1.0:
- print("max value is ", torch.max(y))
-
- global mel_basis, hann_window # pylint: disable=global-statement
- mel_basis_key = name_mel_basis(y, n_fft, fmax)
- wnsize_dtype_device = str(win_length) + "_" + str(y.dtype) + "_" + str(y.device)
- if mel_basis_key not in mel_basis:
- # pylint: disable=missing-kwoa
- mel = librosa_mel_fn(
- sr=sample_rate, n_fft=n_fft, n_mels=num_mels, fmin=fmin, fmax=fmax
- ) # pylint: disable=too-many-function-args
- mel_basis[mel_basis_key] = torch.from_numpy(mel).to(dtype=y.dtype, device=y.device)
- if wnsize_dtype_device not in hann_window:
- hann_window[wnsize_dtype_device] = torch.hann_window(win_length).to(dtype=y.dtype, device=y.device)
-
- y = torch.nn.functional.pad(
- y.unsqueeze(1),
- (int((n_fft - hop_length) / 2), int((n_fft - hop_length) / 2)),
- mode="reflect",
- )
- y = y.squeeze(1)
-
- spec = torch.stft(
- y,
- n_fft,
- hop_length=hop_length,
- win_length=win_length,
- window=hann_window[wnsize_dtype_device],
- center=center,
- pad_mode="reflect",
- normalized=False,
- onesided=True,
- return_complex=False,
- )
-
- spec = torch.sqrt(spec.pow(2).sum(-1) + 1e-6)
- spec = torch.matmul(mel_basis[mel_basis_key], spec)
- spec = amp_to_db(spec)
- return spec
-
-
-##############################
-# DATASET
-##############################
-
-
-def get_attribute_balancer_weights(items: list, attr_name: str, multi_dict: dict = None):
- """Create balancer weight for torch WeightedSampler"""
- attr_names_samples = np.array([item[attr_name] for item in items])
- unique_attr_names = np.unique(attr_names_samples).tolist()
- attr_idx = [unique_attr_names.index(l) for l in attr_names_samples]
- attr_count = np.array([len(np.where(attr_names_samples == l)[0]) for l in unique_attr_names])
- weight_attr = 1.0 / attr_count
- dataset_samples_weight = np.array([weight_attr[l] for l in attr_idx])
- dataset_samples_weight = dataset_samples_weight / np.linalg.norm(dataset_samples_weight)
- if multi_dict is not None:
- multiplier_samples = np.array([multi_dict.get(item[attr_name], 1.0) for item in items])
- dataset_samples_weight *= multiplier_samples
- return (
- torch.from_numpy(dataset_samples_weight).float(),
- unique_attr_names,
- np.unique(dataset_samples_weight).tolist(),
- )
-
-
-class ForwardTTSE2eF0Dataset(F0Dataset):
- """Override F0Dataset to avoid slow computing of pitches"""
-
- def __init__(
- self,
- ap,
- samples: Union[List[List], List[Dict]],
- verbose=False,
- cache_path: str = None,
- precompute_num_workers=0,
- normalize_f0=True,
- ):
- super().__init__(
- samples=samples,
- ap=ap,
- verbose=verbose,
- cache_path=cache_path,
- precompute_num_workers=precompute_num_workers,
- normalize_f0=normalize_f0,
- )
-
- def _compute_and_save_pitch(self, wav_file, pitch_file=None):
- wav, _ = load_audio(wav_file)
- f0 = compute_f0(
- x=wav.numpy()[0],
- sample_rate=self.ap.sample_rate,
- hop_length=self.ap.hop_length,
- pitch_fmax=self.ap.pitch_fmax,
- pitch_fmin=self.ap.pitch_fmin,
- win_length=self.ap.win_length,
- )
- # skip the last F0 value to align with the spectrogram
- if wav.shape[1] % self.ap.hop_length != 0:
- f0 = f0[:-1]
- if pitch_file:
- np.save(pitch_file, f0)
- return f0
-
- def compute_or_load(self, wav_file, audio_name):
- """
- compute pitch and return a numpy array of pitch values
- """
- pitch_file = self.create_pitch_file_path(audio_name, self.cache_path)
- if not os.path.exists(pitch_file):
- pitch = self._compute_and_save_pitch(wav_file=wav_file, pitch_file=pitch_file)
- else:
- pitch = np.load(pitch_file)
- return pitch.astype(np.float32)
-
-
-class ForwardTTSE2eDataset(TTSDataset):
- def __init__(self, *args, **kwargs):
- # don't init the default F0Dataset in TTSDataset
- compute_f0 = kwargs.pop("compute_f0", False)
- kwargs["compute_f0"] = False
- self.attn_prior_cache_path = kwargs.pop("attn_prior_cache_path")
-
- super().__init__(*args, **kwargs)
-
- self.compute_f0 = compute_f0
- self.pad_id = self.tokenizer.characters.pad_id
- self.ap = kwargs["ap"]
-
- if self.compute_f0:
- self.f0_dataset = ForwardTTSE2eF0Dataset(
- ap=self.ap,
- samples=self.samples,
- cache_path=kwargs["f0_cache_path"],
- precompute_num_workers=kwargs["precompute_num_workers"],
- )
-
- if self.attn_prior_cache_path is not None:
- os.makedirs(self.attn_prior_cache_path, exist_ok=True)
-
- def __getitem__(self, idx):
- item = self.samples[idx]
-
- rel_wav_path = Path(item["audio_file"]).relative_to(item["root_path"]).with_suffix("")
- rel_wav_path = str(rel_wav_path).replace("/", "_")
-
- raw_text = item["text"]
- wav, _ = load_audio(item["audio_file"])
- wav_filename = os.path.basename(item["audio_file"])
-
- try:
- token_ids = self.get_token_ids(idx, item["text"])
- except:
- print(idx, item)
- # pylint: disable=raise-missing-from
- raise OSError
- f0 = None
- if self.compute_f0:
- f0 = self.get_f0(idx)["f0"]
-
- # after phonemization the text length may change
- # this is a shameful 🤭 hack to prevent longer phonemes
- # TODO: find a better fix
- if len(token_ids) > self.max_text_len or wav.shape[1] < self.min_audio_len:
- self.rescue_item_idx += 1
- return self.__getitem__(self.rescue_item_idx)
-
- attn_prior = None
- if self.attn_prior_cache_path is not None:
- attn_prior = self.load_or_compute_attn_prior(token_ids, wav, rel_wav_path)
-
- return {
- "raw_text": raw_text,
- "token_ids": token_ids,
- "token_len": len(token_ids),
- "wav": wav,
- "pitch": f0,
- "wav_file": wav_filename,
- "speaker_name": item["speaker_name"],
- "language_name": item["language"],
- "attn_prior": attn_prior,
- "audio_unique_name": item["audio_unique_name"],
- }
-
- def load_or_compute_attn_prior(self, token_ids, wav, rel_wav_path):
- """Load or compute and save the attention prior."""
- attn_prior_file = os.path.join(self.attn_prior_cache_path, f"{rel_wav_path}.npy")
- # pylint: disable=no-else-return
- if os.path.exists(attn_prior_file):
- return np.load(attn_prior_file)
- else:
- token_len = len(token_ids)
- mel_len = wav.shape[1] // self.ap.hop_length
- attn_prior = compute_attn_prior(token_len, mel_len)
- np.save(attn_prior_file, attn_prior)
- return attn_prior
-
- @property
- def lengths(self):
- lens = []
- for item in self.samples:
- _, wav_file, *_ = _parse_sample(item)
- audio_len = os.path.getsize(wav_file) / 16 * 8 # assuming 16bit audio
- lens.append(audio_len)
- return lens
-
- def collate_fn(self, batch):
- """
- Return Shapes:
- - tokens: :math:`[B, T]`
- - token_lens :math:`[B]`
- - token_rel_lens :math:`[B]`
- - pitch :math:`[B, T]`
- - waveform: :math:`[B, 1, T]`
- - waveform_lens: :math:`[B]`
- - waveform_rel_lens: :math:`[B]`
- - speaker_names: :math:`[B]`
- - language_names: :math:`[B]`
- - audiofile_paths: :math:`[B]`
- - raw_texts: :math:`[B]`
- - attn_prior: :math:`[[T_token, T_mel]]`
- """
- B = len(batch)
- batch = {k: [dic[k] for dic in batch] for k in batch[0]}
-
- max_text_len = max([len(x) for x in batch["token_ids"]])
- token_lens = torch.LongTensor(batch["token_len"])
- token_rel_lens = token_lens / token_lens.max()
-
- wav_lens = [w.shape[1] for w in batch["wav"]]
- wav_lens = torch.LongTensor(wav_lens)
- wav_lens_max = torch.max(wav_lens)
- wav_rel_lens = wav_lens / wav_lens_max
-
- pitch_padded = None
- if self.compute_f0:
- pitch_lens = [p.shape[0] for p in batch["pitch"]]
- pitch_lens = torch.LongTensor(pitch_lens)
- pitch_lens_max = torch.max(pitch_lens)
- pitch_padded = torch.FloatTensor(B, 1, pitch_lens_max)
- pitch_padded = pitch_padded.zero_() + self.pad_id
-
- token_padded = torch.LongTensor(B, max_text_len)
- wav_padded = torch.FloatTensor(B, 1, wav_lens_max)
-
- token_padded = token_padded.zero_() + self.pad_id
- wav_padded = wav_padded.zero_() + self.pad_id
-
- for i in range(B):
- token_ids = batch["token_ids"][i]
- token_padded[i, : batch["token_len"][i]] = torch.LongTensor(token_ids)
-
- wav = batch["wav"][i]
- wav_padded[i, :, : wav.size(1)] = torch.FloatTensor(wav)
-
- if self.compute_f0:
- pitch = batch["pitch"][i]
- pitch_padded[i, 0, : len(pitch)] = torch.FloatTensor(pitch)
-
- return {
- "text_input": token_padded,
- "text_lengths": token_lens,
- "text_rel_lens": token_rel_lens,
- "pitch": pitch_padded,
- "waveform": wav_padded, # (B x T)
- "waveform_lens": wav_lens, # (B)
- "waveform_rel_lens": wav_rel_lens,
- "speaker_names": batch["speaker_name"],
- "language_names": batch["language_name"],
- "audio_unique_names": batch["audio_unique_name"],
- "audio_files": batch["wav_file"],
- "raw_text": batch["raw_text"],
- "attn_priors": batch["attn_prior"] if batch["attn_prior"][0] is not None else None,
- }
-
-
-##############################
-# CONFIG DEFINITIONS
-##############################
-
-
-@dataclass
-class VocoderConfig(Coqpit):
- resblock_type_decoder: str = "1"
- resblock_kernel_sizes_decoder: List[int] = field(default_factory=lambda: [3, 7, 11])
- resblock_dilation_sizes_decoder: List[List[int]] = field(default_factory=lambda: [[1, 3, 5], [1, 3, 5], [1, 3, 5]])
- upsample_rates_decoder: List[int] = field(default_factory=lambda: [8, 8, 2, 2])
- upsample_initial_channel_decoder: int = 512
- upsample_kernel_sizes_decoder: List[int] = field(default_factory=lambda: [16, 16, 4, 4])
- use_spectral_norm_discriminator: bool = False
- upsampling_rates_discriminator: List[int] = field(default_factory=lambda: [4, 4, 4, 4])
- periods_discriminator: List[int] = field(default_factory=lambda: [2, 3, 5, 7, 11])
- pretrained_model_path: Optional[str] = None
-
-
-@dataclass
-class DelightfulTtsAudioConfig(Coqpit):
- sample_rate: int = 22050
- hop_length: int = 256
- win_length: int = 1024
- fft_size: int = 1024
- mel_fmin: float = 0.0
- mel_fmax: float = 8000
- num_mels: int = 100
- pitch_fmax: float = 640.0
- pitch_fmin: float = 1.0
- resample: bool = False
- preemphasis: float = 0.0
- ref_level_db: int = 20
- do_sound_norm: bool = False
- log_func: str = "np.log10"
- do_trim_silence: bool = True
- trim_db: int = 45
- do_rms_norm: bool = False
- db_level: float = None
- power: float = 1.5
- griffin_lim_iters: int = 60
- spec_gain: int = 20
- do_amp_to_db_linear: bool = True
- do_amp_to_db_mel: bool = True
- min_level_db: int = -100
- max_norm: float = 4.0
-
-
-@dataclass
-class DelightfulTtsArgs(Coqpit):
- num_chars: int = 100
- spec_segment_size: int = 32
- n_hidden_conformer_encoder: int = 512
- n_layers_conformer_encoder: int = 6
- n_heads_conformer_encoder: int = 8
- dropout_conformer_encoder: float = 0.1
- kernel_size_conv_mod_conformer_encoder: int = 7
- kernel_size_depthwise_conformer_encoder: int = 7
- lrelu_slope: float = 0.3
- n_hidden_conformer_decoder: int = 512
- n_layers_conformer_decoder: int = 6
- n_heads_conformer_decoder: int = 8
- dropout_conformer_decoder: float = 0.1
- kernel_size_conv_mod_conformer_decoder: int = 11
- kernel_size_depthwise_conformer_decoder: int = 11
- bottleneck_size_p_reference_encoder: int = 4
- bottleneck_size_u_reference_encoder: int = 512
- ref_enc_filters_reference_encoder = [32, 32, 64, 64, 128, 128]
- ref_enc_size_reference_encoder: int = 3
- ref_enc_strides_reference_encoder = [1, 2, 1, 2, 1]
- ref_enc_pad_reference_encoder = [1, 1]
- ref_enc_gru_size_reference_encoder: int = 32
- ref_attention_dropout_reference_encoder: float = 0.2
- token_num_reference_encoder: int = 32
- predictor_kernel_size_reference_encoder: int = 5
- n_hidden_variance_adaptor: int = 512
- kernel_size_variance_adaptor: int = 5
- dropout_variance_adaptor: float = 0.5
- n_bins_variance_adaptor: int = 256
- emb_kernel_size_variance_adaptor: int = 3
- use_speaker_embedding: bool = False
- num_speakers: int = 0
- speakers_file: str = None
- d_vector_file: str = None
- speaker_embedding_channels: int = 384
- use_d_vector_file: bool = False
- d_vector_dim: int = 0
- freeze_vocoder: bool = False
- freeze_text_encoder: bool = False
- freeze_duration_predictor: bool = False
- freeze_pitch_predictor: bool = False
- freeze_energy_predictor: bool = False
- freeze_basis_vectors_predictor: bool = False
- freeze_decoder: bool = False
- length_scale: float = 1.0
-
-
-##############################
-# MODEL DEFINITION
-##############################
-class DelightfulTTS(BaseTTSE2E):
- """
- Paper::
- https://arxiv.org/pdf/2110.12612.pdf
-
- Paper Abstract::
- This paper describes the Microsoft end-to-end neural text to speech (TTS) system: DelightfulTTS for Blizzard Challenge 2021.
- The goal of this challenge is to synthesize natural and high-quality speech from text, and we approach this goal in two perspectives:
- The first is to directly model and generate waveform in 48 kHz sampling rate, which brings higher perception quality than previous systems
- with 16 kHz or 24 kHz sampling rate; The second is to model the variation information in speech through a systematic design, which improves
- the prosody and naturalness. Specifically, for 48 kHz modeling, we predict 16 kHz mel-spectrogram in acoustic model, and
- propose a vocoder called HiFiNet to directly generate 48 kHz waveform from predicted 16 kHz mel-spectrogram, which can better trade off training
- efficiency, modelling stability and voice quality. We model variation information systematically from both explicit (speaker ID, language ID, pitch and duration) and
- implicit (utterance-level and phoneme-level prosody) perspectives: 1) For speaker and language ID, we use lookup embedding in training and
- inference; 2) For pitch and duration, we extract the values from paired text-speech data in training and use two predictors to predict the values in inference; 3)
- For utterance-level and phoneme-level prosody, we use two reference encoders to extract the values in training, and use two separate predictors to predict the values in inference.
- Additionally, we introduce an improved Conformer block to better model the local and global dependency in acoustic model. For task SH1, DelightfulTTS achieves 4.17 mean score in MOS test
- and 4.35 in SMOS test, which indicates the effectiveness of our proposed system
-
-
- Model training::
- text --> ForwardTTS() --> spec_hat --> rand_seg_select()--> GANVocoder() --> waveform_seg
- spec --------^
-
- Examples:
- >>> from TTS.tts.models.forward_tts_e2e import ForwardTTSE2e, ForwardTTSE2eConfig
- >>> config = ForwardTTSE2eConfig()
- >>> model = ForwardTTSE2e(config)
- """
-
- # pylint: disable=dangerous-default-value
- def __init__(
- self,
- config: Coqpit,
- ap,
- tokenizer: "TTSTokenizer" = None,
- speaker_manager: SpeakerManager = None,
- ):
- super().__init__(config=config, ap=ap, tokenizer=tokenizer, speaker_manager=speaker_manager)
- self.ap = ap
-
- self._set_model_args(config)
- self.init_multispeaker(config)
- self.binary_loss_weight = None
-
- self.args.out_channels = self.config.audio.num_mels
- self.args.num_mels = self.config.audio.num_mels
- self.acoustic_model = AcousticModel(args=self.args, tokenizer=tokenizer, speaker_manager=speaker_manager)
-
- self.waveform_decoder = HifiganGenerator(
- self.config.audio.num_mels,
- 1,
- self.config.vocoder.resblock_type_decoder,
- self.config.vocoder.resblock_dilation_sizes_decoder,
- self.config.vocoder.resblock_kernel_sizes_decoder,
- self.config.vocoder.upsample_kernel_sizes_decoder,
- self.config.vocoder.upsample_initial_channel_decoder,
- self.config.vocoder.upsample_rates_decoder,
- inference_padding=0,
- # cond_channels=self.embedded_speaker_dim,
- conv_pre_weight_norm=False,
- conv_post_weight_norm=False,
- conv_post_bias=False,
- )
-
- if self.config.init_discriminator:
- self.disc = VitsDiscriminator(
- use_spectral_norm=self.config.vocoder.use_spectral_norm_discriminator,
- periods=self.config.vocoder.periods_discriminator,
- )
-
- @property
- def device(self):
- return next(self.parameters()).device
-
- @property
- def energy_scaler(self):
- return self.acoustic_model.energy_scaler
-
- @property
- def length_scale(self):
- return self.acoustic_model.length_scale
-
- @length_scale.setter
- def length_scale(self, value):
- self.acoustic_model.length_scale = value
-
- @property
- def pitch_mean(self):
- return self.acoustic_model.pitch_mean
-
- @pitch_mean.setter
- def pitch_mean(self, value):
- self.acoustic_model.pitch_mean = value
-
- @property
- def pitch_std(self):
- return self.acoustic_model.pitch_std
-
- @pitch_std.setter
- def pitch_std(self, value):
- self.acoustic_model.pitch_std = value
-
- @property
- def mel_basis(self):
- return build_mel_basis(
- sample_rate=self.ap.sample_rate,
- fft_size=self.ap.fft_size,
- num_mels=self.ap.num_mels,
- mel_fmax=self.ap.mel_fmax,
- mel_fmin=self.ap.mel_fmin,
- ) # pylint: disable=function-redefined
-
- def init_for_training(self) -> None:
- self.train_disc = ( # pylint: disable=attribute-defined-outside-init
- self.config.steps_to_start_discriminator <= 0
- ) # pylint: disable=attribute-defined-outside-init
- self.update_energy_scaler = True # pylint: disable=attribute-defined-outside-init
-
- def init_multispeaker(self, config: Coqpit):
- """Init for multi-speaker training.
-
- Args:
- config (Coqpit): Model configuration.
- """
- self.embedded_speaker_dim = 0
- self.num_speakers = self.args.num_speakers
- self.audio_transform = None
-
- if self.speaker_manager:
- self.num_speakers = self.speaker_manager.num_speakers
- self.args.num_speakers = self.speaker_manager.num_speakers
-
- if self.args.use_speaker_embedding:
- self._init_speaker_embedding()
-
- if self.args.use_d_vector_file:
- self._init_d_vector()
-
- def _init_speaker_embedding(self):
- # pylint: disable=attribute-defined-outside-init
- if self.num_speakers > 0:
- print(" > initialization of speaker-embedding layers.")
- self.embedded_speaker_dim = self.args.speaker_embedding_channels
- self.args.embedded_speaker_dim = self.args.speaker_embedding_channels
-
- def _init_d_vector(self):
- # pylint: disable=attribute-defined-outside-init
- if hasattr(self, "emb_g"):
- raise ValueError("[!] Speaker embedding layer already initialized before d_vector settings.")
- self.embedded_speaker_dim = self.args.d_vector_dim
- self.args.embedded_speaker_dim = self.args.d_vector_dim
-
- def _freeze_layers(self):
- if self.args.freeze_vocoder:
- for param in self.vocoder.paramseters():
- param.requires_grad = False
-
- if self.args.freeze_text_encoder:
- for param in self.text_encoder.parameters():
- param.requires_grad = False
-
- if self.args.freeze_duration_predictor:
- for param in self.durarion_predictor.parameters():
- param.requires_grad = False
-
- if self.args.freeze_pitch_predictor:
- for param in self.pitch_predictor.parameters():
- param.requires_grad = False
-
- if self.args.freeze_energy_predictor:
- for param in self.energy_predictor.parameters():
- param.requires_grad = False
-
- if self.args.freeze_decoder:
- for param in self.decoder.parameters():
- param.requires_grad = False
-
- def forward(
- self,
- x: torch.LongTensor,
- x_lengths: torch.LongTensor,
- spec_lengths: torch.LongTensor,
- spec: torch.FloatTensor,
- waveform: torch.FloatTensor,
- pitch: torch.FloatTensor = None,
- energy: torch.FloatTensor = None,
- attn_priors: torch.FloatTensor = None,
- d_vectors: torch.FloatTensor = None,
- speaker_idx: torch.LongTensor = None,
- ) -> Dict:
- """Model's forward pass.
-
- Args:
- x (torch.LongTensor): Input character sequences.
- x_lengths (torch.LongTensor): Input sequence lengths.
- spec_lengths (torch.LongTensor): Spectrogram sequnce lengths. Defaults to None.
- spec (torch.FloatTensor): Spectrogram frames. Only used when the alignment network is on. Defaults to None.
- waveform (torch.FloatTensor): Waveform. Defaults to None.
- pitch (torch.FloatTensor): Pitch values for each spectrogram frame. Only used when the pitch predictor is on. Defaults to None.
- energy (torch.FloatTensor): Spectral energy values for each spectrogram frame. Only used when the energy predictor is on. Defaults to None.
- attn_priors (torch.FloatTentrasor): Attention priors for the aligner network. Defaults to None.
- aux_input (Dict): Auxiliary model inputs for multi-speaker training. Defaults to `{"d_vectors": 0, "speaker_ids": None}`.
-
- Shapes:
- - x: :math:`[B, T_max]`
- - x_lengths: :math:`[B]`
- - spec_lengths: :math:`[B]`
- - spec: :math:`[B, T_max2, C_spec]`
- - waveform: :math:`[B, 1, T_max2 * hop_length]`
- - g: :math:`[B, C]`
- - pitch: :math:`[B, 1, T_max2]`
- - energy: :math:`[B, 1, T_max2]`
- """
- encoder_outputs = self.acoustic_model(
- tokens=x,
- src_lens=x_lengths,
- mel_lens=spec_lengths,
- mels=spec,
- pitches=pitch,
- energies=energy,
- attn_priors=attn_priors,
- d_vectors=d_vectors,
- speaker_idx=speaker_idx,
- )
-
- # use mel-spec from the decoder
- vocoder_input = encoder_outputs["model_outputs"] # [B, T_max2, C_mel]
-
- vocoder_input_slices, slice_ids = rand_segments(
- x=vocoder_input.transpose(1, 2),
- x_lengths=spec_lengths,
- segment_size=self.args.spec_segment_size,
- let_short_samples=True,
- pad_short=True,
- )
- if encoder_outputs["spk_emb"] is not None:
- g = encoder_outputs["spk_emb"].unsqueeze(-1)
- else:
- g = None
-
- vocoder_output = self.waveform_decoder(x=vocoder_input_slices.detach(), g=g)
- wav_seg = segment(
- waveform,
- slice_ids * self.ap.hop_length,
- self.args.spec_segment_size * self.ap.hop_length,
- pad_short=True,
- )
- model_outputs = {**encoder_outputs}
- model_outputs["acoustic_model_outputs"] = encoder_outputs["model_outputs"]
- model_outputs["model_outputs"] = vocoder_output
- model_outputs["waveform_seg"] = wav_seg
- model_outputs["slice_ids"] = slice_ids
- return model_outputs
-
- @torch.no_grad()
- def inference(
- self, x, aux_input={"d_vectors": None, "speaker_ids": None}, pitch_transform=None, energy_transform=None
- ):
- encoder_outputs = self.acoustic_model.inference(
- tokens=x,
- d_vectors=aux_input["d_vectors"],
- speaker_idx=aux_input["speaker_ids"],
- pitch_transform=pitch_transform,
- energy_transform=energy_transform,
- p_control=None,
- d_control=None,
- )
- vocoder_input = encoder_outputs["model_outputs"].transpose(1, 2) # [B, T_max2, C_mel] -> [B, C_mel, T_max2]
- if encoder_outputs["spk_emb"] is not None:
- g = encoder_outputs["spk_emb"].unsqueeze(-1)
- else:
- g = None
-
- vocoder_output = self.waveform_decoder(x=vocoder_input, g=g)
- model_outputs = {**encoder_outputs}
- model_outputs["model_outputs"] = vocoder_output
- return model_outputs
-
- @torch.no_grad()
- def inference_spec_decoder(self, x, aux_input={"d_vectors": None, "speaker_ids": None}):
- encoder_outputs = self.acoustic_model.inference(
- tokens=x,
- d_vectors=aux_input["d_vectors"],
- speaker_idx=aux_input["speaker_ids"],
- )
- model_outputs = {**encoder_outputs}
- return model_outputs
-
- def train_step(self, batch: dict, criterion: nn.Module, optimizer_idx: int):
- if optimizer_idx == 0:
- tokens = batch["text_input"]
- token_lenghts = batch["text_lengths"]
- mel = batch["mel_input"]
- mel_lens = batch["mel_lengths"]
- waveform = batch["waveform"] # [B, T, C] -> [B, C, T]
- pitch = batch["pitch"]
- d_vectors = batch["d_vectors"]
- speaker_ids = batch["speaker_ids"]
- attn_priors = batch["attn_priors"]
- energy = batch["energy"]
-
- # generator pass
- outputs = self.forward(
- x=tokens,
- x_lengths=token_lenghts,
- spec_lengths=mel_lens,
- spec=mel,
- waveform=waveform,
- pitch=pitch,
- energy=energy,
- attn_priors=attn_priors,
- d_vectors=d_vectors,
- speaker_idx=speaker_ids,
- )
-
- # cache tensors for the generator pass
- self.model_outputs_cache = outputs # pylint: disable=attribute-defined-outside-init
-
- if self.train_disc:
- # compute scores and features
- scores_d_fake, _, scores_d_real, _ = self.disc(
- outputs["model_outputs"].detach(), outputs["waveform_seg"]
- )
-
- # compute loss
- with autocast(enabled=False): # use float32 for the criterion
- loss_dict = criterion[optimizer_idx](
- scores_disc_fake=scores_d_fake,
- scores_disc_real=scores_d_real,
- )
- return outputs, loss_dict
- return None, None
-
- if optimizer_idx == 1:
- mel = batch["mel_input"]
- # compute melspec segment
- with autocast(enabled=False):
- mel_slice = segment(
- mel.float(), self.model_outputs_cache["slice_ids"], self.args.spec_segment_size, pad_short=True
- )
-
- mel_slice_hat = wav_to_mel(
- y=self.model_outputs_cache["model_outputs"].float(),
- n_fft=self.ap.fft_size,
- sample_rate=self.ap.sample_rate,
- num_mels=self.ap.num_mels,
- hop_length=self.ap.hop_length,
- win_length=self.ap.win_length,
- fmin=self.ap.mel_fmin,
- fmax=self.ap.mel_fmax,
- center=False,
- )
-
- scores_d_fake = None
- feats_d_fake = None
- feats_d_real = None
-
- if self.train_disc:
- # compute discriminator scores and features
- scores_d_fake, feats_d_fake, _, feats_d_real = self.disc(
- self.model_outputs_cache["model_outputs"], self.model_outputs_cache["waveform_seg"]
- )
-
- # compute losses
- with autocast(enabled=True): # use float32 for the criterion
- loss_dict = criterion[optimizer_idx](
- mel_output=self.model_outputs_cache["acoustic_model_outputs"].transpose(1, 2),
- mel_target=batch["mel_input"],
- mel_lens=batch["mel_lengths"],
- dur_output=self.model_outputs_cache["dr_log_pred"],
- dur_target=self.model_outputs_cache["dr_log_target"].detach(),
- pitch_output=self.model_outputs_cache["pitch_pred"],
- pitch_target=self.model_outputs_cache["pitch_target"],
- energy_output=self.model_outputs_cache["energy_pred"],
- energy_target=self.model_outputs_cache["energy_target"],
- src_lens=batch["text_lengths"],
- waveform=self.model_outputs_cache["waveform_seg"],
- waveform_hat=self.model_outputs_cache["model_outputs"],
- p_prosody_ref=self.model_outputs_cache["p_prosody_ref"],
- p_prosody_pred=self.model_outputs_cache["p_prosody_pred"],
- u_prosody_ref=self.model_outputs_cache["u_prosody_ref"],
- u_prosody_pred=self.model_outputs_cache["u_prosody_pred"],
- aligner_logprob=self.model_outputs_cache["aligner_logprob"],
- aligner_hard=self.model_outputs_cache["aligner_mas"],
- aligner_soft=self.model_outputs_cache["aligner_soft"],
- binary_loss_weight=self.binary_loss_weight,
- feats_fake=feats_d_fake,
- feats_real=feats_d_real,
- scores_fake=scores_d_fake,
- spec_slice=mel_slice,
- spec_slice_hat=mel_slice_hat,
- skip_disc=not self.train_disc,
- )
-
- loss_dict["avg_text_length"] = batch["text_lengths"].float().mean()
- loss_dict["avg_mel_length"] = batch["mel_lengths"].float().mean()
- loss_dict["avg_text_batch_occupancy"] = (
- batch["text_lengths"].float() / batch["text_lengths"].float().max()
- ).mean()
- loss_dict["avg_mel_batch_occupancy"] = (
- batch["mel_lengths"].float() / batch["mel_lengths"].float().max()
- ).mean()
-
- return self.model_outputs_cache, loss_dict
- raise ValueError(" [!] Unexpected `optimizer_idx`.")
-
- def eval_step(self, batch: dict, criterion: nn.Module, optimizer_idx: int):
- return self.train_step(batch, criterion, optimizer_idx)
-
- def _log(self, batch, outputs, name_prefix="train"):
- figures, audios = {}, {}
-
- # encoder outputs
- model_outputs = outputs[1]["acoustic_model_outputs"]
- alignments = outputs[1]["alignments"]
- mel_input = batch["mel_input"]
-
- pred_spec = model_outputs[0].data.cpu().numpy()
- gt_spec = mel_input[0].data.cpu().numpy()
- align_img = alignments[0].data.cpu().numpy()
-
- figures = {
- "prediction": plot_spectrogram(pred_spec, None, output_fig=False),
- "ground_truth": plot_spectrogram(gt_spec.T, None, output_fig=False),
- "alignment": plot_alignment(align_img, output_fig=False),
- }
-
- # plot pitch figures
- pitch_avg = abs(outputs[1]["pitch_target"][0, 0].data.cpu().numpy())
- pitch_avg_hat = abs(outputs[1]["pitch_pred"][0, 0].data.cpu().numpy())
- chars = self.tokenizer.decode(batch["text_input"][0].data.cpu().numpy())
- pitch_figures = {
- "pitch_ground_truth": plot_avg_pitch(pitch_avg, chars, output_fig=False),
- "pitch_avg_predicted": plot_avg_pitch(pitch_avg_hat, chars, output_fig=False),
- }
- figures.update(pitch_figures)
-
- # plot energy figures
- energy_avg = abs(outputs[1]["energy_target"][0, 0].data.cpu().numpy())
- energy_avg_hat = abs(outputs[1]["energy_pred"][0, 0].data.cpu().numpy())
- chars = self.tokenizer.decode(batch["text_input"][0].data.cpu().numpy())
- energy_figures = {
- "energy_ground_truth": plot_avg_pitch(energy_avg, chars, output_fig=False),
- "energy_avg_predicted": plot_avg_pitch(energy_avg_hat, chars, output_fig=False),
- }
- figures.update(energy_figures)
-
- # plot the attention mask computed from the predicted durations
- alignments_hat = outputs[1]["alignments_dp"][0].data.cpu().numpy()
- figures["alignment_hat"] = plot_alignment(alignments_hat.T, output_fig=False)
-
- # Sample audio
- encoder_audio = mel_to_wav_numpy(
- mel=db_to_amp_numpy(x=pred_spec.T, gain=1, base=None), mel_basis=self.mel_basis, **self.config.audio
- )
- audios[f"{name_prefix}/encoder_audio"] = encoder_audio
-
- # vocoder outputs
- y_hat = outputs[1]["model_outputs"]
- y = outputs[1]["waveform_seg"]
-
- vocoder_figures = plot_results(y_hat=y_hat, y=y, ap=self.ap, name_prefix=name_prefix)
- figures.update(vocoder_figures)
-
- sample_voice = y_hat[0].squeeze(0).detach().cpu().numpy()
- audios[f"{name_prefix}/vocoder_audio"] = sample_voice
- return figures, audios
-
- def train_log(
- self, batch: dict, outputs: dict, logger: "Logger", assets: dict, steps: int
- ): # pylint: disable=no-self-use, unused-argument
- """Create visualizations and waveform examples.
-
- For example, here you can plot spectrograms and generate sample sample waveforms from these spectrograms to
- be projected onto Tensorboard.
-
- Args:
- batch (Dict): Model inputs used at the previous training step.
- outputs (Dict): Model outputs generated at the previous training step.
-
- Returns:
- Tuple[Dict, np.ndarray]: training plots and output waveform.
- """
- figures, audios = self._log(batch=batch, outputs=outputs, name_prefix="vocoder/")
- logger.train_figures(steps, figures)
- logger.train_audios(steps, audios, self.ap.sample_rate)
-
- def eval_log(self, batch: dict, outputs: dict, logger: "Logger", assets: dict, steps: int) -> None:
- figures, audios = self._log(batch=batch, outputs=outputs, name_prefix="vocoder/")
- logger.eval_figures(steps, figures)
- logger.eval_audios(steps, audios, self.ap.sample_rate)
-
- def get_aux_input_from_test_sentences(self, sentence_info):
- if hasattr(self.config, "model_args"):
- config = self.config.model_args
- else:
- config = self.config
-
- # extract speaker and language info
- text, speaker_name, style_wav = None, None, None
-
- if isinstance(sentence_info, list):
- if len(sentence_info) == 1:
- text = sentence_info[0]
- elif len(sentence_info) == 2:
- text, speaker_name = sentence_info
- elif len(sentence_info) == 3:
- text, speaker_name, style_wav = sentence_info
- else:
- text = sentence_info
-
- # get speaker id/d_vector
- speaker_id, d_vector = None, None
- if hasattr(self, "speaker_manager"):
- if config.use_d_vector_file:
- if speaker_name is None:
- d_vector = self.speaker_manager.get_random_embedding()
- else:
- d_vector = self.speaker_manager.get_mean_embedding(speaker_name, num_samples=None, randomize=False)
- elif config.use_speaker_embedding:
- if speaker_name is None:
- speaker_id = self.speaker_manager.get_random_id()
- else:
- speaker_id = self.speaker_manager.name_to_id[speaker_name]
-
- return {"text": text, "speaker_id": speaker_id, "style_wav": style_wav, "d_vector": d_vector}
-
- def plot_outputs(self, text, wav, alignment, outputs):
- figures = {}
- pitch_avg_pred = outputs["pitch"].cpu()
- energy_avg_pred = outputs["energy"].cpu()
- spec = wav_to_mel(
- y=torch.from_numpy(wav[None, :]),
- n_fft=self.ap.fft_size,
- sample_rate=self.ap.sample_rate,
- num_mels=self.ap.num_mels,
- hop_length=self.ap.hop_length,
- win_length=self.ap.win_length,
- fmin=self.ap.mel_fmin,
- fmax=self.ap.mel_fmax,
- center=False,
- )[0].transpose(0, 1)
- pitch = compute_f0(
- x=wav[0],
- sample_rate=self.ap.sample_rate,
- hop_length=self.ap.hop_length,
- pitch_fmax=self.ap.pitch_fmax,
- )
- input_text = self.tokenizer.ids_to_text(self.tokenizer.text_to_ids(text, language="en"))
- input_text = input_text.replace("", "_")
- durations = outputs["durations"]
- pitch_avg = average_over_durations(torch.from_numpy(pitch)[None, None, :], durations.cpu()) # [1, 1, n_frames]
- pitch_avg_pred_denorm = (pitch_avg_pred * self.pitch_std) + self.pitch_mean
- figures["alignment"] = plot_alignment(alignment.transpose(1, 2), output_fig=False)
- figures["spectrogram"] = plot_spectrogram(spec)
- figures["pitch_from_wav"] = plot_pitch(pitch, spec)
- figures["pitch_avg_from_wav"] = plot_avg_pitch(pitch_avg.squeeze(), input_text)
- figures["pitch_avg_pred"] = plot_avg_pitch(pitch_avg_pred_denorm.squeeze(), input_text)
- figures["energy_avg_pred"] = plot_avg_pitch(energy_avg_pred.squeeze(), input_text)
- return figures
-
- def synthesize(
- self,
- text: str,
- speaker_id: str = None,
- d_vector: torch.tensor = None,
- pitch_transform=None,
- **kwargs,
- ): # pylint: disable=unused-argument
- # TODO: add cloning support with ref_waveform
- is_cuda = next(self.parameters()).is_cuda
-
- # convert text to sequence of token IDs
- text_inputs = np.asarray(
- self.tokenizer.text_to_ids(text, language=None),
- dtype=np.int32,
- )
-
- # set speaker inputs
- _speaker_id = None
- if speaker_id is not None and self.args.use_speaker_embedding:
- if isinstance(speaker_id, str) and self.args.use_speaker_embedding:
- # get the speaker id for the speaker embedding layer
- _speaker_id = self.speaker_manager.name_to_id[speaker_id]
- _speaker_id = id_to_torch(_speaker_id, cuda=is_cuda)
-
- if speaker_id is not None and self.args.use_d_vector_file:
- # get the average d_vector for the speaker
- d_vector = self.speaker_manager.get_mean_embedding(speaker_id, num_samples=None, randomize=False)
- d_vector = embedding_to_torch(d_vector, cuda=is_cuda)
-
- text_inputs = numpy_to_torch(text_inputs, torch.long, cuda=is_cuda)
- text_inputs = text_inputs.unsqueeze(0)
-
- # synthesize voice
- outputs = self.inference(
- text_inputs,
- aux_input={"d_vectors": d_vector, "speaker_ids": _speaker_id},
- pitch_transform=pitch_transform,
- # energy_transform=energy_transform
- )
-
- # collect outputs
- wav = outputs["model_outputs"][0].data.cpu().numpy()
- alignments = outputs["alignments"]
- return_dict = {
- "wav": wav,
- "alignments": alignments,
- "text_inputs": text_inputs,
- "outputs": outputs,
- }
- return return_dict
-
- def synthesize_with_gl(self, text: str, speaker_id, d_vector):
- is_cuda = next(self.parameters()).is_cuda
-
- # convert text to sequence of token IDs
- text_inputs = np.asarray(
- self.tokenizer.text_to_ids(text, language=None),
- dtype=np.int32,
- )
- # pass tensors to backend
- if speaker_id is not None:
- speaker_id = id_to_torch(speaker_id, cuda=is_cuda)
-
- if d_vector is not None:
- d_vector = embedding_to_torch(d_vector, cuda=is_cuda)
-
- text_inputs = numpy_to_torch(text_inputs, torch.long, cuda=is_cuda)
- text_inputs = text_inputs.unsqueeze(0)
-
- # synthesize voice
- outputs = self.inference_spec_decoder(
- x=text_inputs,
- aux_input={"d_vectors": d_vector, "speaker_ids": speaker_id},
- )
-
- # collect outputs
- S = outputs["model_outputs"].cpu().numpy()[0].T
- S = db_to_amp_numpy(x=S, gain=1, base=None)
- wav = mel_to_wav_numpy(mel=S, mel_basis=self.mel_basis, **self.config.audio)
- alignments = outputs["alignments"]
- return_dict = {
- "wav": wav[None, :],
- "alignments": alignments,
- "text_inputs": text_inputs,
- "outputs": outputs,
- }
- return return_dict
-
- @torch.no_grad()
- def test_run(self, assets) -> Tuple[Dict, Dict]:
- """Generic test run for `tts` models used by `Trainer`.
-
- You can override this for a different behaviour.
-
- Returns:
- Tuple[Dict, Dict]: Test figures and audios to be projected to Tensorboard.
- """
- print(" | > Synthesizing test sentences.")
- test_audios = {}
- test_figures = {}
- test_sentences = self.config.test_sentences
- for idx, s_info in enumerate(test_sentences):
- aux_inputs = self.get_aux_input_from_test_sentences(s_info)
- outputs = self.synthesize(
- aux_inputs["text"],
- config=self.config,
- speaker_id=aux_inputs["speaker_id"],
- d_vector=aux_inputs["d_vector"],
- )
- outputs_gl = self.synthesize_with_gl(
- aux_inputs["text"],
- speaker_id=aux_inputs["speaker_id"],
- d_vector=aux_inputs["d_vector"],
- )
- # speaker_name = self.speaker_manager.speaker_names[aux_inputs["speaker_id"]]
- test_audios["{}-audio".format(idx)] = outputs["wav"].T
- test_audios["{}-audio_encoder".format(idx)] = outputs_gl["wav"].T
- test_figures["{}-alignment".format(idx)] = plot_alignment(outputs["alignments"], output_fig=False)
- return {"figures": test_figures, "audios": test_audios}
-
- def test_log(
- self, outputs: dict, logger: "Logger", assets: dict, steps: int # pylint: disable=unused-argument
- ) -> None:
- logger.test_audios(steps, outputs["audios"], self.config.audio.sample_rate)
- logger.test_figures(steps, outputs["figures"])
-
- def format_batch(self, batch: Dict) -> Dict:
- """Compute speaker, langugage IDs and d_vector for the batch if necessary."""
- speaker_ids = None
- d_vectors = None
-
- # get numerical speaker ids from speaker names
- if self.speaker_manager is not None and self.speaker_manager.speaker_names and self.args.use_speaker_embedding:
- speaker_ids = [self.speaker_manager.name_to_id[sn] for sn in batch["speaker_names"]]
-
- if speaker_ids is not None:
- speaker_ids = torch.LongTensor(speaker_ids)
- batch["speaker_ids"] = speaker_ids
-
- # get d_vectors from audio file names
- if self.speaker_manager is not None and self.speaker_manager.embeddings and self.args.use_d_vector_file:
- d_vector_mapping = self.speaker_manager.embeddings
- d_vectors = [d_vector_mapping[w]["embedding"] for w in batch["audio_unique_names"]]
- d_vectors = torch.FloatTensor(d_vectors)
-
- batch["d_vectors"] = d_vectors
- batch["speaker_ids"] = speaker_ids
- return batch
-
- def format_batch_on_device(self, batch):
- """Compute spectrograms on the device."""
-
- ac = self.ap
-
- # compute spectrograms
- batch["mel_input"] = wav_to_mel(
- batch["waveform"],
- hop_length=ac.hop_length,
- win_length=ac.win_length,
- n_fft=ac.fft_size,
- num_mels=ac.num_mels,
- sample_rate=ac.sample_rate,
- fmin=ac.mel_fmin,
- fmax=ac.mel_fmax,
- center=False,
- )
-
- # TODO: Align pitch properly
- # assert (
- # batch["pitch"].shape[2] == batch["mel_input"].shape[2]
- # ), f"{batch['pitch'].shape[2]}, {batch['mel_input'].shape[2]}"
- batch["pitch"] = batch["pitch"][:, :, : batch["mel_input"].shape[2]] if batch["pitch"] is not None else None
- batch["mel_lengths"] = (batch["mel_input"].shape[2] * batch["waveform_rel_lens"]).int()
-
- # zero the padding frames
- batch["mel_input"] = batch["mel_input"] * sequence_mask(batch["mel_lengths"]).unsqueeze(1)
-
- # format attn priors as we now the max mel length
- # TODO: fix 1 diff b/w mel_lengths and attn_priors
-
- if self.config.use_attn_priors:
- attn_priors_np = batch["attn_priors"]
-
- batch["attn_priors"] = torch.zeros(
- batch["mel_input"].shape[0],
- batch["mel_lengths"].max(),
- batch["text_lengths"].max(),
- device=batch["mel_input"].device,
- )
-
- for i in range(batch["mel_input"].shape[0]):
- batch["attn_priors"][i, : attn_priors_np[i].shape[0], : attn_priors_np[i].shape[1]] = torch.from_numpy(
- attn_priors_np[i]
- )
-
- batch["energy"] = None
- batch["energy"] = wav_to_energy( # [B, 1, T_max2]
- batch["waveform"],
- hop_length=ac.hop_length,
- win_length=ac.win_length,
- n_fft=ac.fft_size,
- center=False,
- )
- batch["energy"] = self.energy_scaler(batch["energy"])
- return batch
-
- def get_sampler(self, config: Coqpit, dataset: TTSDataset, num_gpus=1):
- weights = None
- data_items = dataset.samples
- if getattr(config, "use_weighted_sampler", False):
- for attr_name, alpha in config.weighted_sampler_attrs.items():
- print(f" > Using weighted sampler for attribute '{attr_name}' with alpha '{alpha}'")
- multi_dict = config.weighted_sampler_multipliers.get(attr_name, None)
- print(multi_dict)
- weights, attr_names, attr_weights = get_attribute_balancer_weights(
- attr_name=attr_name, items=data_items, multi_dict=multi_dict
- )
- weights = weights * alpha
- print(f" > Attribute weights for '{attr_names}' \n | > {attr_weights}")
-
- if weights is not None:
- sampler = WeightedRandomSampler(weights, len(weights))
- else:
- sampler = None
- # sampler for DDP
- if sampler is None:
- sampler = DistributedSampler(dataset) if num_gpus > 1 else None
- else: # If a sampler is already defined use this sampler and DDP sampler together
- sampler = DistributedSamplerWrapper(sampler) if num_gpus > 1 else sampler
- return sampler
-
- def get_data_loader(
- self,
- config: Coqpit,
- assets: Dict,
- is_eval: bool,
- samples: Union[List[Dict], List[List]],
- verbose: bool,
- num_gpus: int,
- rank: int = None,
- ) -> "DataLoader":
- if is_eval and not config.run_eval:
- loader = None
- else:
- # init dataloader
- dataset = ForwardTTSE2eDataset(
- samples=samples,
- ap=self.ap,
- batch_group_size=0 if is_eval else config.batch_group_size * config.batch_size,
- min_text_len=config.min_text_len,
- max_text_len=config.max_text_len,
- min_audio_len=config.min_audio_len,
- max_audio_len=config.max_audio_len,
- phoneme_cache_path=config.phoneme_cache_path,
- precompute_num_workers=config.precompute_num_workers,
- compute_f0=config.compute_f0,
- f0_cache_path=config.f0_cache_path,
- attn_prior_cache_path=config.attn_prior_cache_path if config.use_attn_priors else None,
- verbose=verbose,
- tokenizer=self.tokenizer,
- start_by_longest=config.start_by_longest,
- )
-
- # wait all the DDP process to be ready
- if num_gpus > 1:
- dist.barrier()
-
- # sort input sequences ascendingly by length
- dataset.preprocess_samples()
-
- # get samplers
- sampler = self.get_sampler(config, dataset, num_gpus)
-
- loader = DataLoader(
- dataset,
- batch_size=config.eval_batch_size if is_eval else config.batch_size,
- shuffle=False, # shuffle is done in the dataset.
- drop_last=False, # setting this False might cause issues in AMP training.
- sampler=sampler,
- collate_fn=dataset.collate_fn,
- num_workers=config.num_eval_loader_workers if is_eval else config.num_loader_workers,
- pin_memory=True,
- )
-
- # get pitch mean and std
- self.pitch_mean = dataset.f0_dataset.mean
- self.pitch_std = dataset.f0_dataset.std
- return loader
-
- def get_criterion(self):
- return [VitsDiscriminatorLoss(self.config), DelightfulTTSLoss(self.config)]
-
- def get_optimizer(self) -> List:
- """Initiate and return the GAN optimizers based on the config parameters.
- It returnes 2 optimizers in a list. First one is for the generator and the second one is for the discriminator.
- Returns:
- List: optimizers.
- """
- optimizer_disc = get_optimizer(
- self.config.optimizer, self.config.optimizer_params, self.config.lr_disc, self.disc
- )
- gen_parameters = chain(params for k, params in self.named_parameters() if not k.startswith("disc."))
- optimizer_gen = get_optimizer(
- self.config.optimizer, self.config.optimizer_params, self.config.lr_gen, parameters=gen_parameters
- )
- return [optimizer_disc, optimizer_gen]
-
- def get_lr(self) -> List:
- """Set the initial learning rates for each optimizer.
-
- Returns:
- List: learning rates for each optimizer.
- """
- return [self.config.lr_disc, self.config.lr_gen]
-
- def get_scheduler(self, optimizer) -> List:
- """Set the schedulers for each optimizer.
-
- Args:
- optimizer (List[`torch.optim.Optimizer`]): List of optimizers.
-
- Returns:
- List: Schedulers, one for each optimizer.
- """
- scheduler_D = get_scheduler(self.config.lr_scheduler_gen, self.config.lr_scheduler_gen_params, optimizer[0])
- scheduler_G = get_scheduler(self.config.lr_scheduler_disc, self.config.lr_scheduler_disc_params, optimizer[1])
- return [scheduler_D, scheduler_G]
-
- def on_epoch_end(self, trainer): # pylint: disable=unused-argument
- # stop updating mean and var
- # TODO: do the same for F0
- self.energy_scaler.eval()
-
- @staticmethod
- def init_from_config(
- config: "DelightfulTTSConfig", samples: Union[List[List], List[Dict]] = None, verbose=False
- ): # pylint: disable=unused-argument
- """Initiate model from config
-
- Args:
- config (ForwardTTSE2eConfig): Model config.
- samples (Union[List[List], List[Dict]]): Training samples to parse speaker ids for training.
- Defaults to None.
- """
-
- tokenizer, new_config = TTSTokenizer.init_from_config(config)
- speaker_manager = SpeakerManager.init_from_config(config.model_args, samples)
- ap = AudioProcessor.init_from_config(config=config)
- return DelightfulTTS(config=new_config, tokenizer=tokenizer, speaker_manager=speaker_manager, ap=ap)
-
- def load_checkpoint(self, config, checkpoint_path, eval=False):
- """Load model from a checkpoint created by the 👟"""
- # pylint: disable=unused-argument, redefined-builtin
- state = load_fsspec(checkpoint_path, map_location=torch.device("cpu"))
- self.load_state_dict(state["model"])
- if eval:
- self.eval()
- assert not self.training
-
- def get_state_dict(self):
- """Custom state dict of the model with all the necessary components for inference."""
- save_state = {"config": self.config.to_dict(), "args": self.args.to_dict(), "model": self.state_dict}
-
- if hasattr(self, "emb_g"):
- save_state["speaker_ids"] = self.speaker_manager.speaker_names
-
- if self.args.use_d_vector_file:
- # TODO: implement saving of d_vectors
- ...
- return save_state
-
- def save(self, config, checkpoint_path):
- """Save model to a file."""
- save_state = self.get_state_dict(config, checkpoint_path) # pylint: disable=too-many-function-args
- save_state["pitch_mean"] = self.pitch_mean
- save_state["pitch_std"] = self.pitch_std
- torch.save(save_state, checkpoint_path)
-
- def on_train_step_start(self, trainer) -> None:
- """Enable the discriminator training based on `steps_to_start_discriminator`
-
- Args:
- trainer (Trainer): Trainer object.
- """
- self.binary_loss_weight = min(trainer.epochs_done / self.config.binary_loss_warmup_epochs, 1.0) * 1.0
- self.train_disc = ( # pylint: disable=attribute-defined-outside-init
- trainer.total_steps_done >= self.config.steps_to_start_discriminator
- )
-
-
-class DelightfulTTSLoss(nn.Module):
- def __init__(self, config):
- super().__init__()
-
- self.mse_loss = nn.MSELoss()
- self.mae_loss = nn.L1Loss()
- self.forward_sum_loss = ForwardSumLoss()
- self.multi_scale_stft_loss = MultiScaleSTFTLoss(**config.multi_scale_stft_loss_params)
-
- self.mel_loss_alpha = config.mel_loss_alpha
- self.aligner_loss_alpha = config.aligner_loss_alpha
- self.pitch_loss_alpha = config.pitch_loss_alpha
- self.energy_loss_alpha = config.energy_loss_alpha
- self.u_prosody_loss_alpha = config.u_prosody_loss_alpha
- self.p_prosody_loss_alpha = config.p_prosody_loss_alpha
- self.dur_loss_alpha = config.dur_loss_alpha
- self.char_dur_loss_alpha = config.char_dur_loss_alpha
- self.binary_alignment_loss_alpha = config.binary_align_loss_alpha
-
- self.vocoder_mel_loss_alpha = config.vocoder_mel_loss_alpha
- self.feat_loss_alpha = config.feat_loss_alpha
- self.gen_loss_alpha = config.gen_loss_alpha
- self.multi_scale_stft_loss_alpha = config.multi_scale_stft_loss_alpha
-
- @staticmethod
- def _binary_alignment_loss(alignment_hard, alignment_soft):
- """Binary loss that forces soft alignments to match the hard alignments as
- explained in `https://arxiv.org/pdf/2108.10447.pdf`.
- """
- log_sum = torch.log(torch.clamp(alignment_soft[alignment_hard == 1], min=1e-12)).sum()
- return -log_sum / alignment_hard.sum()
-
- @staticmethod
- def feature_loss(feats_real, feats_generated):
- loss = 0
- for dr, dg in zip(feats_real, feats_generated):
- for rl, gl in zip(dr, dg):
- rl = rl.float().detach()
- gl = gl.float()
- loss += torch.mean(torch.abs(rl - gl))
- return loss * 2
-
- @staticmethod
- def generator_loss(scores_fake):
- loss = 0
- gen_losses = []
- for dg in scores_fake:
- dg = dg.float()
- l = torch.mean((1 - dg) ** 2)
- gen_losses.append(l)
- loss += l
-
- return loss, gen_losses
-
- def forward(
- self,
- mel_output,
- mel_target,
- mel_lens,
- dur_output,
- dur_target,
- pitch_output,
- pitch_target,
- energy_output,
- energy_target,
- src_lens,
- waveform,
- waveform_hat,
- p_prosody_ref,
- p_prosody_pred,
- u_prosody_ref,
- u_prosody_pred,
- aligner_logprob,
- aligner_hard,
- aligner_soft,
- binary_loss_weight=None,
- feats_fake=None,
- feats_real=None,
- scores_fake=None,
- spec_slice=None,
- spec_slice_hat=None,
- skip_disc=False,
- ):
- """
- Shapes:
- - mel_output: :math:`(B, C_mel, T_mel)`
- - mel_target: :math:`(B, C_mel, T_mel)`
- - mel_lens: :math:`(B)`
- - dur_output: :math:`(B, T_src)`
- - dur_target: :math:`(B, T_src)`
- - pitch_output: :math:`(B, 1, T_src)`
- - pitch_target: :math:`(B, 1, T_src)`
- - energy_output: :math:`(B, 1, T_src)`
- - energy_target: :math:`(B, 1, T_src)`
- - src_lens: :math:`(B)`
- - waveform: :math:`(B, 1, T_wav)`
- - waveform_hat: :math:`(B, 1, T_wav)`
- - p_prosody_ref: :math:`(B, T_src, 4)`
- - p_prosody_pred: :math:`(B, T_src, 4)`
- - u_prosody_ref: :math:`(B, 1, 256)
- - u_prosody_pred: :math:`(B, 1, 256)
- - aligner_logprob: :math:`(B, 1, T_mel, T_src)`
- - aligner_hard: :math:`(B, T_mel, T_src)`
- - aligner_soft: :math:`(B, T_mel, T_src)`
- - spec_slice: :math:`(B, C_mel, T_mel)`
- - spec_slice_hat: :math:`(B, C_mel, T_mel)`
- """
- loss_dict = {}
- src_mask = sequence_mask(src_lens).to(mel_output.device) # (B, T_src)
- mel_mask = sequence_mask(mel_lens).to(mel_output.device) # (B, T_mel)
-
- dur_target.requires_grad = False
- mel_target.requires_grad = False
- pitch_target.requires_grad = False
-
- masked_mel_predictions = mel_output.masked_select(mel_mask[:, None])
- mel_targets = mel_target.masked_select(mel_mask[:, None])
- mel_loss = self.mae_loss(masked_mel_predictions, mel_targets)
-
- p_prosody_ref = p_prosody_ref.detach()
- p_prosody_loss = 0.5 * self.mae_loss(
- p_prosody_ref.masked_select(src_mask.unsqueeze(-1)),
- p_prosody_pred.masked_select(src_mask.unsqueeze(-1)),
- )
-
- u_prosody_ref = u_prosody_ref.detach()
- u_prosody_loss = 0.5 * self.mae_loss(u_prosody_ref, u_prosody_pred)
-
- duration_loss = self.mse_loss(dur_output, dur_target)
-
- pitch_output = pitch_output.masked_select(src_mask[:, None])
- pitch_target = pitch_target.masked_select(src_mask[:, None])
- pitch_loss = self.mse_loss(pitch_output, pitch_target)
-
- energy_output = energy_output.masked_select(src_mask[:, None])
- energy_target = energy_target.masked_select(src_mask[:, None])
- energy_loss = self.mse_loss(energy_output, energy_target)
-
- forward_sum_loss = self.forward_sum_loss(aligner_logprob, src_lens, mel_lens)
-
- total_loss = (
- (mel_loss * self.mel_loss_alpha)
- + (duration_loss * self.dur_loss_alpha)
- + (u_prosody_loss * self.u_prosody_loss_alpha)
- + (p_prosody_loss * self.p_prosody_loss_alpha)
- + (pitch_loss * self.pitch_loss_alpha)
- + (energy_loss * self.energy_loss_alpha)
- + (forward_sum_loss * self.aligner_loss_alpha)
- )
-
- if self.binary_alignment_loss_alpha > 0 and aligner_hard is not None:
- binary_alignment_loss = self._binary_alignment_loss(aligner_hard, aligner_soft)
- total_loss = total_loss + self.binary_alignment_loss_alpha * binary_alignment_loss * binary_loss_weight
- if binary_loss_weight:
- loss_dict["loss_binary_alignment"] = (
- self.binary_alignment_loss_alpha * binary_alignment_loss * binary_loss_weight
- )
- else:
- loss_dict["loss_binary_alignment"] = self.binary_alignment_loss_alpha * binary_alignment_loss
-
- loss_dict["loss_aligner"] = self.aligner_loss_alpha * forward_sum_loss
- loss_dict["loss_mel"] = self.mel_loss_alpha * mel_loss
- loss_dict["loss_duration"] = self.dur_loss_alpha * duration_loss
- loss_dict["loss_u_prosody"] = self.u_prosody_loss_alpha * u_prosody_loss
- loss_dict["loss_p_prosody"] = self.p_prosody_loss_alpha * p_prosody_loss
- loss_dict["loss_pitch"] = self.pitch_loss_alpha * pitch_loss
- loss_dict["loss_energy"] = self.energy_loss_alpha * energy_loss
- loss_dict["loss"] = total_loss
-
- # vocoder losses
- if not skip_disc:
- loss_feat = self.feature_loss(feats_real=feats_real, feats_generated=feats_fake) * self.feat_loss_alpha
- loss_gen = self.generator_loss(scores_fake=scores_fake)[0] * self.gen_loss_alpha
- loss_dict["vocoder_loss_feat"] = loss_feat
- loss_dict["vocoder_loss_gen"] = loss_gen
- loss_dict["loss"] = loss_dict["loss"] + loss_feat + loss_gen
-
- loss_mel = torch.nn.functional.l1_loss(spec_slice, spec_slice_hat) * self.vocoder_mel_loss_alpha
- loss_stft_mg, loss_stft_sc = self.multi_scale_stft_loss(y_hat=waveform_hat, y=waveform)
- loss_stft_mg = loss_stft_mg * self.multi_scale_stft_loss_alpha
- loss_stft_sc = loss_stft_sc * self.multi_scale_stft_loss_alpha
-
- loss_dict["vocoder_loss_mel"] = loss_mel
- loss_dict["vocoder_loss_stft_mg"] = loss_stft_mg
- loss_dict["vocoder_loss_stft_sc"] = loss_stft_sc
-
- loss_dict["loss"] = loss_dict["loss"] + loss_mel + loss_stft_sc + loss_stft_mg
- return loss_dict
diff --git a/spaces/artificialguybr/video-dubbing/Wav2Lip/models/conv.py b/spaces/artificialguybr/video-dubbing/Wav2Lip/models/conv.py
deleted file mode 100644
index ed83da00cb199e027ef217fd360352d91a7891ff..0000000000000000000000000000000000000000
--- a/spaces/artificialguybr/video-dubbing/Wav2Lip/models/conv.py
+++ /dev/null
@@ -1,44 +0,0 @@
-import torch
-from torch import nn
-from torch.nn import functional as F
-
-class Conv2d(nn.Module):
- def __init__(self, cin, cout, kernel_size, stride, padding, residual=False, *args, **kwargs):
- super().__init__(*args, **kwargs)
- self.conv_block = nn.Sequential(
- nn.Conv2d(cin, cout, kernel_size, stride, padding),
- nn.BatchNorm2d(cout)
- )
- self.act = nn.ReLU()
- self.residual = residual
-
- def forward(self, x):
- out = self.conv_block(x)
- if self.residual:
- out += x
- return self.act(out)
-
-class nonorm_Conv2d(nn.Module):
- def __init__(self, cin, cout, kernel_size, stride, padding, residual=False, *args, **kwargs):
- super().__init__(*args, **kwargs)
- self.conv_block = nn.Sequential(
- nn.Conv2d(cin, cout, kernel_size, stride, padding),
- )
- self.act = nn.LeakyReLU(0.01, inplace=True)
-
- def forward(self, x):
- out = self.conv_block(x)
- return self.act(out)
-
-class Conv2dTranspose(nn.Module):
- def __init__(self, cin, cout, kernel_size, stride, padding, output_padding=0, *args, **kwargs):
- super().__init__(*args, **kwargs)
- self.conv_block = nn.Sequential(
- nn.ConvTranspose2d(cin, cout, kernel_size, stride, padding, output_padding),
- nn.BatchNorm2d(cout)
- )
- self.act = nn.ReLU()
-
- def forward(self, x):
- out = self.conv_block(x)
- return self.act(out)
diff --git a/spaces/arxify/RVC-beta-v2-0618/runtime/Lib/site-packages/Crypto/SelfTest/Cipher/common.py b/spaces/arxify/RVC-beta-v2-0618/runtime/Lib/site-packages/Crypto/SelfTest/Cipher/common.py
deleted file mode 100644
index c5bc755abb555148ab7c46f1e82fcfeacac31366..0000000000000000000000000000000000000000
--- a/spaces/arxify/RVC-beta-v2-0618/runtime/Lib/site-packages/Crypto/SelfTest/Cipher/common.py
+++ /dev/null
@@ -1,510 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# SelfTest/Hash/common.py: Common code for Crypto.SelfTest.Hash
-#
-# Written in 2008 by Dwayne C. Litzenberger
-#
-# ===================================================================
-# The contents of this file are dedicated to the public domain. To
-# the extent that dedication to the public domain is not available,
-# everyone is granted a worldwide, perpetual, royalty-free,
-# non-exclusive license to exercise all rights associated with the
-# contents of this file for any purpose whatsoever.
-# No rights are reserved.
-#
-# 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.
-# ===================================================================
-
-"""Self-testing for PyCrypto hash modules"""
-
-import unittest
-from binascii import a2b_hex, b2a_hex, hexlify
-
-from Crypto.Util.py3compat import b
-from Crypto.Util.strxor import strxor_c
-
-class _NoDefault: pass # sentinel object
-def _extract(d, k, default=_NoDefault):
- """Get an item from a dictionary, and remove it from the dictionary."""
- try:
- retval = d[k]
- except KeyError:
- if default is _NoDefault:
- raise
- return default
- del d[k]
- return retval
-
-# Generic cipher test case
-class CipherSelfTest(unittest.TestCase):
-
- def __init__(self, module, params):
- unittest.TestCase.__init__(self)
- self.module = module
-
- # Extract the parameters
- params = params.copy()
- self.description = _extract(params, 'description')
- self.key = b(_extract(params, 'key'))
- self.plaintext = b(_extract(params, 'plaintext'))
- self.ciphertext = b(_extract(params, 'ciphertext'))
- self.module_name = _extract(params, 'module_name', None)
- self.assoc_data = _extract(params, 'assoc_data', None)
- self.mac = _extract(params, 'mac', None)
- if self.assoc_data:
- self.mac = b(self.mac)
-
- mode = _extract(params, 'mode', None)
- self.mode_name = str(mode)
-
- if mode is not None:
- # Block cipher
- self.mode = getattr(self.module, "MODE_" + mode)
-
- self.iv = _extract(params, 'iv', None)
- if self.iv is None:
- self.iv = _extract(params, 'nonce', None)
- if self.iv is not None:
- self.iv = b(self.iv)
-
- else:
- # Stream cipher
- self.mode = None
- self.iv = _extract(params, 'iv', None)
- if self.iv is not None:
- self.iv = b(self.iv)
-
- self.extra_params = params
-
- def shortDescription(self):
- return self.description
-
- def _new(self):
- params = self.extra_params.copy()
- key = a2b_hex(self.key)
-
- old_style = []
- if self.mode is not None:
- old_style = [ self.mode ]
- if self.iv is not None:
- old_style += [ a2b_hex(self.iv) ]
-
- return self.module.new(key, *old_style, **params)
-
- def isMode(self, name):
- if not hasattr(self.module, "MODE_"+name):
- return False
- return self.mode == getattr(self.module, "MODE_"+name)
-
- def runTest(self):
- plaintext = a2b_hex(self.plaintext)
- ciphertext = a2b_hex(self.ciphertext)
- assoc_data = []
- if self.assoc_data:
- assoc_data = [ a2b_hex(b(x)) for x in self.assoc_data]
-
- ct = None
- pt = None
-
- #
- # Repeat the same encryption or decryption twice and verify
- # that the result is always the same
- #
- for i in range(2):
- cipher = self._new()
- decipher = self._new()
-
- # Only AEAD modes
- for comp in assoc_data:
- cipher.update(comp)
- decipher.update(comp)
-
- ctX = b2a_hex(cipher.encrypt(plaintext))
- ptX = b2a_hex(decipher.decrypt(ciphertext))
-
- if ct:
- self.assertEqual(ct, ctX)
- self.assertEqual(pt, ptX)
- ct, pt = ctX, ptX
-
- self.assertEqual(self.ciphertext, ct) # encrypt
- self.assertEqual(self.plaintext, pt) # decrypt
-
- if self.mac:
- mac = b2a_hex(cipher.digest())
- self.assertEqual(self.mac, mac)
- decipher.verify(a2b_hex(self.mac))
-
-class CipherStreamingSelfTest(CipherSelfTest):
-
- def shortDescription(self):
- desc = self.module_name
- if self.mode is not None:
- desc += " in %s mode" % (self.mode_name,)
- return "%s should behave like a stream cipher" % (desc,)
-
- def runTest(self):
- plaintext = a2b_hex(self.plaintext)
- ciphertext = a2b_hex(self.ciphertext)
-
- # The cipher should work like a stream cipher
-
- # Test counter mode encryption, 3 bytes at a time
- ct3 = []
- cipher = self._new()
- for i in range(0, len(plaintext), 3):
- ct3.append(cipher.encrypt(plaintext[i:i+3]))
- ct3 = b2a_hex(b("").join(ct3))
- self.assertEqual(self.ciphertext, ct3) # encryption (3 bytes at a time)
-
- # Test counter mode decryption, 3 bytes at a time
- pt3 = []
- cipher = self._new()
- for i in range(0, len(ciphertext), 3):
- pt3.append(cipher.encrypt(ciphertext[i:i+3]))
- # PY3K: This is meant to be text, do not change to bytes (data)
- pt3 = b2a_hex(b("").join(pt3))
- self.assertEqual(self.plaintext, pt3) # decryption (3 bytes at a time)
-
-
-class RoundtripTest(unittest.TestCase):
- def __init__(self, module, params):
- from Crypto import Random
- unittest.TestCase.__init__(self)
- self.module = module
- self.iv = Random.get_random_bytes(module.block_size)
- self.key = b(params['key'])
- self.plaintext = 100 * b(params['plaintext'])
- self.module_name = params.get('module_name', None)
-
- def shortDescription(self):
- return """%s .decrypt() output of .encrypt() should not be garbled""" % (self.module_name,)
-
- def runTest(self):
-
- ## ECB mode
- mode = self.module.MODE_ECB
- encryption_cipher = self.module.new(a2b_hex(self.key), mode)
- ciphertext = encryption_cipher.encrypt(self.plaintext)
- decryption_cipher = self.module.new(a2b_hex(self.key), mode)
- decrypted_plaintext = decryption_cipher.decrypt(ciphertext)
- self.assertEqual(self.plaintext, decrypted_plaintext)
-
-
-class IVLengthTest(unittest.TestCase):
- def __init__(self, module, params):
- unittest.TestCase.__init__(self)
- self.module = module
- self.key = b(params['key'])
-
- def shortDescription(self):
- return "Check that all modes except MODE_ECB and MODE_CTR require an IV of the proper length"
-
- def runTest(self):
- self.assertRaises(TypeError, self.module.new, a2b_hex(self.key),
- self.module.MODE_ECB, b(""))
-
- def _dummy_counter(self):
- return "\0" * self.module.block_size
-
-
-class NoDefaultECBTest(unittest.TestCase):
- def __init__(self, module, params):
- unittest.TestCase.__init__(self)
- self.module = module
- self.key = b(params['key'])
-
- def runTest(self):
- self.assertRaises(TypeError, self.module.new, a2b_hex(self.key))
-
-
-class BlockSizeTest(unittest.TestCase):
- def __init__(self, module, params):
- unittest.TestCase.__init__(self)
- self.module = module
- self.key = a2b_hex(b(params['key']))
-
- def runTest(self):
- cipher = self.module.new(self.key, self.module.MODE_ECB)
- self.assertEqual(cipher.block_size, self.module.block_size)
-
-
-class ByteArrayTest(unittest.TestCase):
- """Verify we can use bytearray's for encrypting and decrypting"""
-
- def __init__(self, module, params):
- unittest.TestCase.__init__(self)
- self.module = module
-
- # Extract the parameters
- params = params.copy()
- self.description = _extract(params, 'description')
- self.key = b(_extract(params, 'key'))
- self.plaintext = b(_extract(params, 'plaintext'))
- self.ciphertext = b(_extract(params, 'ciphertext'))
- self.module_name = _extract(params, 'module_name', None)
- self.assoc_data = _extract(params, 'assoc_data', None)
- self.mac = _extract(params, 'mac', None)
- if self.assoc_data:
- self.mac = b(self.mac)
-
- mode = _extract(params, 'mode', None)
- self.mode_name = str(mode)
-
- if mode is not None:
- # Block cipher
- self.mode = getattr(self.module, "MODE_" + mode)
-
- self.iv = _extract(params, 'iv', None)
- if self.iv is None:
- self.iv = _extract(params, 'nonce', None)
- if self.iv is not None:
- self.iv = b(self.iv)
- else:
- # Stream cipher
- self.mode = None
- self.iv = _extract(params, 'iv', None)
- if self.iv is not None:
- self.iv = b(self.iv)
-
- self.extra_params = params
-
- def _new(self):
- params = self.extra_params.copy()
- key = a2b_hex(self.key)
-
- old_style = []
- if self.mode is not None:
- old_style = [ self.mode ]
- if self.iv is not None:
- old_style += [ a2b_hex(self.iv) ]
-
- return self.module.new(key, *old_style, **params)
-
- def runTest(self):
-
- plaintext = a2b_hex(self.plaintext)
- ciphertext = a2b_hex(self.ciphertext)
- assoc_data = []
- if self.assoc_data:
- assoc_data = [ bytearray(a2b_hex(b(x))) for x in self.assoc_data]
-
- cipher = self._new()
- decipher = self._new()
-
- # Only AEAD modes
- for comp in assoc_data:
- cipher.update(comp)
- decipher.update(comp)
-
- ct = b2a_hex(cipher.encrypt(bytearray(plaintext)))
- pt = b2a_hex(decipher.decrypt(bytearray(ciphertext)))
-
- self.assertEqual(self.ciphertext, ct) # encrypt
- self.assertEqual(self.plaintext, pt) # decrypt
-
- if self.mac:
- mac = b2a_hex(cipher.digest())
- self.assertEqual(self.mac, mac)
- decipher.verify(bytearray(a2b_hex(self.mac)))
-
-
-class MemoryviewTest(unittest.TestCase):
- """Verify we can use memoryviews for encrypting and decrypting"""
-
- def __init__(self, module, params):
- unittest.TestCase.__init__(self)
- self.module = module
-
- # Extract the parameters
- params = params.copy()
- self.description = _extract(params, 'description')
- self.key = b(_extract(params, 'key'))
- self.plaintext = b(_extract(params, 'plaintext'))
- self.ciphertext = b(_extract(params, 'ciphertext'))
- self.module_name = _extract(params, 'module_name', None)
- self.assoc_data = _extract(params, 'assoc_data', None)
- self.mac = _extract(params, 'mac', None)
- if self.assoc_data:
- self.mac = b(self.mac)
-
- mode = _extract(params, 'mode', None)
- self.mode_name = str(mode)
-
- if mode is not None:
- # Block cipher
- self.mode = getattr(self.module, "MODE_" + mode)
-
- self.iv = _extract(params, 'iv', None)
- if self.iv is None:
- self.iv = _extract(params, 'nonce', None)
- if self.iv is not None:
- self.iv = b(self.iv)
- else:
- # Stream cipher
- self.mode = None
- self.iv = _extract(params, 'iv', None)
- if self.iv is not None:
- self.iv = b(self.iv)
-
- self.extra_params = params
-
- def _new(self):
- params = self.extra_params.copy()
- key = a2b_hex(self.key)
-
- old_style = []
- if self.mode is not None:
- old_style = [ self.mode ]
- if self.iv is not None:
- old_style += [ a2b_hex(self.iv) ]
-
- return self.module.new(key, *old_style, **params)
-
- def runTest(self):
-
- plaintext = a2b_hex(self.plaintext)
- ciphertext = a2b_hex(self.ciphertext)
- assoc_data = []
- if self.assoc_data:
- assoc_data = [ memoryview(a2b_hex(b(x))) for x in self.assoc_data]
-
- cipher = self._new()
- decipher = self._new()
-
- # Only AEAD modes
- for comp in assoc_data:
- cipher.update(comp)
- decipher.update(comp)
-
- ct = b2a_hex(cipher.encrypt(memoryview(plaintext)))
- pt = b2a_hex(decipher.decrypt(memoryview(ciphertext)))
-
- self.assertEqual(self.ciphertext, ct) # encrypt
- self.assertEqual(self.plaintext, pt) # decrypt
-
- if self.mac:
- mac = b2a_hex(cipher.digest())
- self.assertEqual(self.mac, mac)
- decipher.verify(memoryview(a2b_hex(self.mac)))
-
-
-def make_block_tests(module, module_name, test_data, additional_params=dict()):
- tests = []
- extra_tests_added = False
- for i in range(len(test_data)):
- row = test_data[i]
-
- # Build the "params" dictionary with
- # - plaintext
- # - ciphertext
- # - key
- # - mode (default is ECB)
- # - (optionally) description
- # - (optionally) any other parameter that this cipher mode requires
- params = {}
- if len(row) == 3:
- (params['plaintext'], params['ciphertext'], params['key']) = row
- elif len(row) == 4:
- (params['plaintext'], params['ciphertext'], params['key'], params['description']) = row
- elif len(row) == 5:
- (params['plaintext'], params['ciphertext'], params['key'], params['description'], extra_params) = row
- params.update(extra_params)
- else:
- raise AssertionError("Unsupported tuple size %d" % (len(row),))
-
- if not "mode" in params:
- params["mode"] = "ECB"
-
- # Build the display-name for the test
- p2 = params.copy()
- p_key = _extract(p2, 'key')
- p_plaintext = _extract(p2, 'plaintext')
- p_ciphertext = _extract(p2, 'ciphertext')
- p_mode = _extract(p2, 'mode')
- p_description = _extract(p2, 'description', None)
-
- if p_description is not None:
- description = p_description
- elif p_mode == 'ECB' and not p2:
- description = "p=%s, k=%s" % (p_plaintext, p_key)
- else:
- description = "p=%s, k=%s, %r" % (p_plaintext, p_key, p2)
- name = "%s #%d: %s" % (module_name, i+1, description)
- params['description'] = name
- params['module_name'] = module_name
- params.update(additional_params)
-
- # Add extra test(s) to the test suite before the current test
- if not extra_tests_added:
- tests += [
- RoundtripTest(module, params),
- IVLengthTest(module, params),
- NoDefaultECBTest(module, params),
- ByteArrayTest(module, params),
- BlockSizeTest(module, params),
- ]
- extra_tests_added = True
-
- # Add the current test to the test suite
- tests.append(CipherSelfTest(module, params))
-
- return tests
-
-def make_stream_tests(module, module_name, test_data):
- tests = []
- extra_tests_added = False
- for i in range(len(test_data)):
- row = test_data[i]
-
- # Build the "params" dictionary
- params = {}
- if len(row) == 3:
- (params['plaintext'], params['ciphertext'], params['key']) = row
- elif len(row) == 4:
- (params['plaintext'], params['ciphertext'], params['key'], params['description']) = row
- elif len(row) == 5:
- (params['plaintext'], params['ciphertext'], params['key'], params['description'], extra_params) = row
- params.update(extra_params)
- else:
- raise AssertionError("Unsupported tuple size %d" % (len(row),))
-
- # Build the display-name for the test
- p2 = params.copy()
- p_key = _extract(p2, 'key')
- p_plaintext = _extract(p2, 'plaintext')
- p_ciphertext = _extract(p2, 'ciphertext')
- p_description = _extract(p2, 'description', None)
-
- if p_description is not None:
- description = p_description
- elif not p2:
- description = "p=%s, k=%s" % (p_plaintext, p_key)
- else:
- description = "p=%s, k=%s, %r" % (p_plaintext, p_key, p2)
- name = "%s #%d: %s" % (module_name, i+1, description)
- params['description'] = name
- params['module_name'] = module_name
-
- # Add extra test(s) to the test suite before the current test
- if not extra_tests_added:
- tests += [
- ByteArrayTest(module, params),
- ]
-
- tests.append(MemoryviewTest(module, params))
- extra_tests_added = True
-
- # Add the test to the test suite
- tests.append(CipherSelfTest(module, params))
- tests.append(CipherStreamingSelfTest(module, params))
- return tests
-
-# vim:set ts=4 sw=4 sts=4 expandtab:
diff --git a/spaces/arxify/RVC-beta-v2-0618/runtime/Lib/site-packages/Cython/Plex/DFA.py b/spaces/arxify/RVC-beta-v2-0618/runtime/Lib/site-packages/Cython/Plex/DFA.py
deleted file mode 100644
index 76324621fcaec820d0d561d2f1beae6f614451d9..0000000000000000000000000000000000000000
--- a/spaces/arxify/RVC-beta-v2-0618/runtime/Lib/site-packages/Cython/Plex/DFA.py
+++ /dev/null
@@ -1,164 +0,0 @@
-#=======================================================================
-#
-# Python Lexical Analyser
-#
-# Converting NFA to DFA
-#
-#=======================================================================
-
-from __future__ import absolute_import
-
-from . import Machines
-from .Machines import LOWEST_PRIORITY
-from .Transitions import TransitionMap
-
-
-def nfa_to_dfa(old_machine, debug=None):
- """
- Given a nondeterministic Machine, return a new equivalent
- Machine which is deterministic.
- """
- # We build a new machine whose states correspond to sets of states
- # in the old machine. Initially we add a new state corresponding to
- # the epsilon-closure of each initial old state. Then we give transitions
- # to each new state which are the union of all transitions out of any
- # of the corresponding old states. The new state reached on a given
- # character is the one corresponding to the set of states reachable
- # on that character from any of the old states. As new combinations of
- # old states are created, new states are added as needed until closure
- # is reached.
- new_machine = Machines.FastMachine()
- state_map = StateMap(new_machine)
- # Seed the process using the initial states of the old machine.
- # Make the corresponding new states into initial states of the new
- # machine with the same names.
- for (key, old_state) in old_machine.initial_states.items():
- new_state = state_map.old_to_new(epsilon_closure(old_state))
- new_machine.make_initial_state(key, new_state)
- # Tricky bit here: we add things to the end of this list while we're
- # iterating over it. The iteration stops when closure is achieved.
- for new_state in new_machine.states:
- transitions = TransitionMap()
- for old_state in state_map.new_to_old(new_state):
- for event, old_target_states in old_state.transitions.items():
- if event and old_target_states:
- transitions.add_set(event, set_epsilon_closure(old_target_states))
- for event, old_states in transitions.items():
- new_machine.add_transitions(new_state, event, state_map.old_to_new(old_states))
- if debug:
- debug.write("\n===== State Mapping =====\n")
- state_map.dump(debug)
- return new_machine
-
-
-def set_epsilon_closure(state_set):
- """
- Given a set of states, return the union of the epsilon
- closures of its member states.
- """
- result = {}
- for state1 in state_set:
- for state2 in epsilon_closure(state1):
- result[state2] = 1
- return result
-
-
-def epsilon_closure(state):
- """
- Return the set of states reachable from the given state
- by epsilon moves.
- """
- # Cache the result
- result = state.epsilon_closure
- if result is None:
- result = {}
- state.epsilon_closure = result
- add_to_epsilon_closure(result, state)
- return result
-
-
-def add_to_epsilon_closure(state_set, state):
- """
- Recursively add to |state_set| states reachable from the given state
- by epsilon moves.
- """
- if not state_set.get(state, 0):
- state_set[state] = 1
- state_set_2 = state.transitions.get_epsilon()
- if state_set_2:
- for state2 in state_set_2:
- add_to_epsilon_closure(state_set, state2)
-
-
-class StateMap(object):
- """
- Helper class used by nfa_to_dfa() to map back and forth between
- sets of states from the old machine and states of the new machine.
- """
- new_machine = None # Machine
- old_to_new_dict = None # {(old_state,...) : new_state}
- new_to_old_dict = None # {id(new_state) : old_state_set}
-
- def __init__(self, new_machine):
- self.new_machine = new_machine
- self.old_to_new_dict = {}
- self.new_to_old_dict = {}
-
- def old_to_new(self, old_state_set):
- """
- Return the state of the new machine corresponding to the
- set of old machine states represented by |state_set|. A new
- state will be created if necessary. If any of the old states
- are accepting states, the new state will be an accepting state
- with the highest priority action from the old states.
- """
- key = self.make_key(old_state_set)
- new_state = self.old_to_new_dict.get(key, None)
- if not new_state:
- action = self.highest_priority_action(old_state_set)
- new_state = self.new_machine.new_state(action)
- self.old_to_new_dict[key] = new_state
- self.new_to_old_dict[id(new_state)] = old_state_set
- #for old_state in old_state_set.keys():
- #new_state.merge_actions(old_state)
- return new_state
-
- def highest_priority_action(self, state_set):
- best_action = None
- best_priority = LOWEST_PRIORITY
- for state in state_set:
- priority = state.action_priority
- if priority > best_priority:
- best_action = state.action
- best_priority = priority
- return best_action
-
- # def old_to_new_set(self, old_state_set):
- # """
- # Return the new state corresponding to a set of old states as
- # a singleton set.
- # """
- # return {self.old_to_new(old_state_set):1}
-
- def new_to_old(self, new_state):
- """Given a new state, return a set of corresponding old states."""
- return self.new_to_old_dict[id(new_state)]
-
- def make_key(self, state_set):
- """
- Convert a set of states into a uniquified
- sorted tuple suitable for use as a dictionary key.
- """
- lst = list(state_set)
- lst.sort()
- return tuple(lst)
-
- def dump(self, file):
- from .Transitions import state_set_str
-
- for new_state in self.new_machine.states:
- old_state_set = self.new_to_old_dict[id(new_state)]
- file.write(" State %s <-- %s\n" % (
- new_state['number'], state_set_str(old_state_set)))
-
-
diff --git a/spaces/arxify/RVC-beta-v2-0618/runtime/Lib/site-packages/fairseq/distributed/fully_sharded_data_parallel.py b/spaces/arxify/RVC-beta-v2-0618/runtime/Lib/site-packages/fairseq/distributed/fully_sharded_data_parallel.py
deleted file mode 100644
index 88dc698b4d14db5b1bb694cab86ccac4d16d555b..0000000000000000000000000000000000000000
--- a/spaces/arxify/RVC-beta-v2-0618/runtime/Lib/site-packages/fairseq/distributed/fully_sharded_data_parallel.py
+++ /dev/null
@@ -1,135 +0,0 @@
-# Copyright (c) Facebook, Inc. and its affiliates.
-#
-# This source code is licensed under the MIT license found in the
-# LICENSE file in the root directory of this source tree.
-
-import contextlib
-from typing import Optional
-
-import torch
-from fairseq.dataclass.configs import DistributedTrainingConfig
-from fairseq.distributed import utils as dist_utils
-
-
-try:
- from fairscale.nn.data_parallel import FullyShardedDataParallel as FSDP
-
- has_FSDP = True
-except ImportError:
- FSDP = torch.nn.Module
- has_FSDP = False
-
-
-class FullyShardedDataParallel(FSDP):
- """
- A small wrapper around fairscale's FullyShardedDataParallel (FSDP) with some
- fairseq-specific checkpoint saving/loading logic.
-
- Args:
- use_sharded_state (bool): if True, then ``state_dict`` will return
- ``FSDP.local_state_dict`` and ``load_state_dict`` will call
- ``FSDP.load_local_state_dict``. Otherwise, ``state_dict`` will
- return the full model weights on data parallel rank 0 (empty on
- other ranks) and ``load_state_dict`` will broadcast model weights
- from rank 0 to other ranks.
- """
-
- def __init__(self, *args, use_sharded_state: bool = False, **kwargs):
- if not has_FSDP:
- raise ImportError(
- "Cannot find FullyShardedDataParallel. "
- "Please install fairscale with: pip install fairscale"
- )
- super().__init__(*args, **kwargs)
- self.use_sharded_state = use_sharded_state
-
- @property
- def unwrapped_module(self) -> torch.nn.Module:
- if self.flatten_parameters:
- return self.module.module
- else:
- return self.module
-
- def state_dict(self, destination=None, prefix="", keep_vars=False):
- if self.use_sharded_state:
- return super().local_state_dict(
- destination=destination, prefix=prefix, keep_vars=keep_vars
- )
- else:
- if self.rank == 0:
- return super().state_dict(
- destination=destination, prefix=prefix, keep_vars=keep_vars
- )
- else:
- # We must call state_dict() due to use of communication
- # primitives. But we don't use the result.
- super().state_dict()
- return destination or {}
-
- def load_state_dict(self, state_dict, strict=True, model_cfg=None):
- if self.use_sharded_state:
- return super().load_local_state_dict(state_dict, strict=strict)
- else:
- state_dict = dist_utils.broadcast_object(
- state_dict, src_rank=0, group=self.process_group
- )
- return super().load_state_dict(state_dict, strict=strict)
-
-
-@contextlib.contextmanager
-def fsdp_enable_wrap(cfg: DistributedTrainingConfig):
- try:
- from fairscale.nn import enable_wrap
- except ImportError:
- raise ImportError(
- "Cannot find FullyShardedDataParallel. "
- "Please install fairscale with: pip install fairscale"
- )
- if cfg.memory_efficient_fp16:
- assert cfg.fp16 # memory_efficient_fp16 should imply fp16
- group = dist_utils.get_data_parallel_group()
- if group is None and cfg.distributed_world_size == 1:
- from fairscale.utils.testing import DummyProcessGroup
-
- group = DummyProcessGroup(rank=0, size=1)
- fsdp_config = {
- "process_group": group,
- "reshard_after_forward": not cfg.no_reshard_after_forward,
- "mixed_precision": cfg.fp16 and not cfg.memory_efficient_fp16,
- "fp32_reduce_scatter": cfg.fp32_reduce_scatter,
- "flatten_parameters": not cfg.not_fsdp_flatten_parameters,
- "cpu_offload": cfg.cpu_offload,
- "compute_dtype": torch.float16 if cfg.fp16 else torch.float32,
- "bucket_cap_mb": cfg.bucket_cap_mb,
- "state_dict_device": torch.device("cpu"), # reduce GPU mem usage
- }
- with enable_wrap(
- wrapper_cls=FullyShardedDataParallel,
- use_sharded_state=cfg.use_sharded_state,
- **fsdp_config,
- ):
- yield
-
-
-def fsdp_wrap(module, min_num_params: Optional[int] = None, **kwargs):
- """
- Helper to wrap layers/modules in FSDP. This falls back to a no-op if
- fairscale is not available.
-
- Args:
- module (nn.Module): module to (maybe) wrap
- min_num_params (int, Optional): minimum number of layer params to wrap
- """
- try:
- from fairscale.nn import wrap
-
- if min_num_params is not None:
- num_params = sum(p.numel() for p in module.parameters())
- if num_params >= min_num_params:
- return wrap(module, **kwargs)
- else:
- return module
- else:
- return wrap(module, **kwargs)
- except ImportError:
- return module
diff --git a/spaces/ashzzf/vits-uma-genshin-honkai/commons.py b/spaces/ashzzf/vits-uma-genshin-honkai/commons.py
deleted file mode 100644
index 40fcc05364d4815971f5c6f9dbb8dcef8e3ec1e9..0000000000000000000000000000000000000000
--- a/spaces/ashzzf/vits-uma-genshin-honkai/commons.py
+++ /dev/null
@@ -1,172 +0,0 @@
-import math
-import torch
-from torch.nn import functional as F
-import torch.jit
-
-
-def script_method(fn, _rcb=None):
- return fn
-
-
-def script(obj, optimize=True, _frames_up=0, _rcb=None):
- return obj
-
-
-torch.jit.script_method = script_method
-torch.jit.script = script
-
-
-def init_weights(m, mean=0.0, std=0.01):
- classname = m.__class__.__name__
- if classname.find("Conv") != -1:
- m.weight.data.normal_(mean, std)
-
-
-def get_padding(kernel_size, dilation=1):
- return int((kernel_size*dilation - dilation)/2)
-
-
-def convert_pad_shape(pad_shape):
- l = pad_shape[::-1]
- pad_shape = [item for sublist in l for item in sublist]
- return pad_shape
-
-
-def intersperse(lst, item):
- result = [item] * (len(lst) * 2 + 1)
- result[1::2] = lst
- return result
-
-
-def kl_divergence(m_p, logs_p, m_q, logs_q):
- """KL(P||Q)"""
- kl = (logs_q - logs_p) - 0.5
- kl += 0.5 * (torch.exp(2. * logs_p) + ((m_p - m_q)**2)) * torch.exp(-2. * logs_q)
- return kl
-
-
-def rand_gumbel(shape):
- """Sample from the Gumbel distribution, protect from overflows."""
- uniform_samples = torch.rand(shape) * 0.99998 + 0.00001
- return -torch.log(-torch.log(uniform_samples))
-
-
-def rand_gumbel_like(x):
- g = rand_gumbel(x.size()).to(dtype=x.dtype, device=x.device)
- return g
-
-
-def slice_segments(x, ids_str, segment_size=4):
- ret = torch.zeros_like(x[:, :, :segment_size])
- for i in range(x.size(0)):
- idx_str = ids_str[i]
- idx_end = idx_str + segment_size
- ret[i] = x[i, :, idx_str:idx_end]
- return ret
-
-
-def rand_slice_segments(x, x_lengths=None, segment_size=4):
- b, d, t = x.size()
- if x_lengths is None:
- x_lengths = t
- ids_str_max = x_lengths - segment_size + 1
- ids_str = (torch.rand([b]).to(device=x.device) * ids_str_max).to(dtype=torch.long)
- ret = slice_segments(x, ids_str, segment_size)
- return ret, ids_str
-
-
-def get_timing_signal_1d(
- length, channels, min_timescale=1.0, max_timescale=1.0e4):
- position = torch.arange(length, dtype=torch.float)
- num_timescales = channels // 2
- log_timescale_increment = (
- math.log(float(max_timescale) / float(min_timescale)) /
- (num_timescales - 1))
- inv_timescales = min_timescale * torch.exp(
- torch.arange(num_timescales, dtype=torch.float) * -log_timescale_increment)
- scaled_time = position.unsqueeze(0) * inv_timescales.unsqueeze(1)
- signal = torch.cat([torch.sin(scaled_time), torch.cos(scaled_time)], 0)
- signal = F.pad(signal, [0, 0, 0, channels % 2])
- signal = signal.view(1, channels, length)
- return signal
-
-
-def add_timing_signal_1d(x, min_timescale=1.0, max_timescale=1.0e4):
- b, channels, length = x.size()
- signal = get_timing_signal_1d(length, channels, min_timescale, max_timescale)
- return x + signal.to(dtype=x.dtype, device=x.device)
-
-
-def cat_timing_signal_1d(x, min_timescale=1.0, max_timescale=1.0e4, axis=1):
- b, channels, length = x.size()
- signal = get_timing_signal_1d(length, channels, min_timescale, max_timescale)
- return torch.cat([x, signal.to(dtype=x.dtype, device=x.device)], axis)
-
-
-def subsequent_mask(length):
- mask = torch.tril(torch.ones(length, length)).unsqueeze(0).unsqueeze(0)
- return mask
-
-
-@torch.jit.script
-def fused_add_tanh_sigmoid_multiply(input_a, input_b, n_channels):
- n_channels_int = n_channels[0]
- in_act = input_a + input_b
- t_act = torch.tanh(in_act[:, :n_channels_int, :])
- s_act = torch.sigmoid(in_act[:, n_channels_int:, :])
- acts = t_act * s_act
- return acts
-
-
-def convert_pad_shape(pad_shape):
- l = pad_shape[::-1]
- pad_shape = [item for sublist in l for item in sublist]
- return pad_shape
-
-
-def shift_1d(x):
- x = F.pad(x, convert_pad_shape([[0, 0], [0, 0], [1, 0]]))[:, :, :-1]
- return x
-
-
-def sequence_mask(length, max_length=None):
- if max_length is None:
- max_length = length.max()
- x = torch.arange(max_length, dtype=length.dtype, device=length.device)
- return x.unsqueeze(0) < length.unsqueeze(1)
-
-
-def generate_path(duration, mask):
- """
- duration: [b, 1, t_x]
- mask: [b, 1, t_y, t_x]
- """
- device = duration.device
-
- b, _, t_y, t_x = mask.shape
- cum_duration = torch.cumsum(duration, -1)
-
- cum_duration_flat = cum_duration.view(b * t_x)
- path = sequence_mask(cum_duration_flat, t_y).to(mask.dtype)
- path = path.view(b, t_x, t_y)
- path = path - F.pad(path, convert_pad_shape([[0, 0], [1, 0], [0, 0]]))[:, :-1]
- path = path.unsqueeze(1).transpose(2,3) * mask
- return path
-
-
-def clip_grad_value_(parameters, clip_value, norm_type=2):
- if isinstance(parameters, torch.Tensor):
- parameters = [parameters]
- parameters = list(filter(lambda p: p.grad is not None, parameters))
- norm_type = float(norm_type)
- if clip_value is not None:
- clip_value = float(clip_value)
-
- total_norm = 0
- for p in parameters:
- param_norm = p.grad.data.norm(norm_type)
- total_norm += param_norm.item() ** norm_type
- if clip_value is not None:
- p.grad.data.clamp_(min=-clip_value, max=clip_value)
- total_norm = total_norm ** (1. / norm_type)
- return total_norm
diff --git a/spaces/awacke1/PoetandKnowIt/app.py b/spaces/awacke1/PoetandKnowIt/app.py
deleted file mode 100644
index e715907e3b07d5018948b9467e985b66bf55f19c..0000000000000000000000000000000000000000
--- a/spaces/awacke1/PoetandKnowIt/app.py
+++ /dev/null
@@ -1,33 +0,0 @@
-import emoji
-
-poem = """
-In the land of code where the streamlit gleams,
-A tale of an inbox, a place for dreams.
-Messages fluttered like leaves on the wind,
-Replying with wisdom, friendships begin.
-
-In this digital haven, hearts intertwined,
-Through lines of poetry, secrets unwind.
-In the realm of streamlit, love's code is designed.
-"""
-
-emojis_to_use = {
- 'code': ':computer:',
- 'streamlit': ':sparkles:',
- 'inbox': ':inbox_tray:',
- 'dreams': ':cloud:',
- 'messages': ':email:',
- 'wind': ':dash:',
- 'wisdom': ':owl:',
- 'friendships': ':people_holding_hands:',
- 'digital': ':satellite:',
- 'hearts': ':heartpulse:',
- 'poetry': ':scroll:',
- 'secrets': ':key:',
- 'love': ':heart:'
-}
-
-for word, emoji_code in emojis_to_use.items():
- poem = poem.replace(word, emoji.emojize(emoji_code, use_aliases=True))
-
-print(poem)
diff --git a/spaces/awacke1/Search_Streamlit/app.py b/spaces/awacke1/Search_Streamlit/app.py
deleted file mode 100644
index 12da2add760ca1f503368371f07748774e043859..0000000000000000000000000000000000000000
--- a/spaces/awacke1/Search_Streamlit/app.py
+++ /dev/null
@@ -1,209 +0,0 @@
-import time
-import re
-import pandas as pd
-import numpy as np
-import torch
-import torch.nn.functional as F
-from transformers import AutoTokenizer, AutoModel
-from tokenizers import Tokenizer, AddedToken
-import streamlit as st
-from st_click_detector import click_detector
-
-# This lil dealio is my test of the new experiemntal primitives which promise to put cach in streamlit within striking distance of simulating cognitive episodic memory (personalized feelings about a moment through space time), and semantic memory (factual memories we are ready to share and communicate like your email address or physical address yo
-# Goal of this is to solve AI problem of two types of memory and their part in cognitive AGI along with the theory of model making as functional design of intelligence :
-# Type 1 Memory - Semantic Memory:
-# Semantic memory is conscious long-term memory for meaning, understanding, and conceptual facts about the world. Semantic memory is one of the two main varieties of explicit, conscious, long-term memory, which is memory that can be retrieved into conscious awareness after a long delay (from several seconds to years).
-# Type 2 Memory - Episodic Memory:
-# Episodic memory refers to the conscious recollection of a personal experience that contains information on what has happened and also where and when it happened. Recollection from episodic memory also implies a kind of first-person subjectivity that has been termed autonoetic consciousness.
-# Functional Design of Intelligence: The brain uses map like structures to build a models repeatedly as part of LTM and STM memory by creating hundreds of thousands of models of everything we know. This allows us to answer important questions about how we perceive the world, why we have a sense of self, and the origin of higher level thought processes.
-# Research Interests: AGI and ML Pipelines, Ambient IoT AI, Behavior Cognitive and Memory AI, Clinical Medical and Nursing AI, Genomics AI, GAN Gaming GAIL AR VR XR and Simulation AI, Graph Ontology KR KE AI, Languages and NLP AI, Quantum Compute GPU TPU NPU AI, Vision Image Document and Audio/Video AI
-# Layman terms for interest with keyword intersection for plot search.
-
-
-# callback to update query param on selectbox change
-def update_params():
- try:
- print("update1")
- #st.experimental_set_query_params(option=st.session_state.query)
- except ValueError:
- pass
-
-# RADIO BUTTON SET PERSIST
-# radio button persistance - plan is to hydrate when selected and change url along with textbox and search
-options = ["artificial intelligence", "robot", "VR", "medicine", "genomics", "cure", "heal", "brain", "support", "friendship", "memory", "aging", "pharma", "virus", "nurse", "doctor", "therapist", "nutrition", "technology", "computer", "software", "neuroscience", "birth", "death", "soul", "space", "sci-fi"] # these options come from my research interests blended with keywords across film genres
-
-query_params = st.experimental_get_query_params()
-ix = 0
-if query_params:
- try:
- q0 = query_params['query'][0]
- ix = options.index(q0)
- except ValueError:
- pass
-selected_option = st.radio(
- "Param", options, index=ix, key="query", on_change=update_params
-)
-st.write("", unsafe_allow_html=True)
-
-
-st.experimental_set_query_params(option=selected_option)
-
-try:
- st.session_state.query = query # if set already above. this prevents two interface elements setting it first time once
-except: # catch exception and set query param to predefined value
- print("Error cant set after init")
-
-
-# Text Input, check the query params set the text input to query value if in session
-# check if here for the first time then set the query
-if 'query' not in st.session_state:
- #st.session_state['query'] = 'AI'
- query = st.text_input("", value="artificial intelligence", key="query")
- #st.session_state.query = 'AI'
- #st.write(st.session_state.query)
-else:
- query = st.text_input("", value=st.session_state["query"], key="query")
-try:
- query_params = st.experimental_get_query_params()
- query_option = query_params['query'][0] #throws an exception when visiting http://host:port
- option_selected = st.sidebar.selectbox('Pick option', options, index=options.index(query_option))
-except: # catch exception and set query param to predefined value
- st.experimental_set_query_params(query="health") # set default
- query_params = st.experimental_get_query_params()
- query_option = query_params['query'][0]
- query_option = "ai"
-
-DEVICE = "cpu"
-MODEL_OPTIONS = ["msmarco-distilbert-base-tas-b", "all-mpnet-base-v2"]
-DESCRIPTION = """
-# Semantic search
-**Enter your query and hit enter**
-Built with 🤗 Hugging Face's [transformers](https://huggingface.co/transformers/) library, [SentenceBert](https://www.sbert.net/) models, [Streamlit](https://streamlit.io/) and 44k movie descriptions from the Kaggle [Movies Dataset](https://www.kaggle.com/rounakbanik/the-movies-dataset)
-"""
-
-# Session state - search parms
-if 'key' not in st.session_state:
- st.session_state['key'] = 'value'
-if 'key' not in st.session_state:
- st.session_state.key = 'value'
-st.write(st.session_state.key)
-st.write(st.session_state)
-
-#st.session_state
-for key in st.session_state.keys():
- del st.session_state[key]
-#st.text_input("Your name", key="name")
-#st.session_state.name
-
-@st.cache(
- show_spinner=False,
- hash_funcs={
- AutoModel: lambda _: None,
- AutoTokenizer: lambda _: None,
- dict: lambda _: None,
- },
-)
-def load():
- models, tokenizers, embeddings = [], [], []
- for model_option in MODEL_OPTIONS:
- tokenizers.append(
- AutoTokenizer.from_pretrained(f"sentence-transformers/{model_option}")
- )
- models.append(
- AutoModel.from_pretrained(f"sentence-transformers/{model_option}").to(
- DEVICE
- )
- )
- embeddings.append(np.load("embeddings.npy"))
- embeddings.append(np.load("embeddings2.npy"))
- df = pd.read_csv("movies.csv")
- return tokenizers, models, embeddings, df
-
-tokenizers, models, embeddings, df = load()
-def pooling(model_output):
- return model_output.last_hidden_state[:, 0]
-
-def compute_embeddings(texts):
- encoded_input = tokenizers[0](
- texts, padding=True, truncation=True, return_tensors="pt"
- ).to(DEVICE)
-
- with torch.no_grad():
- model_output = models[0](**encoded_input, return_dict=True)
-
- embeddings = pooling(model_output)
- return embeddings.cpu().numpy()
-
-def pooling2(model_output, attention_mask):
- token_embeddings = model_output[0]
- input_mask_expanded = (
- attention_mask.unsqueeze(-1).expand(token_embeddings.size()).float()
- )
- return torch.sum(token_embeddings * input_mask_expanded, 1) / torch.clamp(
- input_mask_expanded.sum(1), min=1e-9
- )
-
-def compute_embeddings2(list_of_strings):
- encoded_input = tokenizers[1](
- list_of_strings, padding=True, truncation=True, return_tensors="pt"
- ).to(DEVICE)
- with torch.no_grad():
- model_output = models[1](**encoded_input)
- sentence_embeddings = pooling2(model_output, encoded_input["attention_mask"])
- return F.normalize(sentence_embeddings, p=2, dim=1).cpu().numpy()
-
-@st.cache(
- show_spinner=False,
- hash_funcs={Tokenizer: lambda _: None, AddedToken: lambda _: None},
-)
-def semantic_search(query, model_id):
- start = time.time()
- if len(query.strip()) == 0:
- return ""
- if "[Similar:" not in query:
- if model_id == 0:
- query_embedding = compute_embeddings([query])
- else:
- query_embedding = compute_embeddings2([query])
- else:
- match = re.match(r"\[Similar:(\d{1,5}).*", query)
- if match:
- idx = int(match.groups()[0])
- query_embedding = embeddings[model_id][idx : idx + 1, :]
- if query_embedding.shape[0] == 0:
- return ""
- else:
- return ""
- indices = np.argsort(embeddings[model_id] @ np.transpose(query_embedding)[:, 0])[
- -1:-11:-1
- ]
- if len(indices) == 0:
- return ""
- result = ""
- for i in indices:
- result += f"{df.iloc[i].title} ({df.iloc[i].release_date}). {df.iloc[i].overview} "
- #result += f"Similar movies "
- #result += f"IMDB "
- delay = "%.3f" % (time.time() - start)
- return f"Computation time: {delay} seconds
{result} "
-
-st.sidebar.markdown(DESCRIPTION)
-
-model_choice = st.sidebar.selectbox("Similarity model", options=MODEL_OPTIONS)
-model_id = 0 if model_choice == MODEL_OPTIONS[0] else 1
-
-clicked = click_detector(semantic_search(query, model_id))
-
-if clicked != "":
- st.markdown(clicked)
- change_query = False
- if "last_clicked" not in st.session_state:
- st.session_state["last_clicked"] = clicked
- change_query = True
- else:
- if clicked != st.session_state["last_clicked"]:
- st.session_state["last_clicked"] = clicked
- change_query = True
- if change_query:
- st.session_state["query"] = f"[Similar:{clicked}] {df.iloc[int(clicked)].title}"
- st.experimental_rerun()
diff --git a/spaces/awacke1/VideoSwap/README.md b/spaces/awacke1/VideoSwap/README.md
deleted file mode 100644
index 658b03c049132a1a03fe089e802d3af07b742c44..0000000000000000000000000000000000000000
--- a/spaces/awacke1/VideoSwap/README.md
+++ /dev/null
@@ -1,13 +0,0 @@
----
-title: 🦄VideoSwap🦙
-emoji: 🦄🦙
-colorFrom: green
-colorTo: gray
-sdk: gradio
-sdk_version: 3.0.22
-app_file: app.py
-pinned: false
-license: mit
----
-
-Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
diff --git a/spaces/banana-projects/web3d/node_modules/three/examples/js/loaders/AWDLoader.js b/spaces/banana-projects/web3d/node_modules/three/examples/js/loaders/AWDLoader.js
deleted file mode 100644
index 5bb0c03c5c9121aec07ffd444120d8c175b4f3ae..0000000000000000000000000000000000000000
--- a/spaces/banana-projects/web3d/node_modules/three/examples/js/loaders/AWDLoader.js
+++ /dev/null
@@ -1,1239 +0,0 @@
-/**
- * Author: Pierre Lepers
- * Date: 09/12/2013 17:21
- */
-
-( function () {
-
- var UNCOMPRESSED = 0,
- DEFLATE = 1,
- LZMA = 2,
-
- AWD_FIELD_INT8 = 1,
- AWD_FIELD_INT16 = 2,
- AWD_FIELD_INT32 = 3,
- AWD_FIELD_UINT8 = 4,
- AWD_FIELD_UINT16 = 5,
- AWD_FIELD_UINT32 = 6,
- AWD_FIELD_FLOAT32 = 7,
- AWD_FIELD_FLOAT64 = 8,
- AWD_FIELD_BOOL = 21,
- AWD_FIELD_COLOR = 22,
- AWD_FIELD_BADDR = 23,
- AWD_FIELD_STRING = 31,
- AWD_FIELD_BYTEARRAY = 32,
- AWD_FIELD_VECTOR2x1 = 41,
- AWD_FIELD_VECTOR3x1 = 42,
- AWD_FIELD_VECTOR4x1 = 43,
- AWD_FIELD_MTX3x2 = 44,
- AWD_FIELD_MTX3x3 = 45,
- AWD_FIELD_MTX4x3 = 46,
- AWD_FIELD_MTX4x4 = 47,
-
- BOOL = 21,
- COLOR = 22,
- BADDR = 23,
-
- INT8 = 1,
- INT16 = 2,
- INT32 = 3,
- UINT8 = 4,
- UINT16 = 5,
- UINT32 = 6,
- FLOAT32 = 7,
- FLOAT64 = 8;
-
- var littleEndian = true;
-
- function Block() {
-
- this.id = 0;
- this.data = null;
-
- }
-
- function AWDProperties() {}
-
- AWDProperties.prototype = {
- set: function ( key, value ) {
-
- this[ key ] = value;
-
- },
-
- get: function ( key, fallback ) {
-
- if ( this.hasOwnProperty( key ) ) {
-
- return this[ key ];
-
- } else {
-
- return fallback;
-
- }
-
- }
- };
-
- THREE.AWDLoader = function ( manager ) {
-
- this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager;
-
- this.trunk = new THREE.Object3D();
-
- this.materialFactory = undefined;
-
- this._url = '';
- this._baseDir = '';
-
- this._data = undefined;
- this._ptr = 0;
-
- this._version = [];
- this._streaming = false;
- this._optimized_for_accuracy = false;
- this._compression = 0;
- this._bodylen = 0xFFFFFFFF;
-
- this._blocks = [ new Block() ];
-
- this._accuracyMatrix = false;
- this._accuracyGeo = false;
- this._accuracyProps = false;
-
- };
-
- THREE.AWDLoader.prototype = {
-
- constructor: THREE.AWDLoader,
-
- load: function ( url, onLoad, onProgress, onError ) {
-
- var scope = this;
-
- this._url = url;
- this._baseDir = url.substr( 0, url.lastIndexOf( '/' ) + 1 );
-
- var loader = new THREE.FileLoader( this.manager );
- loader.setPath( this.path );
- loader.setResponseType( 'arraybuffer' );
- loader.load( url, function ( text ) {
-
- onLoad( scope.parse( text ) );
-
- }, onProgress, onError );
-
- },
-
- setPath: function ( value ) {
-
- this.path = value;
- return this;
-
- },
-
- parse: function ( data ) {
-
- var blen = data.byteLength;
-
- this._ptr = 0;
- this._data = new DataView( data );
-
- this._parseHeader( );
-
- if ( this._compression != 0 ) {
-
- console.error( 'compressed AWD not supported' );
-
- }
-
- if ( ! this._streaming && this._bodylen != data.byteLength - this._ptr ) {
-
- console.error( 'AWDLoader: body len does not match file length', this._bodylen, blen - this._ptr );
-
- }
-
- while ( this._ptr < blen ) {
-
- this.parseNextBlock();
-
- }
-
- return this.trunk;
-
- },
-
- parseNextBlock: function () {
-
- var assetData,
- ns, type, len, block,
- blockId = this.readU32(),
- ns = this.readU8(),
- type = this.readU8(),
- flags = this.readU8(),
- len = this.readU32();
-
-
- switch ( type ) {
-
- case 1:
- assetData = this.parseMeshData( len );
- break;
-
- case 22:
- assetData = this.parseContainer( len );
- break;
-
- case 23:
- assetData = this.parseMeshInstance( len );
- break;
-
- case 81:
- assetData = this.parseMaterial( len );
- break;
-
- case 82:
- assetData = this.parseTexture( len );
- break;
-
- case 101:
- assetData = this.parseSkeleton( len );
- break;
-
- // case 111:
- // assetData = this.parseMeshPoseAnimation(len, true);
- // break;
-
- case 112:
- assetData = this.parseMeshPoseAnimation( len, false );
- break;
-
- case 113:
- assetData = this.parseVertexAnimationSet( len );
- break;
-
- case 102:
- assetData = this.parseSkeletonPose( len );
- break;
-
- case 103:
- assetData = this.parseSkeletonAnimation( len );
- break;
-
- case 122:
- assetData = this.parseAnimatorSet( len );
- break;
-
- // case 121:
- // assetData = parseUVAnimation(len);
- // break;
-
- default:
- //debug('Ignoring block!',type, len);
- this._ptr += len;
- break;
-
- }
-
-
- // Store block reference for later use
- this._blocks[ blockId ] = block = new Block();
- block.data = assetData;
- block.id = blockId;
-
-
- },
-
- _parseHeader: function () {
-
- var version = this._version,
- awdmagic = ( this.readU8() << 16 ) | ( this.readU8() << 8 ) | this.readU8();
-
- if ( awdmagic != 4282180 )
- throw new Error( "AWDLoader - bad magic" );
-
- version[ 0 ] = this.readU8();
- version[ 1 ] = this.readU8();
-
- var flags = this.readU16();
-
- this._streaming = ( flags & 0x1 ) == 0x1;
-
- if ( ( version[ 0 ] === 2 ) && ( version[ 1 ] === 1 ) ) {
-
- this._accuracyMatrix = ( flags & 0x2 ) === 0x2;
- this._accuracyGeo = ( flags & 0x4 ) === 0x4;
- this._accuracyProps = ( flags & 0x8 ) === 0x8;
-
- }
-
- this._geoNrType = this._accuracyGeo ? FLOAT64 : FLOAT32;
- this._matrixNrType = this._accuracyMatrix ? FLOAT64 : FLOAT32;
- this._propsNrType = this._accuracyProps ? FLOAT64 : FLOAT32;
-
- this._optimized_for_accuracy = ( flags & 0x2 ) === 0x2;
-
- this._compression = this.readU8();
- this._bodylen = this.readU32();
-
- },
-
- parseContainer: function ( len ) {
-
- var parent,
- ctr = new THREE.Object3D(),
- par_id = this.readU32(),
- mtx = this.parseMatrix4();
-
- ctr.name = this.readUTF();
- ctr.applyMatrix( mtx );
-
- parent = this._blocks[ par_id ].data || this.trunk;
- parent.add( ctr );
-
- this.parseProperties( {
- 1: this._matrixNrType,
- 2: this._matrixNrType,
- 3: this._matrixNrType,
- 4: UINT8
- } );
-
- ctr.extra = this.parseUserAttributes();
-
- return ctr;
-
- },
-
- parseMeshInstance: function ( len ) {
-
- var name,
- mesh, geometries, meshLen, meshes,
- par_id, data_id,
- mtx,
- materials, mat, mat_id,
- num_materials,
- parent,
- i;
-
- par_id = this.readU32();
- mtx = this.parseMatrix4();
- name = this.readUTF();
- data_id = this.readU32();
- num_materials = this.readU16();
-
- geometries = this.getBlock( data_id );
-
- materials = [];
-
- for ( i = 0; i < num_materials; i ++ ) {
-
- mat_id = this.readU32();
- mat = this.getBlock( mat_id );
- materials.push( mat );
-
- }
-
- meshLen = geometries.length;
- meshes = [];
-
- // TODO : BufferGeometry don't support "geometryGroups" for now.
- // so we create sub meshes for each groups
- if ( meshLen > 1 ) {
-
- mesh = new THREE.Object3D();
- for ( i = 0; i < meshLen; i ++ ) {
-
- var sm = new THREE.Mesh( geometries[ i ] );
- meshes.push( sm );
- mesh.add( sm );
-
- }
-
- } else {
-
- mesh = new THREE.Mesh( geometries[ 0 ] );
- meshes.push( mesh );
-
- }
-
- mesh.applyMatrix( mtx );
- mesh.name = name;
-
-
- parent = this.getBlock( par_id ) || this.trunk;
- parent.add( mesh );
-
-
- var matLen = materials.length;
- var maxLen = Math.max( meshLen, matLen );
- for ( i = 0; i < maxLen; i ++ )
- meshes[ i % meshLen ].material = materials[ i % matLen ];
-
-
- // Ignore for now
- this.parseProperties( null );
- mesh.extra = this.parseUserAttributes();
-
- return mesh;
-
- },
-
- parseMaterial: function ( len ) {
-
- var name,
- type,
- props,
- mat,
- attributes,
- finalize,
- num_methods,
- methods_parsed;
-
- name = this.readUTF();
- type = this.readU8();
- num_methods = this.readU8();
-
- //log( "AWDLoader parseMaterial ",name )
-
- // Read material numerical properties
- // (1=color, 2=bitmap url, 11=alpha_blending, 12=alpha_threshold, 13=repeat)
- props = this.parseProperties( {
- 1: AWD_FIELD_INT32,
- 2: AWD_FIELD_BADDR,
- 11: AWD_FIELD_BOOL,
- 12: AWD_FIELD_FLOAT32,
- 13: AWD_FIELD_BOOL
- } );
-
- methods_parsed = 0;
-
- while ( methods_parsed < num_methods ) {
-
- var method_type = this.readU16();
- this.parseProperties( null );
- this.parseUserAttributes();
-
- }
-
- attributes = this.parseUserAttributes();
-
- if ( this.materialFactory !== undefined ) {
-
- mat = this.materialFactory( name );
- if ( mat ) return mat;
-
- }
-
- mat = new THREE.MeshPhongMaterial();
-
- if ( type === 1 ) {
-
- // Color material
- mat.color.setHex( props.get( 1, 0xcccccc ) );
-
- } else if ( type === 2 ) {
-
- // Bitmap material
- var tex_addr = props.get( 2, 0 );
- mat.map = this.getBlock( tex_addr );
-
- }
-
- mat.extra = attributes;
- mat.alphaThreshold = props.get( 12, 0.0 );
- mat.repeat = props.get( 13, false );
-
-
- return mat;
-
- },
-
- parseTexture: function ( len ) {
-
- var name = this.readUTF(),
- type = this.readU8(),
- asset,
- data_len;
-
- // External
- if ( type === 0 ) {
-
- data_len = this.readU32();
- var url = this.readUTFBytes( data_len );
- console.log( url );
-
- asset = this.loadTexture( url );
-
- } else {
- // embed texture not supported
- }
- // Ignore for now
- this.parseProperties( null );
-
- this.parseUserAttributes();
- return asset;
-
- },
-
- loadTexture: function ( url ) {
-
- var tex = new THREE.Texture();
-
- var loader = new THREE.ImageLoader( this.manager );
-
- loader.load( this._baseDir + url, function ( image ) {
-
- tex.image = image;
- tex.needsUpdate = true;
-
- } );
-
- return tex;
-
- },
-
- parseSkeleton: function ( len ) {
-
- // Array
- var name = this.readUTF(),
- num_joints = this.readU16(),
- skeleton = [],
- joints_parsed = 0;
-
- this.parseProperties( null );
-
- while ( joints_parsed < num_joints ) {
-
- var joint, ibp;
-
- // Ignore joint id
- this.readU16();
-
- joint = new THREE.Bone();
- joint.parent = this.readU16() - 1; // 0=null in AWD
- joint.name = this.readUTF();
-
- ibp = this.parseMatrix4();
- joint.skinMatrix = ibp;
-
- // Ignore joint props/attributes for now
- this.parseProperties( null );
- this.parseUserAttributes();
-
- skeleton.push( joint );
- joints_parsed ++;
-
- }
-
- // Discard attributes for now
- this.parseUserAttributes();
-
-
- return skeleton;
-
- },
-
- parseSkeletonPose: function ( blockID ) {
-
- var name = this.readUTF();
-
- var num_joints = this.readU16();
- this.parseProperties( null );
-
- // debug( 'parse Skeleton Pose. joints : ' + num_joints);
-
- var pose = [];
-
- var joints_parsed = 0;
-
- while ( joints_parsed < num_joints ) {
-
- var joint_pose;
-
- var has_transform; //:uint;
- var mtx_data;
-
- has_transform = this.readU8();
-
- if ( has_transform === 1 ) {
-
- mtx_data = this.parseMatrix4();
-
- } else {
-
- mtx_data = new THREE.Matrix4();
-
- }
- pose[ joints_parsed ] = mtx_data;
- joints_parsed ++;
-
- }
-
- // Skip attributes for now
- this.parseUserAttributes();
-
- return pose;
-
- },
-
- parseSkeletonAnimation: function ( blockID ) {
-
- var frame_dur;
- var pose_addr;
- var pose;
-
- var name = this.readUTF();
-
- var clip = [];
-
- var num_frames = this.readU16();
- this.parseProperties( null );
-
- var frames_parsed = 0;
- var returnedArray;
-
- // debug( 'parse Skeleton Animation. frames : ' + num_frames);
-
- while ( frames_parsed < num_frames ) {
-
- pose_addr = this.readU32();
- frame_dur = this.readU16();
-
- pose = this._blocks[ pose_addr ].data;
- // debug( 'pose address ',pose[2].elements[12],pose[2].elements[13],pose[2].elements[14] );
- clip.push( {
- pose: pose,
- duration: frame_dur
- } );
-
- frames_parsed ++;
-
- }
-
- if ( clip.length === 0 ) {
-
- // debug("Could not this SkeletonClipNode, because no Frames where set.");
- return;
-
- }
- // Ignore attributes for now
- this.parseUserAttributes();
- return clip;
-
- },
-
- parseVertexAnimationSet: function ( len ) {
-
- var poseBlockAdress,
- name = this.readUTF(),
- num_frames = this.readU16(),
- props = this.parseProperties( { 1: UINT16 } ),
- frames_parsed = 0,
- skeletonFrames = [];
-
- while ( frames_parsed < num_frames ) {
-
- poseBlockAdress = this.readU32();
- skeletonFrames.push( this._blocks[ poseBlockAdress ].data );
- frames_parsed ++;
-
- }
-
- this.parseUserAttributes();
-
-
- return skeletonFrames;
-
- },
-
- parseAnimatorSet: function ( len ) {
-
- var targetMesh;
-
- var animSetBlockAdress; //:int
-
- var targetAnimationSet; //:AnimationSetBase;
- var outputString = ""; //:String = "";
- var name = this.readUTF();
- var type = this.readU16();
-
- var props = this.parseProperties( { 1: BADDR } );
-
- animSetBlockAdress = this.readU32();
- var targetMeshLength = this.readU16();
-
- var meshAdresses = []; //:Vector. = new Vector.;
-
- for ( var i = 0; i < targetMeshLength; i ++ )
- meshAdresses.push( this.readU32() );
-
- var activeState = this.readU16();
- var autoplay = Boolean( this.readU8() );
- this.parseUserAttributes();
- this.parseUserAttributes();
-
- var returnedArray;
- var targetMeshes = []; //:Vector. = new Vector.;
-
- for ( i = 0; i < meshAdresses.length; i ++ ) {
-
- // returnedArray = getAssetByID(meshAdresses[i], [AssetType.MESH]);
- // if (returnedArray[0])
- targetMeshes.push( this._blocks[ meshAdresses[ i ] ].data );
-
- }
-
- targetAnimationSet = this._blocks[ animSetBlockAdress ].data;
- var thisAnimator;
-
- if ( type == 1 ) {
-
-
- thisAnimator = {
- animationSet: targetAnimationSet,
- skeleton: this._blocks[ props.get( 1, 0 ) ].data
- };
-
- } else if ( type == 2 ) {
- // debug( "vertex Anim???");
- }
-
-
- for ( i = 0; i < targetMeshes.length; i ++ ) {
-
- targetMeshes[ i ].animator = thisAnimator;
-
- }
- // debug("Parsed a Animator: Name = " + name);
-
- return thisAnimator;
-
- },
-
- parseMeshData: function ( len ) {
-
- var name = this.readUTF(),
- num_subs = this.readU16(),
- geom,
- subs_parsed = 0,
- buffer,
- skinW, skinI,
- geometries = [];
-
- // Ignore for now
- this.parseProperties( { 1: this._geoNrType, 2: this._geoNrType } );
-
- // Loop through sub meshes
- while ( subs_parsed < num_subs ) {
-
- var sm_len, sm_end, attrib;
-
- geom = new THREE.BufferGeometry();
- geom.name = name;
- geometries.push( geom );
-
-
- sm_len = this.readU32();
- sm_end = this._ptr + sm_len;
-
-
- // Ignore for now
- this.parseProperties( { 1: this._geoNrType, 2: this._geoNrType } );
-
- // Loop through data streams
- while ( this._ptr < sm_end ) {
-
- var idx = 0,
- str_type = this.readU8(),
- str_ftype = this.readU8(),
- str_len = this.readU32(),
- str_end = str_len + this._ptr;
-
- if ( str_type === 1 ) {
-
- // VERTICES
-
- buffer = new Float32Array( ( str_len / 12 ) * 3 );
- attrib = new THREE.BufferAttribute( buffer, 3 );
-
- geom.addAttribute( 'position', attrib );
- idx = 0;
-
- while ( this._ptr < str_end ) {
-
- buffer[ idx ] = - this.readF32();
- buffer[ idx + 1 ] = this.readF32();
- buffer[ idx + 2 ] = this.readF32();
- idx += 3;
-
- }
-
- } else if ( str_type === 2 ) {
-
- // INDICES
-
- buffer = new Uint16Array( str_len / 2 );
- attrib = new THREE.BufferAttribute( buffer, 1 );
- geom.setIndex( attrib );
-
- idx = 0;
-
- while ( this._ptr < str_end ) {
-
- buffer[ idx + 1 ] = this.readU16();
- buffer[ idx ] = this.readU16();
- buffer[ idx + 2 ] = this.readU16();
- idx += 3;
-
- }
-
- } else if ( str_type === 3 ) {
-
- // UVS
-
- buffer = new Float32Array( ( str_len / 8 ) * 2 );
- attrib = new THREE.BufferAttribute( buffer, 2 );
-
- geom.addAttribute( 'uv', attrib );
- idx = 0;
-
- while ( this._ptr < str_end ) {
-
- buffer[ idx ] = this.readF32();
- buffer[ idx + 1 ] = 1.0 - this.readF32();
- idx += 2;
-
- }
-
- } else if ( str_type === 4 ) {
-
- // NORMALS
-
- buffer = new Float32Array( ( str_len / 12 ) * 3 );
- attrib = new THREE.BufferAttribute( buffer, 3 );
- geom.addAttribute( 'normal', attrib );
- idx = 0;
-
- while ( this._ptr < str_end ) {
-
- buffer[ idx ] = - this.readF32();
- buffer[ idx + 1 ] = this.readF32();
- buffer[ idx + 2 ] = this.readF32();
- idx += 3;
-
- }
-
- } else {
-
- this._ptr = str_end;
-
- }
-
- }
-
- this.parseUserAttributes();
-
- geom.computeBoundingSphere();
- subs_parsed ++;
-
- }
-
- //geom.computeFaceNormals();
-
- this.parseUserAttributes();
- //finalizeAsset(geom, name);
-
- return geometries;
-
- },
-
- parseMeshPoseAnimation: function ( len, poseOnly ) {
-
- var num_frames = 1,
- num_submeshes,
- frames_parsed,
- subMeshParsed,
- frame_dur,
- x, y, z,
-
- str_len,
- str_end,
- geom,
- subGeom,
- idx = 0,
- clip = {},
- indices,
- verts,
- num_Streams,
- streamsParsed,
- streamtypes = [],
-
- props,
- thisGeo,
- name = this.readUTF(),
- geoAdress = this.readU32();
-
- var mesh = this.getBlock( geoAdress );
-
- if ( mesh === null ) {
-
- console.log( "parseMeshPoseAnimation target mesh not found at:", geoAdress );
- return;
-
- }
-
- geom = mesh.geometry;
- geom.morphTargets = [];
-
- if ( ! poseOnly )
- num_frames = this.readU16();
-
- num_submeshes = this.readU16();
- num_Streams = this.readU16();
-
- // debug("VA num_frames : ", num_frames );
- // debug("VA num_submeshes : ", num_submeshes );
- // debug("VA numstreams : ", num_Streams );
-
- streamsParsed = 0;
- while ( streamsParsed < num_Streams ) {
-
- streamtypes.push( this.readU16() );
- streamsParsed ++;
-
- }
- props = this.parseProperties( { 1: BOOL, 2: BOOL } );
-
- clip.looping = props.get( 1, true );
- clip.stitchFinalFrame = props.get( 2, false );
-
- frames_parsed = 0;
-
- while ( frames_parsed < num_frames ) {
-
- frame_dur = this.readU16();
- subMeshParsed = 0;
-
- while ( subMeshParsed < num_submeshes ) {
-
- streamsParsed = 0;
- str_len = this.readU32();
- str_end = this._ptr + str_len;
-
- while ( streamsParsed < num_Streams ) {
-
- if ( streamtypes[ streamsParsed ] === 1 ) {
-
- //geom.addAttribute( 'morphTarget'+frames_parsed, Float32Array, str_len/12, 3 );
- var buffer = new Float32Array( str_len / 4 );
- geom.morphTargets.push( {
- array: buffer
- } );
-
- //buffer = geom.attributes['morphTarget'+frames_parsed].array
- idx = 0;
-
- while ( this._ptr < str_end ) {
-
- buffer[ idx ] = this.readF32();
- buffer[ idx + 1 ] = this.readF32();
- buffer[ idx + 2 ] = this.readF32();
- idx += 3;
-
- }
-
-
- subMeshParsed ++;
-
- } else
- this._ptr = str_end;
- streamsParsed ++;
-
- }
-
- }
-
-
- frames_parsed ++;
-
- }
-
- this.parseUserAttributes();
-
- return null;
-
- },
-
- getBlock: function ( id ) {
-
- return this._blocks[ id ].data;
-
- },
-
- parseMatrix4: function () {
-
- var mtx = new THREE.Matrix4();
- var e = mtx.elements;
-
- e[ 0 ] = this.readF32();
- e[ 1 ] = this.readF32();
- e[ 2 ] = this.readF32();
- e[ 3 ] = 0.0;
- //e[3] = 0.0;
-
- e[ 4 ] = this.readF32();
- e[ 5 ] = this.readF32();
- e[ 6 ] = this.readF32();
- //e[7] = this.readF32();
- e[ 7 ] = 0.0;
-
- e[ 8 ] = this.readF32();
- e[ 9 ] = this.readF32();
- e[ 10 ] = this.readF32();
- //e[11] = this.readF32();
- e[ 11 ] = 0.0;
-
- e[ 12 ] = - this.readF32();
- e[ 13 ] = this.readF32();
- e[ 14 ] = this.readF32();
- //e[15] = this.readF32();
- e[ 15 ] = 1.0;
- return mtx;
-
- },
-
- parseProperties: function ( expected ) {
-
- var list_len = this.readU32();
- var list_end = this._ptr + list_len;
-
- var props = new AWDProperties();
-
- if ( expected ) {
-
- while ( this._ptr < list_end ) {
-
- var key = this.readU16();
- var len = this.readU32();
- var type;
-
- if ( expected.hasOwnProperty( key ) ) {
-
- type = expected[ key ];
- props.set( key, this.parseAttrValue( type, len ) );
-
- } else {
-
- this._ptr += len;
-
- }
-
- }
-
- }
-
- return props;
-
- },
-
- parseUserAttributes: function () {
-
- // skip for now
- this._ptr = this.readU32() + this._ptr;
- return null;
-
- },
-
- parseAttrValue: function ( type, len ) {
-
- var elem_len;
- var read_func;
-
- switch ( type ) {
-
- case AWD_FIELD_INT8:
- elem_len = 1;
- read_func = this.readI8;
- break;
-
- case AWD_FIELD_INT16:
- elem_len = 2;
- read_func = this.readI16;
- break;
-
- case AWD_FIELD_INT32:
- elem_len = 4;
- read_func = this.readI32;
- break;
-
- case AWD_FIELD_BOOL:
- case AWD_FIELD_UINT8:
- elem_len = 1;
- read_func = this.readU8;
- break;
-
- case AWD_FIELD_UINT16:
- elem_len = 2;
- read_func = this.readU16;
- break;
-
- case AWD_FIELD_UINT32:
- case AWD_FIELD_BADDR:
- elem_len = 4;
- read_func = this.readU32;
- break;
-
- case AWD_FIELD_FLOAT32:
- elem_len = 4;
- read_func = this.readF32;
- break;
-
- case AWD_FIELD_FLOAT64:
- elem_len = 8;
- read_func = this.readF64;
- break;
-
- case AWD_FIELD_VECTOR2x1:
- case AWD_FIELD_VECTOR3x1:
- case AWD_FIELD_VECTOR4x1:
- case AWD_FIELD_MTX3x2:
- case AWD_FIELD_MTX3x3:
- case AWD_FIELD_MTX4x3:
- case AWD_FIELD_MTX4x4:
- elem_len = 8;
- read_func = this.readF64;
- break;
-
- }
-
- if ( elem_len < len ) {
-
- var list;
- var num_read;
- var num_elems;
-
- list = [];
- num_read = 0;
- num_elems = len / elem_len;
-
- while ( num_read < num_elems ) {
-
- list.push( read_func.call( this ) );
- num_read ++;
-
- }
-
- return list;
-
- } else {
-
- return read_func.call( this );
-
- }
-
- },
-
- readU8: function () {
-
- return this._data.getUint8( this._ptr ++ );
-
- },
- readI8: function () {
-
- return this._data.getInt8( this._ptr ++ );
-
- },
- readU16: function () {
-
- var a = this._data.getUint16( this._ptr, littleEndian );
- this._ptr += 2;
- return a;
-
- },
- readI16: function () {
-
- var a = this._data.getInt16( this._ptr, littleEndian );
- this._ptr += 2;
- return a;
-
- },
- readU32: function () {
-
- var a = this._data.getUint32( this._ptr, littleEndian );
- this._ptr += 4;
- return a;
-
- },
- readI32: function () {
-
- var a = this._data.getInt32( this._ptr, littleEndian );
- this._ptr += 4;
- return a;
-
- },
- readF32: function () {
-
- var a = this._data.getFloat32( this._ptr, littleEndian );
- this._ptr += 4;
- return a;
-
- },
- readF64: function () {
-
- var a = this._data.getFloat64( this._ptr, littleEndian );
- this._ptr += 8;
- return a;
-
- },
-
- /**
- * Converts a UTF-8 byte array to JavaScript's 16-bit Unicode.
- * @param {Array.} bytes UTF-8 byte array.
- * @return {string} 16-bit Unicode string.
- */
- readUTF: function () {
-
- var len = this.readU16();
- return this.readUTFBytes( len );
-
- },
-
- /**
- * Converts a UTF-8 byte array to JavaScript's 16-bit Unicode.
- * @param {Array.} bytes UTF-8 byte array.
- * @return {string} 16-bit Unicode string.
- */
- readUTFBytes: function ( len ) {
-
- // TODO(user): Use native implementations if/when available
- var out = [], c = 0;
-
- while ( out.length < len ) {
-
- var c1 = this._data.getUint8( this._ptr ++, littleEndian );
- if ( c1 < 128 ) {
-
- out[ c ++ ] = String.fromCharCode( c1 );
-
- } else if ( c1 > 191 && c1 < 224 ) {
-
- var c2 = this._data.getUint8( this._ptr ++, littleEndian );
- out[ c ++ ] = String.fromCharCode( ( c1 & 31 ) << 6 | c2 & 63 );
-
- } else {
-
- var c2 = this._data.getUint8( this._ptr ++, littleEndian );
- var c3 = this._data.getUint8( this._ptr ++, littleEndian );
- out[ c ++ ] = String.fromCharCode( ( c1 & 15 ) << 12 | ( c2 & 63 ) << 6 | c3 & 63 );
-
- }
-
- }
- return out.join( '' );
-
- }
-
- };
-
-} )();
diff --git a/spaces/banana-projects/web3d/node_modules/three/examples/js/shaders/HorizontalTiltShiftShader.js b/spaces/banana-projects/web3d/node_modules/three/examples/js/shaders/HorizontalTiltShiftShader.js
deleted file mode 100644
index 3114aba742fb473dc9d43fea58a3c81a2d8efb66..0000000000000000000000000000000000000000
--- a/spaces/banana-projects/web3d/node_modules/three/examples/js/shaders/HorizontalTiltShiftShader.js
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * @author alteredq / http://alteredqualia.com/
- *
- * Simple fake tilt-shift effect, modulating two pass Gaussian blur (see above) by vertical position
- *
- * - 9 samples per pass
- * - standard deviation 2.7
- * - "h" and "v" parameters should be set to "1 / width" and "1 / height"
- * - "r" parameter control where "focused" horizontal line lies
- */
-
-THREE.HorizontalTiltShiftShader = {
-
- uniforms: {
-
- "tDiffuse": { value: null },
- "h": { value: 1.0 / 512.0 },
- "r": { value: 0.35 }
-
- },
-
- vertexShader: [
-
- "varying vec2 vUv;",
-
- "void main() {",
-
- "vUv = uv;",
- "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
-
- "}"
-
- ].join( "\n" ),
-
- fragmentShader: [
-
- "uniform sampler2D tDiffuse;",
- "uniform float h;",
- "uniform float r;",
-
- "varying vec2 vUv;",
-
- "void main() {",
-
- "vec4 sum = vec4( 0.0 );",
-
- "float hh = h * abs( r - vUv.y );",
-
- "sum += texture2D( tDiffuse, vec2( vUv.x - 4.0 * hh, vUv.y ) ) * 0.051;",
- "sum += texture2D( tDiffuse, vec2( vUv.x - 3.0 * hh, vUv.y ) ) * 0.0918;",
- "sum += texture2D( tDiffuse, vec2( vUv.x - 2.0 * hh, vUv.y ) ) * 0.12245;",
- "sum += texture2D( tDiffuse, vec2( vUv.x - 1.0 * hh, vUv.y ) ) * 0.1531;",
- "sum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;",
- "sum += texture2D( tDiffuse, vec2( vUv.x + 1.0 * hh, vUv.y ) ) * 0.1531;",
- "sum += texture2D( tDiffuse, vec2( vUv.x + 2.0 * hh, vUv.y ) ) * 0.12245;",
- "sum += texture2D( tDiffuse, vec2( vUv.x + 3.0 * hh, vUv.y ) ) * 0.0918;",
- "sum += texture2D( tDiffuse, vec2( vUv.x + 4.0 * hh, vUv.y ) ) * 0.051;",
-
- "gl_FragColor = sum;",
-
- "}"
-
- ].join( "\n" )
-
-};
diff --git a/spaces/bioriAsaeru/text-to-voice/Advent Vega Apx Driver Zip [HOT].md b/spaces/bioriAsaeru/text-to-voice/Advent Vega Apx Driver Zip [HOT].md
deleted file mode 100644
index 2674d630b4c3a7b9283980cb364f618577469151..0000000000000000000000000000000000000000
--- a/spaces/bioriAsaeru/text-to-voice/Advent Vega Apx Driver Zip [HOT].md
+++ /dev/null
@@ -1,47 +0,0 @@
-
-